From 73bcff9d011ac1bed21d4be93676a3cb92309775 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Fri, 31 Jan 2025 22:39:30 -0800 Subject: [PATCH 01/29] fix 16842 (#16952) --- src/install/bun.lock.zig | 4 +- src/install/lockfile.zig | 16 +- .../__snapshots__/bun-lock.test.ts.snap | 10 + test/cli/install/bun-lock.test.ts | 66 +- .../packages/debug-1/debug-1-4.4.0.tgz | Bin 0 -> 172 bytes .../registry/packages/debug-1/package.json | 41 + .../depend-on-debug-1-1.0.0.tgz | Bin 0 -> 173 bytes .../packages/depend-on-debug-1/package.json | 41 + .../registry/packages/ms-1/ms-1-2.1.3.tgz | Bin 0 -> 140 bytes .../registry/packages/ms-1/package.json | 38 + .../registry/packages/npm-1/npm-1-10.9.2.tgz | Bin 0 -> 337 bytes .../registry/packages/npm-1/package.json | 46 + .../dev-server-ssr-100.test.ts.snap | 1068 +++++---- .../__snapshots__/dev-server.test.ts.snap | 1068 +++++---- .../__snapshots__/next-build.test.ts.snap | 2104 ++++++++++------- 15 files changed, 2869 insertions(+), 1633 deletions(-) create mode 100644 test/cli/install/registry/packages/debug-1/debug-1-4.4.0.tgz create mode 100644 test/cli/install/registry/packages/debug-1/package.json create mode 100644 test/cli/install/registry/packages/depend-on-debug-1/depend-on-debug-1-1.0.0.tgz create mode 100644 test/cli/install/registry/packages/depend-on-debug-1/package.json create mode 100644 test/cli/install/registry/packages/ms-1/ms-1-2.1.3.tgz create mode 100644 test/cli/install/registry/packages/ms-1/package.json create mode 100644 test/cli/install/registry/packages/npm-1/npm-1-10.9.2.tgz create mode 100644 test/cli/install/registry/packages/npm-1/package.json diff --git a/src/install/bun.lock.zig b/src/install/bun.lock.zig index dc37811aaac273..0265c374948b4e 100644 --- a/src/install/bun.lock.zig +++ b/src/install/bun.lock.zig @@ -1589,7 +1589,7 @@ pub fn parseIntoBinaryLockfile( } // there should be no duplicates - const pkg_id = try lockfile.appendPackageDedupe(&pkg, string_buf.bytes.items); + const pkg_id = try lockfile.appendPackageNoDedupe(&pkg, string_buf.bytes.items); const entry = try pkg_map.getOrPut(name); if (entry.found_existing) { @@ -1849,7 +1849,7 @@ pub fn parseIntoBinaryLockfile( pkg.name_hash = name_hash; pkg.resolution = res; - const pkg_id = try lockfile.appendPackageDedupe(&pkg, string_buf.bytes.items); + const pkg_id = try lockfile.appendPackageNoDedupe(&pkg, string_buf.bytes.items); const entry = try pkg_map.getOrPut(pkg_path); if (entry.found_existing) { diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index c0b15969ca4f53..edf351578f9d5e 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -2687,8 +2687,8 @@ pub fn getPackageID( return null; } -/// Appends `pkg` to `this.packages` if a duplicate isn't found -pub fn appendPackageDedupe(this: *Lockfile, pkg: *Package, buf: string) OOM!PackageID { +/// Appends `pkg` to `this.packages`, and adds to `this.package_index` +pub fn appendPackageNoDedupe(this: *Lockfile, pkg: *Package, buf: string) OOM!PackageID { const entry = try this.package_index.getOrPut(pkg.name_hash); if (!entry.found_existing) { @@ -2703,11 +2703,6 @@ pub fn appendPackageDedupe(this: *Lockfile, pkg: *Package, buf: string) OOM!Pack return switch (entry.value_ptr.*) { .id => |existing_id| { - if (pkg.resolution.eql(&resolutions[existing_id], buf, buf)) { - pkg.meta.id = existing_id; - return existing_id; - } - const new_id: PackageID = @intCast(this.packages.len); pkg.meta.id = new_id; try this.packages.append(this.allocator, pkg.*); @@ -2729,13 +2724,6 @@ pub fn appendPackageDedupe(this: *Lockfile, pkg: *Package, buf: string) OOM!Pack return new_id; }, .ids => |*existing_ids| { - for (existing_ids.items) |existing_id| { - if (pkg.resolution.eql(&resolutions[existing_id], buf, buf)) { - pkg.meta.id = existing_id; - return existing_id; - } - } - const new_id: PackageID = @intCast(this.packages.len); pkg.meta.id = new_id; try this.packages.append(this.allocator, pkg.*); diff --git a/test/cli/install/__snapshots__/bun-lock.test.ts.snap b/test/cli/install/__snapshots__/bun-lock.test.ts.snap index 6aa260f3489c69..b8c6d8e01c9abc 100644 --- a/test/cli/install/__snapshots__/bun-lock.test.ts.snap +++ b/test/cli/install/__snapshots__/bun-lock.test.ts.snap @@ -273,3 +273,13 @@ exports[`should convert a binary lockfile with invalid optional peers 1`] = ` } " `; + +exports[`should not deduplicate bundled packages with un-bundled packages 1`] = ` +[ + "", + "+ debug-1@4.4.0", + "+ npm-1@10.9.2", + "", + "3 packages installed", +] +`; diff --git a/test/cli/install/bun-lock.test.ts b/test/cli/install/bun-lock.test.ts index 64c5b28f4de390..764375bcb995b9 100644 --- a/test/cli/install/bun-lock.test.ts +++ b/test/cli/install/bun-lock.test.ts @@ -1,6 +1,6 @@ import { spawn, write, file } from "bun"; import { expect, it, beforeAll, afterAll } from "bun:test"; -import { access, copyFile, open, writeFile, exists, cp } from "fs/promises"; +import { access, copyFile, open, writeFile, exists, cp, rm } from "fs/promises"; import { bunExe, bunEnv as env, isWindows, VerdaccioRegistry, runBunInstall } from "harness"; import { join } from "path"; @@ -209,3 +209,67 @@ it("should convert a binary lockfile with invalid optional peers", async () => { expect(await exited).toBe(0); expect(await file(join(packageDir, "bun.lock")).text()).toBe(firstLockfile); }); + +it("should not deduplicate bundled packages with un-bundled packages", async () => { + const { packageDir, packageJson } = await registry.createTestDir(); + + await Promise.all([ + write( + packageJson, + JSON.stringify({ + name: "bundled-deps", + dependencies: { + "debug-1": "4.4.0", + "npm-1": "10.9.2", + }, + }), + ), + ]); + + let { exited, stdout } = spawn({ + cmd: [bunExe(), "install"], + cwd: packageDir, + env, + stdout: "pipe", + stderr: "inherit", + }); + + expect(await exited).toBe(0); + + async function checkModules() { + const res = await Promise.all([ + exists(join(packageDir, "node_modules/debug-1")), + exists(join(packageDir, "node_modules/npm-1")), + exists(join(packageDir, "node_modules/ms-1")), + ]); + expect(res).toEqual([true, true, true]); + } + + await checkModules(); + + const out1 = (await Bun.readableStreamToText(stdout)) + .replaceAll(/\s*\[[0-9\.]+m?s\]\s*$/g, "") + .split(/\r?\n/) + .slice(1); + expect(out1).toMatchSnapshot(); + + await rm(join(packageDir, "node_modules"), { recursive: true, force: true }); + + // running install again will install all packages to node_modules + ({ exited, stdout } = spawn({ + cmd: [bunExe(), "install"], + cwd: packageDir, + env, + stdout: "pipe", + stderr: "inherit", + })); + + expect(await exited).toBe(0); + + await checkModules(); + const out2 = (await Bun.readableStreamToText(stdout)) + .replaceAll(/\s*\[[0-9\.]+m?s\]\s*$/g, "") + .split(/\r?\n/) + .slice(1); + expect(out2).toEqual(out1); +}); diff --git a/test/cli/install/registry/packages/debug-1/debug-1-4.4.0.tgz b/test/cli/install/registry/packages/debug-1/debug-1-4.4.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..9e9825d3f300af0dad4ca54c9b6010eaccba175a GIT binary patch literal 172 zcmV;d08{@TiwFP!00002|LxDg4#FS|24K!S1>vk%Hpan+F~QL+(~K>{c`R*Wh7DRb65q*v0_B8Y4dS7rFw$%F2S))&kAZp)v(k_61YCxsjf- z!6%7$*FW*#g2>=Hlt&>wo~LH7#WKFtAw`u%T aD6LAl1~Z>I%d#xXe##SwLjsTh2mk=!CQwoU literal 0 HcmV?d00001 diff --git a/test/cli/install/registry/packages/debug-1/package.json b/test/cli/install/registry/packages/debug-1/package.json new file mode 100644 index 00000000000000..0eda0cd62a5014 --- /dev/null +++ b/test/cli/install/registry/packages/debug-1/package.json @@ -0,0 +1,41 @@ +{ + "name": "debug-1", + "versions": { + "4.4.0": { + "name": "debug-1", + "version": "4.4.0", + "dependencies": { + "ms-1": "^2.1.3" + }, + "_id": "debug-1@4.4.0", + "_nodeVersion": "23.5.0", + "_npmVersion": "10.9.2", + "dist": { + "integrity": "sha512-uf9R1p7HgIOLOuRhqTZpFwZzkkxcZgS2eldnhsH3MWVrstXCPsjCw76rQUMHrTx0DSqfWI8fCrXpHEDBSFiHug==", + "shasum": "e3c41fed21d99b9133778cd9bd5a747f4345f824", + "tarball": "http://localhost:4873/debug-1/-/debug-1-4.4.0.tgz" + }, + "contributors": [] + } + }, + "time": { + "modified": "2025-02-01T02:30:43.460Z", + "created": "2025-02-01T02:30:43.460Z", + "4.4.0": "2025-02-01T02:30:43.460Z" + }, + "users": {}, + "dist-tags": { + "latest": "4.4.0" + }, + "_uplinks": {}, + "_distfiles": {}, + "_attachments": { + "debug-1-4.4.0.tgz": { + "shasum": "e3c41fed21d99b9133778cd9bd5a747f4345f824", + "version": "4.4.0" + } + }, + "_rev": "", + "_id": "debug-1", + "readme": "ERROR: No README data found!" +} \ No newline at end of file diff --git a/test/cli/install/registry/packages/depend-on-debug-1/depend-on-debug-1-1.0.0.tgz b/test/cli/install/registry/packages/depend-on-debug-1/depend-on-debug-1-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..98761bedb5ec68d48b26b36ff2d027c8a10f32a9 GIT binary patch literal 173 zcmV;e08;-SiwFP!00002|Lu>#3c@f9hIigml%8!(v8&+Q)HRGLwq@PC$ll$|swa;_ z5&B*JkUxJ&qHWK%!)?qePbv6nWdOiv%|7)Plp$}|7*NU>pqh$C?@6mKFs0EBbjk`( z66~#i!mVZm_x6JPz_`PR-ihFa!{gKm#W#82ibLvyUuKj939o(*pl^FjWaf2GCoiCc bmYNa|Yp&TJgbfJN)YQ0c965O4N=)Oy8&}R8xNzaj z8HN>nCk#wY87}dZFf2W)+Ue@BJmBDDhXoAF+c{P|3u0hey64E95LIo~rFW8IomFK! sA|kT_3)AZ4JZ^ZL4>%vuxq4c6qDW6upaGZL!4C`!MIW}CFaVta0I)teH~;_u literal 0 HcmV?d00001 diff --git a/test/cli/install/registry/packages/ms-1/package.json b/test/cli/install/registry/packages/ms-1/package.json new file mode 100644 index 00000000000000..719c23349e7c6a --- /dev/null +++ b/test/cli/install/registry/packages/ms-1/package.json @@ -0,0 +1,38 @@ +{ + "name": "ms-1", + "versions": { + "2.1.3": { + "name": "ms-1", + "version": "2.1.3", + "_id": "ms-1@2.1.3", + "_nodeVersion": "23.5.0", + "_npmVersion": "10.9.2", + "dist": { + "integrity": "sha512-FIsPf9tsd67+QNd/FEx9iRLMrolyU63pjh5U1Ny2OklxhY9bzbq3szkPjebiNltG52ydKGv6c5TaVrV10T2TRA==", + "shasum": "d180fbfb72939b2f53e401dd5329cd264288fb33", + "tarball": "http://localhost:4873/ms-1/-/ms-1-2.1.3.tgz" + }, + "contributors": [] + } + }, + "time": { + "modified": "2025-02-01T02:35:38.436Z", + "created": "2025-02-01T02:35:38.436Z", + "2.1.3": "2025-02-01T02:35:38.436Z" + }, + "users": {}, + "dist-tags": { + "latest": "2.1.3" + }, + "_uplinks": {}, + "_distfiles": {}, + "_attachments": { + "ms-1-2.1.3.tgz": { + "shasum": "d180fbfb72939b2f53e401dd5329cd264288fb33", + "version": "2.1.3" + } + }, + "_rev": "", + "_id": "ms-1", + "readme": "ERROR: No README data found!" +} \ No newline at end of file diff --git a/test/cli/install/registry/packages/npm-1/npm-1-10.9.2.tgz b/test/cli/install/registry/packages/npm-1/npm-1-10.9.2.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a1507b666b991efaca28ffba9cdf4dfff2f3b5ec GIT binary patch literal 337 zcmV-X0j~ZZiwFP!00002|LvFGPJ=KM#<}Jx2-i|hX;-4xzJ*c4){|v!6tappX76tK zn+ardO2nCdH%-ndr;z6NokO0iw#gbpl}UU~Gg<6VhZ2{?I-p@*C&`P>l=FQ7fZ*I4 zi(t-kb?cSr-Sv!om89t3d46;A{!JZz z!@b^Qs?2c03AAyEIVy>2wLxu?b&)EQYV)+&{uB{Pm|rCh?!k4e{-pA8{>$qPG8IhX z1n2k{yw88kXl(hPh5z2ok2nD(@D(R$3v}LLz2I8-FHL-^=6{}lSj2<=4-i@YXW+kT z-$Ue^W^U2_xBO2>`^Ee-Ht7H62S8Z3Giva!aBM$NzT!(KE-BMK?;+gF#b! jStz-~`_Csl^iDWgx5_=2.4.2 <3.0.0", }, - "package_id": 425, + "package_id": 428, }, { "behavior": { @@ -417,7 +417,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-json-comments", "version": ">=3.1.1 <4.0.0", }, - "package_id": 374, + "package_id": 376, }, { "behavior": { @@ -469,7 +469,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string-width", "version": ">=5.1.2 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -483,7 +483,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string-width", "version": ">=4.2.0 <5.0.0", }, - "package_id": 367, + "package_id": 368, }, { "behavior": { @@ -496,7 +496,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -510,7 +510,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 374, }, { "behavior": { @@ -523,7 +523,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "wrap-ansi", "version": ">=8.1.0 <9.0.0", }, - "package_id": 428, + "package_id": 431, }, { "behavior": { @@ -537,7 +537,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 417, }, { "behavior": { @@ -680,7 +680,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "debug", "version": "==4.3.4", }, - "package_id": 429, + "package_id": 432, }, { "behavior": { @@ -732,7 +732,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "semver", "version": "==7.6.0", }, - "package_id": 430, + "package_id": 433, }, { "behavior": { @@ -745,7 +745,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tar-fs", "version": "==3.0.5", }, - "package_id": 381, + "package_id": 383, }, { "behavior": { @@ -758,7 +758,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "unbzip2-stream", "version": "==1.4.3", }, - "package_id": 401, + "package_id": 403, }, { "behavior": { @@ -771,7 +771,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yargs", "version": "==17.7.2", }, - "package_id": 420, + "package_id": 423, }, { "behavior": { @@ -784,7 +784,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tslib", "version": ">=2.4.0 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -849,7 +849,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 434, }, { "behavior": { @@ -862,7 +862,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 435, }, { "behavior": { @@ -1044,7 +1044,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "minimatch", "version": "==9.0.3", }, - "package_id": 432, + "package_id": 436, }, { "behavior": { @@ -1057,7 +1057,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "semver", "version": ">=7.5.4 <8.0.0", }, - "package_id": 430, + "package_id": 437, }, { "behavior": { @@ -1070,7 +1070,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ts-api-utils", "version": ">=1.0.1 <2.0.0", }, - "package_id": 389, + "package_id": 391, }, { "behavior": { @@ -1174,7 +1174,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "uri-js", "version": ">=4.2.2 <5.0.0", }, - "package_id": 405, + "package_id": 407, }, { "behavior": { @@ -1824,7 +1824,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tslib", "version": ">=2.0.1 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -2097,7 +2097,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "update-browserslist-db", "version": ">=1.0.13 <2.0.0", }, - "package_id": 404, + "package_id": 406, }, { "behavior": { @@ -2136,7 +2136,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "@types/node", "version": ">=20.12.8 <20.13.0", }, - "package_id": 431, + "package_id": 438, }, { "behavior": { @@ -2253,7 +2253,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "supports-color", "version": ">=7.1.0 <8.0.0", }, - "package_id": 377, + "package_id": 379, }, { "behavior": { @@ -2305,7 +2305,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <5.2.0", }, - "package_id": 433, + "package_id": 439, }, { "behavior": { @@ -2396,7 +2396,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "urlpattern-polyfill", "version": "==10.0.0", }, - "package_id": 406, + "package_id": 408, }, { "behavior": { @@ -2409,7 +2409,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "zod", "version": "==3.23.8", }, - "package_id": 424, + "package_id": 427, }, { "behavior": { @@ -2435,7 +2435,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -2448,7 +2448,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 416, }, { "behavior": { @@ -2475,7 +2475,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typescript", "version": ">=4.9.5", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -2566,7 +2566,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which", "version": ">=2.0.1 <3.0.0", }, - "package_id": 408, + "package_id": 410, }, { "behavior": { @@ -2878,7 +2878,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tapable", "version": ">=2.2.0 <3.0.0", }, - "package_id": 380, + "package_id": 382, }, { "behavior": { @@ -3385,7 +3385,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string.prototype.trim", "version": ">=1.2.9 <2.0.0", }, - "package_id": 369, + "package_id": 370, }, { "behavior": { @@ -3398,7 +3398,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string.prototype.trimend", "version": ">=1.0.8 <2.0.0", }, - "package_id": 370, + "package_id": 371, }, { "behavior": { @@ -3411,7 +3411,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string.prototype.trimstart", "version": ">=1.0.8 <2.0.0", }, - "package_id": 371, + "package_id": 372, }, { "behavior": { @@ -3424,7 +3424,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typed-array-buffer", "version": ">=1.0.2 <2.0.0", }, - "package_id": 395, + "package_id": 397, }, { "behavior": { @@ -3437,7 +3437,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typed-array-byte-length", "version": ">=1.0.1 <2.0.0", }, - "package_id": 396, + "package_id": 398, }, { "behavior": { @@ -3450,7 +3450,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typed-array-byte-offset", "version": ">=1.0.2 <2.0.0", }, - "package_id": 397, + "package_id": 399, }, { "behavior": { @@ -3463,7 +3463,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typed-array-length", "version": ">=1.0.6 <2.0.0", }, - "package_id": 398, + "package_id": 400, }, { "behavior": { @@ -3476,7 +3476,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "unbox-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 400, + "package_id": 402, }, { "behavior": { @@ -3489,7 +3489,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-typed-array", "version": ">=1.1.15 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -4308,7 +4308,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -4321,7 +4321,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "text-table", "version": ">=0.2.0 <0.3.0", }, - "package_id": 384, + "package_id": 386, }, { "behavior": { @@ -4348,7 +4348,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typescript", "version": ">=3.3.1", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -4478,7 +4478,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 440, }, { "behavior": { @@ -4634,7 +4634,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 441, }, { "behavior": { @@ -4712,7 +4712,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 442, }, { "behavior": { @@ -4725,7 +4725,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 443, }, { "behavior": { @@ -4868,7 +4868,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tsconfig-paths", "version": ">=3.15.0 <4.0.0", }, - "package_id": 391, + "package_id": 393, }, { "behavior": { @@ -5180,7 +5180,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 444, }, { "behavior": { @@ -5310,7 +5310,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "resolve", "version": ">=2.0.0-next.5 <3.0.0", }, - "package_id": 436, + "package_id": 445, }, { "behavior": { @@ -5336,7 +5336,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string.prototype.matchall", "version": ">=4.0.11 <5.0.0", }, - "package_id": 368, + "package_id": 369, }, { "behavior": { @@ -5492,7 +5492,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yauzl", "version": ">=2.10.0 <3.0.0", }, - "package_id": 422, + "package_id": 425, }, { "behavior": { @@ -5531,7 +5531,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <6.0.0", }, - "package_id": 433, + "package_id": 446, }, { "behavior": { @@ -5609,7 +5609,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "to-regex-range", "version": ">=5.0.1 <6.0.0", }, - "package_id": 388, + "package_id": 390, }, { "behavior": { @@ -5752,7 +5752,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6025,7 +6025,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "minimatch", "version": ">=9.0.1 <10.0.0", }, - "package_id": 437, + "package_id": 447, }, { "behavior": { @@ -6077,7 +6077,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "type-fest", "version": ">=0.20.2 <0.21.0", }, - "package_id": 394, + "package_id": 396, }, { "behavior": { @@ -6337,7 +6337,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -6662,7 +6662,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-typed-array", "version": ">=1.1.14 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -6844,7 +6844,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6948,7 +6948,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7052,7 +7052,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "thenify-all", "version": ">=1.0.0 <2.0.0", }, - "package_id": 386, + "package_id": 388, }, { "behavior": { @@ -7301,7 +7301,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "postcss", "version": "==8.4.31", }, - "package_id": 438, + "package_id": 448, }, { "behavior": { @@ -7314,7 +7314,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "styled-jsx", "version": "==5.1.1", }, - "package_id": 375, + "package_id": 377, }, { "behavior": { @@ -7587,7 +7587,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -7652,7 +7652,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7665,7 +7665,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "word-wrap", "version": ">=1.2.5 <2.0.0", }, - "package_id": 413, + "package_id": 415, }, { "behavior": { @@ -7678,7 +7678,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yocto-queue", "version": ">=0.1.0 <0.2.0", }, - "package_id": 423, + "package_id": 426, }, { "behavior": { @@ -7899,7 +7899,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "lru-cache", "version": ">=10.2.0 <11.0.0", }, - "package_id": 439, + "package_id": 449, }, { "behavior": { @@ -8070,7 +8070,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "lilconfig", "version": ">=3.0.0 <4.0.0", }, - "package_id": 440, + "package_id": 450, }, { "behavior": { @@ -8083,7 +8083,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yaml", "version": ">=2.3.4 <3.0.0", }, - "package_id": 419, + "package_id": 422, }, { "behavior": { @@ -8135,7 +8135,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "util-deprecate", "version": ">=1.0.2 <2.0.0", }, - "package_id": 407, + "package_id": 409, }, { "behavior": { @@ -8421,7 +8421,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ws", "version": "==8.17.1", }, - "package_id": 416, + "package_id": 419, }, { "behavior": { @@ -8590,7 +8590,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-builtin-type", "version": ">=1.1.3 <2.0.0", }, - "package_id": 410, + "package_id": 412, }, { "behavior": { @@ -8681,7 +8681,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -8694,7 +8694,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "glob", "version": ">=7.1.3 <8.0.0", }, - "package_id": 441, + "package_id": 451, }, { "behavior": { @@ -9123,7 +9123,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "text-decoder", "version": ">=1.1.0 <2.0.0", }, - "package_id": 383, + "package_id": 385, }, { "behavior": { @@ -9136,7 +9136,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": 442, + "package_id": 452, }, { "behavior": { @@ -9162,7 +9162,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -9175,7 +9175,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": null, + "package_id": 453, }, { "behavior": { @@ -9188,7 +9188,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "is-fullwidth-code-point", "version": ">=3.0.0 <4.0.0", }, - "package_id": null, + "package_id": 228, }, { "behavior": { @@ -9201,7 +9201,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -9513,7 +9513,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ansi-regex", "version": ">=5.0.1 <6.0.0", }, - "package_id": null, + "package_id": 55, }, { "behavior": { @@ -9630,7 +9630,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ts-interface-checker", "version": ">=0.1.9 <0.2.0", }, - "package_id": 390, + "package_id": 392, }, { "behavior": { @@ -9929,7 +9929,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "sucrase", "version": ">=3.32.0 <4.0.0", }, - "package_id": 376, + "package_id": 378, }, { "behavior": { @@ -9981,7 +9981,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "tar-stream", "version": ">=3.1.5 <4.0.0", }, - "package_id": 382, + "package_id": 384, }, { "behavior": { @@ -10059,7 +10059,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "thenify", "version": ">=3.1.0 && <4.0.0", }, - "package_id": 385, + "package_id": 387, }, { "behavior": { @@ -10085,7 +10085,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "typescript", "version": ">=4.2.0", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -10137,7 +10137,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-bom", "version": ">=3.0.0 <4.0.0", }, - "package_id": 373, + "package_id": 375, }, { "behavior": { @@ -10462,7 +10462,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10488,7 +10488,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "through", "version": ">=2.3.8 <3.0.0", }, - "package_id": 387, + "package_id": 389, }, { "behavior": { @@ -10748,7 +10748,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10761,7 +10761,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-collection", "version": ">=1.0.1 <2.0.0", }, - "package_id": 411, + "package_id": 413, }, { "behavior": { @@ -10774,7 +10774,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "which-typed-array", "version": ">=1.1.9 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -10930,7 +10930,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -10943,7 +10943,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ansi-styles", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 56, }, { "behavior": { @@ -10956,7 +10956,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string-width", "version": ">=4.1.0 <5.0.0", }, - "package_id": null, + "package_id": 367, }, { "behavior": { @@ -10969,7 +10969,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -11075,7 +11075,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "y18n", "version": ">=5.0.5 <6.0.0", }, - "package_id": 417, + "package_id": 420, }, { "behavior": { @@ -11088,7 +11088,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yargs-parser", "version": ">=21.1.1 <22.0.0", }, - "package_id": 421, + "package_id": 424, }, { "behavior": { @@ -11127,7 +11127,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ansi-styles", "version": ">=3.2.1 <4.0.0", }, - "package_id": 443, + "package_id": 454, }, { "behavior": { @@ -11140,7 +11140,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "escape-string-regexp", "version": ">=1.0.5 <2.0.0", }, - "package_id": 444, + "package_id": 455, }, { "behavior": { @@ -11153,7 +11153,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "supports-color", "version": ">=5.3.0 <6.0.0", }, - "package_id": 445, + "package_id": 456, }, { "behavior": { @@ -11192,7 +11192,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11205,7 +11205,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ansi-regex", "version": ">=6.0.1 <7.0.0", }, - "package_id": 446, + "package_id": 457, }, { "behavior": { @@ -11218,7 +11218,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ansi-styles", "version": ">=6.1.0 <7.0.0", }, - "package_id": 447, + "package_id": 458, }, { "behavior": { @@ -11231,7 +11231,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "string-width", "version": ">=5.0.1 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -11244,7 +11244,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11270,7 +11270,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": 448, + "package_id": 459, }, { "behavior": { @@ -11283,7 +11283,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": 402, + "package_id": 404, }, { "behavior": { @@ -11296,7 +11296,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11309,7 +11309,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 460, }, { "behavior": { @@ -11322,7 +11322,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 461, }, { "behavior": { @@ -11335,7 +11335,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11374,7 +11374,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11387,7 +11387,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11413,7 +11413,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "esutils", "version": ">=2.0.2 <3.0.0", }, - "package_id": null, + "package_id": 162, }, { "behavior": { @@ -11452,7 +11452,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -11465,7 +11465,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "is-glob", "version": ">=4.0.1 <5.0.0", }, - "package_id": null, + "package_id": 230, }, { "behavior": { @@ -11478,7 +11478,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 462, }, { "behavior": { @@ -11608,7 +11608,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "color-convert", "version": ">=1.9.0 <2.0.0", }, - "package_id": 450, + "package_id": 463, }, { "behavior": { @@ -11621,7 +11621,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "has-flag", "version": ">=3.0.0 <4.0.0", }, - "package_id": 451, + "package_id": 464, }, { "behavior": { @@ -11634,7 +11634,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": 418, + "package_id": 421, }, { "behavior": { @@ -11660,7 +11660,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 421, }, { "behavior": { @@ -11673,7 +11673,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "balanced-match", "version": ">=1.0.0 <2.0.0", }, - "package_id": null, + "package_id": 79, }, { "behavior": { @@ -11686,7 +11686,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "color-name", "version": "==1.1.3", }, - "package_id": 452, + "package_id": 465, }, ], "format": "v2", @@ -11731,7 +11731,9 @@ exports[`ssr works for 100-ish requests 1`] = ` "@tootallnate/quickjs-emscripten": 37, "@types/json5": 38, "@types/node": [ - 431, + 434, + 435, + 438, 39, ], "@types/prop-types": 40, @@ -11750,13 +11752,13 @@ exports[`ssr works for 100-ish requests 1`] = ` "agent-base": 53, "ajv": 54, "ansi-regex": [ - 446, + 457, 55, ], "ansi-styles": [ - 447, + 458, 56, - 443, + 454, ], "any-promise": 57, "anymatch": 58, @@ -11790,7 +11792,8 @@ exports[`ssr works for 100-ish requests 1`] = ` "basic-ftp": 86, "binary-extensions": 87, "brace-expansion": [ - 449, + 460, + 462, 88, ], "braces": 89, @@ -11805,7 +11808,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "caniuse-lite": 98, "chalk": [ 99, - 425, + 428, ], "chokidar": 100, "chromium-bidi": 101, @@ -11813,11 +11816,11 @@ exports[`ssr works for 100-ish requests 1`] = ` "cliui": 103, "color-convert": [ 104, - 450, + 463, ], "color-name": [ 105, - 452, + 465, ], "commander": 106, "concat-map": 107, @@ -11832,8 +11835,10 @@ exports[`ssr works for 100-ish requests 1`] = ` "data-view-byte-offset": 116, "debug": [ 117, - 429, - 434, + 432, + 440, + 441, + 442, ], "deep-is": 118, "default-create-template": 0, @@ -11847,13 +11852,15 @@ exports[`ssr works for 100-ish requests 1`] = ` "dlv": 126, "doctrine": [ 127, - 435, + 443, + 444, ], "eastasianwidth": 128, "electron-to-chromium": 129, "emoji-regex": [ 130, - 442, + 452, + 453, ], "end-of-stream": 131, "enhanced-resolve": 132, @@ -11870,7 +11877,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "escalade": 143, "escape-string-regexp": [ 144, - 444, + 455, ], "escodegen": 145, "eslint": 146, @@ -11920,11 +11927,12 @@ exports[`ssr works for 100-ish requests 1`] = ` "get-uri": 190, "glob": [ 191, - 441, + 451, ], "glob-parent": [ 192, - 433, + 439, + 446, ], "globals": 193, "globalthis": 194, @@ -11935,7 +11943,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "has-bigints": 199, "has-flag": [ 200, - 451, + 464, ], "has-property-descriptors": 201, "has-proto": 202, @@ -12001,7 +12009,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "language-tags": 262, "levn": 263, "lilconfig": [ - 440, + 450, 264, ], "lines-and-columns": 265, @@ -12009,15 +12017,16 @@ exports[`ssr works for 100-ish requests 1`] = ` "lodash.merge": 267, "loose-envify": 268, "lru-cache": [ - 439, + 449, 269, - 448, + 459, + 461, ], "merge2": 270, "micromatch": 271, "minimatch": [ - 437, - 432, + 447, + 436, 272, ], "minimist": 273, @@ -12063,7 +12072,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "pirates": 313, "possible-typed-array-names": 314, "postcss": [ - 438, + 448, 315, ], "postcss-import": 316, @@ -12093,7 +12102,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "regexp.prototype.flags": 340, "require-directory": 341, "resolve": [ - 436, + 445, 342, ], "resolve-from": 343, @@ -12105,7 +12114,8 @@ exports[`ssr works for 100-ish requests 1`] = ` "safe-regex-test": 349, "scheduler": 350, "semver": [ - 430, + 433, + 437, 351, ], "set-function-length": 352, @@ -12124,75 +12134,78 @@ exports[`ssr works for 100-ish requests 1`] = ` "streamsearch": 365, "streamx": 366, "string-width": [ - 426, + 429, 367, + 368, ], - "string.prototype.matchall": 368, - "string.prototype.trim": 369, - "string.prototype.trimend": 370, - "string.prototype.trimstart": 371, + "string.prototype.matchall": 369, + "string.prototype.trim": 370, + "string.prototype.trimend": 371, + "string.prototype.trimstart": 372, "strip-ansi": [ - 427, - 372, + 430, + 373, + 374, ], - "strip-bom": 373, - "strip-json-comments": 374, - "styled-jsx": 375, - "sucrase": 376, + "strip-bom": 375, + "strip-json-comments": 376, + "styled-jsx": 377, + "sucrase": 378, "supports-color": [ - 377, - 445, + 379, + 456, ], - "supports-preserve-symlinks-flag": 378, - "tailwindcss": 379, - "tapable": 380, - "tar-fs": 381, - "tar-stream": 382, - "text-decoder": 383, - "text-table": 384, - "thenify": 385, - "thenify-all": 386, - "through": 387, - "to-regex-range": 388, - "ts-api-utils": 389, - "ts-interface-checker": 390, - "tsconfig-paths": 391, - "tslib": 392, - "type-check": 393, - "type-fest": 394, - "typed-array-buffer": 395, - "typed-array-byte-length": 396, - "typed-array-byte-offset": 397, - "typed-array-length": 398, - "typescript": 399, - "unbox-primitive": 400, - "unbzip2-stream": 401, - "undici-types": 402, - "universalify": 403, - "update-browserslist-db": 404, - "uri-js": 405, - "urlpattern-polyfill": 406, - "util-deprecate": 407, - "which": 408, - "which-boxed-primitive": 409, - "which-builtin-type": 410, - "which-collection": 411, - "which-typed-array": 412, - "word-wrap": 413, + "supports-preserve-symlinks-flag": 380, + "tailwindcss": 381, + "tapable": 382, + "tar-fs": 383, + "tar-stream": 384, + "text-decoder": 385, + "text-table": 386, + "thenify": 387, + "thenify-all": 388, + "through": 389, + "to-regex-range": 390, + "ts-api-utils": 391, + "ts-interface-checker": 392, + "tsconfig-paths": 393, + "tslib": 394, + "type-check": 395, + "type-fest": 396, + "typed-array-buffer": 397, + "typed-array-byte-length": 398, + "typed-array-byte-offset": 399, + "typed-array-length": 400, + "typescript": 401, + "unbox-primitive": 402, + "unbzip2-stream": 403, + "undici-types": 404, + "universalify": 405, + "update-browserslist-db": 406, + "uri-js": 407, + "urlpattern-polyfill": 408, + "util-deprecate": 409, + "which": 410, + "which-boxed-primitive": 411, + "which-builtin-type": 412, + "which-collection": 413, + "which-typed-array": 414, + "word-wrap": 415, "wrap-ansi": [ - 428, - 414, + 431, + 416, + 417, ], - "wrappy": 415, - "ws": 416, - "y18n": 417, - "yallist": 418, - "yaml": 419, - "yargs": 420, - "yargs-parser": 421, - "yauzl": 422, - "yocto-queue": 423, - "zod": 424, + "wrappy": 418, + "ws": 419, + "y18n": 420, + "yallist": 421, + "yaml": 422, + "yargs": 423, + "yargs-parser": 424, + "yauzl": 425, + "yocto-queue": 426, + "zod": 427, }, "packages": [ { @@ -19108,6 +19121,26 @@ exports[`ssr works for 100-ish requests 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 704, + 705, + 706, + ], + "id": 368, + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "man_dir": "", + "name": "string-width", + "name_hash": "15727733666069179645", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "tag": "npm", + "value": "4.2.3", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ @@ -19124,7 +19157,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 717, 718, ], - "id": 368, + "id": 369, "integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==", "man_dir": "", "name": "string.prototype.matchall", @@ -19145,7 +19178,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 721, 722, ], - "id": 369, + "id": 370, "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", "man_dir": "", "name": "string.prototype.trim", @@ -19165,7 +19198,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 724, 725, ], - "id": 370, + "id": 371, "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", "man_dir": "", "name": "string.prototype.trimend", @@ -19185,7 +19218,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 727, 728, ], - "id": 371, + "id": 372, "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "man_dir": "", "name": "string.prototype.trimstart", @@ -19203,7 +19236,25 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 729, ], - "id": 372, + "id": 373, + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "man_dir": "", + "name": "strip-ansi", + "name_hash": "13340235767065158173", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "tag": "npm", + "value": "6.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 730, + ], + "id": 374, "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "man_dir": "", "name": "strip-ansi", @@ -19219,7 +19270,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 373, + "id": 375, "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "man_dir": "", "name": "strip-bom", @@ -19235,7 +19286,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 374, + "id": 376, "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "man_dir": "", "name": "strip-json-comments", @@ -19254,7 +19305,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 731, 732, ], - "id": 375, + "id": 377, "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", "man_dir": "", "name": "styled-jsx", @@ -19281,7 +19332,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 738, 739, ], - "id": 376, + "id": 378, "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", "man_dir": "", "name": "sucrase", @@ -19299,7 +19350,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 740, ], - "id": 377, + "id": 379, "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "man_dir": "", "name": "supports-color", @@ -19315,7 +19366,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 378, + "id": 380, "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "man_dir": "", "name": "supports-preserve-symlinks-flag", @@ -19357,7 +19408,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 761, 762, ], - "id": 379, + "id": 381, "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", "man_dir": "", "name": "tailwindcss", @@ -19373,7 +19424,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 380, + "id": 382, "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "man_dir": "", "name": "tapable", @@ -19394,7 +19445,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 765, 766, ], - "id": 381, + "id": 383, "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "man_dir": "", "name": "tar-fs", @@ -19414,7 +19465,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 768, 769, ], - "id": 382, + "id": 384, "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "man_dir": "", "name": "tar-stream", @@ -19432,7 +19483,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 770, ], - "id": 383, + "id": 385, "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", "man_dir": "", "name": "text-decoder", @@ -19448,7 +19499,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 384, + "id": 386, "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "man_dir": "", "name": "text-table", @@ -19466,7 +19517,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 771, ], - "id": 385, + "id": 387, "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", "man_dir": "", "name": "thenify", @@ -19484,7 +19535,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 772, ], - "id": 386, + "id": 388, "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", "man_dir": "", "name": "thenify-all", @@ -19500,7 +19551,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 387, + "id": 389, "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "man_dir": "", "name": "through", @@ -19518,7 +19569,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 773, ], - "id": 388, + "id": 390, "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "man_dir": "", "name": "to-regex-range", @@ -19536,7 +19587,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 774, ], - "id": 389, + "id": 391, "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "man_dir": "", "name": "ts-api-utils", @@ -19552,7 +19603,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 390, + "id": 392, "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "man_dir": "", "name": "ts-interface-checker", @@ -19573,7 +19624,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 777, 778, ], - "id": 391, + "id": 393, "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "man_dir": "", "name": "tsconfig-paths", @@ -19589,7 +19640,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 392, + "id": 394, "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "man_dir": "", "name": "tslib", @@ -19607,7 +19658,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 779, ], - "id": 393, + "id": 395, "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "man_dir": "", "name": "type-check", @@ -19623,7 +19674,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 394, + "id": 396, "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "man_dir": "", "name": "type-fest", @@ -19643,7 +19694,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 781, 782, ], - "id": 395, + "id": 397, "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", "man_dir": "", "name": "typed-array-buffer", @@ -19665,7 +19716,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 786, 787, ], - "id": 396, + "id": 398, "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", "man_dir": "", "name": "typed-array-byte-length", @@ -19688,7 +19739,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 792, 793, ], - "id": 397, + "id": 399, "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", "man_dir": "", "name": "typed-array-byte-offset", @@ -19711,7 +19762,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 798, 799, ], - "id": 398, + "id": 400, "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "man_dir": "", "name": "typed-array-length", @@ -19730,7 +19781,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "tsserver": "bin/tsserver", }, "dependencies": [], - "id": 399, + "id": 401, "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "man_dir": "", "name": "typescript", @@ -19751,7 +19802,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 802, 803, ], - "id": 400, + "id": 402, "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "man_dir": "", "name": "unbox-primitive", @@ -19770,7 +19821,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 804, 805, ], - "id": 401, + "id": 403, "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "man_dir": "", "name": "unbzip2-stream", @@ -19786,7 +19837,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 402, + "id": 404, "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "man_dir": "", "name": "undici-types", @@ -19802,7 +19853,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 403, + "id": 405, "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "man_dir": "", "name": "universalify", @@ -19825,7 +19876,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 807, 808, ], - "id": 404, + "id": 406, "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "man_dir": "", "name": "update-browserslist-db", @@ -19843,7 +19894,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 809, ], - "id": 405, + "id": 407, "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "man_dir": "", "name": "uri-js", @@ -19859,7 +19910,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 406, + "id": 408, "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==", "man_dir": "", "name": "urlpattern-polyfill", @@ -19875,7 +19926,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 407, + "id": 409, "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "man_dir": "", "name": "util-deprecate", @@ -19896,7 +19947,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 810, ], - "id": 408, + "id": 410, "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "man_dir": "", "name": "which", @@ -19918,7 +19969,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 814, 815, ], - "id": 409, + "id": 411, "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "man_dir": "", "name": "which-boxed-primitive", @@ -19947,7 +19998,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 826, 827, ], - "id": 410, + "id": 412, "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", "man_dir": "", "name": "which-builtin-type", @@ -19968,7 +20019,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 830, 831, ], - "id": 411, + "id": 413, "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", "man_dir": "", "name": "which-collection", @@ -19990,7 +20041,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 835, 836, ], - "id": 412, + "id": 414, "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", "man_dir": "", "name": "which-typed-array", @@ -20006,7 +20057,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 413, + "id": 415, "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "man_dir": "", "name": "word-wrap", @@ -20026,7 +20077,27 @@ exports[`ssr works for 100-ish requests 1`] = ` 838, 839, ], - "id": 414, + "id": 416, + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "man_dir": "", + "name": "wrap-ansi", + "name_hash": "6417752039399150421", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "tag": "npm", + "value": "7.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 840, + 841, + 842, + ], + "id": 417, "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "man_dir": "", "name": "wrap-ansi", @@ -20042,7 +20113,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 415, + "id": 418, "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "man_dir": "", "name": "wrappy", @@ -20061,7 +20132,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 843, 844, ], - "id": 416, + "id": 419, "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "man_dir": "", "name": "ws", @@ -20077,7 +20148,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 417, + "id": 420, "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "man_dir": "", "name": "y18n", @@ -20093,7 +20164,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 418, + "id": 421, "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "man_dir": "", "name": "yallist", @@ -20112,7 +20183,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "name": "yaml", }, "dependencies": [], - "id": 419, + "id": 422, "integrity": "sha512-sntgmxj8o7DE7g/Qi60cqpLBA3HG3STcDA0kO+WfB05jEKhZMbY7umNm2rBpQvsmZ16/lPXCJGW2672dgOUkrg==", "man_dir": "", "name": "yaml", @@ -20136,7 +20207,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 850, 851, ], - "id": 420, + "id": 423, "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "man_dir": "", "name": "yargs", @@ -20152,7 +20223,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 421, + "id": 424, "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "man_dir": "", "name": "yargs-parser", @@ -20171,7 +20242,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 852, 853, ], - "id": 422, + "id": 425, "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "man_dir": "", "name": "yauzl", @@ -20187,7 +20258,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 423, + "id": 426, "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "man_dir": "", "name": "yocto-queue", @@ -20203,7 +20274,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 424, + "id": 427, "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "man_dir": "", "name": "zod", @@ -20223,7 +20294,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 855, 856, ], - "id": 425, + "id": 428, "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "man_dir": "", "name": "chalk", @@ -20243,7 +20314,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 858, 859, ], - "id": 426, + "id": 429, "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "man_dir": "", "name": "string-width", @@ -20261,7 +20332,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 860, ], - "id": 427, + "id": 430, "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "man_dir": "", "name": "strip-ansi", @@ -20281,7 +20352,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 862, 863, ], - "id": 428, + "id": 431, "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "man_dir": "", "name": "wrap-ansi", @@ -20299,7 +20370,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 864, ], - "id": 429, + "id": 432, "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "man_dir": "", "name": "debug", @@ -20320,7 +20391,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 865, ], - "id": 430, + "id": 433, "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", "name": "semver", @@ -20338,7 +20409,25 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 866, ], - "id": 431, + "id": 434, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 867, + ], + "id": 435, "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", "man_dir": "", "name": "@types/node", @@ -20356,7 +20445,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 868, ], - "id": 432, + "id": 436, "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "man_dir": "", "name": "minimatch", @@ -20370,29 +20459,104 @@ exports[`ssr works for 100-ish requests 1`] = ` "scripts": {}, }, { - "bin": null, + "bin": { + "file": "bin/semver.js", + "name": "semver", + }, "dependencies": [ - 871, + 869, ], - "id": 433, - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "id": 437, + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", - "name": "glob-parent", - "name_hash": "11965780159102682782", + "name": "semver", + "name_hash": "16367367531761322261", "origin": "npm", "resolution": { - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "tag": "npm", - "value": "5.1.2", + "value": "7.6.0", }, "scripts": {}, }, { "bin": null, "dependencies": [ - 872, + 870, ], - "id": 434, + "id": 438, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 871, + ], + "id": 439, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 872, + ], + "id": 440, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 873, + ], + "id": 441, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 874, + ], + "id": 442, "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "man_dir": "", "name": "debug", @@ -20410,7 +20574,25 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 875, ], - "id": 435, + "id": 443, + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "man_dir": "", + "name": "doctrine", + "name_hash": "17204823894354646410", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "tag": "npm", + "value": "2.1.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 876, + ], + "id": 444, "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "man_dir": "", "name": "doctrine", @@ -20433,7 +20615,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 878, 879, ], - "id": 436, + "id": 445, "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", "man_dir": "", "name": "resolve", @@ -20446,12 +20628,30 @@ exports[`ssr works for 100-ish requests 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 880, + ], + "id": 446, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 881, ], - "id": 437, + "id": 447, "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "man_dir": "", "name": "minimatch", @@ -20471,7 +20671,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 883, 884, ], - "id": 438, + "id": 448, "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "man_dir": "", "name": "postcss", @@ -20487,7 +20687,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 439, + "id": 449, "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "man_dir": "", "name": "lru-cache", @@ -20503,7 +20703,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 440, + "id": 450, "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", "man_dir": "", "name": "lilconfig", @@ -20526,7 +20726,7 @@ exports[`ssr works for 100-ish requests 1`] = ` 889, 890, ], - "id": 441, + "id": 451, "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "man_dir": "", "name": "glob", @@ -20542,7 +20742,23 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 442, + "id": 452, + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "man_dir": "", + "name": "emoji-regex", + "name_hash": "4954026511424972012", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "tag": "npm", + "value": "8.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [], + "id": 453, "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "man_dir": "", "name": "emoji-regex", @@ -20560,7 +20776,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 891, ], - "id": 443, + "id": 454, "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "man_dir": "", "name": "ansi-styles", @@ -20576,7 +20792,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 444, + "id": 455, "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "man_dir": "", "name": "escape-string-regexp", @@ -20594,7 +20810,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 892, ], - "id": 445, + "id": 456, "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "man_dir": "", "name": "supports-color", @@ -20610,7 +20826,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 446, + "id": 457, "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "man_dir": "", "name": "ansi-regex", @@ -20626,7 +20842,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 447, + "id": 458, "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "man_dir": "", "name": "ansi-styles", @@ -20644,7 +20860,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 893, ], - "id": 448, + "id": 459, "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "man_dir": "", "name": "lru-cache", @@ -20662,7 +20878,43 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 894, ], - "id": 449, + "id": 460, + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "man_dir": "", + "name": "brace-expansion", + "name_hash": "2949258092693339993", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "tag": "npm", + "value": "2.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 895, + ], + "id": 461, + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "man_dir": "", + "name": "lru-cache", + "name_hash": "15261810304153928944", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "tag": "npm", + "value": "6.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 896, + ], + "id": 462, "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "man_dir": "", "name": "brace-expansion", @@ -20680,7 +20932,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": [ 897, ], - "id": 450, + "id": 463, "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "man_dir": "", "name": "color-convert", @@ -20696,7 +20948,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 451, + "id": 464, "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "man_dir": "", "name": "has-flag", @@ -20712,7 +20964,7 @@ exports[`ssr works for 100-ish requests 1`] = ` { "bin": null, "dependencies": [], - "id": 452, + "id": 465, "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "man_dir": "", "name": "color-name", @@ -22199,243 +22451,243 @@ exports[`ssr works for 100-ish requests 1`] = ` }, "string-width-cjs": { "id": 36, - "package_id": 367, + "package_id": 368, }, "string.prototype.matchall": { "id": 409, - "package_id": 368, + "package_id": 369, }, "string.prototype.trim": { "id": 259, - "package_id": 369, + "package_id": 370, }, "string.prototype.trimend": { "id": 260, - "package_id": 370, + "package_id": 371, }, "string.prototype.trimstart": { "id": 261, - "package_id": 371, + "package_id": 372, }, "strip-ansi": { "id": 330, - "package_id": 372, + "package_id": 373, }, "strip-ansi-cjs": { "id": 38, - "package_id": 372, + "package_id": 374, }, "strip-bom": { "id": 778, - "package_id": 373, + "package_id": 375, }, "strip-json-comments": { "id": 31, - "package_id": 374, + "package_id": 376, }, "styled-jsx": { "id": 561, - "package_id": 375, + "package_id": 377, }, "sucrase": { "id": 762, - "package_id": 376, + "package_id": 378, }, "supports-color": { "id": 172, - "package_id": 377, + "package_id": 379, }, "supports-preserve-symlinks-flag": { "id": 666, - "package_id": 378, + "package_id": 380, }, "tailwindcss": { "id": 12, - "package_id": 379, + "package_id": 381, }, "tapable": { "id": 220, - "package_id": 380, + "package_id": 382, }, "tar-fs": { "id": 56, - "package_id": 381, + "package_id": 383, }, "tar-stream": { "id": 766, - "package_id": 382, + "package_id": 384, }, "text-decoder": { "id": 700, - "package_id": 383, + "package_id": 385, }, "text-table": { "id": 331, - "package_id": 384, + "package_id": 386, }, "thenify": { "id": 772, - "package_id": 385, + "package_id": 387, }, "thenify-all": { "id": 541, - "package_id": 386, + "package_id": 388, }, "through": { "id": 805, - "package_id": 387, + "package_id": 389, }, "to-regex-range": { "id": 430, - "package_id": 388, + "package_id": 390, }, "ts-api-utils": { "id": 81, - "package_id": 389, + "package_id": 391, }, "ts-interface-checker": { "id": 739, - "package_id": 390, + "package_id": 392, }, "tsconfig-paths": { "id": 373, - "package_id": 391, + "package_id": 393, }, "tslib": { "id": 59, - "package_id": 392, + "package_id": 394, }, "type-check": { "id": 533, - "package_id": 393, + "package_id": 395, }, "type-fest": { "id": 466, - "package_id": 394, + "package_id": 396, }, "typed-array-buffer": { "id": 262, - "package_id": 395, + "package_id": 397, }, "typed-array-byte-length": { "id": 263, - "package_id": 396, + "package_id": 398, }, "typed-array-byte-offset": { "id": 264, - "package_id": 397, + "package_id": 399, }, "typed-array-length": { "id": 265, - "package_id": 398, + "package_id": 400, }, "typescript": { "id": 13, - "package_id": 399, + "package_id": 401, }, "unbox-primitive": { "id": 266, - "package_id": 400, + "package_id": 402, }, "unbzip2-stream": { "id": 57, - "package_id": 401, + "package_id": 403, }, "undici-types": { - "id": 866, - "package_id": 402, + "id": 870, + "package_id": 404, }, "universalify": { "id": 441, - "package_id": 403, + "package_id": 405, }, "update-browserslist-db": { "id": 160, - "package_id": 404, + "package_id": 406, }, "uri-js": { "id": 89, - "package_id": 405, + "package_id": 407, }, "urlpattern-polyfill": { "id": 183, - "package_id": 406, + "package_id": 408, }, "util-deprecate": { "id": 624, - "package_id": 407, + "package_id": 409, }, "which": { "id": 196, - "package_id": 408, + "package_id": 410, }, "which-boxed-primitive": { "id": 803, - "package_id": 409, + "package_id": 411, }, "which-builtin-type": { "id": 659, - "package_id": 410, + "package_id": 412, }, "which-collection": { "id": 826, - "package_id": 411, + "package_id": 413, }, "which-typed-array": { "id": 267, - "package_id": 412, + "package_id": 414, }, "word-wrap": { "id": 588, - "package_id": 413, + "package_id": 415, }, "wrap-ansi": { "id": 187, - "package_id": 414, + "package_id": 416, }, "wrap-ansi-cjs": { "id": 40, - "package_id": 414, + "package_id": 417, }, "wrappy": { "id": 582, - "package_id": 415, + "package_id": 418, }, "ws": { "id": 646, - "package_id": 416, + "package_id": 419, }, "y18n": { "id": 850, - "package_id": 417, + "package_id": 420, }, "yallist": { "id": 893, - "package_id": 418, + "package_id": 421, }, "yaml": { "id": 620, - "package_id": 419, + "package_id": 422, }, "yargs": { "id": 58, - "package_id": 420, + "package_id": 423, }, "yargs-parser": { "id": 851, - "package_id": 421, + "package_id": 424, }, "yauzl": { "id": 421, - "package_id": 422, + "package_id": 425, }, "yocto-queue": { "id": 589, - "package_id": 423, + "package_id": 426, }, "zod": { "id": 184, - "package_id": 424, + "package_id": 427, }, }, "depth": 0, @@ -22446,7 +22698,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "@types/node": { "id": 163, - "package_id": 431, + "package_id": 438, }, }, "depth": 1, @@ -22457,7 +22709,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "postcss": { "id": 560, - "package_id": 438, + "package_id": 448, }, }, "depth": 1, @@ -22468,7 +22720,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "@types/node": { "id": 64, - "package_id": 431, + "package_id": 434, }, }, "depth": 1, @@ -22479,7 +22731,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "debug": { "id": 343, - "package_id": 434, + "package_id": 440, }, }, "depth": 1, @@ -22490,11 +22742,11 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "debug": { "id": 361, - "package_id": 434, + "package_id": 442, }, "doctrine": { "id": 362, - "package_id": 435, + "package_id": 443, }, }, "depth": 1, @@ -22505,11 +22757,11 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "doctrine": { "id": 397, - "package_id": 435, + "package_id": 444, }, "resolve": { "id": 407, - "package_id": 436, + "package_id": 445, }, }, "depth": 1, @@ -22520,11 +22772,11 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "debug": { "id": 51, - "package_id": 429, + "package_id": 432, }, "semver": { "id": 55, - "package_id": 430, + "package_id": 433, }, }, "depth": 1, @@ -22535,7 +22787,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "glob-parent": { "id": 176, - "package_id": 433, + "package_id": 439, }, }, "depth": 1, @@ -22546,7 +22798,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "glob-parent": { "id": 424, - "package_id": 433, + "package_id": 446, }, }, "depth": 1, @@ -22557,7 +22809,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "lilconfig": { "id": 619, - "package_id": 440, + "package_id": 450, }, }, "depth": 1, @@ -22568,7 +22820,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "minimatch": { "id": 462, - "package_id": 437, + "package_id": 447, }, }, "depth": 1, @@ -22579,11 +22831,11 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "minimatch": { "id": 79, - "package_id": 432, + "package_id": 436, }, "semver": { "id": 80, - "package_id": 430, + "package_id": 437, }, }, "depth": 1, @@ -22594,7 +22846,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "debug": { "id": 355, - "package_id": 434, + "package_id": 441, }, }, "depth": 1, @@ -22605,7 +22857,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "lru-cache": { "id": 865, - "package_id": 448, + "package_id": 459, }, }, "depth": 2, @@ -22616,7 +22868,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "glob": { "id": 667, - "package_id": 441, + "package_id": 451, }, }, "depth": 1, @@ -22627,7 +22879,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "brace-expansion": { "id": 881, - "package_id": 449, + "package_id": 462, }, }, "depth": 2, @@ -22638,7 +22890,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "lru-cache": { "id": 606, - "package_id": 439, + "package_id": 449, }, }, "depth": 1, @@ -22649,7 +22901,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "brace-expansion": { "id": 868, - "package_id": 449, + "package_id": 460, }, }, "depth": 2, @@ -22659,8 +22911,8 @@ exports[`ssr works for 100-ish requests 1`] = ` { "dependencies": { "lru-cache": { - "id": 865, - "package_id": 448, + "id": 869, + "package_id": 461, }, }, "depth": 2, @@ -22671,7 +22923,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "@types/node": { "id": 65, - "package_id": 431, + "package_id": 435, }, }, "depth": 1, @@ -22682,7 +22934,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "emoji-regex": { "id": 701, - "package_id": 442, + "package_id": 452, }, }, "depth": 1, @@ -22693,15 +22945,15 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "string-width": { "id": 35, - "package_id": 426, + "package_id": 429, }, "strip-ansi": { "id": 37, - "package_id": 427, + "package_id": 430, }, "wrap-ansi": { "id": 39, - "package_id": 428, + "package_id": 431, }, }, "depth": 1, @@ -22712,7 +22964,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "chalk": { "id": 17, - "package_id": 425, + "package_id": 428, }, }, "depth": 1, @@ -22722,8 +22974,8 @@ exports[`ssr works for 100-ish requests 1`] = ` { "dependencies": { "emoji-regex": { - "id": 701, - "package_id": 442, + "id": 704, + "package_id": 453, }, }, "depth": 1, @@ -22734,7 +22986,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "ansi-regex": { "id": 860, - "package_id": 446, + "package_id": 457, }, }, "depth": 2, @@ -22745,7 +22997,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "ansi-styles": { "id": 861, - "package_id": 447, + "package_id": 458, }, }, "depth": 2, @@ -22756,15 +23008,15 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "ansi-styles": { "id": 854, - "package_id": 443, + "package_id": 454, }, "escape-string-regexp": { "id": 855, - "package_id": 444, + "package_id": 455, }, "supports-color": { "id": 856, - "package_id": 445, + "package_id": 456, }, }, "depth": 2, @@ -22775,7 +23027,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "color-convert": { "id": 891, - "package_id": 450, + "package_id": 463, }, }, "depth": 3, @@ -22786,7 +23038,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "has-flag": { "id": 892, - "package_id": 451, + "package_id": 464, }, }, "depth": 3, @@ -22797,7 +23049,7 @@ exports[`ssr works for 100-ish requests 1`] = ` "dependencies": { "color-name": { "id": 897, - "package_id": 452, + "package_id": 465, }, }, "depth": 4, diff --git a/test/integration/next-pages/test/__snapshots__/dev-server.test.ts.snap b/test/integration/next-pages/test/__snapshots__/dev-server.test.ts.snap index c5c0b46262ee2a..29c1360d6ddbf0 100644 --- a/test/integration/next-pages/test/__snapshots__/dev-server.test.ts.snap +++ b/test/integration/next-pages/test/__snapshots__/dev-server.test.ts.snap @@ -170,7 +170,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tailwindcss", "version": "==3.3.3", }, - "package_id": 379, + "package_id": 381, }, { "behavior": { @@ -183,7 +183,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typescript", "version": "==5.2.2", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -235,7 +235,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "chalk", "version": ">=2.4.2 <3.0.0", }, - "package_id": 425, + "package_id": 428, }, { "behavior": { @@ -417,7 +417,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-json-comments", "version": ">=3.1.1 <4.0.0", }, - "package_id": 374, + "package_id": 376, }, { "behavior": { @@ -469,7 +469,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string-width", "version": ">=5.1.2 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -483,7 +483,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string-width", "version": ">=4.2.0 <5.0.0", }, - "package_id": 367, + "package_id": 368, }, { "behavior": { @@ -496,7 +496,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -510,7 +510,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 374, }, { "behavior": { @@ -523,7 +523,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "wrap-ansi", "version": ">=8.1.0 <9.0.0", }, - "package_id": 428, + "package_id": 431, }, { "behavior": { @@ -537,7 +537,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 417, }, { "behavior": { @@ -680,7 +680,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "debug", "version": "==4.3.4", }, - "package_id": 429, + "package_id": 432, }, { "behavior": { @@ -732,7 +732,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "semver", "version": "==7.6.0", }, - "package_id": 430, + "package_id": 433, }, { "behavior": { @@ -745,7 +745,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tar-fs", "version": "==3.0.5", }, - "package_id": 381, + "package_id": 383, }, { "behavior": { @@ -758,7 +758,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "unbzip2-stream", "version": "==1.4.3", }, - "package_id": 401, + "package_id": 403, }, { "behavior": { @@ -771,7 +771,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yargs", "version": "==17.7.2", }, - "package_id": 420, + "package_id": 423, }, { "behavior": { @@ -784,7 +784,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tslib", "version": ">=2.4.0 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -849,7 +849,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 434, }, { "behavior": { @@ -862,7 +862,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 435, }, { "behavior": { @@ -1044,7 +1044,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "minimatch", "version": "==9.0.3", }, - "package_id": 432, + "package_id": 436, }, { "behavior": { @@ -1057,7 +1057,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "semver", "version": ">=7.5.4 <8.0.0", }, - "package_id": 430, + "package_id": 437, }, { "behavior": { @@ -1070,7 +1070,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ts-api-utils", "version": ">=1.0.1 <2.0.0", }, - "package_id": 389, + "package_id": 391, }, { "behavior": { @@ -1174,7 +1174,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "uri-js", "version": ">=4.2.2 <5.0.0", }, - "package_id": 405, + "package_id": 407, }, { "behavior": { @@ -1824,7 +1824,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tslib", "version": ">=2.0.1 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -2097,7 +2097,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "update-browserslist-db", "version": ">=1.0.13 <2.0.0", }, - "package_id": 404, + "package_id": 406, }, { "behavior": { @@ -2136,7 +2136,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "@types/node", "version": ">=20.12.8 <20.13.0", }, - "package_id": 431, + "package_id": 438, }, { "behavior": { @@ -2253,7 +2253,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "supports-color", "version": ">=7.1.0 <8.0.0", }, - "package_id": 377, + "package_id": 379, }, { "behavior": { @@ -2305,7 +2305,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <5.2.0", }, - "package_id": 433, + "package_id": 439, }, { "behavior": { @@ -2396,7 +2396,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "urlpattern-polyfill", "version": "==10.0.0", }, - "package_id": 406, + "package_id": 408, }, { "behavior": { @@ -2409,7 +2409,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "zod", "version": "==3.23.8", }, - "package_id": 424, + "package_id": 427, }, { "behavior": { @@ -2435,7 +2435,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -2448,7 +2448,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 416, }, { "behavior": { @@ -2475,7 +2475,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typescript", "version": ">=4.9.5", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -2566,7 +2566,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which", "version": ">=2.0.1 <3.0.0", }, - "package_id": 408, + "package_id": 410, }, { "behavior": { @@ -2878,7 +2878,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tapable", "version": ">=2.2.0 <3.0.0", }, - "package_id": 380, + "package_id": 382, }, { "behavior": { @@ -3385,7 +3385,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string.prototype.trim", "version": ">=1.2.9 <2.0.0", }, - "package_id": 369, + "package_id": 370, }, { "behavior": { @@ -3398,7 +3398,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string.prototype.trimend", "version": ">=1.0.8 <2.0.0", }, - "package_id": 370, + "package_id": 371, }, { "behavior": { @@ -3411,7 +3411,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string.prototype.trimstart", "version": ">=1.0.8 <2.0.0", }, - "package_id": 371, + "package_id": 372, }, { "behavior": { @@ -3424,7 +3424,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typed-array-buffer", "version": ">=1.0.2 <2.0.0", }, - "package_id": 395, + "package_id": 397, }, { "behavior": { @@ -3437,7 +3437,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typed-array-byte-length", "version": ">=1.0.1 <2.0.0", }, - "package_id": 396, + "package_id": 398, }, { "behavior": { @@ -3450,7 +3450,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typed-array-byte-offset", "version": ">=1.0.2 <2.0.0", }, - "package_id": 397, + "package_id": 399, }, { "behavior": { @@ -3463,7 +3463,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typed-array-length", "version": ">=1.0.6 <2.0.0", }, - "package_id": 398, + "package_id": 400, }, { "behavior": { @@ -3476,7 +3476,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "unbox-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 400, + "package_id": 402, }, { "behavior": { @@ -3489,7 +3489,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-typed-array", "version": ">=1.1.15 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -4308,7 +4308,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -4321,7 +4321,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "text-table", "version": ">=0.2.0 <0.3.0", }, - "package_id": 384, + "package_id": 386, }, { "behavior": { @@ -4348,7 +4348,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typescript", "version": ">=3.3.1", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -4478,7 +4478,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 440, }, { "behavior": { @@ -4634,7 +4634,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 441, }, { "behavior": { @@ -4712,7 +4712,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 442, }, { "behavior": { @@ -4725,7 +4725,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 443, }, { "behavior": { @@ -4868,7 +4868,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tsconfig-paths", "version": ">=3.15.0 <4.0.0", }, - "package_id": 391, + "package_id": 393, }, { "behavior": { @@ -5180,7 +5180,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 444, }, { "behavior": { @@ -5310,7 +5310,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "resolve", "version": ">=2.0.0-next.5 <3.0.0", }, - "package_id": 436, + "package_id": 445, }, { "behavior": { @@ -5336,7 +5336,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string.prototype.matchall", "version": ">=4.0.11 <5.0.0", }, - "package_id": 368, + "package_id": 369, }, { "behavior": { @@ -5492,7 +5492,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yauzl", "version": ">=2.10.0 <3.0.0", }, - "package_id": 422, + "package_id": 425, }, { "behavior": { @@ -5531,7 +5531,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <6.0.0", }, - "package_id": 433, + "package_id": 446, }, { "behavior": { @@ -5609,7 +5609,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "to-regex-range", "version": ">=5.0.1 <6.0.0", }, - "package_id": 388, + "package_id": 390, }, { "behavior": { @@ -5752,7 +5752,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6025,7 +6025,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "minimatch", "version": ">=9.0.1 <10.0.0", }, - "package_id": 437, + "package_id": 447, }, { "behavior": { @@ -6077,7 +6077,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "type-fest", "version": ">=0.20.2 <0.21.0", }, - "package_id": 394, + "package_id": 396, }, { "behavior": { @@ -6337,7 +6337,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -6662,7 +6662,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-typed-array", "version": ">=1.1.14 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -6844,7 +6844,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6948,7 +6948,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7052,7 +7052,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "thenify-all", "version": ">=1.0.0 <2.0.0", }, - "package_id": 386, + "package_id": 388, }, { "behavior": { @@ -7301,7 +7301,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "postcss", "version": "==8.4.31", }, - "package_id": 438, + "package_id": 448, }, { "behavior": { @@ -7314,7 +7314,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "styled-jsx", "version": "==5.1.1", }, - "package_id": 375, + "package_id": 377, }, { "behavior": { @@ -7587,7 +7587,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -7652,7 +7652,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7665,7 +7665,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "word-wrap", "version": ">=1.2.5 <2.0.0", }, - "package_id": 413, + "package_id": 415, }, { "behavior": { @@ -7678,7 +7678,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yocto-queue", "version": ">=0.1.0 <0.2.0", }, - "package_id": 423, + "package_id": 426, }, { "behavior": { @@ -7899,7 +7899,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "lru-cache", "version": ">=10.2.0 <11.0.0", }, - "package_id": 439, + "package_id": 449, }, { "behavior": { @@ -8070,7 +8070,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "lilconfig", "version": ">=3.0.0 <4.0.0", }, - "package_id": 440, + "package_id": 450, }, { "behavior": { @@ -8083,7 +8083,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yaml", "version": ">=2.3.4 <3.0.0", }, - "package_id": 419, + "package_id": 422, }, { "behavior": { @@ -8135,7 +8135,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "util-deprecate", "version": ">=1.0.2 <2.0.0", }, - "package_id": 407, + "package_id": 409, }, { "behavior": { @@ -8421,7 +8421,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ws", "version": "==8.17.1", }, - "package_id": 416, + "package_id": 419, }, { "behavior": { @@ -8590,7 +8590,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-builtin-type", "version": ">=1.1.3 <2.0.0", }, - "package_id": 410, + "package_id": 412, }, { "behavior": { @@ -8681,7 +8681,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -8694,7 +8694,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "glob", "version": ">=7.1.3 <8.0.0", }, - "package_id": 441, + "package_id": 451, }, { "behavior": { @@ -9123,7 +9123,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "text-decoder", "version": ">=1.1.0 <2.0.0", }, - "package_id": 383, + "package_id": 385, }, { "behavior": { @@ -9136,7 +9136,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": 442, + "package_id": 452, }, { "behavior": { @@ -9162,7 +9162,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -9175,7 +9175,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": null, + "package_id": 453, }, { "behavior": { @@ -9188,7 +9188,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "is-fullwidth-code-point", "version": ">=3.0.0 <4.0.0", }, - "package_id": null, + "package_id": 228, }, { "behavior": { @@ -9201,7 +9201,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -9513,7 +9513,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ansi-regex", "version": ">=5.0.1 <6.0.0", }, - "package_id": null, + "package_id": 55, }, { "behavior": { @@ -9630,7 +9630,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ts-interface-checker", "version": ">=0.1.9 <0.2.0", }, - "package_id": 390, + "package_id": 392, }, { "behavior": { @@ -9929,7 +9929,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "sucrase", "version": ">=3.32.0 <4.0.0", }, - "package_id": 376, + "package_id": 378, }, { "behavior": { @@ -9981,7 +9981,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "tar-stream", "version": ">=3.1.5 <4.0.0", }, - "package_id": 382, + "package_id": 384, }, { "behavior": { @@ -10059,7 +10059,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "thenify", "version": ">=3.1.0 && <4.0.0", }, - "package_id": 385, + "package_id": 387, }, { "behavior": { @@ -10085,7 +10085,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "typescript", "version": ">=4.2.0", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -10137,7 +10137,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-bom", "version": ">=3.0.0 <4.0.0", }, - "package_id": 373, + "package_id": 375, }, { "behavior": { @@ -10462,7 +10462,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10488,7 +10488,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "through", "version": ">=2.3.8 <3.0.0", }, - "package_id": 387, + "package_id": 389, }, { "behavior": { @@ -10748,7 +10748,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10761,7 +10761,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-collection", "version": ">=1.0.1 <2.0.0", }, - "package_id": 411, + "package_id": 413, }, { "behavior": { @@ -10774,7 +10774,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "which-typed-array", "version": ">=1.1.9 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -10930,7 +10930,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -10943,7 +10943,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ansi-styles", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 56, }, { "behavior": { @@ -10956,7 +10956,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string-width", "version": ">=4.1.0 <5.0.0", }, - "package_id": null, + "package_id": 367, }, { "behavior": { @@ -10969,7 +10969,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -11075,7 +11075,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "y18n", "version": ">=5.0.5 <6.0.0", }, - "package_id": 417, + "package_id": 420, }, { "behavior": { @@ -11088,7 +11088,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yargs-parser", "version": ">=21.1.1 <22.0.0", }, - "package_id": 421, + "package_id": 424, }, { "behavior": { @@ -11127,7 +11127,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ansi-styles", "version": ">=3.2.1 <4.0.0", }, - "package_id": 443, + "package_id": 454, }, { "behavior": { @@ -11140,7 +11140,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "escape-string-regexp", "version": ">=1.0.5 <2.0.0", }, - "package_id": 444, + "package_id": 455, }, { "behavior": { @@ -11153,7 +11153,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "supports-color", "version": ">=5.3.0 <6.0.0", }, - "package_id": 445, + "package_id": 456, }, { "behavior": { @@ -11192,7 +11192,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11205,7 +11205,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ansi-regex", "version": ">=6.0.1 <7.0.0", }, - "package_id": 446, + "package_id": 457, }, { "behavior": { @@ -11218,7 +11218,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ansi-styles", "version": ">=6.1.0 <7.0.0", }, - "package_id": 447, + "package_id": 458, }, { "behavior": { @@ -11231,7 +11231,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "string-width", "version": ">=5.0.1 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -11244,7 +11244,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11270,7 +11270,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": 448, + "package_id": 459, }, { "behavior": { @@ -11283,7 +11283,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": 402, + "package_id": 404, }, { "behavior": { @@ -11296,7 +11296,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11309,7 +11309,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 460, }, { "behavior": { @@ -11322,7 +11322,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 461, }, { "behavior": { @@ -11335,7 +11335,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11374,7 +11374,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11387,7 +11387,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11413,7 +11413,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "esutils", "version": ">=2.0.2 <3.0.0", }, - "package_id": null, + "package_id": 162, }, { "behavior": { @@ -11452,7 +11452,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -11465,7 +11465,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "is-glob", "version": ">=4.0.1 <5.0.0", }, - "package_id": null, + "package_id": 230, }, { "behavior": { @@ -11478,7 +11478,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 462, }, { "behavior": { @@ -11608,7 +11608,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "color-convert", "version": ">=1.9.0 <2.0.0", }, - "package_id": 450, + "package_id": 463, }, { "behavior": { @@ -11621,7 +11621,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "has-flag", "version": ">=3.0.0 <4.0.0", }, - "package_id": 451, + "package_id": 464, }, { "behavior": { @@ -11634,7 +11634,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": 418, + "package_id": 421, }, { "behavior": { @@ -11660,7 +11660,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 421, }, { "behavior": { @@ -11673,7 +11673,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "balanced-match", "version": ">=1.0.0 <2.0.0", }, - "package_id": null, + "package_id": 79, }, { "behavior": { @@ -11686,7 +11686,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "color-name", "version": "==1.1.3", }, - "package_id": 452, + "package_id": 465, }, ], "format": "v2", @@ -11731,7 +11731,9 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "@tootallnate/quickjs-emscripten": 37, "@types/json5": 38, "@types/node": [ - 431, + 434, + 435, + 438, 39, ], "@types/prop-types": 40, @@ -11750,13 +11752,13 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "agent-base": 53, "ajv": 54, "ansi-regex": [ - 446, + 457, 55, ], "ansi-styles": [ - 447, + 458, 56, - 443, + 454, ], "any-promise": 57, "anymatch": 58, @@ -11790,7 +11792,8 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "basic-ftp": 86, "binary-extensions": 87, "brace-expansion": [ - 449, + 460, + 462, 88, ], "braces": 89, @@ -11805,7 +11808,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "caniuse-lite": 98, "chalk": [ 99, - 425, + 428, ], "chokidar": 100, "chromium-bidi": 101, @@ -11813,11 +11816,11 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "cliui": 103, "color-convert": [ 104, - 450, + 463, ], "color-name": [ 105, - 452, + 465, ], "commander": 106, "concat-map": 107, @@ -11832,8 +11835,10 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "data-view-byte-offset": 116, "debug": [ 117, - 429, - 434, + 432, + 440, + 441, + 442, ], "deep-is": 118, "default-create-template": 0, @@ -11847,13 +11852,15 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dlv": 126, "doctrine": [ 127, - 435, + 443, + 444, ], "eastasianwidth": 128, "electron-to-chromium": 129, "emoji-regex": [ 130, - 442, + 452, + 453, ], "end-of-stream": 131, "enhanced-resolve": 132, @@ -11870,7 +11877,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "escalade": 143, "escape-string-regexp": [ 144, - 444, + 455, ], "escodegen": 145, "eslint": 146, @@ -11920,11 +11927,12 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "get-uri": 190, "glob": [ 191, - 441, + 451, ], "glob-parent": [ 192, - 433, + 439, + 446, ], "globals": 193, "globalthis": 194, @@ -11935,7 +11943,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "has-bigints": 199, "has-flag": [ 200, - 451, + 464, ], "has-property-descriptors": 201, "has-proto": 202, @@ -12001,7 +12009,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "language-tags": 262, "levn": 263, "lilconfig": [ - 440, + 450, 264, ], "lines-and-columns": 265, @@ -12009,15 +12017,16 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "lodash.merge": 267, "loose-envify": 268, "lru-cache": [ - 439, + 449, 269, - 448, + 459, + 461, ], "merge2": 270, "micromatch": 271, "minimatch": [ - 437, - 432, + 447, + 436, 272, ], "minimist": 273, @@ -12063,7 +12072,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "pirates": 313, "possible-typed-array-names": 314, "postcss": [ - 438, + 448, 315, ], "postcss-import": 316, @@ -12093,7 +12102,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "regexp.prototype.flags": 340, "require-directory": 341, "resolve": [ - 436, + 445, 342, ], "resolve-from": 343, @@ -12105,7 +12114,8 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "safe-regex-test": 349, "scheduler": 350, "semver": [ - 430, + 433, + 437, 351, ], "set-function-length": 352, @@ -12124,75 +12134,78 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "streamsearch": 365, "streamx": 366, "string-width": [ - 426, + 429, 367, + 368, ], - "string.prototype.matchall": 368, - "string.prototype.trim": 369, - "string.prototype.trimend": 370, - "string.prototype.trimstart": 371, + "string.prototype.matchall": 369, + "string.prototype.trim": 370, + "string.prototype.trimend": 371, + "string.prototype.trimstart": 372, "strip-ansi": [ - 427, - 372, + 430, + 373, + 374, ], - "strip-bom": 373, - "strip-json-comments": 374, - "styled-jsx": 375, - "sucrase": 376, + "strip-bom": 375, + "strip-json-comments": 376, + "styled-jsx": 377, + "sucrase": 378, "supports-color": [ - 377, - 445, + 379, + 456, ], - "supports-preserve-symlinks-flag": 378, - "tailwindcss": 379, - "tapable": 380, - "tar-fs": 381, - "tar-stream": 382, - "text-decoder": 383, - "text-table": 384, - "thenify": 385, - "thenify-all": 386, - "through": 387, - "to-regex-range": 388, - "ts-api-utils": 389, - "ts-interface-checker": 390, - "tsconfig-paths": 391, - "tslib": 392, - "type-check": 393, - "type-fest": 394, - "typed-array-buffer": 395, - "typed-array-byte-length": 396, - "typed-array-byte-offset": 397, - "typed-array-length": 398, - "typescript": 399, - "unbox-primitive": 400, - "unbzip2-stream": 401, - "undici-types": 402, - "universalify": 403, - "update-browserslist-db": 404, - "uri-js": 405, - "urlpattern-polyfill": 406, - "util-deprecate": 407, - "which": 408, - "which-boxed-primitive": 409, - "which-builtin-type": 410, - "which-collection": 411, - "which-typed-array": 412, - "word-wrap": 413, + "supports-preserve-symlinks-flag": 380, + "tailwindcss": 381, + "tapable": 382, + "tar-fs": 383, + "tar-stream": 384, + "text-decoder": 385, + "text-table": 386, + "thenify": 387, + "thenify-all": 388, + "through": 389, + "to-regex-range": 390, + "ts-api-utils": 391, + "ts-interface-checker": 392, + "tsconfig-paths": 393, + "tslib": 394, + "type-check": 395, + "type-fest": 396, + "typed-array-buffer": 397, + "typed-array-byte-length": 398, + "typed-array-byte-offset": 399, + "typed-array-length": 400, + "typescript": 401, + "unbox-primitive": 402, + "unbzip2-stream": 403, + "undici-types": 404, + "universalify": 405, + "update-browserslist-db": 406, + "uri-js": 407, + "urlpattern-polyfill": 408, + "util-deprecate": 409, + "which": 410, + "which-boxed-primitive": 411, + "which-builtin-type": 412, + "which-collection": 413, + "which-typed-array": 414, + "word-wrap": 415, "wrap-ansi": [ - 428, - 414, + 431, + 416, + 417, ], - "wrappy": 415, - "ws": 416, - "y18n": 417, - "yallist": 418, - "yaml": 419, - "yargs": 420, - "yargs-parser": 421, - "yauzl": 422, - "yocto-queue": 423, - "zod": 424, + "wrappy": 418, + "ws": 419, + "y18n": 420, + "yallist": 421, + "yaml": 422, + "yargs": 423, + "yargs-parser": 424, + "yauzl": 425, + "yocto-queue": 426, + "zod": 427, }, "packages": [ { @@ -19108,6 +19121,26 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 704, + 705, + 706, + ], + "id": 368, + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "man_dir": "", + "name": "string-width", + "name_hash": "15727733666069179645", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "tag": "npm", + "value": "4.2.3", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ @@ -19124,7 +19157,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 717, 718, ], - "id": 368, + "id": 369, "integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==", "man_dir": "", "name": "string.prototype.matchall", @@ -19145,7 +19178,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 721, 722, ], - "id": 369, + "id": 370, "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", "man_dir": "", "name": "string.prototype.trim", @@ -19165,7 +19198,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 724, 725, ], - "id": 370, + "id": 371, "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", "man_dir": "", "name": "string.prototype.trimend", @@ -19185,7 +19218,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 727, 728, ], - "id": 371, + "id": 372, "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "man_dir": "", "name": "string.prototype.trimstart", @@ -19203,7 +19236,25 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 729, ], - "id": 372, + "id": 373, + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "man_dir": "", + "name": "strip-ansi", + "name_hash": "13340235767065158173", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "tag": "npm", + "value": "6.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 730, + ], + "id": 374, "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "man_dir": "", "name": "strip-ansi", @@ -19219,7 +19270,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 373, + "id": 375, "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "man_dir": "", "name": "strip-bom", @@ -19235,7 +19286,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 374, + "id": 376, "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "man_dir": "", "name": "strip-json-comments", @@ -19254,7 +19305,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 731, 732, ], - "id": 375, + "id": 377, "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", "man_dir": "", "name": "styled-jsx", @@ -19281,7 +19332,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 738, 739, ], - "id": 376, + "id": 378, "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", "man_dir": "", "name": "sucrase", @@ -19299,7 +19350,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 740, ], - "id": 377, + "id": 379, "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "man_dir": "", "name": "supports-color", @@ -19315,7 +19366,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 378, + "id": 380, "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "man_dir": "", "name": "supports-preserve-symlinks-flag", @@ -19357,7 +19408,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 761, 762, ], - "id": 379, + "id": 381, "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", "man_dir": "", "name": "tailwindcss", @@ -19373,7 +19424,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 380, + "id": 382, "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "man_dir": "", "name": "tapable", @@ -19394,7 +19445,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 765, 766, ], - "id": 381, + "id": 383, "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "man_dir": "", "name": "tar-fs", @@ -19414,7 +19465,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 768, 769, ], - "id": 382, + "id": 384, "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "man_dir": "", "name": "tar-stream", @@ -19432,7 +19483,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 770, ], - "id": 383, + "id": 385, "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", "man_dir": "", "name": "text-decoder", @@ -19448,7 +19499,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 384, + "id": 386, "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "man_dir": "", "name": "text-table", @@ -19466,7 +19517,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 771, ], - "id": 385, + "id": 387, "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", "man_dir": "", "name": "thenify", @@ -19484,7 +19535,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 772, ], - "id": 386, + "id": 388, "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", "man_dir": "", "name": "thenify-all", @@ -19500,7 +19551,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 387, + "id": 389, "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "man_dir": "", "name": "through", @@ -19518,7 +19569,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 773, ], - "id": 388, + "id": 390, "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "man_dir": "", "name": "to-regex-range", @@ -19536,7 +19587,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 774, ], - "id": 389, + "id": 391, "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "man_dir": "", "name": "ts-api-utils", @@ -19552,7 +19603,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 390, + "id": 392, "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "man_dir": "", "name": "ts-interface-checker", @@ -19573,7 +19624,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 777, 778, ], - "id": 391, + "id": 393, "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "man_dir": "", "name": "tsconfig-paths", @@ -19589,7 +19640,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 392, + "id": 394, "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "man_dir": "", "name": "tslib", @@ -19607,7 +19658,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 779, ], - "id": 393, + "id": 395, "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "man_dir": "", "name": "type-check", @@ -19623,7 +19674,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 394, + "id": 396, "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "man_dir": "", "name": "type-fest", @@ -19643,7 +19694,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 781, 782, ], - "id": 395, + "id": 397, "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", "man_dir": "", "name": "typed-array-buffer", @@ -19665,7 +19716,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 786, 787, ], - "id": 396, + "id": 398, "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", "man_dir": "", "name": "typed-array-byte-length", @@ -19688,7 +19739,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 792, 793, ], - "id": 397, + "id": 399, "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", "man_dir": "", "name": "typed-array-byte-offset", @@ -19711,7 +19762,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 798, 799, ], - "id": 398, + "id": 400, "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "man_dir": "", "name": "typed-array-length", @@ -19730,7 +19781,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "tsserver": "bin/tsserver", }, "dependencies": [], - "id": 399, + "id": 401, "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "man_dir": "", "name": "typescript", @@ -19751,7 +19802,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 802, 803, ], - "id": 400, + "id": 402, "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "man_dir": "", "name": "unbox-primitive", @@ -19770,7 +19821,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 804, 805, ], - "id": 401, + "id": 403, "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "man_dir": "", "name": "unbzip2-stream", @@ -19786,7 +19837,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 402, + "id": 404, "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "man_dir": "", "name": "undici-types", @@ -19802,7 +19853,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 403, + "id": 405, "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "man_dir": "", "name": "universalify", @@ -19825,7 +19876,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 807, 808, ], - "id": 404, + "id": 406, "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "man_dir": "", "name": "update-browserslist-db", @@ -19843,7 +19894,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 809, ], - "id": 405, + "id": 407, "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "man_dir": "", "name": "uri-js", @@ -19859,7 +19910,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 406, + "id": 408, "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==", "man_dir": "", "name": "urlpattern-polyfill", @@ -19875,7 +19926,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 407, + "id": 409, "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "man_dir": "", "name": "util-deprecate", @@ -19896,7 +19947,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 810, ], - "id": 408, + "id": 410, "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "man_dir": "", "name": "which", @@ -19918,7 +19969,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 814, 815, ], - "id": 409, + "id": 411, "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "man_dir": "", "name": "which-boxed-primitive", @@ -19947,7 +19998,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 826, 827, ], - "id": 410, + "id": 412, "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", "man_dir": "", "name": "which-builtin-type", @@ -19968,7 +20019,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 830, 831, ], - "id": 411, + "id": 413, "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", "man_dir": "", "name": "which-collection", @@ -19990,7 +20041,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 835, 836, ], - "id": 412, + "id": 414, "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", "man_dir": "", "name": "which-typed-array", @@ -20006,7 +20057,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 413, + "id": 415, "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "man_dir": "", "name": "word-wrap", @@ -20026,7 +20077,27 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 838, 839, ], - "id": 414, + "id": 416, + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "man_dir": "", + "name": "wrap-ansi", + "name_hash": "6417752039399150421", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "tag": "npm", + "value": "7.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 840, + 841, + 842, + ], + "id": 417, "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "man_dir": "", "name": "wrap-ansi", @@ -20042,7 +20113,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 415, + "id": 418, "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "man_dir": "", "name": "wrappy", @@ -20061,7 +20132,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 843, 844, ], - "id": 416, + "id": 419, "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "man_dir": "", "name": "ws", @@ -20077,7 +20148,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 417, + "id": 420, "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "man_dir": "", "name": "y18n", @@ -20093,7 +20164,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 418, + "id": 421, "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "man_dir": "", "name": "yallist", @@ -20112,7 +20183,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "name": "yaml", }, "dependencies": [], - "id": 419, + "id": 422, "integrity": "sha512-sntgmxj8o7DE7g/Qi60cqpLBA3HG3STcDA0kO+WfB05jEKhZMbY7umNm2rBpQvsmZ16/lPXCJGW2672dgOUkrg==", "man_dir": "", "name": "yaml", @@ -20136,7 +20207,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 850, 851, ], - "id": 420, + "id": 423, "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "man_dir": "", "name": "yargs", @@ -20152,7 +20223,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 421, + "id": 424, "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "man_dir": "", "name": "yargs-parser", @@ -20171,7 +20242,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 852, 853, ], - "id": 422, + "id": 425, "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "man_dir": "", "name": "yauzl", @@ -20187,7 +20258,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 423, + "id": 426, "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "man_dir": "", "name": "yocto-queue", @@ -20203,7 +20274,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 424, + "id": 427, "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "man_dir": "", "name": "zod", @@ -20223,7 +20294,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 855, 856, ], - "id": 425, + "id": 428, "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "man_dir": "", "name": "chalk", @@ -20243,7 +20314,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 858, 859, ], - "id": 426, + "id": 429, "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "man_dir": "", "name": "string-width", @@ -20261,7 +20332,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 860, ], - "id": 427, + "id": 430, "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "man_dir": "", "name": "strip-ansi", @@ -20281,7 +20352,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 862, 863, ], - "id": 428, + "id": 431, "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "man_dir": "", "name": "wrap-ansi", @@ -20299,7 +20370,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 864, ], - "id": 429, + "id": 432, "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "man_dir": "", "name": "debug", @@ -20320,7 +20391,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 865, ], - "id": 430, + "id": 433, "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", "name": "semver", @@ -20338,7 +20409,25 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 866, ], - "id": 431, + "id": 434, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 867, + ], + "id": 435, "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", "man_dir": "", "name": "@types/node", @@ -20356,7 +20445,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 868, ], - "id": 432, + "id": 436, "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "man_dir": "", "name": "minimatch", @@ -20370,29 +20459,104 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "scripts": {}, }, { - "bin": null, + "bin": { + "file": "bin/semver.js", + "name": "semver", + }, "dependencies": [ - 871, + 869, ], - "id": 433, - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "id": 437, + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", - "name": "glob-parent", - "name_hash": "11965780159102682782", + "name": "semver", + "name_hash": "16367367531761322261", "origin": "npm", "resolution": { - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", "tag": "npm", - "value": "5.1.2", + "value": "7.6.0", }, "scripts": {}, }, { "bin": null, "dependencies": [ - 872, + 870, ], - "id": 434, + "id": 438, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 871, + ], + "id": 439, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 872, + ], + "id": 440, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 873, + ], + "id": 441, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 874, + ], + "id": 442, "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "man_dir": "", "name": "debug", @@ -20410,7 +20574,25 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 875, ], - "id": 435, + "id": 443, + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "man_dir": "", + "name": "doctrine", + "name_hash": "17204823894354646410", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "tag": "npm", + "value": "2.1.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 876, + ], + "id": 444, "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "man_dir": "", "name": "doctrine", @@ -20433,7 +20615,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 878, 879, ], - "id": 436, + "id": 445, "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", "man_dir": "", "name": "resolve", @@ -20446,12 +20628,30 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 880, + ], + "id": 446, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 881, ], - "id": 437, + "id": 447, "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "man_dir": "", "name": "minimatch", @@ -20471,7 +20671,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 883, 884, ], - "id": 438, + "id": 448, "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "man_dir": "", "name": "postcss", @@ -20487,7 +20687,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 439, + "id": 449, "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "man_dir": "", "name": "lru-cache", @@ -20503,7 +20703,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 440, + "id": 450, "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", "man_dir": "", "name": "lilconfig", @@ -20526,7 +20726,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` 889, 890, ], - "id": 441, + "id": 451, "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "man_dir": "", "name": "glob", @@ -20542,7 +20742,23 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 442, + "id": 452, + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "man_dir": "", + "name": "emoji-regex", + "name_hash": "4954026511424972012", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "tag": "npm", + "value": "8.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [], + "id": 453, "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "man_dir": "", "name": "emoji-regex", @@ -20560,7 +20776,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 891, ], - "id": 443, + "id": 454, "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "man_dir": "", "name": "ansi-styles", @@ -20576,7 +20792,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 444, + "id": 455, "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "man_dir": "", "name": "escape-string-regexp", @@ -20594,7 +20810,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 892, ], - "id": 445, + "id": 456, "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "man_dir": "", "name": "supports-color", @@ -20610,7 +20826,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 446, + "id": 457, "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "man_dir": "", "name": "ansi-regex", @@ -20626,7 +20842,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 447, + "id": 458, "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "man_dir": "", "name": "ansi-styles", @@ -20644,7 +20860,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 893, ], - "id": 448, + "id": 459, "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "man_dir": "", "name": "lru-cache", @@ -20662,7 +20878,43 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 894, ], - "id": 449, + "id": 460, + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "man_dir": "", + "name": "brace-expansion", + "name_hash": "2949258092693339993", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "tag": "npm", + "value": "2.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 895, + ], + "id": 461, + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "man_dir": "", + "name": "lru-cache", + "name_hash": "15261810304153928944", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "tag": "npm", + "value": "6.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 896, + ], + "id": 462, "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "man_dir": "", "name": "brace-expansion", @@ -20680,7 +20932,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": [ 897, ], - "id": 450, + "id": 463, "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "man_dir": "", "name": "color-convert", @@ -20696,7 +20948,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 451, + "id": 464, "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "man_dir": "", "name": "has-flag", @@ -20712,7 +20964,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "bin": null, "dependencies": [], - "id": 452, + "id": 465, "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "man_dir": "", "name": "color-name", @@ -22199,243 +22451,243 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` }, "string-width-cjs": { "id": 36, - "package_id": 367, + "package_id": 368, }, "string.prototype.matchall": { "id": 409, - "package_id": 368, + "package_id": 369, }, "string.prototype.trim": { "id": 259, - "package_id": 369, + "package_id": 370, }, "string.prototype.trimend": { "id": 260, - "package_id": 370, + "package_id": 371, }, "string.prototype.trimstart": { "id": 261, - "package_id": 371, + "package_id": 372, }, "strip-ansi": { "id": 330, - "package_id": 372, + "package_id": 373, }, "strip-ansi-cjs": { "id": 38, - "package_id": 372, + "package_id": 374, }, "strip-bom": { "id": 778, - "package_id": 373, + "package_id": 375, }, "strip-json-comments": { "id": 31, - "package_id": 374, + "package_id": 376, }, "styled-jsx": { "id": 561, - "package_id": 375, + "package_id": 377, }, "sucrase": { "id": 762, - "package_id": 376, + "package_id": 378, }, "supports-color": { "id": 172, - "package_id": 377, + "package_id": 379, }, "supports-preserve-symlinks-flag": { "id": 666, - "package_id": 378, + "package_id": 380, }, "tailwindcss": { "id": 12, - "package_id": 379, + "package_id": 381, }, "tapable": { "id": 220, - "package_id": 380, + "package_id": 382, }, "tar-fs": { "id": 56, - "package_id": 381, + "package_id": 383, }, "tar-stream": { "id": 766, - "package_id": 382, + "package_id": 384, }, "text-decoder": { "id": 700, - "package_id": 383, + "package_id": 385, }, "text-table": { "id": 331, - "package_id": 384, + "package_id": 386, }, "thenify": { "id": 772, - "package_id": 385, + "package_id": 387, }, "thenify-all": { "id": 541, - "package_id": 386, + "package_id": 388, }, "through": { "id": 805, - "package_id": 387, + "package_id": 389, }, "to-regex-range": { "id": 430, - "package_id": 388, + "package_id": 390, }, "ts-api-utils": { "id": 81, - "package_id": 389, + "package_id": 391, }, "ts-interface-checker": { "id": 739, - "package_id": 390, + "package_id": 392, }, "tsconfig-paths": { "id": 373, - "package_id": 391, + "package_id": 393, }, "tslib": { "id": 59, - "package_id": 392, + "package_id": 394, }, "type-check": { "id": 533, - "package_id": 393, + "package_id": 395, }, "type-fest": { "id": 466, - "package_id": 394, + "package_id": 396, }, "typed-array-buffer": { "id": 262, - "package_id": 395, + "package_id": 397, }, "typed-array-byte-length": { "id": 263, - "package_id": 396, + "package_id": 398, }, "typed-array-byte-offset": { "id": 264, - "package_id": 397, + "package_id": 399, }, "typed-array-length": { "id": 265, - "package_id": 398, + "package_id": 400, }, "typescript": { "id": 13, - "package_id": 399, + "package_id": 401, }, "unbox-primitive": { "id": 266, - "package_id": 400, + "package_id": 402, }, "unbzip2-stream": { "id": 57, - "package_id": 401, + "package_id": 403, }, "undici-types": { - "id": 866, - "package_id": 402, + "id": 870, + "package_id": 404, }, "universalify": { "id": 441, - "package_id": 403, + "package_id": 405, }, "update-browserslist-db": { "id": 160, - "package_id": 404, + "package_id": 406, }, "uri-js": { "id": 89, - "package_id": 405, + "package_id": 407, }, "urlpattern-polyfill": { "id": 183, - "package_id": 406, + "package_id": 408, }, "util-deprecate": { "id": 624, - "package_id": 407, + "package_id": 409, }, "which": { "id": 196, - "package_id": 408, + "package_id": 410, }, "which-boxed-primitive": { "id": 803, - "package_id": 409, + "package_id": 411, }, "which-builtin-type": { "id": 659, - "package_id": 410, + "package_id": 412, }, "which-collection": { "id": 826, - "package_id": 411, + "package_id": 413, }, "which-typed-array": { "id": 267, - "package_id": 412, + "package_id": 414, }, "word-wrap": { "id": 588, - "package_id": 413, + "package_id": 415, }, "wrap-ansi": { "id": 187, - "package_id": 414, + "package_id": 416, }, "wrap-ansi-cjs": { "id": 40, - "package_id": 414, + "package_id": 417, }, "wrappy": { "id": 582, - "package_id": 415, + "package_id": 418, }, "ws": { "id": 646, - "package_id": 416, + "package_id": 419, }, "y18n": { "id": 850, - "package_id": 417, + "package_id": 420, }, "yallist": { "id": 893, - "package_id": 418, + "package_id": 421, }, "yaml": { "id": 620, - "package_id": 419, + "package_id": 422, }, "yargs": { "id": 58, - "package_id": 420, + "package_id": 423, }, "yargs-parser": { "id": 851, - "package_id": 421, + "package_id": 424, }, "yauzl": { "id": 421, - "package_id": 422, + "package_id": 425, }, "yocto-queue": { "id": 589, - "package_id": 423, + "package_id": 426, }, "zod": { "id": 184, - "package_id": 424, + "package_id": 427, }, }, "depth": 0, @@ -22446,7 +22698,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "@types/node": { "id": 163, - "package_id": 431, + "package_id": 438, }, }, "depth": 1, @@ -22457,7 +22709,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "postcss": { "id": 560, - "package_id": 438, + "package_id": 448, }, }, "depth": 1, @@ -22468,7 +22720,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "@types/node": { "id": 64, - "package_id": 431, + "package_id": 434, }, }, "depth": 1, @@ -22479,7 +22731,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "debug": { "id": 343, - "package_id": 434, + "package_id": 440, }, }, "depth": 1, @@ -22490,11 +22742,11 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "debug": { "id": 361, - "package_id": 434, + "package_id": 442, }, "doctrine": { "id": 362, - "package_id": 435, + "package_id": 443, }, }, "depth": 1, @@ -22505,11 +22757,11 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "doctrine": { "id": 397, - "package_id": 435, + "package_id": 444, }, "resolve": { "id": 407, - "package_id": 436, + "package_id": 445, }, }, "depth": 1, @@ -22520,11 +22772,11 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "debug": { "id": 51, - "package_id": 429, + "package_id": 432, }, "semver": { "id": 55, - "package_id": 430, + "package_id": 433, }, }, "depth": 1, @@ -22535,7 +22787,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "glob-parent": { "id": 176, - "package_id": 433, + "package_id": 439, }, }, "depth": 1, @@ -22546,7 +22798,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "glob-parent": { "id": 424, - "package_id": 433, + "package_id": 446, }, }, "depth": 1, @@ -22557,7 +22809,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "lilconfig": { "id": 619, - "package_id": 440, + "package_id": 450, }, }, "depth": 1, @@ -22568,7 +22820,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "minimatch": { "id": 462, - "package_id": 437, + "package_id": 447, }, }, "depth": 1, @@ -22579,11 +22831,11 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "minimatch": { "id": 79, - "package_id": 432, + "package_id": 436, }, "semver": { "id": 80, - "package_id": 430, + "package_id": 437, }, }, "depth": 1, @@ -22594,7 +22846,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "debug": { "id": 355, - "package_id": 434, + "package_id": 441, }, }, "depth": 1, @@ -22605,7 +22857,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "lru-cache": { "id": 865, - "package_id": 448, + "package_id": 459, }, }, "depth": 2, @@ -22616,7 +22868,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "glob": { "id": 667, - "package_id": 441, + "package_id": 451, }, }, "depth": 1, @@ -22627,7 +22879,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "brace-expansion": { "id": 881, - "package_id": 449, + "package_id": 462, }, }, "depth": 2, @@ -22638,7 +22890,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "lru-cache": { "id": 606, - "package_id": 439, + "package_id": 449, }, }, "depth": 1, @@ -22649,7 +22901,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "brace-expansion": { "id": 868, - "package_id": 449, + "package_id": 460, }, }, "depth": 2, @@ -22659,8 +22911,8 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "dependencies": { "lru-cache": { - "id": 865, - "package_id": 448, + "id": 869, + "package_id": 461, }, }, "depth": 2, @@ -22671,7 +22923,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "@types/node": { "id": 65, - "package_id": 431, + "package_id": 435, }, }, "depth": 1, @@ -22682,7 +22934,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "emoji-regex": { "id": 701, - "package_id": 442, + "package_id": 452, }, }, "depth": 1, @@ -22693,15 +22945,15 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "string-width": { "id": 35, - "package_id": 426, + "package_id": 429, }, "strip-ansi": { "id": 37, - "package_id": 427, + "package_id": 430, }, "wrap-ansi": { "id": 39, - "package_id": 428, + "package_id": 431, }, }, "depth": 1, @@ -22712,7 +22964,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "chalk": { "id": 17, - "package_id": 425, + "package_id": 428, }, }, "depth": 1, @@ -22722,8 +22974,8 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` { "dependencies": { "emoji-regex": { - "id": 701, - "package_id": 442, + "id": 704, + "package_id": 453, }, }, "depth": 1, @@ -22734,7 +22986,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "ansi-regex": { "id": 860, - "package_id": 446, + "package_id": 457, }, }, "depth": 2, @@ -22745,7 +22997,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "ansi-styles": { "id": 861, - "package_id": 447, + "package_id": 458, }, }, "depth": 2, @@ -22756,15 +23008,15 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "ansi-styles": { "id": 854, - "package_id": 443, + "package_id": 454, }, "escape-string-regexp": { "id": 855, - "package_id": 444, + "package_id": 455, }, "supports-color": { "id": 856, - "package_id": 445, + "package_id": 456, }, }, "depth": 2, @@ -22775,7 +23027,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "color-convert": { "id": 891, - "package_id": 450, + "package_id": 463, }, }, "depth": 3, @@ -22786,7 +23038,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "has-flag": { "id": 892, - "package_id": 451, + "package_id": 464, }, }, "depth": 3, @@ -22797,7 +23049,7 @@ exports[`hot reloading works on the client (+ tailwind hmr) 1`] = ` "dependencies": { "color-name": { "id": 897, - "package_id": 452, + "package_id": 465, }, }, "depth": 4, diff --git a/test/integration/next-pages/test/__snapshots__/next-build.test.ts.snap b/test/integration/next-pages/test/__snapshots__/next-build.test.ts.snap index d64c703ce138ef..2fa624a519a12e 100644 --- a/test/integration/next-pages/test/__snapshots__/next-build.test.ts.snap +++ b/test/integration/next-pages/test/__snapshots__/next-build.test.ts.snap @@ -170,7 +170,7 @@ exports[`next build works: bun 1`] = ` "name": "tailwindcss", "version": "==3.3.3", }, - "package_id": 379, + "package_id": 381, }, { "behavior": { @@ -183,7 +183,7 @@ exports[`next build works: bun 1`] = ` "name": "typescript", "version": "==5.2.2", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -235,7 +235,7 @@ exports[`next build works: bun 1`] = ` "name": "chalk", "version": ">=2.4.2 <3.0.0", }, - "package_id": 425, + "package_id": 428, }, { "behavior": { @@ -417,7 +417,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-json-comments", "version": ">=3.1.1 <4.0.0", }, - "package_id": 374, + "package_id": 376, }, { "behavior": { @@ -469,7 +469,7 @@ exports[`next build works: bun 1`] = ` "name": "string-width", "version": ">=5.1.2 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -483,7 +483,7 @@ exports[`next build works: bun 1`] = ` "name": "string-width", "version": ">=4.2.0 <5.0.0", }, - "package_id": 367, + "package_id": 368, }, { "behavior": { @@ -496,7 +496,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -510,7 +510,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 374, }, { "behavior": { @@ -523,7 +523,7 @@ exports[`next build works: bun 1`] = ` "name": "wrap-ansi", "version": ">=8.1.0 <9.0.0", }, - "package_id": 428, + "package_id": 431, }, { "behavior": { @@ -537,7 +537,7 @@ exports[`next build works: bun 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 417, }, { "behavior": { @@ -680,7 +680,7 @@ exports[`next build works: bun 1`] = ` "name": "debug", "version": "==4.3.4", }, - "package_id": 429, + "package_id": 432, }, { "behavior": { @@ -732,7 +732,7 @@ exports[`next build works: bun 1`] = ` "name": "semver", "version": "==7.6.0", }, - "package_id": 430, + "package_id": 433, }, { "behavior": { @@ -745,7 +745,7 @@ exports[`next build works: bun 1`] = ` "name": "tar-fs", "version": "==3.0.5", }, - "package_id": 381, + "package_id": 383, }, { "behavior": { @@ -758,7 +758,7 @@ exports[`next build works: bun 1`] = ` "name": "unbzip2-stream", "version": "==1.4.3", }, - "package_id": 401, + "package_id": 403, }, { "behavior": { @@ -771,7 +771,7 @@ exports[`next build works: bun 1`] = ` "name": "yargs", "version": "==17.7.2", }, - "package_id": 420, + "package_id": 423, }, { "behavior": { @@ -784,7 +784,7 @@ exports[`next build works: bun 1`] = ` "name": "tslib", "version": ">=2.4.0 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -849,7 +849,7 @@ exports[`next build works: bun 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 434, }, { "behavior": { @@ -862,7 +862,7 @@ exports[`next build works: bun 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 435, }, { "behavior": { @@ -1044,7 +1044,7 @@ exports[`next build works: bun 1`] = ` "name": "minimatch", "version": "==9.0.3", }, - "package_id": 432, + "package_id": 436, }, { "behavior": { @@ -1057,7 +1057,7 @@ exports[`next build works: bun 1`] = ` "name": "semver", "version": ">=7.5.4 <8.0.0", }, - "package_id": 430, + "package_id": 437, }, { "behavior": { @@ -1070,7 +1070,7 @@ exports[`next build works: bun 1`] = ` "name": "ts-api-utils", "version": ">=1.0.1 <2.0.0", }, - "package_id": 389, + "package_id": 391, }, { "behavior": { @@ -1174,7 +1174,7 @@ exports[`next build works: bun 1`] = ` "name": "uri-js", "version": ">=4.2.2 <5.0.0", }, - "package_id": 405, + "package_id": 407, }, { "behavior": { @@ -1824,7 +1824,7 @@ exports[`next build works: bun 1`] = ` "name": "tslib", "version": ">=2.0.1 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -2097,7 +2097,7 @@ exports[`next build works: bun 1`] = ` "name": "update-browserslist-db", "version": ">=1.0.13 <2.0.0", }, - "package_id": 404, + "package_id": 406, }, { "behavior": { @@ -2136,7 +2136,7 @@ exports[`next build works: bun 1`] = ` "name": "@types/node", "version": ">=20.12.8 <20.13.0", }, - "package_id": 431, + "package_id": 438, }, { "behavior": { @@ -2253,7 +2253,7 @@ exports[`next build works: bun 1`] = ` "name": "supports-color", "version": ">=7.1.0 <8.0.0", }, - "package_id": 377, + "package_id": 379, }, { "behavior": { @@ -2305,7 +2305,7 @@ exports[`next build works: bun 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <5.2.0", }, - "package_id": 433, + "package_id": 439, }, { "behavior": { @@ -2396,7 +2396,7 @@ exports[`next build works: bun 1`] = ` "name": "urlpattern-polyfill", "version": "==10.0.0", }, - "package_id": 406, + "package_id": 408, }, { "behavior": { @@ -2409,7 +2409,7 @@ exports[`next build works: bun 1`] = ` "name": "zod", "version": "==3.23.8", }, - "package_id": 424, + "package_id": 427, }, { "behavior": { @@ -2435,7 +2435,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -2448,7 +2448,7 @@ exports[`next build works: bun 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 416, }, { "behavior": { @@ -2475,7 +2475,7 @@ exports[`next build works: bun 1`] = ` "name": "typescript", "version": ">=4.9.5", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -2566,7 +2566,7 @@ exports[`next build works: bun 1`] = ` "name": "which", "version": ">=2.0.1 <3.0.0", }, - "package_id": 408, + "package_id": 410, }, { "behavior": { @@ -2878,7 +2878,7 @@ exports[`next build works: bun 1`] = ` "name": "tapable", "version": ">=2.2.0 <3.0.0", }, - "package_id": 380, + "package_id": 382, }, { "behavior": { @@ -3385,7 +3385,7 @@ exports[`next build works: bun 1`] = ` "name": "string.prototype.trim", "version": ">=1.2.9 <2.0.0", }, - "package_id": 369, + "package_id": 370, }, { "behavior": { @@ -3398,7 +3398,7 @@ exports[`next build works: bun 1`] = ` "name": "string.prototype.trimend", "version": ">=1.0.8 <2.0.0", }, - "package_id": 370, + "package_id": 371, }, { "behavior": { @@ -3411,7 +3411,7 @@ exports[`next build works: bun 1`] = ` "name": "string.prototype.trimstart", "version": ">=1.0.8 <2.0.0", }, - "package_id": 371, + "package_id": 372, }, { "behavior": { @@ -3424,7 +3424,7 @@ exports[`next build works: bun 1`] = ` "name": "typed-array-buffer", "version": ">=1.0.2 <2.0.0", }, - "package_id": 395, + "package_id": 397, }, { "behavior": { @@ -3437,7 +3437,7 @@ exports[`next build works: bun 1`] = ` "name": "typed-array-byte-length", "version": ">=1.0.1 <2.0.0", }, - "package_id": 396, + "package_id": 398, }, { "behavior": { @@ -3450,7 +3450,7 @@ exports[`next build works: bun 1`] = ` "name": "typed-array-byte-offset", "version": ">=1.0.2 <2.0.0", }, - "package_id": 397, + "package_id": 399, }, { "behavior": { @@ -3463,7 +3463,7 @@ exports[`next build works: bun 1`] = ` "name": "typed-array-length", "version": ">=1.0.6 <2.0.0", }, - "package_id": 398, + "package_id": 400, }, { "behavior": { @@ -3476,7 +3476,7 @@ exports[`next build works: bun 1`] = ` "name": "unbox-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 400, + "package_id": 402, }, { "behavior": { @@ -3489,7 +3489,7 @@ exports[`next build works: bun 1`] = ` "name": "which-typed-array", "version": ">=1.1.15 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -4308,7 +4308,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -4321,7 +4321,7 @@ exports[`next build works: bun 1`] = ` "name": "text-table", "version": ">=0.2.0 <0.3.0", }, - "package_id": 384, + "package_id": 386, }, { "behavior": { @@ -4348,7 +4348,7 @@ exports[`next build works: bun 1`] = ` "name": "typescript", "version": ">=3.3.1", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -4478,7 +4478,7 @@ exports[`next build works: bun 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 440, }, { "behavior": { @@ -4634,7 +4634,7 @@ exports[`next build works: bun 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 441, }, { "behavior": { @@ -4712,7 +4712,7 @@ exports[`next build works: bun 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 442, }, { "behavior": { @@ -4725,7 +4725,7 @@ exports[`next build works: bun 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 443, }, { "behavior": { @@ -4868,7 +4868,7 @@ exports[`next build works: bun 1`] = ` "name": "tsconfig-paths", "version": ">=3.15.0 <4.0.0", }, - "package_id": 391, + "package_id": 393, }, { "behavior": { @@ -5180,7 +5180,7 @@ exports[`next build works: bun 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 444, }, { "behavior": { @@ -5310,7 +5310,7 @@ exports[`next build works: bun 1`] = ` "name": "resolve", "version": ">=2.0.0-next.5 <3.0.0", }, - "package_id": 436, + "package_id": 445, }, { "behavior": { @@ -5336,7 +5336,7 @@ exports[`next build works: bun 1`] = ` "name": "string.prototype.matchall", "version": ">=4.0.11 <5.0.0", }, - "package_id": 368, + "package_id": 369, }, { "behavior": { @@ -5492,7 +5492,7 @@ exports[`next build works: bun 1`] = ` "name": "yauzl", "version": ">=2.10.0 <3.0.0", }, - "package_id": 422, + "package_id": 425, }, { "behavior": { @@ -5531,7 +5531,7 @@ exports[`next build works: bun 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <6.0.0", }, - "package_id": 433, + "package_id": 446, }, { "behavior": { @@ -5609,7 +5609,7 @@ exports[`next build works: bun 1`] = ` "name": "to-regex-range", "version": ">=5.0.1 <6.0.0", }, - "package_id": 388, + "package_id": 390, }, { "behavior": { @@ -5752,7 +5752,7 @@ exports[`next build works: bun 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6025,7 +6025,7 @@ exports[`next build works: bun 1`] = ` "name": "minimatch", "version": ">=9.0.1 <10.0.0", }, - "package_id": 437, + "package_id": 447, }, { "behavior": { @@ -6077,7 +6077,7 @@ exports[`next build works: bun 1`] = ` "name": "type-fest", "version": ">=0.20.2 <0.21.0", }, - "package_id": 394, + "package_id": 396, }, { "behavior": { @@ -6337,7 +6337,7 @@ exports[`next build works: bun 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -6662,7 +6662,7 @@ exports[`next build works: bun 1`] = ` "name": "which-typed-array", "version": ">=1.1.14 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -6844,7 +6844,7 @@ exports[`next build works: bun 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -6948,7 +6948,7 @@ exports[`next build works: bun 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7052,7 +7052,7 @@ exports[`next build works: bun 1`] = ` "name": "thenify-all", "version": ">=1.0.0 <2.0.0", }, - "package_id": 386, + "package_id": 388, }, { "behavior": { @@ -7301,7 +7301,7 @@ exports[`next build works: bun 1`] = ` "name": "postcss", "version": "==8.4.31", }, - "package_id": 438, + "package_id": 448, }, { "behavior": { @@ -7314,7 +7314,7 @@ exports[`next build works: bun 1`] = ` "name": "styled-jsx", "version": "==5.1.1", }, - "package_id": 375, + "package_id": 377, }, { "behavior": { @@ -7587,7 +7587,7 @@ exports[`next build works: bun 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -7652,7 +7652,7 @@ exports[`next build works: bun 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -7665,7 +7665,7 @@ exports[`next build works: bun 1`] = ` "name": "word-wrap", "version": ">=1.2.5 <2.0.0", }, - "package_id": 413, + "package_id": 415, }, { "behavior": { @@ -7678,7 +7678,7 @@ exports[`next build works: bun 1`] = ` "name": "yocto-queue", "version": ">=0.1.0 <0.2.0", }, - "package_id": 423, + "package_id": 426, }, { "behavior": { @@ -7899,7 +7899,7 @@ exports[`next build works: bun 1`] = ` "name": "lru-cache", "version": ">=10.2.0 <11.0.0", }, - "package_id": 439, + "package_id": 449, }, { "behavior": { @@ -8070,7 +8070,7 @@ exports[`next build works: bun 1`] = ` "name": "lilconfig", "version": ">=3.0.0 <4.0.0", }, - "package_id": 440, + "package_id": 450, }, { "behavior": { @@ -8083,7 +8083,7 @@ exports[`next build works: bun 1`] = ` "name": "yaml", "version": ">=2.3.4 <3.0.0", }, - "package_id": 419, + "package_id": 422, }, { "behavior": { @@ -8135,7 +8135,7 @@ exports[`next build works: bun 1`] = ` "name": "util-deprecate", "version": ">=1.0.2 <2.0.0", }, - "package_id": 407, + "package_id": 409, }, { "behavior": { @@ -8421,7 +8421,7 @@ exports[`next build works: bun 1`] = ` "name": "ws", "version": "==8.17.1", }, - "package_id": 416, + "package_id": 419, }, { "behavior": { @@ -8590,7 +8590,7 @@ exports[`next build works: bun 1`] = ` "name": "which-builtin-type", "version": ">=1.1.3 <2.0.0", }, - "package_id": 410, + "package_id": 412, }, { "behavior": { @@ -8681,7 +8681,7 @@ exports[`next build works: bun 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -8694,7 +8694,7 @@ exports[`next build works: bun 1`] = ` "name": "glob", "version": ">=7.1.3 <8.0.0", }, - "package_id": 441, + "package_id": 451, }, { "behavior": { @@ -9123,7 +9123,7 @@ exports[`next build works: bun 1`] = ` "name": "text-decoder", "version": ">=1.1.0 <2.0.0", }, - "package_id": 383, + "package_id": 385, }, { "behavior": { @@ -9136,7 +9136,7 @@ exports[`next build works: bun 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": 442, + "package_id": 452, }, { "behavior": { @@ -9162,7 +9162,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -9175,7 +9175,7 @@ exports[`next build works: bun 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": null, + "package_id": 453, }, { "behavior": { @@ -9188,7 +9188,7 @@ exports[`next build works: bun 1`] = ` "name": "is-fullwidth-code-point", "version": ">=3.0.0 <4.0.0", }, - "package_id": null, + "package_id": 228, }, { "behavior": { @@ -9201,7 +9201,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -9513,7 +9513,7 @@ exports[`next build works: bun 1`] = ` "name": "ansi-regex", "version": ">=5.0.1 <6.0.0", }, - "package_id": null, + "package_id": 55, }, { "behavior": { @@ -9630,7 +9630,7 @@ exports[`next build works: bun 1`] = ` "name": "ts-interface-checker", "version": ">=0.1.9 <0.2.0", }, - "package_id": 390, + "package_id": 392, }, { "behavior": { @@ -9929,7 +9929,7 @@ exports[`next build works: bun 1`] = ` "name": "sucrase", "version": ">=3.32.0 <4.0.0", }, - "package_id": 376, + "package_id": 378, }, { "behavior": { @@ -9981,7 +9981,7 @@ exports[`next build works: bun 1`] = ` "name": "tar-stream", "version": ">=3.1.5 <4.0.0", }, - "package_id": 382, + "package_id": 384, }, { "behavior": { @@ -10059,7 +10059,7 @@ exports[`next build works: bun 1`] = ` "name": "thenify", "version": ">=3.1.0 && <4.0.0", }, - "package_id": 385, + "package_id": 387, }, { "behavior": { @@ -10085,7 +10085,7 @@ exports[`next build works: bun 1`] = ` "name": "typescript", "version": ">=4.2.0", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -10137,7 +10137,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-bom", "version": ">=3.0.0 <4.0.0", }, - "package_id": 373, + "package_id": 375, }, { "behavior": { @@ -10462,7 +10462,7 @@ exports[`next build works: bun 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10488,7 +10488,7 @@ exports[`next build works: bun 1`] = ` "name": "through", "version": ">=2.3.8 <3.0.0", }, - "package_id": 387, + "package_id": 389, }, { "behavior": { @@ -10748,7 +10748,7 @@ exports[`next build works: bun 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -10761,7 +10761,7 @@ exports[`next build works: bun 1`] = ` "name": "which-collection", "version": ">=1.0.1 <2.0.0", }, - "package_id": 411, + "package_id": 413, }, { "behavior": { @@ -10774,7 +10774,7 @@ exports[`next build works: bun 1`] = ` "name": "which-typed-array", "version": ">=1.1.9 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -10930,7 +10930,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -10943,7 +10943,7 @@ exports[`next build works: bun 1`] = ` "name": "ansi-styles", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 56, }, { "behavior": { @@ -10956,7 +10956,7 @@ exports[`next build works: bun 1`] = ` "name": "string-width", "version": ">=4.1.0 <5.0.0", }, - "package_id": null, + "package_id": 367, }, { "behavior": { @@ -10969,7 +10969,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -11075,7 +11075,7 @@ exports[`next build works: bun 1`] = ` "name": "y18n", "version": ">=5.0.5 <6.0.0", }, - "package_id": 417, + "package_id": 420, }, { "behavior": { @@ -11088,7 +11088,7 @@ exports[`next build works: bun 1`] = ` "name": "yargs-parser", "version": ">=21.1.1 <22.0.0", }, - "package_id": 421, + "package_id": 424, }, { "behavior": { @@ -11127,7 +11127,7 @@ exports[`next build works: bun 1`] = ` "name": "ansi-styles", "version": ">=3.2.1 <4.0.0", }, - "package_id": 443, + "package_id": 454, }, { "behavior": { @@ -11140,7 +11140,7 @@ exports[`next build works: bun 1`] = ` "name": "escape-string-regexp", "version": ">=1.0.5 <2.0.0", }, - "package_id": 444, + "package_id": 455, }, { "behavior": { @@ -11153,7 +11153,7 @@ exports[`next build works: bun 1`] = ` "name": "supports-color", "version": ">=5.3.0 <6.0.0", }, - "package_id": 445, + "package_id": 456, }, { "behavior": { @@ -11192,7 +11192,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11205,7 +11205,7 @@ exports[`next build works: bun 1`] = ` "name": "ansi-regex", "version": ">=6.0.1 <7.0.0", }, - "package_id": 446, + "package_id": 457, }, { "behavior": { @@ -11218,7 +11218,7 @@ exports[`next build works: bun 1`] = ` "name": "ansi-styles", "version": ">=6.1.0 <7.0.0", }, - "package_id": 447, + "package_id": 458, }, { "behavior": { @@ -11231,7 +11231,7 @@ exports[`next build works: bun 1`] = ` "name": "string-width", "version": ">=5.0.1 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -11244,7 +11244,7 @@ exports[`next build works: bun 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -11270,7 +11270,7 @@ exports[`next build works: bun 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": 448, + "package_id": 459, }, { "behavior": { @@ -11283,7 +11283,7 @@ exports[`next build works: bun 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": 402, + "package_id": 404, }, { "behavior": { @@ -11296,7 +11296,7 @@ exports[`next build works: bun 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11309,7 +11309,7 @@ exports[`next build works: bun 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 460, }, { "behavior": { @@ -11322,7 +11322,7 @@ exports[`next build works: bun 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 461, }, { "behavior": { @@ -11335,7 +11335,7 @@ exports[`next build works: bun 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -11374,7 +11374,7 @@ exports[`next build works: bun 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11387,7 +11387,7 @@ exports[`next build works: bun 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -11413,7 +11413,7 @@ exports[`next build works: bun 1`] = ` "name": "esutils", "version": ">=2.0.2 <3.0.0", }, - "package_id": null, + "package_id": 162, }, { "behavior": { @@ -11452,7 +11452,7 @@ exports[`next build works: bun 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -11465,7 +11465,7 @@ exports[`next build works: bun 1`] = ` "name": "is-glob", "version": ">=4.0.1 <5.0.0", }, - "package_id": null, + "package_id": 230, }, { "behavior": { @@ -11478,7 +11478,7 @@ exports[`next build works: bun 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 462, }, { "behavior": { @@ -11608,7 +11608,7 @@ exports[`next build works: bun 1`] = ` "name": "color-convert", "version": ">=1.9.0 <2.0.0", }, - "package_id": 450, + "package_id": 463, }, { "behavior": { @@ -11621,7 +11621,7 @@ exports[`next build works: bun 1`] = ` "name": "has-flag", "version": ">=3.0.0 <4.0.0", }, - "package_id": 451, + "package_id": 464, }, { "behavior": { @@ -11634,7 +11634,7 @@ exports[`next build works: bun 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": 418, + "package_id": 421, }, { "behavior": { @@ -11660,7 +11660,7 @@ exports[`next build works: bun 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 421, }, { "behavior": { @@ -11673,7 +11673,7 @@ exports[`next build works: bun 1`] = ` "name": "balanced-match", "version": ">=1.0.0 <2.0.0", }, - "package_id": null, + "package_id": 79, }, { "behavior": { @@ -11686,7 +11686,7 @@ exports[`next build works: bun 1`] = ` "name": "color-name", "version": "==1.1.3", }, - "package_id": 452, + "package_id": 465, }, ], "format": "v2", @@ -11731,7 +11731,9 @@ exports[`next build works: bun 1`] = ` "@tootallnate/quickjs-emscripten": 37, "@types/json5": 38, "@types/node": [ - 431, + 434, + 435, + 438, 39, ], "@types/prop-types": 40, @@ -11750,13 +11752,13 @@ exports[`next build works: bun 1`] = ` "agent-base": 53, "ajv": 54, "ansi-regex": [ - 446, + 457, 55, ], "ansi-styles": [ - 447, + 458, 56, - 443, + 454, ], "any-promise": 57, "anymatch": 58, @@ -11790,7 +11792,8 @@ exports[`next build works: bun 1`] = ` "basic-ftp": 86, "binary-extensions": 87, "brace-expansion": [ - 449, + 460, + 462, 88, ], "braces": 89, @@ -11805,7 +11808,7 @@ exports[`next build works: bun 1`] = ` "caniuse-lite": 98, "chalk": [ 99, - 425, + 428, ], "chokidar": 100, "chromium-bidi": 101, @@ -11813,11 +11816,11 @@ exports[`next build works: bun 1`] = ` "cliui": 103, "color-convert": [ 104, - 450, + 463, ], "color-name": [ 105, - 452, + 465, ], "commander": 106, "concat-map": 107, @@ -11832,8 +11835,10 @@ exports[`next build works: bun 1`] = ` "data-view-byte-offset": 116, "debug": [ 117, - 429, - 434, + 432, + 440, + 441, + 442, ], "deep-is": 118, "default-create-template": 0, @@ -11847,13 +11852,15 @@ exports[`next build works: bun 1`] = ` "dlv": 126, "doctrine": [ 127, - 435, + 443, + 444, ], "eastasianwidth": 128, "electron-to-chromium": 129, "emoji-regex": [ 130, - 442, + 452, + 453, ], "end-of-stream": 131, "enhanced-resolve": 132, @@ -11870,7 +11877,7 @@ exports[`next build works: bun 1`] = ` "escalade": 143, "escape-string-regexp": [ 144, - 444, + 455, ], "escodegen": 145, "eslint": 146, @@ -11920,11 +11927,12 @@ exports[`next build works: bun 1`] = ` "get-uri": 190, "glob": [ 191, - 441, + 451, ], "glob-parent": [ 192, - 433, + 439, + 446, ], "globals": 193, "globalthis": 194, @@ -11935,7 +11943,7 @@ exports[`next build works: bun 1`] = ` "has-bigints": 199, "has-flag": [ 200, - 451, + 464, ], "has-property-descriptors": 201, "has-proto": 202, @@ -12001,7 +12009,7 @@ exports[`next build works: bun 1`] = ` "language-tags": 262, "levn": 263, "lilconfig": [ - 440, + 450, 264, ], "lines-and-columns": 265, @@ -12009,15 +12017,16 @@ exports[`next build works: bun 1`] = ` "lodash.merge": 267, "loose-envify": 268, "lru-cache": [ - 439, + 449, 269, - 448, + 459, + 461, ], "merge2": 270, "micromatch": 271, "minimatch": [ - 437, - 432, + 447, + 436, 272, ], "minimist": 273, @@ -12063,7 +12072,7 @@ exports[`next build works: bun 1`] = ` "pirates": 313, "possible-typed-array-names": 314, "postcss": [ - 438, + 448, 315, ], "postcss-import": 316, @@ -12093,7 +12102,7 @@ exports[`next build works: bun 1`] = ` "regexp.prototype.flags": 340, "require-directory": 341, "resolve": [ - 436, + 445, 342, ], "resolve-from": 343, @@ -12105,7 +12114,8 @@ exports[`next build works: bun 1`] = ` "safe-regex-test": 349, "scheduler": 350, "semver": [ - 430, + 433, + 437, 351, ], "set-function-length": 352, @@ -12124,75 +12134,78 @@ exports[`next build works: bun 1`] = ` "streamsearch": 365, "streamx": 366, "string-width": [ - 426, + 429, 367, + 368, ], - "string.prototype.matchall": 368, - "string.prototype.trim": 369, - "string.prototype.trimend": 370, - "string.prototype.trimstart": 371, + "string.prototype.matchall": 369, + "string.prototype.trim": 370, + "string.prototype.trimend": 371, + "string.prototype.trimstart": 372, "strip-ansi": [ - 427, - 372, + 430, + 373, + 374, ], - "strip-bom": 373, - "strip-json-comments": 374, - "styled-jsx": 375, - "sucrase": 376, + "strip-bom": 375, + "strip-json-comments": 376, + "styled-jsx": 377, + "sucrase": 378, "supports-color": [ - 377, - 445, + 379, + 456, ], - "supports-preserve-symlinks-flag": 378, - "tailwindcss": 379, - "tapable": 380, - "tar-fs": 381, - "tar-stream": 382, - "text-decoder": 383, - "text-table": 384, - "thenify": 385, - "thenify-all": 386, - "through": 387, - "to-regex-range": 388, - "ts-api-utils": 389, - "ts-interface-checker": 390, - "tsconfig-paths": 391, - "tslib": 392, - "type-check": 393, - "type-fest": 394, - "typed-array-buffer": 395, - "typed-array-byte-length": 396, - "typed-array-byte-offset": 397, - "typed-array-length": 398, - "typescript": 399, - "unbox-primitive": 400, - "unbzip2-stream": 401, - "undici-types": 402, - "universalify": 403, - "update-browserslist-db": 404, - "uri-js": 405, - "urlpattern-polyfill": 406, - "util-deprecate": 407, - "which": 408, - "which-boxed-primitive": 409, - "which-builtin-type": 410, - "which-collection": 411, - "which-typed-array": 412, - "word-wrap": 413, + "supports-preserve-symlinks-flag": 380, + "tailwindcss": 381, + "tapable": 382, + "tar-fs": 383, + "tar-stream": 384, + "text-decoder": 385, + "text-table": 386, + "thenify": 387, + "thenify-all": 388, + "through": 389, + "to-regex-range": 390, + "ts-api-utils": 391, + "ts-interface-checker": 392, + "tsconfig-paths": 393, + "tslib": 394, + "type-check": 395, + "type-fest": 396, + "typed-array-buffer": 397, + "typed-array-byte-length": 398, + "typed-array-byte-offset": 399, + "typed-array-length": 400, + "typescript": 401, + "unbox-primitive": 402, + "unbzip2-stream": 403, + "undici-types": 404, + "universalify": 405, + "update-browserslist-db": 406, + "uri-js": 407, + "urlpattern-polyfill": 408, + "util-deprecate": 409, + "which": 410, + "which-boxed-primitive": 411, + "which-builtin-type": 412, + "which-collection": 413, + "which-typed-array": 414, + "word-wrap": 415, "wrap-ansi": [ - 428, - 414, + 431, + 416, + 417, ], - "wrappy": 415, - "ws": 416, - "y18n": 417, - "yallist": 418, - "yaml": 419, - "yargs": 420, - "yargs-parser": 421, - "yauzl": 422, - "yocto-queue": 423, - "zod": 424, + "wrappy": 418, + "ws": 419, + "y18n": 420, + "yallist": 421, + "yaml": 422, + "yargs": 423, + "yargs-parser": 424, + "yauzl": 425, + "yocto-queue": 426, + "zod": 427, }, "packages": [ { @@ -19108,6 +19121,26 @@ exports[`next build works: bun 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 704, + 705, + 706, + ], + "id": 368, + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "man_dir": "", + "name": "string-width", + "name_hash": "15727733666069179645", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "tag": "npm", + "value": "4.2.3", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ @@ -19124,7 +19157,7 @@ exports[`next build works: bun 1`] = ` 717, 718, ], - "id": 368, + "id": 369, "integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==", "man_dir": "", "name": "string.prototype.matchall", @@ -19145,7 +19178,7 @@ exports[`next build works: bun 1`] = ` 721, 722, ], - "id": 369, + "id": 370, "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", "man_dir": "", "name": "string.prototype.trim", @@ -19165,7 +19198,7 @@ exports[`next build works: bun 1`] = ` 724, 725, ], - "id": 370, + "id": 371, "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", "man_dir": "", "name": "string.prototype.trimend", @@ -19185,7 +19218,7 @@ exports[`next build works: bun 1`] = ` 727, 728, ], - "id": 371, + "id": 372, "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "man_dir": "", "name": "string.prototype.trimstart", @@ -19203,7 +19236,25 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 729, ], - "id": 372, + "id": 373, + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "man_dir": "", + "name": "strip-ansi", + "name_hash": "13340235767065158173", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "tag": "npm", + "value": "6.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 730, + ], + "id": 374, "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "man_dir": "", "name": "strip-ansi", @@ -19219,7 +19270,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 373, + "id": 375, "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "man_dir": "", "name": "strip-bom", @@ -19235,7 +19286,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 374, + "id": 376, "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "man_dir": "", "name": "strip-json-comments", @@ -19254,7 +19305,7 @@ exports[`next build works: bun 1`] = ` 731, 732, ], - "id": 375, + "id": 377, "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", "man_dir": "", "name": "styled-jsx", @@ -19281,7 +19332,7 @@ exports[`next build works: bun 1`] = ` 738, 739, ], - "id": 376, + "id": 378, "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", "man_dir": "", "name": "sucrase", @@ -19299,7 +19350,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 740, ], - "id": 377, + "id": 379, "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "man_dir": "", "name": "supports-color", @@ -19315,7 +19366,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 378, + "id": 380, "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "man_dir": "", "name": "supports-preserve-symlinks-flag", @@ -19357,7 +19408,7 @@ exports[`next build works: bun 1`] = ` 761, 762, ], - "id": 379, + "id": 381, "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", "man_dir": "", "name": "tailwindcss", @@ -19373,7 +19424,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 380, + "id": 382, "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "man_dir": "", "name": "tapable", @@ -19394,7 +19445,7 @@ exports[`next build works: bun 1`] = ` 765, 766, ], - "id": 381, + "id": 383, "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "man_dir": "", "name": "tar-fs", @@ -19414,7 +19465,7 @@ exports[`next build works: bun 1`] = ` 768, 769, ], - "id": 382, + "id": 384, "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "man_dir": "", "name": "tar-stream", @@ -19432,7 +19483,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 770, ], - "id": 383, + "id": 385, "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", "man_dir": "", "name": "text-decoder", @@ -19448,7 +19499,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 384, + "id": 386, "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "man_dir": "", "name": "text-table", @@ -19466,7 +19517,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 771, ], - "id": 385, + "id": 387, "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", "man_dir": "", "name": "thenify", @@ -19484,7 +19535,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 772, ], - "id": 386, + "id": 388, "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", "man_dir": "", "name": "thenify-all", @@ -19500,7 +19551,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 387, + "id": 389, "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "man_dir": "", "name": "through", @@ -19518,7 +19569,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 773, ], - "id": 388, + "id": 390, "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "man_dir": "", "name": "to-regex-range", @@ -19536,7 +19587,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 774, ], - "id": 389, + "id": 391, "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "man_dir": "", "name": "ts-api-utils", @@ -19552,7 +19603,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 390, + "id": 392, "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "man_dir": "", "name": "ts-interface-checker", @@ -19573,7 +19624,7 @@ exports[`next build works: bun 1`] = ` 777, 778, ], - "id": 391, + "id": 393, "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "man_dir": "", "name": "tsconfig-paths", @@ -19589,7 +19640,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 392, + "id": 394, "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "man_dir": "", "name": "tslib", @@ -19607,7 +19658,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 779, ], - "id": 393, + "id": 395, "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "man_dir": "", "name": "type-check", @@ -19623,7 +19674,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 394, + "id": 396, "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "man_dir": "", "name": "type-fest", @@ -19643,7 +19694,7 @@ exports[`next build works: bun 1`] = ` 781, 782, ], - "id": 395, + "id": 397, "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", "man_dir": "", "name": "typed-array-buffer", @@ -19665,7 +19716,7 @@ exports[`next build works: bun 1`] = ` 786, 787, ], - "id": 396, + "id": 398, "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", "man_dir": "", "name": "typed-array-byte-length", @@ -19688,7 +19739,7 @@ exports[`next build works: bun 1`] = ` 792, 793, ], - "id": 397, + "id": 399, "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", "man_dir": "", "name": "typed-array-byte-offset", @@ -19711,7 +19762,7 @@ exports[`next build works: bun 1`] = ` 798, 799, ], - "id": 398, + "id": 400, "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "man_dir": "", "name": "typed-array-length", @@ -19730,7 +19781,7 @@ exports[`next build works: bun 1`] = ` "tsserver": "bin/tsserver", }, "dependencies": [], - "id": 399, + "id": 401, "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "man_dir": "", "name": "typescript", @@ -19751,7 +19802,7 @@ exports[`next build works: bun 1`] = ` 802, 803, ], - "id": 400, + "id": 402, "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "man_dir": "", "name": "unbox-primitive", @@ -19770,7 +19821,7 @@ exports[`next build works: bun 1`] = ` 804, 805, ], - "id": 401, + "id": 403, "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "man_dir": "", "name": "unbzip2-stream", @@ -19786,7 +19837,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 402, + "id": 404, "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "man_dir": "", "name": "undici-types", @@ -19802,7 +19853,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 403, + "id": 405, "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "man_dir": "", "name": "universalify", @@ -19825,7 +19876,7 @@ exports[`next build works: bun 1`] = ` 807, 808, ], - "id": 404, + "id": 406, "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "man_dir": "", "name": "update-browserslist-db", @@ -19843,7 +19894,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 809, ], - "id": 405, + "id": 407, "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "man_dir": "", "name": "uri-js", @@ -19859,7 +19910,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 406, + "id": 408, "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==", "man_dir": "", "name": "urlpattern-polyfill", @@ -19875,7 +19926,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 407, + "id": 409, "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "man_dir": "", "name": "util-deprecate", @@ -19896,7 +19947,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 810, ], - "id": 408, + "id": 410, "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "man_dir": "", "name": "which", @@ -19918,7 +19969,7 @@ exports[`next build works: bun 1`] = ` 814, 815, ], - "id": 409, + "id": 411, "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "man_dir": "", "name": "which-boxed-primitive", @@ -19947,7 +19998,7 @@ exports[`next build works: bun 1`] = ` 826, 827, ], - "id": 410, + "id": 412, "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", "man_dir": "", "name": "which-builtin-type", @@ -19968,7 +20019,7 @@ exports[`next build works: bun 1`] = ` 830, 831, ], - "id": 411, + "id": 413, "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", "man_dir": "", "name": "which-collection", @@ -19990,7 +20041,7 @@ exports[`next build works: bun 1`] = ` 835, 836, ], - "id": 412, + "id": 414, "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", "man_dir": "", "name": "which-typed-array", @@ -20006,7 +20057,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 413, + "id": 415, "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "man_dir": "", "name": "word-wrap", @@ -20026,7 +20077,27 @@ exports[`next build works: bun 1`] = ` 838, 839, ], - "id": 414, + "id": 416, + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "man_dir": "", + "name": "wrap-ansi", + "name_hash": "6417752039399150421", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "tag": "npm", + "value": "7.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 840, + 841, + 842, + ], + "id": 417, "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "man_dir": "", "name": "wrap-ansi", @@ -20042,7 +20113,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 415, + "id": 418, "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "man_dir": "", "name": "wrappy", @@ -20061,7 +20132,7 @@ exports[`next build works: bun 1`] = ` 843, 844, ], - "id": 416, + "id": 419, "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "man_dir": "", "name": "ws", @@ -20077,7 +20148,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 417, + "id": 420, "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "man_dir": "", "name": "y18n", @@ -20093,7 +20164,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 418, + "id": 421, "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "man_dir": "", "name": "yallist", @@ -20112,7 +20183,7 @@ exports[`next build works: bun 1`] = ` "name": "yaml", }, "dependencies": [], - "id": 419, + "id": 422, "integrity": "sha512-sntgmxj8o7DE7g/Qi60cqpLBA3HG3STcDA0kO+WfB05jEKhZMbY7umNm2rBpQvsmZ16/lPXCJGW2672dgOUkrg==", "man_dir": "", "name": "yaml", @@ -20136,7 +20207,7 @@ exports[`next build works: bun 1`] = ` 850, 851, ], - "id": 420, + "id": 423, "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "man_dir": "", "name": "yargs", @@ -20152,7 +20223,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 421, + "id": 424, "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "man_dir": "", "name": "yargs-parser", @@ -20171,7 +20242,7 @@ exports[`next build works: bun 1`] = ` 852, 853, ], - "id": 422, + "id": 425, "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "man_dir": "", "name": "yauzl", @@ -20187,7 +20258,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 423, + "id": 426, "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "man_dir": "", "name": "yocto-queue", @@ -20203,7 +20274,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 424, + "id": 427, "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "man_dir": "", "name": "zod", @@ -20223,7 +20294,7 @@ exports[`next build works: bun 1`] = ` 855, 856, ], - "id": 425, + "id": 428, "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "man_dir": "", "name": "chalk", @@ -20243,7 +20314,7 @@ exports[`next build works: bun 1`] = ` 858, 859, ], - "id": 426, + "id": 429, "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "man_dir": "", "name": "string-width", @@ -20261,7 +20332,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 860, ], - "id": 427, + "id": 430, "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "man_dir": "", "name": "strip-ansi", @@ -20281,7 +20352,7 @@ exports[`next build works: bun 1`] = ` 862, 863, ], - "id": 428, + "id": 431, "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "man_dir": "", "name": "wrap-ansi", @@ -20299,7 +20370,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 864, ], - "id": 429, + "id": 432, "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "man_dir": "", "name": "debug", @@ -20320,7 +20391,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 865, ], - "id": 430, + "id": 433, "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", "name": "semver", @@ -20338,7 +20409,25 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 866, ], - "id": 431, + "id": 434, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 867, + ], + "id": 435, "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", "man_dir": "", "name": "@types/node", @@ -20356,7 +20445,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 868, ], - "id": 432, + "id": 436, "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "man_dir": "", "name": "minimatch", @@ -20369,12 +20458,51 @@ exports[`next build works: bun 1`] = ` }, "scripts": {}, }, + { + "bin": { + "file": "bin/semver.js", + "name": "semver", + }, + "dependencies": [ + 869, + ], + "id": 437, + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "man_dir": "", + "name": "semver", + "name_hash": "16367367531761322261", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "tag": "npm", + "value": "7.6.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 870, + ], + "id": 438, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 871, ], - "id": 433, + "id": 439, "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "man_dir": "", "name": "glob-parent", @@ -20392,7 +20520,43 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 872, ], - "id": 434, + "id": 440, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 873, + ], + "id": 441, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 874, + ], + "id": 442, "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "man_dir": "", "name": "debug", @@ -20410,7 +20574,25 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 875, ], - "id": 435, + "id": 443, + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "man_dir": "", + "name": "doctrine", + "name_hash": "17204823894354646410", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "tag": "npm", + "value": "2.1.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 876, + ], + "id": 444, "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "man_dir": "", "name": "doctrine", @@ -20433,7 +20615,7 @@ exports[`next build works: bun 1`] = ` 878, 879, ], - "id": 436, + "id": 445, "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", "man_dir": "", "name": "resolve", @@ -20446,12 +20628,30 @@ exports[`next build works: bun 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 880, + ], + "id": 446, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 881, ], - "id": 437, + "id": 447, "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "man_dir": "", "name": "minimatch", @@ -20471,7 +20671,7 @@ exports[`next build works: bun 1`] = ` 883, 884, ], - "id": 438, + "id": 448, "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "man_dir": "", "name": "postcss", @@ -20487,7 +20687,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 439, + "id": 449, "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "man_dir": "", "name": "lru-cache", @@ -20503,7 +20703,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 440, + "id": 450, "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", "man_dir": "", "name": "lilconfig", @@ -20526,7 +20726,7 @@ exports[`next build works: bun 1`] = ` 889, 890, ], - "id": 441, + "id": 451, "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "man_dir": "", "name": "glob", @@ -20542,7 +20742,23 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 442, + "id": 452, + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "man_dir": "", + "name": "emoji-regex", + "name_hash": "4954026511424972012", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "tag": "npm", + "value": "8.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [], + "id": 453, "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "man_dir": "", "name": "emoji-regex", @@ -20560,7 +20776,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 891, ], - "id": 443, + "id": 454, "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "man_dir": "", "name": "ansi-styles", @@ -20576,7 +20792,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 444, + "id": 455, "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "man_dir": "", "name": "escape-string-regexp", @@ -20594,7 +20810,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 892, ], - "id": 445, + "id": 456, "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "man_dir": "", "name": "supports-color", @@ -20610,7 +20826,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 446, + "id": 457, "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "man_dir": "", "name": "ansi-regex", @@ -20626,7 +20842,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 447, + "id": 458, "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "man_dir": "", "name": "ansi-styles", @@ -20644,7 +20860,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 893, ], - "id": 448, + "id": 459, "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "man_dir": "", "name": "lru-cache", @@ -20662,7 +20878,43 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 894, ], - "id": 449, + "id": 460, + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "man_dir": "", + "name": "brace-expansion", + "name_hash": "2949258092693339993", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "tag": "npm", + "value": "2.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 895, + ], + "id": 461, + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "man_dir": "", + "name": "lru-cache", + "name_hash": "15261810304153928944", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "tag": "npm", + "value": "6.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 896, + ], + "id": 462, "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "man_dir": "", "name": "brace-expansion", @@ -20680,7 +20932,7 @@ exports[`next build works: bun 1`] = ` "dependencies": [ 897, ], - "id": 450, + "id": 463, "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "man_dir": "", "name": "color-convert", @@ -20696,7 +20948,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 451, + "id": 464, "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "man_dir": "", "name": "has-flag", @@ -20712,7 +20964,7 @@ exports[`next build works: bun 1`] = ` { "bin": null, "dependencies": [], - "id": 452, + "id": 465, "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "man_dir": "", "name": "color-name", @@ -22199,243 +22451,243 @@ exports[`next build works: bun 1`] = ` }, "string-width-cjs": { "id": 36, - "package_id": 367, + "package_id": 368, }, "string.prototype.matchall": { "id": 409, - "package_id": 368, + "package_id": 369, }, "string.prototype.trim": { "id": 259, - "package_id": 369, + "package_id": 370, }, "string.prototype.trimend": { "id": 260, - "package_id": 370, + "package_id": 371, }, "string.prototype.trimstart": { "id": 261, - "package_id": 371, + "package_id": 372, }, "strip-ansi": { "id": 330, - "package_id": 372, + "package_id": 373, }, "strip-ansi-cjs": { "id": 38, - "package_id": 372, + "package_id": 374, }, "strip-bom": { "id": 778, - "package_id": 373, + "package_id": 375, }, "strip-json-comments": { "id": 31, - "package_id": 374, + "package_id": 376, }, "styled-jsx": { "id": 561, - "package_id": 375, + "package_id": 377, }, "sucrase": { "id": 762, - "package_id": 376, + "package_id": 378, }, "supports-color": { "id": 172, - "package_id": 377, + "package_id": 379, }, "supports-preserve-symlinks-flag": { "id": 666, - "package_id": 378, + "package_id": 380, }, "tailwindcss": { "id": 12, - "package_id": 379, + "package_id": 381, }, "tapable": { "id": 220, - "package_id": 380, + "package_id": 382, }, "tar-fs": { "id": 56, - "package_id": 381, + "package_id": 383, }, "tar-stream": { "id": 766, - "package_id": 382, + "package_id": 384, }, "text-decoder": { "id": 700, - "package_id": 383, + "package_id": 385, }, "text-table": { "id": 331, - "package_id": 384, + "package_id": 386, }, "thenify": { "id": 772, - "package_id": 385, + "package_id": 387, }, "thenify-all": { "id": 541, - "package_id": 386, + "package_id": 388, }, "through": { "id": 805, - "package_id": 387, + "package_id": 389, }, "to-regex-range": { "id": 430, - "package_id": 388, + "package_id": 390, }, "ts-api-utils": { "id": 81, - "package_id": 389, + "package_id": 391, }, "ts-interface-checker": { "id": 739, - "package_id": 390, + "package_id": 392, }, "tsconfig-paths": { "id": 373, - "package_id": 391, + "package_id": 393, }, "tslib": { "id": 59, - "package_id": 392, + "package_id": 394, }, "type-check": { "id": 533, - "package_id": 393, + "package_id": 395, }, "type-fest": { "id": 466, - "package_id": 394, + "package_id": 396, }, "typed-array-buffer": { "id": 262, - "package_id": 395, + "package_id": 397, }, "typed-array-byte-length": { "id": 263, - "package_id": 396, + "package_id": 398, }, "typed-array-byte-offset": { "id": 264, - "package_id": 397, + "package_id": 399, }, "typed-array-length": { "id": 265, - "package_id": 398, + "package_id": 400, }, "typescript": { "id": 13, - "package_id": 399, + "package_id": 401, }, "unbox-primitive": { "id": 266, - "package_id": 400, + "package_id": 402, }, "unbzip2-stream": { "id": 57, - "package_id": 401, + "package_id": 403, }, "undici-types": { - "id": 866, - "package_id": 402, + "id": 870, + "package_id": 404, }, "universalify": { "id": 441, - "package_id": 403, + "package_id": 405, }, "update-browserslist-db": { "id": 160, - "package_id": 404, + "package_id": 406, }, "uri-js": { "id": 89, - "package_id": 405, + "package_id": 407, }, "urlpattern-polyfill": { "id": 183, - "package_id": 406, + "package_id": 408, }, "util-deprecate": { "id": 624, - "package_id": 407, + "package_id": 409, }, "which": { "id": 196, - "package_id": 408, + "package_id": 410, }, "which-boxed-primitive": { "id": 803, - "package_id": 409, + "package_id": 411, }, "which-builtin-type": { "id": 659, - "package_id": 410, + "package_id": 412, }, "which-collection": { "id": 826, - "package_id": 411, + "package_id": 413, }, "which-typed-array": { "id": 267, - "package_id": 412, + "package_id": 414, }, "word-wrap": { "id": 588, - "package_id": 413, + "package_id": 415, }, "wrap-ansi": { "id": 187, - "package_id": 414, + "package_id": 416, }, "wrap-ansi-cjs": { "id": 40, - "package_id": 414, + "package_id": 417, }, "wrappy": { "id": 582, - "package_id": 415, + "package_id": 418, }, "ws": { "id": 646, - "package_id": 416, + "package_id": 419, }, "y18n": { "id": 850, - "package_id": 417, + "package_id": 420, }, "yallist": { "id": 893, - "package_id": 418, + "package_id": 421, }, "yaml": { "id": 620, - "package_id": 419, + "package_id": 422, }, "yargs": { "id": 58, - "package_id": 420, + "package_id": 423, }, "yargs-parser": { "id": 851, - "package_id": 421, + "package_id": 424, }, "yauzl": { "id": 421, - "package_id": 422, + "package_id": 425, }, "yocto-queue": { "id": 589, - "package_id": 423, + "package_id": 426, }, "zod": { "id": 184, - "package_id": 424, + "package_id": 427, }, }, "depth": 0, @@ -22446,7 +22698,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "@types/node": { "id": 163, - "package_id": 431, + "package_id": 438, }, }, "depth": 1, @@ -22457,7 +22709,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "postcss": { "id": 560, - "package_id": 438, + "package_id": 448, }, }, "depth": 1, @@ -22468,7 +22720,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "@types/node": { "id": 64, - "package_id": 431, + "package_id": 434, }, }, "depth": 1, @@ -22479,7 +22731,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "debug": { "id": 343, - "package_id": 434, + "package_id": 440, }, }, "depth": 1, @@ -22490,11 +22742,11 @@ exports[`next build works: bun 1`] = ` "dependencies": { "debug": { "id": 361, - "package_id": 434, + "package_id": 442, }, "doctrine": { "id": 362, - "package_id": 435, + "package_id": 443, }, }, "depth": 1, @@ -22505,11 +22757,11 @@ exports[`next build works: bun 1`] = ` "dependencies": { "doctrine": { "id": 397, - "package_id": 435, + "package_id": 444, }, "resolve": { "id": 407, - "package_id": 436, + "package_id": 445, }, }, "depth": 1, @@ -22520,11 +22772,11 @@ exports[`next build works: bun 1`] = ` "dependencies": { "debug": { "id": 51, - "package_id": 429, + "package_id": 432, }, "semver": { "id": 55, - "package_id": 430, + "package_id": 433, }, }, "depth": 1, @@ -22535,7 +22787,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "glob-parent": { "id": 176, - "package_id": 433, + "package_id": 439, }, }, "depth": 1, @@ -22546,7 +22798,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "glob-parent": { "id": 424, - "package_id": 433, + "package_id": 446, }, }, "depth": 1, @@ -22557,7 +22809,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "lilconfig": { "id": 619, - "package_id": 440, + "package_id": 450, }, }, "depth": 1, @@ -22568,7 +22820,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "minimatch": { "id": 462, - "package_id": 437, + "package_id": 447, }, }, "depth": 1, @@ -22579,11 +22831,11 @@ exports[`next build works: bun 1`] = ` "dependencies": { "minimatch": { "id": 79, - "package_id": 432, + "package_id": 436, }, "semver": { "id": 80, - "package_id": 430, + "package_id": 437, }, }, "depth": 1, @@ -22594,7 +22846,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "debug": { "id": 355, - "package_id": 434, + "package_id": 441, }, }, "depth": 1, @@ -22605,7 +22857,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "lru-cache": { "id": 865, - "package_id": 448, + "package_id": 459, }, }, "depth": 2, @@ -22616,7 +22868,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "glob": { "id": 667, - "package_id": 441, + "package_id": 451, }, }, "depth": 1, @@ -22627,7 +22879,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "brace-expansion": { "id": 881, - "package_id": 449, + "package_id": 462, }, }, "depth": 2, @@ -22638,7 +22890,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "lru-cache": { "id": 606, - "package_id": 439, + "package_id": 449, }, }, "depth": 1, @@ -22649,7 +22901,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "brace-expansion": { "id": 868, - "package_id": 449, + "package_id": 460, }, }, "depth": 2, @@ -22659,8 +22911,8 @@ exports[`next build works: bun 1`] = ` { "dependencies": { "lru-cache": { - "id": 865, - "package_id": 448, + "id": 869, + "package_id": 461, }, }, "depth": 2, @@ -22671,7 +22923,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "@types/node": { "id": 65, - "package_id": 431, + "package_id": 435, }, }, "depth": 1, @@ -22682,7 +22934,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "emoji-regex": { "id": 701, - "package_id": 442, + "package_id": 452, }, }, "depth": 1, @@ -22693,15 +22945,15 @@ exports[`next build works: bun 1`] = ` "dependencies": { "string-width": { "id": 35, - "package_id": 426, + "package_id": 429, }, "strip-ansi": { "id": 37, - "package_id": 427, + "package_id": 430, }, "wrap-ansi": { "id": 39, - "package_id": 428, + "package_id": 431, }, }, "depth": 1, @@ -22712,7 +22964,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "chalk": { "id": 17, - "package_id": 425, + "package_id": 428, }, }, "depth": 1, @@ -22722,8 +22974,8 @@ exports[`next build works: bun 1`] = ` { "dependencies": { "emoji-regex": { - "id": 701, - "package_id": 442, + "id": 704, + "package_id": 453, }, }, "depth": 1, @@ -22734,7 +22986,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "ansi-regex": { "id": 860, - "package_id": 446, + "package_id": 457, }, }, "depth": 2, @@ -22745,7 +22997,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "ansi-styles": { "id": 861, - "package_id": 447, + "package_id": 458, }, }, "depth": 2, @@ -22756,15 +23008,15 @@ exports[`next build works: bun 1`] = ` "dependencies": { "ansi-styles": { "id": 854, - "package_id": 443, + "package_id": 454, }, "escape-string-regexp": { "id": 855, - "package_id": 444, + "package_id": 455, }, "supports-color": { "id": 856, - "package_id": 445, + "package_id": 456, }, }, "depth": 2, @@ -22775,7 +23027,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "color-convert": { "id": 891, - "package_id": 450, + "package_id": 463, }, }, "depth": 3, @@ -22786,7 +23038,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "has-flag": { "id": 892, - "package_id": 451, + "package_id": 464, }, }, "depth": 3, @@ -22797,7 +23049,7 @@ exports[`next build works: bun 1`] = ` "dependencies": { "color-name": { "id": 897, - "package_id": 452, + "package_id": 465, }, }, "depth": 4, @@ -22980,7 +23232,7 @@ exports[`next build works: node 1`] = ` "name": "tailwindcss", "version": "==3.3.3", }, - "package_id": 379, + "package_id": 381, }, { "behavior": { @@ -22993,7 +23245,7 @@ exports[`next build works: node 1`] = ` "name": "typescript", "version": "==5.2.2", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -23045,7 +23297,7 @@ exports[`next build works: node 1`] = ` "name": "chalk", "version": ">=2.4.2 <3.0.0", }, - "package_id": 425, + "package_id": 428, }, { "behavior": { @@ -23227,7 +23479,7 @@ exports[`next build works: node 1`] = ` "name": "strip-json-comments", "version": ">=3.1.1 <4.0.0", }, - "package_id": 374, + "package_id": 376, }, { "behavior": { @@ -23279,7 +23531,7 @@ exports[`next build works: node 1`] = ` "name": "string-width", "version": ">=5.1.2 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -23293,7 +23545,7 @@ exports[`next build works: node 1`] = ` "name": "string-width", "version": ">=4.2.0 <5.0.0", }, - "package_id": 367, + "package_id": 368, }, { "behavior": { @@ -23306,7 +23558,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -23320,7 +23572,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 374, }, { "behavior": { @@ -23333,7 +23585,7 @@ exports[`next build works: node 1`] = ` "name": "wrap-ansi", "version": ">=8.1.0 <9.0.0", }, - "package_id": 428, + "package_id": 431, }, { "behavior": { @@ -23347,7 +23599,7 @@ exports[`next build works: node 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 417, }, { "behavior": { @@ -23490,7 +23742,7 @@ exports[`next build works: node 1`] = ` "name": "debug", "version": "==4.3.4", }, - "package_id": 429, + "package_id": 432, }, { "behavior": { @@ -23542,7 +23794,7 @@ exports[`next build works: node 1`] = ` "name": "semver", "version": "==7.6.0", }, - "package_id": 430, + "package_id": 433, }, { "behavior": { @@ -23555,7 +23807,7 @@ exports[`next build works: node 1`] = ` "name": "tar-fs", "version": "==3.0.5", }, - "package_id": 381, + "package_id": 383, }, { "behavior": { @@ -23568,7 +23820,7 @@ exports[`next build works: node 1`] = ` "name": "unbzip2-stream", "version": "==1.4.3", }, - "package_id": 401, + "package_id": 403, }, { "behavior": { @@ -23581,7 +23833,7 @@ exports[`next build works: node 1`] = ` "name": "yargs", "version": "==17.7.2", }, - "package_id": 420, + "package_id": 423, }, { "behavior": { @@ -23594,7 +23846,7 @@ exports[`next build works: node 1`] = ` "name": "tslib", "version": ">=2.4.0 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -23659,7 +23911,7 @@ exports[`next build works: node 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 434, }, { "behavior": { @@ -23672,7 +23924,7 @@ exports[`next build works: node 1`] = ` "name": "@types/node", "version": ">=0.0.0", }, - "package_id": 431, + "package_id": 435, }, { "behavior": { @@ -23854,7 +24106,7 @@ exports[`next build works: node 1`] = ` "name": "minimatch", "version": "==9.0.3", }, - "package_id": 432, + "package_id": 436, }, { "behavior": { @@ -23867,7 +24119,7 @@ exports[`next build works: node 1`] = ` "name": "semver", "version": ">=7.5.4 <8.0.0", }, - "package_id": 430, + "package_id": 437, }, { "behavior": { @@ -23880,7 +24132,7 @@ exports[`next build works: node 1`] = ` "name": "ts-api-utils", "version": ">=1.0.1 <2.0.0", }, - "package_id": 389, + "package_id": 391, }, { "behavior": { @@ -23984,7 +24236,7 @@ exports[`next build works: node 1`] = ` "name": "uri-js", "version": ">=4.2.2 <5.0.0", }, - "package_id": 405, + "package_id": 407, }, { "behavior": { @@ -24634,7 +24886,7 @@ exports[`next build works: node 1`] = ` "name": "tslib", "version": ">=2.0.1 <3.0.0", }, - "package_id": 392, + "package_id": 394, }, { "behavior": { @@ -24907,7 +25159,7 @@ exports[`next build works: node 1`] = ` "name": "update-browserslist-db", "version": ">=1.0.13 <2.0.0", }, - "package_id": 404, + "package_id": 406, }, { "behavior": { @@ -24946,7 +25198,7 @@ exports[`next build works: node 1`] = ` "name": "@types/node", "version": ">=20.12.8 <20.13.0", }, - "package_id": 431, + "package_id": 438, }, { "behavior": { @@ -25063,7 +25315,7 @@ exports[`next build works: node 1`] = ` "name": "supports-color", "version": ">=7.1.0 <8.0.0", }, - "package_id": 377, + "package_id": 379, }, { "behavior": { @@ -25115,7 +25367,7 @@ exports[`next build works: node 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <5.2.0", }, - "package_id": 433, + "package_id": 439, }, { "behavior": { @@ -25206,7 +25458,7 @@ exports[`next build works: node 1`] = ` "name": "urlpattern-polyfill", "version": "==10.0.0", }, - "package_id": 406, + "package_id": 408, }, { "behavior": { @@ -25219,7 +25471,7 @@ exports[`next build works: node 1`] = ` "name": "zod", "version": "==3.23.8", }, - "package_id": 424, + "package_id": 427, }, { "behavior": { @@ -25245,7 +25497,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -25258,7 +25510,7 @@ exports[`next build works: node 1`] = ` "name": "wrap-ansi", "version": ">=7.0.0 <8.0.0", }, - "package_id": 414, + "package_id": 416, }, { "behavior": { @@ -25285,7 +25537,7 @@ exports[`next build works: node 1`] = ` "name": "typescript", "version": ">=4.9.5", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -25376,7 +25628,7 @@ exports[`next build works: node 1`] = ` "name": "which", "version": ">=2.0.1 <3.0.0", }, - "package_id": 408, + "package_id": 410, }, { "behavior": { @@ -25688,7 +25940,7 @@ exports[`next build works: node 1`] = ` "name": "tapable", "version": ">=2.2.0 <3.0.0", }, - "package_id": 380, + "package_id": 382, }, { "behavior": { @@ -26195,7 +26447,7 @@ exports[`next build works: node 1`] = ` "name": "string.prototype.trim", "version": ">=1.2.9 <2.0.0", }, - "package_id": 369, + "package_id": 370, }, { "behavior": { @@ -26208,7 +26460,7 @@ exports[`next build works: node 1`] = ` "name": "string.prototype.trimend", "version": ">=1.0.8 <2.0.0", }, - "package_id": 370, + "package_id": 371, }, { "behavior": { @@ -26221,7 +26473,7 @@ exports[`next build works: node 1`] = ` "name": "string.prototype.trimstart", "version": ">=1.0.8 <2.0.0", }, - "package_id": 371, + "package_id": 372, }, { "behavior": { @@ -26234,7 +26486,7 @@ exports[`next build works: node 1`] = ` "name": "typed-array-buffer", "version": ">=1.0.2 <2.0.0", }, - "package_id": 395, + "package_id": 397, }, { "behavior": { @@ -26247,7 +26499,7 @@ exports[`next build works: node 1`] = ` "name": "typed-array-byte-length", "version": ">=1.0.1 <2.0.0", }, - "package_id": 396, + "package_id": 398, }, { "behavior": { @@ -26260,7 +26512,7 @@ exports[`next build works: node 1`] = ` "name": "typed-array-byte-offset", "version": ">=1.0.2 <2.0.0", }, - "package_id": 397, + "package_id": 399, }, { "behavior": { @@ -26273,7 +26525,7 @@ exports[`next build works: node 1`] = ` "name": "typed-array-length", "version": ">=1.0.6 <2.0.0", }, - "package_id": 398, + "package_id": 400, }, { "behavior": { @@ -26286,7 +26538,7 @@ exports[`next build works: node 1`] = ` "name": "unbox-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 400, + "package_id": 402, }, { "behavior": { @@ -26299,7 +26551,7 @@ exports[`next build works: node 1`] = ` "name": "which-typed-array", "version": ">=1.1.15 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -27118,7 +27370,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -27131,7 +27383,7 @@ exports[`next build works: node 1`] = ` "name": "text-table", "version": ">=0.2.0 <0.3.0", }, - "package_id": 384, + "package_id": 386, }, { "behavior": { @@ -27158,7 +27410,7 @@ exports[`next build works: node 1`] = ` "name": "typescript", "version": ">=3.3.1", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -27288,7 +27540,7 @@ exports[`next build works: node 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 440, }, { "behavior": { @@ -27444,7 +27696,7 @@ exports[`next build works: node 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 441, }, { "behavior": { @@ -27522,7 +27774,7 @@ exports[`next build works: node 1`] = ` "name": "debug", "version": ">=3.2.7 <4.0.0", }, - "package_id": 434, + "package_id": 442, }, { "behavior": { @@ -27535,7 +27787,7 @@ exports[`next build works: node 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 443, }, { "behavior": { @@ -27678,7 +27930,7 @@ exports[`next build works: node 1`] = ` "name": "tsconfig-paths", "version": ">=3.15.0 <4.0.0", }, - "package_id": 391, + "package_id": 393, }, { "behavior": { @@ -27990,7 +28242,7 @@ exports[`next build works: node 1`] = ` "name": "doctrine", "version": ">=2.1.0 <3.0.0", }, - "package_id": 435, + "package_id": 444, }, { "behavior": { @@ -28120,7 +28372,7 @@ exports[`next build works: node 1`] = ` "name": "resolve", "version": ">=2.0.0-next.5 <3.0.0", }, - "package_id": 436, + "package_id": 445, }, { "behavior": { @@ -28146,7 +28398,7 @@ exports[`next build works: node 1`] = ` "name": "string.prototype.matchall", "version": ">=4.0.11 <5.0.0", }, - "package_id": 368, + "package_id": 369, }, { "behavior": { @@ -28302,7 +28554,7 @@ exports[`next build works: node 1`] = ` "name": "yauzl", "version": ">=2.10.0 <3.0.0", }, - "package_id": 422, + "package_id": 425, }, { "behavior": { @@ -28341,7 +28593,7 @@ exports[`next build works: node 1`] = ` "name": "glob-parent", "version": ">=5.1.2 <6.0.0", }, - "package_id": 433, + "package_id": 446, }, { "behavior": { @@ -28419,7 +28671,7 @@ exports[`next build works: node 1`] = ` "name": "to-regex-range", "version": ">=5.0.1 <6.0.0", }, - "package_id": 388, + "package_id": 390, }, { "behavior": { @@ -28562,7 +28814,7 @@ exports[`next build works: node 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -28835,7 +29087,7 @@ exports[`next build works: node 1`] = ` "name": "minimatch", "version": ">=9.0.1 <10.0.0", }, - "package_id": 437, + "package_id": 447, }, { "behavior": { @@ -28887,7 +29139,7 @@ exports[`next build works: node 1`] = ` "name": "type-fest", "version": ">=0.20.2 <0.21.0", }, - "package_id": 394, + "package_id": 396, }, { "behavior": { @@ -29147,7 +29399,7 @@ exports[`next build works: node 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -29472,7 +29724,7 @@ exports[`next build works: node 1`] = ` "name": "which-typed-array", "version": ">=1.1.14 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -29654,7 +29906,7 @@ exports[`next build works: node 1`] = ` "name": "universalify", "version": ">=2.0.0 <3.0.0", }, - "package_id": 403, + "package_id": 405, }, { "behavior": { @@ -29758,7 +30010,7 @@ exports[`next build works: node 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -29862,7 +30114,7 @@ exports[`next build works: node 1`] = ` "name": "thenify-all", "version": ">=1.0.0 <2.0.0", }, - "package_id": 386, + "package_id": 388, }, { "behavior": { @@ -30111,7 +30363,7 @@ exports[`next build works: node 1`] = ` "name": "postcss", "version": "==8.4.31", }, - "package_id": 438, + "package_id": 448, }, { "behavior": { @@ -30124,7 +30376,7 @@ exports[`next build works: node 1`] = ` "name": "styled-jsx", "version": "==5.1.1", }, - "package_id": 375, + "package_id": 377, }, { "behavior": { @@ -30397,7 +30649,7 @@ exports[`next build works: node 1`] = ` "name": "wrappy", "version": "<2.0.0 >=1.0.0", }, - "package_id": 415, + "package_id": 418, }, { "behavior": { @@ -30462,7 +30714,7 @@ exports[`next build works: node 1`] = ` "name": "type-check", "version": ">=0.4.0 <0.5.0", }, - "package_id": 393, + "package_id": 395, }, { "behavior": { @@ -30475,7 +30727,7 @@ exports[`next build works: node 1`] = ` "name": "word-wrap", "version": ">=1.2.5 <2.0.0", }, - "package_id": 413, + "package_id": 415, }, { "behavior": { @@ -30488,7 +30740,7 @@ exports[`next build works: node 1`] = ` "name": "yocto-queue", "version": ">=0.1.0 <0.2.0", }, - "package_id": 423, + "package_id": 426, }, { "behavior": { @@ -30709,7 +30961,7 @@ exports[`next build works: node 1`] = ` "name": "lru-cache", "version": ">=10.2.0 <11.0.0", }, - "package_id": 439, + "package_id": 449, }, { "behavior": { @@ -30880,7 +31132,7 @@ exports[`next build works: node 1`] = ` "name": "lilconfig", "version": ">=3.0.0 <4.0.0", }, - "package_id": 440, + "package_id": 450, }, { "behavior": { @@ -30893,7 +31145,7 @@ exports[`next build works: node 1`] = ` "name": "yaml", "version": ">=2.3.4 <3.0.0", }, - "package_id": 419, + "package_id": 422, }, { "behavior": { @@ -30945,7 +31197,7 @@ exports[`next build works: node 1`] = ` "name": "util-deprecate", "version": ">=1.0.2 <2.0.0", }, - "package_id": 407, + "package_id": 409, }, { "behavior": { @@ -31231,7 +31483,7 @@ exports[`next build works: node 1`] = ` "name": "ws", "version": "==8.17.1", }, - "package_id": 416, + "package_id": 419, }, { "behavior": { @@ -31400,7 +31652,7 @@ exports[`next build works: node 1`] = ` "name": "which-builtin-type", "version": ">=1.1.3 <2.0.0", }, - "package_id": 410, + "package_id": 412, }, { "behavior": { @@ -31491,7 +31743,7 @@ exports[`next build works: node 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -31504,7 +31756,7 @@ exports[`next build works: node 1`] = ` "name": "glob", "version": ">=7.1.3 <8.0.0", }, - "package_id": 441, + "package_id": 451, }, { "behavior": { @@ -31933,7 +32185,7 @@ exports[`next build works: node 1`] = ` "name": "text-decoder", "version": ">=1.1.0 <2.0.0", }, - "package_id": 383, + "package_id": 385, }, { "behavior": { @@ -31946,7 +32198,7 @@ exports[`next build works: node 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": 442, + "package_id": 452, }, { "behavior": { @@ -31972,7 +32224,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -31985,7 +32237,7 @@ exports[`next build works: node 1`] = ` "name": "emoji-regex", "version": ">=8.0.0 <9.0.0", }, - "package_id": null, + "package_id": 453, }, { "behavior": { @@ -31998,7 +32250,7 @@ exports[`next build works: node 1`] = ` "name": "is-fullwidth-code-point", "version": ">=3.0.0 <4.0.0", }, - "package_id": null, + "package_id": 228, }, { "behavior": { @@ -32011,7 +32263,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.1 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -32323,7 +32575,7 @@ exports[`next build works: node 1`] = ` "name": "ansi-regex", "version": ">=5.0.1 <6.0.0", }, - "package_id": null, + "package_id": 55, }, { "behavior": { @@ -32440,7 +32692,7 @@ exports[`next build works: node 1`] = ` "name": "ts-interface-checker", "version": ">=0.1.9 <0.2.0", }, - "package_id": 390, + "package_id": 392, }, { "behavior": { @@ -32739,7 +32991,7 @@ exports[`next build works: node 1`] = ` "name": "sucrase", "version": ">=3.32.0 <4.0.0", }, - "package_id": 376, + "package_id": 378, }, { "behavior": { @@ -32791,7 +33043,7 @@ exports[`next build works: node 1`] = ` "name": "tar-stream", "version": ">=3.1.5 <4.0.0", }, - "package_id": 382, + "package_id": 384, }, { "behavior": { @@ -32869,7 +33121,7 @@ exports[`next build works: node 1`] = ` "name": "thenify", "version": ">=3.1.0 && <4.0.0", }, - "package_id": 385, + "package_id": 387, }, { "behavior": { @@ -32895,7 +33147,7 @@ exports[`next build works: node 1`] = ` "name": "typescript", "version": ">=4.2.0", }, - "package_id": 399, + "package_id": 401, }, { "behavior": { @@ -32947,7 +33199,7 @@ exports[`next build works: node 1`] = ` "name": "strip-bom", "version": ">=3.0.0 <4.0.0", }, - "package_id": 373, + "package_id": 375, }, { "behavior": { @@ -33272,7 +33524,7 @@ exports[`next build works: node 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -33298,7 +33550,7 @@ exports[`next build works: node 1`] = ` "name": "through", "version": ">=2.3.8 <3.0.0", }, - "package_id": 387, + "package_id": 389, }, { "behavior": { @@ -33558,7 +33810,7 @@ exports[`next build works: node 1`] = ` "name": "which-boxed-primitive", "version": ">=1.0.2 <2.0.0", }, - "package_id": 409, + "package_id": 411, }, { "behavior": { @@ -33571,7 +33823,7 @@ exports[`next build works: node 1`] = ` "name": "which-collection", "version": ">=1.0.1 <2.0.0", }, - "package_id": 411, + "package_id": 413, }, { "behavior": { @@ -33584,7 +33836,7 @@ exports[`next build works: node 1`] = ` "name": "which-typed-array", "version": ">=1.1.9 <2.0.0", }, - "package_id": 412, + "package_id": 414, }, { "behavior": { @@ -33740,7 +33992,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": 372, + "package_id": 373, }, { "behavior": { @@ -33753,7 +34005,7 @@ exports[`next build works: node 1`] = ` "name": "ansi-styles", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 56, }, { "behavior": { @@ -33766,7 +34018,7 @@ exports[`next build works: node 1`] = ` "name": "string-width", "version": ">=4.1.0 <5.0.0", }, - "package_id": null, + "package_id": 367, }, { "behavior": { @@ -33779,7 +34031,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 373, }, { "behavior": { @@ -33885,7 +34137,7 @@ exports[`next build works: node 1`] = ` "name": "y18n", "version": ">=5.0.5 <6.0.0", }, - "package_id": 417, + "package_id": 420, }, { "behavior": { @@ -33898,7 +34150,7 @@ exports[`next build works: node 1`] = ` "name": "yargs-parser", "version": ">=21.1.1 <22.0.0", }, - "package_id": 421, + "package_id": 424, }, { "behavior": { @@ -33937,7 +34189,7 @@ exports[`next build works: node 1`] = ` "name": "ansi-styles", "version": ">=3.2.1 <4.0.0", }, - "package_id": 443, + "package_id": 454, }, { "behavior": { @@ -33950,7 +34202,7 @@ exports[`next build works: node 1`] = ` "name": "escape-string-regexp", "version": ">=1.0.5 <2.0.0", }, - "package_id": 444, + "package_id": 455, }, { "behavior": { @@ -33963,7 +34215,7 @@ exports[`next build works: node 1`] = ` "name": "supports-color", "version": ">=5.3.0 <6.0.0", }, - "package_id": 445, + "package_id": 456, }, { "behavior": { @@ -34002,7 +34254,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -34015,7 +34267,7 @@ exports[`next build works: node 1`] = ` "name": "ansi-regex", "version": ">=6.0.1 <7.0.0", }, - "package_id": 446, + "package_id": 457, }, { "behavior": { @@ -34028,7 +34280,7 @@ exports[`next build works: node 1`] = ` "name": "ansi-styles", "version": ">=6.1.0 <7.0.0", }, - "package_id": 447, + "package_id": 458, }, { "behavior": { @@ -34041,7 +34293,7 @@ exports[`next build works: node 1`] = ` "name": "string-width", "version": ">=5.0.1 <6.0.0", }, - "package_id": 426, + "package_id": 429, }, { "behavior": { @@ -34054,7 +34306,7 @@ exports[`next build works: node 1`] = ` "name": "strip-ansi", "version": ">=7.0.1 <8.0.0", }, - "package_id": 427, + "package_id": 430, }, { "behavior": { @@ -34080,7 +34332,7 @@ exports[`next build works: node 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": 448, + "package_id": 459, }, { "behavior": { @@ -34093,7 +34345,7 @@ exports[`next build works: node 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": 402, + "package_id": 404, }, { "behavior": { @@ -34106,7 +34358,7 @@ exports[`next build works: node 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -34119,7 +34371,7 @@ exports[`next build works: node 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 460, }, { "behavior": { @@ -34132,7 +34384,7 @@ exports[`next build works: node 1`] = ` "name": "lru-cache", "version": ">=6.0.0 <7.0.0", }, - "package_id": null, + "package_id": 461, }, { "behavior": { @@ -34145,7 +34397,7 @@ exports[`next build works: node 1`] = ` "name": "undici-types", "version": ">=5.26.4 <5.27.0", }, - "package_id": null, + "package_id": 404, }, { "behavior": { @@ -34184,7 +34436,7 @@ exports[`next build works: node 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -34197,7 +34449,7 @@ exports[`next build works: node 1`] = ` "name": "ms", "version": ">=2.1.1 <3.0.0", }, - "package_id": null, + "package_id": 276, }, { "behavior": { @@ -34223,7 +34475,7 @@ exports[`next build works: node 1`] = ` "name": "esutils", "version": ">=2.0.2 <3.0.0", }, - "package_id": null, + "package_id": 162, }, { "behavior": { @@ -34262,7 +34514,7 @@ exports[`next build works: node 1`] = ` "name": "supports-preserve-symlinks-flag", "version": ">=1.0.0 <2.0.0", }, - "package_id": 378, + "package_id": 380, }, { "behavior": { @@ -34275,7 +34527,7 @@ exports[`next build works: node 1`] = ` "name": "is-glob", "version": ">=4.0.1 <5.0.0", }, - "package_id": null, + "package_id": 230, }, { "behavior": { @@ -34288,7 +34540,7 @@ exports[`next build works: node 1`] = ` "name": "brace-expansion", "version": ">=2.0.1 <3.0.0", }, - "package_id": 449, + "package_id": 462, }, { "behavior": { @@ -34418,7 +34670,7 @@ exports[`next build works: node 1`] = ` "name": "color-convert", "version": ">=1.9.0 <2.0.0", }, - "package_id": 450, + "package_id": 463, }, { "behavior": { @@ -34431,7 +34683,7 @@ exports[`next build works: node 1`] = ` "name": "has-flag", "version": ">=3.0.0 <4.0.0", }, - "package_id": 451, + "package_id": 464, }, { "behavior": { @@ -34444,7 +34696,7 @@ exports[`next build works: node 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": 418, + "package_id": 421, }, { "behavior": { @@ -34470,7 +34722,7 @@ exports[`next build works: node 1`] = ` "name": "yallist", "version": ">=4.0.0 <5.0.0", }, - "package_id": null, + "package_id": 421, }, { "behavior": { @@ -34483,7 +34735,7 @@ exports[`next build works: node 1`] = ` "name": "balanced-match", "version": ">=1.0.0 <2.0.0", }, - "package_id": null, + "package_id": 79, }, { "behavior": { @@ -34496,7 +34748,7 @@ exports[`next build works: node 1`] = ` "name": "color-name", "version": "==1.1.3", }, - "package_id": 452, + "package_id": 465, }, ], "format": "v2", @@ -34541,7 +34793,9 @@ exports[`next build works: node 1`] = ` "@tootallnate/quickjs-emscripten": 37, "@types/json5": 38, "@types/node": [ - 431, + 434, + 435, + 438, 39, ], "@types/prop-types": 40, @@ -34560,13 +34814,13 @@ exports[`next build works: node 1`] = ` "agent-base": 53, "ajv": 54, "ansi-regex": [ - 446, + 457, 55, ], "ansi-styles": [ - 447, + 458, 56, - 443, + 454, ], "any-promise": 57, "anymatch": 58, @@ -34600,7 +34854,8 @@ exports[`next build works: node 1`] = ` "basic-ftp": 86, "binary-extensions": 87, "brace-expansion": [ - 449, + 460, + 462, 88, ], "braces": 89, @@ -34615,7 +34870,7 @@ exports[`next build works: node 1`] = ` "caniuse-lite": 98, "chalk": [ 99, - 425, + 428, ], "chokidar": 100, "chromium-bidi": 101, @@ -34623,11 +34878,11 @@ exports[`next build works: node 1`] = ` "cliui": 103, "color-convert": [ 104, - 450, + 463, ], "color-name": [ 105, - 452, + 465, ], "commander": 106, "concat-map": 107, @@ -34642,8 +34897,10 @@ exports[`next build works: node 1`] = ` "data-view-byte-offset": 116, "debug": [ 117, - 429, - 434, + 432, + 440, + 441, + 442, ], "deep-is": 118, "default-create-template": 0, @@ -34657,13 +34914,15 @@ exports[`next build works: node 1`] = ` "dlv": 126, "doctrine": [ 127, - 435, + 443, + 444, ], "eastasianwidth": 128, "electron-to-chromium": 129, "emoji-regex": [ 130, - 442, + 452, + 453, ], "end-of-stream": 131, "enhanced-resolve": 132, @@ -34680,7 +34939,7 @@ exports[`next build works: node 1`] = ` "escalade": 143, "escape-string-regexp": [ 144, - 444, + 455, ], "escodegen": 145, "eslint": 146, @@ -34730,11 +34989,12 @@ exports[`next build works: node 1`] = ` "get-uri": 190, "glob": [ 191, - 441, + 451, ], "glob-parent": [ 192, - 433, + 439, + 446, ], "globals": 193, "globalthis": 194, @@ -34745,7 +35005,7 @@ exports[`next build works: node 1`] = ` "has-bigints": 199, "has-flag": [ 200, - 451, + 464, ], "has-property-descriptors": 201, "has-proto": 202, @@ -34811,7 +35071,7 @@ exports[`next build works: node 1`] = ` "language-tags": 262, "levn": 263, "lilconfig": [ - 440, + 450, 264, ], "lines-and-columns": 265, @@ -34819,15 +35079,16 @@ exports[`next build works: node 1`] = ` "lodash.merge": 267, "loose-envify": 268, "lru-cache": [ - 439, + 449, 269, - 448, + 459, + 461, ], "merge2": 270, "micromatch": 271, "minimatch": [ - 437, - 432, + 447, + 436, 272, ], "minimist": 273, @@ -34873,7 +35134,7 @@ exports[`next build works: node 1`] = ` "pirates": 313, "possible-typed-array-names": 314, "postcss": [ - 438, + 448, 315, ], "postcss-import": 316, @@ -34903,7 +35164,7 @@ exports[`next build works: node 1`] = ` "regexp.prototype.flags": 340, "require-directory": 341, "resolve": [ - 436, + 445, 342, ], "resolve-from": 343, @@ -34915,7 +35176,8 @@ exports[`next build works: node 1`] = ` "safe-regex-test": 349, "scheduler": 350, "semver": [ - 430, + 433, + 437, 351, ], "set-function-length": 352, @@ -34934,75 +35196,78 @@ exports[`next build works: node 1`] = ` "streamsearch": 365, "streamx": 366, "string-width": [ - 426, + 429, 367, + 368, ], - "string.prototype.matchall": 368, - "string.prototype.trim": 369, - "string.prototype.trimend": 370, - "string.prototype.trimstart": 371, + "string.prototype.matchall": 369, + "string.prototype.trim": 370, + "string.prototype.trimend": 371, + "string.prototype.trimstart": 372, "strip-ansi": [ - 427, - 372, + 430, + 373, + 374, ], - "strip-bom": 373, - "strip-json-comments": 374, - "styled-jsx": 375, - "sucrase": 376, + "strip-bom": 375, + "strip-json-comments": 376, + "styled-jsx": 377, + "sucrase": 378, "supports-color": [ - 377, - 445, + 379, + 456, ], - "supports-preserve-symlinks-flag": 378, - "tailwindcss": 379, - "tapable": 380, - "tar-fs": 381, - "tar-stream": 382, - "text-decoder": 383, - "text-table": 384, - "thenify": 385, - "thenify-all": 386, - "through": 387, - "to-regex-range": 388, - "ts-api-utils": 389, - "ts-interface-checker": 390, - "tsconfig-paths": 391, - "tslib": 392, - "type-check": 393, - "type-fest": 394, - "typed-array-buffer": 395, - "typed-array-byte-length": 396, - "typed-array-byte-offset": 397, - "typed-array-length": 398, - "typescript": 399, - "unbox-primitive": 400, - "unbzip2-stream": 401, - "undici-types": 402, - "universalify": 403, - "update-browserslist-db": 404, - "uri-js": 405, - "urlpattern-polyfill": 406, - "util-deprecate": 407, - "which": 408, - "which-boxed-primitive": 409, - "which-builtin-type": 410, - "which-collection": 411, - "which-typed-array": 412, - "word-wrap": 413, + "supports-preserve-symlinks-flag": 380, + "tailwindcss": 381, + "tapable": 382, + "tar-fs": 383, + "tar-stream": 384, + "text-decoder": 385, + "text-table": 386, + "thenify": 387, + "thenify-all": 388, + "through": 389, + "to-regex-range": 390, + "ts-api-utils": 391, + "ts-interface-checker": 392, + "tsconfig-paths": 393, + "tslib": 394, + "type-check": 395, + "type-fest": 396, + "typed-array-buffer": 397, + "typed-array-byte-length": 398, + "typed-array-byte-offset": 399, + "typed-array-length": 400, + "typescript": 401, + "unbox-primitive": 402, + "unbzip2-stream": 403, + "undici-types": 404, + "universalify": 405, + "update-browserslist-db": 406, + "uri-js": 407, + "urlpattern-polyfill": 408, + "util-deprecate": 409, + "which": 410, + "which-boxed-primitive": 411, + "which-builtin-type": 412, + "which-collection": 413, + "which-typed-array": 414, + "word-wrap": 415, "wrap-ansi": [ - 428, - 414, + 431, + 416, + 417, ], - "wrappy": 415, - "ws": 416, - "y18n": 417, - "yallist": 418, - "yaml": 419, - "yargs": 420, - "yargs-parser": 421, - "yauzl": 422, - "yocto-queue": 423, - "zod": 424, + "wrappy": 418, + "ws": 419, + "y18n": 420, + "yallist": 421, + "yaml": 422, + "yargs": 423, + "yargs-parser": 424, + "yauzl": 425, + "yocto-queue": 426, + "zod": 427, }, "packages": [ { @@ -41918,6 +42183,26 @@ exports[`next build works: node 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 704, + 705, + 706, + ], + "id": 368, + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "man_dir": "", + "name": "string-width", + "name_hash": "15727733666069179645", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "tag": "npm", + "value": "4.2.3", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ @@ -41934,7 +42219,7 @@ exports[`next build works: node 1`] = ` 717, 718, ], - "id": 368, + "id": 369, "integrity": "sha512-NUdh0aDavY2og7IbBPenWqR9exH+E26Sv8e0/eTe1tltDGZL+GtBkDAnnyBtmekfK6/Dq3MkcGtzXFEd1LQrtg==", "man_dir": "", "name": "string.prototype.matchall", @@ -41955,7 +42240,7 @@ exports[`next build works: node 1`] = ` 721, 722, ], - "id": 369, + "id": 370, "integrity": "sha512-klHuCNxiMZ8MlsOihJhJEBJAiMVqU3Z2nEXWfWnIqjN0gEFS9J9+IxKozWWtQGcgoa1WUZzLjKPTr4ZHNFTFxw==", "man_dir": "", "name": "string.prototype.trim", @@ -41975,7 +42260,7 @@ exports[`next build works: node 1`] = ` 724, 725, ], - "id": 370, + "id": 371, "integrity": "sha512-p73uL5VCHCO2BZZ6krwwQE3kCzM7NKmis8S//xEC6fQonchbum4eP6kR4DLEjQFO3Wnj3Fuo8NM0kOSjVdHjZQ==", "man_dir": "", "name": "string.prototype.trimend", @@ -41995,7 +42280,7 @@ exports[`next build works: node 1`] = ` 727, 728, ], - "id": 371, + "id": 372, "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", "man_dir": "", "name": "string.prototype.trimstart", @@ -42013,7 +42298,25 @@ exports[`next build works: node 1`] = ` "dependencies": [ 729, ], - "id": 372, + "id": 373, + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "man_dir": "", + "name": "strip-ansi", + "name_hash": "13340235767065158173", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "tag": "npm", + "value": "6.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 730, + ], + "id": 374, "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "man_dir": "", "name": "strip-ansi", @@ -42029,7 +42332,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 373, + "id": 375, "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "man_dir": "", "name": "strip-bom", @@ -42045,7 +42348,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 374, + "id": 376, "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "man_dir": "", "name": "strip-json-comments", @@ -42064,7 +42367,7 @@ exports[`next build works: node 1`] = ` 731, 732, ], - "id": 375, + "id": 377, "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", "man_dir": "", "name": "styled-jsx", @@ -42091,7 +42394,7 @@ exports[`next build works: node 1`] = ` 738, 739, ], - "id": 376, + "id": 378, "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", "man_dir": "", "name": "sucrase", @@ -42109,7 +42412,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 740, ], - "id": 377, + "id": 379, "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "man_dir": "", "name": "supports-color", @@ -42125,7 +42428,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 378, + "id": 380, "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "man_dir": "", "name": "supports-preserve-symlinks-flag", @@ -42167,7 +42470,7 @@ exports[`next build works: node 1`] = ` 761, 762, ], - "id": 379, + "id": 381, "integrity": "sha512-A0KgSkef7eE4Mf+nKJ83i75TMyq8HqY3qmFIJSWy8bNt0v1lG7jUcpGpoTFxAwYcWOphcTBLPPJg+bDfhDf52w==", "man_dir": "", "name": "tailwindcss", @@ -42183,7 +42486,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 380, + "id": 382, "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", "man_dir": "", "name": "tapable", @@ -42204,7 +42507,7 @@ exports[`next build works: node 1`] = ` 765, 766, ], - "id": 381, + "id": 383, "integrity": "sha512-JOgGAmZyMgbqpLwct7ZV8VzkEB6pxXFBVErLtb+XCOqzc6w1xiWKI9GVd6bwk68EX7eJ4DWmfXVmq8K2ziZTGg==", "man_dir": "", "name": "tar-fs", @@ -42224,7 +42527,7 @@ exports[`next build works: node 1`] = ` 768, 769, ], - "id": 382, + "id": 384, "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "man_dir": "", "name": "tar-stream", @@ -42242,7 +42545,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 770, ], - "id": 383, + "id": 385, "integrity": "sha512-TmLJNj6UgX8xcUZo4UDStGQtDiTzF7BzWlzn9g7UWrjkpHr5uJTK1ld16wZ3LXb2vb6jH8qU89dW5whuMdXYdw==", "man_dir": "", "name": "text-decoder", @@ -42258,7 +42561,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 384, + "id": 386, "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "man_dir": "", "name": "text-table", @@ -42276,7 +42579,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 771, ], - "id": 385, + "id": 387, "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", "man_dir": "", "name": "thenify", @@ -42294,7 +42597,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 772, ], - "id": 386, + "id": 388, "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", "man_dir": "", "name": "thenify-all", @@ -42310,7 +42613,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 387, + "id": 389, "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "man_dir": "", "name": "through", @@ -42328,7 +42631,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 773, ], - "id": 388, + "id": 390, "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "man_dir": "", "name": "to-regex-range", @@ -42346,7 +42649,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 774, ], - "id": 389, + "id": 391, "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "man_dir": "", "name": "ts-api-utils", @@ -42362,7 +42665,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 390, + "id": 392, "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", "man_dir": "", "name": "ts-interface-checker", @@ -42383,7 +42686,7 @@ exports[`next build works: node 1`] = ` 777, 778, ], - "id": 391, + "id": 393, "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "man_dir": "", "name": "tsconfig-paths", @@ -42399,7 +42702,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 392, + "id": 394, "integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==", "man_dir": "", "name": "tslib", @@ -42417,7 +42720,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 779, ], - "id": 393, + "id": 395, "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "man_dir": "", "name": "type-check", @@ -42433,7 +42736,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 394, + "id": 396, "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "man_dir": "", "name": "type-fest", @@ -42453,7 +42756,7 @@ exports[`next build works: node 1`] = ` 781, 782, ], - "id": 395, + "id": 397, "integrity": "sha512-gEymJYKZtKXzzBzM4jqa9w6Q1Jjm7x2d+sh19AdsD4wqnMPDYyvwpsIc2Q/835kHuo3BEQ7CjelGhfTsoBb2MQ==", "man_dir": "", "name": "typed-array-buffer", @@ -42475,7 +42778,7 @@ exports[`next build works: node 1`] = ` 786, 787, ], - "id": 396, + "id": 398, "integrity": "sha512-3iMJ9q0ao7WE9tWcaYKIptkNBuOIcZCCT0d4MRvuuH88fEoEH62IuQe0OtraD3ebQEoTRk8XCBoknUNc1Y67pw==", "man_dir": "", "name": "typed-array-byte-length", @@ -42498,7 +42801,7 @@ exports[`next build works: node 1`] = ` 792, 793, ], - "id": 397, + "id": 399, "integrity": "sha512-Ous0vodHa56FviZucS2E63zkgtgrACj7omjwd/8lTEMEPFFyjfixMZ1ZXenpgCFBBt4EC1J2XsyVS2gkG0eTFA==", "man_dir": "", "name": "typed-array-byte-offset", @@ -42521,7 +42824,7 @@ exports[`next build works: node 1`] = ` 798, 799, ], - "id": 398, + "id": 400, "integrity": "sha512-/OxDN6OtAk5KBpGb28T+HZc2M+ADtvRxXrKKbUwtsLgdoxgX13hyy7ek6bFRl5+aBs2yZzB0c4CnQfAtVypW/g==", "man_dir": "", "name": "typed-array-length", @@ -42540,7 +42843,7 @@ exports[`next build works: node 1`] = ` "tsserver": "bin/tsserver", }, "dependencies": [], - "id": 399, + "id": 401, "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "man_dir": "", "name": "typescript", @@ -42561,7 +42864,7 @@ exports[`next build works: node 1`] = ` 802, 803, ], - "id": 400, + "id": 402, "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", "man_dir": "", "name": "unbox-primitive", @@ -42580,7 +42883,7 @@ exports[`next build works: node 1`] = ` 804, 805, ], - "id": 401, + "id": 403, "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "man_dir": "", "name": "unbzip2-stream", @@ -42596,7 +42899,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 402, + "id": 404, "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "man_dir": "", "name": "undici-types", @@ -42612,7 +42915,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 403, + "id": 405, "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "man_dir": "", "name": "universalify", @@ -42635,7 +42938,7 @@ exports[`next build works: node 1`] = ` 807, 808, ], - "id": 404, + "id": 406, "integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==", "man_dir": "", "name": "update-browserslist-db", @@ -42653,7 +42956,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 809, ], - "id": 405, + "id": 407, "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "man_dir": "", "name": "uri-js", @@ -42669,7 +42972,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 406, + "id": 408, "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==", "man_dir": "", "name": "urlpattern-polyfill", @@ -42685,7 +42988,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 407, + "id": 409, "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "man_dir": "", "name": "util-deprecate", @@ -42706,7 +43009,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 810, ], - "id": 408, + "id": 410, "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "man_dir": "", "name": "which", @@ -42728,7 +43031,7 @@ exports[`next build works: node 1`] = ` 814, 815, ], - "id": 409, + "id": 411, "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", "man_dir": "", "name": "which-boxed-primitive", @@ -42757,7 +43060,7 @@ exports[`next build works: node 1`] = ` 826, 827, ], - "id": 410, + "id": 412, "integrity": "sha512-YmjsSMDBYsM1CaFiayOVT06+KJeXf0o5M/CAd4o1lTadFAtacTUM49zoYxr/oroopFDfhvN6iEcBxUyc3gvKmw==", "man_dir": "", "name": "which-builtin-type", @@ -42778,7 +43081,7 @@ exports[`next build works: node 1`] = ` 830, 831, ], - "id": 411, + "id": 413, "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", "man_dir": "", "name": "which-collection", @@ -42800,7 +43103,7 @@ exports[`next build works: node 1`] = ` 835, 836, ], - "id": 412, + "id": 414, "integrity": "sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==", "man_dir": "", "name": "which-typed-array", @@ -42816,7 +43119,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 413, + "id": 415, "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "man_dir": "", "name": "word-wrap", @@ -42836,7 +43139,27 @@ exports[`next build works: node 1`] = ` 838, 839, ], - "id": 414, + "id": 416, + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "man_dir": "", + "name": "wrap-ansi", + "name_hash": "6417752039399150421", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "tag": "npm", + "value": "7.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 840, + 841, + 842, + ], + "id": 417, "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "man_dir": "", "name": "wrap-ansi", @@ -42852,7 +43175,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 415, + "id": 418, "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "man_dir": "", "name": "wrappy", @@ -42871,7 +43194,7 @@ exports[`next build works: node 1`] = ` 843, 844, ], - "id": 416, + "id": 419, "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "man_dir": "", "name": "ws", @@ -42887,7 +43210,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 417, + "id": 420, "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "man_dir": "", "name": "y18n", @@ -42903,7 +43226,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 418, + "id": 421, "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "man_dir": "", "name": "yallist", @@ -42922,7 +43245,7 @@ exports[`next build works: node 1`] = ` "name": "yaml", }, "dependencies": [], - "id": 419, + "id": 422, "integrity": "sha512-sntgmxj8o7DE7g/Qi60cqpLBA3HG3STcDA0kO+WfB05jEKhZMbY7umNm2rBpQvsmZ16/lPXCJGW2672dgOUkrg==", "man_dir": "", "name": "yaml", @@ -42946,7 +43269,7 @@ exports[`next build works: node 1`] = ` 850, 851, ], - "id": 420, + "id": 423, "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "man_dir": "", "name": "yargs", @@ -42962,7 +43285,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 421, + "id": 424, "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", "man_dir": "", "name": "yargs-parser", @@ -42981,7 +43304,7 @@ exports[`next build works: node 1`] = ` 852, 853, ], - "id": 422, + "id": 425, "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", "man_dir": "", "name": "yauzl", @@ -42997,7 +43320,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 423, + "id": 426, "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "man_dir": "", "name": "yocto-queue", @@ -43013,7 +43336,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 424, + "id": 427, "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "man_dir": "", "name": "zod", @@ -43033,7 +43356,7 @@ exports[`next build works: node 1`] = ` 855, 856, ], - "id": 425, + "id": 428, "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "man_dir": "", "name": "chalk", @@ -43053,7 +43376,7 @@ exports[`next build works: node 1`] = ` 858, 859, ], - "id": 426, + "id": 429, "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "man_dir": "", "name": "string-width", @@ -43071,7 +43394,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 860, ], - "id": 427, + "id": 430, "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "man_dir": "", "name": "strip-ansi", @@ -43091,7 +43414,7 @@ exports[`next build works: node 1`] = ` 862, 863, ], - "id": 428, + "id": 431, "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "man_dir": "", "name": "wrap-ansi", @@ -43109,7 +43432,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 864, ], - "id": 429, + "id": 432, "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "man_dir": "", "name": "debug", @@ -43130,7 +43453,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 865, ], - "id": 430, + "id": 433, "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "man_dir": "", "name": "semver", @@ -43148,7 +43471,25 @@ exports[`next build works: node 1`] = ` "dependencies": [ 866, ], - "id": 431, + "id": 434, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 867, + ], + "id": 435, "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", "man_dir": "", "name": "@types/node", @@ -43166,7 +43507,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 868, ], - "id": 432, + "id": 436, "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", "man_dir": "", "name": "minimatch", @@ -43179,12 +43520,51 @@ exports[`next build works: node 1`] = ` }, "scripts": {}, }, + { + "bin": { + "file": "bin/semver.js", + "name": "semver", + }, + "dependencies": [ + 869, + ], + "id": 437, + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "man_dir": "", + "name": "semver", + "name_hash": "16367367531761322261", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "tag": "npm", + "value": "7.6.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 870, + ], + "id": 438, + "integrity": "sha512-scnD59RpYD91xngrQQLGkE+6UrHUPzeKZWhhjBSa3HSkwjbQc38+q3RoIVEwxQGRw3M+j5hpNAM+lgV3cVormg==", + "man_dir": "", + "name": "@types/node", + "name_hash": "4124652010926124945", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.14.tgz", + "tag": "npm", + "value": "20.12.14", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 871, ], - "id": 433, + "id": 439, "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "man_dir": "", "name": "glob-parent", @@ -43202,7 +43582,43 @@ exports[`next build works: node 1`] = ` "dependencies": [ 872, ], - "id": 434, + "id": 440, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 873, + ], + "id": 441, + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "man_dir": "", + "name": "debug", + "name_hash": "14324291119347696526", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "tag": "npm", + "value": "3.2.7", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 874, + ], + "id": 442, "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", "man_dir": "", "name": "debug", @@ -43220,7 +43636,25 @@ exports[`next build works: node 1`] = ` "dependencies": [ 875, ], - "id": 435, + "id": 443, + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "man_dir": "", + "name": "doctrine", + "name_hash": "17204823894354646410", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "tag": "npm", + "value": "2.1.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 876, + ], + "id": 444, "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "man_dir": "", "name": "doctrine", @@ -43243,7 +43677,7 @@ exports[`next build works: node 1`] = ` 878, 879, ], - "id": 436, + "id": 445, "integrity": "sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==", "man_dir": "", "name": "resolve", @@ -43256,12 +43690,30 @@ exports[`next build works: node 1`] = ` }, "scripts": {}, }, + { + "bin": null, + "dependencies": [ + 880, + ], + "id": 446, + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "man_dir": "", + "name": "glob-parent", + "name_hash": "11965780159102682782", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "tag": "npm", + "value": "5.1.2", + }, + "scripts": {}, + }, { "bin": null, "dependencies": [ 881, ], - "id": 437, + "id": 447, "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", "man_dir": "", "name": "minimatch", @@ -43281,7 +43733,7 @@ exports[`next build works: node 1`] = ` 883, 884, ], - "id": 438, + "id": 448, "integrity": "sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==", "man_dir": "", "name": "postcss", @@ -43297,7 +43749,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 439, + "id": 449, "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", "man_dir": "", "name": "lru-cache", @@ -43313,7 +43765,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 440, + "id": 450, "integrity": "sha512-O18pf7nyvHTckunPWCV1XUNXU1piu01y2b7ATJ0ppkUkk8ocqVWBrYjJBCwHDjD/ZWcfyrA0P4gKhzWGi5EINQ==", "man_dir": "", "name": "lilconfig", @@ -43336,7 +43788,7 @@ exports[`next build works: node 1`] = ` 889, 890, ], - "id": 441, + "id": 451, "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "man_dir": "", "name": "glob", @@ -43352,7 +43804,23 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 442, + "id": 452, + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "man_dir": "", + "name": "emoji-regex", + "name_hash": "4954026511424972012", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "tag": "npm", + "value": "8.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [], + "id": 453, "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "man_dir": "", "name": "emoji-regex", @@ -43370,7 +43838,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 891, ], - "id": 443, + "id": 454, "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "man_dir": "", "name": "ansi-styles", @@ -43386,7 +43854,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 444, + "id": 455, "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "man_dir": "", "name": "escape-string-regexp", @@ -43404,7 +43872,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 892, ], - "id": 445, + "id": 456, "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "man_dir": "", "name": "supports-color", @@ -43420,7 +43888,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 446, + "id": 457, "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "man_dir": "", "name": "ansi-regex", @@ -43436,7 +43904,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 447, + "id": 458, "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "man_dir": "", "name": "ansi-styles", @@ -43454,7 +43922,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 893, ], - "id": 448, + "id": 459, "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "man_dir": "", "name": "lru-cache", @@ -43472,7 +43940,43 @@ exports[`next build works: node 1`] = ` "dependencies": [ 894, ], - "id": 449, + "id": 460, + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "man_dir": "", + "name": "brace-expansion", + "name_hash": "2949258092693339993", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "tag": "npm", + "value": "2.0.1", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 895, + ], + "id": 461, + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "man_dir": "", + "name": "lru-cache", + "name_hash": "15261810304153928944", + "origin": "npm", + "resolution": { + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "tag": "npm", + "value": "6.0.0", + }, + "scripts": {}, + }, + { + "bin": null, + "dependencies": [ + 896, + ], + "id": 462, "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "man_dir": "", "name": "brace-expansion", @@ -43490,7 +43994,7 @@ exports[`next build works: node 1`] = ` "dependencies": [ 897, ], - "id": 450, + "id": 463, "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "man_dir": "", "name": "color-convert", @@ -43506,7 +44010,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 451, + "id": 464, "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", "man_dir": "", "name": "has-flag", @@ -43522,7 +44026,7 @@ exports[`next build works: node 1`] = ` { "bin": null, "dependencies": [], - "id": 452, + "id": 465, "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", "man_dir": "", "name": "color-name", @@ -45009,243 +45513,243 @@ exports[`next build works: node 1`] = ` }, "string-width-cjs": { "id": 36, - "package_id": 367, + "package_id": 368, }, "string.prototype.matchall": { "id": 409, - "package_id": 368, + "package_id": 369, }, "string.prototype.trim": { "id": 259, - "package_id": 369, + "package_id": 370, }, "string.prototype.trimend": { "id": 260, - "package_id": 370, + "package_id": 371, }, "string.prototype.trimstart": { "id": 261, - "package_id": 371, + "package_id": 372, }, "strip-ansi": { "id": 330, - "package_id": 372, + "package_id": 373, }, "strip-ansi-cjs": { "id": 38, - "package_id": 372, + "package_id": 374, }, "strip-bom": { "id": 778, - "package_id": 373, + "package_id": 375, }, "strip-json-comments": { "id": 31, - "package_id": 374, + "package_id": 376, }, "styled-jsx": { "id": 561, - "package_id": 375, + "package_id": 377, }, "sucrase": { "id": 762, - "package_id": 376, + "package_id": 378, }, "supports-color": { "id": 172, - "package_id": 377, + "package_id": 379, }, "supports-preserve-symlinks-flag": { "id": 666, - "package_id": 378, + "package_id": 380, }, "tailwindcss": { "id": 12, - "package_id": 379, + "package_id": 381, }, "tapable": { "id": 220, - "package_id": 380, + "package_id": 382, }, "tar-fs": { "id": 56, - "package_id": 381, + "package_id": 383, }, "tar-stream": { "id": 766, - "package_id": 382, + "package_id": 384, }, "text-decoder": { "id": 700, - "package_id": 383, + "package_id": 385, }, "text-table": { "id": 331, - "package_id": 384, + "package_id": 386, }, "thenify": { "id": 772, - "package_id": 385, + "package_id": 387, }, "thenify-all": { "id": 541, - "package_id": 386, + "package_id": 388, }, "through": { "id": 805, - "package_id": 387, + "package_id": 389, }, "to-regex-range": { "id": 430, - "package_id": 388, + "package_id": 390, }, "ts-api-utils": { "id": 81, - "package_id": 389, + "package_id": 391, }, "ts-interface-checker": { "id": 739, - "package_id": 390, + "package_id": 392, }, "tsconfig-paths": { "id": 373, - "package_id": 391, + "package_id": 393, }, "tslib": { "id": 59, - "package_id": 392, + "package_id": 394, }, "type-check": { "id": 533, - "package_id": 393, + "package_id": 395, }, "type-fest": { "id": 466, - "package_id": 394, + "package_id": 396, }, "typed-array-buffer": { "id": 262, - "package_id": 395, + "package_id": 397, }, "typed-array-byte-length": { "id": 263, - "package_id": 396, + "package_id": 398, }, "typed-array-byte-offset": { "id": 264, - "package_id": 397, + "package_id": 399, }, "typed-array-length": { "id": 265, - "package_id": 398, + "package_id": 400, }, "typescript": { "id": 13, - "package_id": 399, + "package_id": 401, }, "unbox-primitive": { "id": 266, - "package_id": 400, + "package_id": 402, }, "unbzip2-stream": { "id": 57, - "package_id": 401, + "package_id": 403, }, "undici-types": { - "id": 866, - "package_id": 402, + "id": 870, + "package_id": 404, }, "universalify": { "id": 441, - "package_id": 403, + "package_id": 405, }, "update-browserslist-db": { "id": 160, - "package_id": 404, + "package_id": 406, }, "uri-js": { "id": 89, - "package_id": 405, + "package_id": 407, }, "urlpattern-polyfill": { "id": 183, - "package_id": 406, + "package_id": 408, }, "util-deprecate": { "id": 624, - "package_id": 407, + "package_id": 409, }, "which": { "id": 196, - "package_id": 408, + "package_id": 410, }, "which-boxed-primitive": { "id": 803, - "package_id": 409, + "package_id": 411, }, "which-builtin-type": { "id": 659, - "package_id": 410, + "package_id": 412, }, "which-collection": { "id": 826, - "package_id": 411, + "package_id": 413, }, "which-typed-array": { "id": 267, - "package_id": 412, + "package_id": 414, }, "word-wrap": { "id": 588, - "package_id": 413, + "package_id": 415, }, "wrap-ansi": { "id": 187, - "package_id": 414, + "package_id": 416, }, "wrap-ansi-cjs": { "id": 40, - "package_id": 414, + "package_id": 417, }, "wrappy": { "id": 582, - "package_id": 415, + "package_id": 418, }, "ws": { "id": 646, - "package_id": 416, + "package_id": 419, }, "y18n": { "id": 850, - "package_id": 417, + "package_id": 420, }, "yallist": { "id": 893, - "package_id": 418, + "package_id": 421, }, "yaml": { "id": 620, - "package_id": 419, + "package_id": 422, }, "yargs": { "id": 58, - "package_id": 420, + "package_id": 423, }, "yargs-parser": { "id": 851, - "package_id": 421, + "package_id": 424, }, "yauzl": { "id": 421, - "package_id": 422, + "package_id": 425, }, "yocto-queue": { "id": 589, - "package_id": 423, + "package_id": 426, }, "zod": { "id": 184, - "package_id": 424, + "package_id": 427, }, }, "depth": 0, @@ -45256,7 +45760,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "@types/node": { "id": 163, - "package_id": 431, + "package_id": 438, }, }, "depth": 1, @@ -45267,7 +45771,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "postcss": { "id": 560, - "package_id": 438, + "package_id": 448, }, }, "depth": 1, @@ -45278,7 +45782,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "@types/node": { "id": 64, - "package_id": 431, + "package_id": 434, }, }, "depth": 1, @@ -45289,7 +45793,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "debug": { "id": 343, - "package_id": 434, + "package_id": 440, }, }, "depth": 1, @@ -45300,11 +45804,11 @@ exports[`next build works: node 1`] = ` "dependencies": { "debug": { "id": 361, - "package_id": 434, + "package_id": 442, }, "doctrine": { "id": 362, - "package_id": 435, + "package_id": 443, }, }, "depth": 1, @@ -45315,11 +45819,11 @@ exports[`next build works: node 1`] = ` "dependencies": { "doctrine": { "id": 397, - "package_id": 435, + "package_id": 444, }, "resolve": { "id": 407, - "package_id": 436, + "package_id": 445, }, }, "depth": 1, @@ -45330,11 +45834,11 @@ exports[`next build works: node 1`] = ` "dependencies": { "debug": { "id": 51, - "package_id": 429, + "package_id": 432, }, "semver": { "id": 55, - "package_id": 430, + "package_id": 433, }, }, "depth": 1, @@ -45345,7 +45849,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "glob-parent": { "id": 176, - "package_id": 433, + "package_id": 439, }, }, "depth": 1, @@ -45356,7 +45860,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "glob-parent": { "id": 424, - "package_id": 433, + "package_id": 446, }, }, "depth": 1, @@ -45367,7 +45871,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "lilconfig": { "id": 619, - "package_id": 440, + "package_id": 450, }, }, "depth": 1, @@ -45378,7 +45882,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "minimatch": { "id": 462, - "package_id": 437, + "package_id": 447, }, }, "depth": 1, @@ -45389,11 +45893,11 @@ exports[`next build works: node 1`] = ` "dependencies": { "minimatch": { "id": 79, - "package_id": 432, + "package_id": 436, }, "semver": { "id": 80, - "package_id": 430, + "package_id": 437, }, }, "depth": 1, @@ -45404,7 +45908,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "debug": { "id": 355, - "package_id": 434, + "package_id": 441, }, }, "depth": 1, @@ -45415,7 +45919,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "lru-cache": { "id": 865, - "package_id": 448, + "package_id": 459, }, }, "depth": 2, @@ -45426,7 +45930,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "glob": { "id": 667, - "package_id": 441, + "package_id": 451, }, }, "depth": 1, @@ -45437,7 +45941,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "brace-expansion": { "id": 881, - "package_id": 449, + "package_id": 462, }, }, "depth": 2, @@ -45448,7 +45952,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "lru-cache": { "id": 606, - "package_id": 439, + "package_id": 449, }, }, "depth": 1, @@ -45459,7 +45963,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "brace-expansion": { "id": 868, - "package_id": 449, + "package_id": 460, }, }, "depth": 2, @@ -45469,8 +45973,8 @@ exports[`next build works: node 1`] = ` { "dependencies": { "lru-cache": { - "id": 865, - "package_id": 448, + "id": 869, + "package_id": 461, }, }, "depth": 2, @@ -45481,7 +45985,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "@types/node": { "id": 65, - "package_id": 431, + "package_id": 435, }, }, "depth": 1, @@ -45492,7 +45996,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "emoji-regex": { "id": 701, - "package_id": 442, + "package_id": 452, }, }, "depth": 1, @@ -45503,15 +46007,15 @@ exports[`next build works: node 1`] = ` "dependencies": { "string-width": { "id": 35, - "package_id": 426, + "package_id": 429, }, "strip-ansi": { "id": 37, - "package_id": 427, + "package_id": 430, }, "wrap-ansi": { "id": 39, - "package_id": 428, + "package_id": 431, }, }, "depth": 1, @@ -45522,7 +46026,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "chalk": { "id": 17, - "package_id": 425, + "package_id": 428, }, }, "depth": 1, @@ -45532,8 +46036,8 @@ exports[`next build works: node 1`] = ` { "dependencies": { "emoji-regex": { - "id": 701, - "package_id": 442, + "id": 704, + "package_id": 453, }, }, "depth": 1, @@ -45544,7 +46048,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "ansi-regex": { "id": 860, - "package_id": 446, + "package_id": 457, }, }, "depth": 2, @@ -45555,7 +46059,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "ansi-styles": { "id": 861, - "package_id": 447, + "package_id": 458, }, }, "depth": 2, @@ -45566,15 +46070,15 @@ exports[`next build works: node 1`] = ` "dependencies": { "ansi-styles": { "id": 854, - "package_id": 443, + "package_id": 454, }, "escape-string-regexp": { "id": 855, - "package_id": 444, + "package_id": 455, }, "supports-color": { "id": 856, - "package_id": 445, + "package_id": 456, }, }, "depth": 2, @@ -45585,7 +46089,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "color-convert": { "id": 891, - "package_id": 450, + "package_id": 463, }, }, "depth": 3, @@ -45596,7 +46100,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "has-flag": { "id": 892, - "package_id": 451, + "package_id": 464, }, }, "depth": 3, @@ -45607,7 +46111,7 @@ exports[`next build works: node 1`] = ` "dependencies": { "color-name": { "id": 897, - "package_id": 452, + "package_id": 465, }, }, "depth": 4, From 1ddf3fc097c6b964c284e7e1f2d2dd3a8570c779 Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 31 Jan 2025 22:39:43 -0800 Subject: [PATCH 02/29] Fix fetch with formdata on some servers (#16947) --- src/bun.js/webcore/blob.zig | 2 +- test/regression/issue/07917/7917.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 test/regression/issue/07917/7917.test.ts diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 3902dea342feba..125f4f1e23e024 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -604,7 +604,7 @@ pub const Blob = struct { const store = Blob.Store.init(context.joiner.done(allocator) catch bun.outOfMemory(), allocator); var blob = Blob.initWithStore(store, globalThis); - blob.content_type = std.fmt.allocPrint(allocator, "multipart/form-data; boundary=\"{s}\"", .{boundary}) catch bun.outOfMemory(); + blob.content_type = std.fmt.allocPrint(allocator, "multipart/form-data; boundary={s}", .{boundary}) catch bun.outOfMemory(); blob.content_type_allocated = true; blob.content_type_was_set = true; diff --git a/test/regression/issue/07917/7917.test.ts b/test/regression/issue/07917/7917.test.ts new file mode 100644 index 00000000000000..ba18f7f79d4833 --- /dev/null +++ b/test/regression/issue/07917/7917.test.ts @@ -0,0 +1,19 @@ +test("boundary does not have quotes (#7917)", async () => { + // for `content-type: multipart/form-data; boundary=...` / https://datatracker.ietf.org/doc/html/rfc2046#section-5.1 + // the spec states that the boundary parameter accepts quotes, and both node and bun accept quotes when parsing + // the form data. however, some websites do not accept quotes and node does not quote it. this test ensures that the + // boundary is not quoted. + + const form = new FormData(); + form.append("filename[]", "document.tex"); + form.append("filecontents[]", "\\documentclass{article}\\begin{document}Hello world\\end{document}"); + form.append("return", "pdf"); + const req = new Request("http://localhost:35411", { + method: "POST", + body: form, + }); + const content_type = req.headers.get("content-type"); + const val = await req.text(); + const actual_boundary = val.split("\r")[0].slice(2); + expect(content_type).toEqual(`multipart/form-data; boundary=${actual_boundary}`); +}); From 26d3688e53369513d2df55d2c20b55a5b29d6fb5 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 1 Feb 2025 01:11:02 -0800 Subject: [PATCH 03/29] zig: update to 0.14.0-dev (#16862) Co-authored-by: nektro <5464072+nektro@users.noreply.github.com> --- .gitignore | 3 +- build.zig | 27 +- cmake/scripts/DownloadZig.cmake | 2 +- cmake/tools/SetupZig.cmake | 4 +- src/Global.zig | 4 +- src/Mutex.zig | 2 +- src/Watcher.zig | 12 +- src/analytics/analytics_thread.zig | 16 +- src/ast/base.zig | 2 +- src/async/posix_event_loop.zig | 78 ++-- src/bake/DevServer.zig | 22 +- src/bake/FrameworkRouter.zig | 2 +- src/bit_set.zig | 10 +- src/bitflags.zig | 4 +- src/bun.js/ConsoleObject.zig | 30 +- src/bun.js/api/BunObject.zig | 128 +++---- src/bun.js/api/JSBundler.zig | 2 - src/bun.js/api/JSTranspiler.zig | 8 +- src/bun.js/api/Timer.zig | 14 +- src/bun.js/api/bun/dns_resolver.zig | 57 ++- src/bun.js/api/bun/h2_frame_parser.zig | 17 +- src/bun.js/api/bun/process.zig | 36 +- src/bun.js/api/bun/socket.zig | 6 +- src/bun.js/api/bun/subprocess.zig | 20 +- src/bun.js/api/bun/udp_socket.zig | 2 +- src/bun.js/api/ffi.zig | 4 +- src/bun.js/api/filesystem_router.zig | 4 +- src/bun.js/api/glob.zig | 3 - src/bun.js/api/html_rewriter.zig | 18 +- src/bun.js/api/server.zig | 20 +- src/bun.js/api/server/HTMLBundle.zig | 10 +- src/bun.js/api/server/StaticRoute.zig | 2 +- src/bun.js/base.zig | 110 +++--- src/bun.js/bindings/bindings.zig | 36 +- src/bun.js/bindings/exports.zig | 38 +- src/bun.js/bindings/header-gen.zig | 42 +-- src/bun.js/bindings/shimmer.zig | 39 +- src/bun.js/event_loop.zig | 231 ++++++------ src/bun.js/ipc.zig | 8 +- src/bun.js/javascript.zig | 168 ++++----- src/bun.js/module_loader.zig | 95 +++-- src/bun.js/node/assert/myers_diff.zig | 8 +- src/bun.js/node/buffer.zig | 2 +- src/bun.js/node/fs_events.zig | 11 +- src/bun.js/node/node_fs.zig | 84 ++--- src/bun.js/node/node_fs_binding.zig | 2 +- src/bun.js/node/node_fs_stat_watcher.zig | 2 - src/bun.js/node/node_fs_watcher.zig | 2 - src/bun.js/node/node_os.zig | 2 +- src/bun.js/node/node_zlib_binding.zig | 4 +- src/bun.js/node/path.zig | 22 +- src/bun.js/node/path_watcher.zig | 8 - src/bun.js/node/types.zig | 110 +++--- src/bun.js/node/util/parse_args.zig | 4 +- src/bun.js/node/util/validators.zig | 12 +- src/bun.js/test/expect.zig | 18 +- src/bun.js/test/jest.zig | 20 +- src/bun.js/test/pretty_format.zig | 3 +- src/bun.js/test/snapshot.zig | 2 +- src/bun.js/web_worker.zig | 6 +- src/bun.js/webcore.zig | 10 +- src/bun.js/webcore/ObjectURLRegistry.zig | 6 +- src/bun.js/webcore/S3File.zig | 10 +- src/bun.js/webcore/S3Stat.zig | 4 +- src/bun.js/webcore/blob.zig | 51 +-- src/bun.js/webcore/blob/ReadFile.zig | 51 ++- src/bun.js/webcore/blob/WriteFile.zig | 28 +- src/bun.js/webcore/body.zig | 8 +- src/bun.js/webcore/encoding.zig | 2 +- src/bun.js/webcore/request.zig | 2 +- src/bun.js/webcore/response.zig | 10 +- src/bun.js/webcore/streams.zig | 54 +-- src/bun.zig | 212 ++++++----- src/bun_js.zig | 6 +- src/bundler/bundle_v2.zig | 10 +- src/c.zig | 10 +- src/cli.zig | 14 +- src/cli/bunx_command.zig | 4 +- src/cli/create_command.zig | 11 +- src/cli/filter_run.zig | 7 +- src/cli/init_command.zig | 2 +- src/cli/install_completions_command.zig | 2 +- src/cli/outdated_command.zig | 14 +- src/cli/package_manager_command.zig | 2 +- src/cli/run_command.zig | 6 +- src/cli/test_command.zig | 8 +- src/cli/upgrade_command.zig | 2 +- src/codegen/bindgen.ts | 2 +- src/codegen/generate-classes.ts | 2 +- src/codegen/generate-js2native.ts | 2 +- src/copy_file.zig | 2 +- src/crash_handler.zig | 34 +- src/css/css_parser.zig | 64 ++-- src/css/generics.zig | 119 +++--- src/css/media_query.zig | 4 +- src/css/properties/align.zig | 8 +- src/css/properties/background.zig | 91 +++-- src/css/properties/border.zig | 138 +++---- src/css/properties/border_image.zig | 36 +- src/css/properties/border_radius.zig | 2 +- src/css/properties/custom.zig | 6 +- src/css/properties/display.zig | 16 +- src/css/properties/flex.zig | 4 +- src/css/properties/font.zig | 2 +- src/css/properties/masking.zig | 2 +- src/css/properties/transition.zig | 2 +- src/css/rules/container.zig | 4 +- src/css/selectors/parser.zig | 4 - src/css/small_list.zig | 2 +- src/css/values/color.zig | 37 +- src/css/values/length.zig | 4 +- src/darwin_c.zig | 8 +- src/defines.zig | 6 +- src/deps/boringssl.translated.zig | 2 +- src/deps/c_ares.zig | 8 +- src/deps/libuv.zig | 16 +- src/deps/uws.zig | 38 +- src/deps/zig-clap/clap.zig | 2 +- src/deps/zig-clap/clap/comptime.zig | 2 +- src/dns.zig | 10 +- src/env_loader.zig | 6 +- src/fd.zig | 11 +- src/fmt.zig | 4 +- src/futex.zig | 16 +- src/grapheme.zig | 2 +- src/http.zig | 18 +- src/http/mime_type.zig | 2 +- src/http/websocket_http_client.zig | 28 +- src/install/bin.zig | 2 +- src/install/bun.lock.zig | 14 +- src/install/dependency.zig | 20 +- src/install/install.zig | 69 ++-- src/install/lifecycle_script_runner.zig | 4 +- src/install/lockfile.zig | 16 +- src/install/migration.zig | 2 +- src/install/padding_checker.zig | 22 +- src/install/patch_install.zig | 4 +- src/install/windows-shim/BinLinkingShim.zig | 1 + src/install/windows-shim/bun_shim_impl.zig | 14 +- src/io/PipeReader.zig | 2 +- src/io/io.zig | 56 +-- src/js_ast.zig | 14 +- src/js_lexer.zig | 12 +- src/js_parser.zig | 12 +- src/js_printer.zig | 4 +- src/json_parser.zig | 32 +- src/libarchive/libarchive-bindings.zig | 34 +- src/libarchive/libarchive.zig | 2 +- src/linux_c.zig | 8 +- src/logger.zig | 78 ++-- src/main.zig | 26 +- src/meta.zig | 114 +++--- src/multi_array_list.zig | 385 ++------------------ src/options.zig | 4 +- src/output.zig | 22 +- src/resolver/resolver.zig | 14 +- src/resolver/tsconfig_json.zig | 2 +- src/s3/client.zig | 6 +- src/s3/credentials.zig | 2 +- src/s3/multipart.zig | 2 +- src/shell/interpreter.zig | 68 ++-- src/shell/shell.zig | 26 +- src/shell/subproc.zig | 6 +- src/sourcemap/CodeCoverage.zig | 8 +- src/sourcemap/sourcemap.zig | 2 +- src/sql/postgres.zig | 14 +- src/sql/postgres/postgres_types.zig | 2 +- src/string.zig | 8 +- src/string_immutable.zig | 5 +- src/sync.zig | 6 +- src/sys.zig | 61 ++-- src/sys_uv.zig | 2 +- src/tagged_pointer.zig | 23 +- src/thread_pool.zig | 1 - src/toml/toml_lexer.zig | 10 +- src/toml/toml_parser.zig | 2 +- src/tracy.zig | 5 +- src/trait.zig | 28 +- src/transpiler.zig | 2 +- src/url.zig | 2 +- src/util.zig | 13 +- src/watcher.zig | 12 +- src/watcher/INotifyWatcher.zig | 2 +- src/watcher/KEventWatcher.zig | 10 +- src/watcher/WindowsWatcher.zig | 6 +- src/windows.zig | 16 +- src/windows_c.zig | 4 +- src/work_pool.zig | 2 +- test/js/bun/util/password.test.ts | 23 +- 189 files changed, 1952 insertions(+), 2386 deletions(-) diff --git a/.gitignore b/.gitignore index af3120ab439e4e..b791b8bc3a047f 100644 --- a/.gitignore +++ b/.gitignore @@ -151,6 +151,7 @@ src/bake/generated.ts test/cli/install/registry/packages/publish-pkg-* test/cli/install/registry/packages/@secret/publish-pkg-8 test/js/third_party/prisma/prisma/sqlite/dev.db-journal +tmp # Dependencies /vendor @@ -178,4 +179,4 @@ test/js/third_party/prisma/prisma/sqlite/dev.db-journal .buildkite/ci.yml *.sock -scratch*.{js,ts,tsx,cjs,mjs} \ No newline at end of file +scratch*.{js,ts,tsx,cjs,mjs} diff --git a/build.zig b/build.zig index 01ebdaaeea9d2d..a487dc66239ee7 100644 --- a/build.zig +++ b/build.zig @@ -19,7 +19,7 @@ const OperatingSystem = @import("src/env.zig").OperatingSystem; const pathRel = fs.path.relative; /// Do not rename this constant. It is scanned by some scripts to determine which zig version to install. -const recommended_zig_version = "0.13.0"; +const recommended_zig_version = "0.14.0-dev.2987+183bb8b08"; comptime { if (!std.mem.eql(u8, builtin.zig_version_string, recommended_zig_version)) { @@ -154,8 +154,6 @@ pub fn build(b: *Build) !void { std.log.info("zig compiler v{s}", .{builtin.zig_version_string}); checked_file_exists = std.AutoHashMap(u64, void).init(b.allocator); - b.zig_lib_dir = b.zig_lib_dir orelse b.path("vendor/zig/lib"); - // TODO: Upgrade path for 0.14.0 // b.graph.zig_lib_directory = brk: { // const sub_path = "vendor/zig/lib"; @@ -209,7 +207,7 @@ pub fn build(b: *Build) !void { const bun_version = b.option([]const u8, "version", "Value of `Bun.version`") orelse "0.0.0"; b.reference_trace = ref_trace: { - const trace = b.option(u32, "reference-trace", "Set the reference trace") orelse 16; + const trace = b.option(u32, "reference-trace", "Set the reference trace") orelse 24; break :ref_trace if (trace == 0) null else trace; }; @@ -331,11 +329,25 @@ pub fn build(b: *Build) !void { .{ .os = .windows, .arch = .x86_64 }, }); } + { + const step = b.step("check-macos", "Check for semantic analysis errors on Windows"); + addMultiCheck(b, step, build_options, &.{ + .{ .os = .mac, .arch = .x86_64 }, + .{ .os = .mac, .arch = .aarch64 }, + }); + } + { + const step = b.step("check-linux", "Check for semantic analysis errors on Windows"); + addMultiCheck(b, step, build_options, &.{ + .{ .os = .linux, .arch = .x86_64 }, + .{ .os = .linux, .arch = .aarch64 }, + }); + } // zig build translate-c-headers { const step = b.step("translate-c", "Copy generated translated-c-headers.zig to zig-out"); - step.dependOn(&b.addInstallFile(getTranslateC(b, b.host, .Debug).getOutput(), "translated-c-headers.zig").step); + step.dependOn(&b.addInstallFile(getTranslateC(b, b.graph.host, .Debug).getOutput(), "translated-c-headers.zig").step); } // zig build enum-extractor @@ -363,7 +375,7 @@ pub fn addMultiCheck( const check_target = b.resolveTargetQuery(.{ .os_tag = OperatingSystem.stdOSTag(check.os), .cpu_arch = check.arch, - .cpu_model = getCpuModel(check.os, check.arch) orelse .determined_by_cpu_arch, + .cpu_model = getCpuModel(check.os, check.arch) orelse .determined_by_arch_os, .os_version_min = getOSVersionMin(check.os), .glibc_version = if (check.musl) null else getOSGlibCVersion(check.os), }); @@ -429,7 +441,6 @@ pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile { .strip = false, // stripped at the end }); obj.bundle_compiler_rt = false; - obj.formatted_panics = true; obj.root_module.omit_frame_pointer = false; // Link libc @@ -614,7 +625,7 @@ const WindowsShim = struct { .optimize = .ReleaseFast, .use_llvm = true, .use_lld = true, - .unwind_tables = false, + .unwind_tables = .none, .omit_frame_pointer = true, .strip = true, .linkage = .static, diff --git a/cmake/scripts/DownloadZig.cmake b/cmake/scripts/DownloadZig.cmake index f7f9d8789e90d6..2fb68ac4ca28b9 100644 --- a/cmake/scripts/DownloadZig.cmake +++ b/cmake/scripts/DownloadZig.cmake @@ -38,7 +38,7 @@ else() set(ZIG_FILENAME ${ZIG_NAME}.tar.xz) endif() -set(ZIG_DOWNLOAD_URL https://ziglang.org/download/${ZIG_VERSION}/${ZIG_FILENAME}) +set(ZIG_DOWNLOAD_URL http://mirrors.nektro.net/zig/${ZIG_VERSION}/${ZIG_FILENAME}) execute_process( COMMAND diff --git a/cmake/tools/SetupZig.cmake b/cmake/tools/SetupZig.cmake index e5a5e574ef99aa..d1c6727c831c62 100644 --- a/cmake/tools/SetupZig.cmake +++ b/cmake/tools/SetupZig.cmake @@ -20,8 +20,8 @@ else() unsupported(CMAKE_SYSTEM_NAME) endif() -optionx(ZIG_VERSION STRING "The zig version of the compiler to download" DEFAULT "0.13.0") -optionx(ZIG_COMMIT STRING "The zig commit to use in oven-sh/zig" DEFAULT "131a009ba2eb127a3447d05b9e12f710429aa5ee") +optionx(ZIG_VERSION STRING "The zig version of the compiler to download" DEFAULT "0.14.0-dev.2987+183bb8b08") +optionx(ZIG_COMMIT STRING "The zig commit to use in oven-sh/zig" DEFAULT "b11877fd3e8fbc031c17872155ed481d5ba4e6af") optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET}) if(CMAKE_BUILD_TYPE STREQUAL "Release") diff --git a/src/Global.zig b/src/Global.zig index f935d3b958c3a9..0a07e0ec8f56c8 100644 --- a/src/Global.zig +++ b/src/Global.zig @@ -170,13 +170,13 @@ pub inline fn configureAllocator(_: AllocatorConfiguration) void { } pub fn notimpl() noreturn { - @setCold(true); + @branchHint(.cold); Output.panic("Not implemented yet!!!!!", .{}); } // Make sure we always print any leftover pub fn crash() noreturn { - @setCold(true); + @branchHint(.cold); Global.exit(1); } diff --git a/src/Mutex.zig b/src/Mutex.zig index 7e824f2d822a9b..0aaaee366d3e72 100644 --- a/src/Mutex.zig +++ b/src/Mutex.zig @@ -164,7 +164,7 @@ const FutexImpl = struct { } fn lockSlow(self: *@This()) void { - @setCold(true); + @branchHint(.cold); // Avoid doing an atomic swap below if we already know the state is contended. // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily. diff --git a/src/Watcher.zig b/src/Watcher.zig index 7639bc11bed75f..3f710c64ceb354 100644 --- a/src/Watcher.zig +++ b/src/Watcher.zig @@ -333,11 +333,11 @@ fn appendFileAssumeCapacity( // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html var event = std.mem.zeroes(KEvent); - event.flags = std.c.EV_ADD | std.c.EV_CLEAR | std.c.EV_ENABLE; + event.flags = std.c.EV.ADD | std.c.EV.CLEAR | std.c.EV.ENABLE; // we want to know about the vnode - event.filter = std.c.EVFILT_VNODE; + event.filter = std.c.EVFILT.VNODE; - event.fflags = std.c.NOTE_WRITE | std.c.NOTE_RENAME | std.c.NOTE_DELETE; + event.fflags = std.c.NOTE.WRITE | std.c.NOTE.RENAME | std.c.NOTE.DELETE; // id event.ident = @intCast(fd.int()); @@ -425,15 +425,15 @@ fn appendDirectoryAssumeCapacity( // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html var event = std.mem.zeroes(KEvent); - event.flags = std.c.EV_ADD | std.c.EV_CLEAR | std.c.EV_ENABLE; + event.flags = std.c.EV.ADD | std.c.EV.CLEAR | std.c.EV.ENABLE; // we want to know about the vnode - event.filter = std.c.EVFILT_VNODE; + event.filter = std.c.EVFILT.VNODE; // monitor: // - Write // - Rename // - Delete - event.fflags = std.c.NOTE_WRITE | std.c.NOTE_RENAME | std.c.NOTE_DELETE; + event.fflags = std.c.NOTE.WRITE | std.c.NOTE.RENAME | std.c.NOTE.DELETE; // id event.ident = @intCast(fd.int()); diff --git a/src/analytics/analytics_thread.zig b/src/analytics/analytics_thread.zig index 50c9f2a810c055..51365d41261d45 100644 --- a/src/analytics/analytics_thread.zig +++ b/src/analytics/analytics_thread.zig @@ -126,8 +126,8 @@ pub const Features = struct { pub var s3: usize = 0; comptime { - @export(napi_module_register, .{ .name = "Bun__napi_module_register_count" }); - @export(process_dlopen, .{ .name = "Bun__process_dlopen_count" }); + @export(&napi_module_register, .{ .name = "Bun__napi_module_register_count" }); + @export(&process_dlopen, .{ .name = "Bun__process_dlopen_count" }); } pub fn formatter() Formatter { @@ -138,14 +138,14 @@ pub const Features = struct { pub fn format(_: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { const fields = comptime brk: { const info: std.builtin.Type = @typeInfo(Features); - var buffer: [info.Struct.decls.len][]const u8 = .{""} ** info.Struct.decls.len; + var buffer: [info.@"struct".decls.len][]const u8 = .{""} ** info.@"struct".decls.len; var count: usize = 0; - for (info.Struct.decls) |decl| { + for (info.@"struct".decls) |decl| { var f = &@field(Features, decl.name); _ = &f; const Field = @TypeOf(f); const FieldT: std.builtin.Type = @typeInfo(Field); - if (FieldT.Pointer.child != usize) continue; + if (FieldT.pointer.child != usize) continue; buffer[count] = decl.name; count += 1; } @@ -216,7 +216,7 @@ pub const packed_features_list = brk: { }; pub const PackedFeatures = @Type(.{ - .Struct = .{ + .@"struct" = .{ .layout = .@"packed", .backing_integer = u64, .fields = brk: { @@ -226,7 +226,7 @@ pub const PackedFeatures = @Type(.{ fields[i] = .{ .name = name, .type = bool, - .default_value = &false, + .default_value_ptr = &false, .is_comptime = false, .alignment = 0, }; @@ -236,7 +236,7 @@ pub const PackedFeatures = @Type(.{ fields[i] = .{ .name = std.fmt.comptimePrint("_{d}", .{i}), .type = bool, - .default_value = &false, + .default_value_ptr = &false, .is_comptime = false, .alignment = 0, }; diff --git a/src/ast/base.zig b/src/ast/base.zig index ffd6240ad3e3ba..de1f8a5a3f3d20 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -62,7 +62,7 @@ pub const Index = packed struct(u32) { pub fn init(num: anytype) Index { const NumType = @TypeOf(num); - if (comptime @typeInfo(NumType) == .Pointer) { + if (comptime @typeInfo(NumType) == .pointer) { return init(num.*); } diff --git a/src/async/posix_event_loop.zig b/src/async/posix_event_loop.zig index 2dfb108952fae8..6ab59c66f7330c 100644 --- a/src/async/posix_event_loop.zig +++ b/src/async/posix_event_loop.zig @@ -366,42 +366,42 @@ pub const FilePoll = struct { // var loader = ptr.as(ShellSubprocessCapturedBufferedWriterMini); // loader.onPoll(size_or_offset, 0); // }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(ShellBufferedWriter))) => { + @field(Owner.Tag, @typeName(ShellBufferedWriter)) => { var handler: *ShellBufferedWriter = ptr.as(ShellBufferedWriter); handler.onPoll(size_or_offset, poll.flags.contains(.hup)); }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(ShellStaticPipeWriter))) => { + @field(Owner.Tag, @typeName(ShellStaticPipeWriter)) => { var handler: *ShellStaticPipeWriter = ptr.as(ShellStaticPipeWriter); handler.onPoll(size_or_offset, poll.flags.contains(.hup)); }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(StaticPipeWriter))) => { + @field(Owner.Tag, @typeName(StaticPipeWriter)) => { var handler: *StaticPipeWriter = ptr.as(StaticPipeWriter); handler.onPoll(size_or_offset, poll.flags.contains(.hup)); }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(FileSink))) => { + @field(Owner.Tag, @typeName(FileSink)) => { var handler: *FileSink = ptr.as(FileSink); handler.onPoll(size_or_offset, poll.flags.contains(.hup)); }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(BufferedReader))) => { + @field(Owner.Tag, @typeName(BufferedReader)) => { log("onUpdate " ++ kqueue_or_epoll ++ " (fd: {}) Reader", .{poll.fd}); var handler: *BufferedReader = ptr.as(BufferedReader); handler.onPoll(size_or_offset, poll.flags.contains(.hup)); }, - @field(Owner.Tag, bun.meta.typeBaseName(@typeName(Process))) => { + @field(Owner.Tag, @typeName(Process)) => { log("onUpdate " ++ kqueue_or_epoll ++ " (fd: {}) Process", .{poll.fd}); var loader = ptr.as(Process); loader.onWaitPidFromEventLoopTask(); }, - @field(Owner.Tag, "DNSResolver") => { + @field(Owner.Tag, @typeName(DNSResolver)) => { log("onUpdate " ++ kqueue_or_epoll ++ " (fd: {}) DNSResolver", .{poll.fd}); var loader: *DNSResolver = ptr.as(DNSResolver); loader.onDNSPoll(poll); }, - @field(Owner.Tag, "GetAddrInfoRequest") => { + @field(Owner.Tag, @typeName(GetAddrInfoRequest)) => { if (comptime !Environment.isMac) { unreachable; } @@ -411,7 +411,7 @@ pub const FilePoll = struct { loader.onMachportChange(); }, - @field(Owner.Tag, "Request") => { + @field(Owner.Tag, @typeName(Request)) => { if (comptime !Environment.isMac) { unreachable; } @@ -503,19 +503,19 @@ pub const FilePoll = struct { pub fn fromKQueueEvent(kqueue_event: std.posix.system.kevent64_s) Flags.Set { var flags = Flags.Set{}; - if (kqueue_event.filter == std.posix.system.EVFILT_READ) { + if (kqueue_event.filter == std.posix.system.EVFILT.READ) { flags.insert(Flags.readable); - if (kqueue_event.flags & std.posix.system.EV_EOF != 0) { + if (kqueue_event.flags & std.posix.system.EV.EOF != 0) { flags.insert(Flags.hup); } - } else if (kqueue_event.filter == std.posix.system.EVFILT_WRITE) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.WRITE) { flags.insert(Flags.writable); - if (kqueue_event.flags & std.posix.system.EV_EOF != 0) { + if (kqueue_event.flags & std.posix.system.EV.EOF != 0) { flags.insert(Flags.hup); } - } else if (kqueue_event.filter == std.posix.system.EVFILT_PROC) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.PROC) { flags.insert(Flags.process); - } else if (kqueue_event.filter == std.posix.system.EVFILT_MACHPORT) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.MACHPORT) { flags.insert(Flags.machport); } return flags; @@ -763,7 +763,7 @@ pub const FilePoll = struct { pub fn onTick(loop: *Loop, tagged_pointer: ?*anyopaque) callconv(.C) void { var tag = Pollable.from(tagged_pointer); - if (tag.tag() != @field(Pollable.Tag, "FilePoll")) + if (tag.tag() != @field(Pollable.Tag, @typeName(FilePoll))) return; var file_poll: *FilePoll = tag.as(FilePoll); @@ -782,7 +782,7 @@ pub const FilePoll = struct { }); comptime { - @export(onTick, .{ .name = "Bun__internal_dispatch_ready_poll" }); + @export(&onTick, .{ .name = "Bun__internal_dispatch_ready_poll" }); } const timeout = std.mem.zeroes(std.posix.timespec); @@ -837,45 +837,45 @@ pub const FilePoll = struct { const one_shot_flag: u16 = if (!this.flags.contains(.one_shot)) 0 else if (one_shot == .dispatch) - std.c.EV_DISPATCH | std.c.EV_ENABLE + std.c.EV.DISPATCH | std.c.EV.ENABLE else - std.c.EV_ONESHOT; + std.c.EV.ONESHOT; changelist[0] = switch (flag) { .readable => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_READ, + .filter = std.posix.system.EVFILT.READ, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, + .flags = std.c.EV.ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, .writable => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_WRITE, + .filter = std.posix.system.EVFILT.WRITE, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, + .flags = std.c.EV.ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, .process => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_PROC, + .filter = std.posix.system.EVFILT.PROC, .data = 0, - .fflags = std.c.NOTE_EXIT, + .fflags = std.c.NOTE.EXIT, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, + .flags = std.c.EV.ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, .machport => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_MACHPORT, + .filter = std.posix.system.EVFILT.MACHPORT, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, + .flags = std.c.EV.ADD | one_shot_flag, .ext = .{ this.generation_number, 0 }, }, else => unreachable, @@ -913,7 +913,7 @@ pub const FilePoll = struct { // processing an element of the changelist and there is enough room // in the eventlist, then the event will be placed in the eventlist // with EV_ERROR set in flags and the system error in data. - if (changelist[0].flags == std.c.EV_ERROR and changelist[0].data != 0) { + if (changelist[0].flags == std.c.EV.ERROR and changelist[0].data != 0) { return JSC.Maybe(void).errnoSys(changelist[0].data, .kevent).?; // Otherwise, -1 will be returned, and errno will be set to // indicate the error condition. @@ -1008,38 +1008,38 @@ pub const FilePoll = struct { changelist[0] = switch (flag) { .readable => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_READ, + .filter = std.posix.system.EVFILT.READ, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ 0, 0 }, }, .machport => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_MACHPORT, + .filter = std.posix.system.EVFILT.MACHPORT, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ 0, 0 }, }, .writable => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_WRITE, + .filter = std.posix.system.EVFILT.WRITE, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ 0, 0 }, }, .process => .{ .ident = @intCast(fd.cast()), - .filter = std.posix.system.EVFILT_PROC, + .filter = std.posix.system.EVFILT.PROC, .data = 0, - .fflags = std.c.NOTE_EXIT, + .fflags = std.c.NOTE.EXIT, .udata = @intFromPtr(Pollable.init(this).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ 0, 0 }, }, else => unreachable, @@ -1065,7 +1065,7 @@ pub const FilePoll = struct { // processing an element of the changelist and there is enough room // in the eventlist, then the event will be placed in the eventlist // with EV_ERROR set in flags and the system error in data. - if (changelist[0].flags == std.c.EV_ERROR) { + if (changelist[0].flags == std.c.EV.ERROR) { return JSC.Maybe(void).errnoSys(changelist[0].data, .kevent).?; // Otherwise, -1 will be returned, and errno will be set to // indicate the error condition. diff --git a/src/bake/DevServer.zig b/src/bake/DevServer.zig index 04a8d5f23b714a..6b7f957926d542 100644 --- a/src/bake/DevServer.zig +++ b/src/bake/DevServer.zig @@ -865,7 +865,7 @@ const DeferredRequest = struct { server_handler: bun.JSC.API.SavedRequest, js_payload: *Response, - const Tag = @typeInfo(Data).Union.tag_type.?; + const Tag = @typeInfo(Data).@"union".tag_type.?; }; }; @@ -3715,20 +3715,20 @@ const HmrTopic = enum(u8) { /// Invalid data _, - pub const max_count = @typeInfo(HmrTopic).Enum.fields.len; - pub const Bits = @Type(.{ .Struct = .{ - .backing_integer = @Type(.{ .Int = .{ + pub const max_count = @typeInfo(HmrTopic).@"enum".fields.len; + pub const Bits = @Type(.{ .@"struct" = .{ + .backing_integer = @Type(.{ .int = .{ .bits = max_count, .signedness = .unsigned, } }), .fields = &brk: { - const enum_fields = @typeInfo(HmrTopic).Enum.fields; + const enum_fields = @typeInfo(HmrTopic).@"enum".fields; var fields: [enum_fields.len]std.builtin.Type.StructField = undefined; for (enum_fields, &fields) |e, *s| { s.* = .{ .name = e.name, .type = bool, - .default_value = &false, + .default_value_ptr = &false, .is_comptime = false, .alignment = 0, }; @@ -3768,7 +3768,7 @@ const HmrSocket = struct { const topics = msg[1..]; if (topics.len > HmrTopic.max_count) return; outer: for (topics) |char| { - inline for (@typeInfo(HmrTopic).Enum.fields) |field| { + inline for (@typeInfo(HmrTopic).@"enum".fields) |field| { if (char == field.value) { @field(new_bits, field.name) = true; continue :outer; @@ -4063,7 +4063,7 @@ const WatcherAtomics = struct { ev.timer = std.time.Timer.start() catch unreachable; }, 1 => { - // @branchHint(.unlikely); + @branchHint(.unlikely); // DevServer stole this event. Unlikely but possible when // the user is saving very heavily (10-30 times per second) state.current +%= 1; @@ -4087,12 +4087,12 @@ const WatcherAtomics = struct { ev.owner.bun_watcher.thread_lock.assertLocked(); if (ev.files.count() > 0) { - // @branchHint(.likely); + @branchHint(.likely); // There are files to be processed, increment this count first. const prev_count = state.watcher_events_emitted.fetchAdd(1, .seq_cst); if (prev_count == 0) { - // @branchHint(.likely); + @branchHint(.likely); // Submit a task to the DevServer, notifying it that there is // work to do. The watcher will move to the other event. ev.concurrent_task = .{ @@ -4434,7 +4434,7 @@ pub const EntryPointList = struct { pub fn append(entry_points: *EntryPointList, allocator: std.mem.Allocator, abs_path: []const u8, flags: Flags) !void { const gop = try entry_points.set.getOrPut(allocator, abs_path); if (gop.found_existing) { - const T = @typeInfo(Flags).Struct.backing_integer.?; + const T = @typeInfo(Flags).@"struct".backing_integer.?; gop.value_ptr.* = @bitCast(@as(T, @bitCast(gop.value_ptr.*)) | @as(T, @bitCast(flags))); } else { gop.value_ptr.* = flags; diff --git a/src/bake/FrameworkRouter.zig b/src/bake/FrameworkRouter.zig index c3b6b134cc677d..3182e8ca7c594a 100644 --- a/src/bake/FrameworkRouter.zig +++ b/src/bake/FrameworkRouter.zig @@ -331,7 +331,7 @@ pub const Part = union(enum(u3)) { group: []const u8, const SerializedHeader = packed struct(u32) { - tag: @typeInfo(Part).Union.tag_type.?, + tag: @typeInfo(Part).@"union".tag_type.?, len: u29, }; diff --git a/src/bit_set.zig b/src/bit_set.zig index 2ecd5b3591f12d..f702915dfbe581 100644 --- a/src/bit_set.zig +++ b/src/bit_set.zig @@ -325,10 +325,10 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { const mask_info: std.builtin.Type = @typeInfo(MaskIntType); // Make sure the mask int is indeed an int - if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); + if (mask_info != .int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType)); // It must also be unsigned. - if (mask_info.Int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); + if (mask_info.int.signedness != .unsigned) @compileError("ArrayBitSet requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType)); // And it must not be empty. if (MaskIntType == u0) @@ -1620,7 +1620,7 @@ fn testSupersetOf(empty: anytype, full: anytype, even: anytype, odd: anytype, le fn testBitSet(a: anytype, b: anytype, len: usize) !void { try testing.expectEqual(len, a.capacity()); try testing.expectEqual(len, b.capacity()); - const needs_ptr = @hasField(std.meta.Child(@TypeOf(a)), "masks") and @typeInfo(@TypeOf(@field(a, "masks"))) != .Pointer; + const needs_ptr = @hasField(std.meta.Child(@TypeOf(a)), "masks") and @typeInfo(@TypeOf(@field(a, "masks"))) != .pointer; { for (0..len) |i| { @@ -1844,7 +1844,7 @@ fn fillOdd(set: anytype, len: usize) void { fn testPureBitSet(comptime Set: type) !void { var empty_ = Set.initEmpty(); var full_ = Set.initFull(); - const needs_ptr = @hasField(Set, "masks") and @typeInfo(@TypeOf(empty_.masks)) != .Pointer; + const needs_ptr = @hasField(Set, "masks") and @typeInfo(@TypeOf(empty_.masks)) != .pointer; var even_ = even: { var bit_set = Set.initEmpty(); @@ -1900,7 +1900,7 @@ fn testPureBitSet(comptime Set: type) !void { try testing.expect(full.differenceWith(even).eql(odd)); } -fn testStaticBitSet(comptime Set: type, comptime Container: @Type(.EnumLiteral)) !void { +fn testStaticBitSet(comptime Set: type, comptime Container: @Type(.enum_literal)) !void { var a = Set.initEmpty(); var b = Set.initFull(); try testing.expectEqual(@as(usize, 0), a.count()); diff --git a/src/bitflags.zig b/src/bitflags.zig index f851a694908f66..908179686af7b2 100644 --- a/src/bitflags.zig +++ b/src/bitflags.zig @@ -2,9 +2,9 @@ const std = @import("std"); pub fn Bitflags(comptime T: type) type { const tyinfo = @typeInfo(T); - const IntType = tyinfo.Struct.backing_integer.?; + const IntType = tyinfo.@"struct".backing_integer.?; const IntTypeInfo = @typeInfo(IntType); - const IntRepresentingNumOfBits = std.math.IntFittingRange(0, IntTypeInfo.Int.bits); + const IntRepresentingNumOfBits = std.math.IntFittingRange(0, IntTypeInfo.int.bits); return struct { pub const IMPL_BITFLAGS: u0 = 0; diff --git a/src/bun.js/ConsoleObject.zig b/src/bun.js/ConsoleObject.zig index 38d3fd48cb4da1..b78c9afe7d22ef 100644 --- a/src/bun.js/ConsoleObject.zig +++ b/src/bun.js/ConsoleObject.zig @@ -3433,7 +3433,7 @@ pub const Formatter = struct { ", ... {d} more"; writer.print(comptime Output.prettyFmt(fmt_, enable_ansi_colors), .{ - if (@typeInfo(Number) == .Float) bun.fmt.double(@floatCast(slice[0])) else slice[0], + if (@typeInfo(Number) == .float) bun.fmt.double(@floatCast(slice[0])) else slice[0], }); var leftover = slice[1..]; const max = 512; @@ -3443,7 +3443,7 @@ pub const Formatter = struct { writer.space(); writer.print(comptime Output.prettyFmt(fmt_, enable_ansi_colors), .{ - if (@typeInfo(Number) == .Float) bun.fmt.double(@floatCast(el)) else el, + if (@typeInfo(Number) == .float) bun.fmt.double(@floatCast(el)) else el, }); } @@ -3686,17 +3686,17 @@ pub fn screenshot( ) callconv(JSC.conv) void {} comptime { - @export(messageWithTypeAndLevel, .{ .name = shim.symbolName("messageWithTypeAndLevel") }); - @export(count, .{ .name = shim.symbolName("count") }); - @export(countReset, .{ .name = shim.symbolName("countReset") }); - @export(time, .{ .name = shim.symbolName("time") }); - @export(timeLog, .{ .name = shim.symbolName("timeLog") }); - @export(timeEnd, .{ .name = shim.symbolName("timeEnd") }); - @export(profile, .{ .name = shim.symbolName("profile") }); - @export(profileEnd, .{ .name = shim.symbolName("profileEnd") }); - @export(takeHeapSnapshot, .{ .name = shim.symbolName("takeHeapSnapshot") }); - @export(timeStamp, .{ .name = shim.symbolName("timeStamp") }); - @export(record, .{ .name = shim.symbolName("record") }); - @export(recordEnd, .{ .name = shim.symbolName("recordEnd") }); - @export(screenshot, .{ .name = shim.symbolName("screenshot") }); + @export(&messageWithTypeAndLevel, .{ .name = shim.symbolName("messageWithTypeAndLevel") }); + @export(&count, .{ .name = shim.symbolName("count") }); + @export(&countReset, .{ .name = shim.symbolName("countReset") }); + @export(&time, .{ .name = shim.symbolName("time") }); + @export(&timeLog, .{ .name = shim.symbolName("timeLog") }); + @export(&timeEnd, .{ .name = shim.symbolName("timeEnd") }); + @export(&profile, .{ .name = shim.symbolName("profile") }); + @export(&profileEnd, .{ .name = shim.symbolName("profileEnd") }); + @export(&takeHeapSnapshot, .{ .name = shim.symbolName("takeHeapSnapshot") }); + @export(&timeStamp, .{ .name = shim.symbolName("timeStamp") }); + @export(&record, .{ .name = shim.symbolName("record") }); + @export(&recordEnd, .{ .name = shim.symbolName("recordEnd") }); + @export(&screenshot, .{ .name = shim.symbolName("screenshot") }); } diff --git a/src/bun.js/api/BunObject.zig b/src/bun.js/api/BunObject.zig index d6e02a1ad09ef9..6830bc9fda21d5 100644 --- a/src/bun.js/api/BunObject.zig +++ b/src/bun.js/api/BunObject.zig @@ -100,70 +100,70 @@ pub const BunObject = struct { } // --- Getters --- - @export(BunObject.CryptoHasher, .{ .name = getterName("CryptoHasher") }); - @export(BunObject.FFI, .{ .name = getterName("FFI") }); - @export(BunObject.FileSystemRouter, .{ .name = getterName("FileSystemRouter") }); - @export(BunObject.MD4, .{ .name = getterName("MD4") }); - @export(BunObject.MD5, .{ .name = getterName("MD5") }); - @export(BunObject.SHA1, .{ .name = getterName("SHA1") }); - @export(BunObject.SHA224, .{ .name = getterName("SHA224") }); - @export(BunObject.SHA256, .{ .name = getterName("SHA256") }); - @export(BunObject.SHA384, .{ .name = getterName("SHA384") }); - @export(BunObject.SHA512, .{ .name = getterName("SHA512") }); - @export(BunObject.SHA512_256, .{ .name = getterName("SHA512_256") }); - - @export(BunObject.TOML, .{ .name = getterName("TOML") }); - @export(BunObject.Glob, .{ .name = getterName("Glob") }); - @export(BunObject.Transpiler, .{ .name = getterName("Transpiler") }); - @export(BunObject.argv, .{ .name = getterName("argv") }); - @export(BunObject.cwd, .{ .name = getterName("cwd") }); - @export(BunObject.enableANSIColors, .{ .name = getterName("enableANSIColors") }); - @export(BunObject.hash, .{ .name = getterName("hash") }); - @export(BunObject.inspect, .{ .name = getterName("inspect") }); - @export(BunObject.main, .{ .name = getterName("main") }); - @export(BunObject.origin, .{ .name = getterName("origin") }); - @export(BunObject.stderr, .{ .name = getterName("stderr") }); - @export(BunObject.stdin, .{ .name = getterName("stdin") }); - @export(BunObject.stdout, .{ .name = getterName("stdout") }); - @export(BunObject.unsafe, .{ .name = getterName("unsafe") }); - @export(BunObject.semver, .{ .name = getterName("semver") }); - @export(BunObject.embeddedFiles, .{ .name = getterName("embeddedFiles") }); - @export(BunObject.S3Client, .{ .name = getterName("S3Client") }); - @export(BunObject.s3, .{ .name = getterName("s3") }); + @export(&BunObject.CryptoHasher, .{ .name = getterName("CryptoHasher") }); + @export(&BunObject.FFI, .{ .name = getterName("FFI") }); + @export(&BunObject.FileSystemRouter, .{ .name = getterName("FileSystemRouter") }); + @export(&BunObject.MD4, .{ .name = getterName("MD4") }); + @export(&BunObject.MD5, .{ .name = getterName("MD5") }); + @export(&BunObject.SHA1, .{ .name = getterName("SHA1") }); + @export(&BunObject.SHA224, .{ .name = getterName("SHA224") }); + @export(&BunObject.SHA256, .{ .name = getterName("SHA256") }); + @export(&BunObject.SHA384, .{ .name = getterName("SHA384") }); + @export(&BunObject.SHA512, .{ .name = getterName("SHA512") }); + @export(&BunObject.SHA512_256, .{ .name = getterName("SHA512_256") }); + + @export(&BunObject.TOML, .{ .name = getterName("TOML") }); + @export(&BunObject.Glob, .{ .name = getterName("Glob") }); + @export(&BunObject.Transpiler, .{ .name = getterName("Transpiler") }); + @export(&BunObject.argv, .{ .name = getterName("argv") }); + @export(&BunObject.cwd, .{ .name = getterName("cwd") }); + @export(&BunObject.enableANSIColors, .{ .name = getterName("enableANSIColors") }); + @export(&BunObject.hash, .{ .name = getterName("hash") }); + @export(&BunObject.inspect, .{ .name = getterName("inspect") }); + @export(&BunObject.main, .{ .name = getterName("main") }); + @export(&BunObject.origin, .{ .name = getterName("origin") }); + @export(&BunObject.stderr, .{ .name = getterName("stderr") }); + @export(&BunObject.stdin, .{ .name = getterName("stdin") }); + @export(&BunObject.stdout, .{ .name = getterName("stdout") }); + @export(&BunObject.unsafe, .{ .name = getterName("unsafe") }); + @export(&BunObject.semver, .{ .name = getterName("semver") }); + @export(&BunObject.embeddedFiles, .{ .name = getterName("embeddedFiles") }); + @export(&BunObject.S3Client, .{ .name = getterName("S3Client") }); + @export(&BunObject.s3, .{ .name = getterName("s3") }); // --- Getters -- // -- Callbacks -- - @export(BunObject.allocUnsafe, .{ .name = callbackName("allocUnsafe") }); - @export(BunObject.build, .{ .name = callbackName("build") }); - @export(BunObject.color, .{ .name = callbackName("color") }); - @export(BunObject.connect, .{ .name = callbackName("connect") }); - @export(BunObject.createParsedShellScript, .{ .name = callbackName("createParsedShellScript") }); - @export(BunObject.createShellInterpreter, .{ .name = callbackName("createShellInterpreter") }); - @export(BunObject.deflateSync, .{ .name = callbackName("deflateSync") }); - @export(BunObject.file, .{ .name = callbackName("file") }); - @export(BunObject.gunzipSync, .{ .name = callbackName("gunzipSync") }); - @export(BunObject.gzipSync, .{ .name = callbackName("gzipSync") }); - @export(BunObject.indexOfLine, .{ .name = callbackName("indexOfLine") }); - @export(BunObject.inflateSync, .{ .name = callbackName("inflateSync") }); - @export(BunObject.jest, .{ .name = callbackName("jest") }); - @export(BunObject.listen, .{ .name = callbackName("listen") }); - @export(BunObject.mmap, .{ .name = callbackName("mmap") }); - @export(BunObject.nanoseconds, .{ .name = callbackName("nanoseconds") }); - @export(BunObject.openInEditor, .{ .name = callbackName("openInEditor") }); - @export(BunObject.registerMacro, .{ .name = callbackName("registerMacro") }); - @export(BunObject.resolve, .{ .name = callbackName("resolve") }); - @export(BunObject.resolveSync, .{ .name = callbackName("resolveSync") }); - @export(BunObject.serve, .{ .name = callbackName("serve") }); - @export(BunObject.sha, .{ .name = callbackName("sha") }); - @export(BunObject.shellEscape, .{ .name = callbackName("shellEscape") }); - @export(BunObject.shrink, .{ .name = callbackName("shrink") }); - @export(BunObject.sleepSync, .{ .name = callbackName("sleepSync") }); - @export(BunObject.spawn, .{ .name = callbackName("spawn") }); - @export(BunObject.spawnSync, .{ .name = callbackName("spawnSync") }); - @export(BunObject.udpSocket, .{ .name = callbackName("udpSocket") }); - @export(BunObject.which, .{ .name = callbackName("which") }); - @export(BunObject.write, .{ .name = callbackName("write") }); + @export(&BunObject.allocUnsafe, .{ .name = callbackName("allocUnsafe") }); + @export(&BunObject.build, .{ .name = callbackName("build") }); + @export(&BunObject.color, .{ .name = callbackName("color") }); + @export(&BunObject.connect, .{ .name = callbackName("connect") }); + @export(&BunObject.createParsedShellScript, .{ .name = callbackName("createParsedShellScript") }); + @export(&BunObject.createShellInterpreter, .{ .name = callbackName("createShellInterpreter") }); + @export(&BunObject.deflateSync, .{ .name = callbackName("deflateSync") }); + @export(&BunObject.file, .{ .name = callbackName("file") }); + @export(&BunObject.gunzipSync, .{ .name = callbackName("gunzipSync") }); + @export(&BunObject.gzipSync, .{ .name = callbackName("gzipSync") }); + @export(&BunObject.indexOfLine, .{ .name = callbackName("indexOfLine") }); + @export(&BunObject.inflateSync, .{ .name = callbackName("inflateSync") }); + @export(&BunObject.jest, .{ .name = callbackName("jest") }); + @export(&BunObject.listen, .{ .name = callbackName("listen") }); + @export(&BunObject.mmap, .{ .name = callbackName("mmap") }); + @export(&BunObject.nanoseconds, .{ .name = callbackName("nanoseconds") }); + @export(&BunObject.openInEditor, .{ .name = callbackName("openInEditor") }); + @export(&BunObject.registerMacro, .{ .name = callbackName("registerMacro") }); + @export(&BunObject.resolve, .{ .name = callbackName("resolve") }); + @export(&BunObject.resolveSync, .{ .name = callbackName("resolveSync") }); + @export(&BunObject.serve, .{ .name = callbackName("serve") }); + @export(&BunObject.sha, .{ .name = callbackName("sha") }); + @export(&BunObject.shellEscape, .{ .name = callbackName("shellEscape") }); + @export(&BunObject.shrink, .{ .name = callbackName("shrink") }); + @export(&BunObject.sleepSync, .{ .name = callbackName("sleepSync") }); + @export(&BunObject.spawn, .{ .name = callbackName("spawn") }); + @export(&BunObject.spawnSync, .{ .name = callbackName("spawnSync") }); + @export(&BunObject.udpSocket, .{ .name = callbackName("udpSocket") }); + @export(&BunObject.which, .{ .name = callbackName("which") }); + @export(&BunObject.write, .{ .name = callbackName("write") }); // -- Callbacks -- } }; @@ -1920,7 +1920,7 @@ pub const Crypto = struct { hash: []const u8, pub fn toErrorInstance(this: Value, globalObject: *JSC.JSGlobalObject) JSC.JSValue { - const error_code = std.fmt.allocPrint(bun.default_allocator, "PASSWORD_{}", .{PascalToUpperUnderscoreCaseFormatter{ .input = @errorName(this.err) }}) catch bun.outOfMemory(); + const error_code = std.fmt.allocPrint(bun.default_allocator, "PASSWORD{}", .{PascalToUpperUnderscoreCaseFormatter{ .input = @errorName(this.err) }}) catch bun.outOfMemory(); defer bun.default_allocator.free(error_code); const instance = globalObject.createErrorInstance("Password hashing failed with error \"{s}\"", .{@errorName(this.err)}); instance.put(globalObject, ZigString.static("code"), JSC.ZigString.init(error_code).toJS(globalObject)); @@ -2857,7 +2857,7 @@ pub const Crypto = struct { return globalThis.throw("Bun.file() is not supported here yet (it needs an async version)", .{}); } - if (comptime @typeInfo(@TypeOf(Hasher.hash)).Fn.params.len == 3) { + if (comptime @typeInfo(@TypeOf(Hasher.hash)).@"fn".params.len == 3) { Hasher.hash(input.slice(), &output_digest_buf, JSC.VirtualMachine.get().rareData().boringEngine()); } else { Hasher.hash(input.slice(), &output_digest_buf); @@ -2877,7 +2877,7 @@ pub const Crypto = struct { output_digest_slice = bytes[0..Hasher.digest]; } - if (comptime @typeInfo(@TypeOf(Hasher.hash)).Fn.params.len == 3) { + if (comptime @typeInfo(@TypeOf(Hasher.hash)).@"fn".params.len == 3) { Hasher.hash(input.slice(), output_digest_slice, JSC.VirtualMachine.get().rareData().boringEngine()); } else { Hasher.hash(input.slice(), output_digest_slice); @@ -3266,7 +3266,7 @@ pub fn mmapFile(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun. if (try opts.get(globalThis, "offset")) |value| { offset = @as(usize, @intCast(value.toInt64())); - offset = std.mem.alignBackwardAnyAlign(offset, std.mem.page_size); + offset = std.mem.alignBackwardAnyAlign(usize, offset, std.mem.page_size); } } diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index 8aa4f79e382a67..b5d4a6a6775fa7 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Api = @import("../../api/schema.zig").Api; -const JavaScript = @import("../javascript.zig"); const QueryStringMap = @import("../../url.zig").QueryStringMap; const CombinedScanner = @import("../../url.zig").CombinedScanner; const bun = @import("root").bun; @@ -11,7 +10,6 @@ const WebCore = @import("../webcore/response.zig"); const Transpiler = bun.transpiler; const options = @import("../../options.zig"); const resolve_path = @import("../../resolver/resolve_path.zig"); -const VirtualMachine = JavaScript.VirtualMachine; const ScriptSrcStream = std.io.FixedBufferStream([]u8); const ZigString = JSC.ZigString; const Fs = @import("../../fs.zig"); diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index cd42cb5b14784c..0c0aa5a27ac73c 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Api = @import("../../api/schema.zig").Api; -const JavaScript = @import("../javascript.zig"); const QueryStringMap = @import("../../url.zig").QueryStringMap; const CombinedScanner = @import("../../url.zig").CombinedScanner; const bun = @import("root").bun; @@ -10,7 +9,6 @@ const js = JSC.C; const WebCore = @import("../webcore/response.zig"); const Transpiler = bun.transpiler; const options = @import("../../options.zig"); -const VirtualMachine = JavaScript.VirtualMachine; const ScriptSrcStream = std.io.FixedBufferStream([]u8); const ZigString = JSC.ZigString; const Fs = @import("../../fs.zig"); @@ -454,7 +452,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std allocator, &transpiler.log, logger.Source.initPathString("tsconfig.json", transpiler.tsconfig_buf), - &VirtualMachine.get().transpiler.resolver.caches.json, + &JSC.VirtualMachine.get().transpiler.resolver.caches.json, ) catch null) |parsed_tsconfig| { transpiler.tsconfig = parsed_tsconfig; } @@ -488,7 +486,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std if (out.isEmpty()) break :macros; transpiler.macros_buf = out.toOwnedSlice(allocator) catch bun.outOfMemory(); const source = logger.Source.initPathString("macros.json", transpiler.macros_buf); - const json = (VirtualMachine.get().transpiler.resolver.caches.json.parseJSON( + const json = (JSC.VirtualMachine.get().transpiler.resolver.caches.json.parseJSON( &transpiler.log, source, allocator, @@ -731,7 +729,7 @@ pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) b allocator, log, transpiler_options.transform, - JavaScript.VirtualMachine.get().transpiler.env, + JSC.VirtualMachine.get().transpiler.env, ) catch |err| { if ((log.warnings + log.errors) > 0) { return globalThis.throwValue(log.toJS(globalThis, allocator, "Failed to create transpiler")); diff --git a/src/bun.js/api/Timer.zig b/src/bun.js/api/Timer.zig index e7a3569b2de952..0c9bae6db207d1 100644 --- a/src/bun.js/api/Timer.zig +++ b/src/bun.js/api/Timer.zig @@ -302,7 +302,7 @@ pub const All = struct { } comptime { - @export(setImmediate, .{ .name = "Bun__Timer__setImmediate" }); + @export(&setImmediate, .{ .name = "Bun__Timer__setImmediate" }); } pub fn setTimeout( @@ -412,11 +412,11 @@ pub const All = struct { }); comptime { - @export(setTimeout, .{ .name = Export[0].symbol_name }); - @export(setInterval, .{ .name = Export[1].symbol_name }); - @export(clearTimeout, .{ .name = Export[2].symbol_name }); - @export(clearInterval, .{ .name = Export[3].symbol_name }); - @export(getNextID, .{ .name = Export[4].symbol_name }); + @export(&setTimeout, .{ .name = Export[0].symbol_name }); + @export(&setInterval, .{ .name = Export[1].symbol_name }); + @export(&clearTimeout, .{ .name = Export[2].symbol_name }); + @export(&clearInterval, .{ .name = Export[3].symbol_name }); + @export(&getNextID, .{ .name = Export[4].symbol_name }); } }; @@ -444,7 +444,7 @@ pub const TimerObject = struct { }, pub usingnamespace JSC.Codegen.JSTimeout; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); extern "C" fn Bun__JSTimeout__call(encodedTimeoutValue: JSValue, globalObject: *JSC.JSGlobalObject) void; diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index 60dfc785274ea5..f960f38828ab9a 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -41,10 +41,7 @@ const LibInfo = struct { if (loaded) return handle; loaded = true; - const RTLD_LAZY = 1; - const RTLD_LOCAL = 4; - - handle = bun.C.dlopen("libinfo.dylib", RTLD_LAZY | RTLD_LOCAL); + handle = bun.C.dlopen("libinfo.dylib", .{ .LAZY = true, .LOCAL = true }); if (handle == null) Output.debug("libinfo.dylib not found", .{}); return handle; @@ -1395,7 +1392,7 @@ pub const InternalDNS = struct { // https://github.com/nodejs/node/issues/33816 // https://github.com/aio-libs/aiohttp/issues/5357 // https://github.com/libuv/libuv/issues/2225 - .flags = if (Environment.isPosix) bun.C.translated.AI_ADDRCONFIG else 0, + .flags = if (Environment.isPosix) .{ .ADDRCONFIG = true } else .{}, .next = null, .protocol = 0, .socktype = std.c.SOCK.STREAM, @@ -1527,7 +1524,7 @@ pub const InternalDNS = struct { if (Environment.isWindows) { const wsa = std.os.windows.ws2_32; const wsa_hints = wsa.addrinfo{ - .flags = 0, + .flags = .{}, .family = wsa.AF.UNSPEC, .socktype = wsa.SOCK.STREAM, .protocol = 0, @@ -1756,16 +1753,16 @@ pub const InternalDNS = struct { pub const InternalDNSRequest = InternalDNS.Request; comptime { - @export(InternalDNS.us_getaddrinfo_set, .{ + @export(&InternalDNS.us_getaddrinfo_set, .{ .name = "Bun__addrinfo_set", }); - @export(InternalDNS.us_getaddrinfo, .{ + @export(&InternalDNS.us_getaddrinfo, .{ .name = "Bun__addrinfo_get", }); - @export(InternalDNS.freeaddrinfo, .{ + @export(&InternalDNS.freeaddrinfo, .{ .name = "Bun__addrinfo_freeRequest", }); - @export(InternalDNS.getRequestResult, .{ + @export(&InternalDNS.getRequestResult, .{ .name = "Bun__addrinfo_getRequestResult", }); } @@ -1802,7 +1799,7 @@ pub const DNSResolver = struct { pending_nameinfo_cache_cares: NameInfoPendingCache = NameInfoPendingCache.init(), pub usingnamespace JSC.Codegen.JSDNSResolver; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); const PollsMap = std.AutoArrayHashMap(c_ares.ares_socket_t, *PollType); @@ -1912,7 +1909,7 @@ pub const DNSResolver = struct { } fn anyRequestsPending(this: *DNSResolver) bool { - inline for (@typeInfo(DNSResolver).Struct.fields) |field| { + inline for (@typeInfo(DNSResolver).@"struct".fields) |field| { if (comptime std.mem.startsWith(u8, field.name, "pending_")) { const set = &@field(this, field.name).available; if (set.count() < set.capacity()) { @@ -3396,40 +3393,40 @@ pub const DNSResolver = struct { comptime { const js_resolve = JSC.toJSHostFunction(globalResolve); - @export(js_resolve, .{ .name = "Bun__DNS__resolve" }); + @export(&js_resolve, .{ .name = "Bun__DNS__resolve" }); const js_lookup = JSC.toJSHostFunction(globalLookup); - @export(js_lookup, .{ .name = "Bun__DNS__lookup" }); + @export(&js_lookup, .{ .name = "Bun__DNS__lookup" }); const js_resolveTxt = JSC.toJSHostFunction(globalResolveTxt); - @export(js_resolveTxt, .{ .name = "Bun__DNS__resolveTxt" }); + @export(&js_resolveTxt, .{ .name = "Bun__DNS__resolveTxt" }); const js_resolveSoa = JSC.toJSHostFunction(globalResolveSoa); - @export(js_resolveSoa, .{ .name = "Bun__DNS__resolveSoa" }); + @export(&js_resolveSoa, .{ .name = "Bun__DNS__resolveSoa" }); const js_resolveMx = JSC.toJSHostFunction(globalResolveMx); - @export(js_resolveMx, .{ .name = "Bun__DNS__resolveMx" }); + @export(&js_resolveMx, .{ .name = "Bun__DNS__resolveMx" }); const js_resolveNaptr = JSC.toJSHostFunction(globalResolveNaptr); - @export(js_resolveNaptr, .{ .name = "Bun__DNS__resolveNaptr" }); + @export(&js_resolveNaptr, .{ .name = "Bun__DNS__resolveNaptr" }); const js_resolveSrv = JSC.toJSHostFunction(globalResolveSrv); - @export(js_resolveSrv, .{ .name = "Bun__DNS__resolveSrv" }); + @export(&js_resolveSrv, .{ .name = "Bun__DNS__resolveSrv" }); const js_resolveCaa = JSC.toJSHostFunction(globalResolveCaa); - @export(js_resolveCaa, .{ .name = "Bun__DNS__resolveCaa" }); + @export(&js_resolveCaa, .{ .name = "Bun__DNS__resolveCaa" }); const js_resolveNs = JSC.toJSHostFunction(globalResolveNs); - @export(js_resolveNs, .{ .name = "Bun__DNS__resolveNs" }); + @export(&js_resolveNs, .{ .name = "Bun__DNS__resolveNs" }); const js_resolvePtr = JSC.toJSHostFunction(globalResolvePtr); - @export(js_resolvePtr, .{ .name = "Bun__DNS__resolvePtr" }); + @export(&js_resolvePtr, .{ .name = "Bun__DNS__resolvePtr" }); const js_resolveCname = JSC.toJSHostFunction(globalResolveCname); - @export(js_resolveCname, .{ .name = "Bun__DNS__resolveCname" }); + @export(&js_resolveCname, .{ .name = "Bun__DNS__resolveCname" }); const js_resolveAny = JSC.toJSHostFunction(globalResolveAny); - @export(js_resolveAny, .{ .name = "Bun__DNS__resolveAny" }); + @export(&js_resolveAny, .{ .name = "Bun__DNS__resolveAny" }); const js_getGlobalServers = JSC.toJSHostFunction(getGlobalServers); - @export(js_getGlobalServers, .{ .name = "Bun__DNS__getServers" }); + @export(&js_getGlobalServers, .{ .name = "Bun__DNS__getServers" }); const js_setGlobalServers = JSC.toJSHostFunction(setGlobalServers); - @export(js_setGlobalServers, .{ .name = "Bun__DNS__setServers" }); + @export(&js_setGlobalServers, .{ .name = "Bun__DNS__setServers" }); const js_reverse = JSC.toJSHostFunction(globalReverse); - @export(js_reverse, .{ .name = "Bun__DNS__reverse" }); + @export(&js_reverse, .{ .name = "Bun__DNS__reverse" }); const js_lookupService = JSC.toJSHostFunction(globalLookupService); - @export(js_lookupService, .{ .name = "Bun__DNS__lookupService" }); + @export(&js_lookupService, .{ .name = "Bun__DNS__lookupService" }); const js_prefetchFromJS = JSC.toJSHostFunction(InternalDNS.prefetchFromJS); - @export(js_prefetchFromJS, .{ .name = "Bun__DNS__prefetch" }); + @export(&js_prefetchFromJS, .{ .name = "Bun__DNS__prefetch" }); const js_getDNSCacheStats = JSC.toJSHostFunction(InternalDNS.getDNSCacheStats); - @export(js_getDNSCacheStats, .{ .name = "Bun__DNS__getCacheStats" }); + @export(&js_getDNSCacheStats, .{ .name = "Bun__DNS__getCacheStats" }); } }; diff --git a/src/bun.js/api/bun/h2_frame_parser.zig b/src/bun.js/api/bun/h2_frame_parser.zig index 9522df43bf7f2e..87b719740cf123 100644 --- a/src/bun.js/api/bun/h2_frame_parser.zig +++ b/src/bun.js/api/bun/h2_frame_parser.zig @@ -530,7 +530,7 @@ const Handlers = struct { globalObject: *JSC.JSGlobalObject, strong_ctx: JSC.Strong = .{}, - pub fn callEventHandler(this: *Handlers, comptime event: @Type(.EnumLiteral), thisValue: JSValue, data: []const JSValue) bool { + pub fn callEventHandler(this: *Handlers, comptime event: @Type(.enum_literal), thisValue: JSValue, data: []const JSValue) bool { const callback = @field(this, @tagName(event)); if (callback == .zero) { return false; @@ -546,7 +546,7 @@ const Handlers = struct { return true; } - pub fn callEventHandlerWithResult(this: *Handlers, comptime event: @Type(.EnumLiteral), thisValue: JSValue, data: []const JSValue) JSValue { + pub fn callEventHandlerWithResult(this: *Handlers, comptime event: @Type(.enum_literal), thisValue: JSValue, data: []const JSValue) JSValue { const callback = @field(this, @tagName(event)); if (callback == .zero) { return JSC.JSValue.zero; @@ -643,8 +643,7 @@ const Handlers = struct { pub const H2FrameParser = struct { pub const log = Output.scoped(.H2FrameParser, false); pub usingnamespace JSC.Codegen.JSH2FrameParser; - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); - pub const DEBUG_REFCOUNT_NAME = "H2"; + pub usingnamespace bun.NewRefCounted(@This(), deinit, "H2"); const ENABLE_AUTO_CORK = true; // ENABLE CORK OPTIMIZATION const ENABLE_ALLOCATOR_POOL = true; // ENABLE HIVE ALLOCATOR OPTIMIZATION @@ -1356,7 +1355,7 @@ pub const H2FrameParser = struct { _ = this.write(&buffer); } - pub fn dispatch(this: *H2FrameParser, comptime event: @Type(.EnumLiteral), value: JSC.JSValue) void { + pub fn dispatch(this: *H2FrameParser, comptime event: @Type(.enum_literal), value: JSC.JSValue) void { JSC.markBinding(@src()); const ctx_value = this.strong_ctx.get() orelse return; @@ -1364,7 +1363,7 @@ pub const H2FrameParser = struct { _ = this.handlers.callEventHandler(event, ctx_value, &[_]JSC.JSValue{ ctx_value, value }); } - pub fn call(this: *H2FrameParser, comptime event: @Type(.EnumLiteral), value: JSC.JSValue) JSValue { + pub fn call(this: *H2FrameParser, comptime event: @Type(.enum_literal), value: JSC.JSValue) JSValue { JSC.markBinding(@src()); const ctx_value = this.strong_ctx.get() orelse return .zero; @@ -1376,7 +1375,7 @@ pub const H2FrameParser = struct { _ = this.handlers.callWriteCallback(callback, &[_]JSC.JSValue{}); } - pub fn dispatchWithExtra(this: *H2FrameParser, comptime event: @Type(.EnumLiteral), value: JSC.JSValue, extra: JSC.JSValue) void { + pub fn dispatchWithExtra(this: *H2FrameParser, comptime event: @Type(.enum_literal), value: JSC.JSValue, extra: JSC.JSValue) void { JSC.markBinding(@src()); const ctx_value = this.strong_ctx.get() orelse return; @@ -1385,7 +1384,7 @@ pub const H2FrameParser = struct { _ = this.handlers.callEventHandler(event, ctx_value, &[_]JSC.JSValue{ ctx_value, value, extra }); } - pub fn dispatchWith2Extra(this: *H2FrameParser, comptime event: @Type(.EnumLiteral), value: JSC.JSValue, extra: JSC.JSValue, extra2: JSC.JSValue) void { + pub fn dispatchWith2Extra(this: *H2FrameParser, comptime event: @Type(.enum_literal), value: JSC.JSValue, extra: JSC.JSValue, extra2: JSC.JSValue) void { JSC.markBinding(@src()); const ctx_value = this.strong_ctx.get() orelse return; @@ -1394,7 +1393,7 @@ pub const H2FrameParser = struct { extra2.ensureStillAlive(); _ = this.handlers.callEventHandler(event, ctx_value, &[_]JSC.JSValue{ ctx_value, value, extra, extra2 }); } - pub fn dispatchWith3Extra(this: *H2FrameParser, comptime event: @Type(.EnumLiteral), value: JSC.JSValue, extra: JSC.JSValue, extra2: JSC.JSValue, extra3: JSC.JSValue) void { + pub fn dispatchWith3Extra(this: *H2FrameParser, comptime event: @Type(.enum_literal), value: JSC.JSValue, extra: JSC.JSValue, extra2: JSC.JSValue, extra3: JSC.JSValue) void { JSC.markBinding(@src()); const ctx_value = this.strong_ctx.get() orelse return; diff --git a/src/bun.js/api/bun/process.zig b/src/bun.js/api/bun/process.zig index d7e7c5be142151..9f69ce021c9d2d 100644 --- a/src/bun.js/api/bun/process.zig +++ b/src/bun.js/api/bun/process.zig @@ -11,12 +11,12 @@ const Maybe = JSC.Maybe; const win_rusage = struct { utime: struct { - tv_sec: i64 = 0, - tv_usec: i64 = 0, + sec: i64 = 0, + usec: i64 = 0, }, stime: struct { - tv_sec: i64 = 0, - tv_usec: i64 = 0, + sec: i64 = 0, + usec: i64 = 0, }, maxrss: u64 = 0, ixrss: u0 = 0, @@ -54,16 +54,16 @@ pub fn uv_getrusage(process: *uv.uv_process_t) win_rusage { var kerneltime: WinTime = undefined; var usertime: WinTime = undefined; // We at least get process times - if (std.os.windows.kernel32.GetProcessTimes(process_pid, &starttime, &exittime, &kerneltime, &usertime) == 1) { + if (bun.windows.GetProcessTimes(process_pid, &starttime, &exittime, &kerneltime, &usertime) == 1) { var temp: u64 = (@as(u64, kerneltime.dwHighDateTime) << 32) | kerneltime.dwLowDateTime; if (temp > 0) { - usage_info.stime.tv_sec = @intCast(temp / 10000000); - usage_info.stime.tv_usec = @intCast(temp % 1000000); + usage_info.stime.sec = @intCast(temp / 10000000); + usage_info.stime.usec = @intCast(temp % 1000000); } temp = (@as(u64, usertime.dwHighDateTime) << 32) | usertime.dwLowDateTime; if (temp > 0) { - usage_info.utime.tv_sec = @intCast(temp / 10000000); - usage_info.utime.tv_usec = @intCast(temp % 1000000); + usage_info.utime.sec = @intCast(temp / 10000000); + usage_info.utime.usec = @intCast(temp % 1000000); } } var counters: IO_COUNTERS = .{}; @@ -110,23 +110,23 @@ pub const ProcessExitHandler = struct { } switch (this.ptr.tag()) { - .Subprocess => { + @field(TaggedPointer.Tag, @typeName(Subprocess)) => { const subprocess = this.ptr.as(Subprocess); subprocess.onProcessExit(process, status, rusage); }, - .LifecycleScriptSubprocess => { + @field(TaggedPointer.Tag, @typeName(LifecycleScriptSubprocess)) => { const subprocess = this.ptr.as(LifecycleScriptSubprocess); subprocess.onProcessExit(process, status, rusage); }, - .ProcessHandle => { + @field(TaggedPointer.Tag, @typeName(ProcessHandle)) => { const subprocess = this.ptr.as(ProcessHandle); subprocess.onProcessExit(process, status, rusage); }, - @field(TaggedPointer.Tag, bun.meta.typeBaseName(@typeName(ShellSubprocess))) => { + @field(TaggedPointer.Tag, @typeName(ShellSubprocess)) => { const subprocess = this.ptr.as(ShellSubprocess); subprocess.onProcessExit(process, status, rusage); }, - @field(TaggedPointer.Tag, bun.meta.typeBaseName(@typeName(SyncProcess))) => { + @field(TaggedPointer.Tag, @typeName(SyncProcess)) => { const subprocess = this.ptr.as(SyncProcess); if (comptime Environment.isPosix) { @panic("This code should not reached"); @@ -157,7 +157,7 @@ pub const Process = struct { return @sizeOf(@This()); } - pub usingnamespace bun.NewRefCounted(Process, deinit); + pub usingnamespace bun.NewRefCounted(Process, deinit, null); pub fn setExitHandler(this: *Process, handler: anytype) void { this.exit_handler.init(handler); @@ -924,7 +924,7 @@ const WaiterThreadPosix = struct { .mask = current_mask, .flags = std.posix.SA.NOCLDSTOP, }; - std.posix.sigaction(std.posix.SIG.CHLD, &act, null) catch {}; + std.posix.sigaction(std.posix.SIG.CHLD, &act, null); } } @@ -2018,7 +2018,9 @@ pub const sync = struct { pub fn spawn( options: *const Options, ) !Maybe(Result) { - const envp = options.envp orelse std.c.environ; + // [*:null]?[*:0]const u8 + // [*:null]?[*:0]u8 + const envp = options.envp orelse @as([*:null]?[*:0]const u8, @ptrCast(std.c.environ)); const argv = options.argv; var string_builder = bun.StringBuilder{}; defer string_builder.deinit(bun.default_allocator); diff --git a/src/bun.js/api/bun/socket.zig b/src/bun.js/api/bun/socket.zig index 65f03c1b0bef93..93801a0e809ab1 100644 --- a/src/bun.js/api/bun/socket.zig +++ b/src/bun.js/api/bun/socket.zig @@ -1342,9 +1342,7 @@ fn NewSocket(comptime ssl: bool) type { // This is wasteful because it means we are keeping a JSC::Weak for every single open socket has_pending_activity: std.atomic.Value(bool) = std.atomic.Value(bool).init(true), native_callback: NativeCallbacks = .none, - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); - - pub const DEBUG_REFCOUNT_NAME = "Socket"; + pub usingnamespace bun.NewRefCounted(@This(), deinit, "Socket"); // We use this direct callbacks on HTTP2 when available pub const NativeCallbacks = union(enum) { @@ -1395,8 +1393,6 @@ fn NewSocket(comptime ssl: bool) type { JSC.Codegen.JSTLSSocket; pub fn hasPendingActivity(this: *This) callconv(.C) bool { - @fence(.acquire); - return this.has_pending_activity.load(.acquire); } diff --git a/src/bun.js/api/bun/subprocess.zig b/src/bun.js/api/bun/subprocess.zig index 28bf780f8f587a..5a30592c49fc07 100644 --- a/src/bun.js/api/bun/subprocess.zig +++ b/src/bun.js/api/bun/subprocess.zig @@ -48,8 +48,8 @@ pub const ResourceUsage = struct { var cpu = JSC.JSValue.createEmptyObjectWithNullPrototype(globalObject); const rusage = this.rusage; - const usrTime = JSValue.fromTimevalNoTruncate(globalObject, rusage.utime.tv_usec, rusage.utime.tv_sec); - const sysTime = JSValue.fromTimevalNoTruncate(globalObject, rusage.stime.tv_usec, rusage.stime.tv_sec); + const usrTime = JSValue.fromTimevalNoTruncate(globalObject, rusage.utime.usec, rusage.utime.sec); + const sysTime = JSValue.fromTimevalNoTruncate(globalObject, rusage.stime.usec, rusage.stime.sec); cpu.put(globalObject, JSC.ZigString.static("user"), usrTime); cpu.put(globalObject, JSC.ZigString.static("system"), sysTime); @@ -199,7 +199,7 @@ pub const Subprocess = struct { ref_count: u32 = 1, abort_signal: ?*JSC.AbortSignal = null, - usingnamespace bun.NewRefCounted(@This(), Subprocess.deinit); + usingnamespace bun.NewRefCounted(@This(), deinit, null); pub const Flags = packed struct { is_sync: bool = false, @@ -279,7 +279,6 @@ pub const Subprocess = struct { } pub fn updateHasPendingActivity(this: *Subprocess) void { - @fence(.seq_cst); if (comptime Environment.isDebug) { log("updateHasPendingActivity() {any} -> {any}", .{ this.has_pending_activity.raw, @@ -342,7 +341,6 @@ pub const Subprocess = struct { } pub fn hasPendingActivity(this: *Subprocess) callconv(.C) bool { - @fence(.acquire); return this.has_pending_activity.load(.acquire); } @@ -684,7 +682,7 @@ pub const Subprocess = struct { return this.process.kill(@intCast(sig)); } - fn hasCalledGetter(this: *Subprocess, comptime getter: @Type(.EnumLiteral)) bool { + fn hasCalledGetter(this: *Subprocess, comptime getter: @Type(.enum_literal)) bool { return this.observable_getters.contains(getter); } @@ -853,7 +851,7 @@ pub const Subprocess = struct { ref_count: u32 = 1, buffer: []const u8 = "", - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), _deinit, null); const This = @This(); const print = bun.Output.scoped(.StaticPipeWriter, false); @@ -940,7 +938,7 @@ pub const Subprocess = struct { this.process.onCloseIO(.stdin); } - pub fn deinit(this: *This) void { + fn _deinit(this: *This) void { this.writer.end(); this.source.detach(); this.destroy(); @@ -981,7 +979,7 @@ pub const Subprocess = struct { pub const IOReader = bun.io.BufferedReader; pub const Poll = IOReader; - pub usingnamespace bun.NewRefCounted(PipeReader, PipeReader.deinit); + pub usingnamespace bun.NewRefCounted(PipeReader, _deinit, null); pub fn memoryCost(this: *const PipeReader) usize { return this.reader.memoryCost(); @@ -1148,7 +1146,7 @@ pub const Subprocess = struct { return this.event_loop.virtual_machine.uwsLoop(); } - fn deinit(this: *PipeReader) void { + fn _deinit(this: *PipeReader) void { if (comptime Environment.isPosix) { bun.assert(this.reader.isDone()); } @@ -1570,7 +1568,7 @@ pub const Subprocess = struct { } } - fn closeIO(this: *Subprocess, comptime io: @Type(.EnumLiteral)) void { + fn closeIO(this: *Subprocess, comptime io: @Type(.enum_literal)) void { if (this.closed.contains(io)) return; this.closed.insert(io); diff --git a/src/bun.js/api/bun/udp_socket.zig b/src/bun.js/api/bun/udp_socket.zig index 0f71f800e3a318..e29508f3a05275 100644 --- a/src/bun.js/api/bun/udp_socket.zig +++ b/src/bun.js/api/bun/udp_socket.zig @@ -282,7 +282,7 @@ pub const UDPSocket = struct { globalThis: *JSGlobalObject, thisValue: JSValue = .zero, - ref: JSC.Ref = JSC.Ref.init(), + jsc_ref: JSC.Ref = JSC.Ref.init(), poll_ref: Async.KeepAlive = Async.KeepAlive.init(), // if marked as closed the socket pointer may be stale closed: bool = false, diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index 131842881b8668..a50392f7ce4b60 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -275,7 +275,9 @@ pub const FFI = struct { "macosx", "-show-sdk-path", }, - .envp = std.c.environ, + // ?[*:null]?[*:0]const u8 + // [*:null]?[*:0]u8 + .envp = @ptrCast(std.c.environ), }) catch return; if (process == .result) { defer process.result.deinit(); diff --git a/src/bun.js/api/filesystem_router.zig b/src/bun.js/api/filesystem_router.zig index a85e8697301155..0569d5f858d65e 100644 --- a/src/bun.js/api/filesystem_router.zig +++ b/src/bun.js/api/filesystem_router.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Api = @import("../../api/schema.zig").Api; -const JavaScript = @import("../javascript.zig"); const QueryStringMap = @import("../../url.zig").QueryStringMap; const CombinedScanner = @import("../../url.zig").CombinedScanner; const bun = @import("root").bun; @@ -9,7 +8,6 @@ const JSC = bun.JSC; const js = JSC.C; const WebCore = JSC.WebCore; const Transpiler = bun.transpiler; -const VirtualMachine = JavaScript.VirtualMachine; const ScriptSrcStream = std.io.FixedBufferStream([]u8); const ZigString = JSC.ZigString; const Fs = @import("../../fs.zig"); @@ -605,7 +603,7 @@ pub const MatchedRoute = struct { var writer = stream.writer(); JSC.API.Bun.getPublicPathWithAssetPrefix( this.route.file_path, - if (this.base_dir) |base_dir| base_dir.slice() else VirtualMachine.get().transpiler.fs.top_level_dir, + if (this.base_dir) |base_dir| base_dir.slice() else JSC.VirtualMachine.get().transpiler.fs.top_level_dir, if (this.origin) |origin| URL.parse(origin.slice()) else URL{}, if (this.asset_prefix) |prefix| prefix.slice() else "", @TypeOf(&writer), diff --git a/src/bun.js/api/glob.zig b/src/bun.js/api/glob.zig index d81225f20b19fc..b75a29da95f914 100644 --- a/src/bun.js/api/glob.zig +++ b/src/bun.js/api/glob.zig @@ -324,17 +324,14 @@ pub fn finalize( } pub fn hasPendingActivity(this: *Glob) callconv(.C) bool { - @fence(.seq_cst); return this.has_pending_activity.load(.seq_cst) > 0; } fn incrPendingActivityFlag(has_pending_activity: *std.atomic.Value(usize)) void { - @fence(.seq_cst); _ = has_pending_activity.fetchAdd(1, .seq_cst); } fn decrPendingActivityFlag(has_pending_activity: *std.atomic.Value(usize)) void { - @fence(.seq_cst); _ = has_pending_activity.fetchSub(1, .seq_cst); } diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index da0db62909f3ae..4eaa5441e14413 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -18,7 +18,7 @@ pub const LOLHTMLContext = struct { document_handlers: std.ArrayListUnmanaged(*DocumentHandler) = .{}, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); fn deinit(this: *LOLHTMLContext) void { for (this.selectors.items) |selector| { @@ -395,7 +395,7 @@ pub const HTMLRewriter = struct { bodyValueBufferer: ?JSC.WebCore.BodyValueBufferer = null, tmp_sync_error: ?*JSC.JSValue = null, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(BufferOutputSink, deinit); + pub usingnamespace bun.NewRefCounted(BufferOutputSink, deinit, null); // const log = bun.Output.scoped(.BufferOutputSink, false); pub fn init(context: *LOLHTMLContext, global: *JSGlobalObject, original: *Response, builder: *LOLHTML.HTMLRewriter.Builder) JSC.JSValue { @@ -1066,7 +1066,7 @@ pub const TextChunk = struct { ref_count: u32 = 1, pub usingnamespace JSC.Codegen.JSTextChunk; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn init(text_chunk: *LOLHTML.TextChunk) *TextChunk { return TextChunk.new(.{ .text_chunk = text_chunk, .ref_count = 2 }); } @@ -1175,7 +1175,7 @@ pub const DocType = struct { return DocType.new(.{ .doctype = doctype, .ref_count = 2 }); } - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub usingnamespace JSC.Codegen.JSDocType; /// The doctype name. @@ -1242,7 +1242,7 @@ pub const DocEnd = struct { doc_end: ?*LOLHTML.DocEnd, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub usingnamespace JSC.Codegen.JSDocEnd; pub fn init(doc_end: *LOLHTML.DocEnd) *DocEnd { @@ -1291,7 +1291,7 @@ pub const Comment = struct { comment: ?*LOLHTML.Comment = null, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub usingnamespace JSC.Codegen.JSComment; pub fn init(comment: *LOLHTML.Comment) *Comment { @@ -1436,7 +1436,7 @@ pub const EndTag = struct { }; pub usingnamespace JSC.Codegen.JSEndTag; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); fn contentHandler(this: *EndTag, comptime Callback: (fn (*LOLHTML.EndTag, []const u8, bool) LOLHTML.Error!void), thisObject: JSValue, globalObject: *JSGlobalObject, content: ZigString, contentOptions: ?ContentOptions) JSValue { if (this.end_tag == null) @@ -1554,7 +1554,7 @@ pub const AttributeIterator = struct { } pub usingnamespace JSC.Codegen.JSAttributeIterator; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn next(this: *AttributeIterator, globalObject: *JSGlobalObject, _: *JSC.CallFrame) bun.JSError!JSValue { const done_label = JSC.ZigString.static("done"); @@ -1591,7 +1591,7 @@ pub const Element = struct { ref_count: u32 = 1, pub usingnamespace JSC.Codegen.JSElement; - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn init(element: *LOLHTML.Element) *Element { return Element.new(.{ .element = element, .ref_count = 2 }); diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 16a08406db2174..304f30fbece051 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1607,7 +1607,7 @@ pub const AnyRequestContext = struct { tagged_pointer: Pointer, - pub const Null = .{ .tagged_pointer = Pointer.Null }; + pub const Null: @This() = .{ .tagged_pointer = Pointer.Null }; pub fn init(request_ctx: anytype) AnyRequestContext { return .{ .tagged_pointer = Pointer.init(request_ctx) }; @@ -2751,7 +2751,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp } } - pub fn onReadFile(this: *RequestContext, result: Blob.ReadFile.ResultType) void { + pub fn onReadFile(this: *RequestContext, result: Blob.ReadFileResultType) void { defer this.deref(); if (this.isAbortedOrEnded()) { @@ -4126,7 +4126,7 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp var body = this.request_body.?; var old = body.value; old.Locked.onReceiveValue = null; - var new_body = .{ .Null = {} }; + var new_body: WebCore.Body.Value = .{ .Null = {} }; old.resolve(&new_body, server.globalThis, null); body.value = new_body; } @@ -4182,13 +4182,13 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp comptime { const jsonResolve = JSC.toJSHostFunction(onResolve); - @export(jsonResolve, .{ .name = Export[0].symbol_name }); + @export(&jsonResolve, .{ .name = Export[0].symbol_name }); const jsonReject = JSC.toJSHostFunction(onReject); - @export(jsonReject, .{ .name = Export[1].symbol_name }); + @export(&jsonReject, .{ .name = Export[1].symbol_name }); const jsonResolveStream = JSC.toJSHostFunction(onResolveStream); - @export(jsonResolveStream, .{ .name = Export[2].symbol_name }); + @export(&jsonResolveStream, .{ .name = Export[2].symbol_name }); const jsonRejectStream = JSC.toJSHostFunction(onRejectStream); - @export(jsonRejectStream, .{ .name = Export[3].symbol_name }); + @export(&jsonRejectStream, .{ .name = Export[3].symbol_name }); } }; } @@ -5791,7 +5791,7 @@ const ServePlugins = struct { value: Value, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(ServePlugins, deinit); + pub usingnamespace bun.NewRefCounted(ServePlugins, deinit, null); pub const Value = union(enum) { pending: struct { @@ -5949,8 +5949,8 @@ const ServePlugins = struct { } comptime { - @export(onResolve, .{ .name = "BunServe__onResolvePlugins" }); - @export(onReject, .{ .name = "BunServe__onRejectPlugins" }); + @export(&onResolve, .{ .name = "BunServe__onResolvePlugins" }); + @export(&onReject, .{ .name = "BunServe__onRejectPlugins" }); } }; diff --git a/src/bun.js/api/server/HTMLBundle.zig b/src/bun.js/api/server/HTMLBundle.zig index 02db1b48968ed3..39bc5ac5198442 100644 --- a/src/bun.js/api/server/HTMLBundle.zig +++ b/src/bun.js/api/server/HTMLBundle.zig @@ -77,7 +77,7 @@ pub const HTMLBundleRoute = struct { }); } - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), _deinit, null); pub const Value = union(enum) { pending_plugins, @@ -114,7 +114,7 @@ pub const HTMLBundleRoute = struct { } }; - pub fn deinit(this: *HTMLBundleRoute) void { + fn _deinit(this: *HTMLBundleRoute) void { for (this.pending_responses.items) |pending_response| { pending_response.deref(); } @@ -512,9 +512,9 @@ pub const HTMLBundleRoute = struct { server: ?AnyServer = null, route: *HTMLBundleRoute, - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), __deinit, null); - pub fn deinit(this: *PendingResponse) void { + fn __deinit(this: *PendingResponse) void { if (this.is_response_pending) { this.resp.clearAborted(); this.resp.clearOnWritable(); @@ -544,7 +544,7 @@ pub const HTMLBundleRoute = struct { }; pub usingnamespace JSC.Codegen.JSHTMLBundle; -pub usingnamespace bun.NewRefCounted(HTMLBundle, deinit); +pub usingnamespace bun.NewRefCounted(HTMLBundle, deinit, null); const bun = @import("root").bun; const std = @import("std"); const JSC = bun.JSC; diff --git a/src/bun.js/api/server/StaticRoute.zig b/src/bun.js/api/server/StaticRoute.zig index 31336978771a8d..7270198b051b48 100644 --- a/src/bun.js/api/server/StaticRoute.zig +++ b/src/bun.js/api/server/StaticRoute.zig @@ -10,7 +10,7 @@ headers: Headers = .{ }, ref_count: u32 = 1, -pub usingnamespace bun.NewRefCounted(@This(), deinit); +pub usingnamespace bun.NewRefCounted(@This(), deinit, null); fn deinit(this: *StaticRoute) void { this.blob.detach(); diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index db0594382e46d4..8f58a2b083e71c 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -9,18 +9,11 @@ const strings = bun.strings; const MutableString = bun.MutableString; const stringZ = bun.stringZ; const default_allocator = bun.default_allocator; -const C = bun.C; -const JavaScript = @import("./javascript.zig"); const JSC = bun.JSC; -const WebCore = @import("./webcore.zig"); const Test = @import("./test/jest.zig"); -const Fetch = WebCore.Fetch; -const Response = WebCore.Response; -const Request = WebCore.Request; const Router = @import("./api/filesystem_router.zig"); const IdentityContext = @import("../identity_context.zig").IdentityContext; const uws = bun.uws; -const Body = WebCore.Body; const TaggedPointerTypes = @import("../tagged_pointer.zig"); const TaggedPointerUnion = TaggedPointerTypes.TaggedPointerUnion; @@ -41,11 +34,11 @@ pub const Lifetime = enum { pub fn toJS(globalObject: *JSC.JSGlobalObject, comptime ValueType: type, value: ValueType, comptime lifetime: Lifetime) JSC.JSValue { const Type = comptime brk: { var CurrentType = ValueType; - if (@typeInfo(ValueType) == .Optional) { - CurrentType = @typeInfo(ValueType).Optional.child; + if (@typeInfo(ValueType) == .optional) { + CurrentType = @typeInfo(ValueType).optional.child; } - break :brk if (@typeInfo(CurrentType) == .Pointer and @typeInfo(CurrentType).Pointer.size == .One) - @typeInfo(CurrentType).Pointer.child + break :brk if (@typeInfo(CurrentType) == .pointer and @typeInfo(CurrentType).pointer.size == .one) + @typeInfo(CurrentType).pointer.child else CurrentType; }; @@ -103,16 +96,16 @@ pub fn toJS(globalObject: *JSC.JSGlobalObject, comptime ValueType: type, value: return array; } - if (comptime @hasDecl(Type, "toJSNewlyCreated") and @typeInfo(@TypeOf(@field(Type, "toJSNewlyCreated"))).Fn.params.len == 2) { + if (comptime @hasDecl(Type, "toJSNewlyCreated") and @typeInfo(@TypeOf(@field(Type, "toJSNewlyCreated"))).@"fn".params.len == 2) { return value.toJSNewlyCreated(globalObject); } - if (comptime @hasDecl(Type, "toJS") and @typeInfo(@TypeOf(@field(Type, "toJS"))).Fn.params.len == 2) { + if (comptime @hasDecl(Type, "toJS") and @typeInfo(@TypeOf(@field(Type, "toJS"))).@"fn".params.len == 2) { return value.toJS(globalObject); } // must come after toJS check in case this enum implements its own serializer. - if (@typeInfo(Type) == .Enum) { + if (@typeInfo(Type) == .@"enum") { // FIXME: creates non-normalized integers (e.g. u2), which // aren't handled by `jsNumberWithType` rn return JSC.JSValue.jsNumberWithType(u32, @as(u32, @intFromEnum(value))); @@ -168,9 +161,6 @@ pub const Properties = struct { } }; -const JSValue = JSC.JSValue; -const ZigString = JSC.ZigString; - pub const PathString = bun.PathString; pub fn createError( @@ -205,7 +195,7 @@ fn toTypeErrorWithCode( args: anytype, ctx: js.JSContextRef, ) JSC.JSValue { - @setCold(true); + @branchHint(.cold); var zig_str: JSC.ZigString = undefined; if (comptime std.meta.fields(@TypeOf(args)).len == 0) { zig_str = JSC.ZigString.init(fmt); @@ -216,7 +206,7 @@ fn toTypeErrorWithCode( zig_str.detectEncoding(); zig_str.mark(); } - const code_str = ZigString.init(code); + const code_str = JSC.ZigString.init(code); return JSC.JSValue.createTypeError(&zig_str, &code_str, ctx); } @@ -235,7 +225,7 @@ pub fn throwInvalidArguments( ctx: js.JSContextRef, exception: ExceptionValueRef, ) void { - @setCold(true); + @branchHint(.cold); exception.* = JSC.Error.ERR_INVALID_ARG_TYPE.fmt(ctx, fmt, args).asObjectRef(); } @@ -244,7 +234,7 @@ pub fn toInvalidArguments( args: anytype, ctx: js.JSContextRef, ) JSC.JSValue { - @setCold(true); + @branchHint(.cold); return JSC.Error.ERR_INVALID_ARG_TYPE.fmt(ctx, fmt, args); } @@ -253,7 +243,7 @@ pub fn getAllocator(_: js.JSContextRef) std.mem.Allocator { } /// Print a JSValue to stdout; this is only meant for debugging purposes -pub fn dump(value: JSValue, globalObject: *JSC.JSGlobalObject) !void { +pub fn dump(value: JSC.WebCore.JSValue, globalObject: *JSC.JSGlobalObject) !void { var formatter = JSC.ConsoleObject.Formatter{ .globalThis = globalObject }; try Output.errorWriter().print("{}\n", .{value.toFmt(globalObject, &formatter)}); Output.flush(); @@ -389,7 +379,7 @@ pub const ArrayBuffer = extern struct { return Stream{ .pos = 0, .buf = this.slice() }; } - pub fn create(globalThis: *JSC.JSGlobalObject, bytes: []const u8, comptime kind: JSValue.JSType) JSValue { + pub fn create(globalThis: *JSC.JSGlobalObject, bytes: []const u8, comptime kind: JSC.JSValue.JSType) JSC.JSValue { JSC.markBinding(@src()); return switch (comptime kind) { .Uint8Array => Bun__createUint8ArrayForCopy(globalThis, bytes.ptr, bytes.len, false), @@ -398,7 +388,7 @@ pub const ArrayBuffer = extern struct { }; } - pub fn createEmpty(globalThis: *JSC.JSGlobalObject, comptime kind: JSC.JSValue.JSType) JSValue { + pub fn createEmpty(globalThis: *JSC.JSGlobalObject, comptime kind: JSC.JSValue.JSType) JSC.JSValue { JSC.markBinding(@src()); return switch (comptime kind) { @@ -408,18 +398,18 @@ pub const ArrayBuffer = extern struct { }; } - pub fn createBuffer(globalThis: *JSC.JSGlobalObject, bytes: []const u8) JSValue { + pub fn createBuffer(globalThis: *JSC.JSGlobalObject, bytes: []const u8) JSC.JSValue { JSC.markBinding(@src()); return Bun__createUint8ArrayForCopy(globalThis, bytes.ptr, bytes.len, true); } - pub fn createUint8Array(globalThis: *JSC.JSGlobalObject, bytes: []const u8) JSValue { + pub fn createUint8Array(globalThis: *JSC.JSGlobalObject, bytes: []const u8) JSC.JSValue { JSC.markBinding(@src()); return Bun__createUint8ArrayForCopy(globalThis, bytes.ptr, bytes.len, false); } - extern "C" fn Bun__allocUint8ArrayForCopy(*JSC.JSGlobalObject, usize, **anyopaque) JSValue; - pub fn allocBuffer(globalThis: *JSC.JSGlobalObject, len: usize) struct { JSValue, []u8 } { + extern "C" fn Bun__allocUint8ArrayForCopy(*JSC.JSGlobalObject, usize, **anyopaque) JSC.JSValue; + pub fn allocBuffer(globalThis: *JSC.JSGlobalObject, len: usize) struct { JSC.JSValue, []u8 } { var ptr: [*]u8 = undefined; const buffer = Bun__allocUint8ArrayForCopy(globalThis, len, @ptrCast(&ptr)); if (buffer.isEmpty()) { @@ -428,8 +418,8 @@ pub const ArrayBuffer = extern struct { return .{ buffer, ptr[0..len] }; } - extern "C" fn Bun__createUint8ArrayForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize, buffer: bool) JSValue; - extern "C" fn Bun__createArrayBufferForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize) JSValue; + extern "C" fn Bun__createUint8ArrayForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize, buffer: bool) JSC.JSValue; + extern "C" fn Bun__createArrayBufferForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize) JSC.JSValue; pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue) ArrayBuffer { var out = std.mem.zeroes(ArrayBuffer); @@ -664,7 +654,7 @@ pub const MarkedArrayBuffer = struct { } pub fn toNodeBuffer(this: *const MarkedArrayBuffer, ctx: js.JSContextRef) JSC.JSValue { - return JSValue.createBufferWithCtx(ctx, this.buffer.byteSlice(), this.buffer.ptr, MarkedArrayBuffer_deallocator); + return JSC.JSValue.createBufferWithCtx(ctx, this.buffer.byteSlice(), this.buffer.ptr, MarkedArrayBuffer_deallocator); } pub fn toJSObjectRef(this: *const MarkedArrayBuffer, ctx: js.JSContextRef, exception: js.ExceptionRef) js.JSObjectRef { @@ -723,7 +713,7 @@ pub const RefString = struct { pub const Hash = u32; pub const Map = std.HashMap(Hash, *JSC.RefString, IdentityContext(Hash), 80); - pub fn toJS(this: *RefString, global: *JSC.JSGlobalObject) JSValue { + pub fn toJS(this: *RefString, global: *JSC.JSGlobalObject) JSC.JSValue { return bun.String.init(this.impl).toJS(global); } @@ -795,9 +785,9 @@ const Expect = Test.Expect; const DescribeScope = Test.DescribeScope; const TestScope = Test.TestScope; const NodeFS = JSC.Node.NodeFS; -const TextEncoder = WebCore.TextEncoder; -const TextDecoder = WebCore.TextDecoder; -const TextEncoderStreamEncoder = WebCore.TextEncoderStreamEncoder; +const TextEncoder = JSC.WebCore.TextEncoder; +const TextDecoder = JSC.WebCore.TextDecoder; +const TextEncoderStreamEncoder = JSC.WebCore.TextEncoderStreamEncoder; const HTMLRewriter = JSC.Cloudflare.HTMLRewriter; const Element = JSC.Cloudflare.Element; const Comment = JSC.Cloudflare.Comment; @@ -914,7 +904,7 @@ pub const DOMEffect = struct { }; fn DOMCallArgumentType(comptime Type: type) []const u8 { - const ChildType = if (@typeInfo(Type) == .Pointer) std.meta.Child(Type) else Type; + const ChildType = if (@typeInfo(Type) == .pointer) std.meta.Child(Type) else Type; return switch (ChildType) { i8, u8, i16, u16, i32 => "JSC::SpecInt32Only", u32, i64, u64 => "JSC::SpecInt52Any", @@ -927,7 +917,7 @@ fn DOMCallArgumentType(comptime Type: type) []const u8 { } fn DOMCallArgumentTypeWrapper(comptime Type: type) []const u8 { - const ChildType = if (@typeInfo(Type) == .Pointer) std.meta.Child(Type) else Type; + const ChildType = if (@typeInfo(Type) == .pointer) std.meta.Child(Type) else Type; return switch (ChildType) { i32 => "int32_t", f64 => "double", @@ -941,7 +931,7 @@ fn DOMCallArgumentTypeWrapper(comptime Type: type) []const u8 { } fn DOMCallResultType(comptime Type: type) []const u8 { - const ChildType = if (@typeInfo(Type) == .Pointer) std.meta.Child(Type) else Type; + const ChildType = if (@typeInfo(Type) == .pointer) std.meta.Child(Type) else Type; return switch (ChildType) { i32 => "JSC::SpecInt32Only", bool => "JSC::SpecBoolean", @@ -975,7 +965,7 @@ pub fn DOMCall( thisValue: JSC.JSValue, arguments_ptr: [*]const JSC.JSValue, arguments_len: usize, - ) callconv(JSC.conv) JSValue { + ) callconv(JSC.conv) JSC.JSValue { return JSC.toJSHostValue(globalObject, @field(Container, functionName)(globalObject, thisValue, arguments_ptr[0..arguments_len])); } @@ -983,7 +973,7 @@ pub fn DOMCall( pub const Fastpath = @TypeOf(fastpath); pub const Arguments = std.meta.ArgsTuple(Fastpath); - pub fn put(globalObject: *JSC.JSGlobalObject, value: JSValue) void { + pub fn put(globalObject: *JSC.JSGlobalObject, value: JSC.JSValue) void { shim.cppFn("put", .{ globalObject, value }); } @@ -992,8 +982,8 @@ pub fn DOMCall( pub const Extern = [_][]const u8{"put"}; comptime { - @export(slowpath, .{ .name = shim.symbolName("slowpath") }); - @export(fastpath, .{ .name = shim.symbolName("fastpath") }); + @export(&slowpath, .{ .name = shim.symbolName("slowpath") }); + @export(&fastpath, .{ .name = shim.symbolName("fastpath") }); } }; } @@ -1009,7 +999,7 @@ pub fn wrapInstanceMethod( ) InstanceMethodType(Container) { return struct { const FunctionType = @TypeOf(@field(Container, name)); - const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).Fn; + const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).@"fn"; const Args = std.meta.ArgsTuple(FunctionType); const eater = if (auto_protect) JSC.Node.ArgumentsSlice.protectEatNext else JSC.Node.ArgumentsSlice.nextEat; @@ -1091,7 +1081,7 @@ pub fn wrapInstanceMethod( args[i] = null; } }, - ZigString => { + JSC.ZigString => { var string_value = eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing argument", .{}); @@ -1113,32 +1103,32 @@ pub fn wrapInstanceMethod( args[i] = null; } }, - *Response => { + *JSC.WebCore.Response => { args[i] = (eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing Response object", .{}); - }).as(Response) orelse { + }).as(JSC.WebCore.Response) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Expected Response object", .{}); }; }, - *Request => { + *JSC.WebCore.Request => { args[i] = (eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing Request object", .{}); - }).as(Request) orelse { + }).as(JSC.WebCore.Request) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Expected Request object", .{}); }; }, - JSValue => { + JSC.JSValue => { const val = eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing argument", .{}); }; args[i] = val; }, - ?JSValue => { + ?JSC.JSValue => { args[i] = eater(&iter); }, JSC.C.ExceptionRef => { @@ -1170,7 +1160,7 @@ pub fn wrapStaticMethod( ) JSC.JSHostZigFunction { return struct { const FunctionType = @TypeOf(@field(Container, name)); - const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).Fn; + const FunctionTypeInfo: std.builtin.Type.Fn = @typeInfo(FunctionType).@"fn"; const Args = std.meta.ArgsTuple(FunctionType); const eater = if (auto_protect) JSC.Node.ArgumentsSlice.protectEatNext else JSC.Node.ArgumentsSlice.nextEat; @@ -1244,7 +1234,7 @@ pub fn wrapStaticMethod( args[i] = null; } }, - ZigString => { + JSC.ZigString => { var string_value = eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing argument", .{}); @@ -1266,32 +1256,32 @@ pub fn wrapStaticMethod( args[i] = null; } }, - *Response => { + *JSC.WebCore.Response => { args[i] = (eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing Response object", .{}); - }).as(Response) orelse { + }).as(JSC.WebCore.Response) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Expected Response object", .{}); }; }, - *Request => { + *JSC.WebCore.Request => { args[i] = (eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing Request object", .{}); - }).as(Request) orelse { + }).as(JSC.WebCore.Request) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Expected Request object", .{}); }; }, - JSValue => { + JSC.WebCore.JSValue => { const val = eater(&iter) orelse { iter.deinit(); return globalThis.throwInvalidArguments("Missing argument", .{}); }; args[i] = val; }, - ?JSValue => { + ?JSC.WebCore.JSValue => { args[i] = eater(&iter); }, else => @compileError(std.fmt.comptimePrint("Unexpected Type " ++ @typeName(ArgType) ++ " at argument {d} in {s}#{s}", .{ i, @typeName(Container), name })), @@ -1402,7 +1392,7 @@ pub const BinaryType = enum(u4) { return Map.get(input); } - pub fn fromJSValue(globalThis: *JSC.JSGlobalObject, input: JSValue) bun.JSError!?BinaryType { + pub fn fromJSValue(globalThis: *JSC.JSGlobalObject, input: JSC.JSValue) bun.JSError!?BinaryType { if (input.isString()) { return Map.getWithEql(try input.toBunString2(globalThis), bun.String.eqlComptime); } @@ -1411,7 +1401,7 @@ pub const BinaryType = enum(u4) { } /// This clones bytes - pub fn toJS(this: BinaryType, bytes: []const u8, globalThis: *JSC.JSGlobalObject) JSValue { + pub fn toJS(this: BinaryType, bytes: []const u8, globalThis: *JSC.JSGlobalObject) JSC.JSValue { switch (this) { .Buffer => return JSC.ArrayBuffer.createBuffer(globalThis, bytes), .ArrayBuffer => return JSC.ArrayBuffer.create(globalThis, bytes, .ArrayBuffer), diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index ab9df2f32f595c..8727946521c3b5 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -13,7 +13,6 @@ const ZigStackTrace = Exports.ZigStackTrace; const ArrayBuffer = @import("../base.zig").ArrayBuffer; const JSC = bun.JSC; const Shimmer = JSC.Shimmer; -const ConsoleObject = JSC.ConsoleObject; const FFI = @import("./FFI.zig"); const NullableAllocator = bun.NullableAllocator; const MutableString = bun.MutableString; @@ -66,7 +65,7 @@ pub const JSObject = extern struct { /// prototype (`null_prototype = false`) unless you have a good reason not /// to. fn createFromStructWithPrototype(comptime T: type, pojo: T, global: *JSGlobalObject, comptime null_prototype: bool) *JSObject { - const info: std.builtin.Type.Struct = @typeInfo(T).Struct; + const info: std.builtin.Type.Struct = @typeInfo(T).@"struct"; const obj = obj: { const val = if (comptime null_prototype) @@ -2534,7 +2533,7 @@ pub const JSPromise = extern struct { const Wrapper = struct { args: Args, - pub fn call(this: *@This(), g: *JSC.JSGlobalObject) JSC.JSValue { + pub fn call(this: *@This(), g: *JSC.JSGlobalObject) callconv(.c) JSC.JSValue { return toJSHostValue(g, @call(.auto, Fn, this.args)); } }; @@ -2815,7 +2814,7 @@ pub const AnyPromise = union(enum) { const Wrapper = struct { args: Args, - pub fn call(wrap_: *@This(), global: *JSC.JSGlobalObject) JSC.JSValue { + pub fn call(wrap_: *@This(), global: *JSC.JSGlobalObject) callconv(.c) JSC.JSValue { return toJSHostValue(global, @call(.auto, Fn, wrap_.args)); } }; @@ -4084,7 +4083,6 @@ pub const JSValue = enum(i64) { if (this.isDouble()) { return this.asDouble(); } - return this.coerceToDouble(globalThis); }, i64 => { @@ -4094,13 +4092,21 @@ pub const JSValue = enum(i64) { if (this.isInt32()) { return this.asInt32(); } - if (this.getNumber()) |num| { return coerceJSValueDoubleTruncatingT(i32, num); } - return this.coerceToInt32(globalThis); }, + std.c.AI, + => { + if (this.isInt32()) { + return @bitCast(this.asInt32()); + } + if (this.getNumber()) |num| { + return @bitCast(coerceJSValueDoubleTruncatingT(i32, num)); + } + return @bitCast(this.coerceToInt32(globalThis)); + }, else => @compileError("Unsupported coercion type"), }; } @@ -4108,8 +4114,8 @@ pub const JSValue = enum(i64) { /// This does not call [Symbol.toPrimitive] or [Symbol.toStringTag]. /// This is only safe when you don't want to do conversions across non-primitive types. pub fn to(this: JSValue, comptime T: type) T { - if (@typeInfo(T) == .Enum) { - const Int = @typeInfo(T).Enum.tag_type; + if (@typeInfo(T) == .@"enum") { + const Int = @typeInfo(T).@"enum".tag_type; return @enumFromInt(this.to(Int)); } return switch (comptime T) { @@ -4248,8 +4254,8 @@ pub const JSValue = enum(i64) { pub fn put(value: JSValue, global: *JSGlobalObject, key: anytype, result: JSC.JSValue) void { const Key = @TypeOf(key); - if (comptime @typeInfo(Key) == .Pointer) { - const Elem = @typeInfo(Key).Pointer.child; + if (comptime @typeInfo(Key) == .pointer) { + const Elem = @typeInfo(Key).pointer.child; if (Elem == ZigString) { putZigString(value, global, key, result); } else if (Elem == bun.String) { @@ -4476,8 +4482,8 @@ pub const JSValue = enum(i64) { extern fn JSBuffer__bufferFromPointerAndLengthAndDeinit(*JSGlobalObject, [*]u8, usize, ?*anyopaque, JSC.C.JSTypedArrayBytesDeallocator) JSValue; pub fn jsNumberWithType(comptime Number: type, number: Number) JSValue { - if (@typeInfo(Number) == .Enum) { - return jsNumberWithType(@typeInfo(Number).Enum.tag_type, @intFromEnum(number)); + if (@typeInfo(Number) == .@"enum") { + return jsNumberWithType(@typeInfo(Number).@"enum".tag_type, @intFromEnum(number)); } return switch (comptime Number) { JSValue => number, @@ -4570,8 +4576,8 @@ pub const JSValue = enum(i64) { pub fn print( this: JSValue, globalObject: *JSGlobalObject, - message_type: ConsoleObject.MessageType, - message_level: ConsoleObject.MessageLevel, + message_type: JSC.ConsoleObject.MessageType, + message_level: JSC.ConsoleObject.MessageLevel, ) void { JSC.ConsoleObject.messageWithTypeAndLevel( undefined, diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 800cde4c39541a..c94b5e7b9e0263 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -1,7 +1,6 @@ const JSC = bun.JSC; const Fs = @import("../../fs.zig"); const CAPI = JSC.C; -const JS = @import("../javascript.zig"); const JSBase = @import("../base.zig"); const ZigURL = @import("../../url.zig").URL; const Api = @import("../../api/schema.zig").Api; @@ -48,7 +47,7 @@ pub const ZigGlobalObject = extern struct { pub const name = "Zig::GlobalObject"; pub const include = "\"ZigGlobalObject.h\""; pub const namespace = shim.namespace; - pub const Interface: type = NewGlobalObject(JS.VirtualMachine); + pub const Interface: type = NewGlobalObject(JSC.VirtualMachine); pub fn create( vm: *JSC.VirtualMachine, @@ -113,11 +112,11 @@ pub const ZigGlobalObject = extern struct { pub const Extern = [_][]const u8{ "create", "getModuleRegistryMap", "resetModuleRegistryMap" }; comptime { - @export(import, .{ .name = Export[0].symbol_name }); - @export(resolve, .{ .name = Export[1].symbol_name }); - @export(promiseRejectionTracker, .{ .name = Export[2].symbol_name }); - @export(reportUncaughtException, .{ .name = Export[3].symbol_name }); - @export(onCrash, .{ .name = Export[4].symbol_name }); + @export(&import, .{ .name = Export[0].symbol_name }); + @export(&resolve, .{ .name = Export[1].symbol_name }); + @export(&promiseRejectionTracker, .{ .name = Export[2].symbol_name }); + @export(&reportUncaughtException, .{ .name = Export[3].symbol_name }); + @export(&onCrash, .{ .name = Export[4].symbol_name }); } }; @@ -225,7 +224,7 @@ pub const ResolvedSource = extern struct { allocator: ?*anyopaque = null, - jsvalue_for_export: JSC.JSValue = .zero, + jsvalue_for_export: JSValue = .zero, tag: Tag = Tag.javascript, @@ -413,31 +412,31 @@ pub const Process = extern struct { }); comptime { - @export(getTitle, .{ + @export(&getTitle, .{ .name = Export[0].symbol_name, }); - @export(setTitle, .{ + @export(&setTitle, .{ .name = Export[1].symbol_name, }); - @export(getArgv, .{ + @export(&getArgv, .{ .name = Export[2].symbol_name, }); - @export(getCwd, .{ + @export(&getCwd, .{ .name = Export[3].symbol_name, }); - @export(setCwd, .{ + @export(&setCwd, .{ .name = Export[4].symbol_name, }); - @export(exit, .{ + @export(&exit, .{ .name = Export[5].symbol_name, }); - @export(getArgv0, .{ + @export(&getArgv0, .{ .name = Export[6].symbol_name, }); - @export(getExecPath, .{ + @export(&getExecPath, .{ .name = Export[7].symbol_name, }); - @export(getExecArgv, .{ + @export(&getExecArgv, .{ .name = Export[8].symbol_name, }); } @@ -837,7 +836,6 @@ pub const ZigException = extern struct { } pub const shim = Shimmer("Zig", "Exception", @This()); - pub const name = "ZigException"; pub const namespace = shim.namespace; pub const Holder = extern struct { @@ -966,8 +964,8 @@ pub inline fn toGlobalContextRef(ptr: *JSGlobalObject) CAPI.JSGlobalContextRef { } comptime { - @export(ErrorCode.ParserError, .{ .name = "Zig_ErrorCodeParserError" }); - @export(ErrorCode.JSErrorObject, .{ .name = "Zig_ErrorCodeJSErrorObject" }); + @export(&ErrorCode.ParserError, .{ .name = "Zig_ErrorCodeParserError" }); + @export(&ErrorCode.JSErrorObject, .{ .name = "Zig_ErrorCodeJSErrorObject" }); } const Bun = JSC.API.Bun; diff --git a/src/bun.js/bindings/header-gen.zig b/src/bun.js/bindings/header-gen.zig index 3b4dd7ca1ba808..14a8eac7b77fc0 100644 --- a/src/bun.js/bindings/header-gen.zig +++ b/src/bun.js/bindings/header-gen.zig @@ -156,8 +156,8 @@ pub const C_Generator = struct { comptime nonnull.append(i) catch unreachable; }, else => |info| { - if (comptime info == .Pointer and @typeInfo(info.Pointer.child) == .Fn) { - self.gen_closure(comptime info.Pointer.child, comptime std.fmt.comptimePrint(" ArgFn{d}", .{i})); + if (comptime info == .pointer and @typeInfo(info.pointer.child) == .Fn) { + self.gen_closure(comptime info.pointer.child, comptime std.fmt.comptimePrint(" ArgFn{d}", .{i})); comptime nonnull.append(i) catch unreachable; } else { self.writeType(comptime arg.type.?); @@ -189,7 +189,7 @@ pub const C_Generator = struct { defer self.write(";\n"); // const ReturnTypeInfo: std.builtin.Type = comptime @typeInfo(func.return_type); // switch (comptime ReturnTypeInfo) { - // .Pointer => |Pointer| { + // .pointer => |Pointer| { // self.write(" __attribute__((returns_nonnull))"); // }, // .Optional => |Optional| {}, @@ -226,7 +226,7 @@ pub const C_Generator = struct { self.write(")"); // const ReturnTypeInfo: std.builtin.Type = comptime @typeInfo(func.return_type); // switch (comptime ReturnTypeInfo) { - // .Pointer => |Pointer| { + // .pointer => |Pointer| { // self.write(" __attribute__((returns_nonnull))"); // }, // .Optional => |Optional| {}, @@ -344,16 +344,16 @@ pub const C_Generator = struct { Type = OtherType; } } - if (@typeInfo(Type) == .Pointer and !std.meta.isManyItemPtr(Type)) { - Type = @typeInfo(Type).Pointer.child; + if (@typeInfo(Type) == .pointer and !std.meta.isManyItemPtr(Type)) { + Type = @typeInfo(Type).pointer.child; } break :brk Type; }; if (comptime (isCppObject(TT)) and @hasDecl(TT, "name")) { - if (@typeInfo(T) == .Pointer or (@hasDecl(TT, "Type") and (@TypeOf(TT.Type) == type and @typeInfo(TT.Type) == .Pointer))) { - if (@hasDecl(TT, "is_pointer") and !TT.is_pointer) {} else if (@typeInfo(T).Pointer.is_const) { + if (@typeInfo(T) == .pointer or (@hasDecl(TT, "Type") and (@TypeOf(TT.Type) == type and @typeInfo(TT.Type) == .pointer))) { + if (@hasDecl(TT, "is_pointer") and !TT.is_pointer) {} else if (@typeInfo(T).pointer.is_const) { write(self, "const "); } } @@ -401,7 +401,7 @@ pub const C_Generator = struct { write(self, comptime formatted_name); } - if (@typeInfo(T) == .Pointer or (@hasDecl(TT, "Type") and (@TypeOf(TT.Type) == type and @typeInfo(TT.Type) == .Pointer))) { + if (@typeInfo(T) == .pointer or (@hasDecl(TT, "Type") and (@TypeOf(TT.Type) == type and @typeInfo(TT.Type) == .pointer))) { if (@hasDecl(TT, "is_pointer") and !TT.is_pointer) {} else { write(self, "*"); } @@ -414,7 +414,7 @@ pub const C_Generator = struct { } else { const meta = @typeInfo(T); switch (meta) { - .Pointer => |Pointer| { + .pointer => |Pointer| { const child = Pointer.child; // if (childmeta == .Struct and childmeta.Struct.layout != .Extern) { // self.write("void"); @@ -619,9 +619,9 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp \\//-- GENERATED FILE. Do not edit -- \\// \\// To regenerate this file, run: - \\// + \\// \\// make headers - \\// + \\// \\//-- GENERATED FILE. Do not edit -- \\ ) catch unreachable; @@ -663,9 +663,9 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp \\//-- GENERATED FILE. Do not edit -- \\// \\// To regenerate this file, run: - \\// + \\// \\// make headers - \\// + \\// \\//-- GENERATED FILE. Do not edit -- \\ ) catch unreachable; @@ -726,8 +726,8 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp all_types[1] = second_import; var counter: usize = 2; inline for (first_import.DOMCalls) |Type_| { - const Type = if (@typeInfo(@TypeOf(Type_)) == .Pointer) - @typeInfo(@TypeOf(Type_)).Pointer.child + const Type = if (@typeInfo(@TypeOf(Type_)) == .pointer) + @typeInfo(@TypeOf(Type_)).pointer.child else @TypeOf(Type_); @@ -742,8 +742,8 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp }; inline for (first_import.DOMCalls) |Type_| { - const Type = if (@typeInfo(@TypeOf(Type_)) == .Pointer) - @typeInfo(@TypeOf(Type_)).Pointer.child + const Type = if (@typeInfo(@TypeOf(Type_)) == .pointer) + @typeInfo(@TypeOf(Type_)).pointer.child else @TypeOf(Type_); @@ -962,16 +962,16 @@ pub fn HeaderGen(comptime first_import: type, comptime second_import: type, comp generated.writer().print( \\ #include "root.h" \\ #include "headers.h" - \\ + \\ \\ #include \\ #include "DOMJITIDLConvert.h" \\ #include "DOMJITIDLType.h" \\ #include "DOMJITIDLTypeFilter.h" \\ #include "DOMJITHelpers.h" \\ #include - \\ + \\ \\ #include "JSDOMConvertBufferSource.h" - \\ + \\ \\ using namespace JSC; \\ using namespace WebCore; \\ diff --git a/src/bun.js/bindings/shimmer.zig b/src/bun.js/bindings/shimmer.zig index ac5c44c963ed1b..4b306e2d015452 100644 --- a/src/bun.js/bindings/shimmer.zig +++ b/src/bun.js/bindings/shimmer.zig @@ -5,8 +5,7 @@ const Sizes = @import("./sizes.zig"); const headers = @import("./headers.zig"); fn isNullableType(comptime Type: type) bool { - return @typeInfo(Type) == .Optional or - (@typeInfo(Type) == .Pointer and @typeInfo(Type).Pointer.is_allowzero); + return @typeInfo(Type) == .optional or (@typeInfo(Type) == .pointer and @typeInfo(Type).pointer.is_allowzero); } const log = @import("../../output.zig").scoped(.CPP, true); @@ -17,7 +16,7 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp pub fn assertJSFunction(comptime funcs: anytype) void { inline for (funcs) |func| { - if (@typeInfo(@TypeOf(func)) != .Fn) { + if (@typeInfo(@TypeOf(func)) != .@"fn") { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(func) ++ " to be a function but received " ++ @tagName(@typeInfo(@TypeOf(func)))); } } @@ -46,15 +45,15 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp // var ReturnTypeInfo: std.builtin.Type = @typeInfo(FromType); - // if (ReturnTypeInfo == .Pointer and NewReturnType != *anyopaque) { - // NewReturnType = ReturnTypeInfo.Pointer.child; + // if (ReturnTypeInfo == .pointer and NewReturnType != *anyopaque) { + // NewReturnType = ReturnTypeInfo.pointer.child; // ReturnTypeInfo = @typeInfo(NewReturnType); // } // switch (ReturnTypeInfo) { // .Union, // .Struct, - // .Enum, + // .@"enum", // => { // if (@hasDecl(ReturnTypeInfo., "Type")) { // return NewReturnType; @@ -94,8 +93,8 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp }; fn pointerChild(comptime Type: type) type { - if (@typeInfo(Type) == .Pointer) { - return @typeInfo(Type).Pointer.child_type; + if (@typeInfo(Type) == .pointer) { + return @typeInfo(Type).pointer.child_type; } return Type; @@ -115,17 +114,17 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp var functions: [std.meta.fieldNames(FunctionsType).len]StaticExport = undefined; for (std.meta.fieldNames(FunctionsType), 0..) |fn_name, i| { const Function = @TypeOf(@field(Functions, fn_name)); - if (@typeInfo(Function) != .Fn) { + if (@typeInfo(Function) != .@"fn") { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to be a function but received " ++ @tagName(@typeInfo(Function))); } - const Fn: std.builtin.Type.Fn = @typeInfo(Function).Fn; + const Fn: std.builtin.Type.Fn = @typeInfo(Function).@"fn"; if (Function == bun.JSC.JSHostFunctionTypeWithCCallConvForAssertions and bun.JSC.conv != .C) { @compileError("Expected " ++ bun.meta.typeName(Function) ++ " to have a JSC.conv Calling Convention."); } else if (Function == bun.JSC.JSHostFunctionType) { // } else if (Function == bun.JSC.JSHostZigFunction) { // - } else if (Fn.calling_convention != .C) { + } else if (std.meta.activeTag(Fn.calling_convention) != std.meta.activeTag(std.builtin.CallingConvention.c)) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to have a C Calling Convention."); } @@ -150,10 +149,10 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp for (Functions) |thenable| { for ([_][]const u8{ "resolve", "reject" }) |fn_name| { const Function = @TypeOf(@field(thenable, fn_name)); - if (@typeInfo(Function) != .Fn) { + if (@typeInfo(Function) != .@"fn") { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to be a function but received " ++ @tagName(@typeInfo(Function))); } - const Fn: std.builtin.Type.Fn = @typeInfo(Function).Fn; + const Fn: std.builtin.Type.@"fn" = @typeInfo(Function).@"fn"; if (Fn.calling_convention != .C) { @compileError("Expected " ++ @typeName(Parent) ++ "." ++ @typeName(Function) ++ " to have a C Calling Convention."); } @@ -176,7 +175,7 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp pub inline fn matchNullable(comptime ExpectedReturnType: type, comptime ExternReturnType: type, value: ExternReturnType) ExpectedReturnType { if (comptime isNullableType(ExpectedReturnType) != isNullableType(ExternReturnType)) { return value.?; - } else if (comptime (@typeInfo(ExpectedReturnType) == .Enum) and (@typeInfo(ExternReturnType) != .Enum)) { + } else if (comptime (@typeInfo(ExpectedReturnType) == .@"enum") and (@typeInfo(ExternReturnType) != .@"enum")) { return @as(ExpectedReturnType, @enumFromInt(value)); } else { return value; @@ -188,22 +187,22 @@ pub fn Shimmer(comptime _namespace: []const u8, comptime _name: []const u8, comp if (!@hasDecl(Parent, typeName)) { @compileError(@typeName(Parent) ++ " is missing cppFn: " ++ typeName); } - break :ret @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?; + break :ret @typeInfo(@TypeOf(@field(Parent, typeName))).@"fn".return_type.?; }) { log(comptime name ++ "__" ++ typeName, .{}); @setEvalBranchQuota(99999); { const Fn = comptime @field(headers, symbolName(typeName)); - if (@typeInfo(@TypeOf(Fn)).Fn.params.len > 0) + if (@typeInfo(@TypeOf(Fn)).@"fn".params.len > 0) return matchNullable( - comptime @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?, - comptime @typeInfo(@TypeOf(Fn)).Fn.return_type.?, + comptime @typeInfo(@TypeOf(@field(Parent, typeName))).@"fn".return_type.?, + comptime @typeInfo(@TypeOf(Fn)).@"fn".return_type.?, @call(.auto, Fn, args), ); return matchNullable( - comptime @typeInfo(@TypeOf(@field(Parent, typeName))).Fn.return_type.?, - comptime @typeInfo(@TypeOf(Fn)).Fn.return_type.?, + comptime @typeInfo(@TypeOf(@field(Parent, typeName))).@"fn".return_type.?, + comptime @typeInfo(@TypeOf(Fn)).@"fn".return_type.?, Fn(), ); } diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index d09359bfa62c88..59e3347d26f9f9 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -1,29 +1,25 @@ const std = @import("std"); const JSC = bun.JSC; -const JSGlobalObject = JSC.JSGlobalObject; -const VirtualMachine = JSC.VirtualMachine; +const VirtualMachine = bun.JSC.VirtualMachine; const Allocator = std.mem.Allocator; const Lock = bun.Mutex; const bun = @import("root").bun; const Environment = bun.Environment; const Fetch = JSC.WebCore.Fetch; -const WebCore = JSC.WebCore; const Bun = JSC.API.Bun; const TaggedPointerUnion = @import("../tagged_pointer.zig").TaggedPointerUnion; const typeBaseName = @import("../meta.zig").typeBaseName; const AsyncGlobWalkTask = JSC.API.Glob.WalkTask.AsyncGlobWalkTask; -const CopyFilePromiseTask = WebCore.Blob.Store.CopyFile.CopyFilePromiseTask; +const CopyFilePromiseTask = bun.JSC.WebCore.Blob.Store.CopyFilePromiseTask; const AsyncTransformTask = JSC.API.JSTranspiler.TransformTask.AsyncTransformTask; -const ReadFileTask = WebCore.Blob.ReadFile.ReadFileTask; -const WriteFileTask = WebCore.Blob.WriteFile.WriteFileTask; +const ReadFileTask = bun.JSC.WebCore.Blob.ReadFileTask; +const WriteFileTask = bun.JSC.WebCore.Blob.WriteFileTask; const napi_async_work = JSC.napi.napi_async_work; const FetchTasklet = Fetch.FetchTasklet; const S3 = bun.S3; const S3HttpSimpleTask = S3.S3HttpSimpleTask; const S3HttpDownloadStreamingTask = S3.S3HttpDownloadStreamingTask; -const JSValue = JSC.JSValue; -const js = JSC.C; const Waker = bun.Async.Waker; pub const WorkPool = @import("../work_pool.zig").WorkPool; @@ -40,7 +36,7 @@ pub fn ConcurrentPromiseTask(comptime Context: type) type { event_loop: *JSC.EventLoop, allocator: std.mem.Allocator, promise: JSC.JSPromise.Strong = .{}, - globalThis: *JSGlobalObject, + globalThis: *JSC.JSGlobalObject, concurrent_task: JSC.ConcurrentTask = .{}, // This is a poll because we want it to enter the uSockets loop @@ -48,7 +44,7 @@ pub fn ConcurrentPromiseTask(comptime Context: type) type { pub usingnamespace bun.New(@This()); - pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This { + pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSC.JSGlobalObject, value: *Context) !*This { var this = This.new(.{ .event_loop = VirtualMachine.get().event_loop, .ctx = value, @@ -101,7 +97,7 @@ pub fn WorkTask(comptime Context: type) type { task: TaskType = .{ .callback = &runFromThreadPool }, event_loop: *JSC.EventLoop, allocator: std.mem.Allocator, - globalThis: *JSGlobalObject, + globalThis: *JSC.JSGlobalObject, concurrent_task: ConcurrentTask = .{}, async_task_tracker: JSC.AsyncTaskTracker, @@ -110,7 +106,7 @@ pub fn WorkTask(comptime Context: type) type { pub usingnamespace bun.New(@This()); - pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This { + pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSC.JSGlobalObject, value: *Context) !*This { var vm = globalThis.bunVM(); var this = This.new(.{ .event_loop = vm.eventLoop(), @@ -298,8 +294,8 @@ pub const AnyTaskWithExtraContext = struct { }; pub const CppTask = opaque { - extern fn Bun__performTask(globalObject: *JSGlobalObject, task: *CppTask) void; - pub fn run(this: *CppTask, global: *JSGlobalObject) void { + extern fn Bun__performTask(globalObject: *JSC.JSGlobalObject, task: *CppTask) void; + pub fn run(this: *CppTask, global: *JSC.JSGlobalObject) void { JSC.markBinding(@src()); Bun__performTask(global, this); } @@ -311,7 +307,7 @@ pub const ConcurrentCppTask = struct { const EventLoopTaskNoContext = opaque { extern fn Bun__EventLoopTaskNoContext__performTask(task: *EventLoopTaskNoContext) void; - extern fn Bun__EventLoopTaskNoContext__createdInBunVm(task: *const EventLoopTaskNoContext) ?*JSC.VirtualMachine; + extern fn Bun__EventLoopTaskNoContext__createdInBunVm(task: *const EventLoopTaskNoContext) ?*VirtualMachine; /// Deallocates `this` pub fn run(this: *EventLoopTaskNoContext) void { @@ -319,7 +315,7 @@ pub const ConcurrentCppTask = struct { } /// Get the VM that created this task - pub fn getVM(this: *const EventLoopTaskNoContext) ?*JSC.VirtualMachine { + pub fn getVM(this: *const EventLoopTaskNoContext) ?*VirtualMachine { return Bun__EventLoopTaskNoContext__createdInBunVm(this); } }; @@ -658,7 +654,7 @@ pub const GarbageCollectionController = struct { // // When the heap size is increasing, we always switch to fast mode // When the heap size has been the same or less for 30 seconds, we switch to slow mode - pub fn updateGCRepeatTimer(this: *GarbageCollectionController, comptime setting: @Type(.EnumLiteral)) void { + pub fn updateGCRepeatTimer(this: *GarbageCollectionController, comptime setting: @Type(.enum_literal)) void { if (setting == .fast and !this.gc_repeating_timer_fast) { this.gc_repeating_timer_fast = true; this.gc_repeating_timer.set(this, onGCRepeatingTimer, this.gc_timer_interval, this.gc_timer_interval); @@ -744,7 +740,7 @@ pub const GarbageCollectionController = struct { export fn Bun__tickWhilePaused(paused: *bool) void { JSC.markBinding(@src()); - JSC.VirtualMachine.get().eventLoop().tickWhilePaused(paused); + VirtualMachine.get().eventLoop().tickWhilePaused(paused); } comptime { @@ -831,8 +827,8 @@ pub const EventLoop = struct { next_immediate_tasks: Queue = undefined, concurrent_tasks: ConcurrentTask.Queue = ConcurrentTask.Queue{}, - global: *JSGlobalObject = undefined, - virtual_machine: *JSC.VirtualMachine = undefined, + global: *JSC.JSGlobalObject = undefined, + virtual_machine: *VirtualMachine = undefined, waker: ?Waker = null, forever_timer: ?*uws.Timer = null, deferred_tasks: DeferredTaskQueue = .{}, @@ -847,7 +843,7 @@ pub const EventLoop = struct { pub export fn Bun__ensureSignalHandler() void { if (Environment.isPosix) { - if (JSC.VirtualMachine.getMainThreadVM()) |vm| { + if (VirtualMachine.getMainThreadVM()) |vm| { const this = vm.eventLoop(); if (this.signal_handler == null) { this.signal_handler = PosixSignalHandle.new(.{}); @@ -904,7 +900,7 @@ pub const EventLoop = struct { this.entered_event_loop_count -= 1; } - pub inline fn getVmImpl(this: *EventLoop) *JSC.VirtualMachine { + pub inline fn getVmImpl(this: *EventLoop) *VirtualMachine { return this.virtual_machine; } @@ -1007,77 +1003,75 @@ pub const EventLoop = struct { while (@field(this, queue_name).readItem()) |task| { defer counter += 1; switch (task.tag()) { - @field(Task.Tag, typeBaseName(@typeName(ShellAsync))) => { + @field(Task.Tag, @typeName(ShellAsync)) => { var shell_ls_task: *ShellAsync = task.get(ShellAsync).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellAsyncSubprocessDone))) => { + @field(Task.Tag, @typeName(ShellAsyncSubprocessDone)) => { var shell_ls_task: *ShellAsyncSubprocessDone = task.get(ShellAsyncSubprocessDone).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellIOWriterAsyncDeinit))) => { + @field(Task.Tag, @typeName(ShellIOWriterAsyncDeinit)) => { var shell_ls_task: *ShellIOWriterAsyncDeinit = task.get(ShellIOWriterAsyncDeinit).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellIOReaderAsyncDeinit))) => { + @field(Task.Tag, @typeName(ShellIOReaderAsyncDeinit)) => { var shell_ls_task: *ShellIOReaderAsyncDeinit = task.get(ShellIOReaderAsyncDeinit).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellCondExprStatTask))) => { + @field(Task.Tag, @typeName(ShellCondExprStatTask)) => { var shell_ls_task: *ShellCondExprStatTask = task.get(ShellCondExprStatTask).?; shell_ls_task.task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellCpTask))) => { + @field(Task.Tag, @typeName(ShellCpTask)) => { var shell_ls_task: *ShellCpTask = task.get(ShellCpTask).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellTouchTask))) => { + @field(Task.Tag, @typeName(ShellTouchTask)) => { var shell_ls_task: *ShellTouchTask = task.get(ShellTouchTask).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellMkdirTask))) => { + @field(Task.Tag, @typeName(ShellMkdirTask)) => { var shell_ls_task: *ShellMkdirTask = task.get(ShellMkdirTask).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellLsTask))) => { + @field(Task.Tag, @typeName(ShellLsTask)) => { var shell_ls_task: *ShellLsTask = task.get(ShellLsTask).?; shell_ls_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellMvBatchedTask))) => { + @field(Task.Tag, @typeName(ShellMvBatchedTask)) => { var shell_mv_batched_task: *ShellMvBatchedTask = task.get(ShellMvBatchedTask).?; shell_mv_batched_task.task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellMvCheckTargetTask))) => { + @field(Task.Tag, @typeName(ShellMvCheckTargetTask)) => { var shell_mv_check_target_task: *ShellMvCheckTargetTask = task.get(ShellMvCheckTargetTask).?; shell_mv_check_target_task.task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellRmTask))) => { + @field(Task.Tag, @typeName(ShellRmTask)) => { var shell_rm_task: *ShellRmTask = task.get(ShellRmTask).?; shell_rm_task.runFromMainThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ShellRmDirTask))) => { + @field(Task.Tag, @typeName(ShellRmDirTask)) => { var shell_rm_task: *ShellRmDirTask = task.get(ShellRmDirTask).?; shell_rm_task.runFromMainThread(); }, - - @field(Task.Tag, typeBaseName(@typeName(ShellGlobTask))) => { + @field(Task.Tag, @typeName(ShellGlobTask)) => { var shell_glob_task: *ShellGlobTask = task.get(ShellGlobTask).?; shell_glob_task.runFromMainThread(); shell_glob_task.deinit(); }, - .FetchTasklet => { + @field(Task.Tag, @typeName(FetchTasklet)) => { var fetch_task: *Fetch.FetchTasklet = task.get(Fetch.FetchTasklet).?; fetch_task.onProgressUpdate(); }, - .S3HttpSimpleTask => { + @field(Task.Tag, @typeName(S3HttpSimpleTask)) => { var s3_task: *S3HttpSimpleTask = task.get(S3HttpSimpleTask).?; s3_task.onResponse(); }, - .S3HttpDownloadStreamingTask => { + @field(Task.Tag, @typeName(S3HttpDownloadStreamingTask)) => { var s3_task: *S3HttpDownloadStreamingTask = task.get(S3HttpDownloadStreamingTask).?; s3_task.onResponse(); }, - @field(Task.Tag, @typeName(AsyncGlobWalkTask)) => { var globWalkTask: *AsyncGlobWalkTask = task.get(AsyncGlobWalkTask).?; globWalkTask.*.runFromJS(); @@ -1093,11 +1087,11 @@ pub const EventLoop = struct { transform_task.*.runFromJS(); transform_task.deinit(); }, - @field(Task.Tag, typeBaseName(@typeName(JSC.napi.napi_async_work))) => { + @field(Task.Tag, @typeName(JSC.napi.napi_async_work)) => { const transform_task: *JSC.napi.napi_async_work = task.get(JSC.napi.napi_async_work).?; transform_task.*.runFromJS(); }, - .ThreadSafeFunction => { + @field(Task.Tag, @typeName(ThreadSafeFunction)) => { var transform_task: *ThreadSafeFunction = task.as(ThreadSafeFunction); transform_task.onDispatch(); }, @@ -1106,7 +1100,7 @@ pub const EventLoop = struct { transform_task.*.runFromJS(); transform_task.deinit(); }, - @field(Task.Tag, bun.meta.typeBaseName(@typeName(JSCDeferredWorkTask))) => { + @field(Task.Tag, @typeName(JSCDeferredWorkTask)) => { var jsc_task: *JSCDeferredWorkTask = task.get(JSCDeferredWorkTask).?; JSC.markBinding(@src()); jsc_task.run(); @@ -1123,239 +1117,238 @@ pub const EventLoop = struct { // special case: we return return 0; }, - @field(Task.Tag, typeBaseName(@typeName(bun.bake.DevServer.HotReloadEvent))) => { + @field(Task.Tag, @typeName(bun.bake.DevServer.HotReloadEvent)) => { const hmr_task: *bun.bake.DevServer.HotReloadEvent = task.get(bun.bake.DevServer.HotReloadEvent).?; hmr_task.run(); }, - @field(Task.Tag, typeBaseName(@typeName(FSWatchTask))) => { + @field(Task.Tag, @typeName(FSWatchTask)) => { var transform_task: *FSWatchTask = task.get(FSWatchTask).?; transform_task.*.run(); transform_task.deinit(); }, - @field(Task.Tag, typeBaseName(@typeName(AnyTask))) => { + @field(Task.Tag, @typeName(AnyTask)) => { var any: *AnyTask = task.get(AnyTask).?; any.run(); }, - @field(Task.Tag, typeBaseName(@typeName(ManagedTask))) => { + @field(Task.Tag, @typeName(ManagedTask)) => { var any: *ManagedTask = task.get(ManagedTask).?; any.run(); }, - @field(Task.Tag, typeBaseName(@typeName(CppTask))) => { + @field(Task.Tag, @typeName(CppTask)) => { var any: *CppTask = task.get(CppTask).?; any.run(global); }, - @field(Task.Tag, typeBaseName(@typeName(PollPendingModulesTask))) => { + @field(Task.Tag, @typeName(PollPendingModulesTask)) => { virtual_machine.modules.onPoll(); }, - @field(Task.Tag, typeBaseName(@typeName(GetAddrInfoRequestTask))) => { + @field(Task.Tag, @typeName(GetAddrInfoRequestTask)) => { if (Environment.os == .windows) @panic("This should not be reachable on Windows"); var any: *GetAddrInfoRequestTask = task.get(GetAddrInfoRequestTask).?; any.runFromJS(); any.deinit(); }, - @field(Task.Tag, typeBaseName(@typeName(Stat))) => { + @field(Task.Tag, @typeName(Stat)) => { var any: *Stat = task.get(Stat).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Lstat))) => { + @field(Task.Tag, @typeName(Lstat)) => { var any: *Lstat = task.get(Lstat).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Fstat))) => { + @field(Task.Tag, @typeName(Fstat)) => { var any: *Fstat = task.get(Fstat).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Open))) => { + @field(Task.Tag, @typeName(Open)) => { var any: *Open = task.get(Open).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ReadFile))) => { + @field(Task.Tag, @typeName(ReadFile)) => { var any: *ReadFile = task.get(ReadFile).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(WriteFile))) => { + @field(Task.Tag, @typeName(WriteFile)) => { var any: *WriteFile = task.get(WriteFile).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(CopyFile))) => { + @field(Task.Tag, @typeName(CopyFile)) => { var any: *CopyFile = task.get(CopyFile).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Read))) => { + @field(Task.Tag, @typeName(Read)) => { var any: *Read = task.get(Read).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Write))) => { + @field(Task.Tag, @typeName(Write)) => { var any: *Write = task.get(Write).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Truncate))) => { + @field(Task.Tag, @typeName(Truncate)) => { var any: *Truncate = task.get(Truncate).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Writev))) => { + @field(Task.Tag, @typeName(Writev)) => { var any: *Writev = task.get(Writev).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Readv))) => { + @field(Task.Tag, @typeName(Readv)) => { var any: *Readv = task.get(Readv).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Rename))) => { + @field(Task.Tag, @typeName(Rename)) => { var any: *Rename = task.get(Rename).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(FTruncate))) => { + @field(Task.Tag, @typeName(FTruncate)) => { var any: *FTruncate = task.get(FTruncate).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Readdir))) => { + @field(Task.Tag, @typeName(Readdir)) => { var any: *Readdir = task.get(Readdir).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ReaddirRecursive))) => { + @field(Task.Tag, @typeName(ReaddirRecursive)) => { var any: *ReaddirRecursive = task.get(ReaddirRecursive).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Close))) => { + @field(Task.Tag, @typeName(Close)) => { var any: *Close = task.get(Close).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Rm))) => { + @field(Task.Tag, @typeName(Rm)) => { var any: *Rm = task.get(Rm).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Rmdir))) => { + @field(Task.Tag, @typeName(Rmdir)) => { var any: *Rmdir = task.get(Rmdir).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Chown))) => { + @field(Task.Tag, @typeName(Chown)) => { var any: *Chown = task.get(Chown).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(FChown))) => { + @field(Task.Tag, @typeName(FChown)) => { var any: *FChown = task.get(FChown).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Utimes))) => { + @field(Task.Tag, @typeName(Utimes)) => { var any: *Utimes = task.get(Utimes).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Lutimes))) => { + @field(Task.Tag, @typeName(Lutimes)) => { var any: *Lutimes = task.get(Lutimes).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Chmod))) => { + @field(Task.Tag, @typeName(Chmod)) => { var any: *Chmod = task.get(Chmod).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Fchmod))) => { + @field(Task.Tag, @typeName(Fchmod)) => { var any: *Fchmod = task.get(Fchmod).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Link))) => { + @field(Task.Tag, @typeName(Link)) => { var any: *Link = task.get(Link).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Symlink))) => { + @field(Task.Tag, @typeName(Symlink)) => { var any: *Symlink = task.get(Symlink).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Readlink))) => { + @field(Task.Tag, @typeName(Readlink)) => { var any: *Readlink = task.get(Readlink).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Realpath))) => { + @field(Task.Tag, @typeName(Realpath)) => { var any: *Realpath = task.get(Realpath).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(RealpathNonNative))) => { + @field(Task.Tag, @typeName(RealpathNonNative)) => { var any: *RealpathNonNative = task.get(RealpathNonNative).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Mkdir))) => { + @field(Task.Tag, @typeName(Mkdir)) => { var any: *Mkdir = task.get(Mkdir).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Fsync))) => { + @field(Task.Tag, @typeName(Fsync)) => { var any: *Fsync = task.get(Fsync).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Fdatasync))) => { + @field(Task.Tag, @typeName(Fdatasync)) => { var any: *Fdatasync = task.get(Fdatasync).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Access))) => { + @field(Task.Tag, @typeName(Access)) => { var any: *Access = task.get(Access).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(AppendFile))) => { + @field(Task.Tag, @typeName(AppendFile)) => { var any: *AppendFile = task.get(AppendFile).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Mkdtemp))) => { + @field(Task.Tag, @typeName(Mkdtemp)) => { var any: *Mkdtemp = task.get(Mkdtemp).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Exists))) => { + @field(Task.Tag, @typeName(Exists)) => { var any: *Exists = task.get(Exists).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Futimes))) => { + @field(Task.Tag, @typeName(Futimes)) => { var any: *Futimes = task.get(Futimes).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Lchmod))) => { + @field(Task.Tag, @typeName(Lchmod)) => { var any: *Lchmod = task.get(Lchmod).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Lchown))) => { + @field(Task.Tag, @typeName(Lchown)) => { var any: *Lchown = task.get(Lchown).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(Unlink))) => { + @field(Task.Tag, @typeName(Unlink)) => { var any: *Unlink = task.get(Unlink).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(NativeZlib))) => { + @field(Task.Tag, @typeName(NativeZlib)) => { var any: *NativeZlib = task.get(NativeZlib).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(NativeBrotli))) => { + @field(Task.Tag, @typeName(NativeBrotli)) => { var any: *NativeBrotli = task.get(NativeBrotli).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(ProcessWaiterThreadTask))) => { + @field(Task.Tag, @typeName(ProcessWaiterThreadTask)) => { bun.markPosixOnly(); var any: *ProcessWaiterThreadTask = task.get(ProcessWaiterThreadTask).?; any.runFromJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(RuntimeTranspilerStore))) => { + @field(Task.Tag, @typeName(RuntimeTranspilerStore)) => { var any: *RuntimeTranspilerStore = task.get(RuntimeTranspilerStore).?; any.drain(); }, - @field(Task.Tag, typeBaseName(@typeName(TimerObject))) => { + @field(Task.Tag, @typeName(TimerObject)) => { var any: *TimerObject = task.get(TimerObject).?; any.runImmediateTask(virtual_machine); }, - @field(Task.Tag, typeBaseName(@typeName(ServerAllConnectionsClosedTask))) => { + @field(Task.Tag, @typeName(ServerAllConnectionsClosedTask)) => { var any: *ServerAllConnectionsClosedTask = task.get(ServerAllConnectionsClosedTask).?; any.runFromJSThread(virtual_machine); }, - @field(Task.Tag, typeBaseName(@typeName(bun.bundle_v2.DeferredBatchTask))) => { + @field(Task.Tag, @typeName(bun.bundle_v2.DeferredBatchTask)) => { var any: *bun.bundle_v2.DeferredBatchTask = task.get(bun.bundle_v2.DeferredBatchTask).?; any.runOnJSThread(); }, - @field(Task.Tag, typeBaseName(@typeName(PosixSignalTask))) => { + @field(Task.Tag, @typeName(PosixSignalTask)) => { PosixSignalTask.runFromJSThread(@intCast(task.asUintptr()), global); }, - @field(Task.Tag, typeBaseName(@typeName(StatFS))) => { + @field(Task.Tag, @typeName(StatFS)) => { var any: *StatFS = task.get(StatFS).?; any.runFromJSThread(); }, - - @field(Task.Tag, typeBaseName(@typeName(FlushPendingFileSinkTask))) => { + @field(Task.Tag, @typeName(FlushPendingFileSinkTask)) => { var any: *FlushPendingFileSinkTask = task.get(FlushPendingFileSinkTask).?; any.runFromJSThread(); }, @@ -1691,7 +1684,7 @@ pub const EventLoop = struct { const task = Task.from(timer.as(*anyopaque)); defer timer.deinit(true); - JSC.VirtualMachine.get().enqueueTask(task); + VirtualMachine.get().enqueueTask(task); } pub fn ensureWaker(this: *EventLoop) void { @@ -1771,9 +1764,9 @@ pub const EventLoop = struct { }; pub const JsVM = struct { - vm: *JSC.VirtualMachine, + vm: *VirtualMachine, - pub inline fn init(inner: *JSC.VirtualMachine) JsVM { + pub inline fn init(inner: *VirtualMachine) JsVM { return .{ .vm = inner, }; @@ -1847,25 +1840,25 @@ pub const EventLoopKind = enum { pub fn refType(comptime this: EventLoopKind) type { return switch (this) { - .js => *JSC.VirtualMachine, + .js => *VirtualMachine, .mini => *JSC.MiniEventLoop, }; } pub fn getVm(comptime this: EventLoopKind) EventLoopKind.refType(this) { return switch (this) { - .js => JSC.VirtualMachine.get(), + .js => VirtualMachine.get(), .mini => JSC.MiniEventLoop.global, }; } }; pub fn AbstractVM(inner: anytype) switch (@TypeOf(inner)) { - *JSC.VirtualMachine => JsVM, + *VirtualMachine => JsVM, *JSC.MiniEventLoop => MiniVM, else => @compileError("Invalid event loop ctx: " ++ @typeName(@TypeOf(inner))), } { - if (comptime @TypeOf(inner) == *JSC.VirtualMachine) return JsVM.init(inner); + if (comptime @TypeOf(inner) == *VirtualMachine) return JsVM.init(inner); if (comptime @TypeOf(inner) == *JSC.MiniEventLoop) return MiniVM.init(inner); @compileError("Invalid event loop ctx: " ++ @typeName(@TypeOf(inner))); } @@ -1887,8 +1880,8 @@ pub const MiniEventLoop = struct { after_event_loop_callback_ctx: ?*anyopaque = null, after_event_loop_callback: ?JSC.OpaqueCallback = null, pipe_read_buffer: ?*PipeReadBuffer = null, - stdout_store: ?*JSC.WebCore.Blob.Store = null, - stderr_store: ?*JSC.WebCore.Blob.Store = null, + stdout_store: ?*bun.JSC.WebCore.Blob.Store = null, + stderr_store: ?*bun.JSC.WebCore.Blob.Store = null, const PipeReadBuffer = [256 * 1024]u8; pub threadlocal var globalInitialized: bool = false; @@ -2267,7 +2260,7 @@ pub const EventLoopHandle = union(enum) { }; } - pub fn bunVM(this: EventLoopHandle) ?*JSC.VirtualMachine { + pub fn bunVM(this: EventLoopHandle) ?*VirtualMachine { if (this == .js) { return this.js.virtual_machine; } @@ -2282,7 +2275,7 @@ pub const EventLoopHandle = union(enum) { }; } - pub fn cast(this: EventLoopHandle, comptime as: @Type(.EnumLiteral)) if (as == .js) *JSC.EventLoop else *MiniEventLoop { + pub fn cast(this: EventLoopHandle, comptime as: @Type(.enum_literal)) if (as == .js) *JSC.EventLoop else *MiniEventLoop { if (as == .js) { if (this != .js) @panic("Expected *JSC.EventLoop but got *MiniEventLoop"); return this.js; @@ -2313,7 +2306,7 @@ pub const EventLoopHandle = union(enum) { pub fn init(context: anytype) EventLoopHandle { const Context = @TypeOf(context); return switch (Context) { - *JSC.VirtualMachine => .{ .js = context.eventLoop() }, + *VirtualMachine => .{ .js = context.eventLoop() }, *JSC.EventLoop => .{ .js = context }, *JSC.MiniEventLoop => .{ .mini = context }, *AnyEventLoop => switch (context.*) { @@ -2374,7 +2367,7 @@ pub const EventLoopHandle = union(enum) { this.loop().unref(); } - pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]u8 { + pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]const u8 { return switch (this) { .js => this.js.virtual_machine.transpiler.env.map.createNullDelimitedEnvMap(alloc), .mini => this.mini.env.?.map.createNullDelimitedEnvMap(alloc), @@ -2407,7 +2400,7 @@ pub const EventLoopTask = union { js: ConcurrentTask, mini: JSC.AnyTaskWithExtraContext, - pub fn init(comptime kind: @TypeOf(.EnumLiteral)) EventLoopTask { + pub fn init(comptime kind: @TypeOf(.enum_literal)) EventLoopTask { switch (kind) { .js => return .{ .js = ConcurrentTask{} }, .mini => return .{ .mini = JSC.AnyTaskWithExtraContext{} }, @@ -2467,7 +2460,7 @@ pub const PosixSignalHandle = struct { // Publish the new tail (Release so that the consumer sees the updated tail). this.tail.store(old_tail +% 1, .release); - JSC.VirtualMachine.getMainThreadVM().?.eventLoop().wakeup(); + VirtualMachine.getMainThreadVM().?.eventLoop().wakeup(); return true; } @@ -2475,7 +2468,7 @@ pub const PosixSignalHandle = struct { /// This is the signal handler entry point. Calls enqueue on the ring buffer. /// Note: Must be minimal logic here. Only do atomics & signal‐safe calls. export fn Bun__onPosixSignal(number: i32) void { - const vm = JSC.VirtualMachine.getMainThreadVM().?; + const vm = VirtualMachine.getMainThreadVM().?; _ = vm.eventLoop().signal_handler.?.enqueue(@intCast(number)); } diff --git a/src/bun.js/ipc.zig b/src/bun.js/ipc.zig index 83e93bd1335848..456bf943362691 100644 --- a/src/bun.js/ipc.zig +++ b/src/bun.js/ipc.zig @@ -695,8 +695,8 @@ fn NewSocketIPCHandler(comptime Context: type) type { // In the VirtualMachine case, `globalThis` is an optional, in case // the vm is freed before the socket closes. const globalThis = switch (@typeInfo(@TypeOf(this.globalThis))) { - .Pointer => this.globalThis, - .Optional => brk: { + .pointer => this.globalThis, + .optional => brk: { if (this.globalThis) |global| { break :brk global; } @@ -842,8 +842,8 @@ fn NewNamedPipeIPCHandler(comptime Context: type) type { bun.assert(bun.isSliceInBuffer(buffer, ipc.incoming.allocatedSlice())); const globalThis = switch (@typeInfo(@TypeOf(this.globalThis))) { - .Pointer => this.globalThis, - .Optional => brk: { + .pointer => this.globalThis, + .optional => brk: { if (this.globalThis) |global| { break :brk global; } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index bf1f5bb8b4a5ed..3d9010143db9f2 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -12,7 +12,6 @@ const default_allocator = bun.default_allocator; const StoredFileDescriptorType = bun.StoredFileDescriptorType; const ErrorableString = bun.JSC.ErrorableString; const Arena = @import("../allocators/mimalloc_arena.zig").Arena; -const C = bun.C; const Exception = bun.JSC.Exception; const Allocator = std.mem.Allocator; @@ -41,14 +40,7 @@ const ImportRecord = ast.ImportRecord; const DotEnv = @import("../env_loader.zig"); const PackageJSON = @import("../resolver/package_json.zig").PackageJSON; const MacroRemap = @import("../resolver/package_json.zig").MacroMap; -const WebCore = bun.JSC.WebCore; -const Request = WebCore.Request; -const Response = WebCore.Response; -const Headers = WebCore.Headers; const String = bun.String; -const Fetch = WebCore.Fetch; -const FetchEvent = WebCore.FetchEvent; -const js = bun.JSC.C; const JSC = bun.JSC; const JSError = @import("./base.zig").JSError; const d = @import("./base.zig").d; @@ -66,18 +58,17 @@ const ZigException = bun.JSC.ZigException; const ZigStackTrace = bun.JSC.ZigStackTrace; const ErrorableResolvedSource = bun.JSC.ErrorableResolvedSource; const ResolvedSource = bun.JSC.ResolvedSource; -const JSPromise = bun.JSC.JSPromise; const JSInternalPromise = bun.JSC.JSInternalPromise; const JSModuleLoader = bun.JSC.JSModuleLoader; const JSPromiseRejectionOperation = bun.JSC.JSPromiseRejectionOperation; const ErrorableZigString = bun.JSC.ErrorableZigString; const ZigGlobalObject = bun.JSC.ZigGlobalObject; -const VM = bun.JSC.VM; +const VM = JSC.VM; const JSFunction = bun.JSC.JSFunction; const Config = @import("./config.zig"); const URL = @import("../url.zig").URL; const Bun = JSC.API.Bun; -const EventLoop = JSC.EventLoop; +const EventLoop = bun.JSC.EventLoop; const PendingResolution = @import("../resolver/resolver.zig").PendingResolution; const ThreadSafeFunction = JSC.napi.ThreadSafeFunction; const PackageManager = @import("../install/install.zig").PackageManager; @@ -93,8 +84,6 @@ const Task = JSC.Task; pub const Buffer = MarkedArrayBuffer; const Lock = bun.Mutex; -const BuildMessage = JSC.BuildMessage; -const ResolveMessage = JSC.ResolveMessage; const Async = bun.Async; const Ordinal = bun.Ordinal; @@ -321,13 +310,13 @@ pub const SavedSourceMap = struct { }; switch (Value.from(mapping.value_ptr.*).tag()) { - Value.Tag.ParsedSourceMap => { + @field(Value.Tag, @typeName(ParsedSourceMap)) => { defer this.unlock(); const map = Value.from(mapping.value_ptr.*).as(ParsedSourceMap); map.ref(); return .{ .map = map }; }, - Value.Tag.SavedMappings => { + @field(Value.Tag, @typeName(SavedMappings)) => { defer this.unlock(); var saved = SavedMappings{ .data = @as([*]u8, @ptrCast(Value.from(mapping.value_ptr.*).as(ParsedSourceMap))) }; defer saved.deinit(); @@ -340,7 +329,7 @@ pub const SavedSourceMap = struct { return .{ .map = result }; }, - Value.Tag.SourceProviderMap => { + @field(Value.Tag, @typeName(SourceProviderMap)) => { const ptr: *SourceProviderMap = Value.from(mapping.value_ptr.*).as(SourceProviderMap); this.unlock(); @@ -423,17 +412,17 @@ export fn Bun__readOriginTimerStart(vm: *JSC.VirtualMachine) f64 { return @as(f64, @floatCast((@as(f64, @floatFromInt(vm.origin_timestamp)) + JSC.VirtualMachine.origin_relative_epoch) / 1_000_000.0)); } -pub export fn Bun__GlobalObject__hasIPC(global: *JSC.JSGlobalObject) bool { +pub export fn Bun__GlobalObject__hasIPC(global: *JSGlobalObject) bool { return global.bunVM().ipc != null; } -extern fn Bun__Process__queueNextTick1(*JSC.ZigGlobalObject, JSC.JSValue, JSC.JSValue) void; +extern fn Bun__Process__queueNextTick1(*ZigGlobalObject, JSValue, JSValue) void; comptime { const Bun__Process__send = JSC.toJSHostFunction(Bun__Process__send_); - @export(Bun__Process__send, .{ .name = "Bun__Process__send" }); + @export(&Bun__Process__send, .{ .name = "Bun__Process__send" }); } -pub fn Bun__Process__send_(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue { +pub fn Bun__Process__send_(globalObject: *JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSValue { JSC.markBinding(@src()); var message, var handle, var options_, var callback = callFrame.argumentsAsArray(4); @@ -449,7 +438,7 @@ pub fn Bun__Process__send_(globalObject: *JSGlobalObject, callFrame: *JSC.CallFr } const S = struct { - fn impl(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { + fn impl(globalThis: *JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue { const arguments_ = callframe.arguments_old(1).slice(); const ex = arguments_[0]; VirtualMachine.Process__emitErrorEvent(globalThis, ex); @@ -458,13 +447,13 @@ pub fn Bun__Process__send_(globalObject: *JSGlobalObject, callFrame: *JSC.CallFr }; const vm = globalObject.bunVM(); - const zigGlobal: *JSC.ZigGlobalObject = @ptrCast(globalObject); + const zigGlobal: *ZigGlobalObject = @ptrCast(globalObject); const ipc_instance = vm.getIPCInstance() orelse { const ex = globalObject.ERR_IPC_CHANNEL_CLOSED("Channel closed.", .{}).toJS(); if (callback.isFunction()) { Bun__Process__queueNextTick1(zigGlobal, callback, ex); } else { - const fnvalue = JSC.JSFunction.create(globalObject, "", S.impl, 1, .{}); + const fnvalue = JSFunction.create(globalObject, "", S.impl, 1, .{}); Bun__Process__queueNextTick1(zigGlobal, fnvalue, ex); } return .false; @@ -489,7 +478,7 @@ pub fn Bun__Process__send_(globalObject: *JSGlobalObject, callFrame: *JSC.CallFr if (callback.isFunction()) { Bun__Process__queueNextTick1(zigGlobal, callback, ex); } else { - const fnvalue = JSC.JSFunction.create(globalObject, "", S.impl, 1, .{}); + const fnvalue = JSFunction.create(globalObject, "", S.impl, 1, .{}); Bun__Process__queueNextTick1(zigGlobal, fnvalue, ex); } } @@ -578,7 +567,7 @@ const WindowsOnly = struct { comptime { if (Environment.isWindows) { - @export(WindowsOnly.Bun__ZigGlobalObject__uvLoop, .{ .name = "Bun__ZigGlobalObject__uvLoop" }); + @export(&WindowsOnly.Bun__ZigGlobalObject__uvLoop, .{ .name = "Bun__ZigGlobalObject__uvLoop" }); } } @@ -593,8 +582,8 @@ pub const ExitHandler = struct { vm.exit_handler.exit_code = code; } - extern fn Process__dispatchOnBeforeExit(*JSC.JSGlobalObject, code: u8) void; - extern fn Process__dispatchOnExit(*JSC.JSGlobalObject, code: u8) void; + extern fn Process__dispatchOnBeforeExit(*JSGlobalObject, code: u8) void; + extern fn Process__dispatchOnExit(*JSGlobalObject, code: u8) void; extern fn Bun__closeAllSQLiteDatabasesForTermination() void; pub fn dispatchOnExit(this: *ExitHandler) void { @@ -779,7 +768,7 @@ pub const VirtualMachine = struct { main: string = "", main_resolved_path: bun.String = bun.String.empty, main_hash: u32 = 0, - process: js.JSObjectRef = null, + process: bun.JSC.C.JSObjectRef = null, entry_point: ServerEntryPoint = undefined, origin: URL = URL{}, node_fs: ?*Node.NodeFS = null, @@ -787,13 +776,13 @@ pub const VirtualMachine = struct { event_loop_handle: ?*PlatformEventLoop = null, pending_unref_counter: i32 = 0, preload: []const string = &[_][]const u8{}, - unhandled_pending_rejection_to_capture: ?*JSC.JSValue = null, + unhandled_pending_rejection_to_capture: ?*JSValue = null, standalone_module_graph: ?*bun.StandaloneModuleGraph = null, smol: bool = false, dns_result_order: DNSResolver.Order = .verbatim, hot_reload: bun.CLI.Command.HotReload = .none, - jsc: *JSC.VM = undefined, + jsc: *VM = undefined, /// hide bun:wrap from stack traces /// bun:wrap is very noisy @@ -873,7 +862,7 @@ pub const VirtualMachine = struct { rare_data: ?*JSC.RareData = null, is_us_loop_entered: bool = false, - pending_internal_promise: *JSC.JSInternalPromise = undefined, + pending_internal_promise: *JSInternalPromise = undefined, entry_point_result: struct { value: JSC.Strong = .{}, cjs_set_value: bool = false, @@ -907,7 +896,7 @@ pub const VirtualMachine = struct { is_inside_deferred_task_queue: bool = false, - pub const OnUnhandledRejection = fn (*VirtualMachine, globalObject: *JSC.JSGlobalObject, JSC.JSValue) void; + pub const OnUnhandledRejection = fn (*VirtualMachine, globalObject: *JSGlobalObject, JSValue) void; pub const OnException = fn (*ZigException) void; @@ -1102,11 +1091,11 @@ pub const VirtualMachine = struct { } }; - pub fn onQuietUnhandledRejectionHandler(this: *VirtualMachine, _: *JSC.JSGlobalObject, _: JSC.JSValue) void { + pub fn onQuietUnhandledRejectionHandler(this: *VirtualMachine, _: *JSGlobalObject, _: JSValue) void { this.unhandled_error_counter += 1; } - pub fn onQuietUnhandledRejectionHandlerCaptureValue(this: *VirtualMachine, _: *JSC.JSGlobalObject, value: JSC.JSValue) void { + pub fn onQuietUnhandledRejectionHandlerCaptureValue(this: *VirtualMachine, _: *JSGlobalObject, value: JSValue) void { this.unhandled_error_counter += 1; value.ensureStillAlive(); if (this.unhandled_pending_rejection_to_capture) |ptr| { @@ -1192,15 +1181,15 @@ pub const VirtualMachine = struct { } } - extern fn Bun__handleUncaughtException(*JSC.JSGlobalObject, err: JSC.JSValue, is_rejection: c_int) c_int; - extern fn Bun__handleUnhandledRejection(*JSC.JSGlobalObject, reason: JSC.JSValue, promise: JSC.JSValue) c_int; - extern fn Bun__Process__exit(*JSC.JSGlobalObject, code: c_int) noreturn; + extern fn Bun__handleUncaughtException(*JSGlobalObject, err: JSValue, is_rejection: c_int) c_int; + extern fn Bun__handleUnhandledRejection(*JSGlobalObject, reason: JSValue, promise: JSValue) c_int; + extern fn Bun__Process__exit(*JSGlobalObject, code: c_int) noreturn; export fn Bun__VirtualMachine__exitDuringUncaughtException(this: *JSC.VirtualMachine) void { this.exit_on_uncaught_exception = true; } - pub fn unhandledRejection(this: *JSC.VirtualMachine, globalObject: *JSC.JSGlobalObject, reason: JSC.JSValue, promise: JSC.JSValue) bool { + pub fn unhandledRejection(this: *JSC.VirtualMachine, globalObject: *JSGlobalObject, reason: JSValue, promise: JSValue) bool { if (this.isShuttingDown()) { Output.debugWarn("unhandledRejection during shutdown.", .{}); return true; @@ -1220,7 +1209,7 @@ pub const VirtualMachine = struct { return handled; } - pub fn uncaughtException(this: *JSC.VirtualMachine, globalObject: *JSC.JSGlobalObject, err: JSC.JSValue, is_rejection: bool) bool { + pub fn uncaughtException(this: *JSC.VirtualMachine, globalObject: *JSGlobalObject, err: JSValue, is_rejection: bool) bool { if (this.isShuttingDown()) { Output.debugWarn("uncaughtException during shutdown.", .{}); return true; @@ -1261,7 +1250,7 @@ pub const VirtualMachine = struct { } } - pub fn defaultOnUnhandledRejection(this: *JSC.VirtualMachine, _: *JSC.JSGlobalObject, value: JSC.JSValue) void { + pub fn defaultOnUnhandledRejection(this: *JSC.VirtualMachine, _: *JSGlobalObject, value: JSValue) void { this.runErrorHandler(value, this.onUnhandledRejectionExceptionList); } @@ -1270,7 +1259,7 @@ pub const VirtualMachine = struct { } pub fn garbageCollect(this: *const VirtualMachine, sync: bool) usize { - @setCold(true); + @branchHint(.cold); Global.mimalloc_cleanup(false); if (sync) return this.global.vm().runGC(true); @@ -1405,10 +1394,10 @@ pub const VirtualMachine = struct { } comptime { - @export(scriptExecutionStatus, .{ .name = "Bun__VM__scriptExecutionStatus" }); - @export(setEntryPointEvalResultESM, .{ .name = "Bun__VM__setEntryPointEvalResultESM" }); - @export(setEntryPointEvalResultCJS, .{ .name = "Bun__VM__setEntryPointEvalResultCJS" }); - @export(specifierIsEvalEntryPoint, .{ .name = "Bun__VM__specifierIsEvalEntryPoint" }); + @export(&scriptExecutionStatus, .{ .name = "Bun__VM__scriptExecutionStatus" }); + @export(&setEntryPointEvalResultESM, .{ .name = "Bun__VM__setEntryPointEvalResultESM" }); + @export(&setEntryPointEvalResultCJS, .{ .name = "Bun__VM__setEntryPointEvalResultCJS" }); + @export(&specifierIsEvalEntryPoint, .{ .name = "Bun__VM__specifierIsEvalEntryPoint" }); } pub fn onExit(this: *VirtualMachine) void { @@ -1516,7 +1505,7 @@ pub const VirtualMachine = struct { pub const Handle = opaque { extern "c" fn Bun__LifecycleAgentReportReload(agent: *Handle) void; - extern "c" fn Bun__LifecycleAgentReportError(agent: *Handle, exception: *JSC.ZigException) void; + extern "c" fn Bun__LifecycleAgentReportError(agent: *Handle, exception: *ZigException) void; extern "c" fn Bun__LifecycleAgentPreventExit(agent: *Handle) void; extern "c" fn Bun__LifecycleAgentStopPreventingExit(agent: *Handle) void; @@ -1533,7 +1522,7 @@ pub const VirtualMachine = struct { Bun__LifecycleAgentReportReload(this); } - pub fn reportError(this: *Handle, exception: *JSC.ZigException) void { + pub fn reportError(this: *Handle, exception: *ZigException) void { debug("reportError", .{}); Bun__LifecycleAgentReportError(this, exception); } @@ -1560,7 +1549,7 @@ pub const VirtualMachine = struct { } } - pub fn reportError(this: *LifecycleAgent, exception: *JSC.ZigException) void { + pub fn reportError(this: *LifecycleAgent, exception: *ZigException) void { if (this.handle) |handle| { handle.reportError(exception); } @@ -1595,9 +1584,9 @@ pub const VirtualMachine = struct { pub const log = Output.scoped(.debugger, false); - extern "C" fn Bun__createJSDebugger(*JSC.JSGlobalObject) u32; + extern "C" fn Bun__createJSDebugger(*JSGlobalObject) u32; extern "C" fn Bun__ensureDebugger(u32, bool) void; - extern "C" fn Bun__startJSDebuggerThread(*JSC.JSGlobalObject, u32, *bun.String, c_int, bool) void; + extern "C" fn Bun__startJSDebuggerThread(*JSGlobalObject, u32, *bun.String, c_int, bool) void; var futex_atomic: std.atomic.Value(u32) = undefined; pub fn waitForDebuggerIfNecessary(this: *VirtualMachine) void { @@ -1826,7 +1815,7 @@ pub const VirtualMachine = struct { this.eventLoop().waitForTasks(); } - pub const MacroMap = std.AutoArrayHashMap(i32, js.JSObjectRef); + pub const MacroMap = std.AutoArrayHashMap(i32, bun.JSC.C.JSObjectRef); pub fn enableMacroMode(this: *VirtualMachine) void { JSC.markBinding(@src()); @@ -1944,7 +1933,7 @@ pub const VirtualMachine = struct { vm.transpiler.resolver.onWakePackageManager = .{ .context = &vm.modules, .handler = ModuleLoader.AsyncModule.Queue.onWakeHandler, - .onDependencyError = JSC.ModuleLoader.AsyncModule.Queue.onDependencyError, + .onDependencyError = ModuleLoader.AsyncModule.Queue.onDependencyError, }; vm.transpiler.resolver.standalone_module_graph = opts.graph.?; @@ -2066,7 +2055,7 @@ pub const VirtualMachine = struct { vm.transpiler.resolver.onWakePackageManager = .{ .context = &vm.modules, .handler = ModuleLoader.AsyncModule.Queue.onWakeHandler, - .onDependencyError = JSC.ModuleLoader.AsyncModule.Queue.onDependencyError, + .onDependencyError = ModuleLoader.AsyncModule.Queue.onDependencyError, }; vm.transpiler.configureLinker(); @@ -2226,7 +2215,7 @@ pub const VirtualMachine = struct { vm.transpiler.resolver.onWakePackageManager = .{ .context = &vm.modules, .handler = ModuleLoader.AsyncModule.Queue.onWakeHandler, - .onDependencyError = JSC.ModuleLoader.AsyncModule.Queue.onDependencyError, + .onDependencyError = ModuleLoader.AsyncModule.Queue.onDependencyError, }; vm.transpiler.resolver.standalone_module_graph = opts.graph; @@ -2321,7 +2310,7 @@ pub const VirtualMachine = struct { vm.transpiler.resolver.onWakePackageManager = .{ .context = &vm.modules, .handler = ModuleLoader.AsyncModule.Queue.onWakeHandler, - .onDependencyError = JSC.ModuleLoader.AsyncModule.Queue.onDependencyError, + .onDependencyError = ModuleLoader.AsyncModule.Queue.onDependencyError, }; vm.transpiler.configureLinker(); @@ -2411,7 +2400,7 @@ pub const VirtualMachine = struct { pub fn fetchWithoutOnLoadPlugins( jsc_vm: *VirtualMachine, - globalObject: *JSC.JSGlobalObject, + globalObject: *JSGlobalObject, _specifier: String, referrer: String, log: *logger.Log, @@ -2728,7 +2717,7 @@ pub const VirtualMachine = struct { defer specifier_utf8.deinit(); const source_utf8 = source.toUTF8(bun.default_allocator); defer source_utf8.deinit(); - const printed = ResolveMessage.fmt( + const printed = JSC.ResolveMessage.fmt( bun.default_allocator, specifier_utf8.slice(), source_utf8.slice(), @@ -2741,7 +2730,7 @@ pub const VirtualMachine = struct { printed, ), }; - res.* = ErrorableString.err(error.NameTooLong, ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source_utf8.slice()).asVoid()); + res.* = ErrorableString.err(error.NameTooLong, JSC.ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source_utf8.slice()).asVoid()); return; } @@ -2809,7 +2798,7 @@ pub const VirtualMachine = struct { } } - const printed = ResolveMessage.fmt( + const printed = JSC.ResolveMessage.fmt( jsc_vm.allocator, specifier_utf8.slice(), source_utf8.slice(), @@ -2829,7 +2818,7 @@ pub const VirtualMachine = struct { }; { - res.* = ErrorableString.err(err, ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source_utf8.slice()).asVoid()); + res.* = ErrorableString.err(err, JSC.ResolveMessage.create(global, VirtualMachine.get().allocator, msg, source_utf8.slice()).asVoid()); } return; @@ -2867,7 +2856,7 @@ pub const VirtualMachine = struct { }; }; { - ret.* = ErrorableResolvedSource.err(err, BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid()); + ret.* = ErrorableResolvedSource.err(err, JSC.BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid()); } return; }, @@ -2875,8 +2864,8 @@ pub const VirtualMachine = struct { 1 => { const msg = log.msgs.items[0]; ret.* = ErrorableResolvedSource.err(err, switch (msg.metadata) { - .build => BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid(), - .resolve => ResolveMessage.create( + .build => JSC.BuildMessage.create(globalThis, globalThis.allocator(), msg).asVoid(), + .resolve => JSC.ResolveMessage.create( globalThis, globalThis.allocator(), msg, @@ -2894,8 +2883,8 @@ pub const VirtualMachine = struct { for (logs, errors) |msg, *current| { current.* = switch (msg.metadata) { - .build => BuildMessage.create(globalThis, globalThis.allocator(), msg), - .resolve => ResolveMessage.create( + .build => JSC.BuildMessage.create(globalThis, globalThis.allocator(), msg), + .resolve => JSC.ResolveMessage.create( globalThis, globalThis.allocator(), msg, @@ -2967,7 +2956,7 @@ pub const VirtualMachine = struct { } pub noinline fn runErrorHandler(this: *VirtualMachine, result: JSValue, exception_list: ?*ExceptionList) void { - @setCold(true); + @branchHint(.cold); if (!result.isEmptyOrUndefinedOrNull()) this.last_reported_error_for_dedupe = result; @@ -3007,7 +2996,7 @@ pub const VirtualMachine = struct { } } - export fn Bun__logUnhandledException(exception: JSC.JSValue) void { + export fn Bun__logUnhandledException(exception: JSValue) void { get().runErrorHandler(exception, null); } @@ -3125,20 +3114,20 @@ pub const VirtualMachine = struct { if (!this.transpiler.options.disable_transpilation) { if (try this.loadPreloads()) |promise| { - JSC.JSValue.fromCell(promise).ensureStillAlive(); - JSC.JSValue.fromCell(promise).protect(); + JSValue.fromCell(promise).ensureStillAlive(); + JSValue.fromCell(promise).protect(); this.pending_internal_promise = promise; return promise; } const promise = JSModuleLoader.loadAndEvaluateModule(this.global, &String.init(main_file_name)) orelse return error.JSError; this.pending_internal_promise = promise; - JSC.JSValue.fromCell(promise).ensureStillAlive(); + JSValue.fromCell(promise).ensureStillAlive(); return promise; } else { const promise = JSModuleLoader.loadAndEvaluateModule(this.global, &String.fromBytes(this.main)) orelse return error.JSError; this.pending_internal_promise = promise; - JSC.JSValue.fromCell(promise).ensureStillAlive(); + JSValue.fromCell(promise).ensureStillAlive(); return promise; } @@ -3155,9 +3144,9 @@ pub const VirtualMachine = struct { if (!this.transpiler.options.disable_transpilation) { if (try this.loadPreloads()) |promise| { - JSC.JSValue.fromCell(promise).ensureStillAlive(); + JSValue.fromCell(promise).ensureStillAlive(); this.pending_internal_promise = promise; - JSC.JSValue.fromCell(promise).protect(); + JSValue.fromCell(promise).protect(); return promise; } @@ -3165,7 +3154,7 @@ pub const VirtualMachine = struct { const promise = JSModuleLoader.loadAndEvaluateModule(this.global, &String.fromBytes(this.main)) orelse return error.JSError; this.pending_internal_promise = promise; - JSC.JSValue.fromCell(promise).ensureStillAlive(); + JSValue.fromCell(promise).ensureStillAlive(); return promise; } @@ -3393,7 +3382,7 @@ pub const VirtualMachine = struct { fn printErrorFromMaybePrivateData( this: *VirtualMachine, - value: JSC.JSValue, + value: JSValue, exception_list: ?*ExceptionList, formatter: *ConsoleObject.Formatter, comptime Writer: type, @@ -3462,7 +3451,7 @@ pub const VirtualMachine = struct { return false; } - pub fn reportUncaughtException(globalObject: *JSGlobalObject, exception: *JSC.Exception) JSValue { + pub fn reportUncaughtException(globalObject: *JSGlobalObject, exception: *Exception) JSValue { var jsc_vm = globalObject.bunVM(); _ = jsc_vm.uncaughtException(globalObject, exception.value(), false); return .undefined; @@ -3553,7 +3542,7 @@ pub const VirtualMachine = struct { } } - pub export fn Bun__remapStackFramePositions(globalObject: *JSC.JSGlobalObject, frames: [*]JSC.ZigStackFrame, frames_count: usize) void { + pub export fn Bun__remapStackFramePositions(globalObject: *JSGlobalObject, frames: [*]JSC.ZigStackFrame, frames_count: usize) void { globalObject.bunVM().remapStackFramePositions(frames, frames_count); } @@ -3764,11 +3753,11 @@ pub const VirtualMachine = struct { if (strings.getLinesInText( code.slice(), @intCast(last_line), - JSC.ZigException.Holder.source_lines_count, + ZigException.Holder.source_lines_count, )) |lines_buf| { var lines = lines_buf.slice(); - var source_lines = exception.stack.source_lines_ptr[0..JSC.ZigException.Holder.source_lines_count]; - var source_line_numbers = exception.stack.source_lines_numbers[0..JSC.ZigException.Holder.source_lines_count]; + var source_lines = exception.stack.source_lines_ptr[0..ZigException.Holder.source_lines_count]; + var source_line_numbers = exception.stack.source_lines_numbers[0..ZigException.Holder.source_lines_count]; @memset(source_lines, String.empty); @memset(source_line_numbers, 0); @@ -4007,7 +3996,7 @@ pub const VirtualMachine = struct { } // This is usually unsafe to do, but we are protecting them each time first - var errors_to_append = std.ArrayList(JSC.JSValue).init(this.allocator); + var errors_to_append = std.ArrayList(JSValue).init(this.allocator); defer { for (errors_to_append.items) |err| { err.unprotect(); @@ -4211,8 +4200,8 @@ pub const VirtualMachine = struct { // In Github Actions, emit an annotation that renders the error and location. // https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message - pub noinline fn printGithubAnnotation(exception: *JSC.ZigException) void { - @setCold(true); + pub noinline fn printGithubAnnotation(exception: *ZigException) void { + @branchHint(.cold); const name = exception.name; const message = exception.message; const frames = exception.stack.frames(); @@ -4437,7 +4426,7 @@ pub const VirtualMachine = struct { this.destroy(); } - extern fn Bun__setChannelRef(*JSC.JSGlobalObject, bool) void; + extern fn Bun__setChannelRef(*JSGlobalObject, bool) void; export fn Bun__closeChildIPC(global: *JSGlobalObject) void { if (global.bunVM().ipc) |*current_ipc| { @@ -4533,8 +4522,8 @@ pub const VirtualMachine = struct { } }; -pub const HotReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, false); -pub const WatchReloader = NewHotReloader(VirtualMachine, JSC.EventLoop, true); +pub const HotReloader = NewHotReloader(VirtualMachine, EventLoop, false); +pub const WatchReloader = NewHotReloader(VirtualMachine, EventLoop, true); extern fn BunDebugger__willHotReload() void; pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime reload_immediately: bool) type { @@ -4751,7 +4740,7 @@ pub fn NewHotReloader(comptime Ctx: type, comptime EventLoopType: type, comptime } else { return this.ctx.bun_watcher.hot; } - } else if (@typeInfo(@TypeOf(this.ctx.bun_watcher)) == .Optional) { + } else if (@typeInfo(@TypeOf(this.ctx.bun_watcher)) == .optional) { return this.ctx.bun_watcher.?; } else { return this.ctx.bun_watcher; @@ -4964,11 +4953,10 @@ pub var synthetic_allocation_limit: usize = std.math.maxInt(u32); pub var string_allocation_limit: usize = std.math.maxInt(u32); comptime { - @export(synthetic_allocation_limit, .{ .name = "Bun__syntheticAllocationLimit" }); - @export(string_allocation_limit, .{ .name = "Bun__stringSyntheticAllocationLimit" }); + @export(&string_allocation_limit, .{ .name = "Bun__stringSyntheticAllocationLimit" }); } -pub fn Bun__setSyntheticAllocationLimitForTesting(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue { +pub fn Bun__setSyntheticAllocationLimitForTesting(globalObject: *JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue { const args = callframe.arguments_old(1).slice(); if (args.len < 1) { return globalObject.throwNotEnoughArguments("setSyntheticAllocationLimitForTesting", 1, args.len); diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index f3f2f324cd4630..191b346f28bb12 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -39,12 +39,6 @@ const ImportRecord = ast.ImportRecord; const DotEnv = @import("../env_loader.zig"); const PackageJSON = @import("../resolver/package_json.zig").PackageJSON; const MacroRemap = @import("../resolver/package_json.zig").MacroMap; -const WebCore = bun.JSC.WebCore; -const Request = WebCore.Request; -const Response = WebCore.Response; -const Headers = WebCore.Headers; -const Fetch = WebCore.Fetch; -const FetchEvent = WebCore.FetchEvent; const js = bun.JSC.C; const JSC = bun.JSC; const JSError = @import("./base.zig").JSError; @@ -58,13 +52,10 @@ const JSGlobalObject = bun.JSC.JSGlobalObject; const ExceptionValueRef = bun.JSC.ExceptionValueRef; const JSPrivateDataPtr = bun.JSC.JSPrivateDataPtr; const ConsoleObject = bun.JSC.ConsoleObject; -const Node = bun.JSC.Node; const ZigException = bun.JSC.ZigException; const ZigStackTrace = bun.JSC.ZigStackTrace; -const ErrorableResolvedSource = bun.JSC.ErrorableResolvedSource; const ResolvedSource = bun.JSC.ResolvedSource; const JSPromise = bun.JSC.JSPromise; -const JSInternalPromise = bun.JSC.JSInternalPromise; const JSModuleLoader = bun.JSC.JSModuleLoader; const JSPromiseRejectionOperation = bun.JSC.JSPromiseRejectionOperation; const ErrorableZigString = bun.JSC.ErrorableZigString; @@ -79,7 +70,7 @@ const PendingResolution = @import("../resolver/resolver.zig").PendingResolution; const ThreadSafeFunction = JSC.napi.ThreadSafeFunction; const PackageManager = @import("../install/install.zig").PackageManager; const Install = @import("../install/install.zig"); -const VirtualMachine = JSC.VirtualMachine; +const VirtualMachine = bun.JSC.VirtualMachine; const Dependency = @import("../install/dependency.zig"); const Async = bun.Async; const String = bun.String; @@ -231,7 +222,7 @@ pub const RuntimeTranspilerStore = struct { } else { return; } - var vm: *JSC.VirtualMachine = @fieldParentPtr("transpiler_store", this); + var vm: *VirtualMachine = @fieldParentPtr("transpiler_store", this); const event_loop = vm.eventLoop(); const global = vm.global; const jsc_vm = vm.jsc; @@ -246,8 +237,8 @@ pub const RuntimeTranspilerStore = struct { pub fn transpile( this: *RuntimeTranspilerStore, - vm: *JSC.VirtualMachine, - globalObject: *JSC.JSGlobalObject, + vm: *VirtualMachine, + globalObject: *JSGlobalObject, input_specifier: bun.String, path: Fs.Path, referrer: bun.String, @@ -263,7 +254,7 @@ pub const RuntimeTranspilerStore = struct { .vm = vm, .log = logger.Log.init(bun.default_allocator), .loader = vm.transpiler.options.loader(owned_path.name.ext), - .promise = JSC.Strong.create(JSC.JSValue.fromCell(promise), globalObject), + .promise = JSC.Strong.create(JSValue.fromCell(promise), globalObject), .poll_ref = .{}, .fetcher = TranspilerJob.Fetcher{ .file = {}, @@ -281,8 +272,8 @@ pub const RuntimeTranspilerStore = struct { non_threadsafe_referrer: String, loader: options.Loader, promise: JSC.Strong = .{}, - vm: *JSC.VirtualMachine, - globalThis: *JSC.JSGlobalObject, + vm: *VirtualMachine, + globalThis: *JSGlobalObject, fetcher: Fetcher, poll_ref: Async.KeepAlive = .{}, generation_number: u32 = 0, @@ -713,7 +704,7 @@ pub const ModuleLoader = struct { } } - pub fn resolveEmbeddedFile(vm: *JSC.VirtualMachine, input_path: []const u8, extname: []const u8) ?[]const u8 { + pub fn resolveEmbeddedFile(vm: *VirtualMachine, input_path: []const u8, extname: []const u8) ?[]const u8 { if (input_path.len == 0) return null; var graph = vm.standalone_module_graph orelse return null; const file = graph.find(input_path) orelse return null; @@ -739,7 +730,7 @@ pub const ModuleLoader = struct { .{ .data = .{ - .encoded_slice = JSC.ZigString.Slice.fromUTF8NeverFree(file.contents), + .encoded_slice = ZigString.Slice.fromUTF8NeverFree(file.contents), }, .dirfd = bun.toFD(tmpdir.fd), .file = .{ @@ -769,7 +760,7 @@ pub const ModuleLoader = struct { package_json: ?*PackageJSON = null, loader: Api.Loader, hash: u32 = std.math.maxInt(u32), - globalThis: *JSC.JSGlobalObject = undefined, + globalThis: *JSGlobalObject = undefined, arena: *bun.ArenaAllocator, // This is the specific state for making it async @@ -805,7 +796,7 @@ pub const ModuleLoader = struct { pub const Map = std.ArrayListUnmanaged(AsyncModule); - pub fn enqueue(this: *Queue, globalObject: *JSC.JSGlobalObject, opts: anytype) void { + pub fn enqueue(this: *Queue, globalObject: *JSGlobalObject, opts: anytype) void { debug("enqueue: {s}", .{opts.specifier}); var module = AsyncModule.init(opts, globalObject) catch unreachable; module.poll_ref.ref(this.vm()); @@ -1063,7 +1054,7 @@ pub const ModuleLoader = struct { } }; - pub fn init(opts: anytype, globalObject: *JSC.JSGlobalObject) !AsyncModule { + pub fn init(opts: anytype, globalObject: *JSGlobalObject) !AsyncModule { var promise = JSC.Strong{}; // var stmt_blocks = js_ast.Stmt.Data.toOwnedSlice(); // var expr_blocks = js_ast.Expr.Data.toOwnedSlice(); @@ -1098,7 +1089,7 @@ pub const ModuleLoader = struct { }; } - pub fn done(this: *AsyncModule, jsc_vm: *JSC.VirtualMachine) void { + pub fn done(this: *AsyncModule, jsc_vm: *VirtualMachine) void { var clone = jsc_vm.allocator.create(AsyncModule) catch unreachable; clone.* = this.*; jsc_vm.modules.scheduled += 1; @@ -1115,11 +1106,11 @@ pub const ModuleLoader = struct { } var log = logger.Log.init(jsc_vm.allocator); defer log.deinit(); - var errorable: ErrorableResolvedSource = undefined; + var errorable: JSC.ErrorableResolvedSource = undefined; this.poll_ref.unref(jsc_vm); outer: { - errorable = ErrorableResolvedSource.ok(this.resumeLoadingModule(&log) catch |err| { - JSC.VirtualMachine.processFetchLog( + errorable = JSC.ErrorableResolvedSource.ok(this.resumeLoadingModule(&log) catch |err| { + VirtualMachine.processFetchLog( this.globalThis, bun.String.init(this.specifier), bun.String.init(this.referrer), @@ -1145,8 +1136,8 @@ pub const ModuleLoader = struct { } pub fn fulfill( - globalThis: *JSC.JSGlobalObject, - promise: JSC.JSValue, + globalThis: *JSGlobalObject, + promise: JSValue, resolved_source: ResolvedSource, err: ?anyerror, specifier_: bun.String, @@ -1161,9 +1152,9 @@ pub const ModuleLoader = struct { referrer.deref(); } - var errorable: ErrorableResolvedSource = undefined; + var errorable: JSC.ErrorableResolvedSource = undefined; if (err) |e| { - JSC.VirtualMachine.processFetchLog( + VirtualMachine.processFetchLog( globalThis, specifier, referrer, @@ -1172,7 +1163,7 @@ pub const ModuleLoader = struct { e, ); } else { - errorable = ErrorableResolvedSource.ok(resolved_source); + errorable = JSC.ErrorableResolvedSource.ok(resolved_source); } log.deinit(); @@ -1187,7 +1178,7 @@ pub const ModuleLoader = struct { ); } - pub fn resolveError(this: *AsyncModule, vm: *JSC.VirtualMachine, import_record_id: u32, result: PackageResolveError) !void { + pub fn resolveError(this: *AsyncModule, vm: *VirtualMachine, import_record_id: u32, result: PackageResolveError) !void { const globalThis = this.globalThis; const msg: []u8 = try switch (result.err) { @@ -1279,7 +1270,7 @@ pub const ModuleLoader = struct { this.deinit(); promise.rejectAsHandled(globalThis, error_instance); } - pub fn downloadError(this: *AsyncModule, vm: *JSC.VirtualMachine, import_record_id: u32, result: PackageDownloadError) !void { + pub fn downloadError(this: *AsyncModule, vm: *VirtualMachine, import_record_id: u32, result: PackageDownloadError) !void { const globalThis = this.globalThis; const msg_args = .{ @@ -1378,7 +1369,7 @@ pub const ModuleLoader = struct { debug("resumeLoadingModule: {s}", .{this.specifier}); var parse_result = this.parse_result; const path = this.path; - var jsc_vm = JSC.VirtualMachine.get(); + var jsc_vm = VirtualMachine.get(); const specifier = this.specifier; const old_log = jsc_vm.log; @@ -1469,15 +1460,15 @@ pub const ModuleLoader = struct { } extern "C" fn Bun__onFulfillAsyncModule( - globalObject: *JSC.JSGlobalObject, - promiseValue: JSC.JSValue, + globalObject: *JSGlobalObject, + promiseValue: JSValue, res: *JSC.ErrorableResolvedSource, specifier: *bun.String, referrer: *bun.String, ) void; }; - pub export fn Bun__getDefaultLoader(global: *JSC.JSGlobalObject, str: *const bun.String) Api.Loader { + pub export fn Bun__getDefaultLoader(global: *JSGlobalObject, str: *const bun.String) Api.Loader { var jsc_vm = global.bunVM(); const filename = str.toUTF8(jsc_vm.allocator); defer filename.deinit(); @@ -1500,7 +1491,7 @@ pub const ModuleLoader = struct { virtual_source: ?*const logger.Source, promise_ptr: ?*?*JSC.JSInternalPromise, source_code_printer: *js_printer.BufferPrinter, - globalObject: ?*JSC.JSGlobalObject, + globalObject: ?*JSGlobalObject, comptime flags: FetchFlags, ) !ResolvedSource { const disable_transpilying = comptime flags.disableTranspiling(); @@ -1764,7 +1755,7 @@ pub const ModuleLoader = struct { .specifier = input_specifier, .source_url = input_specifier.createIfDifferent(path.text), .hash = 0, - .jsvalue_for_export = JSC.JSValue.createEmptyObject(jsc_vm.global, 0), + .jsvalue_for_export = JSValue.createEmptyObject(jsc_vm.global, 0), .tag = .exports_object, }; } @@ -2007,10 +1998,10 @@ pub const ModuleLoader = struct { const encoded = JSC.EncodedJSValue{ .asPtr = globalThis, }; - const globalValue = @as(JSC.JSValue, @enumFromInt(encoded.asInt64)); + const globalValue = @as(JSValue, @enumFromInt(encoded.asInt64)); globalValue.put( globalThis, - JSC.ZigString.static("wasmSourceBytes"), + ZigString.static("wasmSourceBytes"), JSC.ArrayBuffer.create(globalThis, source.contents, .Uint8Array), ); } @@ -2225,10 +2216,10 @@ pub const ModuleLoader = struct { pub export fn Bun__fetchBuiltinModule( jsc_vm: *VirtualMachine, - globalObject: *JSC.JSGlobalObject, + globalObject: *JSGlobalObject, specifier: *bun.String, referrer: *bun.String, - ret: *ErrorableResolvedSource, + ret: *JSC.ErrorableResolvedSource, ) bool { JSC.markBinding(@src()); var log = logger.Log.init(jsc_vm.transpiler.allocator); @@ -2245,7 +2236,7 @@ pub const ModuleLoader = struct { VirtualMachine.processFetchLog(globalObject, specifier.*, referrer.*, &log, ret, err); return true; }) |builtin| { - ret.* = ErrorableResolvedSource.ok(builtin); + ret.* = JSC.ErrorableResolvedSource.ok(builtin); return true; } else { return false; @@ -2254,11 +2245,11 @@ pub const ModuleLoader = struct { pub export fn Bun__transpileFile( jsc_vm: *VirtualMachine, - globalObject: *JSC.JSGlobalObject, + globalObject: *JSGlobalObject, specifier_ptr: *bun.String, referrer: *bun.String, type_attribute: ?*const bun.String, - ret: *ErrorableResolvedSource, + ret: *JSC.ErrorableResolvedSource, allow_promise: bool, ) ?*anyopaque { JSC.markBinding(@src()); @@ -2326,7 +2317,7 @@ pub const ModuleLoader = struct { virtual_source = &virtual_source_to_use.?; } } else { - ret.* = ErrorableResolvedSource.err(error.JSErrorObject, globalObject.MODULE_NOT_FOUND("Blob not found", .{}).toJS().asVoid()); + ret.* = JSC.ErrorableResolvedSource.err(error.JSErrorObject, globalObject.MODULE_NOT_FOUND("Blob not found", .{}).toJS().asVoid()); return null; } } @@ -2409,7 +2400,7 @@ pub const ModuleLoader = struct { defer jsc_vm.module_loader.resetArena(jsc_vm); var promise: ?*JSC.JSInternalPromise = null; - ret.* = ErrorableResolvedSource.ok( + ret.* = JSC.ErrorableResolvedSource.ok( ModuleLoader.transpileSourceCode( jsc_vm, specifier, @@ -2440,7 +2431,7 @@ pub const ModuleLoader = struct { return promise; } - export fn Bun__runVirtualModule(globalObject: *JSC.JSGlobalObject, specifier_ptr: *const bun.String) JSValue { + export fn Bun__runVirtualModule(globalObject: *JSGlobalObject, specifier_ptr: *const bun.String) JSValue { JSC.markBinding(@src()); if (globalObject.bunVM().plugin_runner == null) return JSValue.zero; @@ -2627,12 +2618,12 @@ pub const ModuleLoader = struct { } export fn Bun__transpileVirtualModule( - globalObject: *JSC.JSGlobalObject, + globalObject: *JSGlobalObject, specifier_ptr: *const bun.String, referrer_ptr: *const bun.String, source_code: *ZigString, loader_: Api.Loader, - ret: *ErrorableResolvedSource, + ret: *JSC.ErrorableResolvedSource, ) bool { JSC.markBinding(@src()); const jsc_vm = globalObject.bunVM(); @@ -2664,7 +2655,7 @@ pub const ModuleLoader = struct { defer log.deinit(); defer jsc_vm.module_loader.resetArena(jsc_vm); - ret.* = ErrorableResolvedSource.ok( + ret.* = JSC.ErrorableResolvedSource.ok( ModuleLoader.transpileSourceCode( jsc_vm, specifier_slice.slice(), @@ -3104,7 +3095,7 @@ pub const HardcodedModule = enum { }; /// Support embedded .node files -export fn Bun__resolveEmbeddedNodeFile(vm: *JSC.VirtualMachine, in_out_str: *bun.String) bool { +export fn Bun__resolveEmbeddedNodeFile(vm: *VirtualMachine, in_out_str: *bun.String) bool { if (vm.standalone_module_graph == null) return false; const input_path = in_out_str.toUTF8(bun.default_allocator); diff --git a/src/bun.js/node/assert/myers_diff.zig b/src/bun.js/node/assert/myers_diff.zig index d6eb316c217182..4b51c63dd65c32 100644 --- a/src/bun.js/node/assert/myers_diff.zig +++ b/src/bun.js/node/assert/myers_diff.zig @@ -255,7 +255,7 @@ pub fn DifferWithEql(comptime Line: type, comptime opts: Options, comptime areLi try result.ensureUnusedCapacity(u(@max(x - prev_x, y - prev_y))); while (x > prev_x and y > prev_y) { const line: Line = blk: { - if (@typeInfo(Line) == .Pointer and comptime opts.check_comma_disparity) { + if (@typeInfo(Line) == .pointer and comptime opts.check_comma_disparity) { const actual_el = actual[u(x) - 1]; // actual[x-1].endsWith(',') break :blk if (actual_el[actual_el.len - 1] == ',') @@ -347,7 +347,7 @@ fn areStrLinesEqual(comptime T: type, a: T, b: T, comptime check_comma_disparity // []const u8 -> u8 const info = @typeInfo(T); - const ChildType = info.Pointer.child; + const ChildType = info.pointer.child; if (comptime !check_comma_disparity) { return mem.eql(ChildType, a, b); @@ -498,7 +498,7 @@ test StrDiffer { \\ 4, \\ 5, \\ 6, - \\ 7 + \\ 7 \\] , // expected @@ -509,7 +509,7 @@ test StrDiffer { \\ 4, \\ 5, \\ 9, - \\ 7 + \\ 7 \\] }, // // remove line diff --git a/src/bun.js/node/buffer.zig b/src/bun.js/node/buffer.zig index 970307825969d1..0bccfa0b9d02b8 100644 --- a/src/bun.js/node/buffer.zig +++ b/src/bun.js/node/buffer.zig @@ -82,5 +82,5 @@ pub const BufferVectorized = struct { }; comptime { - @export(BufferVectorized.fill, .{ .name = "Bun__Buffer_fill" }); + @export(&BufferVectorized.fill, .{ .name = "Bun__Buffer_fill" }); } diff --git a/src/bun.js/node/fs_events.zig b/src/bun.js/node/fs_events.zig index 9953527a6ebfb6..483da52d0ad732 100644 --- a/src/bun.js/node/fs_events.zig +++ b/src/bun.js/node/fs_events.zig @@ -79,13 +79,6 @@ pub const kFSEventStreamEventFlagRootChanged: c_int = 32; pub const kFSEventStreamEventFlagUnmount: c_int = 128; pub const kFSEventStreamEventFlagUserDropped: c_int = 2; -// Lazy function call binding. -const RTLD_LAZY = 0x1; -// Symbols exported from this image (dynamic library or bundle) -// are generally hidden and only availble to dlsym() when -// directly using the handle returned by this call to dlopen(). -const RTLD_LOCAL = 0x4; - pub const kFSEventsModified: c_int = kFSEventStreamEventFlagItemChangeOwner | kFSEventStreamEventFlagItemFinderInfoMod | @@ -191,7 +184,7 @@ var fsevents_cf: ?CoreFoundation = null; var fsevents_cs: ?CoreServices = null; fn InitLibrary() void { - const fsevents_cf_handle = bun.C.dlopen("/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation", RTLD_LAZY | RTLD_LOCAL); + const fsevents_cf_handle = bun.C.dlopen("/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation", .{ .LAZY = true, .LOCAL = true }); if (fsevents_cf_handle == null) @panic("Cannot Load CoreFoundation"); fsevents_cf = CoreFoundation{ @@ -210,7 +203,7 @@ fn InitLibrary() void { .RunLoopDefaultMode = dlsym(fsevents_cf_handle, *CFStringRef, "kCFRunLoopDefaultMode") orelse @panic("Cannot Load CoreFoundation"), }; - const fsevents_cs_handle = bun.C.dlopen("/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices", RTLD_LAZY | RTLD_LOCAL); + const fsevents_cs_handle = bun.C.dlopen("/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices", .{ .LAZY = true, .LOCAL = true }); if (fsevents_cs_handle == null) @panic("Cannot Load CoreServices"); fsevents_cs = CoreServices{ diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 31effabf8a0326..d2dd5eb6232bd6 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -43,10 +43,6 @@ const StringOrBuffer = JSC.Node.StringOrBuffer; const NodeFSFunctionEnum = std.meta.DeclEnum(JSC.Node.NodeFS); const UvFsCallback = fn (*uv.fs_t) callconv(.C) void; -const Stats = JSC.Node.Stats; -const Dirent = JSC.Node.Dirent; -const StatFS = JSC.Node.StatFS; - pub const default_permission = if (Environment.isPosix) Syscall.S.IRUSR | Syscall.S.IWUSR | @@ -1015,7 +1011,7 @@ pub const AsyncReaddirRecursiveTask = struct { pub const ResultListEntry = struct { pub const Value = union(Return.Readdir.Tag) { - with_file_types: std.ArrayList(Dirent), + with_file_types: std.ArrayList(bun.JSC.Node.Dirent), buffers: std.ArrayList(Buffer), files: std.ArrayList(bun.String), @@ -1096,7 +1092,7 @@ pub const AsyncReaddirRecursiveTask = struct { .root_path = PathString.init(bun.default_allocator.dupeZ(u8, args.path.slice()) catch bun.outOfMemory()), .result_list = switch (args.tag()) { .files => .{ .files = std.ArrayList(bun.String).init(bun.default_allocator) }, - .with_file_types => .{ .with_file_types = std.ArrayList(Dirent).init(bun.default_allocator) }, + .with_file_types => .{ .with_file_types = .init(bun.default_allocator) }, .buffers => .{ .buffers = std.ArrayList(Buffer).init(bun.default_allocator) }, }, }); @@ -1114,7 +1110,7 @@ pub const AsyncReaddirRecursiveTask = struct { inline else => |tag| { const ResultType = comptime switch (tag) { .files => bun.String, - .with_file_types => Dirent, + .with_file_types => bun.JSC.Node.Dirent, .buffers => Buffer, }; var stack = std.heap.stackFallback(8192, bun.default_allocator); @@ -1137,7 +1133,7 @@ pub const AsyncReaddirRecursiveTask = struct { for (entries.items) |*item| { switch (ResultType) { bun.String => item.deref(), - Dirent => item.deref(), + bun.JSC.Node.Dirent => item.deref(), Buffer => bun.default_allocator.free(item.buffer.byteSlice()), else => @compileError("unreachable"), } @@ -1174,7 +1170,7 @@ pub const AsyncReaddirRecursiveTask = struct { if (result.items.len > 0) { const Field = switch (ResultType) { bun.String => .files, - Dirent => .with_file_types, + bun.JSC.Node.Dirent => .with_file_types, Buffer => .buffers, else => @compileError("unreachable"), }; @@ -1604,7 +1600,7 @@ pub const Arguments = struct { }; fn wrapTo(T: type, in: i64) T { - comptime bun.assert(@typeInfo(T).Int.signedness == .unsigned); + comptime bun.assert(@typeInfo(T).int.signedness == .unsigned); return @intCast(@mod(in, std.math.maxInt(T))); } @@ -3066,16 +3062,16 @@ pub const Arguments = struct { }; errdefer dest.deinit(); - var mode: Mode = 0; + var mode: Constants.Copyfile = @enumFromInt(0); if (arguments.next()) |arg| { arguments.eat(); - mode = @intFromEnum(try FileSystemFlags.fromJSNumberOnly(ctx, arg, .copy_file)); + mode = @enumFromInt(@intFromEnum(try FileSystemFlags.fromJSNumberOnly(ctx, arg, .copy_file))); } return CopyFile{ .src = src, .dest = dest, - .mode = @enumFromInt(mode), + .mode = mode, }; } }; @@ -3187,7 +3183,7 @@ pub const Arguments = struct { }; pub const StatOrNotFound = union(enum) { - stats: Stats, + stats: bun.JSC.Node.Stats, not_found: void, pub fn toJS(this: *StatOrNotFound, globalObject: *JSC.JSGlobalObject) JSC.JSValue { @@ -3235,7 +3231,7 @@ const Return = struct { pub const Chmod = void; pub const Fchown = void; pub const Fdatasync = void; - pub const Fstat = Stats; + pub const Fstat = bun.JSC.Node.Stats; pub const Rm = void; pub const Fsync = void; pub const Ftruncate = void; @@ -3249,7 +3245,7 @@ const Return = struct { pub const Open = FDImpl; pub const WriteFile = void; pub const Readv = Read; - pub const StatFS = JSC.Node.StatFS; + pub const StatFS = bun.JSC.Node.StatFS; pub const Read = struct { bytes_read: u52, @@ -3315,7 +3311,7 @@ const Return = struct { } }; pub const Readdir = union(Tag) { - with_file_types: []Dirent, + with_file_types: []bun.JSC.Node.Dirent, buffers: []Buffer, files: []const bun.String, @@ -3357,7 +3353,7 @@ const Return = struct { pub const ReadFileWithOptions = union(enum) { string: string, transcoded_string: bun.String, - buffer: JSC.Node.Buffer, + buffer: Buffer, null_terminated: [:0]const u8, }; pub const Readlink = StringOrBuffer; @@ -3639,7 +3635,7 @@ pub const NodeFS = struct { // we fallback to copyfile() when the file is > 128 KB and clonefile fails // clonefile() isn't supported on all devices // nor is it supported across devices - var mode: Mode = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA; + var mode: u32 = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA; if (args.mode.shouldntOverwrite()) { mode |= C.darwin.COPYFILE_EXCL; } @@ -3670,7 +3666,7 @@ pub const NodeFS = struct { return Maybe(Return.CopyFile){ .err = .{ .errno = @intFromEnum(C.SystemErrno.ENOTSUP), .syscall = .copyfile } }; } - var flags: Mode = bun.O.CREAT | bun.O.WRONLY; + var flags: i32 = bun.O.CREAT | bun.O.WRONLY; var wrote: usize = 0; if (args.mode.shouldntOverwrite()) { flags |= bun.O.EXCL; @@ -3846,7 +3842,7 @@ pub const NodeFS = struct { pub fn fstat(_: *NodeFS, args: Arguments.Fstat, _: Flavor) Maybe(Return.Fstat) { return switch (Syscall.fstat(args.fd)) { - .result => |result| .{ .result = Stats.init(result, args.big_int) }, + .result => |result| .{ .result = .init(result, args.big_int) }, .err => |err| .{ .err = err }, }; } @@ -3917,13 +3913,13 @@ pub const NodeFS = struct { }; } - return Maybe(Return.Link).errnoSysPD(system.link(from, to, 0), .link, args.old_path.slice(), args.new_path.slice()) orelse + return Maybe(Return.Link).errnoSysPD(system.link(from, to), .link, args.old_path.slice(), args.new_path.slice()) orelse Maybe(Return.Link).success; } pub fn lstat(this: *NodeFS, args: Arguments.Lstat, _: Flavor) Maybe(Return.Lstat) { return switch (Syscall.lstat(args.path.sliceZ(&this.sync_error_buf))) { - .result => |result| Maybe(Return.Lstat){ .result = .{ .stats = Stats.init(result, args.big_int) } }, + .result => |result| Maybe(Return.Lstat){ .result = .{ .stats = .init(result, args.big_int) } }, .err => |err| brk: { if (!args.throw_if_no_entry and err.getErrno() == .NOENT) { return Maybe(Return.Lstat){ .result = .{ .not_found = {} } }; @@ -3994,7 +3990,7 @@ pub const NodeFS = struct { }; const Char = bun.OSPathChar; - const len = @as(u16, @truncate(path.len)); + const len: u16 = @truncate(path.len); // First, attempt to create the desired directory // If that fails, then walk back up the path until we have a match @@ -4443,7 +4439,7 @@ pub const NodeFS = struct { const maybe = switch (args.recursive) { inline else => |recursive| switch (args.tag()) { .buffers => readdirInner(&this.sync_error_buf, args, Buffer, recursive, flavor), - .with_file_types => readdirInner(&this.sync_error_buf, args, Dirent, recursive, flavor), + .with_file_types => readdirInner(&this.sync_error_buf, args, bun.JSC.Node.Dirent, recursive, flavor), .files => readdirInner(&this.sync_error_buf, args, bun.String, recursive, flavor), }, }; @@ -4465,7 +4461,7 @@ pub const NodeFS = struct { entries: *std.ArrayList(ExpectedType), ) Maybe(void) { const dir = fd.asDir(); - const is_u16 = comptime Environment.isWindows and (ExpectedType == bun.String or ExpectedType == Dirent); + const is_u16 = comptime Environment.isWindows and (ExpectedType == bun.String or ExpectedType == bun.JSC.Node.Dirent); var dirent_path: bun.String = bun.String.dead; defer { @@ -4486,7 +4482,7 @@ pub const NodeFS = struct { .err => |err| { for (entries.items) |*item| { switch (ExpectedType) { - Dirent => { + bun.JSC.Node.Dirent => { item.deref(); }, Buffer => { @@ -4507,7 +4503,7 @@ pub const NodeFS = struct { }, .result => |ent| ent, }) |current| : (entry = iterator.next()) { - if (ExpectedType == Dirent) { + if (ExpectedType == JSC.Node.Dirent) { if (dirent_path.isEmpty()) { dirent_path = JSC.WebCore.Encoder.toBunString(strings.withoutNTPrefix(std.meta.Child(@TypeOf(basename)), basename), args.encoding); } @@ -4515,7 +4511,7 @@ pub const NodeFS = struct { if (comptime !is_u16) { const utf8_name = current.name.slice(); switch (ExpectedType) { - Dirent => { + JSC.Node.Dirent => { dirent_path.ref(); entries.append(.{ .name = JSC.WebCore.Encoder.toBunString(utf8_name, args.encoding), @@ -4534,7 +4530,7 @@ pub const NodeFS = struct { } else { const utf16_name = current.name.slice(); switch (ExpectedType) { - Dirent => { + JSC.Node.Dirent => { dirent_path.ref(); entries.append(.{ .name = bun.String.createUTF16(utf16_name), @@ -4669,7 +4665,7 @@ pub const NodeFS = struct { } switch (comptime ExpectedType) { - Dirent => { + bun.JSC.Node.Dirent => { const path_u8 = bun.path.dirname(bun.path.join(&[_]string{ root_basename, name_to_copy }, .auto), .auto); if (dirent_path_prev.isEmpty() or !bun.strings.eql(dirent_path_prev.byteSlice(), path_u8)) { dirent_path_prev.deref(); @@ -4809,7 +4805,7 @@ pub const NodeFS = struct { } switch (comptime ExpectedType) { - Dirent => { + bun.JSC.Node.Dirent => { const path_u8 = bun.path.dirname(bun.path.join(&[_]string{ root_basename, name_to_copy }, .auto), .auto); if (dirent_path_prev.isEmpty() or !bun.strings.eql(dirent_path_prev.byteSlice(), path_u8)) { dirent_path_prev.deref(); @@ -4867,7 +4863,7 @@ pub const NodeFS = struct { comptime flavor: Flavor, ) Maybe(Return.Readdir) { const file_type = switch (ExpectedType) { - Dirent => "with_file_types", + bun.JSC.Node.Dirent => "with_file_types", bun.String => "files", Buffer => "buffers", else => @compileError("unreachable"), @@ -4883,7 +4879,7 @@ pub const NodeFS = struct { .err => |err| { for (entries.items) |*result| { switch (ExpectedType) { - Dirent => { + bun.JSC.Node.Dirent => { result.name.deref(); }, Buffer => { @@ -5383,7 +5379,7 @@ pub const NodeFS = struct { // If this errors, we silently ignore it. // Not all files are seekable (and thus, not all files can be truncated). if (Environment.isWindows) { - _ = std.os.windows.kernel32.SetEndOfFile(fd.cast()); + _ = bun.windows.SetEndOfFile(fd.cast()); } else { _ = Syscall.ftruncate(fd, @intCast(@as(u63, @truncate(written)))); } @@ -5754,7 +5750,7 @@ pub const NodeFS = struct { const path = args.path.sliceZ(&this.sync_error_buf); return switch (Syscall.stat(path)) { .result => |result| .{ - .result = .{ .stats = Stats.init(result, args.big_int) }, + .result = .{ .stats = .init(result, args.big_int) }, }, .err => |err| brk: { if (!args.throw_if_no_entry and err.getErrno() == .NOENT) { @@ -5941,8 +5937,8 @@ pub const NodeFS = struct { Maybe(Return.Utimes).success; } - bun.assert(args.mtime.tv_nsec <= 1e9); - bun.assert(args.atime.tv_nsec <= 1e9); + bun.assert(args.mtime.nsec <= 1e9); + bun.assert(args.atime.nsec <= 1e9); return switch (Syscall.utimens( args.path.sliceZ(&this.sync_error_buf), @@ -5976,8 +5972,8 @@ pub const NodeFS = struct { Maybe(Return.Utimes).success; } - bun.assert(args.mtime.tv_nsec <= 1e9); - bun.assert(args.atime.tv_nsec <= 1e9); + bun.assert(args.mtime.nsec <= 1e9); + bun.assert(args.atime.nsec <= 1e9); return switch (Syscall.lutimes(args.path.sliceZ(&this.sync_error_buf), args.atime, args.mtime)) { .err => |err| .{ .err = err.withPath(args.path.slice()) }, @@ -6254,7 +6250,7 @@ pub const NodeFS = struct { if (!posix.S.ISREG(stat_.mode)) { if (posix.S.ISLNK(stat_.mode)) { - var mode_: Mode = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA | C.darwin.COPYFILE_NOFOLLOW_SRC; + var mode_: u32 = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA | C.darwin.COPYFILE_NOFOLLOW_SRC; if (mode.shouldntOverwrite()) { mode_ |= C.darwin.COPYFILE_EXCL; } @@ -6341,7 +6337,7 @@ pub const NodeFS = struct { // we fallback to copyfile() when the file is > 128 KB and clonefile fails // clonefile() isn't supported on all devices // nor is it supported across devices - var mode_: Mode = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA | C.darwin.COPYFILE_NOFOLLOW_SRC; + var mode_: u32 = C.darwin.COPYFILE_ACL | C.darwin.COPYFILE_DATA | C.darwin.COPYFILE_NOFOLLOW_SRC; if (mode.shouldntOverwrite()) { mode_ |= C.darwin.COPYFILE_EXCL; } @@ -6388,7 +6384,7 @@ pub const NodeFS = struct { } }; } - var flags: Mode = bun.O.CREAT | bun.O.WRONLY; + var flags: i32 = bun.O.CREAT | bun.O.WRONLY; var wrote: usize = 0; if (mode.shouldntOverwrite()) { flags |= bun.O.EXCL; @@ -6850,7 +6846,7 @@ fn zigDeleteTreeMinStackSizeWithKindHint(self: std.fs.Dir, sub_path: []const u8, // Valid use of MAX_PATH_BYTES because dir_name_buf will only // ever store a single path component that was returned from the // filesystem. - var dir_name_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + var dir_name_buf: [std.fs.max_path_bytes]u8 = undefined; var dir_name: []const u8 = sub_path; // Here we must avoid recursion, in order to provide O(1) memory guarantee of this function. diff --git a/src/bun.js/node/node_fs_binding.zig b/src/bun.js/node/node_fs_binding.zig index e5787b7ed4c233..feb633c2e0eacf 100644 --- a/src/bun.js/node/node_fs_binding.zig +++ b/src/bun.js/node/node_fs_binding.zig @@ -18,7 +18,7 @@ const NodeFSFunctionEnum = std.meta.DeclEnum(JSC.Node.NodeFS); /// Async calls use a thread pool. fn Bindings(comptime function_name: NodeFSFunctionEnum) type { const function = @field(JSC.Node.NodeFS, @tagName(function_name)); - const fn_info = @typeInfo(@TypeOf(function)).Fn; + const fn_info = @typeInfo(@TypeOf(function)).@"fn"; if (fn_info.params.len != 3) { @compileError("Expected fn(NodeFS, Arguments) Return for NodeFS." ++ @tagName(function_name)); } diff --git a/src/bun.js/node/node_fs_stat_watcher.zig b/src/bun.js/node/node_fs_stat_watcher.zig index 7579b5f7a6221d..5fac2538b4d81c 100644 --- a/src/bun.js/node/node_fs_stat_watcher.zig +++ b/src/bun.js/node/node_fs_stat_watcher.zig @@ -307,8 +307,6 @@ pub const StatWatcher = struct { } pub fn hasPendingActivity(this: *StatWatcher) bool { - @fence(.acquire); - return this.used_by_scheduler_thread.load(.acquire); } diff --git a/src/bun.js/node/node_fs_watcher.zig b/src/bun.js/node/node_fs_watcher.zig index bd511c0e92bf8c..55c2af8c892853 100644 --- a/src/bun.js/node/node_fs_watcher.zig +++ b/src/bun.js/node/node_fs_watcher.zig @@ -572,7 +572,6 @@ pub const FSWatcher = struct { // this can be called from Watcher Thread or JS Context Thread pub fn refTask(this: *FSWatcher) bool { - @fence(.acquire); this.mutex.lock(); defer this.mutex.unlock(); if (this.closed) return false; @@ -582,7 +581,6 @@ pub const FSWatcher = struct { } pub fn hasPendingActivity(this: *FSWatcher) bool { - @fence(.acquire); return this.pending_activity_count.load(.acquire) > 0; } diff --git a/src/bun.js/node/node_os.zig b/src/bun.js/node/node_os.zig index fc60648fee1385..ee4eaf3aa9f637 100644 --- a/src/bun.js/node/node_os.zig +++ b/src/bun.js/node/node_os.zig @@ -88,7 +88,7 @@ fn cpusImplLinux(globalThis: *JSC.JSGlobalObject) !JSC.JSValue { // Read each CPU line while (line_iter.next()) |line| { // CPU lines are formatted as `cpu0 user nice sys idle iowait irq softirq` - var toks = std.mem.tokenize(u8, line, " \t"); + var toks = std.mem.tokenizeAny(u8, line, " \t"); const cpu_name = toks.next(); if (cpu_name == null or !std.mem.startsWith(u8, cpu_name.?, "cpu")) break; // done with CPUs diff --git a/src/bun.js/node/node_zlib_binding.zig b/src/bun.js/node/node_zlib_binding.zig index cd233554c775b3..ceb1a605f3ecb1 100644 --- a/src/bun.js/node/node_zlib_binding.zig +++ b/src/bun.js/node/node_zlib_binding.zig @@ -310,7 +310,7 @@ const CountedKeepAlive = struct { }; pub const SNativeZlib = struct { - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub usingnamespace JSC.Codegen.JSNativeZlib; pub usingnamespace CompressionStream(@This()); @@ -676,7 +676,7 @@ const ZlibContext = struct { pub const NativeBrotli = JSC.Codegen.JSNativeBrotli.getConstructor; pub const SNativeBrotli = struct { - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub usingnamespace JSC.Codegen.JSNativeBrotli; pub usingnamespace CompressionStream(@This()); diff --git a/src/bun.js/node/path.zig b/src/bun.js/node/path.zig index b2635e55018f4b..d12b1e74ce1bf2 100644 --- a/src/bun.js/node/path.zig +++ b/src/bun.js/node/path.zig @@ -2976,17 +2976,17 @@ pub fn toNamespacedPath(globalObject: *JSC.JSGlobalObject, isWindows: bool, args pub const Extern = [_][]const u8{"create"}; comptime { - @export(Path.basename, .{ .name = "Bun__Path__basename" }); - @export(Path.dirname, .{ .name = "Bun__Path__dirname" }); - @export(Path.extname, .{ .name = "Bun__Path__extname" }); - @export(path_format, .{ .name = "Bun__Path__format" }); - @export(Path.isAbsolute, .{ .name = "Bun__Path__isAbsolute" }); - @export(Path.join, .{ .name = "Bun__Path__join" }); - @export(Path.normalize, .{ .name = "Bun__Path__normalize" }); - @export(Path.parse, .{ .name = "Bun__Path__parse" }); - @export(Path.relative, .{ .name = "Bun__Path__relative" }); - @export(Path.resolve, .{ .name = "Bun__Path__resolve" }); - @export(Path.toNamespacedPath, .{ .name = "Bun__Path__toNamespacedPath" }); + @export(&Path.basename, .{ .name = "Bun__Path__basename" }); + @export(&Path.dirname, .{ .name = "Bun__Path__dirname" }); + @export(&Path.extname, .{ .name = "Bun__Path__extname" }); + @export(&path_format, .{ .name = "Bun__Path__format" }); + @export(&Path.isAbsolute, .{ .name = "Bun__Path__isAbsolute" }); + @export(&Path.join, .{ .name = "Bun__Path__join" }); + @export(&Path.normalize, .{ .name = "Bun__Path__normalize" }); + @export(&Path.parse, .{ .name = "Bun__Path__parse" }); + @export(&Path.relative, .{ .name = "Bun__Path__relative" }); + @export(&Path.resolve, .{ .name = "Bun__Path__resolve" }); + @export(&Path.toNamespacedPath, .{ .name = "Bun__Path__toNamespacedPath" }); } fn path_format(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue { diff --git a/src/bun.js/node/path_watcher.zig b/src/bun.js/node/path_watcher.zig index 71cfd3c631e3d7..9e647386c3350b 100644 --- a/src/bun.js/node/path_watcher.zig +++ b/src/bun.js/node/path_watcher.zig @@ -51,7 +51,6 @@ pub const PathWatcherManager = struct { }; fn refPendingTask(this: *PathWatcherManager) bool { - @fence(.release); this.mutex.lock(); defer this.mutex.unlock(); if (this.deinit_on_last_task) return false; @@ -61,12 +60,10 @@ pub const PathWatcherManager = struct { } fn hasPendingTasks(this: *PathWatcherManager) callconv(.C) bool { - @fence(.acquire); return this.has_pending_tasks.load(.acquire); } fn unrefPendingTask(this: *PathWatcherManager) void { - @fence(.release); this.mutex.lock(); defer this.mutex.unlock(); this.pending_tasks -= 1; @@ -830,7 +827,6 @@ pub const PathWatcher = struct { } pub fn refPendingDirectory(this: *PathWatcher) bool { - @fence(.release); this.mutex.lock(); defer this.mutex.unlock(); if (this.isClosed()) return false; @@ -840,24 +836,20 @@ pub const PathWatcher = struct { } pub fn hasPendingDirectories(this: *PathWatcher) callconv(.C) bool { - @fence(.acquire); return this.has_pending_directories.load(.acquire); } pub fn isClosed(this: *PathWatcher) bool { - @fence(.acquire); return this.closed.load(.acquire); } pub fn setClosed(this: *PathWatcher) void { this.mutex.lock(); defer this.mutex.unlock(); - @fence(.release); this.closed.store(true, .release); } pub fn unrefPendingDirectory(this: *PathWatcher) void { - @fence(.release); this.mutex.lock(); defer this.mutex.unlock(); this.pending_directories -= 1; diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig index 5939857dee191c..a065cf635f1842 100644 --- a/src/bun.js/node/types.zig +++ b/src/bun.js/node/types.zig @@ -199,9 +199,9 @@ pub fn Maybe(comptime ReturnTypeT: type, comptime ErrorTypeT: type) type { []u8 => JSC.ArrayBuffer.fromBytes(r, .ArrayBuffer).toJS(globalObject, null), else => switch (@typeInfo(ReturnType)) { - .Int, .Float, .ComptimeInt, .ComptimeFloat => JSC.JSValue.jsNumber(r), - .Struct, .Enum, .Opaque, .Union => r.toJS(globalObject), - .Pointer => { + .int, .float, .comptime_int, .comptime_float => JSC.JSValue.jsNumber(r), + .@"struct", .@"enum", .@"opaque", .@"union" => r.toJS(globalObject), + .pointer => { if (bun.trait.isZigString(ReturnType)) JSC.ZigString.init(bun.asByteSlice(r)).withEncoding().toJS(globalObject); @@ -1285,8 +1285,8 @@ fn timeLikeFromSeconds(seconds: f64) TimeLike { return seconds; } return .{ - .tv_sec = @intFromFloat(seconds), - .tv_nsec = @intFromFloat(@mod(seconds, 1) * std.time.ns_per_s), + .sec = @intFromFloat(seconds), + .nsec = @intFromFloat(@mod(seconds, 1) * std.time.ns_per_s), }; } @@ -1304,8 +1304,8 @@ fn timeLikeFromMilliseconds(milliseconds: f64) TimeLike { } return .{ - .tv_sec = @intFromFloat(sec), - .tv_nsec = @intFromFloat(nsec), + .sec = @intFromFloat(sec), + .nsec = @intFromFloat(nsec), }; } @@ -1335,15 +1335,15 @@ fn timeLikeFromNow() TimeLike { // ownership or permission checks are performed, and the file // timestamps are not modified, but other error conditions may still return .{ - .tv_sec = 0, - .tv_nsec = if (Environment.isLinux) std.os.linux.UTIME.NOW else bun.C.translated.UTIME_NOW, + .sec = 0, + .nsec = if (Environment.isLinux) std.os.linux.UTIME.NOW else bun.C.translated.UTIME_NOW, }; } pub fn modeFromJS(ctx: JSC.C.JSContextRef, value: JSC.JSValue) bun.JSError!?Mode { const mode_int = if (value.isNumber()) brk: { const m = try validators.validateUint32(ctx, value, "mode", .{}, false); - break :brk @as(Mode, @as(u24, @truncate(m))); + break :brk @as(Mode, @truncate(m)); } else brk: { if (value.isUndefinedOrNull()) return null; @@ -1438,8 +1438,8 @@ pub const PathOrFileDescriptor = union(Tag) { } }; -pub const FileSystemFlags = enum(if (Environment.isWindows) c_int else c_uint) { - pub const tag_type = @typeInfo(FileSystemFlags).Enum.tag_type; +pub const FileSystemFlags = enum(c_int) { + pub const tag_type = @typeInfo(FileSystemFlags).@"enum".tag_type; const O = bun.O; /// Open file for appending. The file is created if it does not exist. @@ -1473,7 +1473,7 @@ pub const FileSystemFlags = enum(if (Environment.isWindows) c_int else c_uint) { _, - const map = bun.ComptimeStringMap(Mode, .{ + const map = bun.ComptimeStringMap(i32, .{ .{ "r", O.RDONLY }, .{ "rs", O.RDONLY | O.SYNC }, .{ "sr", O.RDONLY | O.SYNC }, @@ -1549,7 +1549,7 @@ pub const FileSystemFlags = enum(if (Environment.isWindows) c_int else c_uint) { return ctx.throwInvalidArguments("Invalid flag '{any}'. Learn more at https://nodejs.org/api/fs.html#fs_file_system_flags", .{str}); } - const flags = brk: { + const flags: i32 = brk: { switch (str.is16Bit()) { inline else => |is_16bit| { const chars = if (is_16bit) str.utf16SliceAligned() else str.slice(); @@ -1560,20 +1560,20 @@ pub const FileSystemFlags = enum(if (Environment.isWindows) c_int else c_uint) { const slice = str.toSlice(bun.default_allocator); defer slice.deinit(); - break :brk std.fmt.parseInt(Mode, slice.slice(), 10) catch null; + break :brk @as(i32, @intCast(std.fmt.parseInt(Mode, slice.slice(), 10) catch break :brk null)); } else { - break :brk std.fmt.parseInt(Mode, chars, 10) catch null; + break :brk @as(i32, @intCast(std.fmt.parseInt(Mode, chars, 10) catch break :brk null)); } } }, } - break :brk map.getWithEql(str, JSC.ZigString.eqlComptime); + break :brk map.getWithEql(str, JSC.ZigString.eqlComptime) orelse break :brk null; } orelse { return ctx.throwInvalidArguments("Invalid flag '{any}'. Learn more at https://nodejs.org/api/fs.html#fs_file_system_flags", .{str}); }; - return @as(FileSystemFlags, @enumFromInt(@as(Mode, @intCast(flags)))); + return @enumFromInt(flags); } return null; @@ -1622,16 +1622,16 @@ pub fn StatType(comptime big: bool) type { const Float = if (big) i64 else f64; inline fn toNanoseconds(ts: StatTimespec) u64 { - if (ts.tv_sec < 0) { + if (ts.sec < 0) { return @intCast(@max(bun.timespec.nsSigned(&bun.timespec{ - .sec = @intCast(ts.tv_sec), - .nsec = @intCast(ts.tv_nsec), + .sec = @intCast(ts.sec), + .nsec = @intCast(ts.nsec), }), 0)); } return bun.timespec.ns(&bun.timespec{ - .sec = @intCast(ts.tv_sec), - .nsec = @intCast(ts.tv_nsec), + .sec = @intCast(ts.sec), + .nsec = @intCast(ts.nsec), }); } @@ -1641,8 +1641,8 @@ pub fn StatType(comptime big: bool) type { // > libuv calculates tv_sec and tv_nsec from it and converts to signed long, // > which causes Y2038 overflow. On the other platforms it is safe to treat // > negative values as pre-epoch time. - const tv_sec = if (Environment.isWindows) @as(u32, @bitCast(ts.tv_sec)) else ts.tv_sec; - const tv_nsec = if (Environment.isWindows) @as(u32, @bitCast(ts.tv_nsec)) else ts.tv_nsec; + const tv_sec = if (Environment.isWindows) @as(u32, @bitCast(ts.sec)) else ts.sec; + const tv_nsec = if (Environment.isWindows) @as(u32, @bitCast(ts.nsec)) else ts.nsec; if (big) { const sec: i64 = tv_sec; const nsec: i64 = tv_nsec; @@ -2132,7 +2132,7 @@ pub const Process = struct { comptime { if (Environment.export_cpp_apis and Environment.isWindows) { - @export(Bun__Process__editWindowsEnvVar, .{ .name = "Bun__Process__editWindowsEnvVar" }); + @export(&Bun__Process__editWindowsEnvVar, .{ .name = "Bun__Process__editWindowsEnvVar" }); } } @@ -2194,13 +2194,13 @@ pub fn StatFSType(comptime big: bool) type { pub usingnamespace bun.New(@This()); // Common fields between Linux and macOS - fstype: Int, - bsize: Int, - blocks: Int, - bfree: Int, - bavail: Int, - files: Int, - ffree: Int, + _fstype: Int, + _bsize: Int, + _blocks: Int, + _bfree: Int, + _bavail: Int, + _files: Int, + _ffree: Int, const This = @This(); @@ -2211,7 +2211,7 @@ pub fn StatFSType(comptime big: bool) type { pub fn callback(this: *This, globalObject: *JSC.JSGlobalObject) JSC.JSValue { const value = @field(this, @tagName(field)); const Type = @TypeOf(value); - if (comptime big and @typeInfo(Type) == .Int) { + if (comptime big and @typeInfo(Type) == .int) { return JSC.JSValue.fromInt64NoTruncate(globalObject, value); } @@ -2224,13 +2224,13 @@ pub fn StatFSType(comptime big: bool) type { }.callback; } - pub const fstype = getter(.fstype); - pub const bsize = getter(.bsize); - pub const blocks = getter(.blocks); - pub const bfree = getter(.bfree); - pub const bavail = getter(.bavail); - pub const files = getter(.files); - pub const ffree = getter(.ffree); + pub const fstype = getter(._fstype); + pub const bsize = getter(._bsize); + pub const blocks = getter(._blocks); + pub const bfree = getter(._bfree); + pub const bavail = getter(._bavail); + pub const files = getter(._files); + pub const ffree = getter(._ffree); pub fn finalize(this: *This) void { this.destroy(); @@ -2259,13 +2259,13 @@ pub fn StatFSType(comptime big: bool) type { else => @compileError("Unsupported OS"), }; return .{ - .fstype = @truncate(@as(i64, @intCast(fstype_))), - .bsize = @truncate(@as(i64, @intCast(bsize_))), - .blocks = @truncate(@as(i64, @intCast(blocks_))), - .bfree = @truncate(@as(i64, @intCast(bfree_))), - .bavail = @truncate(@as(i64, @intCast(bavail_))), - .files = @truncate(@as(i64, @intCast(files_))), - .ffree = @truncate(@as(i64, @intCast(ffree_))), + ._fstype = @truncate(@as(i64, @intCast(fstype_))), + ._bsize = @truncate(@as(i64, @intCast(bsize_))), + ._blocks = @truncate(@as(i64, @intCast(blocks_))), + ._bfree = @truncate(@as(i64, @intCast(bfree_))), + ._bavail = @truncate(@as(i64, @intCast(bavail_))), + ._files = @truncate(@as(i64, @intCast(files_))), + ._ffree = @truncate(@as(i64, @intCast(ffree_))), }; } @@ -2277,13 +2277,13 @@ pub fn StatFSType(comptime big: bool) type { var args = callFrame.arguments(); const this = This.new(.{ - .fstype = if (args.len > 0 and args[0].isNumber()) args[0].toInt32() else 0, - .bsize = if (args.len > 1 and args[1].isNumber()) args[1].toInt32() else 0, - .blocks = if (args.len > 2 and args[2].isNumber()) args[2].toInt32() else 0, - .bfree = if (args.len > 3 and args[3].isNumber()) args[3].toInt32() else 0, - .bavail = if (args.len > 4 and args[4].isNumber()) args[4].toInt32() else 0, - .files = if (args.len > 5 and args[5].isNumber()) args[5].toInt32() else 0, - .ffree = if (args.len > 6 and args[6].isNumber()) args[6].toInt32() else 0, + ._fstype = if (args.len > 0 and args[0].isNumber()) args[0].toInt32() else 0, + ._bsize = if (args.len > 1 and args[1].isNumber()) args[1].toInt32() else 0, + ._blocks = if (args.len > 2 and args[2].isNumber()) args[2].toInt32() else 0, + ._bfree = if (args.len > 3 and args[3].isNumber()) args[3].toInt32() else 0, + ._bavail = if (args.len > 4 and args[4].isNumber()) args[4].toInt32() else 0, + ._files = if (args.len > 5 and args[5].isNumber()) args[5].toInt32() else 0, + ._ffree = if (args.len > 6 and args[6].isNumber()) args[6].toInt32() else 0, }); return this; diff --git a/src/bun.js/node/util/parse_args.zig b/src/bun.js/node/util/parse_args.zig index 3c1e61e1601bbd..599873d157a145 100644 --- a/src/bun.js/node/util/parse_args.zig +++ b/src/bun.js/node/util/parse_args.zig @@ -65,7 +65,7 @@ const TokenKind = enum { option, @"option-terminator", - const COUNT = @typeInfo(TokenKind).Enum.fields.len; + const COUNT = @typeInfo(TokenKind).@"enum".fields.len; }; const Token = union(TokenKind) { positional: struct { index: u32, value: ValueRef }, @@ -652,7 +652,7 @@ pub fn parseArgs( comptime { const parseArgsFn = JSC.toJSHostFunction(parseArgs); - @export(parseArgsFn, .{ .name = "Bun__NodeUtil__jsParseArgs" }); + @export(&parseArgsFn, .{ .name = "Bun__NodeUtil__jsParseArgs" }); } pub fn parseArgsImpl(globalThis: *JSGlobalObject, config_obj: JSValue) bun.JSError!JSValue { diff --git a/src/bun.js/node/util/validators.zig b/src/bun.js/node/util/validators.zig index 699419a3cb7ea1..e6c003ef59da8c 100644 --- a/src/bun.js/node/util/validators.zig +++ b/src/bun.js/node/util/validators.zig @@ -19,7 +19,7 @@ pub fn throwErrInvalidArgValue( comptime fmt: [:0]const u8, args: anytype, ) bun.JSError { - @setCold(true); + @branchHint(.cold); return globalThis.ERR_INVALID_ARG_VALUE(fmt, args).throw(); } @@ -28,7 +28,7 @@ pub fn throwErrInvalidArgTypeWithMessage( comptime fmt: [:0]const u8, args: anytype, ) bun.JSError { - @setCold(true); + @branchHint(.cold); return globalThis.ERR_INVALID_ARG_TYPE(fmt, args).throw(); } @@ -39,7 +39,7 @@ pub fn throwErrInvalidArgType( comptime expected_type: []const u8, value: JSValue, ) bun.JSError { - @setCold(true); + @branchHint(.cold); const actual_type = getTypeName(globalThis, value); return throwErrInvalidArgTypeWithMessage(globalThis, "The \"" ++ name_fmt ++ "\" property must be of type {s}, got {s}", name_args ++ .{ expected_type, actual_type }); } @@ -49,7 +49,7 @@ pub fn throwRangeError( comptime fmt: [:0]const u8, args: anytype, ) bun.JSError { - @setCold(true); + @branchHint(.cold); return globalThis.ERR_OUT_OF_RANGE(fmt, args).throw(); } @@ -261,14 +261,14 @@ pub fn validateUndefined(globalThis: *JSGlobalObject, value: JSValue, comptime n pub fn validateStringEnum(comptime T: type, globalThis: *JSGlobalObject, value: JSValue, comptime name_fmt: string, name_args: anytype) bun.JSError!T { const str = try value.toBunString2(globalThis); defer str.deref(); - inline for (@typeInfo(T).Enum.fields) |enum_field| { + inline for (@typeInfo(T).@"enum".fields) |enum_field| { if (str.eqlComptime(enum_field.name)) return @field(T, enum_field.name); } const values_info = comptime blk: { var out: []const u8 = ""; - for (@typeInfo(T).Enum.fields, 0..) |enum_field, i| { + for (@typeInfo(T).@"enum".fields, 0..) |enum_field, i| { out = out ++ (if (i > 0) "|" else "") ++ enum_field.name; } break :blk out; diff --git a/src/bun.js/test/expect.zig b/src/bun.js/test/expect.zig index 9315790ff73fa1..f55568b2e3e27f 100644 --- a/src/bun.js/test/expect.zig +++ b/src/bun.js/test/expect.zig @@ -4696,7 +4696,7 @@ pub const Expect = struct { }; fn throwInvalidMatcherError(globalThis: *JSGlobalObject, matcher_name: bun.String, result: JSValue) bun.JSError { - @setCold(true); + @branchHint(.cold); var formatter = JSC.ConsoleObject.Formatter{ .globalThis = globalThis, @@ -4981,7 +4981,7 @@ pub const ExpectStatic = struct { } fn asyncChainingError(globalThis: *JSGlobalObject, flags: Expect.Flags, name: string) bun.JSError!JSValue { - @setCold(true); + @branchHint(.cold); const str = switch (flags.promise) { .resolves => "resolvesTo", .rejects => "rejectsTo", @@ -5619,9 +5619,9 @@ extern fn Expect__getPrototype(globalThis: *JSGlobalObject) JSValue; extern fn ExpectStatic__getPrototype(globalThis: *JSGlobalObject) JSValue; comptime { - @export(ExpectMatcherUtils.createSingleton, .{ .name = "ExpectMatcherUtils_createSigleton" }); - @export(Expect.readFlagsAndProcessPromise, .{ .name = "Expect_readFlagsAndProcessPromise" }); - @export(ExpectCustomAsymmetricMatcher.execute, .{ .name = "ExpectCustomAsymmetricMatcher__execute" }); + @export(&ExpectMatcherUtils.createSingleton, .{ .name = "ExpectMatcherUtils_createSigleton" }); + @export(&Expect.readFlagsAndProcessPromise, .{ .name = "Expect_readFlagsAndProcessPromise" }); + @export(&ExpectCustomAsymmetricMatcher.execute, .{ .name = "ExpectCustomAsymmetricMatcher__execute" }); } fn incrementExpectCallCounter() void { @@ -5674,7 +5674,7 @@ test "Expect.trimLeadingWhitespaceForInlineSnapshot" { try testTrimLeadingWhitespaceForSnapshot( \\ \\ Hello, world! - \\ + \\ , \\ \\Hello, world! @@ -5699,7 +5699,7 @@ test "Expect.trimLeadingWhitespaceForInlineSnapshot" { \\ key: value \\ \\ } - \\ + \\ , \\ \\Object{ @@ -5713,13 +5713,13 @@ test "Expect.trimLeadingWhitespaceForInlineSnapshot" { \\ Object{ \\ key: value \\ } - \\ + \\ , \\ \\ Object{ \\ key: value \\ } - \\ + \\ ); try testTrimLeadingWhitespaceForSnapshot( \\ diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 4220c41e11b693..137c286a0e6327 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -559,8 +559,8 @@ pub const Jest = struct { } comptime { - @export(Bun__Jest__createTestModuleObject, .{ .name = "Bun__Jest__createTestModuleObject" }); - @export(Bun__Jest__createTestPreloadObject, .{ .name = "Bun__Jest__createTestPreloadObject" }); + @export(&Bun__Jest__createTestModuleObject, .{ .name = "Bun__Jest__createTestModuleObject" }); + @export(&Bun__Jest__createTestPreloadObject, .{ .name = "Bun__Jest__createTestPreloadObject" }); } }; @@ -808,10 +808,10 @@ pub const TestScope = struct { pub const name = "TestScope"; pub const shim = JSC.Shimmer("Bun", name, @This()); comptime { - @export(jsOnResolve, .{ + @export(&jsOnResolve, .{ .name = shim.symbolName("onResolve"), }); - @export(jsOnReject, .{ + @export(&jsOnReject, .{ .name = shim.symbolName("onReject"), }); } @@ -820,10 +820,10 @@ pub const TestScope = struct { pub const DescribeScope = struct { label: string = "", parent: ?*DescribeScope = null, - beforeAll: std.ArrayListUnmanaged(JSValue) = .{}, - beforeEach: std.ArrayListUnmanaged(JSValue) = .{}, - afterEach: std.ArrayListUnmanaged(JSValue) = .{}, - afterAll: std.ArrayListUnmanaged(JSValue) = .{}, + beforeAlls: std.ArrayListUnmanaged(JSValue) = .{}, + beforeEachs: std.ArrayListUnmanaged(JSValue) = .{}, + afterEachs: std.ArrayListUnmanaged(JSValue) = .{}, + afterAlls: std.ArrayListUnmanaged(JSValue) = .{}, test_id_start: TestRunner.Test.ID = 0, test_id_len: TestRunner.Test.ID = 0, tests: std.ArrayListUnmanaged(TestScope) = .{}, @@ -904,7 +904,7 @@ pub const DescribeScope = struct { } cb.protect(); - @field(DescribeScope.active.?, @tagName(hook)).append(getAllocator(globalThis), cb) catch unreachable; + @field(DescribeScope.active.?, @tagName(hook) ++ "s").append(getAllocator(globalThis), cb) catch unreachable; return JSValue.jsBoolean(true); } }.run; @@ -939,7 +939,7 @@ pub const DescribeScope = struct { pub const beforeEach = createCallback(.beforeEach); pub fn execCallback(this: *DescribeScope, globalObject: *JSGlobalObject, comptime hook: LifecycleHook) ?JSValue { - var hooks = &@field(this, @tagName(hook)); + var hooks = &@field(this, @tagName(hook) ++ "s"); defer { if (comptime hook == .beforeAll or hook == .afterAll) { hooks.clearAndFree(getAllocator(globalObject)); diff --git a/src/bun.js/test/pretty_format.zig b/src/bun.js/test/pretty_format.zig index d463598aae33cf..5d7fd28884c31b 100644 --- a/src/bun.js/test/pretty_format.zig +++ b/src/bun.js/test/pretty_format.zig @@ -12,7 +12,6 @@ const string = bun.string; const JSLexer = bun.js_lexer; const JSPrinter = bun.js_printer; const JSPrivateDataPtr = JSC.JSPrivateDataPtr; -const JS = @import("../javascript.zig"); const JSPromise = JSC.JSPromise; const expect = @import("./expect.zig"); @@ -1986,7 +1985,7 @@ pub const JestPrettyFormat = struct { // comptime var so we have to repeat it here. The rationale there is // it _should_ limit the stack usage because each version of the // function will be relatively small - return try switch (result.tag) { + return switch (result.tag) { .StringPossiblyFormatted => this.printAs(.StringPossiblyFormatted, Writer, writer, value, result.cell, enable_ansi_colors), .String => this.printAs(.String, Writer, writer, value, result.cell, enable_ansi_colors), .Undefined => this.printAs(.Undefined, Writer, writer, value, result.cell, enable_ansi_colors), diff --git a/src/bun.js/test/snapshot.zig b/src/bun.js/test/snapshot.zig index fb5ce9a888c7a7..becdc040399807 100644 --- a/src/bun.js/test/snapshot.zig +++ b/src/bun.js/test/snapshot.zig @@ -510,7 +510,7 @@ pub const Snapshots = struct { remain[0] = 0; const snapshot_file_path = snapshot_file_path_buf[0 .. snapshot_file_path_buf.len - remain.len :0]; - var flags: bun.Mode = bun.O.CREAT | bun.O.RDWR; + var flags: i32 = bun.O.CREAT | bun.O.RDWR; if (this.update_snapshots) flags |= bun.O.TRUNC; const fd = switch (bun.sys.open(snapshot_file_path, flags, 0o644)) { .result => |_fd| _fd, diff --git a/src/bun.js/web_worker.zig b/src/bun.js/web_worker.zig index 76520cbb39ff75..3cd99e7ebe907d 100644 --- a/src/bun.js/web_worker.zig +++ b/src/bun.js/web_worker.zig @@ -535,9 +535,9 @@ pub const WebWorker = struct { } comptime { - @export(create, .{ .name = "WebWorker__create" }); - @export(requestTerminate, .{ .name = "WebWorker__requestTerminate" }); - @export(setRef, .{ .name = "WebWorker__setRef" }); + @export(&create, .{ .name = "WebWorker__create" }); + @export(&requestTerminate, .{ .name = "WebWorker__requestTerminate" }); + @export(&setRef, .{ .name = "WebWorker__setRef" }); _ = WebWorker__updatePtr; } }; diff --git a/src/bun.js/webcore.zig b/src/bun.js/webcore.zig index 55ecdeb63f1333..ab76f70729daf9 100644 --- a/src/bun.js/webcore.zig +++ b/src/bun.js/webcore.zig @@ -533,7 +533,7 @@ pub const Crypto = struct { return globalThis.ERR_CRYPTO_SCRYPT_INVALID_PARAMETER("Invalid scrypt parameters", .{}).throw(); } - fn throwInvalidParams(globalThis: *JSC.JSGlobalObject, comptime error_type: @Type(.EnumLiteral), comptime message: [:0]const u8, fmt: anytype) bun.JSError { + fn throwInvalidParams(globalThis: *JSC.JSGlobalObject, comptime error_type: @Type(.enum_literal), comptime message: [:0]const u8, fmt: anytype) bun.JSError { if (error_type != .RangeError) @compileError("Error type not added!"); BoringSSL.ERR_clear_error(); return globalThis.ERR_CRYPTO_INVALID_SCRYPT_PARAMS(message, fmt).throw(); @@ -644,7 +644,7 @@ pub const Crypto = struct { comptime { const Bun__randomUUIDv7 = JSC.toJSHostFunction(Bun__randomUUIDv7_); - @export(Bun__randomUUIDv7, .{ .name = "Bun__randomUUIDv7" }); + @export(&Bun__randomUUIDv7, .{ .name = "Bun__randomUUIDv7" }); } pub fn Bun__randomUUIDv7_(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { const arguments = callframe.argumentsUndef(2).slice(); @@ -736,9 +736,9 @@ pub const Crypto = struct { comptime { const js_alert = JSC.toJSHostFunction(alert); - @export(js_alert, .{ .name = "WebCore__alert" }); + @export(&js_alert, .{ .name = "WebCore__alert" }); const js_prompt = JSC.toJSHostFunction(Prompt.call); - @export(js_prompt, .{ .name = "WebCore__prompt" }); + @export(&js_prompt, .{ .name = "WebCore__prompt" }); const js_confirm = JSC.toJSHostFunction(confirm); - @export(js_confirm, .{ .name = "WebCore__confirm" }); + @export(&js_confirm, .{ .name = "WebCore__confirm" }); } diff --git a/src/bun.js/webcore/ObjectURLRegistry.zig b/src/bun.js/webcore/ObjectURLRegistry.zig index 5bf2ed7803e868..65234b632a703f 100644 --- a/src/bun.js/webcore/ObjectURLRegistry.zig +++ b/src/bun.js/webcore/ObjectURLRegistry.zig @@ -91,7 +91,7 @@ pub fn has(this: *ObjectURLRegistry, pathname: []const u8) bool { comptime { const Bun__createObjectURL = JSC.toJSHostFunction(Bun__createObjectURL_); - @export(Bun__createObjectURL, .{ .name = "Bun__createObjectURL" }); + @export(&Bun__createObjectURL, .{ .name = "Bun__createObjectURL" }); } fn Bun__createObjectURL_(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { const arguments = callframe.arguments_old(1); @@ -109,7 +109,7 @@ fn Bun__createObjectURL_(globalObject: *JSC.JSGlobalObject, callframe: *JSC.Call comptime { const Bun__revokeObjectURL = JSC.toJSHostFunction(Bun__revokeObjectURL_); - @export(Bun__revokeObjectURL, .{ .name = "Bun__revokeObjectURL" }); + @export(&Bun__revokeObjectURL, .{ .name = "Bun__revokeObjectURL" }); } fn Bun__revokeObjectURL_(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { const arguments = callframe.arguments_old(1); @@ -138,7 +138,7 @@ fn Bun__revokeObjectURL_(globalObject: *JSC.JSGlobalObject, callframe: *JSC.Call comptime { const jsFunctionResolveObjectURL = JSC.toJSHostFunction(jsFunctionResolveObjectURL_); - @export(jsFunctionResolveObjectURL, .{ .name = "jsFunctionResolveObjectURL" }); + @export(&jsFunctionResolveObjectURL, .{ .name = "jsFunctionResolveObjectURL" }); } fn jsFunctionResolveObjectURL_(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { const arguments = callframe.arguments_old(1); diff --git a/src/bun.js/webcore/S3File.zig b/src/bun.js/webcore/S3File.zig index 03aca7800b7d55..8309c0fe8885a0 100644 --- a/src/bun.js/webcore/S3File.zig +++ b/src/bun.js/webcore/S3File.zig @@ -603,11 +603,11 @@ pub fn hasInstance(_: JSC.JSValue, _: *JSC.JSGlobalObject, value: JSC.JSValue) c } comptime { - @export(exports.JSS3File__presign, .{ .name = "JSS3File__presign" }); - @export(construct, .{ .name = "JSS3File__construct" }); - @export(hasInstance, .{ .name = "JSS3File__hasInstance" }); - @export(getBucket, .{ .name = "JSS3File__bucket" }); - @export(getStat, .{ .name = "JSS3File__stat" }); + @export(&exports.JSS3File__presign, .{ .name = "JSS3File__presign" }); + @export(&construct, .{ .name = "JSS3File__construct" }); + @export(&hasInstance, .{ .name = "JSS3File__hasInstance" }); + @export(&getBucket, .{ .name = "JSS3File__bucket" }); + @export(&getStat, .{ .name = "JSS3File__stat" }); } pub const exports = struct { diff --git a/src/bun.js/webcore/S3Stat.zig b/src/bun.js/webcore/S3Stat.zig index 53deb25bcb4c94..361c639d3f2150 100644 --- a/src/bun.js/webcore/S3Stat.zig +++ b/src/bun.js/webcore/S3Stat.zig @@ -1,5 +1,5 @@ -const bun = @import("../../bun.zig"); -const JSC = @import("../../jsc.zig"); +const bun = @import("root").bun; +const JSC = bun.JSC; pub const S3Stat = struct { const log = bun.Output.scoped(.S3Stat, false); diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index 125f4f1e23e024..c39153baa01acd 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -49,9 +49,6 @@ const PathOrBlob = JSC.Node.PathOrBlob; const WriteFilePromise = @import("./blob/WriteFile.zig").WriteFilePromise; const WriteFileWaitFromLockedValueTask = @import("./blob/WriteFile.zig").WriteFileWaitFromLockedValueTask; const NewReadFileHandler = @import("./blob/ReadFile.zig").NewReadFileHandler; -const WriteFile = @import("./blob/WriteFile.zig").WriteFile; -const ReadFile = @import("./blob/ReadFile.zig").ReadFile; -const WriteFileWindows = @import("./blob/WriteFile.zig").WriteFileWindows; const S3File = @import("./S3File.zig"); @@ -60,8 +57,20 @@ pub const Blob = struct { pub usingnamespace bun.New(@This()); pub usingnamespace JSC.Codegen.JSBlob; - pub usingnamespace @import("./blob/WriteFile.zig"); - pub usingnamespace @import("./blob/ReadFile.zig"); + + // pub usingnamespace @import("./blob/ReadFile.zig"); + const rf = @import("./blob/ReadFile.zig"); + pub const ReadFile = rf.ReadFile; + pub const ReadFileUV = rf.ReadFileUV; + pub const ReadFileTask = rf.ReadFileTask; + pub const ReadFileResultType = rf.ReadFileResultType; + + // pub usingnamespace @import("./blob/WriteFile.zig"); + const wf = @import("./blob/WriteFile.zig"); + pub const WriteFile = wf.WriteFile; + pub const WriteFileWindows = wf.WriteFileWindows; + pub const WriteFileTask = wf.WriteFileTask; + pub const ClosingState = enum(u8) { running, closing, @@ -142,7 +151,6 @@ pub const Blob = struct { return store.data == .file; } - const ReadFileUV = @import("./blob/ReadFile.zig").ReadFileUV; pub fn doReadFromS3(this: *Blob, comptime Function: anytype, global: *JSGlobalObject) JSValue { bloblog("doReadFromS3", .{}); @@ -183,7 +191,7 @@ pub const Blob = struct { handler, Handler.run, ) catch bun.outOfMemory(); - var read_file_task = ReadFile.ReadFileTask.createOnJSThread(bun.default_allocator, global, file_read) catch bun.outOfMemory(); + var read_file_task = ReadFileTask.createOnJSThread(bun.default_allocator, global, file_read) catch bun.outOfMemory(); // Create the Promise only after the store has been ref()'d. // The garbage collector runs on memory allocations @@ -202,7 +210,7 @@ pub const Blob = struct { pub fn NewInternalReadFileHandler(comptime Context: type, comptime Function: anytype) type { return struct { - pub fn run(handler: *anyopaque, bytes_: ReadFile.ResultType) void { + pub fn run(handler: *anyopaque, bytes_: ReadFileResultType) void { Function(bun.cast(Context, handler), bytes_); } }; @@ -221,7 +229,7 @@ pub const Blob = struct { this.offset, this.size, ) catch bun.outOfMemory(); - var read_file_task = ReadFile.ReadFileTask.createOnJSThread(bun.default_allocator, global, file_read) catch bun.outOfMemory(); + var read_file_task = ReadFileTask.createOnJSThread(bun.default_allocator, global, file_read) catch bun.outOfMemory(); read_file_task.schedule(); } @@ -973,7 +981,7 @@ pub const Blob = struct { WriteFilePromise.run, options.mkdirp_if_not_exists orelse true, ) catch unreachable; - var task = WriteFile.WriteFileTask.createOnJSThread(bun.default_allocator, ctx, file_copier) catch bun.outOfMemory(); + var task = WriteFileTask.createOnJSThread(bun.default_allocator, ctx, file_copier) catch bun.outOfMemory(); // Defer promise creation until we're just about to schedule the task var promise = JSC.JSPromise.create(ctx); const promise_value = promise.asValue(ctx); @@ -2294,10 +2302,7 @@ pub const Blob = struct { this.update(); } - pub fn doClose( - this: *This, - is_allowed_to_close_fd: bool, - ) bool { + pub fn doClose(this: *This, is_allowed_to_close_fd: bool) bool { if (@hasField(This, "io_request")) { if (this.close_after_io) { this.state.store(ClosingState.closing, .seq_cst); @@ -2827,7 +2832,7 @@ pub const Blob = struct { fn truncate(this: *CopyFileWindows) void { // TODO: optimize this - @setCold(true); + @branchHint(.cold); var node_fs: JSC.Node.NodeFS = .{}; _ = node_fs.truncate( @@ -2903,6 +2908,9 @@ pub const Blob = struct { .syscall = bun.String.static("fstat"), }; + pub const CopyFilePromiseTask = JSC.ConcurrentPromiseTask(CopyFile); + pub const CopyFilePromiseTaskEventLoopTask = CopyFilePromiseTask.EventLoopTask; + // blocking, but off the main thread pub const CopyFile = struct { destination_file_store: FileStore, @@ -2927,8 +2935,6 @@ pub const Blob = struct { pub const ResultType = anyerror!SizeType; pub const Callback = *const fn (ctx: *anyopaque, len: ResultType) void; - pub const CopyFilePromiseTask = JSC.ConcurrentPromiseTask(CopyFile); - pub const CopyFilePromiseTaskEventLoopTask = CopyFilePromiseTask.EventLoopTask; pub fn create( allocator: std.mem.Allocator, @@ -3234,7 +3240,7 @@ pub const Blob = struct { } pub fn doFCopyFileWithReadWriteLoopFallback(this: *CopyFile) anyerror!void { - switch (bun.sys.fcopyfile(this.source_fd, this.destination_fd, posix.system.COPYFILE_DATA)) { + switch (bun.sys.fcopyfile(this.source_fd, this.destination_fd, posix.system.COPYFILE{ .DATA = true })) { .err => |errno| { switch (errno.getErrno()) { // If the file type doesn't support seeking, it may return EBADF @@ -3293,6 +3299,7 @@ pub const Blob = struct { } pub fn runAsync(this: *CopyFile) void { + if (Environment.isWindows) return; //why // defer task.onFinish(); var stat_: ?bun.Stat = null; @@ -4083,9 +4090,9 @@ pub const Blob = struct { }); comptime { const jsonResolveRequestStream = JSC.toJSHostFunction(onFileStreamResolveRequestStream); - @export(jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); + @export(&jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); const jsonRejectRequestStream = JSC.toJSHostFunction(onFileStreamRejectRequestStream); - @export(jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); + @export(&jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); } pub fn pipeReadableStreamToBlob(this: *Blob, globalThis: *JSC.JSGlobalObject, readable_stream: JSC.WebCore.ReadableStream, extra_options: ?JSValue) JSC.JSValue { var store = this.store orelse { @@ -4824,7 +4831,7 @@ pub const Blob = struct { Blob.max_size; store.data.file.mode = @intCast(stat.mode); store.data.file.seekable = bun.isRegularFile(stat.mode); - store.data.file.last_modified = JSC.toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec); + store.data.file.last_modified = JSC.toJSTime(stat.mtime().sec, stat.mtime().nsec); }, // the file may not exist yet. Thats's okay. else => {}, @@ -4838,7 +4845,7 @@ pub const Blob = struct { Blob.max_size; store.data.file.mode = @intCast(stat.mode); store.data.file.seekable = bun.isRegularFile(stat.mode); - store.data.file.last_modified = JSC.toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec); + store.data.file.last_modified = JSC.toJSTime(stat.mtime().sec, stat.mtime().nsec); }, // the file may not exist yet. Thats's okay. else => {}, diff --git a/src/bun.js/webcore/blob/ReadFile.zig b/src/bun.js/webcore/blob/ReadFile.zig index 2add4b0053e365..040ff469b4f6e9 100644 --- a/src/bun.js/webcore/blob/ReadFile.zig +++ b/src/bun.js/webcore/blob/ReadFile.zig @@ -1,14 +1,14 @@ const bun = @import("root").bun; const JSC = bun.JSC; const std = @import("std"); -const Blob = JSC.WebCore.Blob; +const Blob = bun.JSC.WebCore.Blob; const invalid_fd = bun.invalid_fd; const SystemError = JSC.SystemError; const SizeType = Blob.SizeType; const io = bun.io; -const FileOpenerMixin = Blob.Store.FileOpenerMixin; -const FileCloserMixin = Blob.Store.FileCloserMixin; +const FileOpenerMixin = Store.FileOpenerMixin; +const FileCloserMixin = Store.FileCloserMixin; const Environment = bun.Environment; const bloblog = bun.Output.scoped(.WriteFile, true); const JSPromise = JSC.JSPromise; @@ -24,7 +24,7 @@ pub fn NewReadFileHandler(comptime Function: anytype) type { promise: JSPromise.Strong = .{}, globalThis: *JSGlobalObject, - pub fn run(handler: *@This(), maybe_bytes: Blob.ReadFile.ResultType) void { + pub fn run(handler: *@This(), maybe_bytes: ReadFileResultType) void { var promise = handler.promise.swap(); var blob = handler.context; blob.allocator = null; @@ -34,7 +34,7 @@ pub fn NewReadFileHandler(comptime Function: anytype) type { .result => |result| { const bytes = result.buf; if (blob.size > 0) - blob.size = @min(@as(Blob.SizeType, @truncate(bytes.len)), blob.size); + blob.size = @min(@as(SizeType, @truncate(bytes.len)), blob.size); const WrappedFn = struct { pub fn wrapped(b: *Blob, g: *JSGlobalObject, by: []u8) JSC.JSValue { return JSC.toJSHostValue(g, Function(b, g, by, .temporary)); @@ -56,6 +56,11 @@ const ByteStore = Blob.ByteStore; const Store = Blob.Store; const ClosingState = Blob.ClosingState; +pub const ReadFileOnReadFileCallback = *const fn (ctx: *anyopaque, bytes: ReadFileResultType) void; +pub const ReadFileRead = struct { buf: []u8, is_temporary: bool = false, total_size: SizeType = 0 }; +pub const ReadFileResultType = SystemError.Maybe(ReadFileRead); +pub const ReadFileTask = JSC.WorkTask(ReadFile); + pub const ReadFile = struct { file_store: FileStore, byte_store: ByteStore = ByteStore{ .allocator = bun.default_allocator }, @@ -72,7 +77,7 @@ pub const ReadFile = struct { system_error: ?JSC.SystemError = null, errno: ?anyerror = null, onCompleteCtx: *anyopaque = undefined, - onCompleteCallback: OnReadFileCallback = undefined, + onCompleteCallback: ReadFileOnReadFileCallback = undefined, io_task: ?*ReadFileTask = null, io_poll: bun.io.Poll = .{}, io_request: bun.io.Request = .{ .callback = &onRequestReadable }, @@ -80,19 +85,11 @@ pub const ReadFile = struct { close_after_io: bool = false, state: std.atomic.Value(ClosingState) = std.atomic.Value(ClosingState).init(.running), - pub const Read = struct { - buf: []u8, - is_temporary: bool = false, - total_size: SizeType = 0, - }; - pub const ResultType = SystemError.Maybe(Read); - - pub const OnReadFileCallback = *const fn (ctx: *anyopaque, bytes: ResultType) void; - pub usingnamespace FileOpenerMixin(ReadFile); pub usingnamespace FileCloserMixin(ReadFile); pub fn update(this: *ReadFile) void { + if (Environment.isWindows) return; //why switch (this.state.load(.monotonic)) { .closing => { this.onFinish(); @@ -105,7 +102,7 @@ pub const ReadFile = struct { _: std.mem.Allocator, store: *Store, onReadFileContext: *anyopaque, - onCompleteCallback: OnReadFileCallback, + onCompleteCallback: ReadFileOnReadFileCallback, off: SizeType, max_len: SizeType, ) !*ReadFile { @@ -131,13 +128,13 @@ pub const ReadFile = struct { max_len: SizeType, comptime Context: type, context: Context, - comptime callback: fn (ctx: Context, bytes: ResultType) void, + comptime callback: fn (ctx: Context, bytes: ReadFileResultType) void, ) !*ReadFile { if (Environment.isWindows) @compileError("dont call this function on windows"); const Handler = struct { - pub fn run(ptr: *anyopaque, bytes: ResultType) void { + pub fn run(ptr: *anyopaque, bytes: ReadFileResultType) void { callback(bun.cast(Context, ptr), bytes); } }; @@ -257,8 +254,6 @@ pub const ReadFile = struct { return true; } - pub const ReadFileTask = JSC.WorkTask(@This()); - pub fn then(this: *ReadFile, _: *JSC.JSGlobalObject) void { const cb = this.onCompleteCallback; const cb_ctx = this.onCompleteCtx; @@ -266,12 +261,12 @@ pub const ReadFile = struct { if (this.store == null and this.system_error != null) { const system_error = this.system_error.?; bun.destroy(this); - cb(cb_ctx, ResultType{ .err = system_error }); + cb(cb_ctx, ReadFileResultType{ .err = system_error }); return; } else if (this.store == null) { bun.destroy(this); if (Environment.allow_assert) @panic("assertion failure - store should not be null"); - cb(cb_ctx, ResultType{ + cb(cb_ctx, ReadFileResultType{ .err = SystemError{ .code = bun.String.static("INTERNAL_ERROR"), .message = bun.String.static("assertion failure - store should not be null"), @@ -290,7 +285,7 @@ pub const ReadFile = struct { bun.destroy(this); if (system_error) |err| { - cb(cb_ctx, ResultType{ .err = err }); + cb(cb_ctx, ReadFileResultType{ .err = err }); return; } @@ -302,6 +297,7 @@ pub const ReadFile = struct { } fn runAsync(this: *ReadFile, task: *ReadFileTask) void { + if (Environment.isWindows) return; //why this.io_task = task; if (this.file_store.pathlike == .fd) { @@ -347,7 +343,7 @@ pub const ReadFile = struct { if (this.store) |store| { if (store.data == .file) { - store.data.file.last_modified = JSC.toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec); + store.data.file.last_modified = JSC.toJSTime(stat.mtime().sec, stat.mtime().nsec); } } @@ -445,6 +441,7 @@ pub const ReadFile = struct { } fn doReadLoop(this: *ReadFile) void { + if (Environment.isWindows) return; //why while (this.state.load(.monotonic) == .running) { // we hold a 64 KB stack buffer incase the amount of data to // be read is greater than the reported amount @@ -563,7 +560,7 @@ pub const ReadFileUV = struct { system_error: ?JSC.SystemError = null, errno: ?anyerror = null, on_complete_data: *anyopaque = undefined, - on_complete_fn: ReadFile.OnReadFileCallback, + on_complete_fn: ReadFileOnReadFileCallback, is_regular_file: bool = false, req: libuv.fs_t = std.mem.zeroes(libuv.fs_t), @@ -596,7 +593,7 @@ pub const ReadFileUV = struct { const cb_ctx = this.on_complete_data; if (this.system_error) |err| { - cb(cb_ctx, ReadFile.ResultType{ .err = err }); + cb(cb_ctx, ReadFileResultType{ .err = err }); return; } @@ -661,7 +658,7 @@ pub const ReadFileUV = struct { // keep in sync with resolveSizeAndLastModified if (this.store.data == .file) { - this.store.data.file.last_modified = JSC.toJSTime(stat.mtime().tv_sec, stat.mtime().tv_nsec); + this.store.data.file.last_modified = JSC.toJSTime(stat.mtime().sec, stat.mtime().nsec); } if (bun.S.ISDIR(@intCast(stat.mode))) { diff --git a/src/bun.js/webcore/blob/WriteFile.zig b/src/bun.js/webcore/blob/WriteFile.zig index 9560fc4cd2f18f..06416629c53f05 100644 --- a/src/bun.js/webcore/blob/WriteFile.zig +++ b/src/bun.js/webcore/blob/WriteFile.zig @@ -17,6 +17,10 @@ const ZigString = JSC.ZigString; const ClosingState = Blob.ClosingState; +pub const WriteFileResultType = SystemError.Maybe(SizeType); +pub const WriteFileOnWriteFileCallback = *const fn (ctx: *anyopaque, count: WriteFileResultType) void; +pub const WriteFileTask = JSC.WorkTask(WriteFile); + pub const WriteFile = struct { file_blob: Blob, bytes_blob: Blob, @@ -31,15 +35,13 @@ pub const WriteFile = struct { state: std.atomic.Value(ClosingState) = std.atomic.Value(ClosingState).init(.running), onCompleteCtx: *anyopaque = undefined, - onCompleteCallback: OnWriteFileCallback = undefined, + onCompleteCallback: WriteFileOnWriteFileCallback = undefined, total_written: usize = 0, could_block: bool = false, close_after_io: bool = false, mkdirp_if_not_exists: bool = false, - pub const ResultType = SystemError.Maybe(SizeType); - pub const OnWriteFileCallback = *const fn (ctx: *anyopaque, count: ResultType) void; pub const io_tag = io.Poll.Tag.WriteFile; pub usingnamespace FileOpenerMixin(WriteFile); @@ -92,7 +94,7 @@ pub const WriteFile = struct { file_blob: Blob, bytes_blob: Blob, onWriteFileContext: *anyopaque, - onCompleteCallback: OnWriteFileCallback, + onCompleteCallback: WriteFileOnWriteFileCallback, mkdirp_if_not_exists: bool, ) !*WriteFile { const write_file = bun.new(WriteFile, WriteFile{ @@ -113,11 +115,11 @@ pub const WriteFile = struct { bytes_blob: Blob, comptime Context: type, context: Context, - comptime callback: fn (ctx: Context, bytes: ResultType) void, + comptime callback: fn (ctx: Context, bytes: WriteFileResultType) void, mkdirp_if_not_exists: bool, ) !*WriteFile { const Handler = struct { - pub fn run(ptr: *anyopaque, bytes: ResultType) void { + pub fn run(ptr: *anyopaque, bytes: WriteFileResultType) void { callback(bun.cast(Context, ptr), bytes); } }; @@ -178,8 +180,6 @@ pub const WriteFile = struct { return true; } - pub const WriteFileTask = JSC.WorkTask(@This()); - pub fn then(this: *WriteFile, _: *JSC.JSGlobalObject) void { const cb = this.onCompleteCallback; const cb_ctx = this.onCompleteCtx; @@ -199,6 +199,7 @@ pub const WriteFile = struct { bun.destroy(this); cb(cb_ctx, .{ .result = @as(SizeType, @truncate(wrote)) }); } + pub fn run(this: *WriteFile, task: *WriteFileTask) void { if (Environment.isWindows) { @panic("todo"); @@ -308,6 +309,7 @@ pub const WriteFile = struct { } fn doWriteLoop(this: *WriteFile) void { + if (Environment.isWindows) return; //why while (this.state.load(.monotonic) == .running) { var remain = this.bytes_blob.sharedView(); @@ -355,7 +357,7 @@ pub const WriteFileWindows = struct { io_request: uv.fs_t, file_blob: Blob, bytes_blob: Blob, - onCompleteCallback: OnWriteFileCallback, + onCompleteCallback: WriteFileOnWriteFileCallback, onCompleteCtx: *anyopaque, mkdirp_if_not_exists: bool = false, uv_bufs: [1]uv.uv_buf_t, @@ -374,7 +376,7 @@ pub const WriteFileWindows = struct { bytes_blob: Blob, event_loop: *bun.JSC.EventLoop, onWriteFileContext: *anyopaque, - onCompleteCallback: OnWriteFileCallback, + onCompleteCallback: WriteFileOnWriteFileCallback, mkdirp_if_not_exists: bool, ) *WriteFileWindows { const write_file = WriteFileWindows.new(.{ @@ -419,8 +421,6 @@ pub const WriteFileWindows = struct { write_file.event_loop.refConcurrently(); return write_file; } - pub const ResultType = WriteFile.ResultType; - pub const OnWriteFileCallback = WriteFile.OnWriteFileCallback; pub inline fn loop(this: *const WriteFileWindows) *uv.Loop { return this.event_loop.virtual_machine.event_loop_handle.?; @@ -637,7 +637,7 @@ pub const WriteFileWindows = struct { bytes_blob: Blob, comptime Context: type, context: Context, - comptime callback: *const fn (ctx: Context, bytes: ResultType) void, + comptime callback: *const fn (ctx: Context, bytes: WriteFileResultType) void, mkdirp_if_not_exists: bool, ) *WriteFileWindows { return WriteFileWindows.createWithCtx( @@ -654,7 +654,7 @@ pub const WriteFileWindows = struct { pub const WriteFilePromise = struct { promise: JSPromise.Strong = .{}, globalThis: *JSGlobalObject, - pub fn run(handler: *@This(), count: Blob.WriteFile.ResultType) void { + pub fn run(handler: *@This(), count: WriteFileResultType) void { var promise = handler.promise.swap(); const globalThis = handler.globalThis; bun.destroy(handler); diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig index c6177879d9b708..17d95af117663c 100644 --- a/src/bun.js/webcore/body.zig +++ b/src/bun.js/webcore/body.zig @@ -1427,7 +1427,7 @@ pub const BodyValueBufferer = struct { global: *JSGlobalObject, allocator: std.mem.Allocator, ) @This() { - const this = .{ + const this: BodyValueBufferer = .{ .ctx = ctx, .onFinishedBuffering = onFinish, .allocator = allocator, @@ -1486,7 +1486,7 @@ pub const BodyValueBufferer = struct { } } - fn onFinishedLoadingFile(sink: *@This(), bytes: JSC.WebCore.Blob.ReadFile.ResultType) void { + fn onFinishedLoadingFile(sink: *@This(), bytes: Blob.ReadFileResultType) void { switch (bytes) { .err => |err| { log("onFinishedLoadingFile Error", .{}); @@ -1722,9 +1722,9 @@ pub const BodyValueBufferer = struct { comptime { const jsonResolveStream = JSC.toJSHostFunction(onResolveStream); - @export(jsonResolveStream, .{ .name = Export[0].symbol_name }); + @export(&jsonResolveStream, .{ .name = Export[0].symbol_name }); const jsonRejectStream = JSC.toJSHostFunction(onRejectStream); - @export(jsonRejectStream, .{ .name = Export[1].symbol_name }); + @export(&jsonRejectStream, .{ .name = Export[1].symbol_name }); } }; diff --git a/src/bun.js/webcore/encoding.zig b/src/bun.js/webcore/encoding.zig index 78846c6fa4dad0..0c58eb0390561f 100644 --- a/src/bun.js/webcore/encoding.zig +++ b/src/bun.js/webcore/encoding.zig @@ -31,7 +31,7 @@ const JSValue = JSC.JSValue; const JSGlobalObject = JSC.JSGlobalObject; const VirtualMachine = JSC.VirtualMachine; -const Task = @import("../javascript.zig").Task; +const Task = JSC.Task; const picohttp = bun.picohttp; diff --git a/src/bun.js/webcore/request.zig b/src/bun.js/webcore/request.zig index c0b3882a12fee8..4d85d4226c33c0 100644 --- a/src/bun.js/webcore/request.zig +++ b/src/bun.js/webcore/request.zig @@ -611,7 +611,7 @@ pub const Request = struct { } } - if (value.asDirect(JSC.WebCore.Response)) |response| { + if (value.asDirect(Response)) |response| { if (!fields.contains(.method)) { req.method = response.init.method; fields.insert(.method); diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig index 2a9d0d144ba931..a5bf52f203b5b7 100644 --- a/src/bun.js/webcore/response.zig +++ b/src/bun.js/webcore/response.zig @@ -898,7 +898,7 @@ pub const Fetch = struct { pub const Empty: HTTPRequestBody = .{ .AnyBlob = .{ .Blob = .{} } }; - pub fn store(this: *HTTPRequestBody) ?*JSC.WebCore.Blob.Store { + pub fn store(this: *HTTPRequestBody) ?*Blob.Store { return switch (this.*) { .AnyBlob => this.AnyBlob.store(), else => null, @@ -1127,9 +1127,9 @@ pub const Fetch = struct { }); comptime { const jsonResolveRequestStream = JSC.toJSHostFunction(onResolveRequestStream); - @export(jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); + @export(&jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); const jsonRejectRequestStream = JSC.toJSHostFunction(onRejectRequestStream); - @export(jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); + @export(&jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); } pub fn startRequestStream(this: *FetchTasklet) void { @@ -2203,7 +2203,7 @@ pub const Fetch = struct { comptime { const Bun__fetchPreconnect = JSC.toJSHostFunction(Bun__fetchPreconnect_); - @export(Bun__fetchPreconnect, .{ .name = "Bun__fetchPreconnect" }); + @export(&Bun__fetchPreconnect, .{ .name = "Bun__fetchPreconnect" }); } pub fn Bun__fetchPreconnect_( globalObject: *JSC.JSGlobalObject, @@ -2264,7 +2264,7 @@ pub const Fetch = struct { comptime { const Bun__fetch = JSC.toJSHostFunction(Bun__fetch_); - @export(Bun__fetch, .{ .name = "Bun__fetch" }); + @export(&Bun__fetch, .{ .name = "Bun__fetch" }); } /// Implementation of `Bun.fetch` diff --git a/src/bun.js/webcore/streams.zig b/src/bun.js/webcore/streams.zig index 1f0adae622f514..5fc56a1c327bc3 100644 --- a/src/bun.js/webcore/streams.zig +++ b/src/bun.js/webcore/streams.zig @@ -36,14 +36,14 @@ const JSPrinter = bun.js_printer; const picohttp = bun.picohttp; const StringJoiner = bun.StringJoiner; const uws = bun.uws; -const Blob = JSC.WebCore.Blob; +const Blob = bun.JSC.WebCore.Blob; const Response = JSC.WebCore.Response; const Request = JSC.WebCore.Request; const assert = bun.assert; const Syscall = bun.sys; const uv = bun.windows.libuv; -const AnyBlob = JSC.WebCore.AnyBlob; +const AnyBlob = bun.JSC.WebCore.AnyBlob; pub const ReadableStream = struct { value: JSValue, ptr: Source, @@ -123,7 +123,7 @@ pub const ReadableStream = struct { pub fn toAnyBlob( stream: *ReadableStream, globalThis: *JSC.JSGlobalObject, - ) ?JSC.WebCore.AnyBlob { + ) ?AnyBlob { if (stream.isDisturbed(globalThis)) { return null; } @@ -139,7 +139,7 @@ pub const ReadableStream = struct { }, .File => |blobby| { if (blobby.lazy == .blob) { - var blob = JSC.WebCore.Blob.initWithStore(blobby.lazy.blob, globalThis); + var blob = Blob.initWithStore(blobby.lazy.blob, globalThis); blob.store.?.ref(); // it should be lazy, file shouldn't have opened yet. bun.assert(!blobby.started); @@ -492,7 +492,7 @@ pub const StreamStart = union(Tag) { close: bool = false, mode: bun.Mode = 0o664, - pub fn flags(this: *const FileSinkOptions) bun.Mode { + pub fn flags(this: *const FileSinkOptions) i32 { _ = this; return bun.O.NONBLOCK | bun.O.CLOEXEC | bun.O.CREAT | bun.O.WRONLY; @@ -562,7 +562,7 @@ pub const StreamStart = union(Tag) { .ArrayBufferSink => { var as_uint8array = false; var stream = false; - var chunk_size: JSC.WebCore.Blob.SizeType = 0; + var chunk_size: Blob.SizeType = 0; var empty = true; if (value.getOwn(globalThis, "asUint8Array")) |val| { @@ -582,7 +582,7 @@ pub const StreamStart = union(Tag) { if (value.fastGet(globalThis, .highWaterMark)) |chunkSize| { if (chunkSize.isNumber()) { empty = false; - chunk_size = @as(JSC.WebCore.Blob.SizeType, @intCast(@max(0, @as(i51, @truncate(chunkSize.toInt64()))))); + chunk_size = @as(Blob.SizeType, @intCast(@max(0, @as(i51, @truncate(chunkSize.toInt64()))))); } } @@ -597,11 +597,11 @@ pub const StreamStart = union(Tag) { } }, .FileSink => { - var chunk_size: JSC.WebCore.Blob.SizeType = 0; + var chunk_size: Blob.SizeType = 0; if (value.fastGet(globalThis, .highWaterMark)) |chunkSize| { if (chunkSize.isNumber()) - chunk_size = @as(JSC.WebCore.Blob.SizeType, @intCast(@max(0, @as(i51, @truncate(chunkSize.toInt64()))))); + chunk_size = @as(Blob.SizeType, @intCast(@max(0, @as(i51, @truncate(chunkSize.toInt64()))))); } if (value.fastGet(globalThis, .path)) |path| { @@ -660,12 +660,12 @@ pub const StreamStart = union(Tag) { }, .NetworkSink, .HTTPSResponseSink, .HTTPResponseSink => { var empty = true; - var chunk_size: JSC.WebCore.Blob.SizeType = 2048; + var chunk_size: Blob.SizeType = 2048; if (value.fastGet(globalThis, .highWaterMark)) |chunkSize| { if (chunkSize.isNumber()) { empty = false; - chunk_size = @as(JSC.WebCore.Blob.SizeType, @intCast(@max(256, @as(i51, @truncate(chunkSize.toInt64()))))); + chunk_size = @as(Blob.SizeType, @intCast(@max(256, @as(i51, @truncate(chunkSize.toInt64()))))); } } @@ -1608,10 +1608,10 @@ pub const SinkDestructor = struct { } switch (ptr.tag()) { - .Detached => { + @field(Ptr.Tag, @typeName(Detached)) => { return; }, - .Subprocess => { + @field(Ptr.Tag, @typeName(Subprocess)) => { const subprocess = ptr.as(Subprocess); subprocess.onStdinDestroyed(); }, @@ -1982,17 +1982,17 @@ pub fn NewJSSink(comptime SinkType: type, comptime name_: []const u8) type { } comptime { - @export(finalize, .{ .name = shim.symbolName("finalize") }); - @export(jsWrite, .{ .name = shim.symbolName("write") }); - @export(jsGetInternalFd, .{ .name = shim.symbolName("getInternalFd") }); - @export(close, .{ .name = shim.symbolName("close") }); - @export(jsFlush, .{ .name = shim.symbolName("flush") }); - @export(jsStart, .{ .name = shim.symbolName("start") }); - @export(jsEnd, .{ .name = shim.symbolName("end") }); - @export(jsConstruct, .{ .name = shim.symbolName("construct") }); - @export(endWithSink, .{ .name = shim.symbolName("endWithSink") }); - @export(updateRef, .{ .name = shim.symbolName("updateRef") }); - @export(memoryCost, .{ .name = shim.symbolName("memoryCost") }); + @export(&finalize, .{ .name = shim.symbolName("finalize") }); + @export(&jsWrite, .{ .name = shim.symbolName("write") }); + @export(&jsGetInternalFd, .{ .name = shim.symbolName("getInternalFd") }); + @export(&close, .{ .name = shim.symbolName("close") }); + @export(&jsFlush, .{ .name = shim.symbolName("flush") }); + @export(&jsStart, .{ .name = shim.symbolName("start") }); + @export(&jsEnd, .{ .name = shim.symbolName("end") }); + @export(&jsConstruct, .{ .name = shim.symbolName("construct") }); + @export(&endWithSink, .{ .name = shim.symbolName("endWithSink") }); + @export(&updateRef, .{ .name = shim.symbolName("updateRef") }); + @export(&memoryCost, .{ .name = shim.symbolName("memoryCost") }); shim.assertJSFunction(.{ write, @@ -3434,7 +3434,7 @@ pub const FileSink = struct { const log = Output.scoped(.FileSink, false); - pub usingnamespace bun.NewRefCounted(FileSink, deinit); + pub usingnamespace bun.NewRefCounted(FileSink, deinit, null); pub const IOWriter = bun.io.StreamingWriter(@This(), onWrite, onError, onReady, onClose); pub const Poll = IOWriter; @@ -3456,7 +3456,7 @@ pub const FileSink = struct { } comptime { - @export(Bun__ForceFileSinkToBeSynchronousForProcessObjectStdio, .{ .name = "Bun__ForceFileSinkToBeSynchronousForProcessObjectStdio" }); + @export(&Bun__ForceFileSinkToBeSynchronousForProcessObjectStdio, .{ .name = "Bun__ForceFileSinkToBeSynchronousForProcessObjectStdio" }); } pub fn onAttachedProcessExit(this: *FileSink) void { @@ -4781,7 +4781,7 @@ pub const ByteBlobLoader = struct { } } - var blob = JSC.WebCore.Blob.initWithStore(store, globalThis); + var blob = Blob.initWithStore(store, globalThis); blob.offset = this.offset; blob.size = this.remain; this.parent().is_closed = true; diff --git a/src/bun.zig b/src/bun.zig index a61b2373dab8c7..ce576c8bf327d5 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -336,7 +336,7 @@ pub const OSPathSlice = []const OSPathChar; pub const OSPathBuffer = if (Environment.isWindows) WPathBuffer else PathBuffer; pub inline fn cast(comptime To: type, value: anytype) To { - if (@typeInfo(@TypeOf(value)) == .Int) { + if (@typeInfo(@TypeOf(value)) == .int) { return @ptrFromInt(@as(usize, value)); } @@ -345,12 +345,12 @@ pub inline fn cast(comptime To: type, value: anytype) To { pub fn len(value: anytype) usize { return switch (@typeInfo(@TypeOf(value))) { - .Array => |info| info.len, - .Vector => |info| info.len, - .Pointer => |info| switch (info.size) { - .One => switch (@typeInfo(info.child)) { - .Array => |array| brk: { - if (array.sentinel != null) { + .array => |info| info.len, + .vector => |info| info.len, + .pointer => |info| switch (info.size) { + .one => switch (@typeInfo(info.child)) { + .array => |array| brk: { + if (array.sentinel_ptr != null) { @compileError("use bun.sliceTo"); } @@ -358,20 +358,20 @@ pub fn len(value: anytype) usize { }, else => @compileError("invalid type given to std.mem.len"), }, - .Many => { - const sentinel_ptr = info.sentinel orelse + .many => { + const sentinel_ptr = info.sentinel_ptr orelse @compileError("length of pointer with no sentinel"); const sentinel = @as(*align(1) const info.child, @ptrCast(sentinel_ptr)).*; return std.mem.indexOfSentinel(info.child, sentinel, value); }, - .C => { + .c => { assert(value != null); return std.mem.indexOfSentinel(info.child, 0, value); }, - .Slice => value.len, + .slice => value.len, }, - .Struct => |info| if (info.is_tuple) { + .@"struct" => |info| if (info.is_tuple) { return info.fields.len; } else @compileError("invalid type given to std.mem.len"), else => @compileError("invalid type given to std.mem.len"), @@ -380,34 +380,34 @@ pub fn len(value: anytype) usize { fn Span(comptime T: type) type { switch (@typeInfo(T)) { - .Optional => |optional_info| { + .optional => |optional_info| { return ?Span(optional_info.child); }, - .Pointer => |ptr_info| { + .pointer => |ptr_info| { var new_ptr_info = ptr_info; switch (ptr_info.size) { - .One => switch (@typeInfo(ptr_info.child)) { - .Array => |info| { + .one => switch (@typeInfo(ptr_info.child)) { + .array => |info| { new_ptr_info.child = info.child; - new_ptr_info.sentinel = info.sentinel; + new_ptr_info.sentinel_ptr = info.sentinel_ptr; }, else => @compileError("invalid type given to std.mem.Span"), }, - .C => { - new_ptr_info.sentinel = &@as(ptr_info.child, 0); + .c => { + new_ptr_info.sentinel_ptr = &@as(ptr_info.child, 0); new_ptr_info.is_allowzero = false; }, - .Many, .Slice => {}, + .many, .slice => {}, } - new_ptr_info.size = .Slice; - return @Type(.{ .Pointer = new_ptr_info }); + new_ptr_info.size = .slice; + return @Type(.{ .pointer = new_ptr_info }); }, else => @compileError("invalid type given to std.mem.Span: " ++ @typeName(T)), } } pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { - if (@typeInfo(@TypeOf(ptr)) == .Optional) { + if (@typeInfo(@TypeOf(ptr)) == .optional) { if (ptr) |non_null| { return span(non_null); } else { @@ -416,8 +416,8 @@ pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { } const Result = Span(@TypeOf(ptr)); const l = len(ptr); - const ptr_info = @typeInfo(Result).Pointer; - if (ptr_info.sentinel) |s_ptr| { + const ptr_info = @typeInfo(Result).pointer; + if (ptr_info.sentinel_ptr) |s_ptr| { const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; return ptr[0..l :s]; } else { @@ -591,11 +591,11 @@ pub fn fastRandom() u64 { } }; - var prng_: ?std.rand.DefaultPrng = null; + var prng_: ?std.Random.DefaultPrng = null; pub fn get() u64 { if (prng_ == null) { - prng_ = std.rand.DefaultPrng.init(random_seed.get()); + prng_ = std.Random.DefaultPrng.init(random_seed.get()); } return prng_.?.random().uintAtMost(u64, std.math.maxInt(u64)); @@ -808,7 +808,7 @@ pub const zlib = @import("./zlib.zig"); pub var start_time: i128 = 0; pub fn openFileZ(pathZ: [:0]const u8, open_flags: std.fs.File.OpenFlags) !std.fs.File { - var flags: Mode = 0; + var flags: i32 = 0; switch (open_flags.mode) { .read_only => flags |= O.RDONLY, .write_only => flags |= O.WRONLY, @@ -821,7 +821,7 @@ pub fn openFileZ(pathZ: [:0]const u8, open_flags: std.fs.File.OpenFlags) !std.fs pub fn openFile(path_: []const u8, open_flags: std.fs.File.OpenFlags) !std.fs.File { if (comptime Environment.isWindows) { - var flags: Mode = 0; + var flags: i32 = 0; switch (open_flags.mode) { .read_only => flags |= O.RDONLY, .write_only => flags |= O.WRONLY, @@ -1468,10 +1468,10 @@ pub fn getFdPathW(fd_: anytype, buf: *WPathBuffer) ![]u16 { fn lenSliceTo(ptr: anytype, comptime end: meta.Elem(@TypeOf(ptr))) usize { switch (@typeInfo(@TypeOf(ptr))) { - .Pointer => |ptr_info| switch (ptr_info.size) { - .One => switch (@typeInfo(ptr_info.child)) { - .Array => |array_info| { - if (array_info.sentinel) |sentinel_ptr| { + .pointer => |ptr_info| switch (ptr_info.size) { + .one => switch (@typeInfo(ptr_info.child)) { + .array => |array_info| { + if (array_info.sentinel_ptr) |sentinel_ptr| { const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; if (sentinel == end) { return std.mem.indexOfSentinel(array_info.child, end, ptr); @@ -1481,7 +1481,7 @@ fn lenSliceTo(ptr: anytype, comptime end: meta.Elem(@TypeOf(ptr))) usize { }, else => {}, }, - .Many => if (ptr_info.sentinel) |sentinel_ptr| { + .many => if (ptr_info.sentinel_ptr) |sentinel_ptr| { const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; // We may be looking for something other than the sentinel, // but iterating past the sentinel would be a bug so we need @@ -1490,12 +1490,12 @@ fn lenSliceTo(ptr: anytype, comptime end: meta.Elem(@TypeOf(ptr))) usize { while (ptr[i] != end and ptr[i] != sentinel) i += 1; return i; }, - .C => { + .c => { assert(ptr != null); return std.mem.indexOfSentinel(ptr_info.child, end, ptr); }, - .Slice => { - if (ptr_info.sentinel) |sentinel_ptr| { + .slice => { + if (ptr_info.sentinel_ptr) |sentinel_ptr| { const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; if (sentinel == end) { return std.mem.indexOfSentinel(ptr_info.child, sentinel, ptr); @@ -1512,51 +1512,51 @@ fn lenSliceTo(ptr: anytype, comptime end: meta.Elem(@TypeOf(ptr))) usize { /// Helper for the return type of sliceTo() fn SliceTo(comptime T: type, comptime end: meta.Elem(T)) type { switch (@typeInfo(T)) { - .Optional => |optional_info| { + .optional => |optional_info| { return ?SliceTo(optional_info.child, end); }, - .Pointer => |ptr_info| { + .pointer => |ptr_info| { var new_ptr_info = ptr_info; - new_ptr_info.size = .Slice; + new_ptr_info.size = .slice; switch (ptr_info.size) { - .One => switch (@typeInfo(ptr_info.child)) { - .Array => |array_info| { + .one => switch (@typeInfo(ptr_info.child)) { + .array => |array_info| { new_ptr_info.child = array_info.child; // The return type must only be sentinel terminated if we are guaranteed // to find the value searched for, which is only the case if it matches // the sentinel of the type passed. - if (array_info.sentinel) |sentinel_ptr| { + if (array_info.sentinel_ptr) |sentinel_ptr| { const sentinel = @as(*align(1) const array_info.child, @ptrCast(sentinel_ptr)).*; if (end == sentinel) { - new_ptr_info.sentinel = &end; + new_ptr_info.sentinel_ptr = &end; } else { - new_ptr_info.sentinel = null; + new_ptr_info.sentinel_ptr = null; } } }, else => {}, }, - .Many, .Slice => { + .many, .slice => { // The return type must only be sentinel terminated if we are guaranteed // to find the value searched for, which is only the case if it matches // the sentinel of the type passed. - if (ptr_info.sentinel) |sentinel_ptr| { + if (ptr_info.sentinel_ptr) |sentinel_ptr| { const sentinel = @as(*align(1) const ptr_info.child, @ptrCast(sentinel_ptr)).*; if (end == sentinel) { - new_ptr_info.sentinel = &end; + new_ptr_info.sentinel_ptr = &end; } else { - new_ptr_info.sentinel = null; + new_ptr_info.sentinel_ptr = null; } } }, - .C => { - new_ptr_info.sentinel = &end; + .c => { + new_ptr_info.sentinel_ptr = &end; // C pointers are always allowzero, but we don't want the return type to be. assert(new_ptr_info.is_allowzero); new_ptr_info.is_allowzero = false; }, } - return @Type(.{ .Pointer = new_ptr_info }); + return @Type(.{ .pointer = new_ptr_info }); }, else => {}, } @@ -1571,14 +1571,14 @@ fn SliceTo(comptime T: type, comptime end: meta.Elem(T)) type { /// Pointer properties such as mutability and alignment are preserved. /// C pointers are assumed to be non-null. pub fn sliceTo(ptr: anytype, comptime end: meta.Elem(@TypeOf(ptr))) SliceTo(@TypeOf(ptr), end) { - if (@typeInfo(@TypeOf(ptr)) == .Optional) { + if (@typeInfo(@TypeOf(ptr)) == .optional) { const non_null = ptr orelse return null; return sliceTo(non_null, end); } const Result = SliceTo(@TypeOf(ptr), end); const length = lenSliceTo(ptr, end); - const ptr_info = @typeInfo(Result).Pointer; - if (ptr_info.sentinel) |s_ptr| { + const ptr_info = @typeInfo(Result).pointer; + if (ptr_info.sentinel_ptr) |s_ptr| { const s = @as(*align(1) const ptr_info.child, @ptrCast(s_ptr)).*; return ptr[0..length :s]; } else { @@ -1693,7 +1693,6 @@ pub const failing_allocator = std.mem.Allocator{ .ptr = undefined, .vtable = &.{ var __reload_in_progress__ = std.atomic.Value(bool).init(false); threadlocal var __reload_in_progress__on_current_thread = false; pub fn isProcessReloadInProgressOnAnotherThread() bool { - @fence(.acquire); return __reload_in_progress__.load(.monotonic) and !__reload_in_progress__on_current_thread; } @@ -2305,7 +2304,7 @@ pub fn initArgv(allocator: std.mem.Allocator) !void { // Updates in Zig v0.12 related to Windows cmd line parsing may fix this, // see (here: https://ziglang.org/download/0.12.0/release-notes.html#Windows-Command-Line-Argument-Parsing), // so this may only need to be a temporary workaround. - const cmdline_ptr = std.os.windows.kernel32.GetCommandLineW(); + const cmdline_ptr = bun.windows.GetCommandLineW(); var length: c_int = 0; // As per the documentation: @@ -2323,7 +2322,7 @@ pub fn initArgv(allocator: std.mem.Allocator) !void { }; const argvu16 = argvu16_ptr[0..@intCast(length)]; - const out_argv = try allocator.alloc([:0]u8, @intCast(length)); + const out_argv = try allocator.alloc([:0]const u8, @intCast(length)); var string_builder = StringBuilder{}; for (argvu16) |argraw| { @@ -2559,7 +2558,7 @@ pub const win32 = struct { @memset(std.mem.asBytes(procinfo), 0); const rc = w.kernel32.CreateProcessW( image_pathZ.ptr, - w.kernel32.GetCommandLineW(), + bun.windows.GetCommandLineW(), null, null, 1, @@ -2601,7 +2600,7 @@ pub const FDTag = enum { const fd = toFD(fd_); const T = @TypeOf(fd_); if (comptime Environment.isWindows) { - if (@typeInfo(T) == .Int or @typeInfo(T) == .ComptimeInt) { + if (@typeInfo(T) == .int or @typeInfo(T) == .comptime_int) { switch (fd_) { 0 => return .stdin, 1 => return .stdout, @@ -2672,7 +2671,7 @@ pub fn serializable(input: anytype) @TypeOf(input) { const T = @TypeOf(input); comptime { if (trait.isExternContainer(T)) { - if (@typeInfo(T) == .Union) { + if (@typeInfo(T) == .@"union") { @compileError("Extern unions must be serialized with serializableInto"); } } @@ -3045,12 +3044,12 @@ pub const Dirname = struct { }; pub noinline fn outOfMemory() noreturn { - @setCold(true); + @branchHint(.cold); crash_handler.crashHandler(.out_of_memory, null, @returnAddress()); } pub fn todoPanic(src: std.builtin.SourceLocation, comptime format: string, args: anytype) noreturn { - @setCold(true); + @branchHint(.cold); bun.Analytics.Features.todo_panic = 1; Output.panic("TODO: " ++ format ++ " ({s}:{d})", args ++ .{ src.file, src.line }); } @@ -3086,10 +3085,11 @@ pub inline fn new(comptime T: type, init: T) *T { break :ptr ptr; }; - if (comptime Environment.allow_assert) { - const logAlloc = Output.scoped(.alloc, @hasDecl(T, "logAllocations")); - logAlloc("new({s}) = {*}", .{ meta.typeName(T), ptr }); - } + // TODO:: + // if (comptime Environment.allow_assert) { + // const logAlloc = Output.scoped(.alloc, @hasDecl(T, "logAllocations")); + // logAlloc("new({s}) = {*}", .{ meta.typeName(T), ptr }); + // } return ptr; } @@ -3132,21 +3132,20 @@ pub fn New(comptime T: type) type { /// Reference-counted heap-allocated instance value. /// /// `ref_count` is expected to be defined on `T` with a default value set to `1` -pub fn NewRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void) type { +pub fn NewRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void, debug_name: ?[:0]const u8) type { if (!@hasField(T, "ref_count")) { @compileError("Expected a field named \"ref_count\" with a default value of 1 on " ++ @typeName(T)); } for (std.meta.fields(T)) |field| { if (strings.eqlComptime(field.name, "ref_count")) { - if (field.default_value == null) { + if (field.default_value_ptr == null) { @compileError("Expected a field named \"ref_count\" with a default value of 1 on " ++ @typeName(T)); } } } - const output_name: []const u8 = if (@hasDecl(T, "DEBUG_REFCOUNT_NAME")) T.DEBUG_REFCOUNT_NAME else meta.typeBaseName(@typeName(T)); - + const output_name = debug_name orelse meta.typeBaseName(@typeName(T)); const log = Output.scoped(output_name, true); return struct { @@ -3192,21 +3191,20 @@ pub fn NewRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void) }; } -pub fn NewThreadSafeRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void) type { +pub fn NewThreadSafeRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void, debug_name: ?[:0]const u8) type { if (!@hasField(T, "ref_count")) { @compileError("Expected a field named \"ref_count\" with a default value of 1 on " ++ @typeName(T)); } for (std.meta.fields(T)) |field| { if (strings.eqlComptime(field.name, "ref_count")) { - if (field.default_value == null) { + if (field.default_value_ptr == null) { @compileError("Expected a field named \"ref_count\" with a default value of 1 on " ++ @typeName(T)); } } } - const output_name: []const u8 = if (@hasDecl(T, "DEBUG_REFCOUNT_NAME")) T.DEBUG_REFCOUNT_NAME else meta.typeBaseName(@typeName(T)); - + const output_name = debug_name orelse meta.typeBaseName(@typeName(T)); const log = Output.scoped(output_name, true); return struct { @@ -3297,7 +3295,7 @@ const errno_map = errno_map: { }; pub fn errnoToZigErr(err: anytype) anyerror { - var num = if (@typeInfo(@TypeOf(err)) == .Enum) + var num = if (@typeInfo(@TypeOf(err)) == .@"enum") @intFromEnum(err) else err; @@ -3330,13 +3328,13 @@ pub fn iterateDir(dir: std.fs.Dir) DirIterator.Iterator { } fn ReinterpretSliceType(comptime T: type, comptime slice: type) type { - const is_const = @typeInfo(slice).Pointer.is_const; + const is_const = @typeInfo(slice).pointer.is_const; return if (is_const) []const T else []T; } /// Zig has a todo for @ptrCast changing the `.len`. This is the workaround pub fn reinterpretSlice(comptime T: type, slice: anytype) ReinterpretSliceType(T, @TypeOf(slice)) { - const is_const = @typeInfo(@TypeOf(slice)).Pointer.is_const; + const is_const = @typeInfo(@TypeOf(slice)).pointer.is_const; const bytes = std.mem.sliceAsBytes(slice); const new_ptr = @as(if (is_const) [*]const T else [*]T, @ptrCast(@alignCast(bytes.ptr))); return new_ptr[0..@divTrunc(bytes.len, @sizeOf(T))]; @@ -3532,23 +3530,23 @@ pub const handleErrorReturnTrace = crash_handler.handleErrorReturnTrace; noinline fn assertionFailure() noreturn { if (@inComptime()) { @compileError("assertion failure"); + } else { + @branchHint(.cold); + Output.panic("Internal assertion failure", .{}); } - - @setCold(true); - Output.panic("Internal assertion failure", .{}); } noinline fn assertionFailureWithLocation(src: std.builtin.SourceLocation) noreturn { if (@inComptime()) { @compileError("assertion failure"); + } else { + @branchHint(.cold); + Output.panic("Internal assertion failure {s}:{d}:{d}", .{ + src.file, + src.line, + src.column, + }); } - - @setCold(true); - Output.panic("Internal assertion failure {s}:{d}:{d}", .{ - src.file, - src.line, - src.column, - }); } pub fn debugAssert(cheap_value_only_plz: bool) callconv(callconv_inline) void { @@ -3618,14 +3616,14 @@ pub fn getRoughTickCount() timespec { .sec = 0, }; const clocky = struct { - pub var clock_id: i32 = 0; + pub var clock_id: std.c.CLOCK = .REALTIME; pub fn get() void { var res = timespec{}; - _ = std.c.clock_getres(C.CLOCK_MONOTONIC_RAW_APPROX, @ptrCast(&res)); + _ = std.c.clock_getres(.MONOTONIC_RAW_APPROX, @ptrCast(&res)); if (res.ms() <= 1) { - clock_id = C.CLOCK_MONOTONIC_RAW_APPROX; + clock_id = .MONOTONIC_RAW_APPROX; } else { - clock_id = C.CLOCK_MONOTONIC_RAW; + clock_id = .MONOTONIC_RAW; } } @@ -3644,14 +3642,14 @@ pub fn getRoughTickCount() timespec { .sec = 0, }; const clocky = struct { - pub var clock_id: i32 = 0; + pub var clock_id: std.os.linux.CLOCK = .REALTIME; pub fn get() void { var res = timespec{}; - _ = std.os.linux.clock_getres(std.os.linux.CLOCK.MONOTONIC_COARSE, @ptrCast(&res)); + _ = std.os.linux.clock_getres(.MONOTONIC_COARSE, @ptrCast(&res)); if (res.ms() <= 1) { - clock_id = std.os.linux.CLOCK.MONOTONIC_COARSE; + clock_id = .MONOTONIC_COARSE; } else { - clock_id = std.os.linux.CLOCK.MONOTONIC_RAW; + clock_id = .MONOTONIC_RAW; } } @@ -3812,7 +3810,7 @@ pub const UUID = @import("./bun.js/uuid.zig"); /// call a first element '0' or '1' which makes integer type ambiguous. pub fn OrdinalT(comptime Int: type) type { return enum(Int) { - invalid = switch (@typeInfo(Int).Int.signedness) { + invalid = switch (@typeInfo(Int).int.signedness) { .unsigned => std.math.maxInt(Int), .signed => -1, }, @@ -3880,7 +3878,7 @@ pub const bake = @import("bake/bake.zig"); /// like std.enums.tagName, except it doesn't lose the sentinel value. pub fn tagName(comptime Enum: type, value: Enum) ?[:0]const u8 { - return inline for (@typeInfo(Enum).Enum.fields) |f| { + return inline for (@typeInfo(Enum).@"enum".fields) |f| { if (@intFromEnum(value) == f.value) break f.name; } else null; } @@ -4020,7 +4018,7 @@ pub fn GenericIndex(backing_int: type, uid: anytype) type { return @enumFromInt(int); } - /// Prefer this over @intFromEnum because of type confusion with `.Optional` + /// Prefer this over @intFromEnum because of type confusion with `.optional` pub inline fn get(i: @This()) backing_int { bun.assert(@intFromEnum(i) != null_value); // memory corruption return @intFromEnum(i); @@ -4121,7 +4119,7 @@ pub fn once(comptime f: anytype) Once(f) { /// It is undefined behavior if `f` re-enters the same Once instance. pub fn Once(comptime f: anytype) type { return struct { - const Return = @typeInfo(@TypeOf(f)).Fn.return_type.?; + const Return = @typeInfo(@TypeOf(f)).@"fn".return_type.?; done: bool = false, payload: Return = undefined, @@ -4139,7 +4137,7 @@ pub fn Once(comptime f: anytype) type { } fn callSlow(self: *@This(), args: std.meta.ArgsTuple(@TypeOf(f))) Return { - @setCold(true); + @branchHint(.cold); self.mutex.lock(); defer self.mutex.unlock(); @@ -4158,7 +4156,7 @@ pub fn Once(comptime f: anytype) type { /// `val` must be a pointer to an optional type (e.g. `*?T`) /// /// This function takes the value out of the optional, replacing it with null, and returns the value. -pub inline fn take(val: anytype) ?bun.meta.OptionalChild(@TypeOf(val)) { +pub inline fn take(val: anytype) ?@typeInfo(@typeInfo(@TypeOf(val)).pointer.child).optional.child { if (val.*) |v| { val.* = null; return v; @@ -4182,11 +4180,11 @@ pub inline fn wrappingNegation(val: anytype) @TypeOf(val) { fn assertNoPointers(T: type) void { switch (@typeInfo(T)) { - .Pointer => @compileError("no pointers!"), - inline .Struct, .Union => |s| for (s.fields) |field| { + .pointer => @compileError("no pointers!"), + inline .@"struct", .@"union" => |s| for (s.fields) |field| { assertNoPointers(field.type); }, - .Array => |a| assertNoPointers(a.child), + .array => |a| assertNoPointers(a.child), else => {}, } } @@ -4197,7 +4195,7 @@ pub inline fn writeAnyToHasher(hasher: anytype, thing: anytype) void { } pub inline fn isComptimeKnown(x: anytype) bool { - return comptime @typeInfo(@TypeOf(.{x})).Struct.fields[0].is_comptime; + return comptime @typeInfo(@TypeOf(.{x})).@"struct".fields[0].is_comptime; } pub inline fn itemOrNull(comptime T: type, slice: []const T, index: usize) ?T { @@ -4314,7 +4312,7 @@ pub const StackCheck = struct { // Workaround for lack of branch hints. pub noinline fn throwStackOverflow() StackOverflow!void { - @setCold(true); + @branchHint(.cold); return error.StackOverflow; } const StackOverflow = error{StackOverflow}; diff --git a/src/bun_js.zig b/src/bun_js.zig index 857770971b62e0..904c16d0388a3e 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -155,7 +155,7 @@ pub const Run = struct { } fn bootBunShell(ctx: Command.Context, entry_path: []const u8) !bun.shell.ExitCode { - @setCold(true); + @branchHint(.cold); // this is a hack: make dummy bundler so we can use its `.runEnvLoader()` function to populate environment variables probably should split out the functionality var bundle = try bun.Transpiler.init( @@ -482,7 +482,7 @@ pub export fn Bun__onRejectEntryPointResult(global: *JSC.JSGlobalObject, callfra } noinline fn dumpBuildError(vm: *JSC.VirtualMachine) void { - @setCold(true); + @branchHint(.cold); Output.flush(); @@ -498,7 +498,7 @@ noinline fn dumpBuildError(vm: *JSC.VirtualMachine) void { } pub noinline fn failWithBuildError(vm: *JSC.VirtualMachine) noreturn { - @setCold(true); + @branchHint(.cold); dumpBuildError(vm); Global.exit(1); } diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index 066843e3231266..c1003b858741b8 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -1719,7 +1719,7 @@ pub const BundleV2 = struct { ref_count: std.atomic.Value(u32) = std.atomic.Value(u32).init(1), started_at_ns: u64 = 0, - pub usingnamespace bun.NewThreadSafeRefCounted(JSBundleCompletionTask, @This().deinit); + pub usingnamespace bun.NewThreadSafeRefCounted(JSBundleCompletionTask, _deinit, null); pub fn configureBundler( completion: *JSBundleCompletionTask, @@ -1797,7 +1797,7 @@ pub const BundleV2 = struct { pub const TaskCompletion = bun.JSC.AnyTask.New(JSBundleCompletionTask, onComplete); - pub fn deinit(this: *JSBundleCompletionTask) void { + fn _deinit(this: *JSBundleCompletionTask) void { this.result.deinit(); this.log.deinit(); this.poll_ref.disable(); @@ -14790,7 +14790,7 @@ pub const LinkerContext = struct { Part.SymbolUseMap, c.allocator, .{ - .{ wrapper_ref, .{ .count_estimate = 1 } }, + .{ wrapper_ref, Symbol.Use{ .count_estimate = 1 } }, }, ) catch unreachable, .declared_symbols = js_ast.DeclaredSymbol.List.fromSlice( @@ -14847,10 +14847,10 @@ pub const LinkerContext = struct { const part_index = c.graph.addPartToFile( source_index, .{ - .symbol_uses = bun.from( + .symbol_uses = bun.fromMapLike( Part.SymbolUseMap, c.allocator, - .{ + &.{ .{ wrapper_ref, .{ .count_estimate = 1 } }, }, ) catch unreachable, diff --git a/src/c.zig b/src/c.zig index 98414cbfbde47f..d21250a90529ec 100644 --- a/src/c.zig +++ b/src/c.zig @@ -88,9 +88,9 @@ pub fn lstat_absolute(path: [:0]const u8) !Stat { else => Kind.unknown, }, }, - .atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, - .mtime = @as(i128, mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec, - .ctime = @as(i128, ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec, + .atime = @as(i128, atime.sec) * std.time.ns_per_s + atime.nsec, + .mtime = @as(i128, mtime.sec) * std.time.ns_per_s + mtime.nsec, + .ctime = @as(i128, ctime.sec) * std.time.ns_per_s + ctime.nsec, }; } @@ -417,7 +417,7 @@ pub fn _dlsym(handle: ?*anyopaque, name: [:0]const u8) ?*anyopaque { } pub fn dlsymWithHandle(comptime Type: type, comptime name: [:0]const u8, comptime handle_getter: fn () ?*anyopaque) ?Type { - if (comptime @typeInfo(Type) != .Pointer) { + if (comptime @typeInfo(Type) != .pointer) { @compileError("dlsym must be a pointer type (e.g. ?const *fn()). Received " ++ @typeName(Type) ++ "."); } @@ -480,7 +480,7 @@ pub extern fn memmove(dest: [*]u8, src: [*]const u8, n: usize) void; // https://man7.org/linux/man-pages/man3/fmod.3.html pub extern fn fmod(f64, f64) f64; -pub fn dlopen(filename: [:0]const u8, flags: i32) ?*anyopaque { +pub fn dlopen(filename: [:0]const u8, flags: C.RTLD) ?*anyopaque { if (comptime Environment.isWindows) { return bun.windows.LoadLibraryA(filename); } diff --git a/src/cli.zig b/src/cli.zig index 0f1bad446ed8ee..54a05dad0ced89 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -109,7 +109,7 @@ const ColonListType = @import("./cli/colon_list_type.zig").ColonListType; pub const LoaderColonList = ColonListType(Api.Loader, Arguments.loader_resolver); pub const DefineColonList = ColonListType(string, Arguments.noop_resolver); fn invalidTarget(diag: *clap.Diagnostic, _target: []const u8) noreturn { - @setCold(true); + @branchHint(.cold); diag.name.long = "target"; diag.arg = _target; diag.report(Output.errorWriter(), error.InvalidTarget) catch {}; @@ -1250,7 +1250,7 @@ const AutoCommand = struct { pub const HelpCommand = struct { pub fn exec(allocator: std.mem.Allocator) !void { - @setCold(true); + @branchHint(.cold); execWithReason(allocator, .explicit); } @@ -1344,7 +1344,7 @@ pub const HelpCommand = struct { ; pub fn printWithReason(comptime reason: Reason, show_all_flags: bool) void { - var rand_state = std.rand.DefaultPrng.init(@as(u64, @intCast(@max(std.time.milliTimestamp(), 0)))); + var rand_state = std.Random.DefaultPrng.init(@as(u64, @intCast(@max(std.time.milliTimestamp(), 0)))); const rand = rand_state.random(); const package_x_i = rand.uintAtMost(usize, packages_to_x_filler.len - 1); @@ -1388,7 +1388,7 @@ pub const HelpCommand = struct { } pub fn execWithReason(_: std.mem.Allocator, comptime reason: Reason) void { - @setCold(true); + @branchHint(.cold); printWithReason(reason, false); if (reason == .invalid_command) { @@ -1400,7 +1400,7 @@ pub const HelpCommand = struct { pub const ReservedCommand = struct { pub fn exec(_: std.mem.Allocator) !void { - @setCold(true); + @branchHint(.cold); const command_name = for (bun.argv[1..]) |arg| { if (arg.len > 1 and arg[0] == '-') continue; break arg; @@ -2651,13 +2651,13 @@ pub const Command = struct { }; pub fn printVersionAndExit() noreturn { - @setCold(true); + @branchHint(.cold); Output.writer().writeAll(Global.package_json_version ++ "\n") catch {}; Global.exit(0); } pub fn printRevisionAndExit() noreturn { - @setCold(true); + @branchHint(.cold); Output.writer().writeAll(Global.package_json_version_with_revision ++ "\n") catch {}; Global.exit(0); } diff --git a/src/cli/bunx_command.zig b/src/cli/bunx_command.zig index 3256f302edcbda..e5210fb97d67f9 100644 --- a/src/cli/bunx_command.zig +++ b/src/cli/bunx_command.zig @@ -252,7 +252,7 @@ pub const BunxCommand = struct { } } else { const stat = target_package_json.stat().unwrap() catch break :is_stale true; - break :is_stale std.time.timestamp() - stat.mtime().tv_sec > seconds_cache_valid; + break :is_stale std.time.timestamp() - stat.mtime().sec > seconds_cache_valid; } }; @@ -568,7 +568,7 @@ pub const BunxCommand = struct { if (rc != 0) { break :is_stale true; } - break :is_stale std.time.timestamp() - stat.mtime().tv_sec > seconds_cache_valid; + break :is_stale std.time.timestamp() - stat.mtime().sec > seconds_cache_valid; } }; diff --git a/src/cli/create_command.zig b/src/cli/create_command.zig index bc85f9533113b0..07656cefcfa870 100644 --- a/src/cli/create_command.zig +++ b/src/cli/create_command.zig @@ -99,7 +99,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string, const task = std.mem.trim(u8, task_, " \n\r\t"); if (task.len == 0) return; - var splitter = std.mem.split(u8, task, " "); + var splitter = std.mem.splitScalar(u8, task, ' '); var count: usize = 0; while (splitter.next() != null) { count += 1; @@ -117,7 +117,7 @@ fn execTask(allocator: std.mem.Allocator, task_: string, cwd: string, _: string, { var i: usize = npm_args; - splitter = std.mem.split(u8, task, " "); + splitter = std.mem.splitScalar(u8, task, ' '); while (splitter.next()) |split| { argv[i] = split; i += 1; @@ -237,7 +237,7 @@ const BUN_CREATE_DIR = ".bun-create"; var home_dir_buf: bun.PathBuffer = undefined; pub const CreateCommand = struct { pub fn exec(ctx: Command.Context, example_tag: Example.Tag, template: []const u8) !void { - @setCold(true); + @branchHint(.cold); Global.configureAllocator(.{ .long_running = false }); HTTP.HTTPThread.init(&.{}); @@ -1367,7 +1367,7 @@ pub const CreateCommand = struct { for (items) |task| { if (task.asString(ctx.allocator)) |task_entry| { // if (needs.bun_bun_for_nextjs or bun_bun_for_react_scripts) { - // var iter = std.mem.split(u8, task_entry, " "); + // var iter = std.mem.splitScalar(u8, task_entry, ' '); // var last_was_bun = false; // while (iter.next()) |current| { // if (strings.eqlComptime(current, "bun")) { @@ -2306,7 +2306,6 @@ const GitHandler = struct { else run(destination, PATH, false) catch false; - @fence(.acquire); success.store( if (outcome) 1 @@ -2318,8 +2317,6 @@ const GitHandler = struct { } pub fn wait() bool { - @fence(.release); - while (success.load(.acquire) == 0) { Futex.wait(&success, 0, 1000) catch continue; } diff --git a/src/cli/filter_run.zig b/src/cli/filter_run.zig index ba1a00ed90b545..af4071132f69c9 100644 --- a/src/cli/filter_run.zig +++ b/src/cli/filter_run.zig @@ -409,12 +409,7 @@ const AbortHandler = struct { .mask = std.posix.empty_sigset, .flags = std.posix.SA.SIGINFO | std.posix.SA.RESTART | std.posix.SA.RESETHAND, }; - // if we can't set the handler, we just ignore it - std.posix.sigaction(std.posix.SIG.INT, &action, null) catch |err| { - if (Environment.isDebug) { - Output.warn("Failed to set abort handler: {s}\n", .{@errorName(err)}); - } - }; + std.posix.sigaction(std.posix.SIG.INT, &action, null); } else { const res = bun.windows.SetConsoleCtrlHandler(windowsCtrlHandler, std.os.windows.TRUE); if (res == 0) { diff --git a/src/cli/init_command.zig b/src/cli/init_command.zig index a4676aa6506a0c..9506ef0b55968a 100644 --- a/src/cli/init_command.zig +++ b/src/cli/init_command.zig @@ -68,7 +68,7 @@ pub const InitCommand = struct { /// Create a new asset file, overriding anything that already exists. Known /// assets will have their contents pre-populated; otherwise the file will be empty. fn create(comptime asset_name: []const u8, args: anytype) !void { - const is_template = comptime (@TypeOf(args) != @TypeOf(null)) and @typeInfo(@TypeOf(args)).Struct.fields.len > 0; + const is_template = comptime (@TypeOf(args) != @TypeOf(null)) and @typeInfo(@TypeOf(args)).@"struct".fields.len > 0; return createFull(asset_name, asset_name, "", is_template, args); } diff --git a/src/cli/install_completions_command.zig b/src/cli/install_completions_command.zig index ed9e5d02ace5cf..28109a61319b52 100644 --- a/src/cli/install_completions_command.zig +++ b/src/cli/install_completions_command.zig @@ -303,7 +303,7 @@ pub const InstallCompletionsCommand = struct { }, .zsh => { if (bun.getenvZ("fpath")) |fpath| { - var splitter = std.mem.split(u8, fpath, " "); + var splitter = std.mem.splitScalar(u8, fpath, ' '); while (splitter.next()) |dir| { completions_dir = dir; diff --git a/src/cli/outdated_command.zig b/src/cli/outdated_command.zig index af827fcbcbfba0..c15fc0ca4f4f74 100644 --- a/src/cli/outdated_command.zig +++ b/src/cli/outdated_command.zig @@ -427,14 +427,12 @@ pub const OutdatedCommand = struct { table.printColumnNames(); for (workspace_pkg_ids) |workspace_pkg_id| { - inline for ( - .{ - Behavior.prod, - Behavior.dev, - Behavior.peer, - Behavior.optional, - }, - ) |group_behavior| { + inline for ([_]Behavior{ + .{ .prod = true }, + .{ .dev = true }, + .{ .peer = true }, + .{ .optional = true }, + }) |group_behavior| { for (outdated_ids.items) |ids| { if (workspace_pkg_id != ids.workspace_pkg_id) continue; const package_id = ids.package_id; diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig index 87866a4713b9a2..77a833a084cfa0 100644 --- a/src/cli/package_manager_command.zig +++ b/src/cli/package_manager_command.zig @@ -59,7 +59,7 @@ pub const PackageManagerCommand = struct { } pub fn printHash(ctx: Command.Context, file: File) !void { - @setCold(true); + @branchHint(.cold); const cli = try PackageManager.CommandLineArguments.parse(ctx.allocator, .pm); var pm, const cwd = try PackageManager.init(ctx, cli, PackageManager.Subcommand.pm); diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index f82ae5b5351a47..d7ae1c799c9ef4 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -757,7 +757,7 @@ pub const RunCommand = struct { const dir_slice = target_path_buffer[0 .. prefix.len + len + dir_name.len]; if (Environment.isDebug) { - const dir_slice_u8 = std.unicode.utf16leToUtf8Alloc(bun.default_allocator, dir_slice) catch @panic("oom"); + const dir_slice_u8 = std.unicode.utf16LeToUtf8Alloc(bun.default_allocator, dir_slice) catch @panic("oom"); defer bun.default_allocator.free(dir_slice_u8); std.fs.deleteTreeAbsolute(dir_slice_u8) catch {}; std.fs.makeDirAbsolute(dir_slice_u8) catch @panic("huh?"); @@ -1569,7 +1569,7 @@ pub const RunCommand = struct { const PATH = this_transpiler.env.get("PATH") orelse ""; var path_for_which = PATH; - if (comptime bin_dirs_only) { + if (bin_dirs_only) { if (ORIGINAL_PATH.len < PATH.len) { path_for_which = PATH[0 .. PATH.len - (ORIGINAL_PATH.len + 1)]; } else { @@ -1598,7 +1598,7 @@ pub const RunCommand = struct { return true; } - if (comptime log_errors) { + if (log_errors) { const ext = std.fs.path.extension(target_name); const default_loader = options.defaultLoaders.get(ext); if (default_loader != null and default_loader.?.isJavaScriptLikeOrJSON() or target_name.len > 0 and (target_name[0] == '.' or target_name[0] == '/' or std.fs.path.isAbsolute(target_name))) { diff --git a/src/cli/test_command.zig b/src/cli/test_command.zig index f9d036d2f2c23b..244083f4a8d261 100644 --- a/src/cli/test_command.zig +++ b/src/cli/test_command.zig @@ -83,7 +83,7 @@ fn escapeXml(str: string, writer: anytype) !void { try writer.writeAll(str[last..]); } } -fn fmtStatusTextLine(comptime status: @Type(.EnumLiteral), comptime emoji_or_color: bool) []const u8 { +fn fmtStatusTextLine(comptime status: @Type(.enum_literal), comptime emoji_or_color: bool) []const u8 { comptime { // emoji and color might be split into two different options in the future // some terminals support color, but not emoji. @@ -107,7 +107,7 @@ fn fmtStatusTextLine(comptime status: @Type(.EnumLiteral), comptime emoji_or_col } } -fn writeTestStatusLine(comptime status: @Type(.EnumLiteral), writer: anytype) void { +fn writeTestStatusLine(comptime status: @Type(.enum_literal), writer: anytype) void { if (Output.enable_ansi_colors_stderr) writer.print(fmtStatusTextLine(status, true), .{}) catch unreachable else @@ -271,9 +271,7 @@ pub const JunitReporter = struct { \\ ); - try this.contents.appendSlice(bun.default_allocator, - \\\n"); } diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig index 9c656a24c29e93..dc9204a14d0cbb 100644 --- a/src/cli/upgrade_command.zig +++ b/src/cli/upgrade_command.zig @@ -400,7 +400,7 @@ pub const UpgradeCommand = struct { }; pub fn exec(ctx: Command.Context) !void { - @setCold(true); + @branchHint(.cold); const args = bun.argv; if (args.len > 2) { diff --git a/src/codegen/bindgen.ts b/src/codegen/bindgen.ts index b3d8be92c67098..200dcf0caa6070 100644 --- a/src/codegen/bindgen.ts +++ b/src/codegen/bindgen.ts @@ -1485,7 +1485,7 @@ zigInternal.line("};"); zigInternal.line(); zigInternal.line("comptime {"); zigInternal.line(` if (bun.Environment.export_cpp_apis) {`); -zigInternal.line(" for (@typeInfo(binding_internals).Struct.decls) |decl| {"); +zigInternal.line(" for (@typeInfo(binding_internals).@\"struct\".decls) |decl| {"); zigInternal.line(" _ = &@field(binding_internals, decl.name);"); zigInternal.line(" }"); zigInternal.line(" }"); diff --git a/src/codegen/generate-classes.ts b/src/codegen/generate-classes.ts index 738ea2330c408b..8d8f01be847000 100644 --- a/src/codegen/generate-classes.ts +++ b/src/codegen/generate-classes.ts @@ -2064,7 +2064,7 @@ const JavaScriptCoreBindings = struct { ` }; comptime { -${[...exports.values()].map(name => ` @export(JavaScriptCoreBindings.${name}, .{ .name = "${name}" });`).join("\n")} +${[...exports.values()].map(name => ` @export(&JavaScriptCoreBindings.${name}, .{ .name = "${name}" });`).join("\n")} }` ); } diff --git a/src/codegen/generate-js2native.ts b/src/codegen/generate-js2native.ts index 7034c0b9852b6a..8b2f46bbd0527b 100644 --- a/src/codegen/generate-js2native.ts +++ b/src/codegen/generate-js2native.ts @@ -236,7 +236,7 @@ export function getJS2NativeZig(gs2NativeZigPath: string) { .flatMap(x => { const base = basename(x.filename.replace(/\.bind\.ts$/, "")); return [ - ` @export(bun.gen.${base}.create${cap(x.symbol)}Callback, .{ .name = ${JSON.stringify( + ` @export(&bun.gen.${base}.create${cap(x.symbol)}Callback, .{ .name = ${JSON.stringify( `js2native_bindgen_${base}_${x.symbol}`, )} });`, ]; diff --git a/src/copy_file.zig b/src/copy_file.zig index 220aeb773395e3..d254711b49badc 100644 --- a/src/copy_file.zig +++ b/src/copy_file.zig @@ -60,7 +60,7 @@ const CopyFileReturnType = bun.sys.Maybe(void); pub fn copyFileWithState(in: InputType, out: InputType, copy_file_state: *CopyFileState) CopyFileReturnType { if (comptime Environment.isMac) { - const rc = posix.system.fcopyfile(in, out, null, posix.system.COPYFILE_DATA); + const rc = posix.system.fcopyfile(in, out, null, posix.system.COPYFILE{ .DATA = true }); switch (posix.errno(rc)) { .SUCCESS => return CopyFileReturnType.success, diff --git a/src/crash_handler.zig b/src/crash_handler.zig index 6a1ae522b207bc..0692f384f2754d 100644 --- a/src/crash_handler.zig +++ b/src/crash_handler.zig @@ -178,7 +178,7 @@ pub fn crashHandler( error_return_trace: ?*std.builtin.StackTrace, begin_addr: ?usize, ) noreturn { - @setCold(true); + @branchHint(.cold); if (bun.Environment.isDebug) bun.Output.disableScopedDebugWriter(); @@ -275,11 +275,11 @@ pub fn crashHandler( } else switch (bun.Environment.os) { .windows => { var name: std.os.windows.PWSTR = undefined; - const result = bun.windows.GetThreadDescription(std.os.windows.kernel32.GetCurrentThread(), &name); + const result = bun.windows.GetThreadDescription(bun.windows.GetCurrentThread(), &name); if (std.os.windows.HRESULT_CODE(result) == .SUCCESS and name[0] != 0) { writer.print("({})", .{bun.fmt.utf16(bun.span(name))}) catch std.posix.abort(); } else { - writer.print("(thread {d})", .{std.os.windows.kernel32.GetCurrentThreadId()}) catch std.posix.abort(); + writer.print("(thread {d})", .{bun.windows.GetCurrentThreadId()}) catch std.posix.abort(); } }, .mac, .linux => {}, @@ -706,7 +706,7 @@ pub fn handleRootError(err: anyerror, error_return_trace: ?*std.builtin.StackTra } pub fn panicImpl(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, begin_addr: ?usize) noreturn { - @setCold(true); + @branchHint(.cold); crashHandler( if (bun.strings.eqlComptime(msg, "reached unreachable code")) .{ .@"unreachable" = {} } @@ -796,10 +796,10 @@ pub fn updatePosixSegfaultHandler(act: ?*std.posix.Sigaction) !void { } } - try std.posix.sigaction(std.posix.SIG.SEGV, act, null); - try std.posix.sigaction(std.posix.SIG.ILL, act, null); - try std.posix.sigaction(std.posix.SIG.BUS, act, null); - try std.posix.sigaction(std.posix.SIG.FPE, act, null); + std.posix.sigaction(std.posix.SIG.SEGV, act, null); + std.posix.sigaction(std.posix.SIG.ILL, act, null); + std.posix.sigaction(std.posix.SIG.BUS, act, null); + std.posix.sigaction(std.posix.SIG.FPE, act, null); } var windows_segfault_handle: ?windows.HANDLE = null; @@ -1146,19 +1146,19 @@ const StackLine = struct { fn callback(info: *std.posix.dl_phdr_info, _: usize, context: *CtxTy) !void { defer context.i += 1; - if (context.address < info.dlpi_addr) return; - const phdrs = info.dlpi_phdr[0..info.dlpi_phnum]; + if (context.address < info.addr) return; + const phdrs = info.phdr[0..info.phnum]; for (phdrs) |*phdr| { if (phdr.p_type != std.elf.PT_LOAD) continue; // Overflowing addition is used to handle the case of VSDOs // having a p_vaddr = 0xffffffffff700000 - const seg_start = info.dlpi_addr +% phdr.p_vaddr; + const seg_start = info.addr +% phdr.p_vaddr; const seg_end = seg_start + phdr.p_memsz; if (context.address >= seg_start and context.address < seg_end) { - // const name = bun.sliceTo(info.dlpi_name, 0) orelse ""; + // const name = bun.sliceTo(info.name, 0) orelse ""; context.result = .{ - .address = @intCast(context.address - info.dlpi_addr), + .address = @intCast(context.address - info.addr), .object = null, }; return error.Found; @@ -1470,7 +1470,7 @@ fn crash() noreturn { std.posix.SIG.HUP, std.posix.SIG.TERM, }) |sig| { - std.posix.sigaction(sig, &sigact, null) catch {}; + std.posix.sigaction(sig, &sigact, null); } @trap(); @@ -1481,7 +1481,7 @@ fn crash() noreturn { pub var verbose_error_trace = false; noinline fn coldHandleErrorReturnTrace(err_int_workaround_for_zig_ccall_bug: std.meta.Int(.unsigned, @bitSizeOf(anyerror)), trace: *std.builtin.StackTrace, comptime is_root: bool) void { - @setCold(true); + @branchHint(.cold); const err = @errorFromInt(err_int_workaround_for_zig_ccall_bug); // The format of the panic trace is slightly different in debug @@ -1582,9 +1582,7 @@ pub fn dumpStackTrace(trace: std.builtin.StackTrace) void { stderr.print("Unable to dump stack trace: Unable to open debug info: {s}\n", .{@errorName(err)}) catch return; break :attempt_dump; }; - var arena = bun.ArenaAllocator.init(bun.default_allocator); - defer arena.deinit(); - debug.writeStackTrace(trace, stderr, arena.allocator(), debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch |err| { + debug.writeStackTrace(trace, stderr, debug_info, std.io.tty.detectConfig(std.io.getStdErr())) catch |err| { stderr.print("Unable to dump stack trace: {s}\nFallback trace:\n", .{@errorName(err)}) catch return; break :attempt_dump; }; diff --git a/src/css/css_parser.zig b/src/css/css_parser.zig index 48a52dd51dd8a9..17a20262d6879c 100644 --- a/src/css/css_parser.zig +++ b/src/css/css_parser.zig @@ -243,6 +243,7 @@ pub const Location = css_rules.Location; pub const Error = Err(ParserError); pub fn Result(comptime T: type) type { + @setEvalBranchQuota(1_000_000); return Maybe(T, ParseError(ParserError)); } @@ -271,11 +272,11 @@ pub fn DefineListShorthand(comptime T: type) type { return struct {}; } -pub fn DefineShorthand(comptime T: type, comptime property_name: PropertyIdTag) type { +pub fn DefineShorthand(comptime T: type, comptime property_name: PropertyIdTag, comptime PropertyFieldMap: anytype) type { _ = property_name; // autofix // TODO: validate map, make sure each field is set // make sure each field is same index as in T - _ = T.PropertyFieldMap; + _ = PropertyFieldMap; return struct { /// Returns a shorthand from the longhand properties defined in the given declaration block. @@ -527,9 +528,9 @@ pub fn DefineSizeShorthand(comptime T: type, comptime V: type) type { pub fn DeriveParse(comptime T: type) type { const tyinfo = @typeInfo(T); - const is_union_enum = tyinfo == .Union; - const enum_type = if (comptime is_union_enum) @typeInfo(tyinfo.Union.tag_type.?) else tyinfo; - const enum_actual_type = if (comptime is_union_enum) tyinfo.Union.tag_type.? else T; + const is_union_enum = tyinfo == .@"union"; + const enum_type = if (comptime is_union_enum) @typeInfo(tyinfo.@"union".tag_type.?) else tyinfo; + const enum_actual_type = if (comptime is_union_enum) tyinfo.@"union".tag_type.? else T; const Map = bun.ComptimeEnumMap(enum_actual_type); @@ -541,7 +542,7 @@ pub fn DeriveParse(comptime T: type) type { var first_payload_index: ?usize = null; var payload_count: usize = 0; var void_count: usize = 0; - for (tyinfo.Union.fields, 0..) |field, i| { + for (tyinfo.@"union".fields, 0..) |field, i| { if (field.type == void) { void_count += 1; if (first_void_index == null) first_void_index = i; @@ -619,7 +620,7 @@ pub fn DeriveParse(comptime T: type) type { ) Result(T) { const last_payload_index = first_payload_index + payload_count - 1; if (comptime maybe_first_void_index == null) { - inline for (tyinfo.Union.fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { + inline for (tyinfo.@"union".fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { if (comptime (i == last_payload_index)) { return .{ .result = switch (generic.parseFor(field.type)(input)) { .result => |v| @unionInit(T, field.name, v), @@ -637,7 +638,7 @@ pub fn DeriveParse(comptime T: type) type { const void_fields = bun.meta.EnumFields(T)[first_void_index .. first_void_index + void_count]; if (comptime void_count == 1) { - const void_field = enum_type.Enum.fields[first_void_index]; + const void_field = enum_type.@"enum".fields[first_void_index]; // The field is declared before the payload fields. // So try to parse an ident matching the name of the field, then fallthrough // to parsing the payload fields. @@ -647,7 +648,7 @@ pub fn DeriveParse(comptime T: type) type { return .{ .result = @enumFromInt(void_field.value) }; } - inline for (tyinfo.Union.fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { + inline for (tyinfo.@"union".fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { if (comptime (i == last_payload_index and last_payload_index > first_void_index)) { return .{ .result = switch (generic.parseFor(field.type)(input)) { .result => |v| @unionInit(T, field.name, v), @@ -659,7 +660,7 @@ pub fn DeriveParse(comptime T: type) type { } } } else { - inline for (tyinfo.Union.fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { + inline for (tyinfo.@"union".fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { if (comptime (i == last_payload_index and last_payload_index > first_void_index)) { return .{ .result = switch (generic.parseFor(field.type)(input)) { .result => |v| @unionInit(T, field.name, v), @@ -692,7 +693,7 @@ pub fn DeriveParse(comptime T: type) type { input.reset(&state); } - inline for (tyinfo.Union.fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { + inline for (tyinfo.@"union".fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { if (comptime (i == last_payload_index and last_payload_index > first_void_index)) { return .{ .result = switch (generic.parseFor(field.type)(input)) { .result => |v| @unionInit(T, field.name, v), @@ -704,7 +705,7 @@ pub fn DeriveParse(comptime T: type) type { } } } else if (comptime first_void_index > first_payload_index) { - inline for (tyinfo.Union.fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { + inline for (tyinfo.@"union".fields[first_payload_index .. first_payload_index + payload_count], first_payload_index..) |field, i| { if (comptime (i == last_payload_index and last_payload_index > first_void_index)) { return .{ .result = switch (generic.parseFor(field.type)(input)) { .result => |v| @unionInit(T, field.name, v), @@ -742,7 +743,7 @@ pub fn DeriveParse(comptime T: type) type { // comptime payload_count: usize, // ) Result(T) { // const last_payload_index = first_payload_index + payload_count - 1; - // inline for (tyinfo.Union.fields[first_payload_index..], first_payload_index..) |field, i| { + // inline for (tyinfo.@"union".fields[first_payload_index..], first_payload_index..) |field, i| { // if (comptime (i == last_payload_index and last_payload_index > first_void_index)) { // return generic.parseFor(field.type)(input); // } @@ -773,24 +774,24 @@ pub fn DeriveParse(comptime T: type) type { pub fn DeriveToCss(comptime T: type) type { const tyinfo = @typeInfo(T); const enum_fields = bun.meta.EnumFields(T); - const is_enum_or_union_enum = tyinfo == .Union or tyinfo == .Enum; + const is_enum_or_union_enum = tyinfo == .@"union" or tyinfo == .@"enum"; return struct { pub fn toCss(this: *const T, comptime W: type, dest: *Printer(W)) PrintErr!void { if (comptime is_enum_or_union_enum) { inline for (std.meta.fields(T), 0..) |field, i| { if (@intFromEnum(this.*) == enum_fields[i].value) { - if (comptime tyinfo == .Enum or field.type == void) { + if (comptime tyinfo == .@"enum" or field.type == void) { return dest.writeStr(enum_fields[i].name); } else if (comptime generic.hasToCss(field.type)) { return generic.toCss(field.type, &@field(this, field.name), W, dest); - } else if (@hasDecl(field.type, "__generateToCss") and @typeInfo(field.type) == .Struct) { + } else if (@hasDecl(field.type, "__generateToCss") and @typeInfo(field.type) == .@"struct") { const variant_fields = std.meta.fields(field.type); if (variant_fields.len > 1) { const last = variant_fields.len - 1; inline for (variant_fields, 0..) |variant_field, j| { // Unwrap it from the optional - if (@typeInfo(variant_field.type) == .Optional) { + if (@typeInfo(variant_field.type) == .optional) { if (@field(@field(this, field.name), variant_field.name)) |*value| { try value.toCss(W, dest); } @@ -899,10 +900,7 @@ pub fn DefineEnumProperty(comptime T: type) type { }; } -pub fn DeriveValueType(comptime T: type) type { - _ = @typeInfo(T).Enum; - - const ValueTypeMap = T.ValueTypeMap; +pub fn DeriveValueType(comptime T: type, comptime ValueTypeMap: anytype) type { const field_values: []const MediaFeatureType = field_values: { const fields = std.meta.fields(T); var mapping: [fields.len]MediaFeatureType = undefined; @@ -927,7 +925,7 @@ pub fn DeriveValueType(comptime T: type) type { } fn consume_until_end_of_block(block_type: BlockType, tokenizer: *Tokenizer) void { - @setCold(true); + @branchHint(.cold); var stack = SmallList(BlockType, 16){}; stack.appendAssumeCapacity(block_type); @@ -4086,7 +4084,7 @@ pub const Delimiters = packed struct(u8) { const NONE: Delimiters = .{}; - pub fn getDelimiter(comptime tag: @TypeOf(.EnumLiteral)) Delimiters { + pub fn getDelimiter(comptime tag: @TypeOf(.enum_literal)) Delimiters { var empty = Delimiters{}; @field(empty, @tagName(tag)) = true; return empty; @@ -4440,7 +4438,7 @@ const Tokenizer = struct { // Any other valid case here already resulted in IDHash. '0'...'9', '-' => true, else => false, - }) break :brk .{ .hash = this.consumeName() }; + }) break :brk .{ .unrestrictedhash = this.consumeName() }; break :brk .{ .delim = '#' }; }, '$' => brk: { @@ -5012,7 +5010,7 @@ const Tokenizer = struct { // todo_stuff.match_byte switch (this.nextByteUnchecked()) { ' ', '\t', '\n', '\r', FORM_FEED_BYTE => { - var value = .{ .borrowed = this.sliceFrom(start_pos) }; + var value: CopyOnWriteStr = .{ .borrowed = this.sliceFrom(start_pos) }; return this.consumeUrlEnd(start_pos, &value); }, ')' => { @@ -5475,7 +5473,7 @@ const TokenKind = enum { /// A [``](https://drafts.csswg.org/css-syntax/#hash-token-diagram) with the type flag set to "unrestricted" /// /// The value does not include the `#` marker. - hash, + unrestrictedhash, /// A [``](https://drafts.csswg.org/css-syntax/#hash-token-diagram) with the type flag set to "id" /// @@ -5599,7 +5597,7 @@ pub const Token = union(TokenKind) { /// A [``](https://drafts.csswg.org/css-syntax/#hash-token-diagram) with the type flag set to "unrestricted" /// /// The value does not include the `#` marker. - hash: []const u8, + unrestrictedhash: []const u8, /// A [``](https://drafts.csswg.org/css-syntax/#hash-token-diagram) with the type flag set to "id" /// @@ -5718,7 +5716,7 @@ pub const Token = union(TokenKind) { inline .ident, .function, .at_keyword, - .hash, + .unrestrictedhash, .idhash, .quoted_string, .bad_string, @@ -5765,13 +5763,9 @@ pub const Token = union(TokenKind) { try writer.writeAll("@"); try serializer.serializeIdentifier(this.at_keyword, writer); }, - .hash => { - try writer.writeAll("#"); - try serializer.serializeName(this.hash, writer); - }, - .idhash => { + .unrestrictedhash, .idhash => |v| { try writer.writeAll("#"); - try serializer.serializeName(this.idhash, writer); + try serializer.serializeName(v, writer); }, .quoted_string => |x| { try serializer.serializeName(x, writer); @@ -5864,7 +5858,7 @@ pub const Token = union(TokenKind) { try dest.writeStr("@"); return serializer.serializeIdentifier(value, dest) catch return dest.addFmtError(); }, - .hash => |value| { + .unrestrictedhash => |value| { try dest.writeStr("#"); return serializer.serializeName(value, dest) catch return dest.addFmtError(); }, diff --git a/src/css/generics.zig b/src/css/generics.zig index 11cbcd50ceb5b6..9c7fbb3a230b81 100644 --- a/src/css/generics.zig +++ b/src/css/generics.zig @@ -45,15 +45,15 @@ pub inline fn implementDeepClone(comptime T: type, this: *const T, allocator: Al return this.*; } - if (comptime @typeInfo(T) == .Pointer) { + if (comptime @typeInfo(T) == .pointer) { const TT = std.meta.Child(T); return implementEql(TT, this.*); } return switch (tyinfo) { - .Struct => { + .@"struct" => { var strct: T = undefined; - inline for (tyinfo.Struct.fields) |field| { + inline for (tyinfo.@"struct".fields) |field| { if (comptime canTransitivelyImplementDeepClone(field.type) and @hasDecl(field.type, "__generateDeepClone")) { @field(strct, field.name) = implementDeepClone(field.type, &field(this, field.name, allocator)); } else { @@ -62,8 +62,8 @@ pub inline fn implementDeepClone(comptime T: type, this: *const T, allocator: Al } return strct; }, - .Union => { - inline for (bun.meta.EnumFields(T), tyinfo.Union.fields) |enum_field, union_field| { + .@"union" => { + inline for (bun.meta.EnumFields(T), tyinfo.@"union".fields) |enum_field, union_field| { if (@intFromEnum(this.*) == enum_field.value) { if (comptime canTransitivelyImplementDeepClone(union_field.type) and @hasDecl(union_field.type, "__generateDeepClone")) { return @unionInit(T, enum_field.name, implementDeepClone(union_field.type, &@field(this, enum_field.name), allocator)); @@ -97,11 +97,11 @@ pub fn implementEql(comptime T: type, this: *const T, other: *const T) bool { if (comptime T == []const u8) { return bun.strings.eql(this.*, other.*); } - if (comptime @typeInfo(T) == .Pointer) { + if (comptime @typeInfo(T) == .pointer) { const TT = std.meta.Child(T); return implementEql(TT, this.*, other.*); } - if (comptime @typeInfo(T) == .Optional) { + if (comptime @typeInfo(T) == .optional) { const TT = std.meta.Child(T); if (this.* != null and other.* != null) return implementEql(TT, &this.*.?, &other.*.?); return false; @@ -110,9 +110,9 @@ pub fn implementEql(comptime T: type, this: *const T, other: *const T) bool { return VendorPrefix.eql(this.*, other.*); } return switch (tyinfo) { - .Optional => @compileError("Handled above, this means Zack wrote a bug."), - .Pointer => @compileError("Handled above, this means Zack wrote a bug."), - .Array => { + .optional => @compileError("Handled above, this means Zack wrote a bug."), + .pointer => @compileError("Handled above, this means Zack wrote a bug."), + .array => { const Child = std.meta.Child(T); if (comptime bun.meta.isSimpleEqlType(Child)) { return std.mem.eql(Child, &this.*, &other.*); @@ -129,14 +129,14 @@ pub fn implementEql(comptime T: type, this: *const T, other: *const T) bool { } return true; }, - .Struct => { - inline for (tyinfo.Struct.fields) |field| { + .@"struct" => { + inline for (tyinfo.@"struct".fields) |field| { if (!eql(field.type, &@field(this, field.name), &@field(other, field.name))) return false; } return true; }, - .Union => { - if (tyinfo.Union.tag_type == null) @compileError("Unions must have a tag type"); + .@"union" => { + if (tyinfo.@"union".tag_type == null) @compileError("Unions must have a tag type"); if (@intFromEnum(this.*) != @intFromEnum(other.*)) return false; const enum_fields = bun.meta.EnumFields(T); inline for (enum_fields, std.meta.fields(T)) |enum_field, union_field| { @@ -171,42 +171,42 @@ pub fn implementHash(comptime T: type, this: *const T, hasher: *std.hash.Wyhash) }; bun.writeAnyToHasher(hasher, list.len); for (list) |*item| { - hash(tyinfo.Array.child, item, hasher); + hash(tyinfo.array.child, item, hasher); } return; } if (comptime T == []const u8) { return hasher.update(this.*); } - if (comptime @typeInfo(T) == .Pointer) { + if (comptime @typeInfo(T) == .pointer) { @compileError("Invalid type for implementHash(): " ++ @typeName(T)); } - if (comptime @typeInfo(T) == .Optional) { + if (comptime @typeInfo(T) == .optional) { @compileError("Invalid type for implementHash(): " ++ @typeName(T)); } return switch (tyinfo) { - .Optional => { + .optional => { if (this.* == null) { bun.writeAnyToHasher(hasher, "null"); } else { bun.writeAnyToHasher(hasher, "some"); - hash(tyinfo.Optional.child, &this.*.?, hasher); + hash(tyinfo.optional.child, &this.*.?, hasher); } }, - .Pointer => { - hash(tyinfo.Pointer.child, &this.*, hasher); + .pointer => { + hash(tyinfo.pointer.child, &this.*, hasher); }, - .Array => { + .array => { bun.writeAnyToHasher(hasher, this.len); for (this.*[0..]) |*item| { - hash(tyinfo.Array.child, item, hasher); + hash(tyinfo.array.child, item, hasher); } }, - .Struct => { - inline for (tyinfo.Struct.fields) |field| { + .@"struct" => { + inline for (tyinfo.@"struct".fields) |field| { if (comptime hasHash(field.type)) { hash(field.type, &@field(this, field.name), hasher); - } else if (@hasDecl(field.type, "__generateHash") and @typeInfo(field.type) == .Struct) { + } else if (@hasDecl(field.type, "__generateHash") and @typeInfo(field.type) == .@"struct") { implementHash(field.type, &@field(this, field.name), hasher); } else { @compileError("Can't hash these fields: " ++ @typeName(field.type) ++ ". On " ++ @typeName(T)); @@ -214,11 +214,11 @@ pub fn implementHash(comptime T: type, this: *const T, hasher: *std.hash.Wyhash) } return; }, - .Enum => { + .@"enum" => { bun.writeAnyToHasher(hasher, @intFromEnum(this.*)); }, - .Union => { - if (tyinfo.Union.tag_type == null) @compileError("Unions must have a tag type"); + .@"union" => { + if (tyinfo.@"union".tag_type == null) @compileError("Unions must have a tag type"); bun.writeAnyToHasher(hasher, @intFromEnum(this.*)); const enum_fields = bun.meta.EnumFields(T); inline for (enum_fields, std.meta.fields(T)) |enum_field, union_field| { @@ -226,7 +226,7 @@ pub fn implementHash(comptime T: type, this: *const T, hasher: *std.hash.Wyhash) const field = union_field; if (comptime hasHash(field.type)) { hash(field.type, &@field(this, field.name), hasher); - } else if (@hasDecl(field.type, "__generateHash") and @typeInfo(field.type) == .Struct) { + } else if (@hasDecl(field.type, "__generateHash") and @typeInfo(field.type) == .@"struct") { implementHash(field.type, &@field(this, field.name), hasher); } else { @compileError("Can't hash these fields: " ++ @typeName(field.type) ++ ". On " ++ @typeName(T)); @@ -253,7 +253,7 @@ pub fn slice(comptime T: type, val: *const T) []const bun.meta.looksLikeListCont pub fn isCompatible(comptime T: type, val: *const T, browsers: bun.css.targets.Browsers) bool { if (@hasDecl(T, "isCompatible")) return T.isCompatible(val, browsers); const tyinfo = @typeInfo(T); - if (tyinfo == .Pointer) { + if (tyinfo == .pointer) { const TT = std.meta.Child(T); return isCompatible(TT, val.*, browsers); } @@ -291,14 +291,14 @@ pub inline fn parseWithOptions(comptime T: type, input: *Parser, options: *const } pub inline fn parse(comptime T: type, input: *Parser) Result(T) { - if (comptime @typeInfo(T) == .Pointer) { + if (comptime @typeInfo(T) == .pointer) { const TT = std.meta.Child(T); return switch (parse(TT, input)) { .result => |v| .{ .result = bun.create(input.allocator(), TT, v) }, .err => |e| .{ .err = e }, }; } - if (comptime @typeInfo(T) == .Optional) { + if (comptime @typeInfo(T) == .optional) { const TT = std.meta.Child(T); return .{ .result = input.tryParse(parseFor(TT), .{}).asValue() }; } @@ -334,11 +334,11 @@ pub inline fn parseFor(comptime T: type) @TypeOf(struct { pub fn hasToCss(comptime T: type) bool { const tyinfo = @typeInfo(T); if (comptime T == []const u8) return false; - if (tyinfo == .Pointer) { + if (tyinfo == .pointer) { const TT = std.meta.Child(T); return hasToCss(TT); } - if (tyinfo == .Optional) { + if (tyinfo == .optional) { const TT = std.meta.Child(T); return hasToCss(TT); } @@ -356,11 +356,11 @@ pub fn hasToCss(comptime T: type) bool { } pub inline fn toCss(comptime T: type, this: *const T, comptime W: type, dest: *Printer(W)) PrintErr!void { - if (@typeInfo(T) == .Pointer) { + if (@typeInfo(T) == .pointer) { const TT = std.meta.Child(T); return toCss(TT, this.*, W, dest); } - if (@typeInfo(T) == .Optional) { + if (@typeInfo(T) == .optional) { const TT = std.meta.Child(T); if (this.*) |*val| { @@ -397,29 +397,30 @@ pub fn eqlList(comptime T: type, lhs: *const ArrayList(T), rhs: *const ArrayList pub fn canTransitivelyImplementEql(comptime T: type) bool { return switch (@typeInfo(T)) { - .Struct, .Union => true, + .@"struct", .@"union" => true, else => false, }; } pub inline fn eql(comptime T: type, lhs: *const T, rhs: *const T) bool { const tyinfo = comptime @typeInfo(T); - if (comptime tyinfo == .Pointer) { + @setEvalBranchQuota(10_000); + if (comptime tyinfo == .pointer) { if (comptime T == []const u8) return bun.strings.eql(lhs.*, rhs.*); - if (comptime tyinfo.Pointer.size == .One) { + if (comptime tyinfo.pointer.size == .one) { const TT = std.meta.Child(T); return eql(TT, lhs.*, rhs.*); - } else if (comptime tyinfo.Pointer.size == .Slice) { + } else if (comptime tyinfo.pointer.size == .slice) { if (lhs.*.len != rhs.*.len) return false; for (lhs.*[0..], rhs.*[0..]) |*a, *b| { - if (!eql(tyinfo.Pointer.child, a, b)) return false; + if (!eql(tyinfo.pointer.child, a, b)) return false; } return true; } else { - @compileError("Unsupported pointer size: " ++ @tagName(tyinfo.Pointer.size) ++ " (" ++ @typeName(T) ++ ")"); + @compileError("Unsupported pointer size: " ++ @tagName(tyinfo.pointer.size) ++ " (" ++ @typeName(T) ++ ")"); } } - if (comptime tyinfo == .Optional) { + if (comptime tyinfo == .optional) { const TT = std.meta.Child(T); if (lhs.* == null and rhs.* == null) return true; if (lhs.* != null and rhs.* != null) return eql(TT, &lhs.*.?, &rhs.*.?); @@ -450,32 +451,32 @@ pub inline fn eql(comptime T: type, lhs: *const T, rhs: *const T) bool { pub fn canTransitivelyImplementDeepClone(comptime T: type) bool { return switch (@typeInfo(T)) { - .Struct, .Union => true, + .@"struct", .@"union" => true, else => false, }; } pub inline fn deepClone(comptime T: type, this: *const T, allocator: Allocator) T { const tyinfo = comptime @typeInfo(T); - if (comptime tyinfo == .Pointer) { - if (comptime tyinfo.Pointer.size == .One) { + if (comptime tyinfo == .pointer) { + if (comptime tyinfo.pointer.size == .one) { const TT = std.meta.Child(T); return bun.create(allocator, TT, deepClone(TT, this.*, allocator)); } - if (comptime tyinfo.Pointer.size == .Slice) { - var slc = allocator.alloc(tyinfo.Pointer.child, this.len) catch bun.outOfMemory(); - if (comptime bun.meta.isSimpleCopyType(tyinfo.Pointer.child) or tyinfo.Pointer.child == []const u8) { + if (comptime tyinfo.pointer.size == .slice) { + var slc = allocator.alloc(tyinfo.pointer.child, this.len) catch bun.outOfMemory(); + if (comptime bun.meta.isSimpleCopyType(tyinfo.pointer.child) or tyinfo.pointer.child == []const u8) { @memcpy(slc, this.*); } else { for (this.*, 0..) |*e, i| { - slc[i] = deepClone(tyinfo.Pointer.child, e, allocator); + slc[i] = deepClone(tyinfo.pointer.child, e, allocator); } } return slc; } - @compileError("Deep clone not supported for this kind of pointer: " ++ @tagName(tyinfo.Pointer.size) ++ " (" ++ @typeName(T) ++ ")"); + @compileError("Deep clone not supported for this kind of pointer: " ++ @tagName(tyinfo.pointer.size) ++ " (" ++ @typeName(T) ++ ")"); } - if (comptime tyinfo == .Optional) { + if (comptime tyinfo == .optional) { const TT = std.meta.Child(T); if (this.* != null) return deepClone(TT, &this.*.?, allocator); return null; @@ -607,11 +608,11 @@ pub fn hasHash(comptime T: type) bool { const tyinfo = @typeInfo(T); if (comptime T == []const u8) return true; if (comptime bun.meta.isSimpleEqlType(T)) return true; - if (tyinfo == .Pointer) { + if (tyinfo == .pointer) { const TT = std.meta.Child(T); return hasHash(TT); } - if (tyinfo == .Optional) { + if (tyinfo == .optional) { const TT = std.meta.Child(T); return hasHash(TT); } @@ -630,11 +631,11 @@ pub fn hasHash(comptime T: type) bool { pub fn hash(comptime T: type, this: *const T, hasher: *std.hash.Wyhash) void { if (comptime T == void) return; const tyinfo = @typeInfo(T); - if (comptime tyinfo == .Pointer and T != []const u8) { + if (comptime tyinfo == .pointer and T != []const u8) { const TT = std.meta.Child(T); - if (tyinfo.Pointer.size == .One) { + if (tyinfo.pointer.size == .one) { return hash(TT, this.*, hasher); - } else if (tyinfo.Pointer.size == .Slice) { + } else if (tyinfo.pointer.size == .slice) { for (this.*) |*item| { hash(TT, item, hasher); } @@ -643,7 +644,7 @@ pub fn hash(comptime T: type, this: *const T, hasher: *std.hash.Wyhash) void { @compileError("Can't hash this pointer type: " ++ @typeName(T)); } } - if (comptime @typeInfo(T) == .Optional) { + if (comptime @typeInfo(T) == .optional) { const TT = std.meta.Child(T); if (this.* != null) return hash(TT, &this.*.?, hasher); return; diff --git a/src/css/media_query.zig b/src/css/media_query.zig index 25a5c58c619d4d..1f4980f42d7e95 100644 --- a/src/css/media_query.zig +++ b/src/css/media_query.zig @@ -708,7 +708,7 @@ pub const MediaFeatureId = enum { /// The non-standard -moz-device-pixel-ratio media feature. @"-moz-device-pixel-ratio", - pub usingnamespace css.DeriveValueType(@This()); + pub usingnamespace css.DeriveValueType(@This(), ValueTypeMap); pub const ValueTypeMap = .{ .width = MediaFeatureType.length, @@ -1510,7 +1510,7 @@ pub fn MediaFeatureName(comptime FeatureId: type) type { // this only works if FeatureId doesn't hold any references to the input string. // i.e. it is an enum comptime { - std.debug.assert(@typeInfo(FeatureId) == .Enum); + std.debug.assert(@typeInfo(FeatureId) == .@"enum"); } input.allocator().free(final_name); }; diff --git a/src/css/properties/align.zig b/src/css/properties/align.zig index af5fd00cb4d8a6..60e6a68eb357af 100644 --- a/src/css/properties/align.zig +++ b/src/css/properties/align.zig @@ -747,7 +747,7 @@ pub const Gap = struct { /// The column gap. column: GapValue, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.gap); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.gap, PropertyFieldMap); pub const PropertyFieldMap = .{ .row = "row-gap", @@ -790,7 +790,7 @@ pub const PlaceItems = struct { /// The item justification. justify: JustifyItems, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-items"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-items", PropertyFieldMap); pub const PropertyFieldMap = .{ .@"align" = "align-items", @@ -862,7 +862,7 @@ pub const PlaceSelf = struct { /// The item justification. justify: JustifySelf, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-self"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-self", PropertyFieldMap); pub const PropertyFieldMap = .{ .@"align" = "align-self", @@ -956,7 +956,7 @@ pub const PlaceContent = struct { /// The content justification. justify: JustifyContent, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-content"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"place-content", PropertyFieldMap); pub const PropertyFieldMap = .{ .@"align" = css.PropertyIdTag.@"align-content", diff --git a/src/css/properties/background.zig b/src/css/properties/background.zig index 2447a370fa6d68..2946f44b083bdc 100644 --- a/src/css/properties/background.zig +++ b/src/css/properties/background.zig @@ -524,63 +524,54 @@ pub const AspectRatio = struct { }; pub const BackgroundProperty = packed struct(u16) { - @"background-color": bool = false, - @"background-image": bool = false, - @"background-position-x": bool = false, - @"background-position-y": bool = false, - @"background-repeat": bool = false, - @"background-size": bool = false, - @"background-attachment": bool = false, - @"background-origin": bool = false, - @"background-clip": bool = false, + color: bool = false, + image: bool = false, + @"position-x": bool = false, + @"position-y": bool = false, + repeat: bool = false, + size: bool = false, + attachment: bool = false, + origin: bool = false, + clip: bool = false, __unused: u7 = 0, pub usingnamespace css.Bitflags(@This()); - pub const @"background-color" = BackgroundProperty{ .@"background-color" = true }; - pub const @"background-image" = BackgroundProperty{ .@"background-image" = true }; - pub const @"background-position-x" = BackgroundProperty{ .@"background-position-x" = true }; - pub const @"background-position-y" = BackgroundProperty{ .@"background-position-y" = true }; - pub const @"background-position" = BackgroundProperty{ .@"background-position-x" = true, .@"background-position-y" = true }; - pub const @"background-repeat" = BackgroundProperty{ .@"background-repeat" = true }; - pub const @"background-size" = BackgroundProperty{ .@"background-size" = true }; - pub const @"background-attachment" = BackgroundProperty{ .@"background-attachment" = true }; - pub const @"background-origin" = BackgroundProperty{ .@"background-origin" = true }; - pub const @"background-clip" = BackgroundProperty{ .@"background-clip" = true }; + pub const @"background-color" = BackgroundProperty{ .color = true }; + pub const @"background-image" = BackgroundProperty{ .image = true }; + pub const @"background-position-x" = BackgroundProperty{ .@"position-x" = true }; + pub const @"background-position-y" = BackgroundProperty{ .@"position-y" = true }; + pub const @"background-position" = BackgroundProperty{ .@"position-x" = true, .@"position-y" = true }; + pub const @"background-repeat" = BackgroundProperty{ .repeat = true }; + pub const @"background-size" = BackgroundProperty{ .size = true }; + pub const @"background-attachment" = BackgroundProperty{ .attachment = true }; + pub const @"background-origin" = BackgroundProperty{ .origin = true }; + pub const @"background-clip" = BackgroundProperty{ .clip = true }; + pub const background = BackgroundProperty{ - .@"background-color" = true, - .@"background-image" = true, - .@"background-position-x" = true, - .@"background-position-y" = true, - .@"background-repeat" = true, - .@"background-size" = true, - .@"background-attachment" = true, - .@"background-origin" = true, - .@"background-clip" = true, + .color = true, + .image = true, + .@"position-x" = true, + .@"position-y" = true, + .repeat = true, + .size = true, + .attachment = true, + .origin = true, + .clip = true, }; - pub fn fromPropertyId(property_id: css.PropertyId) ?BackgroundProperty { + pub fn tryFromPropertyId(property_id: css.PropertyId) ?BackgroundProperty { return switch (property_id) { - .@"background-color" => BackgroundProperty{ .@"background-color" = true }, - .@"background-image" => BackgroundProperty{ .@"background-image" = true }, - .@"background-position-x" => BackgroundProperty{ .@"background-position-x" = true }, - .@"background-position-y" => BackgroundProperty{ .@"background-position-y" = true }, - .@"background-position" => BackgroundProperty{ .@"background-position-x" = true, .@"background-position-y" = true }, - .@"background-repeat" => BackgroundProperty{ .@"background-repeat" = true }, - .@"background-size" => BackgroundProperty{ .@"background-size" = true }, - .@"background-attachment" => BackgroundProperty{ .@"background-attachment" = true }, - .@"background-origin" => BackgroundProperty{ .@"background-origin" = true }, - .background => BackgroundProperty{ - .@"background-color" = true, - .@"background-image" = true, - .@"background-position-x" = true, - .@"background-position-y" = true, - .@"background-repeat" = true, - .@"background-size" = true, - .@"background-attachment" = true, - .@"background-origin" = true, - .@"background-clip" = true, - }, + .@"background-color" => @"background-color", + .@"background-image" => @"background-image", + .@"background-position-x" => @"background-position-x", + .@"background-position-y" => @"background-position-y", + .@"background-position" => @"background-position", + .@"background-repeat" => @"background-repeat", + .@"background-size" => @"background-size", + .@"background-attachment" => @"background-attachment", + .@"background-origin" => @"background-origin", + .background => background, else => null, }; } @@ -726,7 +717,7 @@ pub const BackgroundHandler = struct { this.flush(allocator, dest, context); var unparsed = val.deepClone(allocator); context.addUnparsedFallbacks(&unparsed); - if (BackgroundProperty.fromPropertyId(val.property_id)) |prop| { + if (BackgroundProperty.tryFromPropertyId(val.property_id)) |prop| { this.flushed_properties.insert(prop); } diff --git a/src/css/properties/border.zig b/src/css/properties/border.zig index 091fb3ef0390a0..71a2137065c265 100644 --- a/src/css/properties/border.zig +++ b/src/css/properties/border.zig @@ -551,79 +551,79 @@ const BorderShorthand = struct { }; const BorderProperty = packed struct(u32) { - @"border-top-color": bool = false, - @"border-bottom-color": bool = false, - @"border-left-color": bool = false, - @"border-right-color": bool = false, - @"border-block-start-color": bool = false, - @"border-block-end-color": bool = false, - @"border-inline-start-color": bool = false, - @"border-inline-end-color": bool = false, - @"border-top-width": bool = false, - @"border-bottom-width": bool = false, - @"border-left-width": bool = false, - @"border-right-width": bool = false, - @"border-block-start-width": bool = false, - @"border-block-end-width": bool = false, - @"border-inline-start-width": bool = false, - @"border-inline-end-width": bool = false, - @"border-top-style": bool = false, - @"border-bottom-style": bool = false, - @"border-left-style": bool = false, - @"border-right-style": bool = false, - @"border-block-start-style": bool = false, - @"border-block-end-style": bool = false, - @"border-inline-start-style": bool = false, - @"border-inline-end-style": bool = false, + @"top-color": bool = false, + @"bottom-color": bool = false, + @"left-color": bool = false, + @"right-color": bool = false, + @"block-start-color": bool = false, + @"block-end-color": bool = false, + @"inline-start-color": bool = false, + @"inline-end-color": bool = false, + @"top-width": bool = false, + @"bottom-width": bool = false, + @"left-width": bool = false, + @"right-width": bool = false, + @"block-start-width": bool = false, + @"block-end-width": bool = false, + @"inline-start-width": bool = false, + @"inline-end-width": bool = false, + @"top-style": bool = false, + @"bottom-style": bool = false, + @"left-style": bool = false, + @"right-style": bool = false, + @"block-start-style": bool = false, + @"block-end-style": bool = false, + @"inline-start-style": bool = false, + @"inline-end-style": bool = false, __unused: u8 = 0, pub usingnamespace css.Bitflags(@This()); - const @"border-top-color" = BorderProperty{ .@"border-top-color" = true }; - const @"border-bottom-color" = BorderProperty{ .@"border-bottom-color" = true }; - const @"border-left-color" = BorderProperty{ .@"border-left-color" = true }; - const @"border-right-color" = BorderProperty{ .@"border-right-color" = true }; - const @"border-block-start-color" = BorderProperty{ .@"border-block-start-color" = true }; - const @"border-block-end-color" = BorderProperty{ .@"border-block-end-color" = true }; - const @"border-inline-start-color" = BorderProperty{ .@"border-inline-start-color" = true }; - const @"border-inline-end-color" = BorderProperty{ .@"border-inline-end-color" = true }; - const @"border-top-width" = BorderProperty{ .@"border-top-width" = true }; - const @"border-bottom-width" = BorderProperty{ .@"border-bottom-width" = true }; - const @"border-left-width" = BorderProperty{ .@"border-left-width" = true }; - const @"border-right-width" = BorderProperty{ .@"border-right-width" = true }; - const @"border-block-start-width" = BorderProperty{ .@"border-block-start-width" = true }; - const @"border-block-end-width" = BorderProperty{ .@"border-block-end-width" = true }; - const @"border-inline-start-width" = BorderProperty{ .@"border-inline-start-width" = true }; - const @"border-inline-end-width" = BorderProperty{ .@"border-inline-end-width" = true }; - const @"border-top-style" = BorderProperty{ .@"border-top-style" = true }; - const @"border-bottom-style" = BorderProperty{ .@"border-bottom-style" = true }; - const @"border-left-style" = BorderProperty{ .@"border-left-style" = true }; - const @"border-right-style" = BorderProperty{ .@"border-right-style" = true }; - const @"border-block-start-style" = BorderProperty{ .@"border-block-start-style" = true }; - const @"border-block-end-style" = BorderProperty{ .@"border-block-end-style" = true }; - const @"border-inline-start-style" = BorderProperty{ .@"border-inline-start-style" = true }; - const @"border-inline-end-style" = BorderProperty{ .@"border-inline-end-style" = true }; - - const @"border-block-color" = BorderProperty{ .@"border-block-start-color" = true, .@"border-block-end-color" = true }; - const @"border-inline-color" = BorderProperty{ .@"border-inline-start-color" = true, .@"border-inline-end-color" = true }; - const @"border-block-width" = BorderProperty{ .@"border-block-start-width" = true, .@"border-block-end-width" = true }; - const @"border-inline-width" = BorderProperty{ .@"border-inline-start-width" = true, .@"border-inline-end-width" = true }; - const @"border-block-style" = BorderProperty{ .@"border-block-start-style" = true, .@"border-block-end-style" = true }; - const @"border-inline-style" = BorderProperty{ .@"border-inline-start-style" = true, .@"border-inline-end-style" = true }; - const @"border-top" = BorderProperty{ .@"border-top-color" = true, .@"border-top-width" = true, .@"border-top-style" = true }; - const @"border-bottom" = BorderProperty{ .@"border-bottom-color" = true, .@"border-bottom-width" = true, .@"border-bottom-style" = true }; - const @"border-left" = BorderProperty{ .@"border-left-color" = true, .@"border-left-width" = true, .@"border-left-style" = true }; - const @"border-right" = BorderProperty{ .@"border-right-color" = true, .@"border-right-width" = true, .@"border-right-style" = true }; - const @"border-block-start" = BorderProperty{ .@"border-block-start-color" = true, .@"border-block-start-width" = true, .@"border-block-start-style" = true }; - const @"border-block-end" = BorderProperty{ .@"border-block-end-color" = true, .@"border-block-end-width" = true, .@"border-block-end-style" = true }; - const @"border-inline-start" = BorderProperty{ .@"border-inline-start-color" = true, .@"border-inline-start-width" = true, .@"border-inline-start-style" = true }; - const @"border-inline-end" = BorderProperty{ .@"border-inline-end-color" = true, .@"border-inline-end-width" = true, .@"border-inline-end-style" = true }; - const @"border-block" = BorderProperty{ .@"border-block-start-color" = true, .@"border-block-end-color" = true, .@"border-block-start-width" = true, .@"border-block-end-width" = true, .@"border-block-start-style" = true, .@"border-block-end-style" = true }; - const @"border-inline" = BorderProperty{ .@"border-inline-start-color" = true, .@"border-inline-end-color" = true, .@"border-inline-start-width" = true, .@"border-inline-end-width" = true, .@"border-inline-start-style" = true, .@"border-inline-end-style" = true }; - const @"border-width" = BorderProperty{ .@"border-left-width" = true, .@"border-right-width" = true, .@"border-top-width" = true, .@"border-bottom-width" = true }; - const @"border-style" = BorderProperty{ .@"border-left-style" = true, .@"border-right-style" = true, .@"border-top-style" = true, .@"border-bottom-style" = true }; - const @"border-color" = BorderProperty{ .@"border-left-color" = true, .@"border-right-color" = true, .@"border-top-color" = true, .@"border-bottom-color" = true }; - const border = BorderProperty{ .@"border-left-width" = true, .@"border-right-width" = true, .@"border-top-width" = true, .@"border-bottom-width" = true, .@"border-left-style" = true, .@"border-right-style" = true, .@"border-top-style" = true, .@"border-bottom-style" = true, .@"border-left-color" = true, .@"border-right-color" = true, .@"border-top-color" = true, .@"border-bottom-color" = true }; + const @"border-top-color" = BorderProperty{ .@"top-color" = true }; + const @"border-bottom-color" = BorderProperty{ .@"bottom-color" = true }; + const @"border-left-color" = BorderProperty{ .@"left-color" = true }; + const @"border-right-color" = BorderProperty{ .@"right-color" = true }; + const @"border-block-start-color" = BorderProperty{ .@"block-start-color" = true }; + const @"border-block-end-color" = BorderProperty{ .@"block-end-color" = true }; + const @"border-inline-start-color" = BorderProperty{ .@"inline-start-color" = true }; + const @"border-inline-end-color" = BorderProperty{ .@"inline-end-color" = true }; + const @"border-top-width" = BorderProperty{ .@"top-width" = true }; + const @"border-bottom-width" = BorderProperty{ .@"bottom-width" = true }; + const @"border-left-width" = BorderProperty{ .@"left-width" = true }; + const @"border-right-width" = BorderProperty{ .@"right-width" = true }; + const @"border-block-start-width" = BorderProperty{ .@"block-start-width" = true }; + const @"border-block-end-width" = BorderProperty{ .@"block-end-width" = true }; + const @"border-inline-start-width" = BorderProperty{ .@"inline-start-width" = true }; + const @"border-inline-end-width" = BorderProperty{ .@"inline-end-width" = true }; + const @"border-top-style" = BorderProperty{ .@"top-style" = true }; + const @"border-bottom-style" = BorderProperty{ .@"bottom-style" = true }; + const @"border-left-style" = BorderProperty{ .@"left-style" = true }; + const @"border-right-style" = BorderProperty{ .@"right-style" = true }; + const @"border-block-start-style" = BorderProperty{ .@"block-start-style" = true }; + const @"border-block-end-style" = BorderProperty{ .@"block-end-style" = true }; + const @"border-inline-start-style" = BorderProperty{ .@"inline-start-style" = true }; + const @"border-inline-end-style" = BorderProperty{ .@"inline-end-style" = true }; + + const @"border-block-color" = BorderProperty{ .@"block-start-color" = true, .@"block-end-color" = true }; + const @"border-inline-color" = BorderProperty{ .@"inline-start-color" = true, .@"inline-end-color" = true }; + const @"border-block-width" = BorderProperty{ .@"block-start-width" = true, .@"block-end-width" = true }; + const @"border-inline-width" = BorderProperty{ .@"inline-start-width" = true, .@"inline-end-width" = true }; + const @"border-block-style" = BorderProperty{ .@"block-start-style" = true, .@"block-end-style" = true }; + const @"border-inline-style" = BorderProperty{ .@"inline-start-style" = true, .@"inline-end-style" = true }; + const @"border-top" = BorderProperty{ .@"top-color" = true, .@"top-width" = true, .@"top-style" = true }; + const @"border-bottom" = BorderProperty{ .@"bottom-color" = true, .@"bottom-width" = true, .@"bottom-style" = true }; + const @"border-left" = BorderProperty{ .@"left-color" = true, .@"left-width" = true, .@"left-style" = true }; + const @"border-right" = BorderProperty{ .@"right-color" = true, .@"right-width" = true, .@"right-style" = true }; + const @"border-block-start" = BorderProperty{ .@"block-start-color" = true, .@"block-start-width" = true, .@"block-start-style" = true }; + const @"border-block-end" = BorderProperty{ .@"block-end-color" = true, .@"block-end-width" = true, .@"block-end-style" = true }; + const @"border-inline-start" = BorderProperty{ .@"inline-start-color" = true, .@"inline-start-width" = true, .@"inline-start-style" = true }; + const @"border-inline-end" = BorderProperty{ .@"inline-end-color" = true, .@"inline-end-width" = true, .@"inline-end-style" = true }; + const @"border-block" = BorderProperty{ .@"block-start-color" = true, .@"block-end-color" = true, .@"block-start-width" = true, .@"block-end-width" = true, .@"block-start-style" = true, .@"block-end-style" = true }; + const @"border-inline" = BorderProperty{ .@"inline-start-color" = true, .@"inline-end-color" = true, .@"inline-start-width" = true, .@"inline-end-width" = true, .@"inline-start-style" = true, .@"inline-end-style" = true }; + const @"border-width" = BorderProperty{ .@"left-width" = true, .@"right-width" = true, .@"top-width" = true, .@"bottom-width" = true }; + const @"border-style" = BorderProperty{ .@"left-style" = true, .@"right-style" = true, .@"top-style" = true, .@"bottom-style" = true }; + const @"border-color" = BorderProperty{ .@"left-color" = true, .@"right-color" = true, .@"top-color" = true, .@"bottom-color" = true }; + const border = BorderProperty{ .@"left-width" = true, .@"right-width" = true, .@"top-width" = true, .@"bottom-width" = true, .@"left-style" = true, .@"right-style" = true, .@"top-style" = true, .@"bottom-style" = true, .@"left-color" = true, .@"right-color" = true, .@"top-color" = true, .@"bottom-color" = true }; pub fn tryFromPropertyId(property_id: css.PropertyIdTag) ?@This() { @setEvalBranchQuota(10000); diff --git a/src/css/properties/border_image.zig b/src/css/properties/border_image.zig index 6d21e1e25ff68d..e47112e513714e 100644 --- a/src/css/properties/border_image.zig +++ b/src/css/properties/border_image.zig @@ -40,7 +40,7 @@ pub const BorderImage = struct { /// How the border image is scaled and tiled. repeat: BorderImageRepeat, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-image"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-image", PropertyFieldMap); pub const PropertyFieldMap = .{ .source = css.PropertyIdTag.@"border-image-source", @@ -393,33 +393,33 @@ pub const BorderImageSlice = struct { }; pub const BorderImageProperty = packed struct(u8) { - @"border-image-source": bool = false, - @"border-image-slice": bool = false, - @"border-image-width": bool = false, - @"border-image-outset": bool = false, - @"border-image-repeat": bool = false, + source: bool = false, + slice: bool = false, + width: bool = false, + outset: bool = false, + repeat: bool = false, __unused: u3 = 0, - pub const @"border-image-source" = BorderImageProperty{ .@"border-image-source" = true }; - pub const @"border-image-slice" = BorderImageProperty{ .@"border-image-slice" = true }; - pub const @"border-image-width" = BorderImageProperty{ .@"border-image-width" = true }; - pub const @"border-image-outset" = BorderImageProperty{ .@"border-image-outset" = true }; - pub const @"border-image-repeat" = BorderImageProperty{ .@"border-image-repeat" = true }; + pub const @"border-image-source" = BorderImageProperty{ .source = true }; + pub const @"border-image-slice" = BorderImageProperty{ .slice = true }; + pub const @"border-image-width" = BorderImageProperty{ .width = true }; + pub const @"border-image-outset" = BorderImageProperty{ .outset = true }; + pub const @"border-image-repeat" = BorderImageProperty{ .repeat = true }; pub usingnamespace css.Bitflags(@This()); pub const @"border-image" = BorderImageProperty{ - .@"border-image-source" = true, - .@"border-image-slice" = true, - .@"border-image-width" = true, - .@"border-image-outset" = true, - .@"border-image-repeat" = true, + .source = true, + .slice = true, + .width = true, + .outset = true, + .repeat = true, }; pub fn tryFromPropertyId(property_id: css.PropertyIdTag) ?BorderImageProperty { inline for (std.meta.fields(BorderImageProperty)) |field| { if (comptime std.mem.eql(u8, field.name, "__unused")) continue; - const desired = comptime @field(css.PropertyIdTag, field.name); + const desired = comptime @field(css.PropertyIdTag, "border-image-" ++ field.name); if (desired == property_id) { var result: BorderImageProperty = .{}; @field(result, field.name) = true; @@ -599,7 +599,7 @@ pub const BorderImageHandler = struct { this.flushed_properties.insert(BorderImageProperty.@"border-image"); } else { if (source) |*mut_source| { - if (!this.flushed_properties.contains(BorderImageProperty{ .@"border-image-source" = true })) { + if (!this.flushed_properties.contains(BorderImageProperty.@"border-image-source")) { for (mut_source.getFallbacks(allocator, context.targets).slice()) |fallback| { dest.append(allocator, Property{ .@"border-image-source" = fallback }) catch bun.outOfMemory(); } diff --git a/src/css/properties/border_radius.zig b/src/css/properties/border_radius.zig index d2c9843c24309b..ec35e73618d1f0 100644 --- a/src/css/properties/border_radius.zig +++ b/src/css/properties/border_radius.zig @@ -38,7 +38,7 @@ pub const BorderRadius = struct { /// The x and y radius values for the bottom left corner. bottom_left: Size2D(LengthPercentage), - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-radius"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"border-radius", PropertyFieldMap); pub const PropertyFieldMap = .{ .top_left = "border-top-left-radius", diff --git a/src/css/properties/custom.zig b/src/css/properties/custom.zig index c94ed570fdd6d7..d955f6566704f4 100644 --- a/src/css/properties/custom.zig +++ b/src/css/properties/custom.zig @@ -462,9 +462,9 @@ pub const TokenList = struct { } continue; }, - .hash, .idhash => { + .unrestrictedhash, .idhash => { const h = switch (tok.*) { - .hash => |h| h, + .unrestrictedhash => |h| h, .idhash => |h| h, else => unreachable, }; @@ -472,7 +472,7 @@ pub const TokenList = struct { const r, const g, const b, const a = css.color.parseHashColor(h) orelse { tokens.append( input.allocator(), - .{ .token = .{ .hash = h } }, + .{ .token = .{ .unrestrictedhash = h } }, ) catch unreachable; break :brk; }; diff --git a/src/css/properties/display.zig b/src/css/properties/display.zig index eba2fee7cdf464..3671d346fe556a 100644 --- a/src/css/properties/display.zig +++ b/src/css/properties/display.zig @@ -241,14 +241,14 @@ pub const DisplayInside = union(enum) { const displayInsideMap = bun.ComptimeStringMap(DisplayInside, .{ .{ "flow", DisplayInside.flow }, .{ "flow-root", DisplayInside.flow_root }, - .{ "table", .table }, - .{ "flex", .{ .flex = css.VendorPrefix{ .none = true } } }, - .{ "-webkit-flex", .{ .flex = css.VendorPrefix{ .webkit = true } } }, - .{ "-ms-flexbox", .{ .flex = css.VendorPrefix{ .ms = true } } }, - .{ "-webkit-box", .{ .box = css.VendorPrefix{ .webkit = true } } }, - .{ "-moz-box", .{ .box = css.VendorPrefix{ .moz = true } } }, - .{ "grid", .grid }, - .{ "ruby", .ruby }, + .{ "table", DisplayInside.table }, + .{ "flex", DisplayInside{ .flex = css.VendorPrefix{ .none = true } } }, + .{ "-webkit-flex", DisplayInside{ .flex = css.VendorPrefix{ .webkit = true } } }, + .{ "-ms-flexbox", DisplayInside{ .flex = css.VendorPrefix{ .ms = true } } }, + .{ "-webkit-box", DisplayInside{ .box = css.VendorPrefix{ .webkit = true } } }, + .{ "-moz-box", DisplayInside{ .box = css.VendorPrefix{ .moz = true } } }, + .{ "grid", DisplayInside.grid }, + .{ "ruby", DisplayInside.ruby }, }); const location = input.currentSourceLocation(); diff --git a/src/css/properties/flex.zig b/src/css/properties/flex.zig index 57412f121bdecd..c63f7597026dd9 100644 --- a/src/css/properties/flex.zig +++ b/src/css/properties/flex.zig @@ -94,7 +94,7 @@ pub const FlexFlow = struct { /// How the flex items wrap. wrap: FlexWrap, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"flex-flow"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"flex-flow", PropertyFieldMap); pub const PropertyFieldMap = .{ .direction = css.PropertyIdTag.@"flex-direction", @@ -170,7 +170,7 @@ pub const Flex = struct { /// The flex basis. basis: LengthPercentageOrAuto, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.flex); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.flex, PropertyFieldMap); pub const PropertyFieldMap = .{ .grow = css.PropertyIdTag.@"flex-grow", diff --git a/src/css/properties/font.zig b/src/css/properties/font.zig index 80af832a245af5..93935b9228af29 100644 --- a/src/css/properties/font.zig +++ b/src/css/properties/font.zig @@ -608,7 +608,7 @@ pub const Font = struct { /// How the text should be capitalized. Only CSS 2.1 values are supported. variant_caps: FontVariantCaps, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.font); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.font, PropertyFieldMap); pub const PropertyFieldMap = .{ .family = css.PropertyIdTag.@"font-family", diff --git a/src/css/properties/masking.zig b/src/css/properties/masking.zig index cf192d97e7abb0..84062e63f9f5be 100644 --- a/src/css/properties/masking.zig +++ b/src/css/properties/masking.zig @@ -427,7 +427,7 @@ pub const MaskBorder = struct { /// How the mask image is interpreted. mode: MaskBorderMode, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"mask-border"); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.@"mask-border", PropertyFieldMap); pub const PropertyFieldMap = .{ .source = css.PropertyIdTag.@"mask-border-source", diff --git a/src/css/properties/transition.zig b/src/css/properties/transition.zig index 4c7d5b5c31f3d7..c2acd1a3fd923c 100644 --- a/src/css/properties/transition.zig +++ b/src/css/properties/transition.zig @@ -52,7 +52,7 @@ pub const Transition = struct { /// The easing function for the transition. timing_function: EasingFunction, - pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.transition); + pub usingnamespace css.DefineShorthand(@This(), css.PropertyIdTag.transition, PropertyFieldMap); pub usingnamespace css.DefineListShorthand(@This()); pub const PropertyFieldMap = .{ diff --git a/src/css/rules/container.zig b/src/css/rules/container.zig index 13a11ca966d708..13d7203b26e7fe 100644 --- a/src/css/rules/container.zig +++ b/src/css/rules/container.zig @@ -62,7 +62,7 @@ pub const ContainerSizeFeatureId = enum { /// The [orientation](https://w3c.github.io/csswg-drafts/css-contain-3/#orientation) size container feature. orientation, - pub usingnamespace css.DeriveValueType(@This()); + pub usingnamespace css.DeriveValueType(@This(), ValueTypeMap); pub const ValueTypeMap = .{ .width = css.MediaFeatureType.length, @@ -141,7 +141,7 @@ pub const StyleQuery = union(enum) { if (input.expectColon().asErr()) |e| return .{ .err = e }; input.skipWhitespace(); const opts = css.ParserOptions.default(input.allocator(), null); - const feature = .{ + const feature: StyleQuery = .{ .feature = switch (css.Property.parse( property_id, input, diff --git a/src/css/selectors/parser.zig b/src/css/selectors/parser.zig index 88a811a4b934d7..135b45bc437e75 100644 --- a/src/css/selectors/parser.zig +++ b/src/css/selectors/parser.zig @@ -2153,10 +2153,6 @@ pub fn NthOfSelectorData(comptime Impl: type) type { pub fn nthData(this: *const @This()) NthSelectorData { return this.data; } - - pub fn selectors(this: *const @This()) []GenericSelector(Impl) { - return this.selectors; - } }; } diff --git a/src/css/small_list.zig b/src/css/small_list.zig index d2749f79139ddc..e433f503c2a3cf 100644 --- a/src/css/small_list.zig +++ b/src/css/small_list.zig @@ -575,7 +575,7 @@ pub fn SmallList(comptime T: type, comptime N: comptime_int) type { } fn reserveOneUnchecked(this: *@This(), allocator: Allocator) void { - @setCold(true); + @branchHint(.cold); bun.assert(this.len() == this.capacity); const new_cap = growCapacity(this.capacity, this.len() + 1); this.tryGrow(allocator, new_cap); diff --git a/src/css/values/color.zig b/src/css/values/color.zig index e742af54b745c7..01ef1cf9c1c7db 100644 --- a/src/css/values/color.zig +++ b/src/css/values/color.zig @@ -262,7 +262,7 @@ pub const CssColor = union(enum) { }; switch (token.*) { - .hash, .idhash => |v| { + .unrestrictedhash, .idhash => |v| { const r, const g, const b, const a = css.color.parseHashColor(v) orelse return .{ .err = location.newUnexpectedTokenError(token.*) }; return .{ .result = .{ .rgba = RGBA.new(r, g, b, a), @@ -1621,7 +1621,7 @@ pub const LAB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -1651,7 +1651,7 @@ pub const SRGB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1691,7 +1691,7 @@ pub const HSL = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace HslHwbColorGamut(@This(), "s", "l"); @@ -1735,7 +1735,7 @@ pub const HWB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace HslHwbColorGamut(@This(), "w", "b"); @@ -1774,7 +1774,7 @@ pub const SRGBLinear = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1804,7 +1804,7 @@ pub const P3 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1828,7 +1828,7 @@ pub const A98 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1852,7 +1852,7 @@ pub const ProPhoto = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1876,7 +1876,7 @@ pub const Rec2020 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace BoundedColorGamut(@This()); @@ -1900,7 +1900,7 @@ pub const XYZd50 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -1927,7 +1927,7 @@ pub const XYZd65 = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -1957,7 +1957,7 @@ pub const LCH = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -1985,7 +1985,7 @@ pub const OKLAB = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -2015,7 +2015,7 @@ pub const OKLCH = struct { /// The alpha component. alpha: f32, - pub usingnamespace DefineColorspace(@This()); + pub usingnamespace DefineColorspace(@This(), ChannelTypeMap); pub usingnamespace ColorspaceConversions(@This()); pub usingnamespace UnboundedColorGamut(@This()); @@ -3037,12 +3037,7 @@ pub fn ColorspaceConversions(comptime T: type) type { }; } -pub fn DefineColorspace(comptime T: type) type { - if (!@hasDecl(T, "ChannelTypeMap")) { - @compileError("A Colorspace must define a ChannelTypeMap"); - } - const ChannelTypeMap = T.ChannelTypeMap; - +pub fn DefineColorspace(comptime T: type, comptime ChannelTypeMap: anytype) type { const fields: []const std.builtin.Type.StructField = std.meta.fields(T); const a = fields[0].name; const b = fields[1].name; diff --git a/src/css/values/length.zig b/src/css/values/length.zig index a4e1a0989e7cc5..b256a0c463700e 100644 --- a/src/css/values/length.zig +++ b/src/css/values/length.zig @@ -355,7 +355,7 @@ pub const LengthValue = union(enum) { } pub fn sign(this: *const @This()) f32 { - const enum_fields = @typeInfo(@typeInfo(@This()).Union.tag_type.?).Enum.fields; + const enum_fields = @typeInfo(@typeInfo(@This()).@"union".tag_type.?).@"enum".fields; inline for (std.meta.fields(@This()), 0..) |field, i| { if (enum_fields[i].value == @intFromEnum(this.*)) { return css.signfns.signF32(@field(this, field.name)); @@ -379,7 +379,7 @@ pub const LengthValue = union(enum) { } pub fn toUnitValue(this: *const @This()) struct { CSSNumber, []const u8 } { - const enum_fields = @typeInfo(@typeInfo(@This()).Union.tag_type.?).Enum.fields; + const enum_fields = @typeInfo(@typeInfo(@This()).@"union".tag_type.?).@"enum".fields; inline for (std.meta.fields(@This()), 0..) |field, i| { if (enum_fields[i].value == @intFromEnum(this.*)) { return .{ @field(this, field.name), field.name }; diff --git a/src/darwin_c.zig b/src/darwin_c.zig index b74dabc73818fe..acbcf178544d6f 100644 --- a/src/darwin_c.zig +++ b/src/darwin_c.zig @@ -150,9 +150,9 @@ pub const stat = blk: { // else => Kind.Unknown, // }, // }, -// .atime = @as(i128, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, -// .mtime = @as(i128, mtime.tv_sec) * std.time.ns_per_s + mtime.tv_nsec, -// .ctime = @as(i128, ctime.tv_sec) * std.time.ns_per_s + ctime.tv_nsec, +// .atime = @as(i128, atime.sec) * std.time.ns_per_s + atime.nsec, +// .mtime = @as(i128, mtime.sec) * std.time.ns_per_s + mtime.nsec, +// .ctime = @as(i128, ctime.sec) * std.time.ns_per_s + ctime.nsec, // }; // } @@ -487,7 +487,7 @@ pub fn getSystemUptime() u64 { else => return 0, }; - return @intCast(std.time.timestamp() - boot_time.tv_sec); + return @intCast(std.time.timestamp() - boot_time.sec); } pub fn getSystemLoadavg() [3]f64 { diff --git a/src/defines.zig b/src/defines.zig index f038248505ab35..f61508f3056cc7 100644 --- a/src/defines.zig +++ b/src/defines.zig @@ -85,7 +85,7 @@ pub const DefineData = struct { } pub fn fromMergeableInputEntry(user_defines: *UserDefines, key: []const u8, value_str: []const u8, value_is_undefined: bool, method_call_must_be_replaced_with_undefined: bool, log: *logger.Log, allocator: std.mem.Allocator) !void { - var keySplitter = std.mem.split(u8, key, "."); + var keySplitter = std.mem.splitScalar(u8, key, '.'); while (keySplitter.next()) |part| { if (!js_lexer.isIdentifier(part)) { if (strings.eql(part, key)) { @@ -98,7 +98,7 @@ pub const DefineData = struct { } // check for nested identifiers - var valueSplitter = std.mem.split(u8, value_str, "."); + var valueSplitter = std.mem.splitScalar(u8, value_str, '.'); var isIdent = true; while (valueSplitter.next()) |part| { @@ -217,7 +217,7 @@ pub const Define = struct { const remainder = key[0..last_dot]; const count = std.mem.count(u8, remainder, ".") + 1; var parts = try allocator.alloc(string, count + 1); - var splitter = std.mem.split(u8, remainder, "."); + var splitter = std.mem.splitScalar(u8, remainder, '.'); var i: usize = 0; while (splitter.next()) |split| : (i += 1) { parts[i] = split; diff --git a/src/deps/boringssl.translated.zig b/src/deps/boringssl.translated.zig index 60460ab810fcb7..dd88fbfd987c5b 100644 --- a/src/deps/boringssl.translated.zig +++ b/src/deps/boringssl.translated.zig @@ -18791,7 +18791,7 @@ pub extern fn ERR_get_next_error_library() c_int; pub const struct_bio_st = extern struct { method: [*c]const BIO_METHOD, - init: c_int, + _init: c_int, shutdown: c_int, flags: c_int, retry_reason: c_int, diff --git a/src/deps/c_ares.zig b/src/deps/c_ares.zig index 09c365a34c8614..5f8b945fae31b8 100644 --- a/src/deps/c_ares.zig +++ b/src/deps/c_ares.zig @@ -1433,7 +1433,7 @@ pub const struct_any_reply = struct { pub fn toJS(this: *struct_any_reply, globalThis: *JSC.JSGlobalObject, allocator: std.mem.Allocator) JSC.JSValue { const array = JSC.JSValue.createEmptyArray(globalThis, blk: { var len: usize = 0; - inline for (comptime @typeInfo(struct_any_reply).Struct.fields) |field| { + inline for (comptime @typeInfo(struct_any_reply).@"struct".fields) |field| { if (comptime std.mem.endsWith(u8, field.name, "_reply")) { len += @intFromBool(@field(this, field.name) != null); } @@ -1443,7 +1443,7 @@ pub const struct_any_reply = struct { var i: u32 = 0; - inline for (comptime @typeInfo(struct_any_reply).Struct.fields) |field| { + inline for (comptime @typeInfo(struct_any_reply).@"struct".fields) |field| { if (comptime std.mem.endsWith(u8, field.name, "_reply")) { if (@field(this, field.name)) |reply| { const lookup_name = comptime field.name[0 .. field.name.len - "_reply".len]; @@ -1561,7 +1561,7 @@ pub const struct_any_reply = struct { } pub fn deinit(this: *struct_any_reply) void { - inline for (@typeInfo(struct_any_reply).Struct.fields) |field| { + inline for (@typeInfo(struct_any_reply).@"struct".fields) |field| { if (comptime std.mem.endsWith(u8, field.name, "_reply")) { if (@field(this, field.name)) |reply| { reply.deinit(); @@ -1993,7 +1993,7 @@ pub const ares_addr_port_node = struct_ares_addr_port_node; comptime { const Bun__canonicalizeIP = JSC.toJSHostFunction(Bun__canonicalizeIP_); - @export(Bun__canonicalizeIP, .{ .name = "Bun__canonicalizeIP" }); + @export(&Bun__canonicalizeIP, .{ .name = "Bun__canonicalizeIP" }); } pub fn Bun__canonicalizeIP_(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { JSC.markBinding(@src()); diff --git a/src/deps/libuv.zig b/src/deps/libuv.zig index a07f095a2615ec..011be6e3823f35 100644 --- a/src/deps/libuv.zig +++ b/src/deps/libuv.zig @@ -2023,20 +2023,20 @@ pub const UV_CLOCK_MONOTONIC: c_int = 0; pub const UV_CLOCK_REALTIME: c_int = 1; pub const uv_clock_id = c_uint; pub const uv_timespec_t = extern struct { - tv_sec: c_long, - tv_nsec: c_long, + sec: c_long, + nsec: c_long, }; pub const uv_timespec64_t = extern struct { - tv_sec: i64, - tv_nsec: i32, + sec: i64, + nsec: i32, }; pub const uv_timeval_t = extern struct { - tv_sec: c_long, - tv_usec: c_long, + sec: c_long, + usec: c_long, }; pub const uv_timeval64_t = extern struct { - tv_sec: i64, - tv_usec: i32, + sec: i64, + usec: i32, }; pub const uv_stat_t = extern struct { dev: u64, diff --git a/src/deps/uws.zig b/src/deps/uws.zig index f5d364def2a929..f36ed289b36362 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -1798,8 +1798,8 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type { /// # Returns /// This function returns a slice of the buffer on success, or null on failure. pub fn localAddressText(this: ThisSocket, buf: []u8, is_ipv6: *bool) ?[]const u8 { - const addr_v4_len = @sizeOf(std.meta.FieldType(std.posix.sockaddr.in, .addr)); - const addr_v6_len = @sizeOf(std.meta.FieldType(std.posix.sockaddr.in6, .addr)); + const addr_v4_len = @sizeOf(@FieldType(std.posix.sockaddr.in, "addr")); + const addr_v6_len = @sizeOf(@FieldType(std.posix.sockaddr.in6, "addr")); var sa_buf: [addr_v6_len + 1]u8 = undefined; const binary = this.localAddressBinary(&sa_buf) orelse return null; @@ -2104,23 +2104,23 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type { } }; - if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) + if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .null) us_socket_context_on_open(ssl_int, ctx, SocketHandler.on_open); - if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) + if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .null) us_socket_context_on_close(ssl_int, ctx, SocketHandler.on_close); - if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) + if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .null) us_socket_context_on_data(ssl_int, ctx, SocketHandler.on_data); - if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) + if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .null) us_socket_context_on_writable(ssl_int, ctx, SocketHandler.on_writable); - if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) + if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .null) us_socket_context_on_timeout(ssl_int, ctx, SocketHandler.on_timeout); - if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) { + if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .null) { us_socket_context_on_socket_connect_error(ssl_int, ctx, SocketHandler.on_connect_error); us_socket_context_on_connect_error(ssl_int, ctx, SocketHandler.on_connect_error_connecting_socket); } - if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) + if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .null) us_socket_context_on_end(ssl_int, ctx, SocketHandler.on_end); - if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) + if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .null) us_socket_context_on_handshake(ssl_int, ctx, SocketHandler.on_handshake, null); } @@ -2249,25 +2249,25 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type { } }; - if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .Null) + if (comptime @hasDecl(Type, "onOpen") and @typeInfo(@TypeOf(Type.onOpen)) != .null) us_socket_context_on_open(ssl_int, ctx, SocketHandler.on_open); - if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .Null) + if (comptime @hasDecl(Type, "onClose") and @typeInfo(@TypeOf(Type.onClose)) != .null) us_socket_context_on_close(ssl_int, ctx, SocketHandler.on_close); - if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .Null) + if (comptime @hasDecl(Type, "onData") and @typeInfo(@TypeOf(Type.onData)) != .null) us_socket_context_on_data(ssl_int, ctx, SocketHandler.on_data); - if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .Null) + if (comptime @hasDecl(Type, "onWritable") and @typeInfo(@TypeOf(Type.onWritable)) != .null) us_socket_context_on_writable(ssl_int, ctx, SocketHandler.on_writable); - if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .Null) + if (comptime @hasDecl(Type, "onTimeout") and @typeInfo(@TypeOf(Type.onTimeout)) != .null) us_socket_context_on_timeout(ssl_int, ctx, SocketHandler.on_timeout); - if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .Null) { + if (comptime @hasDecl(Type, "onConnectError") and @typeInfo(@TypeOf(Type.onConnectError)) != .null) { us_socket_context_on_socket_connect_error(ssl_int, ctx, SocketHandler.on_connect_error); us_socket_context_on_connect_error(ssl_int, ctx, SocketHandler.on_connect_error_connecting_socket); } - if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .Null) + if (comptime @hasDecl(Type, "onEnd") and @typeInfo(@TypeOf(Type.onEnd)) != .null) us_socket_context_on_end(ssl_int, ctx, SocketHandler.on_end); - if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .Null) + if (comptime @hasDecl(Type, "onHandshake") and @typeInfo(@TypeOf(Type.onHandshake)) != .null) us_socket_context_on_handshake(ssl_int, ctx, SocketHandler.on_handshake, null); - if (comptime @hasDecl(Type, "onLongTimeout") and @typeInfo(@TypeOf(Type.onLongTimeout)) != .Null) + if (comptime @hasDecl(Type, "onLongTimeout") and @typeInfo(@TypeOf(Type.onLongTimeout)) != .null) us_socket_context_on_long_timeout(ssl_int, ctx, SocketHandler.on_long_timeout); } diff --git a/src/deps/zig-clap/clap.zig b/src/deps/zig-clap/clap.zig index cea034c1a7853b..8b128a24c9e9eb 100644 --- a/src/deps/zig-clap/clap.zig +++ b/src/deps/zig-clap/clap.zig @@ -69,7 +69,7 @@ pub fn parseParam(line: []const u8) !Param(Help) { @setEvalBranchQuota(999999); var found_comma = false; - var it = mem.tokenize(u8, line, " \t"); + var it = mem.tokenizeAny(u8, line, " \t"); var param_str = it.next() orelse return error.NoParamFound; const short_name = if (!mem.startsWith(u8, param_str, "--") and diff --git a/src/deps/zig-clap/clap/comptime.zig b/src/deps/zig-clap/clap/comptime.zig index 62d007c43b8cd9..cbd920952b2f7b 100644 --- a/src/deps/zig-clap/clap/comptime.zig +++ b/src/deps/zig-clap/clap/comptime.zig @@ -67,7 +67,7 @@ pub fn ComptimeClap( .passthrough_positionals = undefined, }; - var stream = clap.StreamingClap(usize, @typeInfo(@TypeOf(iter)).Pointer.child){ + var stream = clap.StreamingClap(usize, @typeInfo(@TypeOf(iter)).pointer.child){ .params = converted_params, .iter = iter, .diagnostic = opt.diagnostic, diff --git a/src/dns.zig b/src/dns.zig index c1d97920f264fb..1921e1428aa088 100644 --- a/src/dns.zig +++ b/src/dns.zig @@ -27,7 +27,7 @@ pub const GetAddrInfo = struct { hints.ai_family = this.options.family.toLibC(); hints.ai_socktype = this.options.socktype.toLibC(); hints.ai_protocol = this.options.protocol.toLibC(); - hints.ai_flags = this.options.flags; + hints.ai_flags = @bitCast(this.options.flags); return hints; } @@ -54,10 +54,10 @@ pub const GetAddrInfo = struct { socktype: SocketType = .stream, protocol: Protocol = .unspecified, backend: Backend = Backend.default, - flags: i32 = 0, + flags: std.c.AI = .{}, pub fn toLibC(this: Options) ?std.c.addrinfo { - if (this.family == .unspecified and this.socktype == .unspecified and this.protocol == .unspecified and this.flags == 0) { + if (this.family == .unspecified and this.socktype == .unspecified and this.protocol == .unspecified and this.flags == std.c.AI{}) { return null; } @@ -98,9 +98,9 @@ pub const GetAddrInfo = struct { if (!flags.isNumber()) return error.InvalidFlags; - options.flags = flags.coerce(i32, globalObject); + options.flags = flags.coerce(std.c.AI, globalObject); - if (options.flags & ~(AI_ALL | AI_ADDRCONFIG | AI_V4MAPPED) != 0) + if (!options.flags.ALL and !options.flags.ADDRCONFIG and !options.flags.V4MAPPED) return error.InvalidFlags; } diff --git a/src/env_loader.zig b/src/env_loader.zig index 63646845276287..adb7cd8ac4264e 100644 --- a/src/env_loader.zig +++ b/src/env_loader.zig @@ -221,7 +221,7 @@ pub const Loader = struct { return http_proxy; } - var no_proxy_list = std.mem.split(u8, no_proxy_text, ","); + var no_proxy_list = std.mem.splitScalar(u8, no_proxy_text, ','); var next = no_proxy_list.next(); while (next != null) { var host = strings.trim(next.?, &strings.whitespace_chars); @@ -1163,11 +1163,11 @@ pub const Map = struct { map: HashTable, - pub fn createNullDelimitedEnvMap(this: *Map, arena: std.mem.Allocator) ![:null]?[*:0]u8 { + pub fn createNullDelimitedEnvMap(this: *Map, arena: std.mem.Allocator) ![:null]?[*:0]const u8 { var env_map = &this.map; const envp_count = env_map.count(); - const envp_buf = try arena.allocSentinel(?[*:0]u8, envp_count, null); + const envp_buf = try arena.allocSentinel(?[*:0]const u8, envp_count, null); { var it = env_map.iterator(); var i: usize = 0; diff --git a/src/fd.zig b/src/fd.zig index 5f9872255e7556..32b255e922df6d 100644 --- a/src/fd.zig +++ b/src/fd.zig @@ -238,7 +238,7 @@ pub const FDImpl = packed struct { const this_fmt = if (environment.isDebug) std.fmt.bufPrint(&buf, "{}", .{this}) catch unreachable; const result: ?bun.sys.Error = switch (environment.os) { - .linux => result: { + .linux, .mac => result: { const fd = this.encode(); bun.assert(fd != bun.invalid_fd); bun.assert(fd.cast() >= 0); @@ -247,15 +247,6 @@ pub const FDImpl = packed struct { else => null, }; }, - .mac => result: { - const fd = this.encode(); - bun.assert(fd != bun.invalid_fd); - bun.assert(fd.cast() >= 0); - break :result switch (bun.C.getErrno(bun.sys.syscall.@"close$NOCANCEL"(fd.cast()))) { - .BADF => bun.sys.Error{ .errno = @intFromEnum(posix.E.BADF), .syscall = .close, .fd = fd }, - else => null, - }; - }, .windows => result: { switch (this.kind) { .uv => { diff --git a/src/fmt.zig b/src/fmt.zig index e946f2ae562df0..179c29a26ef0ff 100644 --- a/src/fmt.zig +++ b/src/fmt.zig @@ -1344,7 +1344,7 @@ pub fn quote(self: string) bun.fmt.QuotedFormatter { }; } -pub fn EnumTagListFormatter(comptime Enum: type, comptime Separator: @Type(.EnumLiteral)) type { +pub fn EnumTagListFormatter(comptime Enum: type, comptime Separator: @Type(.enum_literal)) type { return struct { pretty: bool = true, const output = brk: { @@ -1375,7 +1375,7 @@ pub fn EnumTagListFormatter(comptime Enum: type, comptime Separator: @Type(.Enum }; } -pub fn enumTagList(comptime Enum: type, comptime separator: @Type(.EnumLiteral)) EnumTagListFormatter(Enum, separator) { +pub fn enumTagList(comptime Enum: type, comptime separator: @Type(.enum_literal)) EnumTagListFormatter(Enum, separator) { return EnumTagListFormatter(Enum, separator){}; } diff --git a/src/futex.zig b/src/futex.zig index 24d66b056e69c4..546fd51547ec53 100644 --- a/src/futex.zig +++ b/src/futex.zig @@ -28,7 +28,7 @@ const atomic = std.atomic; /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically /// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`. pub fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: ?u64) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS for no-op timeouts. if (timeout_ns) |t| { @@ -42,7 +42,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: ?u64) error{ } pub fn waitForever(ptr: *const atomic.Value(u32), expect: u32) void { - @setCold(true); + @branchHint(.cold); while (true) { Impl.wait(ptr, expect, null) catch |err| switch (err) { @@ -55,7 +55,7 @@ pub fn waitForever(ptr: *const atomic.Value(u32), expect: u32) void { /// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`. pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS if there's nothing to wake up. if (max_waiters == 0) { @@ -161,7 +161,7 @@ const DarwinImpl = struct { var timeout_overflowed = false; const addr: *const anyopaque = ptr; - const flags = c.UL_COMPARE_AND_WAIT | c.ULF_NO_ERRNO; + const flags: c.UL = .{ .op = .COMPARE_AND_WAIT, .NO_ERRNO = true }; const status = blk: { if (supports_ulock_wait2) { break :blk c.__ulock_wait2(flags, addr, expect, timeout_ns, 0); @@ -193,8 +193,8 @@ const DarwinImpl = struct { } fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { - const default_flags: u32 = c.UL_COMPARE_AND_WAIT | c.ULF_NO_ERRNO; - const flags: u32 = default_flags | (if (max_waiters > 1) c.ULF_WAKE_ALL else @as(u32, 0)); + var flags: c.UL = .{ .op = .COMPARE_AND_WAIT, .NO_ERRNO = true }; + if (max_waiters > 1) flags.WAKE_ALL = true; while (true) { const addr: *const anyopaque = ptr; @@ -217,8 +217,8 @@ const LinuxImpl = struct { fn wait(ptr: *const atomic.Value(u32), expect: u32, timeout: ?u64) error{Timeout}!void { const ts: linux.timespec = if (timeout) |timeout_ns| .{ - .tv_sec = @intCast(timeout_ns / std.time.ns_per_s), - .tv_nsec = @intCast(timeout_ns % std.time.ns_per_s), + .sec = @intCast(timeout_ns / std.time.ns_per_s), + .nsec = @intCast(timeout_ns % std.time.ns_per_s), } else undefined; diff --git a/src/grapheme.zig b/src/grapheme.zig index 91a8c865e32677..2634c8d680a4f1 100644 --- a/src/grapheme.zig +++ b/src/grapheme.zig @@ -41,7 +41,7 @@ const Precompute = struct { var result: [std.math.maxInt(u10)]Value = undefined; @setEvalBranchQuota(2_000); - const info = @typeInfo(GraphemeBoundaryClass).Enum; + const info = @typeInfo(GraphemeBoundaryClass).@"enum"; for (0..std.math.maxInt(u2) + 1) |state_init| { for (info.fields) |field1| { for (info.fields) |field2| { diff --git a/src/http.zig b/src/http.zig index 3b4451c0cce36d..efb9255ba75e6c 100644 --- a/src/http.zig +++ b/src/http.zig @@ -50,13 +50,13 @@ const DeadSocket = opaque {}; var dead_socket = @as(*DeadSocket, @ptrFromInt(1)); //TODO: this needs to be freed when Worker Threads are implemented var socket_async_http_abort_tracker = std.AutoArrayHashMap(u32, uws.InternalSocket).init(bun.default_allocator); -var async_http_id: std.atomic.Value(u32) = std.atomic.Value(u32).init(0); +var async_http_id_monotonic: std.atomic.Value(u32) = std.atomic.Value(u32).init(0); const MAX_REDIRECT_URL_LENGTH = 128 * 1024; var custom_ssl_context_map = std.AutoArrayHashMap(*SSLConfig, *NewHTTPContext(true)).init(bun.default_allocator); pub var max_http_header_size: usize = 16 * 1024; comptime { - @export(max_http_header_size, .{ .name = "BUN_DEFAULT_MAX_HTTP_HEADER_SIZE" }); + @export(&max_http_header_size, .{ .name = "BUN_DEFAULT_MAX_HTTP_HEADER_SIZE" }); } const print_every = 0; @@ -235,7 +235,7 @@ const ProxyTunnel = struct { const ProxyTunnelWrapper = SSLWrapper(*HTTPClient); - usingnamespace bun.NewRefCounted(ProxyTunnel, ProxyTunnel.deinit); + usingnamespace bun.NewRefCounted(ProxyTunnel, _deinit, null); fn onOpen(this: *HTTPClient) void { this.state.response_stage = .proxy_handshake; @@ -520,7 +520,7 @@ const ProxyTunnel = struct { this.deref(); } - pub fn deinit(this: *ProxyTunnel) void { + fn _deinit(this: *ProxyTunnel) void { this.socket = .{ .none = {} }; if (this.wrapper) |*wrapper| { wrapper.deinit(); @@ -598,7 +598,7 @@ fn NewHTTPContext(comptime ssl: bool) type { } const ActiveSocket = TaggedPointerUnion(.{ - DeadSocket, + *DeadSocket, HTTPClient, PooledSocket, }); @@ -2462,13 +2462,11 @@ pub const AsyncHTTP = struct { } pub fn signalHeaderProgress(this: *AsyncHTTP) void { - @fence(.release); var progress = this.signals.header_progress orelse return; progress.store(true, .release); } pub fn enableBodyStreaming(this: *AsyncHTTP) void { - @fence(.release); var stream = this.signals.body_streaming orelse return; stream.store(true, .release); } @@ -2572,7 +2570,7 @@ pub const AsyncHTTP = struct { .result_callback = callback, .http_proxy = options.http_proxy, .signals = options.signals orelse .{}, - .async_http_id = if (options.signals != null and options.signals.?.aborted != null) async_http_id.fetchAdd(1, .monotonic) else 0, + .async_http_id = if (options.signals != null and options.signals.?.aborted != null) async_http_id_monotonic.fetchAdd(1, .monotonic) else 0, }; this.client = .{ @@ -3116,7 +3114,7 @@ pub const HTTPResponseMetadata = struct { }; fn printRequest(request: picohttp.Request, url: string, ignore_insecure: bool, body: []const u8, curl: bool) void { - @setCold(true); + @branchHint(.cold); var request_ = request; request_.path = url; @@ -3130,7 +3128,7 @@ fn printRequest(request: picohttp.Request, url: string, ignore_insecure: bool, b } fn printResponse(response: picohttp.Response) void { - @setCold(true); + @branchHint(.cold); Output.prettyErrorln("{}", .{response}); Output.flush(); } diff --git a/src/http/mime_type.zig b/src/http/mime_type.zig index a7cf32c5a990b7..1f284dc7ee4769 100644 --- a/src/http/mime_type.zig +++ b/src/http/mime_type.zig @@ -21,7 +21,7 @@ category: Category, pub const Map = bun.StringHashMap(MimeType); pub fn createHashTable(allocator: std.mem.Allocator) !Map { - @setCold(true); + @branchHint(.cold); const decls = comptime std.meta.declarations(all); diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index c612de3183b186..66aa643d6bb9ce 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -226,7 +226,7 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { pub const name = if (ssl) "WebSocketHTTPSClient" else "WebSocketHTTPClient"; pub const shim = JSC.Shimmer("Bun", name, @This()); - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); const HTTPClient = @This(); pub fn register(_: *JSC.JSGlobalObject, _: *anyopaque, ctx: *uws.SocketContext) callconv(.C) void { @@ -713,16 +713,16 @@ pub fn NewHTTPUpgradeClient(comptime ssl: bool) type { }); comptime { - @export(connect, .{ + @export(&connect, .{ .name = Export[0].symbol_name, }); - @export(cancel, .{ + @export(&cancel, .{ .name = Export[1].symbol_name, }); - @export(register, .{ + @export(®ister, .{ .name = Export[2].symbol_name, }); - @export(memoryCost, .{ + @export(&memoryCost, .{ .name = Export[3].symbol_name, }); } @@ -1032,7 +1032,7 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { const WebSocket = @This(); - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn register(global: *JSC.JSGlobalObject, loop_: *anyopaque, ctx_: *anyopaque) callconv(.C) void { const vm = global.bunVM(); const loop = @as(*uws.Loop, @ptrCast(@alignCast(loop_))); @@ -2007,14 +2007,14 @@ pub fn NewWebSocketClient(comptime ssl: bool) type { }); comptime { - @export(writeBinaryData, .{ .name = Export[0].symbol_name }); - @export(writeString, .{ .name = Export[1].symbol_name }); - @export(close, .{ .name = Export[2].symbol_name }); - @export(cancel, .{ .name = Export[3].symbol_name }); - @export(register, .{ .name = Export[4].symbol_name }); - @export(init, .{ .name = Export[5].symbol_name }); - @export(finalize, .{ .name = Export[6].symbol_name }); - @export(memoryCost, .{ .name = Export[7].symbol_name }); + @export(&writeBinaryData, .{ .name = Export[0].symbol_name }); + @export(&writeString, .{ .name = Export[1].symbol_name }); + @export(&close, .{ .name = Export[2].symbol_name }); + @export(&cancel, .{ .name = Export[3].symbol_name }); + @export(®ister, .{ .name = Export[4].symbol_name }); + @export(&init, .{ .name = Export[5].symbol_name }); + @export(&finalize, .{ .name = Export[6].symbol_name }); + @export(&memoryCost, .{ .name = Export[7].symbol_name }); } }; } diff --git a/src/install/bin.zig b/src/install/bin.zig index 61bdf26ba427e3..f47807bef37515 100644 --- a/src/install/bin.zig +++ b/src/install/bin.zig @@ -364,7 +364,7 @@ pub const Bin = extern struct { } pub fn init() Bin { - return bun.serializable(.{ .tag = .none, .value = Value.init(.{ .none = {} }) }); + return bun.serializable(Bin{ .tag = .none, .value = Value.init(.{ .none = {} }) }); } pub const Value = extern union { diff --git a/src/install/bun.lock.zig b/src/install/bun.lock.zig index 0265c374948b4e..83ecb7b1de6ad9 100644 --- a/src/install/bun.lock.zig +++ b/src/install/bun.lock.zig @@ -941,7 +941,7 @@ pub const Stringifier = struct { any = true; } try writer.writeAll( - \\ "os": + \\ "os": ); try Negatable(Npm.OperatingSystem).toJson(meta.os, writer); } @@ -953,7 +953,7 @@ pub const Stringifier = struct { any = true; } try writer.writeAll( - \\ "cpu": + \\ "cpu": ); try Negatable(Npm.Architecture).toJson(meta.arch, writer); } @@ -1154,10 +1154,10 @@ pub const Stringifier = struct { }; const workspace_dependency_groups = [4]struct { []const u8, Dependency.Behavior }{ - .{ "dependencies", Dependency.Behavior.prod }, - .{ "devDependencies", Dependency.Behavior.dev }, - .{ "optionalDependencies", Dependency.Behavior.optional }, - .{ "peerDependencies", Dependency.Behavior.peer }, + .{ "dependencies", .{ .prod = true } }, + .{ "devDependencies", .{ .dev = true } }, + .{ "optionalDependencies", .{ .optional = true } }, + .{ "peerDependencies", .{ .peer = true } }, }; const ParseError = OOM || error{ @@ -1526,7 +1526,7 @@ pub fn parseIntoBinaryLockfile( const dep: Dependency = .{ .name = try string_buf.appendWithHash(name, name_hash), .name_hash = name_hash, - .behavior = Dependency.Behavior.workspace, + .behavior = .{ .workspace = true }, .version = .{ .tag = .workspace, .value = .{ diff --git a/src/install/dependency.zig b/src/install/dependency.zig index d89ebce1c43dfd..2ef640ddbb7290 100644 --- a/src/install/dependency.zig +++ b/src/install/dependency.zig @@ -1311,12 +1311,6 @@ pub const Behavior = packed struct(u8) { bundled: bool = false, _unused_2: u1 = 0, - pub const prod = Behavior{ .prod = true }; - pub const optional = Behavior{ .optional = true }; - pub const dev = Behavior{ .dev = true }; - pub const peer = Behavior{ .peer = true }; - pub const workspace = Behavior{ .workspace = true }; - pub inline fn isProd(this: Behavior) bool { return this.prod; } @@ -1357,13 +1351,13 @@ pub const Behavior = packed struct(u8) { return @as(u8, @bitCast(lhs)) & @as(u8, @bitCast(rhs)) != 0; } - pub inline fn add(this: Behavior, kind: @Type(.EnumLiteral)) Behavior { + pub inline fn add(this: Behavior, kind: @Type(.enum_literal)) Behavior { var new = this; @field(new, @tagName(kind)) = true; return new; } - pub inline fn set(this: Behavior, kind: @Type(.EnumLiteral), value: bool) Behavior { + pub inline fn set(this: Behavior, kind: @Type(.enum_literal), value: bool) Behavior { var new = this; @field(new, @tagName(kind)) = value; return new; @@ -1425,10 +1419,10 @@ pub const Behavior = packed struct(u8) { } comptime { - bun.assert(@as(u8, @bitCast(Behavior.prod)) == (1 << 1)); - bun.assert(@as(u8, @bitCast(Behavior.optional)) == (1 << 2)); - bun.assert(@as(u8, @bitCast(Behavior.dev)) == (1 << 3)); - bun.assert(@as(u8, @bitCast(Behavior.peer)) == (1 << 4)); - bun.assert(@as(u8, @bitCast(Behavior.workspace)) == (1 << 5)); + bun.assert(@as(u8, @bitCast(Behavior{ .prod = true })) == (1 << 1)); + bun.assert(@as(u8, @bitCast(Behavior{ .optional = true })) == (1 << 2)); + bun.assert(@as(u8, @bitCast(Behavior{ .dev = true })) == (1 << 3)); + bun.assert(@as(u8, @bitCast(Behavior{ .peer = true })) == (1 << 4)); + bun.assert(@as(u8, @bitCast(Behavior{ .workspace = true })) == (1 << 5)); } }; diff --git a/src/install/install.zig b/src/install/install.zig index aa0465d1c10f00..96a6ed95dab80d 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -1316,7 +1316,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { pub const Result = union(Tag) { success: void, - fail: struct { + failure: struct { err: anyerror, step: Step, debug_trace: if (Environment.isDebug) bun.crash_handler.StoredTrace else void, @@ -1326,13 +1326,10 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { } }, - pub inline fn success() Result { - return .{ .success = {} }; - } - + /// Init a Result with the 'fail' tag. use `.success` for the 'success' tag. pub inline fn fail(err: anyerror, step: Step, trace: ?*std.builtin.StackTrace) Result { return .{ - .fail = .{ + .failure = .{ .err = err, .step = step, .debug_trace = if (Environment.isDebug) @@ -1347,13 +1344,13 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { pub fn isFail(this: @This()) bool { return switch (this) { .success => false, - .fail => true, + .failure => true, }; } pub const Tag = enum { success, - fail, + failure, }; }; @@ -1540,10 +1537,10 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { state.walker.deinit(); return Result.fail(err, .opening_dest_dir, @errorReturnTrace()); }; - return Result.success(); + return .success; } - const dest_path_length = bun.windows.kernel32.GetFinalPathNameByHandleW(destbase.fd, &state.buf, state.buf.len, 0); + const dest_path_length = bun.windows.GetFinalPathNameByHandleW(destbase.fd, &state.buf, state.buf.len, 0); if (dest_path_length == 0) { const e = bun.windows.Win32Error.get(); const err = if (e.toSystemErrno()) |sys_err| bun.errnoToZigErr(sys_err) else error.Unexpected; @@ -1567,7 +1564,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { _ = node_fs_for_package_installer.mkdirRecursiveOSPathImpl(void, {}, fullpath, 0, false); state.to_copy_buf = state.buf[fullpath.len..]; - const cache_path_length = bun.windows.kernel32.GetFinalPathNameByHandleW(state.cached_package_dir.fd, &state.buf2, state.buf2.len, 0); + const cache_path_length = bun.windows.GetFinalPathNameByHandleW(state.cached_package_dir.fd, &state.buf2, state.buf2.len, 0); if (cache_path_length == 0) { const e = bun.windows.Win32Error.get(); const err = if (e.toSystemErrno()) |sys_err| bun.errnoToZigErr(sys_err) else error.Unexpected; @@ -1585,7 +1582,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { } state.to_copy_buf2 = to_copy_buf2; - return Result.success(); + return .success; } fn installWithCopyfile(this: *@This(), destination_dir: std.fs.Dir) Result { @@ -1715,7 +1712,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { if (Environment.isWindows) &state.buf2 else void{}, ) catch |err| return Result.fail(err, .copying_files, @errorReturnTrace()); - return Result.success(); + return .success; } fn NewTaskQueue(comptime TaskType: type) type { @@ -1726,7 +1723,6 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { wake_value: std.atomic.Value(u32) = std.atomic.Value(u32).init(0), pub fn completeOne(this: *@This()) void { - @fence(.release); if (this.remaining.fetchSub(1, .monotonic) == 1) { _ = this.wake_value.fetchAdd(1, .monotonic); bun.Futex.wake(&this.wake_value, std.math.maxInt(u32)); @@ -1739,7 +1735,6 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { } pub fn wait(this: *@This()) void { - @fence(.acquire); this.wake_value.store(0, .monotonic); while (this.remaining.load(.monotonic) > 0) { bun.Futex.wait(&this.wake_value, 0, std.time.ns_per_ms * 5) catch {}; @@ -1963,7 +1958,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { return Result.fail(err, .copying_files, @errorReturnTrace()); }; - return Result.success(); + return .success; } fn installWithSymlink(this: *@This(), dest_dir: std.fs.Dir) !Result { @@ -2103,7 +2098,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { return Result.fail(err, .copying_files, @errorReturnTrace()); }; - return Result.success(); + return .success; } pub fn uninstall(this: *@This(), destination_dir: std.fs.Dir) void { @@ -2263,7 +2258,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { // When we're linking on Windows, we want to avoid keeping the source directory handle open if (comptime Environment.isWindows) { var wbuf: bun.WPathBuffer = undefined; - const dest_path_length = bun.windows.kernel32.GetFinalPathNameByHandleW(destination_dir.fd, &wbuf, dest_buf.len, 0); + const dest_path_length = bun.windows.GetFinalPathNameByHandleW(destination_dir.fd, &wbuf, dest_buf.len, 0); if (dest_path_length == 0) { const e = bun.windows.Win32Error.get(); const err = if (e.toSystemErrno()) |sys_err| bun.errnoToZigErr(sys_err) else error.Unexpected; @@ -2334,7 +2329,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { if (isDanglingSymlink(symlinked_path)) return Result.fail(error.DanglingSymlink, .linking_dependency, @errorReturnTrace()); - return Result.success(); + return .success; } pub fn getInstallMethod(this: *const @This()) Method { @@ -2402,12 +2397,12 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { const fd = bun.toFD(destination_dir.fd); const subpath = bun.path.joinZ(&[_][]const u8{ this.destination_dir_subpath, ".bun-patch-tag" }); const tag_fd = switch (bun.sys.openat(fd, subpath, bun.O.CREAT | bun.O.WRONLY, 0o666)) { - .err => |e| return .{ .fail = .{ .err = bun.errnoToZigErr(e.getErrno()), .step = Step.patching } }, + .err => |e| return .fail(bun.errnoToZigErr(e.getErrno()), .patching, @errorReturnTrace()), .result => |f| f, }; defer _ = bun.sys.close(tag_fd); - if (bun.sys.File.writeAll(.{ .handle = tag_fd }, this.package_version).asErr()) |e| return .{ .fail = .{ .err = bun.errnoToZigErr(e.getErrno()), .step = Step.patching } }; + if (bun.sys.File.writeAll(.{ .handle = tag_fd }, this.package_version).asErr()) |e| return .fail(bun.errnoToZigErr(e.getErrno()), .patching, @errorReturnTrace()); } pub fn installImpl(this: *@This(), skip_delete: bool, destination_dir: std.fs.Dir, method_: Method, resolution_tag: Resolution.Tag) Result { @@ -2486,7 +2481,7 @@ pub fn NewPackageInstall(comptime kind: PkgInstallKind) type { else => {}, } - if (supported_method_to_use != .copyfile) return Result.success(); + if (supported_method_to_use != .copyfile) return .success; // TODO: linux io_uring return this.installWithCopyfile(destination_dir); @@ -7801,10 +7796,10 @@ pub const PackageManager = struct { const trusted_dependencies_string = "trustedDependencies"; const dependency_groups = &.{ - .{ "optionalDependencies", Dependency.Behavior.optional }, - .{ "devDependencies", Dependency.Behavior.dev }, - .{ "dependencies", Dependency.Behavior.prod }, - .{ "peerDependencies", Dependency.Behavior.peer }, + .{ "optionalDependencies", .{ .optional = true } }, + .{ "devDependencies", .{ .dev = true } }, + .{ "dependencies", .{ .prod = true } }, + .{ "peerDependencies", .{ .peer = true } }, }; pub const EditOptions = struct { @@ -11632,7 +11627,7 @@ pub const PackageManager = struct { var out_dir: if (bun.Environment.isWindows) []const u16 else void = undefined; if (comptime bun.Environment.isWindows) { - const inlen = bun.windows.kernel32.GetFinalPathNameByHandleW(pkg_in_cache_dir.fd, &buf1, buf1.len, 0); + const inlen = bun.windows.GetFinalPathNameByHandleW(pkg_in_cache_dir.fd, &buf1, buf1.len, 0); if (inlen == 0) { const e = bun.windows.Win32Error.get(); const err = if (e.toSystemErrno()) |sys_err| bun.errnoToZigErr(sys_err) else error.Unexpected; @@ -11640,7 +11635,7 @@ pub const PackageManager = struct { Global.crash(); } in_dir = buf1[0..inlen]; - const outlen = bun.windows.kernel32.GetFinalPathNameByHandleW(node_modules_folder.fd, &buf2, buf2.len, 0); + const outlen = bun.windows.GetFinalPathNameByHandleW(node_modules_folder.fd, &buf2, buf2.len, 0); if (outlen == 0) { const e = bun.windows.Win32Error.get(); const err = if (e.toSystemErrno()) |sys_err| bun.errnoToZigErr(sys_err) else error.Unexpected; @@ -12197,7 +12192,7 @@ pub const PackageManager = struct { const ESCAPE_TABLE: [256]EscapeVal = comptime brk: { var table: [256]EscapeVal = [_]EscapeVal{.other} ** 256; const ty = @typeInfo(EscapeVal); - for (ty.Enum.fields) |field| { + for (ty.@"enum".fields) |field| { if (field.name.len == 1) { const c = field.name[0]; table[c] = @enumFromInt(field.value); @@ -12238,7 +12233,7 @@ pub const PackageManager = struct { Output.prettyln("bun add v" ++ Global.package_json_version_with_sha ++ "\n", .{}); Output.flush(); } - return try switch (manager.options.log_level) { + return switch (manager.options.log_level) { inline else => |log_level| manager.updatePackageJSONAndInstallWithManager(ctx, original_cwd, log_level), }; } @@ -13372,7 +13367,7 @@ pub const PackageManager = struct { var lazy_package_dir: LazyPackageDestinationDir = .{ .dir = destination_dir }; - const install_result = switch (resolution.tag) { + const install_result: PackageInstall.Result = switch (resolution.tag) { .symlink, .workspace => installer.installFromLink(this.skip_delete, destination_dir), else => result: { if (resolution.tag == .root or (resolution.tag == .folder and !this.lockfile.isWorkspaceTreeId(this.current_tree_id))) { @@ -13381,15 +13376,15 @@ pub const PackageManager = struct { const dirname = std.fs.path.dirname(this.node_modules.path.items) orelse this.node_modules.path.items; installer.cache_dir = this.root_node_modules_folder.openDir(dirname, .{ .iterate = true, .access_sub_paths = true }) catch |err| - break :result PackageInstall.Result.fail(err, .opening_cache_dir, @errorReturnTrace()); + break :result .fail(err, .opening_cache_dir, @errorReturnTrace()); const result = if (resolution.tag == .root) installer.installFromLink(this.skip_delete, destination_dir) else installer.install(this.skip_delete, destination_dir, resolution.tag); - if (result.isFail() and (result.fail.err == error.ENOENT or result.fail.err == error.FileNotFound)) - break :result PackageInstall.Result.success(); + if (result.isFail() and (result.failure.err == error.ENOENT or result.failure.err == error.FileNotFound)) + break :result .success; break :result result; } @@ -13472,7 +13467,7 @@ pub const PackageManager = struct { if (!pkg_has_patch) this.incrementTreeInstallCount(this.current_tree_id, &lazy_package_dir, !is_pending_package_install, log_level); }, - .fail => |cause| { + .failure => |cause| { if (comptime Environment.allow_assert) { bun.assert(!cause.isPackageMissingFromCache() or (resolution.tag != .symlink and resolution.tag != .workspace)); } @@ -13541,7 +13536,7 @@ pub const PackageManager = struct { cause.err, "failed {s} for package {s}", .{ - install_result.fail.step.name(), + install_result.failure.step.name(), this.names[package_id].slice(this.lockfile.buffers.string_bytes.items), }, ); @@ -15021,7 +15016,7 @@ pub const PackageManager = struct { // added/removed/updated direct dependencies. Output.pretty( \\ - \\Saved {s} ({d} package{s}) + \\Saved {s} ({d} package{s}) , .{ switch (save_format) { .text => "bun.lock", diff --git a/src/install/lifecycle_script_runner.zig b/src/install/lifecycle_script_runner.zig index 42c71494eae16f..52f10c548c5209 100644 --- a/src/install/lifecycle_script_runner.zig +++ b/src/install/lifecycle_script_runner.zig @@ -27,7 +27,7 @@ pub const LifecycleScriptSubprocess = struct { stderr: OutputReader = OutputReader.init(@This()), has_called_process_exit: bool = false, manager: *PackageManager, - envp: [:null]?[*:0]u8, + envp: [:null]?[*:0]const u8, timer: ?Timer = null, @@ -484,7 +484,7 @@ pub const LifecycleScriptSubprocess = struct { pub fn spawnPackageScripts( manager: *PackageManager, list: Lockfile.Package.Scripts.List, - envp: [:null]?[*:0]u8, + envp: [:null]?[*:0]const u8, optional: bool, comptime log_level: PackageManager.Options.LogLevel, comptime foreground: bool, diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index edf351578f9d5e..71ddd3691b6dbc 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -1704,7 +1704,7 @@ pub const Printer = struct { input_lockfile_path: string, format: Format, ) !void { - @setCold(true); + @branchHint(.cold); // We truncate longer than allowed paths. We should probably throw an error instead. const path = input_lockfile_path[0..@min(input_lockfile_path.len, bun.MAX_PATH_BYTES)]; @@ -3763,11 +3763,11 @@ pub const Package = extern struct { field: string, behavior: Behavior, - pub const dependencies = DependencyGroup{ .prop = "dependencies", .field = "dependencies", .behavior = Behavior.prod }; - pub const dev = DependencyGroup{ .prop = "devDependencies", .field = "dev_dependencies", .behavior = Behavior.dev }; - pub const optional = DependencyGroup{ .prop = "optionalDependencies", .field = "optional_dependencies", .behavior = Behavior.optional }; - pub const peer = DependencyGroup{ .prop = "peerDependencies", .field = "peer_dependencies", .behavior = Behavior.peer }; - pub const workspaces = DependencyGroup{ .prop = "workspaces", .field = "workspaces", .behavior = Behavior.workspace }; + pub const dependencies = DependencyGroup{ .prop = "dependencies", .field = "dependencies", .behavior = .{ .prod = true } }; + pub const dev = DependencyGroup{ .prop = "devDependencies", .field = "dev_dependencies", .behavior = .{ .dev = true } }; + pub const optional = DependencyGroup{ .prop = "optionalDependencies", .field = "optional_dependencies", .behavior = .{ .optional = true } }; + pub const peer = DependencyGroup{ .prop = "peerDependencies", .field = "peer_dependencies", .behavior = .{ .peer = true } }; + pub const workspaces = DependencyGroup{ .prop = "workspaces", .field = "workspaces", .behavior = .{ .workspace = true } }; }; pub inline fn isDisabled(this: *const Lockfile.Package) bool { @@ -6074,7 +6074,7 @@ pub const Package = extern struct { }; }; - const FieldsEnum = @typeInfo(Lockfile.Package.List.Field).Enum; + const FieldsEnum = @typeInfo(Lockfile.Package.List.Field).@"enum"; pub fn byteSize(list: Lockfile.Package.List) usize { const sizes_vector: std.meta.Vector(sizes.bytes.len, usize) = sizes.bytes; @@ -7501,7 +7501,7 @@ pub fn jsonStringifyDependency(this: *const Lockfile, w: anytype, dep_id: Depend try w.beginObject(); defer w.endObject() catch {}; - const fields = @typeInfo(Behavior).Struct.fields; + const fields = @typeInfo(Behavior).@"struct".fields; inline for (fields[1 .. fields.len - 1]) |field| { if (@field(dep.behavior, field.name)) { try w.objectField(field.name); diff --git a/src/install/migration.zig b/src/install/migration.zig index 71ecc89e8fe7db..da2c8fa30119e9 100644 --- a/src/install/migration.zig +++ b/src/install/migration.zig @@ -675,7 +675,7 @@ pub fn migrateNPMLockfile( .workspace = wksp_path, }, }, - .behavior = Dependency.Behavior.workspace, + .behavior = .{ .workspace = true }, }; resolutions_buf[0] = entry1.new_package_id; diff --git a/src/install/padding_checker.zig b/src/install/padding_checker.zig index fffc6203a90403..597e6da559de4e 100644 --- a/src/install/padding_checker.zig +++ b/src/install/padding_checker.zig @@ -33,17 +33,17 @@ const std = @import("std"); pub fn assertNoUninitializedPadding(comptime T: type) void { const info_ = @typeInfo(T); const info = switch (info_) { - .Struct => info_.Struct, - .Union => info_.Union, - .Array => |a| { + .@"struct" => info_.@"struct", + .@"union" => info_.@"union", + .array => |a| { assertNoUninitializedPadding(a.child); return; }, - .Optional => |a| { + .optional => |a| { assertNoUninitializedPadding(a.child); return; }, - .Pointer => |ptr| { + .pointer => |ptr| { // Pointers aren't allowed, but this just makes the assertion easier to invoke. assertNoUninitializedPadding(ptr.child); return; @@ -58,18 +58,18 @@ pub fn assertNoUninitializedPadding(comptime T: type) void { for (info.fields) |field| { const fieldInfo = @typeInfo(field.type); switch (fieldInfo) { - .Struct => assertNoUninitializedPadding(field.type), - .Union => assertNoUninitializedPadding(field.type), - .Array => |a| assertNoUninitializedPadding(a.child), - .Optional => |a| assertNoUninitializedPadding(a.child), - .Pointer => { + .@"struct" => assertNoUninitializedPadding(field.type), + .@"union" => assertNoUninitializedPadding(field.type), + .array => |a| assertNoUninitializedPadding(a.child), + .optional => |a| assertNoUninitializedPadding(a.child), + .pointer => { @compileError("Expected no pointer types in " ++ @typeName(T) ++ ", found field '" ++ field.name ++ "' of type '" ++ @typeName(field.type) ++ "'"); }, else => {}, } } - if (info_ == .Union) { + if (info_ == .@"union") { return; } diff --git a/src/install/patch_install.zig b/src/install/patch_install.zig index 50e7eb49ecdbd5..a09fce928fa8cb 100644 --- a/src/install/patch_install.zig +++ b/src/install/patch_install.zig @@ -313,7 +313,7 @@ pub const PatchTask = struct { var resolution_buf: [512]u8 = undefined; const resolution_label = std.fmt.bufPrint(&resolution_buf, "{}", .{this.callback.apply.resolution.fmt(strbuf, .posix)}) catch unreachable; - const dummy_node_modules = .{ + const dummy_node_modules: PackageManager.NodeModulesFolder = .{ .path = std.ArrayList(u8).init(this.manager.allocator), .tree_id = 0, }; @@ -335,7 +335,7 @@ pub const PatchTask = struct { switch (pkg_install.installImpl(true, system_tmpdir, .copyfile, this.callback.apply.resolution.tag)) { .success => {}, - .fail => |reason| { + .failure => |reason| { return try log.addErrorFmtOpts( this.manager.allocator, "{s} while executing step: {s}", diff --git a/src/install/windows-shim/BinLinkingShim.zig b/src/install/windows-shim/BinLinkingShim.zig index 219e13dc16779e..b4000502bcdb31 100644 --- a/src/install/windows-shim/BinLinkingShim.zig +++ b/src/install/windows-shim/BinLinkingShim.zig @@ -77,6 +77,7 @@ pub const Flags = packed struct(u16) { pub const embedded_executable_data = @embedFile("bun_shim_impl.exe"); fn wU8(comptime s: []const u8) []const u8 { + @setEvalBranchQuota(1_000_000); const str = std.unicode.utf8ToUtf16LeStringLiteral(s); return @alignCast(std.mem.sliceAsBytes(str)); } diff --git a/src/install/windows-shim/bun_shim_impl.zig b/src/install/windows-shim/bun_shim_impl.zig index a40d7780d9df54..e3d78724136aa2 100644 --- a/src/install/windows-shim/bun_shim_impl.zig +++ b/src/install/windows-shim/bun_shim_impl.zig @@ -44,7 +44,7 @@ const dbg = builtin.mode == .Debug; const std = @import("std"); const w = std.os.windows; const assert = std.debug.assert; -const fmt16 = std.unicode.fmtUtf16le; +const fmt16 = std.unicode.fmtUtf16Le; const is_standalone = @import("root") == @This(); const bun = if (!is_standalone) @import("root").bun else @compileError("cannot use 'bun' in standalone build of bun_shim_impl"); @@ -260,7 +260,7 @@ var failure_reason_data: [512]u8 = undefined; var failure_reason_argument: ?[]const u8 = null; noinline fn failAndExitWithReason(reason: FailReason) noreturn { - @setCold(true); + @branchHint(.cold); const console_handle = w.teb().ProcessEnvironmentBlock.ProcessParameters.hStdError; var mode: w.DWORD = 0; @@ -310,7 +310,7 @@ pub const LauncherMode = enum { } noinline fn fail(comptime mode: LauncherMode, comptime reason: FailReason) mode.FailRetType() { - @setCold(true); + @branchHint(.cold); return switch (mode) { .launch => failAndExitWithReason(reason), .read_without_launch => ReadWithoutLaunchResult{ .err = reason }, @@ -363,8 +363,8 @@ fn launcher(comptime mode: LauncherMode, bun_ctx: anytype) mode.RetType() { const suffix = comptime (if (is_standalone) wliteral("exe") else wliteral("bunx")); if (dbg) if (!std.mem.endsWith(u16, image_path_u16, suffix)) { std.debug.panic("assert failed: image path expected to end with {}, got {}", .{ - std.unicode.fmtUtf16le(suffix), - std.unicode.fmtUtf16le(image_path_u16), + std.unicode.fmtUtf16Le(suffix), + std.unicode.fmtUtf16Le(image_path_u16), }); }; const image_path_to_copy_b_len = image_path_b_len - 2 * suffix.len; @@ -487,7 +487,7 @@ fn launcher(comptime mode: LauncherMode, bun_ctx: anytype) mode.RetType() { assert(ptr[1] == '.'); while (true) { - if (dbg) debug("1 - {}", .{std.unicode.fmtUtf16le(ptr[0..1])}); + if (dbg) debug("1 - {}", .{std.unicode.fmtUtf16Le(ptr[0..1])}); if (ptr[0] == '\\') { left -= 1; // ptr is of type [*]u16, which means -= operates on number of ITEMS, not BYTES @@ -505,7 +505,7 @@ fn launcher(comptime mode: LauncherMode, bun_ctx: anytype) mode.RetType() { // inlined loop to do this again, because the completion case is different // using `inline for` caused comptime issues that made the code much harder to read while (true) { - if (dbg) debug("2 - {}", .{std.unicode.fmtUtf16le(ptr[0..1])}); + if (dbg) debug("2 - {}", .{std.unicode.fmtUtf16Le(ptr[0..1])}); if (ptr[0] == '\\') { // ptr is at the position marked S, so move forward one *character* break :brk ptr + 1; diff --git a/src/io/PipeReader.zig b/src/io/PipeReader.zig index 3d800beae40bb5..04342020bb58d4 100644 --- a/src/io/PipeReader.zig +++ b/src/io/PipeReader.zig @@ -972,7 +972,7 @@ pub const WindowsBufferedReader = struct { parent: *anyopaque = undefined, vtable: WindowsOutputReaderVTable = undefined, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(@This(), deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); const WindowsOutputReader = @This(); diff --git a/src/io/io.zig b/src/io/io.zig index 7a4f36d3c2505b..279fbed6251d08 100644 --- a/src/io/io.zig +++ b/src/io/io.zig @@ -19,8 +19,8 @@ pub const Loop = struct { epoll_fd: if (Environment.isLinux) bun.FileDescriptor else u0 = if (Environment.isLinux) .zero else 0, cached_now: posix.timespec = .{ - .tv_nsec = 0, - .tv_sec = 0, + .nsec = 0, + .sec = 0, }, active: usize = 0, @@ -297,14 +297,14 @@ pub const Loop = struct { const rc = linux.clock_gettime(linux.CLOCK.MONOTONIC, timespec); assert(rc == 0); } else if (comptime Environment.isWindows) { - var tv_sec: i64 = 0; - var tv_nsec: i64 = 0; + var sec: i64 = 0; + var nsec: i64 = 0; - const rc = clock_gettime_monotonic(&tv_sec, &tv_nsec); + const rc = clock_gettime_monotonic(&sec, &nsec); assert(rc == 0); - timespec.tv_sec = @intCast(tv_sec); - timespec.tv_nsec = @intCast(tv_nsec); + timespec.sec = @intCast(sec); + timespec.nsec = @intCast(nsec); } else { std.posix.clock_gettime(std.posix.CLOCK.MONOTONIC, timespec) catch {}; } @@ -397,7 +397,7 @@ pub const Poll = struct { const GenerationNumberInt = if (Environment.isMac and Environment.allow_assert) u64 else u0; - var generation_number: GenerationNumberInt = 0; + var generation_number_monotonic: GenerationNumberInt = 0; pub const Tag = Pollable.Tag; @@ -446,24 +446,24 @@ pub const Poll = struct { pub fn fromKQueueEvent(kqueue_event: std.posix.system.kevent64_s) Flags.Set { var flags = Flags.Set{}; - if (kqueue_event.filter == std.posix.system.EVFILT_READ) { + if (kqueue_event.filter == std.posix.system.EVFILT.READ) { flags.insert(Flags.readable); log("readable", .{}); if (kqueue_event.flags & std.posix.system.EV_EOF != 0) { flags.insert(Flags.hup); log("hup", .{}); } - } else if (kqueue_event.filter == std.posix.system.EVFILT_WRITE) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.WRITE) { flags.insert(Flags.writable); log("writable", .{}); if (kqueue_event.flags & std.posix.system.EV_EOF != 0) { flags.insert(Flags.hup); log("hup", .{}); } - } else if (kqueue_event.filter == std.posix.system.EVFILT_PROC) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.PROC) { log("proc", .{}); flags.insert(Flags.process); - } else if (kqueue_event.filter == std.posix.system.EVFILT_MACHPORT) { + } else if (kqueue_event.filter == std.posix.system.EVFILT.MACHPORT) { log("machport", .{}); flags.insert(Flags.machport); } @@ -492,7 +492,7 @@ pub const Poll = struct { } pub fn applyKQueue( - comptime action: @Type(.EnumLiteral), + comptime action: @Type(.enum_literal), tag: Pollable.Tag, poll: *Poll, fd: bun.FileDescriptor, @@ -516,47 +516,47 @@ pub const Poll = struct { } if (comptime Environment.allow_assert and action != .cancel) { - generation_number += 1; - poll.generation_number = generation_number; + generation_number_monotonic += 1; + poll.generation_number = generation_number_monotonic; } } - const one_shot_flag = std.posix.system.EV_ONESHOT; + const one_shot_flag = std.posix.system.EV.ONESHOT; kqueue_event.* = switch (comptime action) { .readable => .{ .ident = @as(u64, @intCast(fd.int())), - .filter = std.posix.system.EVFILT_READ, + .filter = std.posix.system.EVFILT.READ, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(tag, poll).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, - .ext = .{ generation_number, 0 }, + .flags = std.c.EV.ADD | one_shot_flag, + .ext = .{ generation_number_monotonic, 0 }, }, .writable => .{ .ident = @as(u64, @intCast(fd.int())), - .filter = std.posix.system.EVFILT_WRITE, + .filter = std.posix.system.EVFILT.WRITE, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(tag, poll).ptr()), - .flags = std.c.EV_ADD | one_shot_flag, - .ext = .{ generation_number, 0 }, + .flags = std.c.EV.ADD | one_shot_flag, + .ext = .{ generation_number_monotonic, 0 }, }, .cancel => if (poll.flags.contains(.poll_readable)) .{ .ident = @as(u64, @intCast(fd.int())), - .filter = std.posix.system.EVFILT_READ, + .filter = std.posix.system.EVFILT.READ, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(tag, poll).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ poll.generation_number, 0 }, } else if (poll.flags.contains(.poll_writable)) .{ .ident = @as(u64, @intCast(fd.int())), - .filter = std.posix.system.EVFILT_WRITE, + .filter = std.posix.system.EVFILT.WRITE, .data = 0, .fflags = 0, .udata = @intFromPtr(Pollable.init(tag, poll).ptr()), - .flags = std.c.EV_DELETE, + .flags = std.c.EV.DELETE, .ext = .{ poll.generation_number, 0 }, } else unreachable, @@ -578,7 +578,7 @@ pub const Poll = struct { pub fn onUpdateKQueue( event: std.posix.system.kevent64_s, ) void { - if (event.filter == std.c.EVFILT_MACHPORT) + if (event.filter == std.c.EVFILT.MACHPORT) return; const pollable = Pollable.from(event.udata); @@ -590,7 +590,7 @@ pub const Poll = struct { inline else => |t| { var this: *Pollable.Tag.Type(t) = @alignCast(@fieldParentPtr("io_poll", poll)); - if (event.flags == std.c.EV_ERROR) { + if (event.flags == std.c.EV.ERROR) { log("error({d}) = {d}", .{ event.ident, event.data }); this.onIOError(bun.sys.Error.fromCode(@enumFromInt(event.data), .kevent)); } else { diff --git a/src/js_ast.zig b/src/js_ast.zig index 3736cbc11c45b4..caf47d46d17e35 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -3202,9 +3202,9 @@ pub const Stmt = struct { }; pub fn StoredData(tag: Tag) type { - const T = std.meta.FieldType(Data, tag); + const T = @FieldType(Data, tag); return switch (@typeInfo(T)) { - .Pointer => |ptr| ptr.child, + .pointer => |ptr| ptr.child, else => T, }; } @@ -5306,7 +5306,7 @@ pub const Expr = struct { bun.assert_eql(@sizeOf(Data), 24); // Do not increase the size of Expr } - pub fn as(data: Data, comptime tag: Tag) ?std.meta.FieldType(Data, tag) { + pub fn as(data: Data, comptime tag: Tag) ?@FieldType(Data, @tagName(tag)) { return if (data == tag) @field(data, @tagName(tag)) else null; } @@ -6043,7 +6043,7 @@ pub const Expr = struct { p: anytype, comptime kind: enum { loose, strict }, ) Equality { - comptime bun.assert(@typeInfo(@TypeOf(p)).Pointer.size == .One); // pass *Parser + comptime bun.assert(@typeInfo(@TypeOf(p)).pointer.size == .one); // pass *Parser // https://dorey.github.io/JavaScript-Equality-Table/ switch (left) { @@ -6329,9 +6329,9 @@ pub const Expr = struct { }; pub fn StoredData(tag: Tag) type { - const T = std.meta.FieldType(Data, tag); + const T = @FieldType(Data, tag); return switch (@typeInfo(T)) { - .Pointer => |ptr| ptr.child, + .pointer => |ptr| ptr.child, else => T, }; } @@ -8175,7 +8175,7 @@ pub const Macro = struct { this: *Run, value: JSC.JSValue, ) MacroError!Expr { - return try switch (JSC.ConsoleObject.Formatter.Tag.get(value, this.global).tag) { + return switch (JSC.ConsoleObject.Formatter.Tag.get(value, this.global).tag) { .Error => this.coerce(value, .Error), .Undefined => this.coerce(value, .Undefined), .Null => this.coerce(value, .Null), diff --git a/src/js_lexer.zig b/src/js_lexer.zig index 251cd7c08a5807..7c9dd41e91f5f7 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -187,7 +187,7 @@ fn NewLexer_( } pub fn syntaxError(self: *LexerType) !void { - @setCold(true); + @branchHint(.cold); // Only add this if there is not already an error. // It is possible that there is a more descriptive error already emitted. @@ -198,20 +198,20 @@ fn NewLexer_( } pub fn addDefaultError(self: *LexerType, msg: []const u8) !void { - @setCold(true); + @branchHint(.cold); self.addError(self.start, "{s}", .{msg}, true); return Error.SyntaxError; } pub fn addSyntaxError(self: *LexerType, _loc: usize, comptime fmt: []const u8, args: anytype) !void { - @setCold(true); + @branchHint(.cold); self.addError(_loc, fmt, args, false); return Error.SyntaxError; } pub fn addError(self: *LexerType, _loc: usize, comptime format: []const u8, args: anytype, _: bool) void { - @setCold(true); + @branchHint(.cold); if (self.is_log_disabled) return; var __loc = logger.usize2Loc(_loc); @@ -224,7 +224,7 @@ fn NewLexer_( } pub fn addRangeError(self: *LexerType, r: logger.Range, comptime format: []const u8, args: anytype, _: bool) !void { - @setCold(true); + @branchHint(.cold); if (self.is_log_disabled) return; if (self.prev_error_loc.eql(r.loc)) { @@ -241,7 +241,7 @@ fn NewLexer_( } pub fn addRangeErrorWithNotes(self: *LexerType, r: logger.Range, comptime format: []const u8, args: anytype, notes: []const logger.Data) !void { - @setCold(true); + @branchHint(.cold); if (self.is_log_disabled) return; if (self.prev_error_loc.eql(r.loc)) { diff --git a/src/js_parser.zig b/src/js_parser.zig index 69a7b91c021c9f..7d9a1d1389ae21 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2600,7 +2600,7 @@ const InvalidLoc = struct { }; pub fn addError(loc: InvalidLoc, log: *logger.Log, source: *const logger.Source) void { - @setCold(true); + @branchHint(.cold); const text = switch (loc.kind) { .spread => "Unexpected trailing comma after rest element", .parentheses => "Unexpected parentheses in binding pattern", @@ -5617,7 +5617,7 @@ fn NewParser_( } // Output.print("\nStmt: {s} - {d}\n", .{ @typeName(@TypeOf(t)), loc.start }); - if (@typeInfo(Type) == .Pointer) { + if (@typeInfo(Type) == .pointer) { // ExportFrom normally becomes import records during the visiting pass // However, we skip the visiting pass in this mode // So we must generate a minimum version of it here. @@ -5707,7 +5707,7 @@ fn NewParser_( } // Output.print("\nExpr: {s} - {d}\n", .{ @typeName(@TypeOf(t)), loc.start }); - if (@typeInfo(Type) == .Pointer) { + if (@typeInfo(Type) == .pointer) { if (comptime only_scan_imports_and_do_not_visit) { if (Type == *E.Call) { const call: *E.Call = t; @@ -5743,7 +5743,7 @@ fn NewParser_( } pub fn b(p: *P, t: anytype, loc: logger.Loc) Binding { - if (@typeInfo(@TypeOf(t)) == .Pointer) { + if (@typeInfo(@TypeOf(t)) == .pointer) { return Binding.init(t, loc); } else { return Binding.alloc(p.allocator, t, loc); @@ -9213,7 +9213,7 @@ fn NewParser_( } fn validateImportType(p: *P, import_tag: ImportRecord.Tag, stmt: *S.Import) !void { - @setCold(true); + @branchHint(.cold); if (import_tag.loader() != null) { p.import_records.items[stmt.import_record_index].tag = import_tag; @@ -14760,8 +14760,8 @@ fn NewParser_( } pub fn panic(p: *P, comptime fmt: string, args: anytype) noreturn { + @branchHint(.cold); p.panicLoc(fmt, args, null); - @setCold(true); } pub fn panicLoc(p: *P, comptime fmt: string, args: anytype, loc: ?logger.Loc) noreturn { diff --git a/src/js_printer.zig b/src/js_printer.zig index 2f791393556cb7..42bfb573a6a9fd 100644 --- a/src/js_printer.zig +++ b/src/js_printer.zig @@ -1909,7 +1909,7 @@ fn NewPrinter( return printClauseItemAs(p, item, .@"export"); } - fn printClauseItemAs(p: *Printer, item: js_ast.ClauseItem, comptime as: @Type(.EnumLiteral)) void { + fn printClauseItemAs(p: *Printer, item: js_ast.ClauseItem, comptime as: @Type(.enum_literal)) void { const name = p.renamer.nameForSymbol(item.name.ref.?); if (comptime as == .import) { @@ -5978,7 +5978,7 @@ pub fn printWithWriterAndPlatform( printer.printFunc(func); } else { // Special-case lazy-export AST - // @branchHint(.unlikely) + @branchHint(.unlikely); printer.printFnArgs(func.open_parens_loc, func.args, func.flags.contains(.has_rest_arg), false); printer.printSpace(); printer.print("{\n"); diff --git a/src/json_parser.zig b/src/json_parser.zig index c7a95ead6e7a36..63cd0bfecd1b25 100644 --- a/src/json_parser.zig +++ b/src/json_parser.zig @@ -87,7 +87,7 @@ const HashMapPool = struct { fn newExpr(t: anytype, loc: logger.Loc) Expr { const Type = @TypeOf(t); - if (comptime @typeInfo(Type) == .Pointer) { + if (comptime @typeInfo(Type) == .pointer) { @compileError("Unexpected pointer"); } @@ -533,7 +533,7 @@ pub fn toAST( const type_info: std.builtin.Type = @typeInfo(Type); switch (type_info) { - .Bool => { + .bool => { return Expr{ .data = .{ .e_boolean = .{ .value = value, @@ -541,7 +541,7 @@ pub fn toAST( .loc = logger.Loc{}, }; }, - .Int => { + .int => { return Expr{ .data = .{ .e_number = .{ @@ -551,7 +551,7 @@ pub fn toAST( .loc = logger.Loc{}, }; }, - .Float => { + .float => { return Expr{ .data = .{ .e_number = .{ @@ -561,9 +561,9 @@ pub fn toAST( .loc = logger.Loc{}, }; }, - .Pointer => |ptr_info| switch (ptr_info.size) { - .One => switch (@typeInfo(ptr_info.child)) { - .Array => { + .pointer => |ptr_info| switch (ptr_info.size) { + .one => switch (@typeInfo(ptr_info.child)) { + .array => { const Slice = []const std.meta.Elem(ptr_info.child); return try toAST(allocator, Slice, value.*); }, @@ -571,7 +571,7 @@ pub fn toAST( return try toAST(allocator, @TypeOf(value.*), value.*); }, }, - .Slice => { + .slice => { if (ptr_info.child == u8) { return Expr.init(js_ast.E.String, js_ast.E.String.init(value), logger.Loc.Empty); } @@ -583,7 +583,7 @@ pub fn toAST( }, else => @compileError("Unable to stringify type '" ++ @typeName(T) ++ "'"), }, - .Array => |Array| { + .array => |Array| { if (Array.child == u8) { return Expr.init(js_ast.E.String, js_ast.E.String.init(value), logger.Loc.Empty); } @@ -593,7 +593,7 @@ pub fn toAST( return Expr.init(js_ast.E.Array, js_ast.E.Array{ .items = exprs }, logger.Loc.Empty); }, - .Struct => |Struct| { + .@"struct" => |Struct| { const fields: []const std.builtin.Type.StructField = Struct.fields; var properties = try allocator.alloc(js_ast.G.Property, fields.len); var property_i: usize = 0; @@ -614,25 +614,25 @@ pub fn toAST( logger.Loc.Empty, ); }, - .Null => { + .null => { return Expr{ .data = .{ .e_null = .{} }, .loc = logger.Loc{} }; }, - .Optional => { + .optional => { if (value) |_value| { return try toAST(allocator, @TypeOf(_value), _value); } else { return Expr{ .data = .{ .e_null = .{} }, .loc = logger.Loc{} }; } }, - .Enum => { + .@"enum" => { _ = std.meta.intToEnum(Type, @intFromEnum(value)) catch { return Expr{ .data = .{ .e_null = .{} }, .loc = logger.Loc{} }; }; return toAST(allocator, string, @as(string, @tagName(value))); }, - .ErrorSet => return try toAST(allocator, []const u8, bun.asByteSlice(@errorName(value))), - .Union => |Union| { + .error_set => return try toAST(allocator, []const u8, bun.asByteSlice(@errorName(value))), + .@"union" => |Union| { const info = Union; if (info.tag_type) |UnionTagType| { inline for (info.fields) |u_field| { @@ -650,7 +650,7 @@ pub fn toAST( @field(value, u_field.name), ), .is_comptime = false, - .default_value = undefined, + .default_value_ptr = undefined, .alignment = @alignOf( @TypeOf( @field(value, u_field.name), diff --git a/src/libarchive/libarchive-bindings.zig b/src/libarchive/libarchive-bindings.zig index d9bd69630a80bf..f8ec3f8f797389 100644 --- a/src/libarchive/libarchive-bindings.zig +++ b/src/libarchive/libarchive-bindings.zig @@ -874,11 +874,11 @@ pub const Archive = opaque { }, result: T, - pub fn err(arch: *Archive, msg: []const u8) @This() { + pub fn initErr(arch: *Archive, msg: []const u8) @This() { return .{ .err = .{ .message = msg, .archive = arch } }; } - pub fn res(value: T) @This() { + pub fn initRes(value: T) @This() { return .{ .result = value }; } }; @@ -891,38 +891,38 @@ pub const Archive = opaque { switch (archive.readSupportFormatTar()) { .failed, .fatal, .warn => { - return Return.err(archive, "failed to enable tar format support"); + return Return.initErr(archive, "failed to enable tar format support"); }, else => {}, } switch (archive.readSupportFormatGnutar()) { .failed, .fatal, .warn => { - return Return.err(archive, "failed to enable gnutar format support"); + return Return.initErr(archive, "failed to enable gnutar format support"); }, else => {}, } switch (archive.readSupportFilterGzip()) { .failed, .fatal, .warn => { - return Return.err(archive, "failed to enable support for gzip compression"); + return Return.initErr(archive, "failed to enable support for gzip compression"); }, else => {}, } switch (archive.readSetOptions("read_concatenated_archives")) { .failed, .fatal, .warn => { - return Return.err(archive, "failed to set option `read_concatenated_archives`"); + return Return.initErr(archive, "failed to set option `read_concatenated_archives`"); }, else => {}, } switch (archive.readOpenMemory(tarball_bytes)) { .failed, .fatal, .warn => { - return Return.err(archive, "failed to read tarball"); + return Return.initErr(archive, "failed to read tarball"); }, else => {}, } - return Return.res(.{ + return Return.initRes(.{ .archive = archive, .filter = std.EnumSet(std.fs.File.Kind).initEmpty(), }); @@ -935,15 +935,15 @@ pub const Archive = opaque { pub fn readEntryData(this: *const @This(), allocator: std.mem.Allocator, archive: *Archive) OOM!Iterator.Result([]const u8) { const Return = Iterator.Result([]const u8); const size = this.entry.size(); - if (size < 0) return Return.err(archive, "invalid archive entry size"); + if (size < 0) return Return.initErr(archive, "invalid archive entry size"); const buf = try allocator.alloc(u8, @intCast(size)); const read = archive.readData(buf); if (read < 0) { - return Return.err(archive, "failed to read archive data"); + return Return.initErr(archive, "failed to read archive data"); } - return Return.res(buf[0..@intCast(read)]); + return Return.initRes(buf[0..@intCast(read)]); } }; @@ -954,18 +954,18 @@ pub const Archive = opaque { while (true) { return switch (this.archive.readNextHeader(&entry)) { .retry => continue, - .eof => Return.res(null), + .eof => Return.initRes(null), .ok => { const kind = bun.C.kindFromMode(entry.filetype()); if (this.filter.contains(kind)) continue; - return Return.res(.{ + return Return.initRes(.{ .entry = entry, .kind = kind, }); }, - else => Return.err(this.archive, "failed to read archive header"), + else => Return.initErr(this.archive, "failed to read archive header"), }; } } @@ -975,18 +975,18 @@ pub const Archive = opaque { switch (this.archive.readClose()) { .failed, .fatal, .warn => { - return Return.err(this.archive, "failed to close archive read"); + return Return.initErr(this.archive, "failed to close archive read"); }, else => {}, } switch (this.archive.readFree()) { .failed, .fatal, .warn => { - return Return.err(this.archive, "failed to free archive read"); + return Return.initErr(this.archive, "failed to free archive read"); }, else => {}, } - return Return.res({}); + return Return.initRes({}); } }; }; diff --git a/src/libarchive/libarchive.zig b/src/libarchive/libarchive.zig index 29c56875b515b0..f19bcd570598ee 100644 --- a/src/libarchive/libarchive.zig +++ b/src/libarchive/libarchive.zig @@ -262,7 +262,7 @@ pub const Archiver = struct { // it will require us to pull in libiconv // though we should probably validate the utf8 here nonetheless var pathname = entry.pathname(); - var tokenizer = std.mem.tokenize(u8, bun.asByteSlice(pathname), std.fs.path.sep_str); + var tokenizer = std.mem.tokenizeScalar(u8, bun.asByteSlice(pathname), std.fs.path.sep); comptime var depth_i: usize = 0; inline while (depth_i < depth_to_skip) : (depth_i += 1) { if (tokenizer.next() == null) continue :loop; diff --git a/src/linux_c.zig b/src/linux_c.zig index da337bd791973a..7187f120b9afac 100644 --- a/src/linux_c.zig +++ b/src/linux_c.zig @@ -702,10 +702,10 @@ comptime { _ = fstat64; _ = fstatat; _ = statx; - @export(stat, .{ .name = "stat64" }); - @export(lstat, .{ .name = "lstat64" }); - @export(fstat, .{ .name = "fstat64" }); - @export(fstatat, .{ .name = "fstatat64" }); + @export(&stat, .{ .name = "stat64" }); + @export(&lstat, .{ .name = "lstat64" }); + @export(&fstat, .{ .name = "fstat64" }); + @export(&fstatat, .{ .name = "fstatat64" }); } // ********************************************************************************* diff --git a/src/logger.zig b/src/logger.zig index cddd6d75e9d43c..20457169915de6 100644 --- a/src/logger.zig +++ b/src/logger.zig @@ -729,23 +729,23 @@ pub const Log = struct { } pub fn addDebugFmt(log: *Log, source: ?*const Source, l: Loc, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - if (!Kind.shouldPrint(.debug, log.level)) return; - - @setCold(true); - try log.addMsg(.{ - .kind = .debug, - .data = try rangeData(source, Range{ .loc = l }, try allocPrint(allocator, text, args)).cloneLineText(log.clone_line_text, log.msgs.allocator), - }); + if (Kind.shouldPrint(.debug, log.level)) { + @branchHint(.cold); + try log.addMsg(.{ + .kind = .debug, + .data = try rangeData(source, Range{ .loc = l }, try allocPrint(allocator, text, args)).cloneLineText(log.clone_line_text, log.msgs.allocator), + }); + } } pub fn addVerbose(log: *Log, source: ?*const Source, loc: Loc, text: string) OOM!void { - if (!Kind.shouldPrint(.verbose, log.level)) return; - - @setCold(true); - try log.addMsg(.{ - .kind = .verbose, - .data = rangeData(source, Range{ .loc = loc }, text), - }); + if (Kind.shouldPrint(.verbose, log.level)) { + @branchHint(.cold); + try log.addMsg(.{ + .kind = .verbose, + .data = rangeData(source, Range{ .loc = loc }, text), + }); + } } pub fn toJS(this: Log, global: *JSC.JSGlobalObject, allocator: std.mem.Allocator, message: string) JSC.JSValue { @@ -871,7 +871,7 @@ pub const Log = struct { pub const clearAndFree = deinit; pub fn addVerboseWithNotes(log: *Log, source: ?*const Source, loc: Loc, text: string, notes: []Data) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.verbose, log.level)) return; try log.addMsg(.{ @@ -882,7 +882,7 @@ pub const Log = struct { } inline fn allocPrint(allocator: std.mem.Allocator, comptime fmt: string, args: anytype) OOM!string { - return try switch (Output.enable_ansi_colors) { + return switch (Output.enable_ansi_colors) { inline else => |enable_ansi_colors| std.fmt.allocPrint(allocator, Output.prettyFmt(fmt, enable_ansi_colors), args), }; } @@ -950,7 +950,7 @@ pub const Log = struct { import_kind: ImportKind, err: anyerror, ) OOM!void { - @setCold(true); + @branchHint(.cold); return try addResolveErrorWithLevel(log, source, r, allocator, fmt, args, import_kind, false, .err, err); } @@ -963,12 +963,12 @@ pub const Log = struct { args: anytype, import_kind: ImportKind, ) OOM!void { - @setCold(true); + @branchHint(.cold); return try addResolveErrorWithLevel(log, source, r, allocator, fmt, args, import_kind, true, .err, error.ModuleNotFound); } pub fn addRangeError(log: *Log, source: ?*const Source, r: Range, text: string) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = .err, @@ -977,7 +977,7 @@ pub const Log = struct { } pub fn addRangeErrorFmt(log: *Log, source: ?*const Source, r: Range, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = .err, @@ -986,7 +986,7 @@ pub const Log = struct { } pub fn addRangeErrorFmtWithNotes(log: *Log, source: ?*const Source, r: Range, allocator: std.mem.Allocator, notes: []Data, comptime fmt: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = .err, @@ -996,7 +996,7 @@ pub const Log = struct { } pub fn addErrorFmt(log: *Log, source: ?*const Source, l: Loc, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = .err, @@ -1006,7 +1006,7 @@ pub const Log = struct { // TODO(dylan-conway): rename and replace `addErrorFmt` pub fn addErrorFmtOpts(log: *Log, allocator: std.mem.Allocator, comptime fmt: string, args: anytype, opts: AddErrorOptions) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = .err, @@ -1035,7 +1035,7 @@ pub const Log = struct { } pub fn addZigErrorWithNote(log: *Log, allocator: std.mem.Allocator, err: anyerror, comptime noteFmt: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; var notes = try allocator.alloc(Data, 1); @@ -1049,7 +1049,7 @@ pub const Log = struct { } pub fn addRangeWarning(log: *Log, source: ?*const Source, r: Range, text: string) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; try log.addMsg(.{ @@ -1059,7 +1059,7 @@ pub const Log = struct { } pub fn addWarningFmt(log: *Log, source: ?*const Source, l: Loc, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; try log.addMsg(.{ @@ -1069,7 +1069,7 @@ pub const Log = struct { } pub fn addWarningFmtLineCol(log: *Log, filepath: []const u8, line: u32, col: u32, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; @@ -1089,7 +1089,7 @@ pub const Log = struct { } pub fn addRangeWarningFmt(log: *Log, source: ?*const Source, r: Range, allocator: std.mem.Allocator, comptime text: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; try log.addMsg(.{ @@ -1109,7 +1109,7 @@ pub const Log = struct { note_args: anytype, note_range: Range, ) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; @@ -1124,7 +1124,7 @@ pub const Log = struct { } pub fn addRangeWarningFmtWithNotes(log: *Log, source: ?*const Source, r: Range, allocator: std.mem.Allocator, notes: []Data, comptime fmt: string, args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); log.warnings += 1; try log.addMsg(.{ .kind = .warn, @@ -1144,7 +1144,7 @@ pub const Log = struct { note_args: anytype, note_range: Range, ) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.err, log.level)) return; log.errors += 1; @@ -1159,7 +1159,7 @@ pub const Log = struct { } pub fn addWarning(log: *Log, source: ?*const Source, l: Loc, text: string) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; try log.addMsg(.{ @@ -1169,7 +1169,7 @@ pub const Log = struct { } pub fn addWarningWithNote(log: *Log, source: ?*const Source, l: Loc, allocator: std.mem.Allocator, warn: string, comptime note_fmt: string, note_args: anytype) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; @@ -1184,7 +1184,7 @@ pub const Log = struct { } pub fn addRangeDebug(log: *Log, source: ?*const Source, r: Range, text: string) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.debug, log.level)) return; try log.addMsg(.{ .kind = .debug, @@ -1193,7 +1193,7 @@ pub const Log = struct { } pub fn addRangeDebugWithNotes(log: *Log, source: ?*const Source, r: Range, text: string, notes: []Data) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.debug, log.level)) return; // log.de += 1; try log.addMsg(.{ @@ -1204,7 +1204,7 @@ pub const Log = struct { } pub fn addRangeErrorWithNotes(log: *Log, source: ?*const Source, r: Range, text: string, notes: []Data) OOM!void { - @setCold(true); + @branchHint(.cold); log.errors += 1; try log.addMsg(.{ .kind = Kind.err, @@ -1214,7 +1214,7 @@ pub const Log = struct { } pub fn addRangeWarningWithNotes(log: *Log, source: ?*const Source, r: Range, text: string, notes: []Data) OOM!void { - @setCold(true); + @branchHint(.cold); if (!Kind.shouldPrint(.warn, log.level)) return; log.warnings += 1; try log.addMsg(.{ @@ -1229,7 +1229,7 @@ pub const Log = struct { } pub fn addError(self: *Log, _source: ?*const Source, loc: Loc, text: string) OOM!void { - @setCold(true); + @branchHint(.cold); self.errors += 1; try self.addMsg(.{ .kind = .err, .data = rangeData(_source, Range{ .loc = loc }, text) }); } @@ -1243,7 +1243,7 @@ pub const Log = struct { // TODO(dylan-conway): rename and replace `addError` pub fn addErrorOpts(self: *Log, text: string, opts: AddErrorOptions) OOM!void { - @setCold(true); + @branchHint(.cold); self.errors += 1; try self.addMsg(.{ .kind = .err, diff --git a/src/main.zig b/src/main.zig index 1df928f583cbe6..338fc2e2432ea4 100644 --- a/src/main.zig +++ b/src/main.zig @@ -27,8 +27,8 @@ pub fn main() void { .mask = std.posix.empty_sigset, .flags = 0, }; - std.posix.sigaction(std.posix.SIG.PIPE, &act, null) catch {}; - std.posix.sigaction(std.posix.SIG.XFSZ, &act, null) catch {}; + std.posix.sigaction(std.posix.SIG.PIPE, &act, null); + std.posix.sigaction(std.posix.SIG.XFSZ, &act, null); } // This should appear before we make any calls at all to libuv. @@ -59,28 +59,6 @@ pub fn main() void { bun.Global.exit(0); } -pub const overrides = struct { - pub const mem = struct { - extern "C" fn wcslen(s: [*:0]const u16) usize; - - pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]const T) usize { - if (comptime T == u16 and sentinel == 0 and Environment.isWindows) { - return wcslen(p); - } - - if (comptime T == u8 and sentinel == 0) { - return bun.C.strlen(p); - } - - var i: usize = 0; - while (p[i] != sentinel) { - i += 1; - } - return i; - } - }; -}; - pub export fn Bun__panic(msg: [*]const u8, len: usize) noreturn { Output.panic("{s}", .{msg[0..len]}); } diff --git a/src/meta.zig b/src/meta.zig index 9385ea8066a19f..3b29f33bb080ec 100644 --- a/src/meta.zig +++ b/src/meta.zig @@ -5,8 +5,8 @@ pub usingnamespace std.meta; pub fn OptionalChild(comptime T: type) type { const tyinfo = @typeInfo(T); - if (tyinfo != .Pointer) @compileError("OptionalChild(T) requires that T be a pointer to an optional type."); - const child = @typeInfo(tyinfo.Pointer.child); + if (tyinfo != .pointer) @compileError("OptionalChild(T) requires that T be a pointer to an optional type."); + const child = @typeInfo(tyinfo.pointer.child); if (child != .Optional) @compileError("OptionalChild(T) requires that T be a pointer to an optional type."); return child.Optional.child; } @@ -14,8 +14,8 @@ pub fn OptionalChild(comptime T: type) type { pub fn EnumFields(comptime T: type) []const std.builtin.Type.EnumField { const tyinfo = @typeInfo(T); return switch (tyinfo) { - .Union => std.meta.fields(tyinfo.Union.tag_type.?), - .Enum => tyinfo.Enum.fields, + .@"union" => std.meta.fields(tyinfo.@"union".tag_type.?), + .@"enum" => tyinfo.@"enum".fields, else => { @compileError("Used `EnumFields(T)` on a type that is not an `enum` or a `union(enum)`"); }, @@ -24,7 +24,7 @@ pub fn EnumFields(comptime T: type) []const std.builtin.Type.EnumField { pub fn ReturnOfMaybe(comptime function: anytype) type { const Func = @TypeOf(function); - const typeinfo: std.builtin.Type.Fn = @typeInfo(Func).Fn; + const typeinfo: std.builtin.Type.Fn = @typeInfo(Func).@"fn"; const MaybeType = typeinfo.return_type orelse @compileError("Expected the function to have a return type"); return MaybeResult(MaybeType); } @@ -32,7 +32,7 @@ pub fn ReturnOfMaybe(comptime function: anytype) type { pub fn MaybeResult(comptime MaybeType: type) type { const maybe_ty_info = @typeInfo(MaybeType); - const maybe = maybe_ty_info.Union; + const maybe = maybe_ty_info.@"union"; if (maybe.fields.len != 2) @compileError("Expected the Maybe type to be a union(enum) with two variants"); if (!std.mem.eql(u8, maybe.fields[0].name, "err")) { @@ -51,7 +51,7 @@ pub fn ReturnOf(comptime function: anytype) type { } pub fn ReturnOfType(comptime Type: type) type { - const typeinfo: std.builtin.Type.Fn = @typeInfo(Type).Fn; + const typeinfo: std.builtin.Type.Fn = @typeInfo(Type).@"fn"; return typeinfo.return_type orelse void; } @@ -62,15 +62,16 @@ pub fn typeName(comptime Type: type) []const u8 { /// partially emulates behaviour of @typeName in previous Zig versions, /// converting "some.namespace.MyType" to "MyType" -pub fn typeBaseName(comptime fullname: [:0]const u8) [:0]const u8 { +pub inline fn typeBaseName(comptime fullname: [:0]const u8) [:0]const u8 { + @setEvalBranchQuota(1_000_000); // leave type name like "namespace.WrapperType(namespace.MyType)" as it is const baseidx = comptime std.mem.indexOf(u8, fullname, "("); - if (baseidx != null) return fullname; + if (baseidx != null) return comptime fullname; const idx = comptime std.mem.lastIndexOf(u8, fullname, "."); const name = if (idx == null) fullname else fullname[(idx.? + 1)..]; - return comptime std.fmt.comptimePrint("{s}", .{name}); + return comptime name; } pub fn enumFieldNames(comptime Type: type) []const []const u8 { @@ -103,10 +104,10 @@ pub fn banFieldType(comptime Container: type, comptime T: type) void { // *[n]T -> T pub fn Item(comptime T: type) type { switch (@typeInfo(T)) { - .Pointer => |ptr| { - if (ptr.size == .One) { + .pointer => |ptr| { + if (ptr.size == .one) { switch (@typeInfo(ptr.child)) { - .Array => |array| { + .array => |array| { return array.child; }, else => {}, @@ -183,14 +184,14 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { tuple_fields[i] = .{ .name = std.fmt.bufPrintZ(&num_buf, "{d}", .{i}) catch unreachable, .type = T, - .default_value = null, + .default_value_ptr = null, .is_comptime = false, .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0, }; } return @Type(.{ - .Struct = .{ + .@"struct" = .{ .is_tuple = true, .layout = .auto, .decls = &.{}, @@ -207,14 +208,14 @@ pub fn hasStableMemoryLayout(comptime T: type) bool { .Bool => true, .Int => true, .Float => true, - .Enum => { + .@"enum" => { // not supporting this rn - if (tyinfo.Enum.is_exhaustive) return false; - return hasStableMemoryLayout(tyinfo.Enum.tag_type); + if (tyinfo.@"enum".is_exhaustive) return false; + return hasStableMemoryLayout(tyinfo.@"enum".tag_type); }, - .Struct => switch (tyinfo.Struct.layout) { + .@"struct" => switch (tyinfo.@"struct".layout) { .auto => { - inline for (tyinfo.Struct.fields) |field| { + inline for (tyinfo.@"struct".fields) |field| { if (!hasStableMemoryLayout(field.field_type)) return false; } return true; @@ -222,11 +223,11 @@ pub fn hasStableMemoryLayout(comptime T: type) bool { .@"extern" => true, .@"packed" => false, }, - .Union => switch (tyinfo.Union.layout) { + .@"union" => switch (tyinfo.@"union".layout) { .auto => { - if (tyinfo.Union.tag_type == null or !hasStableMemoryLayout(tyinfo.Union.tag_type.?)) return false; + if (tyinfo.@"union".tag_type == null or !hasStableMemoryLayout(tyinfo.@"union".tag_type.?)) return false; - inline for (tyinfo.Union.fields) |field| { + inline for (tyinfo.@"union".fields) |field| { if (!hasStableMemoryLayout(field.type)) return false; } @@ -240,26 +241,27 @@ pub fn hasStableMemoryLayout(comptime T: type) bool { } pub fn isSimpleCopyType(comptime T: type) bool { + @setEvalBranchQuota(1_000_000); const tyinfo = @typeInfo(T); return switch (tyinfo) { - .Void => true, - .Bool => true, - .Int => true, - .Float => true, - .Enum => true, - .Struct => { - inline for (tyinfo.Struct.fields) |field| { + .void => true, + .bool => true, + .int => true, + .float => true, + .@"enum" => true, + .@"struct" => { + inline for (tyinfo.@"struct".fields) |field| { if (!isSimpleCopyType(field.type)) return false; } return true; }, - .Union => { - inline for (tyinfo.Union.fields) |field| { + .@"union" => { + inline for (tyinfo.@"union".fields) |field| { if (!isSimpleCopyType(field.type)) return false; } return true; }, - .Optional => return isSimpleCopyType(tyinfo.Optional.child), + .optional => return isSimpleCopyType(tyinfo.optional.child), else => false, }; } @@ -269,7 +271,7 @@ pub fn isScalar(comptime T: type) bool { i32, u32, i64, u64, f32, f64, bool => true, else => { const tyinfo = @typeInfo(T); - if (tyinfo == .Enum) return true; + if (tyinfo == .@"enum") return true; return false; }, }; @@ -278,12 +280,12 @@ pub fn isScalar(comptime T: type) bool { pub fn isSimpleEqlType(comptime T: type) bool { const tyinfo = @typeInfo(T); return switch (tyinfo) { - .Type => true, - .Void => true, - .Bool => true, - .Int => true, - .Float => true, - .Enum => true, + .type => true, + .void => true, + .bool => true, + .int => true, + .float => true, + .@"enum" => true, else => false, }; } @@ -295,27 +297,27 @@ pub const ListContainerType = enum { }; pub fn looksLikeListContainerType(comptime T: type) ?struct { list: ListContainerType, child: type } { const tyinfo = @typeInfo(T); - if (tyinfo == .Struct) { + if (tyinfo == .@"struct") { // Looks like array list - if (tyinfo.Struct.fields.len == 2 and - std.mem.eql(u8, tyinfo.Struct.fields[0].name, "items") and - std.mem.eql(u8, tyinfo.Struct.fields[1].name, "capacity")) - return .{ .list = .array_list, .child = std.meta.Child(tyinfo.Struct.fields[0].type) }; + if (tyinfo.@"struct".fields.len == 2 and + std.mem.eql(u8, tyinfo.@"struct".fields[0].name, "items") and + std.mem.eql(u8, tyinfo.@"struct".fields[1].name, "capacity")) + return .{ .list = .array_list, .child = std.meta.Child(tyinfo.@"struct".fields[0].type) }; // Looks like babylist - if (tyinfo.Struct.fields.len == 3 and - std.mem.eql(u8, tyinfo.Struct.fields[0].name, "ptr") and - std.mem.eql(u8, tyinfo.Struct.fields[1].name, "len") and - std.mem.eql(u8, tyinfo.Struct.fields[2].name, "cap")) - return .{ .list = .baby_list, .child = std.meta.Child(tyinfo.Struct.fields[0].type) }; + if (tyinfo.@"struct".fields.len == 3 and + std.mem.eql(u8, tyinfo.@"struct".fields[0].name, "ptr") and + std.mem.eql(u8, tyinfo.@"struct".fields[1].name, "len") and + std.mem.eql(u8, tyinfo.@"struct".fields[2].name, "cap")) + return .{ .list = .baby_list, .child = std.meta.Child(tyinfo.@"struct".fields[0].type) }; // Looks like SmallList - if (tyinfo.Struct.fields.len == 2 and - std.mem.eql(u8, tyinfo.Struct.fields[0].name, "capacity") and - std.mem.eql(u8, tyinfo.Struct.fields[1].name, "data")) return .{ + if (tyinfo.@"struct".fields.len == 2 and + std.mem.eql(u8, tyinfo.@"struct".fields[0].name, "capacity") and + std.mem.eql(u8, tyinfo.@"struct".fields[1].name, "data")) return .{ .list = .small_list, .child = std.meta.Child( - @typeInfo(tyinfo.Struct.fields[1].type).Union.fields[0].type, + @typeInfo(tyinfo.@"struct".fields[1].type).@"union".fields[0].type, ), }; } @@ -324,8 +326,8 @@ pub fn looksLikeListContainerType(comptime T: type) ?struct { list: ListContaine } pub fn Tagged(comptime U: type, comptime T: type) type { - var info: std.builtin.Type.Union = @typeInfo(U).Union; + var info: std.builtin.Type.Union = @typeInfo(U).@"union"; info.tag_type = T; info.decls = &.{}; - return @Type(.{ .Union = info }); + return @Type(.{ .@"union" = info }); } diff --git a/src/multi_array_list.zig b/src/multi_array_list.zig index 46fbe6a936b0b0..087b8a42741a15 100644 --- a/src/multi_array_list.zig +++ b/src/multi_array_list.zig @@ -24,11 +24,16 @@ pub fn MultiArrayList(comptime T: type) type { len: usize = 0, capacity: usize = 0, - pub const Elem = switch (@typeInfo(T)) { - .Struct => T, - .Union => |u| struct { - pub const Bare = - @Type(.{ .Union = .{ + pub const empty: Self = .{ + .bytes = undefined, + .len = 0, + .capacity = 0, + }; + + const Elem = switch (@typeInfo(T)) { + .@"struct" => T, + .@"union" => |u| struct { + pub const Bare = @Type(.{ .@"union" = .{ .layout = u.layout, .tag_type = null, .fields = u.fields, @@ -70,6 +75,12 @@ pub fn MultiArrayList(comptime T: type) type { len: usize, capacity: usize, + pub const empty: Slice = .{ + .ptrs = undefined, + .len = 0, + .capacity = 0, + }; + pub fn items(self: Slice, comptime field: Field) []FieldType(field) { const F = FieldType(field); if (self.capacity == 0) { @@ -85,9 +96,9 @@ pub fn MultiArrayList(comptime T: type) type { pub fn set(self: *Slice, index: usize, elem: T) void { const e = switch (@typeInfo(T)) { - .Struct => elem, - .Union => Elem.fromT(elem), - else => @compileError("unreachable"), + .@"struct" => elem, + .@"union" => Elem.fromT(elem), + else => unreachable, }; inline for (fields, 0..) |field_info, i| { self.items(@as(Field, @enumFromInt(i)))[index] = @field(e, field_info.name); @@ -100,14 +111,14 @@ pub fn MultiArrayList(comptime T: type) type { @field(result, field_info.name) = self.items(@as(Field, @enumFromInt(i)))[index]; } return switch (@typeInfo(T)) { - .Struct => result, - .Union => Elem.toT(result.tags, result.data), - else => @compileError("unreachable"), + .@"struct" => result, + .@"union" => Elem.toT(result.tags, result.data), + else => unreachable, }; } pub fn toMultiArrayList(self: Slice) Self { - if (self.ptrs.len == 0) { + if (self.ptrs.len == 0 or self.capacity == 0) { return .{}; } const unaligned_ptr = self.ptrs[sizes.fields[0]]; @@ -279,6 +290,7 @@ pub fn MultiArrayList(comptime T: type) type { self.insertAssumeCapacity(index, elem); } + /// Invalidates all element pointers. pub fn clearRetainingCapacity(this: *Self) void { this.len = 0; } @@ -292,9 +304,9 @@ pub fn MultiArrayList(comptime T: type) type { assert(index <= self.len); self.len += 1; const entry = switch (@typeInfo(T)) { - .Struct => elem, - .Union => Elem.fromT(elem), - else => @compileError("unreachable"), + .@"struct" => elem, + .@"union" => Elem.fromT(elem), + else => unreachable, }; const slices = self.slice(); inline for (fields, 0..) |field_info, field_index| { @@ -359,11 +371,8 @@ pub fn MultiArrayList(comptime T: type) type { /// If `new_len` is greater than zero, this may fail to reduce the capacity, /// but the data remains intact and the length is updated to new_len. pub fn shrinkAndFree(self: *Self, gpa: Allocator, new_len: usize) void { - if (new_len == 0) { - gpa.free(self.allocatedBytes()); - self.* = .{}; - return; - } + if (new_len == 0) return clearAndFree(self, gpa); + assert(new_len <= self.capacity); assert(new_len <= self.len); @@ -404,6 +413,11 @@ pub fn MultiArrayList(comptime T: type) type { self.* = other; } + pub fn clearAndFree(self: *Self, gpa: Allocator) void { + gpa.free(self.allocatedBytes()); + self.* = .{}; + } + /// Reduce length to `new_len`. /// Invalidates pointers to elements `items[new_len..]`. /// Keeps capacity the same. @@ -485,7 +499,7 @@ pub fn MultiArrayList(comptime T: type) type { /// `ctx` has the following method: /// `fn lessThan(ctx: @TypeOf(ctx), a_index: usize, b_index: usize) bool` - fn sortInternal(self: Self, a: usize, b: usize, ctx: anytype, comptime mode: enum { stable, unstable }) void { + fn sortInternal(self: Self, a: usize, b: usize, ctx: anytype, comptime mode: std.sort.Mode) void { const sort_context: struct { sub_ctx: @TypeOf(ctx), slice: Slice, @@ -493,7 +507,7 @@ pub fn MultiArrayList(comptime T: type) type { pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { inline for (fields, 0..) |field_info, i| { if (@sizeOf(field_info.type) != 0) { - const field = @as(Field, @enumFromInt(i)); + const field: Field = @enumFromInt(i); const ptr = sc.slice.items(field); mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); } @@ -571,7 +585,7 @@ pub fn MultiArrayList(comptime T: type) type { } fn FieldType(comptime field: Field) type { - return meta.fieldInfo(Elem, field).type; + return @FieldType(Elem, @tagName(field)); } const Entry = entry: { @@ -579,11 +593,11 @@ pub fn MultiArrayList(comptime T: type) type { for (&entry_fields, sizes.fields) |*entry_field, i| entry_field.* = .{ .name = fields[i].name ++ "_ptr", .type = *fields[i].type, - .default_value = null, + .default_value_ptr = null, .is_comptime = fields[i].is_comptime, .alignment = fields[i].alignment, }; - break :entry @Type(.{ .Struct = .{ + break :entry @Type(.{ .@"struct" = .{ .layout = .@"extern", .fields = &entry_fields, .decls = &.{}, @@ -600,329 +614,10 @@ pub fn MultiArrayList(comptime T: type) type { } comptime { - if (builtin.mode == .Debug) { + if (builtin.zig_backend == .stage2_llvm and !builtin.strip_debug_info) { _ = &dbHelper; _ = &Slice.dbHelper; } } }; } - -test "basic usage" { - const ally = testing.allocator; - - const Foo = struct { - a: u32, - b: []const u8, - c: u8, - }; - - var list = MultiArrayList(Foo){}; - defer list.deinit(ally); - - try testing.expectEqual(@as(usize, 0), list.items(.a).len); - - try list.ensureTotalCapacity(ally, 2); - - list.appendAssumeCapacity(.{ - .a = 1, - .b = "foobar", - .c = 'a', - }); - - list.appendAssumeCapacity(.{ - .a = 2, - .b = "zigzag", - .c = 'b', - }); - - try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2 }); - try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b' }); - - try testing.expectEqual(@as(usize, 2), list.items(.b).len); - try testing.expectEqualStrings("foobar", list.items(.b)[0]); - try testing.expectEqualStrings("zigzag", list.items(.b)[1]); - - try list.append(ally, .{ - .a = 3, - .b = "fizzbuzz", - .c = 'c', - }); - - try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 }); - try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' }); - - try testing.expectEqual(@as(usize, 3), list.items(.b).len); - try testing.expectEqualStrings("foobar", list.items(.b)[0]); - try testing.expectEqualStrings("zigzag", list.items(.b)[1]); - try testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]); - - // Add 6 more things to force a capacity increase. - for (0..6) |i| { - try list.append(ally, .{ - .a = @as(u32, @intCast(4 + i)), - .b = "whatever", - .c = @as(u8, @intCast('d' + i)), - }); - } - - try testing.expectEqualSlices( - u32, - &[_]u32{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, - list.items(.a), - ); - try testing.expectEqualSlices( - u8, - &[_]u8{ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i' }, - list.items(.c), - ); - - list.shrinkAndFree(ally, 3); - - try testing.expectEqualSlices(u32, list.items(.a), &[_]u32{ 1, 2, 3 }); - try testing.expectEqualSlices(u8, list.items(.c), &[_]u8{ 'a', 'b', 'c' }); - - try testing.expectEqual(@as(usize, 3), list.items(.b).len); - try testing.expectEqualStrings("foobar", list.items(.b)[0]); - try testing.expectEqualStrings("zigzag", list.items(.b)[1]); - try testing.expectEqualStrings("fizzbuzz", list.items(.b)[2]); - - list.set(try list.addOne(ally), .{ - .a = 4, - .b = "xnopyt", - .c = 'd', - }); - try testing.expectEqualStrings("xnopyt", list.pop().b); - try testing.expectEqual(@as(?u8, 'c'), if (list.popOrNull()) |elem| elem.c else null); - try testing.expectEqual(@as(u32, 2), list.pop().a); - try testing.expectEqual(@as(u8, 'a'), list.pop().c); - try testing.expectEqual(@as(?Foo, null), list.popOrNull()); -} - -// This was observed to fail on aarch64 with LLVM 11, when the capacityInBytes -// function used the @reduce code path. -test "regression test for @reduce bug" { - const ally = testing.allocator; - var list = MultiArrayList(struct { - tag: std.zig.Token.Tag, - start: u32, - }){}; - defer list.deinit(ally); - - try list.ensureTotalCapacity(ally, 20); - - try list.append(ally, .{ .tag = .keyword_const, .start = 0 }); - try list.append(ally, .{ .tag = .identifier, .start = 6 }); - try list.append(ally, .{ .tag = .equal, .start = 10 }); - try list.append(ally, .{ .tag = .builtin, .start = 12 }); - try list.append(ally, .{ .tag = .l_paren, .start = 19 }); - try list.append(ally, .{ .tag = .string_literal, .start = 20 }); - try list.append(ally, .{ .tag = .r_paren, .start = 25 }); - try list.append(ally, .{ .tag = .semicolon, .start = 26 }); - try list.append(ally, .{ .tag = .keyword_pub, .start = 29 }); - try list.append(ally, .{ .tag = .keyword_fn, .start = 33 }); - try list.append(ally, .{ .tag = .identifier, .start = 36 }); - try list.append(ally, .{ .tag = .l_paren, .start = 40 }); - try list.append(ally, .{ .tag = .r_paren, .start = 41 }); - try list.append(ally, .{ .tag = .identifier, .start = 43 }); - try list.append(ally, .{ .tag = .bang, .start = 51 }); - try list.append(ally, .{ .tag = .identifier, .start = 52 }); - try list.append(ally, .{ .tag = .l_brace, .start = 57 }); - try list.append(ally, .{ .tag = .identifier, .start = 63 }); - try list.append(ally, .{ .tag = .period, .start = 66 }); - try list.append(ally, .{ .tag = .identifier, .start = 67 }); - try list.append(ally, .{ .tag = .period, .start = 70 }); - try list.append(ally, .{ .tag = .identifier, .start = 71 }); - try list.append(ally, .{ .tag = .l_paren, .start = 75 }); - try list.append(ally, .{ .tag = .string_literal, .start = 76 }); - try list.append(ally, .{ .tag = .comma, .start = 113 }); - try list.append(ally, .{ .tag = .period, .start = 115 }); - try list.append(ally, .{ .tag = .l_brace, .start = 116 }); - try list.append(ally, .{ .tag = .r_brace, .start = 117 }); - try list.append(ally, .{ .tag = .r_paren, .start = 118 }); - try list.append(ally, .{ .tag = .semicolon, .start = 119 }); - try list.append(ally, .{ .tag = .r_brace, .start = 121 }); - try list.append(ally, .{ .tag = .eof, .start = 123 }); - - const tags = list.items(.tag); - try testing.expectEqual(tags[1], .identifier); - try testing.expectEqual(tags[2], .equal); - try testing.expectEqual(tags[3], .builtin); - try testing.expectEqual(tags[4], .l_paren); - try testing.expectEqual(tags[5], .string_literal); - try testing.expectEqual(tags[6], .r_paren); - try testing.expectEqual(tags[7], .semicolon); - try testing.expectEqual(tags[8], .keyword_pub); - try testing.expectEqual(tags[9], .keyword_fn); - try testing.expectEqual(tags[10], .identifier); - try testing.expectEqual(tags[11], .l_paren); - try testing.expectEqual(tags[12], .r_paren); - try testing.expectEqual(tags[13], .identifier); - try testing.expectEqual(tags[14], .bang); - try testing.expectEqual(tags[15], .identifier); - try testing.expectEqual(tags[16], .l_brace); - try testing.expectEqual(tags[17], .identifier); - try testing.expectEqual(tags[18], .period); - try testing.expectEqual(tags[19], .identifier); - try testing.expectEqual(tags[20], .period); - try testing.expectEqual(tags[21], .identifier); - try testing.expectEqual(tags[22], .l_paren); - try testing.expectEqual(tags[23], .string_literal); - try testing.expectEqual(tags[24], .comma); - try testing.expectEqual(tags[25], .period); - try testing.expectEqual(tags[26], .l_brace); - try testing.expectEqual(tags[27], .r_brace); - try testing.expectEqual(tags[28], .r_paren); - try testing.expectEqual(tags[29], .semicolon); - try testing.expectEqual(tags[30], .r_brace); - try testing.expectEqual(tags[31], .eof); -} - -test "ensure capacity on empty list" { - const ally = testing.allocator; - - const Foo = struct { - a: u32, - b: u8, - }; - - var list = MultiArrayList(Foo){}; - defer list.deinit(ally); - - try list.ensureTotalCapacity(ally, 2); - list.appendAssumeCapacity(.{ .a = 1, .b = 2 }); - list.appendAssumeCapacity(.{ .a = 3, .b = 4 }); - - try testing.expectEqualSlices(u32, &[_]u32{ 1, 3 }, list.items(.a)); - try testing.expectEqualSlices(u8, &[_]u8{ 2, 4 }, list.items(.b)); - - list.len = 0; - list.appendAssumeCapacity(.{ .a = 5, .b = 6 }); - list.appendAssumeCapacity(.{ .a = 7, .b = 8 }); - - try testing.expectEqualSlices(u32, &[_]u32{ 5, 7 }, list.items(.a)); - try testing.expectEqualSlices(u8, &[_]u8{ 6, 8 }, list.items(.b)); - - list.len = 0; - try list.ensureTotalCapacity(ally, 16); - - list.appendAssumeCapacity(.{ .a = 9, .b = 10 }); - list.appendAssumeCapacity(.{ .a = 11, .b = 12 }); - - try testing.expectEqualSlices(u32, &[_]u32{ 9, 11 }, list.items(.a)); - try testing.expectEqualSlices(u8, &[_]u8{ 10, 12 }, list.items(.b)); -} - -test "insert elements" { - const ally = testing.allocator; - - const Foo = struct { - a: u8, - b: u32, - }; - - var list = MultiArrayList(Foo){}; - defer list.deinit(ally); - - try list.insert(ally, 0, .{ .a = 1, .b = 2 }); - try list.ensureUnusedCapacity(ally, 1); - list.insertAssumeCapacity(1, .{ .a = 2, .b = 3 }); - - try testing.expectEqualSlices(u8, &[_]u8{ 1, 2 }, list.items(.a)); - try testing.expectEqualSlices(u32, &[_]u32{ 2, 3 }, list.items(.b)); -} - -test "union" { - const ally = testing.allocator; - - const Foo = union(enum) { - a: u32, - b: []const u8, - }; - - var list = MultiArrayList(Foo){}; - defer list.deinit(ally); - - try testing.expectEqual(@as(usize, 0), list.items(.tags).len); - - try list.ensureTotalCapacity(ally, 2); - - list.appendAssumeCapacity(.{ .a = 1 }); - list.appendAssumeCapacity(.{ .b = "zigzag" }); - - try testing.expectEqualSlices(meta.Tag(Foo), list.items(.tags), &.{ .a, .b }); - try testing.expectEqual(@as(usize, 2), list.items(.tags).len); - - list.appendAssumeCapacity(.{ .b = "foobar" }); - try testing.expectEqualStrings("zigzag", list.items(.data)[1].b); - try testing.expectEqualStrings("foobar", list.items(.data)[2].b); - - // Add 6 more things to force a capacity increase. - for (0..6) |i| { - try list.append(ally, .{ .a = @as(u32, @intCast(4 + i)) }); - } - - try testing.expectEqualSlices( - meta.Tag(Foo), - &.{ .a, .b, .b, .a, .a, .a, .a, .a, .a }, - list.items(.tags), - ); - try testing.expectEqual(list.get(0), .{ .a = 1 }); - try testing.expectEqual(list.get(1), .{ .b = "zigzag" }); - try testing.expectEqual(list.get(2), .{ .b = "foobar" }); - try testing.expectEqual(list.get(3), .{ .a = 4 }); - try testing.expectEqual(list.get(4), .{ .a = 5 }); - try testing.expectEqual(list.get(5), .{ .a = 6 }); - try testing.expectEqual(list.get(6), .{ .a = 7 }); - try testing.expectEqual(list.get(7), .{ .a = 8 }); - try testing.expectEqual(list.get(8), .{ .a = 9 }); - - list.shrinkAndFree(ally, 3); - - try testing.expectEqual(@as(usize, 3), list.items(.tags).len); - try testing.expectEqualSlices(meta.Tag(Foo), list.items(.tags), &.{ .a, .b, .b }); - - try testing.expectEqual(list.get(0), .{ .a = 1 }); - try testing.expectEqual(list.get(1), .{ .b = "zigzag" }); - try testing.expectEqual(list.get(2), .{ .b = "foobar" }); -} - -test "sorting a span" { - var list: MultiArrayList(struct { score: u32, chr: u8 }) = .{}; - defer list.deinit(testing.allocator); - - try list.ensureTotalCapacity(testing.allocator, 42); - for ( - // zig fmt: off - [42]u8{ 'b', 'a', 'c', 'a', 'b', 'c', 'b', 'c', 'b', 'a', 'b', 'a', 'b', 'c', 'b', 'a', 'a', 'c', 'c', 'a', 'c', 'b', 'a', 'c', 'a', 'b', 'b', 'c', 'c', 'b', 'a', 'b', 'a', 'b', 'c', 'b', 'a', 'a', 'c', 'c', 'a', 'c' }, - [42]u32{ 1, 1, 1, 2, 2, 2, 3, 3, 4, 3, 5, 4, 6, 4, 7, 5, 6, 5, 6, 7, 7, 8, 8, 8, 9, 9, 10, 9, 10, 11, 10, 12, 11, 13, 11, 14, 12, 13, 12, 13, 14, 14 }, - // zig fmt: on - ) |chr, score| { - list.appendAssumeCapacity(.{ .chr = chr, .score = score }); - } - - const sliced = list.slice(); - list.sortSpan(6, 21, struct { - chars: []const u8, - - fn lessThan(ctx: @This(), a: usize, b: usize) bool { - return ctx.chars[a] < ctx.chars[b]; - } - }{ .chars = sliced.items(.chr) }); - - var i: u32 = 0; - var j: u32 = 6; - var c: u8 = 'a'; - - while (j < 21) { - i = j; - j += 5; - var n: u32 = 3; - for (sliced.items(.chr)[i..j], sliced.items(.score)[i..j]) |chr, score| { - try testing.expectEqual(score, n); - try testing.expectEqual(chr, c); - n += 1; - } - c += 1; - } -} diff --git a/src/options.zig b/src/options.zig index c73fa65806a087..93a309ddc3a4b9 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1106,7 +1106,7 @@ pub const JSX = struct { // ...unless new is "React.createElement" and original is ["React", "createElement"] // saves an allocation for the majority case pub fn memberListToComponentsIfDifferent(allocator: std.mem.Allocator, original: []const string, new: string) ![]const string { - var splitter = std.mem.split(u8, new, "."); + var splitter = std.mem.splitScalar(u8, new, '.'); const count = strings.countChar(new, '.') + 1; var needs_alloc = false; @@ -1131,7 +1131,7 @@ pub const JSX = struct { var out = try allocator.alloc(string, count); - splitter = std.mem.split(u8, new, "."); + splitter = std.mem.splitScalar(u8, new, '.'); var i: usize = 0; while (splitter.next()) |str| { if (str.len == 0) continue; diff --git a/src/output.zig b/src/output.zig index 3181b2788c1db3..47b9808cb5a8be 100644 --- a/src/output.zig +++ b/src/output.zig @@ -488,7 +488,7 @@ pub fn disableBuffering() void { } pub fn panic(comptime fmt: string, args: anytype) noreturn { - @setCold(true); + @branchHint(.cold); if (isEmojiEnabled()) { std.debug.panic(comptime prettyFmt(fmt, true), args); @@ -714,7 +714,7 @@ pub const LogFunction = fn (comptime fmt: string, args: anytype) callconv(bun.ca pub fn Scoped(comptime tag: anytype, comptime disabled: bool) type { const tagname = comptime brk: { const input = switch (@TypeOf(tag)) { - @Type(.EnumLiteral) => @tagName(tag), + @Type(.enum_literal) => @tagName(tag), else => tag, }; var ascii_slice: [input.len]u8 = undefined; @@ -1064,7 +1064,7 @@ pub inline fn err(error_name: anytype, comptime fmt: []const u8, args: anytype) const T = @TypeOf(error_name); const info = @typeInfo(T); - if (comptime T == bun.sys.Error or info == .Pointer and info.Pointer.child == bun.sys.Error) { + if (comptime T == bun.sys.Error or info == .pointer and info.pointer.child == bun.sys.Error) { const e: bun.sys.Error = error_name; const tag_name, const sys_errno = e.getErrorCodeTagName() orelse { err("unknown error", fmt, args); @@ -1081,10 +1081,10 @@ pub inline fn err(error_name: anytype, comptime fmt: []const u8, args: anytype) const display_name, const is_comptime_name = display_name: { // Zig string literals are of type *const [n:0]u8 // we assume that no one will pass this type from not using a string literal. - if (info == .Pointer and info.Pointer.size == .One and info.Pointer.is_const) { - const child_info = @typeInfo(info.Pointer.child); - if (child_info == .Array and child_info.Array.child == u8) { - if (child_info.Array.len == 0) @compileError("Output.err should not be passed an empty string (use errGeneric)"); + if (info == .pointer and info.pointer.size == .one and info.pointer.is_const) { + const child_info = @typeInfo(info.pointer.child); + if (child_info == .array and child_info.array.child == u8) { + if (child_info.array.len == 0) @compileError("Output.err should not be passed an empty string (use errGeneric)"); break :display_name .{ error_name, true }; } } @@ -1095,8 +1095,8 @@ pub inline fn err(error_name: anytype, comptime fmt: []const u8, args: anytype) } // error unions - if (info == .ErrorSet) { - if (info.ErrorSet) |errors| { + if (info == .error_set) { + if (info.error_set) |errors| { if (errors.len == 0) { @compileError("Output.err was given an empty error set"); } @@ -1109,7 +1109,7 @@ pub inline fn err(error_name: anytype, comptime fmt: []const u8, args: anytype) } // enum literals - if (info == .EnumLiteral) { + if (info == .enum_literal) { const tag = @tagName(info); comptime bun.assert(tag.len > 0); // how? if (tag[0] != 'E') break :display_name .{ "E" ++ tag, true }; @@ -1117,7 +1117,7 @@ pub inline fn err(error_name: anytype, comptime fmt: []const u8, args: anytype) } // enums - if (info == .Enum) { + if (info == .@"enum") { const errno: bun.C.SystemErrno = @enumFromInt(@intFromEnum(info)); break :display_name .{ @tagName(errno), false }; } diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 4273c9893173ee..fd87fd9a82d782 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -341,17 +341,17 @@ pub const DebugLogs = struct { } pub fn increaseIndent(d: *DebugLogs) void { - @setCold(true); + @branchHint(.cold); d.indent.append(" ") catch unreachable; } pub fn decreaseIndent(d: *DebugLogs) void { - @setCold(true); + @branchHint(.cold); d.indent.list.shrinkRetainingCapacity(d.indent.list.items.len - 1); } pub fn addNote(d: *DebugLogs, _text: string) void { - @setCold(true); + @branchHint(.cold); var text = _text; const len = d.indent.len(); if (len > 0) { @@ -366,7 +366,7 @@ pub const DebugLogs = struct { } pub fn addNoteFmt(d: *DebugLogs, comptime fmt: string, args: anytype) void { - @setCold(true); + @branchHint(.cold); return d.addNote(std.fmt.allocPrint(d.notes.allocator, fmt, args) catch unreachable); } }; @@ -1843,7 +1843,7 @@ pub const Resolver = struct { // https://nodejs.org/api/modules.html#loading-from-the-global-folders const node_path: []const u8 = if (r.env_loader) |env_loader| env_loader.get("NODE_PATH") orelse "" else ""; if (node_path.len > 0) { - var it = std.mem.tokenize(u8, node_path, if (Environment.isWindows) ";" else ":"); + var it = std.mem.tokenizeScalar(u8, node_path, if (Environment.isWindows) ';' else ':'); while (it.next()) |path| { const abs_path = r.fs.absBuf(&[_]string{ path, import_path }, bufs(.node_modules_check)); if (r.debug_logs) |*debug| { @@ -1866,7 +1866,7 @@ pub const Resolver = struct { // check the global cache directory for a package.json file. const manager = r.getPackageManager(); var dependency_version = Dependency.Version{}; - var dependency_behavior = Dependency.Behavior.prod; + var dependency_behavior: Dependency.Behavior = .{ .prod = true }; var string_buf = esm.version; // const initial_pending_tasks = manager.pending_tasks; @@ -3362,7 +3362,7 @@ pub const Resolver = struct { comptime { const Resolver__nodeModulePathsForJS = JSC.toJSHostFunction(Resolver__nodeModulePathsForJS_); - @export(Resolver__nodeModulePathsForJS, .{ .name = "Resolver__nodeModulePathsForJS" }); + @export(&Resolver__nodeModulePathsForJS, .{ .name = "Resolver__nodeModulePathsForJS" }); } pub fn Resolver__nodeModulePathsForJS_(globalThis: *bun.JSC.JSGlobalObject, callframe: *bun.JSC.CallFrame) bun.JSError!JSC.JSValue { bun.JSC.markBinding(@src()); diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index c4e40a70569ef4..0eb8a1832154e2 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -424,7 +424,7 @@ pub const TSConfigJSON = struct { return parts.items; } - var iter = std.mem.tokenize(u8, text, "."); + var iter = std.mem.tokenizeScalar(u8, text, '.'); while (iter.next()) |part| { if (!js_lexer.isIdentifier(part)) { diff --git a/src/s3/client.zig b/src/s3/client.zig index 6d527ff9f2afa0..a5f9fdfd424a53 100644 --- a/src/s3/client.zig +++ b/src/s3/client.zig @@ -202,7 +202,7 @@ const S3UploadStreamWrapper = struct { callback_context: *anyopaque, ref_count: u32 = 1, path: []const u8, // this is owned by the task not by the wrapper - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn resolve(result: S3UploadResult, self: *@This()) void { const sink = self.sink; defer self.deref(); @@ -282,9 +282,9 @@ pub const Export = shim.exportFunctions(.{ }); comptime { const jsonResolveRequestStream = JSC.toJSHostFunction(onUploadStreamResolveRequestStream); - @export(jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); + @export(&jsonResolveRequestStream, .{ .name = Export[0].symbol_name }); const jsonRejectRequestStream = JSC.toJSHostFunction(onUploadStreamRejectRequestStream); - @export(jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); + @export(&jsonRejectRequestStream, .{ .name = Export[1].symbol_name }); } /// consumes the readable stream and upload to s3 diff --git a/src/s3/credentials.zig b/src/s3/credentials.zig index 2c10db4d8ad2a0..a8701f335354b6 100644 --- a/src/s3/credentials.zig +++ b/src/s3/credentials.zig @@ -23,7 +23,7 @@ pub const S3Credentials = struct { insecure_http: bool = false, ref_count: u32 = 1, - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); pub fn estimatedSize(this: *const @This()) usize { return @sizeOf(S3Credentials) + this.accessKeyId.len + this.region.len + this.secretAccessKey.len + this.endpoint.len + this.bucket.len; diff --git a/src/s3/multipart.zig b/src/s3/multipart.zig index 0ff45d5da43b2b..5fa8502cd7f375 100644 --- a/src/s3/multipart.zig +++ b/src/s3/multipart.zig @@ -145,7 +145,7 @@ pub const MultiPartUpload = struct { callback: *const fn (S3SimpleRequest.S3UploadResult, *anyopaque) void, callback_context: *anyopaque, - pub usingnamespace bun.NewRefCounted(@This(), @This().deinit); + pub usingnamespace bun.NewRefCounted(@This(), deinit, null); const log = bun.Output.scoped(.S3MultiPartUpload, true); diff --git a/src/shell/interpreter.zig b/src/shell/interpreter.zig index f515e175c67036..d2a08a3f4d869a 100644 --- a/src/shell/interpreter.zig +++ b/src/shell/interpreter.zig @@ -1792,18 +1792,15 @@ pub const Interpreter = struct { } pub fn hasPendingActivity(this: *ThisInterpreter) bool { - @fence(.seq_cst); return this.has_pending_activity.load(.seq_cst) > 0; } fn incrPendingActivityFlag(has_pending_activity: *std.atomic.Value(u32)) void { - @fence(.seq_cst); _ = has_pending_activity.fetchAdd(1, .seq_cst); log("Interpreter incr pending activity {d}", .{has_pending_activity.load(.seq_cst)}); } fn decrPendingActivityFlag(has_pending_activity: *std.atomic.Value(u32)) void { - @fence(.seq_cst); _ = has_pending_activity.fetchSub(1, .seq_cst); log("Interpreter decr pending activity {d}", .{has_pending_activity.load(.seq_cst)}); } @@ -5338,9 +5335,9 @@ pub const Interpreter = struct { const Blob = struct { ref_count: usize = 1, blob: bun.JSC.WebCore.Blob, - pub usingnamespace bun.NewRefCounted(Blob, Blob.deinit); + pub usingnamespace bun.NewRefCounted(Blob, _deinit, null); - pub fn deinit(this: *Blob) void { + fn _deinit(this: *Blob) void { this.blob.deinit(); bun.destroy(this); } @@ -5680,7 +5677,7 @@ pub const Interpreter = struct { } /// If the stdout/stderr is supposed to be captured then get the bytelist associated with that - pub fn stdBufferedBytelist(this: *Builtin, comptime io_kind: @Type(.EnumLiteral)) ?*bun.ByteList { + pub fn stdBufferedBytelist(this: *Builtin, comptime io_kind: @Type(.enum_literal)) ?*bun.ByteList { if (comptime io_kind != .stdout and io_kind != .stderr) { @compileError("Bad IO" ++ @tagName(io_kind)); } @@ -5702,7 +5699,7 @@ pub const Interpreter = struct { } /// **WARNING** You should make sure that stdout/stderr does not need IO (e.g. `.needsIO(.stderr)` is false before caling `.writeNoIO(.stderr, buf)`) - pub fn writeNoIO(this: *Builtin, comptime io_kind: @Type(.EnumLiteral), buf: []const u8) Maybe(usize) { + pub fn writeNoIO(this: *Builtin, comptime io_kind: @Type(.enum_literal), buf: []const u8) Maybe(usize) { if (comptime io_kind != .stdout and io_kind != .stderr) { @compileError("Bad IO" ++ @tagName(io_kind)); } @@ -6368,8 +6365,8 @@ pub const Interpreter = struct { var node_fs = JSC.Node.NodeFS{}; const milliseconds: f64 = @floatFromInt(std.time.milliTimestamp()); const atime: JSC.Node.TimeLike = if (bun.Environment.isWindows) milliseconds / 1000.0 else JSC.Node.TimeLike{ - .tv_sec = @intFromFloat(@divFloor(milliseconds, std.time.ms_per_s)), - .tv_nsec = @intFromFloat(@mod(milliseconds, std.time.ms_per_s) * std.time.ns_per_ms), + .sec = @intFromFloat(@divFloor(milliseconds, std.time.ms_per_s)), + .nsec = @intFromFloat(@mod(milliseconds, std.time.ms_per_s) * std.time.ns_per_ms), }; const mtime = atime; const args = JSC.Node.Arguments.Utimes{ @@ -6906,7 +6903,7 @@ pub const Interpreter = struct { } }; - pub fn writeOutput(this: *Export, comptime io_kind: @Type(.EnumLiteral), comptime fmt: []const u8, args: anytype) Maybe(void) { + pub fn writeOutput(this: *Export, comptime io_kind: @Type(.enum_literal), comptime fmt: []const u8, args: anytype) Maybe(void) { if (this.bltn.stdout.needsIO()) |safeguard| { var output: *BuiltinIO.Output = &@field(this.bltn, @tagName(io_kind)); this.printing = true; @@ -8733,16 +8730,14 @@ pub const Interpreter = struct { } }, - fn incrementOutputCount(this: *@This(), comptime thevar: @Type(.EnumLiteral)) void { - @fence(.seq_cst); + fn incrementOutputCount(this: *@This(), comptime thevar: @Type(.enum_literal)) void { var atomicvar = &@field(this, @tagName(thevar)); const result = atomicvar.fetchAdd(1, .seq_cst); log("[rm] {s}: {d} + 1", .{ @tagName(thevar), result }); return; } - fn getOutputCount(this: *@This(), comptime thevar: @Type(.EnumLiteral)) usize { - @fence(.seq_cst); + fn getOutputCount(this: *@This(), comptime thevar: @Type(.enum_literal)) usize { var atomicvar = &@field(this, @tagName(thevar)); return atomicvar.load(.seq_cst); } @@ -10109,8 +10104,8 @@ pub const Interpreter = struct { bltn: *Builtin, state: enum { idle, waiting_io, err, done } = .idle, buf: std.ArrayListUnmanaged(u8) = .{}, - start: f32 = 1, - end: f32 = 1, + _start: f32 = 1, + _end: f32 = 1, increment: f32 = 1, separator: string = "\n", terminator: string = "", @@ -10155,27 +10150,27 @@ pub const Interpreter = struct { const maybe1 = iter.next().?; const int1 = bun.fmt.parseFloat(f32, bun.sliceTo(maybe1, 0)) catch return this.fail("seq: invalid argument\n"); - this.end = int1; - if (this.start > this.end) this.increment = -1; + this._end = int1; + if (this._start > this._end) this.increment = -1; const maybe2 = iter.next(); if (maybe2 == null) return this.do(); const int2 = bun.fmt.parseFloat(f32, bun.sliceTo(maybe2.?, 0)) catch return this.fail("seq: invalid argument\n"); - this.start = int1; - this.end = int2; - if (this.start < this.end) this.increment = 1; - if (this.start > this.end) this.increment = -1; + this._start = int1; + this._end = int2; + if (this._start < this._end) this.increment = 1; + if (this._start > this._end) this.increment = -1; const maybe3 = iter.next(); if (maybe3 == null) return this.do(); const int3 = bun.fmt.parseFloat(f32, bun.sliceTo(maybe3.?, 0)) catch return this.fail("seq: invalid argument\n"); - this.start = int1; + this._start = int1; this.increment = int2; - this.end = int3; + this._end = int3; if (this.increment == 0) return this.fail("seq: zero increment\n"); - if (this.start > this.end and this.increment > 0) return this.fail("seq: needs negative decrement\n"); - if (this.start < this.end and this.increment < 0) return this.fail("seq: needs positive increment\n"); + if (this._start > this._end and this.increment > 0) return this.fail("seq: needs negative decrement\n"); + if (this._start < this._end and this.increment < 0) return this.fail("seq: needs positive increment\n"); return this.do(); } @@ -10192,11 +10187,11 @@ pub const Interpreter = struct { } fn do(this: *@This()) Maybe(void) { - var current = this.start; + var current = this._start; var arena = std.heap.ArenaAllocator.init(bun.default_allocator); defer arena.deinit(); - while (if (this.increment > 0) current <= this.end else current >= this.end) : (current += this.increment) { + while (if (this.increment > 0) current <= this._end else current >= this._end) : (current += this.increment) { const str = std.fmt.allocPrint(arena.allocator(), "{d}", .{current}) catch bun.outOfMemory(); defer _ = arena.reset(.retain_capacity); _ = this.print(str); @@ -11136,8 +11131,7 @@ pub const Interpreter = struct { pub const ChildPtr = IOReaderChildPtr; pub const ReaderImpl = bun.io.BufferedReader; - pub const DEBUG_REFCOUNT_NAME: []const u8 = "IOReaderRefCount"; - pub usingnamespace bun.NewRefCounted(@This(), IOReader.asyncDeinit); + pub usingnamespace bun.NewRefCounted(@This(), asyncDeinit, "IOReaderRefCount"); const InitFlags = packed struct(u8) { pollable: bool = false, @@ -11403,8 +11397,6 @@ pub const Interpreter = struct { started: bool = false, flags: InitFlags = .{}, - pub const DEBUG_REFCOUNT_NAME: []const u8 = "IOWriterRefCount"; - const debug = bun.Output.scoped(.IOWriter, true); const ChildPtr = IOWriterChildPtr; @@ -11416,7 +11408,7 @@ pub const Interpreter = struct { pub const auto_poll = false; - pub usingnamespace bun.NewRefCounted(@This(), asyncDeinit); + pub usingnamespace bun.NewRefCounted(@This(), asyncDeinit, "IOWriterRefCount"); const This = @This(); pub const WriterImpl = bun.io.BufferedWriter( This, @@ -11940,7 +11932,7 @@ pub fn StatePtrUnion(comptime TypesValue: anytype) type { pub fn init(_ptr: anytype) @This() { const tyinfo = @typeInfo(@TypeOf(_ptr)); - if (tyinfo != .Pointer) @compileError("Only pass pointers to StatePtrUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); + if (tyinfo != .pointer) @compileError("Only pass pointers to StatePtrUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); const Type = std.meta.Child(@TypeOf(_ptr)); Ptr.assert_type(Type); @@ -11957,7 +11949,7 @@ pub fn MaybeChild(comptime T: type) type { return switch (@typeInfo(T)) { .Array => |info| info.child, .Vector => |info| info.child, - .Pointer => |info| info.child, + .pointer => |info| info.child, .Optional => |info| info.child, else => T, }; @@ -12089,8 +12081,8 @@ inline fn errnocast(errno: anytype) u16 { inline fn fastMod(val: anytype, comptime rhs: comptime_int) @TypeOf(val) { const Value = @typeInfo(@TypeOf(val)); - if (Value != .Int) @compileError("LHS of fastMod should be an int"); - if (Value.Int.signedness != .unsigned) @compileError("LHS of fastMod should be unsigned"); + if (Value != .int) @compileError("LHS of fastMod should be an int"); + if (Value.int.signedness != .unsigned) @compileError("LHS of fastMod should be unsigned"); if (!comptime std.math.isPowerOfTwo(rhs)) @compileError("RHS of fastMod should be power of 2"); return val & (rhs - 1); @@ -12242,7 +12234,7 @@ const ShellSyscall = struct { return Syscall.fstatat(dir, path_); } - fn openat(dir: bun.FileDescriptor, path: [:0]const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { + fn openat(dir: bun.FileDescriptor, path: [:0]const u8, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (bun.Environment.isWindows) { if (flags & bun.O.DIRECTORY != 0) { if (ResolvePath.Platform.posix.isAbsolute(path[0..path.len])) { diff --git a/src/shell/shell.zig b/src/shell/shell.zig index 6133dc62c17935..352ca854908a4d 100644 --- a/src/shell/shell.zig +++ b/src/shell/shell.zig @@ -226,7 +226,7 @@ pub const GlobalJS = struct { }; } - pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]u8 { + pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]const u8 { return this.globalThis.bunVM().transpiler.env.map.createNullDelimitedEnvMap(alloc); } @@ -298,7 +298,7 @@ pub const GlobalMini = struct { }; } - pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]u8 { + pub inline fn createNullDelimitedEnvMap(this: @This(), alloc: Allocator) ![:null]?[*:0]const u8 { return this.mini.env.?.map.createNullDelimitedEnvMap(alloc); } @@ -770,10 +770,10 @@ pub const AST = struct { return .{ .stdout = true, .duplicate = true }; } - pub fn toFlags(this: RedirectFlags) bun.Mode { - const read_write_flags: bun.Mode = if (this.stdin) bun.O.RDONLY else bun.O.WRONLY | bun.O.CREAT; - const extra: bun.Mode = if (this.append) bun.O.APPEND else bun.O.TRUNC; - const final_flags: bun.Mode = if (this.stdin) read_write_flags else extra | read_write_flags; + pub fn toFlags(this: RedirectFlags) i32 { + const read_write_flags: i32 = if (this.stdin) bun.O.RDONLY else bun.O.WRONLY | bun.O.CREAT; + const extra: i32 = if (this.append) bun.O.APPEND else bun.O.TRUNC; + const final_flags: i32 = if (this.stdin) read_write_flags else extra | read_write_flags; return final_flags; } @@ -986,7 +986,7 @@ pub const Parser = struct { /// If you make a subparser and call some fallible functions on it, you need to catch the errors and call `.continue_from_subparser()`, otherwise errors /// will not propagate upwards to the parent. pub fn make_subparser(this: *Parser, kind: SubshellKind) Parser { - const subparser = .{ + const subparser: Parser = .{ .strpool = this.strpool, .tokens = this.tokens, .alloc = this.alloc, @@ -1146,7 +1146,7 @@ pub const Parser = struct { return expr; } - fn extractIfClauseTextToken(comptime if_clause_token: @TypeOf(.EnumLiteral)) []const u8 { + fn extractIfClauseTextToken(comptime if_clause_token: @TypeOf(.enum_literal)) []const u8 { const tagname = comptime switch (if_clause_token) { .@"if" => "if", .@"else" => "else", @@ -1158,7 +1158,7 @@ pub const Parser = struct { return tagname; } - fn expectIfClauseTextToken(self: *Parser, comptime if_clause_token: @TypeOf(.EnumLiteral)) Token { + fn expectIfClauseTextToken(self: *Parser, comptime if_clause_token: @TypeOf(.enum_literal)) Token { const tagname = comptime extractIfClauseTextToken(if_clause_token); if (bun.Environment.allow_assert) assert(@as(TokenTag, self.peek()) == .Text); if (self.peek() == .Text and @@ -1172,14 +1172,14 @@ pub const Parser = struct { @panic("Expected: " ++ @tagName(if_clause_token)); } - fn isIfClauseTextToken(self: *Parser, comptime if_clause_token: @TypeOf(.EnumLiteral)) bool { + fn isIfClauseTextToken(self: *Parser, comptime if_clause_token: @TypeOf(.enum_literal)) bool { return switch (self.peek()) { .Text => |range| self.isIfClauseTextTokenImpl(range, if_clause_token), else => false, }; } - fn isIfClauseTextTokenImpl(self: *Parser, range: Token.TextRange, comptime if_clause_token: @TypeOf(.EnumLiteral)) bool { + fn isIfClauseTextTokenImpl(self: *Parser, range: Token.TextRange, comptime if_clause_token: @TypeOf(.enum_literal)) bool { const tagname = comptime extractIfClauseTextToken(if_clause_token); return bun.strings.eqlComptime(self.text(range), tagname); } @@ -2248,7 +2248,7 @@ pub fn NewLexer(comptime encoding: StringEncoding) type { fn make_sublexer(self: *@This(), kind: SubShellKind) @This() { log("[lex] make sublexer", .{}); - var sublexer = .{ + var sublexer: @This() = .{ .chars = self.chars, .strpool = self.strpool, .tokens = self.tokens, @@ -2727,7 +2727,7 @@ pub fn NewLexer(comptime encoding: StringEncoding) type { } fn appendUnicodeCharToStrPool(self: *@This(), char: Chars.CodepointType) !void { - @setCold(true); + @branchHint(.cold); const ichar: i32 = @intCast(char); var bytes: [4]u8 = undefined; diff --git a/src/shell/subproc.zig b/src/shell/subproc.zig index 940e117562ebe4..9ced2d1fa7f91c 100644 --- a/src/shell/subproc.zig +++ b/src/shell/subproc.zig @@ -511,7 +511,7 @@ pub const ShellSubprocess = struct { return this.process.kill(@intCast(sig)); } - // fn hasCalledGetter(this: *Subprocess, comptime getter: @Type(.EnumLiteral)) bool { + // fn hasCalledGetter(this: *Subprocess, comptime getter: @Type(.enum_literal)) bool { // return this.observable_getters.contains(getter); // } @@ -528,7 +528,7 @@ pub const ShellSubprocess = struct { // this.ipc_mode = .none; } - pub fn closeIO(this: *@This(), comptime io: @Type(.EnumLiteral)) void { + pub fn closeIO(this: *@This(), comptime io: @Type(.enum_literal)) void { if (this.closed.contains(io)) return; log("close IO {s}", .{@tagName(io)}); this.closed.insert(io); @@ -1020,7 +1020,7 @@ pub const PipeReader = struct { } }; - pub usingnamespace bun.NewRefCounted(PipeReader, deinit); + pub usingnamespace bun.NewRefCounted(PipeReader, deinit, null); pub const CapturedWriter = struct { dead: bool = true, diff --git a/src/sourcemap/CodeCoverage.zig b/src/sourcemap/CodeCoverage.zig index 4385ec626b67d2..2075f1d4c94571 100644 --- a/src/sourcemap/CodeCoverage.zig +++ b/src/sourcemap/CodeCoverage.zig @@ -706,10 +706,10 @@ pub const ByteRangeMapping = struct { comptime { if (bun.Environment.isNative) { - @export(ByteRangeMapping.generate, .{ .name = "ByteRangeMapping__generate" }); - @export(ByteRangeMapping.findExecutedLines, .{ .name = "ByteRangeMapping__findExecutedLines" }); - @export(ByteRangeMapping.find, .{ .name = "ByteRangeMapping__find" }); - @export(ByteRangeMapping.getSourceID, .{ .name = "ByteRangeMapping__getSourceID" }); + @export(&ByteRangeMapping.generate, .{ .name = "ByteRangeMapping__generate" }); + @export(&ByteRangeMapping.findExecutedLines, .{ .name = "ByteRangeMapping__findExecutedLines" }); + @export(&ByteRangeMapping.find, .{ .name = "ByteRangeMapping__find" }); + @export(&ByteRangeMapping.getSourceID, .{ .name = "ByteRangeMapping__getSourceID" }); } } diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig index 41ddfd67f13d67..50c37980c19953 100644 --- a/src/sourcemap/sourcemap.zig +++ b/src/sourcemap/sourcemap.zig @@ -640,7 +640,7 @@ pub const ParsedSourceMap = struct { is_standalone_module_graph: bool = false, - pub usingnamespace bun.NewThreadSafeRefCounted(ParsedSourceMap, deinitFn); + pub usingnamespace bun.NewThreadSafeRefCounted(ParsedSourceMap, deinitFn, null); const SourceContentPtr = packed struct(u64) { load_hint: SourceMapLoadHint = .none, diff --git a/src/sql/postgres.zig b/src/sql/postgres.zig index 4ca76484e4ae9d..cacf84965719b9 100644 --- a/src/sql/postgres.zig +++ b/src/sql/postgres.zig @@ -244,7 +244,7 @@ pub const PostgresSQLContext = struct { comptime { const js_init = JSC.toJSHostFunction(init); - @export(js_init, .{ .name = "PostgresSQLContext__init" }); + @export(&js_init, .{ .name = "PostgresSQLContext__init" }); } }; pub const PostgresSQLQueryResultMode = enum(u8) { @@ -800,7 +800,7 @@ pub const PostgresSQLQuery = struct { comptime { const jscall = JSC.toJSHostFunction(call); - @export(jscall, .{ .name = "PostgresSQLQuery__createInstance" }); + @export(&jscall, .{ .name = "PostgresSQLQuery__createInstance" }); } }; @@ -879,7 +879,7 @@ pub const PostgresRequest = struct { continue; } if (comptime bun.Environment.enable_logs) { - debug(" -> {s}", .{tag.name() orelse "(unknown)"}); + debug(" -> {s}", .{tag.tagName() orelse "(unknown)"}); } switch ( @@ -1419,12 +1419,10 @@ pub const PostgresSQLConnection = struct { } pub fn hasPendingActivity(this: *PostgresSQLConnection) bool { - @fence(.acquire); return this.pending_activity_count.load(.acquire) > 0; } fn updateHasPendingActivity(this: *PostgresSQLConnection) void { - @fence(.release); const a: u32 = if (this.requests.readableLength() > 0) 1 else 0; const b: u32 = if (this.status != .disconnected) 1 else 0; this.pending_activity_count.store(a + b, .release); @@ -1728,7 +1726,7 @@ pub const PostgresSQLConnection = struct { comptime { const jscall = JSC.toJSHostFunction(call); - @export(jscall, .{ .name = "PostgresSQLConnection__createInstance" }); + @export(&jscall, .{ .name = "PostgresSQLConnection__createInstance" }); } pub fn call(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue { @@ -2412,7 +2410,7 @@ pub const PostgresSQLConnection = struct { fn pg_ntoT(comptime IntSize: usize, i: anytype) std.meta.Int(.unsigned, IntSize) { @setRuntimeSafety(false); const T = @TypeOf(i); - if (@typeInfo(T) == .Array) { + if (@typeInfo(T) == .array) { return pg_ntoT(IntSize, @as(std.meta.Int(.unsigned, IntSize), @bitCast(i))); } @@ -2668,7 +2666,7 @@ pub const PostgresSQLConnection = struct { return PostgresSQLConnection.queriesGetCached(this.js_value) orelse .zero; } - pub fn on(this: *PostgresSQLConnection, comptime MessageType: @Type(.EnumLiteral), comptime Context: type, reader: protocol.NewReader(Context)) AnyPostgresError!void { + pub fn on(this: *PostgresSQLConnection, comptime MessageType: @Type(.enum_literal), comptime Context: type, reader: protocol.NewReader(Context)) AnyPostgresError!void { debug("on({s})", .{@tagName(MessageType)}); if (comptime MessageType != .ReadyForQuery) { this.is_ready_for_query = false; diff --git a/src/sql/postgres/postgres_types.zig b/src/sql/postgres/postgres_types.zig index a6fa23ff73f906..83a1e8488138cc 100644 --- a/src/sql/postgres/postgres_types.zig +++ b/src/sql/postgres/postgres_types.zig @@ -177,7 +177,7 @@ pub const Tag = enum(short) { jsonpath_array = 4073, _, - pub fn name(this: Tag) ?[]const u8 { + pub fn tagName(this: Tag) ?[]const u8 { return std.enums.tagName(Tag, this); } diff --git a/src/string.zig b/src/string.zig index f0dda92cbb6d73..411be37d49fe35 100644 --- a/src/string.zig +++ b/src/string.zig @@ -592,10 +592,10 @@ pub const String = extern struct { const info = @typeInfo(Type); // Zig string literals - if (info == .Pointer and info.Pointer.size == .One and info.Pointer.is_const) { - const child_info = @typeInfo(info.Pointer.child); - if (child_info == .Array and child_info.Array.child == u8) { - if (child_info.Array.len == 0) return String.empty; + if (info == .pointer and info.pointer.size == .one and info.pointer.is_const) { + const child_info = @typeInfo(info.pointer.child); + if (child_info == .array and child_info.array.child == u8) { + if (child_info.array.len == 0) return String.empty; return static(value); } } diff --git a/src/string_immutable.zig b/src/string_immutable.zig index f3446289df69a0..365d1acda0bc56 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -1091,7 +1091,7 @@ fn eqlComptimeCheckLenWithKnownType(comptime Type: type, a: []const Type, compti /// strings.eqlComptime(input, "hello world"); /// strings.eqlComptime(input, "hai"); pub fn eqlComptimeCheckLenWithType(comptime Type: type, a: []const Type, comptime b: anytype, comptime check_len: bool) bool { - return eqlComptimeCheckLenWithKnownType(comptime Type, a, if (@typeInfo(@TypeOf(b)) != .Pointer) &b else b, comptime check_len); + return eqlComptimeCheckLenWithKnownType(comptime Type, a, if (@typeInfo(@TypeOf(b)) != .pointer) &b else b, comptime check_len); } pub fn eqlCaseInsensitiveASCIIIgnoreLength( @@ -4762,6 +4762,7 @@ pub fn indexOfLineRanges(text: []const u8, target_line: u32, comptime line_range else => continue, } } + @panic("unreachable"); }; if (ranges.len == line_range_count and current_line <= target_line) { @@ -5553,7 +5554,7 @@ pub fn cloneNormalizingSeparators( ) ![]u8 { // remove duplicate slashes in the file path const base = withoutTrailingSlash(input); - var tokenized = std.mem.tokenize(u8, base, std.fs.path.sep_str); + var tokenized = std.mem.tokenizeScalar(u8, base, std.fs.path.sep); var buf = try allocator.alloc(u8, base.len + 2); if (comptime Environment.allow_assert) assert(base.len > 0); if (base[0] == std.fs.path.sep) { diff --git a/src/sync.zig b/src/sync.zig index b71040f6fab026..e147116ec6485c 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -634,7 +634,7 @@ pub const RwLock = if (@import("builtin").os.tag != .windows and @import("builti writer_count: i32 = 0, waiters: [2]?*anyopaque = [_]?*anyopaque{ null, null }, }, - .kfreebsd, .freebsd, .openbsd => extern struct { + .freebsd, .openbsd => extern struct { ptr: ?*anyopaque = null, }, .hermit => extern struct { @@ -946,7 +946,7 @@ else if (@import("builtin").os.tag == .linux) } fn lockSlow(self: *Mutex, current_state: State) void { - @setCold(true); + @branchHint(.cold); var new_state = current_state; while (true) { @@ -992,7 +992,7 @@ else if (@import("builtin").os.tag == .linux) } fn unlockSlow(self: *Mutex) void { - @setCold(true); + @branchHint(.cold); Futex.wake(@as(*const i32, @ptrCast(&self.state))); } diff --git a/src/sys.zig b/src/sys.zig index 039a9625537833..1d6dc575beb23c 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -65,11 +65,11 @@ pub const O = switch (Environment.os) { pub const NOFOLLOW = 0x0100; pub const SYMLINK = 0x200000; pub const EVTONLY = 0x8000; - pub const CLOEXEC = 0x1000000; + pub const CLOEXEC = 0x01000000; pub const ACCMODE = 3; pub const ALERT = 536870912; pub const ASYNC = 64; - pub const DIRECTORY = 1048576; + pub const DIRECTORY = 0x00100000; pub const DP_GETRAWENCRYPTED = 1; pub const DP_GETRAWUNENCRYPTED = 2; pub const DSYNC = 4194304; @@ -456,6 +456,7 @@ pub const Error = struct { /// Simpler formatting which does not allocate a message pub fn toShellSystemError(this: Error) SystemError { + @setEvalBranchQuota(1_000_000); var err = SystemError{ .errno = @as(c_int, this.errno) * -1, .syscall = bun.String.static(@tagName(this.syscall)), @@ -878,7 +879,7 @@ pub fn fstatat(fd: bun.FileDescriptor, path: [:0]const u8) Maybe(bun.Stat) { return Maybe(bun.Stat){ .result = stat_buf }; } -pub fn mkdir(file_path: [:0]const u8, flags: bun.Mode) Maybe(void) { +pub fn mkdir(file_path: [:0]const u8, flags: mode_t) Maybe(void) { return switch (Environment.os) { .mac => Maybe(void).errnoSysP(syscall.mkdir(file_path, flags), .mkdir, file_path) orelse Maybe(void).success, @@ -888,7 +889,7 @@ pub fn mkdir(file_path: [:0]const u8, flags: bun.Mode) Maybe(void) { const wbuf = bun.WPathBufferPool.get(); defer bun.WPathBufferPool.put(wbuf); return Maybe(void).errnoSysP( - kernel32.CreateDirectoryW(bun.strings.toKernel32Path(wbuf, file_path).ptr, null), + bun.windows.CreateDirectoryW(bun.strings.toKernel32Path(wbuf, file_path).ptr, null), .mkdir, file_path, ) orelse Maybe(void).success; @@ -898,7 +899,7 @@ pub fn mkdir(file_path: [:0]const u8, flags: bun.Mode) Maybe(void) { }; } -pub fn mkdirA(file_path: []const u8, flags: bun.Mode) Maybe(void) { +pub fn mkdirA(file_path: []const u8, flags: mode_t) Maybe(void) { if (comptime Environment.isMac) { return Maybe(void).errnoSysP(syscall.mkdir(&(std.posix.toPosixPath(file_path) catch return Maybe(void){ .err = .{ @@ -930,7 +931,7 @@ pub fn mkdirA(file_path: []const u8, flags: bun.Mode) Maybe(void) { } } -pub fn mkdirOSPath(file_path: bun.OSPathSliceZ, flags: bun.Mode) Maybe(void) { +pub fn mkdirOSPath(file_path: bun.OSPathSliceZ, flags: mode_t) Maybe(void) { return switch (Environment.os) { else => mkdir(file_path, flags), .windows => { @@ -1572,11 +1573,11 @@ pub noinline fn openFileAtWindowsA( return openFileAtWindowsT(u8, dirFd, path, opts); } -pub fn openatWindowsT(comptime T: type, dir: bun.FileDescriptor, path: []const T, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn openatWindowsT(comptime T: type, dir: bun.FileDescriptor, path: []const T, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { return openatWindowsTMaybeNormalize(T, dir, path, flags, perm, true); } -fn openatWindowsTMaybeNormalize(comptime T: type, dir: bun.FileDescriptor, path: []const T, flags: bun.Mode, perm: bun.Mode, comptime normalize: bool) Maybe(bun.FileDescriptor) { +fn openatWindowsTMaybeNormalize(comptime T: type, dir: bun.FileDescriptor, path: []const T, flags: i32, perm: bun.Mode, comptime normalize: bool) Maybe(bun.FileDescriptor) { if (flags & O.DIRECTORY != 0) { const windows_options: WindowsOpenDirOptions = .{ .iterable = flags & O.PATH == 0, @@ -1652,7 +1653,7 @@ fn openatWindowsTMaybeNormalize(comptime T: type, dir: bun.FileDescriptor, path: pub fn openatWindows( dir: anytype, path: []const u16, - flags: bun.Mode, + flags: i32, perm: bun.Mode, ) Maybe(bun.FileDescriptor) { return openatWindowsT(u16, bun.toFD(dir), path, flags, perm); @@ -1661,13 +1662,13 @@ pub fn openatWindows( pub fn openatWindowsA( dir: bun.FileDescriptor, path: []const u8, - flags: bun.Mode, + flags: i32, perm: bun.Mode, ) Maybe(bun.FileDescriptor) { return openatWindowsT(u8, dir, path, flags, perm); } -pub fn openatOSPath(dirfd: bun.FileDescriptor, file_path: bun.OSPathSliceZ, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn openatOSPath(dirfd: bun.FileDescriptor, file_path: bun.OSPathSliceZ, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (comptime Environment.isMac) { // https://opensource.apple.com/source/xnu/xnu-7195.81.3/libsyscall/wrappers/open-base.c const rc = syscall.@"openat$NOCANCEL"(dirfd.cast(), file_path.ptr, @as(c_uint, @intCast(flags)), @as(c_int, @intCast(perm))); @@ -1699,7 +1700,7 @@ pub fn openatOSPath(dirfd: bun.FileDescriptor, file_path: bun.OSPathSliceZ, flag } } -pub fn access(path: bun.OSPathSliceZ, mode: bun.Mode) Maybe(void) { +pub fn access(path: bun.OSPathSliceZ, mode: i32) Maybe(void) { if (Environment.isWindows) { const attrs = getFileAttributes(path) orelse { return .{ .err = .{ @@ -1723,7 +1724,7 @@ pub fn access(path: bun.OSPathSliceZ, mode: bun.Mode) Maybe(void) { return Maybe(void).errnoSysP(syscall.access(path, mode), .access, path) orelse .{ .result = {} }; } -pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn openat(dirfd: bun.FileDescriptor, file_path: [:0]const u8, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (comptime Environment.isWindows) { return openatWindowsT(u8, dirfd, file_path, flags, perm); } else { @@ -1745,7 +1746,7 @@ pub fn openatFileWithLibuvFlags(dirfd: bun.FileDescriptor, file_path: [:0]const } } -pub fn openatA(dirfd: bun.FileDescriptor, file_path: []const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn openatA(dirfd: bun.FileDescriptor, file_path: []const u8, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { if (comptime Environment.isWindows) { return openatWindowsT(u8, dirfd, file_path, flags, perm); } @@ -1765,12 +1766,12 @@ pub fn openatA(dirfd: bun.FileDescriptor, file_path: []const u8, flags: bun.Mode ); } -pub fn openA(file_path: []const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn openA(file_path: []const u8, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { // this is what open() does anyway. return openatA(bun.toFD((std.fs.cwd().fd)), file_path, flags, perm); } -pub fn open(file_path: [:0]const u8, flags: bun.Mode, perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn open(file_path: [:0]const u8, flags: i32, perm: bun.Mode) Maybe(bun.FileDescriptor) { // TODO(@paperclover): this should not use libuv; when the libuv path is // removed here, the call sites in node_fs.zig should make sure they parse // the libuv specific file flags using the WindowsOpenFlags structure. @@ -2135,7 +2136,7 @@ pub fn read(fd: bun.FileDescriptor, buf: []u8) Maybe(usize) { var amount_read: u32 = 0; const rc = kernel32.ReadFile(fd.cast(), buf.ptr, @as(u32, @intCast(adjusted_len)), &amount_read, null); if (rc == windows.FALSE) { - const ret = .{ + const ret: Maybe(usize) = .{ .err = Syscall.Error{ .errno = @intFromEnum(bun.windows.getLastErrno()), .syscall = .read, @@ -2534,7 +2535,7 @@ pub fn symlinkW(dest: [:0]const u16, target: [:0]const u16, options: WindowsSyml while (true) { const flags = options.flags(); - if (windows.kernel32.CreateSymbolicLinkW(dest, target, flags) == 0) { + if (windows.CreateSymbolicLinkW(dest, target, flags) == 0) { const errno = bun.windows.Win32Error.get(); log("CreateSymbolicLinkW({}, {}, {any}) = {s}", .{ bun.fmt.fmtPath(u16, dest, .{}), @@ -2587,7 +2588,7 @@ pub fn clonefile(from: [:0]const u8, to: [:0]const u8) Maybe(void) { } } -pub fn copyfile(from: [:0]const u8, to: [:0]const u8, flags: c_int) Maybe(void) { +pub fn copyfile(from: [:0]const u8, to: [:0]const u8, flags: posix.system.COPYFILE) Maybe(void) { if (comptime !Environment.isMac) @compileError("macOS only"); while (true) { @@ -2599,7 +2600,7 @@ pub fn copyfile(from: [:0]const u8, to: [:0]const u8, flags: c_int) Maybe(void) } } -pub fn fcopyfile(fd_in: bun.FileDescriptor, fd_out: bun.FileDescriptor, flags: u32) Maybe(void) { +pub fn fcopyfile(fd_in: bun.FileDescriptor, fd_out: bun.FileDescriptor, flags: posix.system.COPYFILE) Maybe(void) { if (comptime !Environment.isMac) @compileError("macOS only"); while (true) { @@ -3097,7 +3098,7 @@ pub fn existsOSPath(path: bun.OSPathSliceZ, file_only: bool) bool { null, ); if (rc == w.INVALID_HANDLE_VALUE) return false; - defer _ = std.os.windows.kernel32.CloseHandle(rc); + defer _ = bun.windows.CloseHandle(rc); return true; } return true; @@ -3243,11 +3244,11 @@ pub fn futimens(fd: bun.FileDescriptor, atime: JSC.Node.TimeLike, mtime: JSC.Nod while (true) { const rc = syscall.futimens(fd.cast(), &[2]syscall.timespec{ - .{ .tv_sec = @intCast(atime.tv_sec), .tv_nsec = atime.tv_nsec }, - .{ .tv_sec = @intCast(mtime.tv_sec), .tv_nsec = mtime.tv_nsec }, + .{ .sec = @intCast(atime.sec), .nsec = atime.nsec }, + .{ .sec = @intCast(mtime.sec), .nsec = mtime.nsec }, }); - log("futimens({}, accessed=({d}, {d}), modified=({d}, {d})) = {d}", .{ fd, atime.tv_sec, atime.tv_nsec, mtime.tv_sec, mtime.tv_nsec, rc }); + log("futimens({}, accessed=({d}, {d}), modified=({d}, {d})) = {d}", .{ fd, atime.sec, atime.nsec, mtime.sec, mtime.nsec, rc }); if (rc == 0) { return Maybe(void).success; @@ -3267,8 +3268,8 @@ fn utimensWithFlags(path: bun.OSPathSliceZ, atime: JSC.Node.TimeLike, mtime: JSC while (true) { var times: [2]syscall.timespec = .{ - .{ .tv_sec = @intCast(atime.tv_sec), .tv_nsec = atime.tv_nsec }, - .{ .tv_sec = @intCast(mtime.tv_sec), .tv_nsec = mtime.tv_nsec }, + .{ .sec = @intCast(atime.sec), .nsec = atime.nsec }, + .{ .sec = @intCast(mtime.sec), .nsec = mtime.nsec }, }; const rc = syscall.utimensat( std.fs.cwd().fd, @@ -3278,7 +3279,7 @@ fn utimensWithFlags(path: bun.OSPathSliceZ, atime: JSC.Node.TimeLike, mtime: JSC flags, ); - log("utimensat({d}, atime=({d}, {d}), mtime=({d}, {d})) = {d}", .{ std.fs.cwd().fd, atime.tv_sec, atime.tv_nsec, mtime.tv_sec, mtime.tv_nsec, rc }); + log("utimensat({d}, atime=({d}, {d}), mtime=({d}, {d})) = {d}", .{ std.fs.cwd().fd, atime.sec, atime.nsec, mtime.sec, mtime.nsec, rc }); if (rc == 0) { return Maybe(void).success; @@ -3752,18 +3753,18 @@ pub const File = struct { // "handle" matches std.fs.File handle: bun.FileDescriptor, - pub fn openat(other: anytype, path: [:0]const u8, flags: bun.Mode, mode: bun.Mode) Maybe(File) { + pub fn openat(other: anytype, path: [:0]const u8, flags: i32, mode: bun.Mode) Maybe(File) { return switch (This.openat(bun.toFD(other), path, flags, mode)) { .result => |fd| .{ .result = .{ .handle = fd } }, .err => |err| .{ .err = err }, }; } - pub fn open(path: [:0]const u8, flags: bun.Mode, mode: bun.Mode) Maybe(File) { + pub fn open(path: [:0]const u8, flags: i32, mode: bun.Mode) Maybe(File) { return File.openat(bun.FD.cwd(), path, flags, mode); } - pub fn openatOSPath(other: anytype, path: bun.OSPathSliceZ, flags: bun.Mode, mode: bun.Mode) Maybe(File) { + pub fn openatOSPath(other: anytype, path: bun.OSPathSliceZ, flags: i32, mode: bun.Mode) Maybe(File) { return switch (This.openatOSPath(bun.toFD(other), path, flags, mode)) { .result => |fd| .{ .result = .{ .handle = fd } }, .err => |err| .{ .err = err }, diff --git a/src/sys_uv.zig b/src/sys_uv.zig index 9fc18d100f3bfa..9a574bd581bcd3 100644 --- a/src/sys_uv.zig +++ b/src/sys_uv.zig @@ -38,7 +38,7 @@ pub const access = bun.sys.access; // Note: `req = undefined; req.deinit()` has a saftey-check in a debug build -pub fn open(file_path: [:0]const u8, c_flags: bun.Mode, _perm: bun.Mode) Maybe(bun.FileDescriptor) { +pub fn open(file_path: [:0]const u8, c_flags: i32, _perm: bun.Mode) Maybe(bun.FileDescriptor) { assertIsValidWindowsPath(u8, file_path); var req: uv.fs_t = uv.fs_t.uninitialized; diff --git a/src/tagged_pointer.zig b/src/tagged_pointer.zig index f81aa656b3a111..cb0d798feb533d 100644 --- a/src/tagged_pointer.zig +++ b/src/tagged_pointer.zig @@ -7,7 +7,6 @@ const Environment = bun.Environment; const strings = bun.strings; const default_allocator = bun.default_allocator; const C = bun.C; -const typeBaseName = @import("./meta.zig").typeBaseName; const TagSize = u15; const AddressableSize = u49; @@ -24,7 +23,7 @@ pub const TaggedPointer = packed struct { return .{ ._ptr = 0, .data = data }; } - if (comptime @typeInfo(Ptr) != .Pointer and Ptr != ?*anyopaque) { + if (comptime @typeInfo(Ptr) != .pointer and Ptr != ?*anyopaque) { @compileError(@typeName(Ptr) ++ " must be a ptr, received: " ++ @tagName(@typeInfo(Ptr))); } @@ -74,7 +73,7 @@ pub fn TagTypeEnumWithTypeMap(comptime Types: anytype) struct { @memset(&typeMap, TypeMapT{ .value = 0, .ty = void, .name = "" }); inline for (Types, 0..) |field, i| { - const name = comptime typeBaseName(@typeName(field)); + const name = comptime @typeName(field); enumFields[i] = .{ .name = name, .value = 1024 - i, @@ -84,7 +83,7 @@ pub fn TagTypeEnumWithTypeMap(comptime Types: anytype) struct { return .{ .tag_type = @Type(.{ - .Enum = .{ + .@"enum" = .{ .tag_type = TagSize, .fields = &enumFields, .decls = &.{}, @@ -106,7 +105,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub const type_map: TypeMap(Types) = result.ty_map; repr: TaggedPointer, - pub const Null = .{ .repr = .{ ._ptr = 0, .data = 0 } }; + pub const Null: @This() = .{ .repr = .{ ._ptr = 0, .data = 0 } }; pub fn clear(this: *@This()) void { this.* = Null; @@ -132,7 +131,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { const This = @This(); pub fn assert_type(comptime Type: type) void { - const name = comptime typeBaseName(@typeName(Type)); + const name = comptime @typeName(Type); if (!comptime @hasField(Tag, name)) { @compileError("TaggedPointerUnion does not have " ++ name ++ "."); } @@ -163,7 +162,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn is(this: This, comptime Type: type) bool { comptime assert_type(Type); - return this.repr.data == comptime @intFromEnum(@field(Tag, typeBaseName(@typeName(Type)))); + return this.repr.data == comptime @intFromEnum(@field(Tag, @typeName(Type))); } pub fn set(this: *@This(), _ptr: anytype) void { @@ -177,9 +176,9 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn isValid(this: This) bool { return switch (this.repr.data) { @intFromEnum( - @field(Tag, typeBaseName(@typeName(Types[Types.len - 1]))), + @field(Tag, @typeName(Types[Types.len - 1])), )...@intFromEnum( - @field(Tag, typeBaseName(@typeName(Types[0]))), + @field(Tag, @typeName(Types[0])), ) => true, else => false, }; @@ -200,7 +199,7 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn init(_ptr: anytype) @This() { const tyinfo = @typeInfo(@TypeOf(_ptr)); - if (tyinfo != .Pointer) @compileError("Only pass pointers to TaggedPointerUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); + if (tyinfo != .pointer) @compileError("Only pass pointers to TaggedPointerUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); const Type = std.meta.Child(@TypeOf(_ptr)); return initWithType(Type, _ptr); @@ -208,8 +207,8 @@ pub fn TaggedPointerUnion(comptime Types: anytype) type { pub inline fn initWithType(comptime Type: type, _ptr: anytype) @This() { const tyinfo = @typeInfo(@TypeOf(_ptr)); - if (tyinfo != .Pointer) @compileError("Only pass pointers to TaggedPointerUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); - const name = comptime typeBaseName(@typeName(Type)); + if (tyinfo != .pointer) @compileError("Only pass pointers to TaggedPointerUnion.init(), you gave us a: " ++ @typeName(@TypeOf(_ptr))); + const name = comptime @typeName(Type); // there will be a compiler error if the passed in type doesn't exist in the enum return This{ .repr = TaggedPointer.init(_ptr, @intFromEnum(@field(Tag, name))) }; diff --git a/src/thread_pool.zig b/src/thread_pool.zig index 4186d489c2a08c..2cf8c738e351a0 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -766,7 +766,6 @@ const Event = struct { // Acquire barrier to ensure operations before the shutdown() are seen after the wait(). // Shutdown is rare so it's better to have an Acquire barrier here instead of on CAS failure + load which are common. if (state == SHUTDOWN) { - @fence(.acquire); return; } diff --git a/src/toml/toml_lexer.zig b/src/toml/toml_lexer.zig index 5984f33d26cfc4..6467efd7c342fe 100644 --- a/src/toml/toml_lexer.zig +++ b/src/toml/toml_lexer.zig @@ -77,7 +77,7 @@ pub const Lexer = struct { } pub fn syntaxError(self: *Lexer) !void { - @setCold(true); + @branchHint(.cold); // Only add this if there is not already an error. // It is possible that there is a more descriptive error already emitted. @@ -88,7 +88,7 @@ pub const Lexer = struct { } pub fn addError(self: *Lexer, _loc: usize, comptime format: []const u8, args: anytype) void { - @setCold(true); + @branchHint(.cold); var __loc = logger.usize2Loc(_loc); if (__loc.eql(self.prev_error_loc)) { @@ -109,20 +109,20 @@ pub const Lexer = struct { } pub fn addDefaultError(self: *Lexer, msg: []const u8) !void { - @setCold(true); + @branchHint(.cold); self.addError(self.start, "{s}", .{msg}); return Error.SyntaxError; } pub fn addSyntaxError(self: *Lexer, _loc: usize, comptime fmt: []const u8, args: anytype) !void { - @setCold(true); + @branchHint(.cold); self.addError(_loc, fmt, args); return Error.SyntaxError; } pub fn addRangeError(self: *Lexer, r: logger.Range, comptime format: []const u8, args: anytype) !void { - @setCold(true); + @branchHint(.cold); if (self.prev_error_loc.eql(r.loc)) { return; diff --git a/src/toml/toml_parser.zig b/src/toml/toml_parser.zig index 0d07d49714394f..3d5a69e097748c 100644 --- a/src/toml/toml_parser.zig +++ b/src/toml/toml_parser.zig @@ -95,7 +95,7 @@ pub const TOML = struct { pub fn e(_: *TOML, t: anytype, loc: logger.Loc) Expr { const Type = @TypeOf(t); - if (@typeInfo(Type) == .Pointer) { + if (@typeInfo(Type) == .pointer) { return Expr.init(std.meta.Child(Type), t.*, loc); } else { return Expr.init(Type, t, loc); diff --git a/src/tracy.zig b/src/tracy.zig index b83c6946abd63d..2ca3874a81c20b 100644 --- a/src/tracy.zig +++ b/src/tracy.zig @@ -531,10 +531,7 @@ fn dlsym(comptime Type: type, comptime symbol: [:0]const u8) ?Type { "tracy.dll", } else .{}; - const RLTD = if (bun.Environment.isMac) - -2 - else - 0; + const RLTD: std.c.RTLD = if (bun.Environment.isMac) @bitCast(@as(i32, -2)) else if (bun.Environment.isLinux) .{} else {}; if (bun.getenvZ("BUN_TRACY_PATH")) |path| { const handle = bun.C.dlopen(&(std.posix.toPosixPath(path) catch unreachable), RLTD); diff --git a/src/trait.zig b/src/trait.zig index 5c3db377499b6b..57bac0db03ed09 100644 --- a/src/trait.zig +++ b/src/trait.zig @@ -14,14 +14,14 @@ pub inline fn isZigString(comptime T: type) bool { return comptime blk: { // Only pointer types can be strings, no optionals const info = @typeInfo(T); - if (info != .Pointer) break :blk false; + if (info != .pointer) break :blk false; - const ptr = &info.Pointer; + const ptr = &info.pointer; // Check for CV qualifiers that would prevent coerction to []const u8 if (ptr.is_volatile or ptr.is_allowzero) break :blk false; // If it's already a slice, simple check. - if (ptr.size == .Slice) { + if (ptr.size == .slice) { break :blk ptr.child == u8; } @@ -40,50 +40,50 @@ pub inline fn isZigString(comptime T: type) bool { pub inline fn isSlice(comptime T: type) bool { const info = @typeInfo(T); - return info == .Pointer and info.Pointer.size == .Slice; + return info == .pointer and info.pointer.size == .slice; } pub inline fn isNumber(comptime T: type) bool { return switch (@typeInfo(T)) { - .Int, .Float, .ComptimeInt, .ComptimeFloat => true, + .int, .float, .comptime_int, .comptime_float => true, else => false, }; } pub inline fn isContainer(comptime T: type) bool { return switch (@typeInfo(T)) { - .Struct, .Enum, .Opaque, .Union => true, + .@"struct", .@"enum", .@"opaque", .@"union" => true, else => false, }; } pub inline fn isSingleItemPtr(comptime T: type) bool { const info = @typeInfo(T); - return info == .Pointer and .Pointer.size == .One; + return info == .pointer and .pointer.size == .One; } pub fn isExternContainer(comptime T: type) bool { return switch (@typeInfo(T)) { - .Struct => |s| s.layout == .@"extern", - .Union => |u| u.layout == .@"extern", + .@"struct" => |s| s.layout == .@"extern", + .@"union" => |u| u.layout == .@"extern", else => false, }; } pub fn isConstPtr(comptime T: type) bool { const info = @typeInfo(T); - return info == .Pointer and info.Pointer.is_const; + return info == .pointer and info.pointer.is_const; } pub fn isIndexable(comptime T: type) bool { const info = @typeInfo(T); return switch (info) { - .Pointer => |ptr| switch (ptr.size) { - .One => @typeInfo(ptr.child) == .Array, + .pointer => |ptr| switch (ptr.size) { + .One => @typeInfo(ptr.child) == .array, else => true, }, - .Array, .Vector => true, - .Struct => |s| s.is_tuple, + .array, .vector => true, + .@"struct" => |s| s.is_tuple, else => false, }; } diff --git a/src/transpiler.zig b/src/transpiler.zig index a3b41f967f65e1..7ac0299e04de43 100644 --- a/src/transpiler.zig +++ b/src/transpiler.zig @@ -613,7 +613,7 @@ pub const Transpiler = struct { } pub noinline fn dumpEnvironmentVariables(transpiler: *const Transpiler) void { - @setCold(true); + @branchHint(.cold); const opts = std.json.StringifyOptions{ .whitespace = .indent_2, }; diff --git a/src/url.zig b/src/url.zig index 451060cfa12e89..c3a31bc9206d95 100644 --- a/src/url.zig +++ b/src/url.zig @@ -1043,7 +1043,7 @@ pub const FormData = struct { comptime { const jsFunctionFromMultipartData = JSC.toJSHostFunction(fromMultipartData); - @export(jsFunctionFromMultipartData, .{ .name = "FormData__jsFunctionFromMultipartData" }); + @export(&jsFunctionFromMultipartData, .{ .name = "FormData__jsFunctionFromMultipartData" }); } pub fn toJSFromMultipartData( diff --git a/src/util.zig b/src/util.zig index fbf2e5838d5cf3..d4eadfcf991579 100644 --- a/src/util.zig +++ b/src/util.zig @@ -82,7 +82,7 @@ pub fn fromEntries( pub fn fromMapLike( comptime Map: type, allocator: std.mem.Allocator, - entries: anytype, + entries: []const struct { @FieldType(Map.KV, "key"), @FieldType(Map.KV, "value") }, ) !Map { var map: Map = undefined; if (comptime @hasField(Map, "allocator")) { @@ -91,11 +91,10 @@ pub fn fromMapLike( map = Map{}; } - try map.ensureUnusedCapacity(entries.count()); + try map.ensureUnusedCapacity(allocator, entries.len); - var iter = entries.iterator(); - while (iter.next()) |entry| { - map.putAssumeCapacityNoClobber(entry.key_ptr.*, entry.value_ptr.*); + for (entries) |entry| { + map.putAssumeCapacityNoClobber(entry[0], entry[1]); } return map; @@ -156,11 +155,11 @@ pub inline fn from( return fromEntries(Array, allocator, DefaultType, default); } - if (comptime @typeInfo(DefaultType) == .Struct) { + if (comptime @typeInfo(DefaultType) == .@"struct") { return fromSlice(Array, allocator, DefaultType, default); } - if (comptime @typeInfo(DefaultType) == .Array) { + if (comptime @typeInfo(DefaultType) == .array) { return fromSlice(Array, allocator, []const Of(Array), @as([]const Of(Array), &default)); } diff --git a/src/watcher.zig b/src/watcher.zig index 7639bc11bed75f..3f710c64ceb354 100644 --- a/src/watcher.zig +++ b/src/watcher.zig @@ -333,11 +333,11 @@ fn appendFileAssumeCapacity( // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html var event = std.mem.zeroes(KEvent); - event.flags = std.c.EV_ADD | std.c.EV_CLEAR | std.c.EV_ENABLE; + event.flags = std.c.EV.ADD | std.c.EV.CLEAR | std.c.EV.ENABLE; // we want to know about the vnode - event.filter = std.c.EVFILT_VNODE; + event.filter = std.c.EVFILT.VNODE; - event.fflags = std.c.NOTE_WRITE | std.c.NOTE_RENAME | std.c.NOTE_DELETE; + event.fflags = std.c.NOTE.WRITE | std.c.NOTE.RENAME | std.c.NOTE.DELETE; // id event.ident = @intCast(fd.int()); @@ -425,15 +425,15 @@ fn appendDirectoryAssumeCapacity( // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/kqueue.2.html var event = std.mem.zeroes(KEvent); - event.flags = std.c.EV_ADD | std.c.EV_CLEAR | std.c.EV_ENABLE; + event.flags = std.c.EV.ADD | std.c.EV.CLEAR | std.c.EV.ENABLE; // we want to know about the vnode - event.filter = std.c.EVFILT_VNODE; + event.filter = std.c.EVFILT.VNODE; // monitor: // - Write // - Rename // - Delete - event.fflags = std.c.NOTE_WRITE | std.c.NOTE_RENAME | std.c.NOTE_DELETE; + event.fflags = std.c.NOTE.WRITE | std.c.NOTE.RENAME | std.c.NOTE.DELETE; // id event.ident = @intCast(fd.int()); diff --git a/src/watcher/INotifyWatcher.zig b/src/watcher/INotifyWatcher.zig index 25ba6248e74112..d86694d6338bf3 100644 --- a/src/watcher/INotifyWatcher.zig +++ b/src/watcher/INotifyWatcher.zig @@ -142,7 +142,7 @@ pub fn read(this: *INotifyWatcher) bun.JSC.Maybe([]const *align(1) Event) { .events = std.posix.POLL.IN | std.posix.POLL.ERR, .revents = 0, }}; - var timespec = std.posix.timespec{ .tv_sec = 0, .tv_nsec = this.coalesce_interval }; + var timespec = std.posix.timespec{ .sec = 0, .nsec = this.coalesce_interval }; if ((std.posix.ppoll(&fds, ×pec, null) catch 0) > 0) { inner: while (true) { const rest = this.eventlist_bytes[read_eventlist_bytes.len..]; diff --git a/src/watcher/KEventWatcher.zig b/src/watcher/KEventWatcher.zig index b5c4436d13da9e..e1037db01a3506 100644 --- a/src/watcher/KEventWatcher.zig +++ b/src/watcher/KEventWatcher.zig @@ -28,10 +28,10 @@ pub fn stop(this: *KEventWatcher) void { pub fn watchEventFromKEvent(kevent: KEvent) Watcher.Event { return .{ .op = .{ - .delete = (kevent.fflags & std.c.NOTE_DELETE) > 0, - .metadata = (kevent.fflags & std.c.NOTE_ATTRIB) > 0, - .rename = (kevent.fflags & (std.c.NOTE_RENAME | std.c.NOTE_LINK)) > 0, - .write = (kevent.fflags & std.c.NOTE_WRITE) > 0, + .delete = (kevent.fflags & std.c.NOTE.DELETE) > 0, + .metadata = (kevent.fflags & std.c.NOTE.ATTRIB) > 0, + .rename = (kevent.fflags & (std.c.NOTE.RENAME | std.c.NOTE.LINK)) > 0, + .write = (kevent.fflags & std.c.NOTE.WRITE) > 0, }, .index = @truncate(kevent.udata), }; @@ -59,7 +59,7 @@ pub fn watchLoopCycle(this: *Watcher) bun.JSC.Maybe(void) { // Give the events more time to coalesce if (count < 128 / 2) { const remain = 128 - count; - var timespec = std.posix.timespec{ .tv_sec = 0, .tv_nsec = 100_000 }; + var timespec = std.posix.timespec{ .sec = 0, .nsec = 100_000 }; const extra = std.posix.system.kevent( this.platform.fd.cast(), @as([*]KEvent, changelist[@as(usize, @intCast(count))..].ptr), diff --git a/src/watcher/WindowsWatcher.zig b/src/watcher/WindowsWatcher.zig index 294e9275df4697..9e62d53381e6f5 100644 --- a/src/watcher/WindowsWatcher.zig +++ b/src/watcher/WindowsWatcher.zig @@ -38,7 +38,7 @@ const DirWatcher = struct { // invalidates any EventIterators fn prepare(this: *DirWatcher) bun.JSC.Maybe(void) { - const filter = w.FILE_NOTIFY_CHANGE_FILE_NAME | w.FILE_NOTIFY_CHANGE_DIR_NAME | w.FILE_NOTIFY_CHANGE_LAST_WRITE | w.FILE_NOTIFY_CHANGE_CREATION; + const filter: w.FileNotifyChangeFilter = .{ .file_name = true, .dir_name = true, .last_write = true, .creation = true }; if (w.kernel32.ReadDirectoryChangesW(this.dirHandle, &this.buf, this.buf.len, 1, filter, null, &this.overlapped, null) == 0) { const err = w.kernel32.GetLastError(); log("failed to start watching directory: {s}", .{@tagName(err)}); @@ -117,10 +117,10 @@ pub fn init(this: *WindowsWatcher, root: []const u8) !void { log("failed to open directory for watching: {s}", .{@tagName(err)}); return Error.CreateFileFailed; } - errdefer _ = w.kernel32.CloseHandle(handle); + errdefer _ = bun.windows.CloseHandle(handle); this.iocp = try w.CreateIoCompletionPort(handle, null, 0, 1); - errdefer _ = w.kernel32.CloseHandle(this.iocp); + errdefer _ = bun.windows.CloseHandle(this.iocp); this.watcher = .{ .dirHandle = handle }; diff --git a/src/windows.zig b/src/windows.zig index 8f6cbc5f5e326b..ecf2de533494f8 100644 --- a/src/windows.zig +++ b/src/windows.zig @@ -7,6 +7,7 @@ pub const WORD = windows.WORD; pub const DWORD = windows.DWORD; pub const CHAR = windows.CHAR; pub const BOOL = windows.BOOL; +pub const BOOLEAN = windows.BOOLEAN; pub const LPVOID = windows.LPVOID; pub const LPCVOID = windows.LPCVOID; pub const LPWSTR = windows.LPWSTR; @@ -33,6 +34,7 @@ pub const STATUS_SUCCESS = windows.STATUS_SUCCESS; pub const MOVEFILE_COPY_ALLOWED = 0x2; pub const MOVEFILE_REPLACE_EXISTING = 0x1; pub const MOVEFILE_WRITE_THROUGH = 0x8; +pub const FILETIME = windows.FILETIME; pub const DUPLICATE_SAME_ACCESS = windows.DUPLICATE_SAME_ACCESS; pub const OBJECT_ATTRIBUTES = windows.OBJECT_ATTRIBUTES; @@ -3259,8 +3261,8 @@ fn Bun__UVSignalHandle__close(signal: *libuv.uv_signal_t) callconv(.C) void { comptime { if (Environment.isWindows) { - @export(Bun__UVSignalHandle__init, .{ .name = "Bun__UVSignalHandle__init" }); - @export(Bun__UVSignalHandle__close, .{ .name = "Bun__UVSignalHandle__close" }); + @export(&Bun__UVSignalHandle__init, .{ .name = "Bun__UVSignalHandle__init" }); + @export(&Bun__UVSignalHandle__close, .{ .name = "Bun__UVSignalHandle__close" }); } } @@ -3658,3 +3660,13 @@ pub const rescle = struct { }; } }; + +pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(.winapi) BOOL; +pub extern "kernel32" fn GetFinalPathNameByHandleW(hFile: HANDLE, lpszFilePath: [*]u16, cchFilePath: DWORD, dwFlags: DWORD) callconv(.winapi) DWORD; +pub extern "kernel32" fn DeleteFileW(lpFileName: [*:0]const u16) callconv(.winapi) BOOL; +pub extern "kernel32" fn CreateSymbolicLinkW(lpSymlinkFileName: [*:0]const u16, lpTargetFileName: [*:0]const u16, dwFlags: DWORD) callconv(.winapi) BOOLEAN; +pub extern "kernel32" fn GetCurrentThread() callconv(.winapi) HANDLE; +pub extern "kernel32" fn GetCommandLineW() callconv(.winapi) LPWSTR; +pub extern "kernel32" fn CreateDirectoryW(lpPathName: [*:0]const u16, lpSecurityAttributes: ?*windows.SECURITY_ATTRIBUTES) callconv(.winapi) BOOL; +pub extern "kernel32" fn SetEndOfFile(hFile: HANDLE) callconv(.winapi) BOOL; +pub extern "kernel32" fn GetProcessTimes(in_hProcess: HANDLE, out_lpCreationTime: *FILETIME, out_lpExitTime: *FILETIME, out_lpKernelTime: *FILETIME, out_lpUserTime: *FILETIME) callconv(.winapi) BOOL; diff --git a/src/windows_c.zig b/src/windows_c.zig index f4f6e08c3d6857..8a0dd420014fe3 100644 --- a/src/windows_c.zig +++ b/src/windows_c.zig @@ -27,7 +27,7 @@ pub export fn memmem(haystack: ?[*]const u8, haystacklen: usize, needle: ?[*]con } comptime { - @export(memmem, .{ .name = "zig_memmem" }); + @export(&memmem, .{ .name = "zig_memmem" }); } pub const lstat = blk: { @@ -57,7 +57,7 @@ pub fn getSystemLoadavg() [3]f32 { return .{ 0, 0, 0 }; } -pub const Mode = i32; +pub const Mode = u16; const Win32Error = bun.windows.Win32Error; // The way we do errors in Bun needs to get cleaned up. diff --git a/src/work_pool.zig b/src/work_pool.zig index 380dfacfd8a715..53b04a10027118 100644 --- a/src/work_pool.zig +++ b/src/work_pool.zig @@ -11,7 +11,7 @@ pub fn NewWorkPool(comptime max_threads: ?usize) type { var loaded: bool = false; fn create() *ThreadPool { - @setCold(true); + @branchHint(.cold); pool = ThreadPool.init(.{ .max_threads = max_threads orelse bun.getThreadCount(), diff --git a/test/js/bun/util/password.test.ts b/test/js/bun/util/password.test.ts index f838ad3a485406..0d8fd5cc25f9cd 100644 --- a/test/js/bun/util/password.test.ts +++ b/test/js/bun/util/password.test.ts @@ -217,7 +217,7 @@ for (let algorithmValue of algorithms) { expect(verifySync(input + "\0", hashed)).toBeFalse(); }); - test("password", async () => { + describe("password", async () => { async function runSlowTest(algorithm = algorithmValue as any) { const hashed = await password.hash(input, algorithm); const prefix = "$" + algorithm; @@ -228,12 +228,13 @@ for (let algorithmValue of algorithms) { } async function runSlowTestWithOptions(algorithmLabel: any) { - const algorithm = { algorithm: algorithmLabel, timeCost: 5, memoryCost: 4 }; + const algorithm = { algorithm: algorithmLabel, timeCost: 5, memoryCost: 8 }; const hashed = await password.hash(input, algorithm); const prefix = "$" + algorithmLabel; expect(hashed).toStartWith(prefix); expect(hashed).toContain("t=5"); - expect(hashed).toContain("m=4"); + expect(hashed).toContain("m=8"); + expect(hashed).toContain("p=1"); expect(await password.verify(input, hashed, algorithmLabel)).toBeTrue(); expect(() => password.verify(hashed, input, algorithmLabel)).toThrow(); expect(await password.verify(input + "\0", hashed, algorithmLabel)).toBeFalse(); @@ -252,7 +253,12 @@ for (let algorithmValue of algorithms) { if (algorithmValue === defaultAlgorithm) { // these tests are very slow // run the hashing tests in parallel - await Promise.all([...argons.map(runSlowTest), ...argons.map(runSlowTestWithOptions)]); + for (const a of argons) { + test(`${a}`, async () => { + await runSlowTest(a); + await runSlowTestWithOptions(a); + }) + } return; } @@ -265,9 +271,14 @@ for (let algorithmValue of algorithms) { } if (algorithmValue === "bcrypt") { - await Promise.all([defaultTest(), runSlowBCryptTest()]); + test("bcrypt", async () => { + await defaultTest(); + await runSlowBCryptTest(); + }); } else { - await defaultTest(); + test("default", async () => { + await defaultTest(); + }); } }); }); From 43fd9326baf06cb90f2f5fd2fea4ab90080da384 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Feb 2025 22:12:22 -0800 Subject: [PATCH 04/29] Use a more reliable zig download url --- cmake/scripts/DownloadZig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/scripts/DownloadZig.cmake b/cmake/scripts/DownloadZig.cmake index 2fb68ac4ca28b9..590a443f444009 100644 --- a/cmake/scripts/DownloadZig.cmake +++ b/cmake/scripts/DownloadZig.cmake @@ -38,7 +38,7 @@ else() set(ZIG_FILENAME ${ZIG_NAME}.tar.xz) endif() -set(ZIG_DOWNLOAD_URL http://mirrors.nektro.net/zig/${ZIG_VERSION}/${ZIG_FILENAME}) +set(ZIG_DOWNLOAD_URL https://bun-ci-assets.bun.sh/${ZIG_FILENAME}) execute_process( COMMAND From 87281b6d48f8015c8d779a28d47bbc6a670aee58 Mon Sep 17 00:00:00 2001 From: Okinea Dev Date: Sun, 2 Feb 2025 06:18:17 +0000 Subject: [PATCH 05/29] fix: add file association for `*.mdc` files (#16963) --- .gitattributes | 1 + .vscode/settings.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.gitattributes b/.gitattributes index 1b3908f258f862..bc089ec2f34a70 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,6 +15,7 @@ *.lock text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 *.map text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 *.md text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 +*.mdc text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 *.mjs text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 *.mts text eol=lf whitespace=blank-at-eol,-blank-at-eof,-space-before-tab,tab-in-indent,tabwidth=2 diff --git a/.vscode/settings.json b/.vscode/settings.json index eca14849b66fe7..f7f738011685e0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -140,6 +140,7 @@ }, "files.associations": { "*.idl": "cpp", + "*.mdc": "markdown", "array": "cpp", }, "C_Cpp.files.exclude": { From 5366c9db33c0a4ae69f713d293312940314dace4 Mon Sep 17 00:00:00 2001 From: Michael H Date: Sun, 2 Feb 2025 17:55:19 +1100 Subject: [PATCH 06/29] hopefully auto pr to DT (#16956) --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++++ packages/bun-types/package.json | 2 +- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4086ae59397ffd..ed68ab8c90856c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,6 +44,10 @@ on: description: Should types be released to npm? type: boolean default: false + use-definitelytyped: + description: "Should types be PR'd to DefinitelyTyped?" + type: boolean + default: false jobs: sign: @@ -155,6 +159,48 @@ jobs: with: package: packages/bun-types/package.json token: ${{ secrets.NPM_TOKEN }} + definitelytyped: + name: Make pr to DefinitelyTyped to update `bun-types` version + runs-on: ubuntu-latest + needs: npm-types + if: ${{ github.event_name == 'release' || github.event.inputs.use-definitelytyped == 'true' }} + permissions: + contents: read + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: DefinitelyTyped/DefinitelyTyped + - name: Setup Bun + uses: ./.github/actions/setup-bun + with: + bun-version: "1.2.0" + - id: bun-version + run: echo "BUN_VERSION=${BUN_VERSION#bun-v}" >> "$GITHUB_OUTPUT" + - name: Update bun-types version in package.json + run: | + bun -e ' + const file = Bun.file("./types/bun/package.json"); + const json = await file.json(); + const version = "${{ steps.bun-version.outputs.BUN_VERSION }}"; + json.dependencies["bun-types"] = version; + json.version = version.slice(0, version.lastIndexOf(".")) + ".9999"; + await file.write(JSON.stringify(json, null, 4) + "\n"); + ' + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + if: ${{ env.BUN_LATEST == 'true' && env.BUN_VERSION != 'canary'}} + with: + token: ${{ secrets.ROBOBUN_TOKEN }} + add-paths: ./types/bun/package.json + title: "[bun] update to ${{ steps.bun-version.outputs.BUN_VERSION }}" + commit-message: "[bun] update to ${{ steps.bun-version.outputs.BUN_VERSION }}" + body: | + Update `bun-types` version to ${{ steps.bun-version.outputs.BUN_VERSION }} + + https://bun.sh/blog/${{ env.BUN_VERSION }} + push-to-fork: oven-sh/DefinitelyTyped + branch: ${{env.BUN_VERSION}} docker: name: Release to Dockerhub runs-on: ubuntu-latest diff --git a/packages/bun-types/package.json b/packages/bun-types/package.json index 8139546ef74f25..73298a165ece0f 100644 --- a/packages/bun-types/package.json +++ b/packages/bun-types/package.json @@ -27,7 +27,7 @@ }, "scripts": { "prebuild": "echo $(pwd)", - "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION:-1.0.0}\"'/g' ./docs/**/*.md", + "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && find ./docs -type f -name '*.md' -exec sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION#bun-v:-1.0.0}\"'/g' {} +", "build": "bun run copy-docs && bun scripts/build.ts && bun run fmt", "test": "tsc", "fmt": "echo $(which biome) && biome format --write ." From 1595b1cc2ba3ac35058e9a655f511bdea71b39fe Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sat, 1 Feb 2025 22:56:34 -0800 Subject: [PATCH 07/29] Disable stop if necessary timer (#16962) --- src/bun.js/bindings/ZigGlobalObject.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 91499e5368c4f3..0ab051cfb81154 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -895,6 +895,8 @@ extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(void* console_client, vm.heap.acquireAccess(); JSC::JSLockHolder locker(vm); + vm.heap.disableStopIfNecessaryTimer(); + WebCore::JSVMClientData::create(&vm, Bun__getVM()); const auto createGlobalObject = [&]() -> Zig::GlobalObject* { From 34419c5f0d5da0871d52b00b71fb87d97739be3d Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 1 Feb 2025 23:59:45 -0800 Subject: [PATCH 08/29] zig: only call strlen/wcslen in indexOfSentinel if libc is linked (#16986) --- cmake/tools/SetupZig.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/tools/SetupZig.cmake b/cmake/tools/SetupZig.cmake index d1c6727c831c62..00cab1c61bffd7 100644 --- a/cmake/tools/SetupZig.cmake +++ b/cmake/tools/SetupZig.cmake @@ -21,7 +21,7 @@ else() endif() optionx(ZIG_VERSION STRING "The zig version of the compiler to download" DEFAULT "0.14.0-dev.2987+183bb8b08") -optionx(ZIG_COMMIT STRING "The zig commit to use in oven-sh/zig" DEFAULT "b11877fd3e8fbc031c17872155ed481d5ba4e6af") +optionx(ZIG_COMMIT STRING "The zig commit to use in oven-sh/zig" DEFAULT "568a19ea4b811a5580bbf869cdaf6071244b9bb2") optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET}) if(CMAKE_BUILD_TYPE STREQUAL "Release") From aac951bd4715febf3b9ceacd0435b4121845f0bb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 2 Feb 2025 00:20:45 -0800 Subject: [PATCH 09/29] Move semver-related structs into their own files (#16987) --- src/analytics/analytics_thread.zig | 2 +- src/bun.js/api/BunObject.zig | 2 +- src/bun.zig | 2 +- src/cli/filter_run.zig | 2 +- src/cli/pack_command.zig | 2 +- src/cli/package_manager_command.zig | 2 +- src/cli/pm_trusted_command.zig | 2 +- src/install/bin.zig | 2 +- src/install/dependency.zig | 2 +- src/install/extract_tarball.zig | 2 +- src/install/install.zig | 2 +- src/install/lockfile.zig | 2 +- src/install/migration.zig | 2 +- src/install/npm.zig | 2 +- src/install/repository.zig | 2 +- src/install/resolution.zig | 2 +- src/install/resolvers/folder_resolver.zig | 4 +- src/install/semver.zig | 2889 --------------------- src/install/versioned_url.zig | 5 +- src/resolver/package_json.zig | 4 +- src/resolver/resolver.zig | 2 +- src/semver.zig | 9 + src/semver/ExternalString.zig | 66 + src/semver/SemverObject.zig | 152 ++ src/semver/SemverQuery.zig | 801 ++++++ src/semver/SemverRange.zig | 273 ++ src/semver/SemverString.zig | 628 +++++ src/semver/SlicedString.zig | 58 + src/semver/Version.zig | 1010 +++++++ 29 files changed, 3021 insertions(+), 2912 deletions(-) delete mode 100644 src/install/semver.zig create mode 100644 src/semver.zig create mode 100644 src/semver/ExternalString.zig create mode 100644 src/semver/SemverObject.zig create mode 100644 src/semver/SemverQuery.zig create mode 100644 src/semver/SemverRange.zig create mode 100644 src/semver/SemverString.zig create mode 100644 src/semver/SlicedString.zig create mode 100644 src/semver/Version.zig diff --git a/src/analytics/analytics_thread.zig b/src/analytics/analytics_thread.zig index 51365d41261d45..e0d3dfcc902460 100644 --- a/src/analytics/analytics_thread.zig +++ b/src/analytics/analytics_thread.zig @@ -20,7 +20,7 @@ const Analytics = @import("./analytics_schema.zig").analytics; const Writer = @import("./analytics_schema.zig").Writer; const Headers = bun.http.Headers; const Futex = @import("../futex.zig"); -const Semver = @import("../install/semver.zig"); +const Semver = bun.Semver; /// Enables analytics. This is used by: /// - crash_handler.zig's `report` function to anonymously report crashes diff --git a/src/bun.js/api/BunObject.zig b/src/bun.js/api/BunObject.zig index 6830bc9fda21d5..0afc440aadde56 100644 --- a/src/bun.js/api/BunObject.zig +++ b/src/bun.js/api/BunObject.zig @@ -247,7 +247,7 @@ const ErrorableString = JSC.ErrorableString; const max_addressable_memory = std.math.maxInt(u56); const glob = @import("../../glob.zig"); const Async = bun.Async; -const SemverObject = @import("../../install/semver.zig").SemverObject; +const SemverObject = bun.Semver.SemverObject; const Braces = @import("../../shell/braces.zig"); const Shell = @import("../../shell/shell.zig"); diff --git a/src/bun.zig b/src/bun.zig index ce576c8bf327d5..beae14b002cd61 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -1598,7 +1598,7 @@ pub fn cstring(input: []const u8) [:0]const u8 { return @as([*:0]const u8, @ptrCast(input.ptr))[0..input.len :0]; } -pub const Semver = @import("./install/semver.zig"); +pub const Semver = @import("./semver.zig"); pub const ImportRecord = @import("./import_record.zig").ImportRecord; pub const ImportKind = @import("./import_record.zig").ImportKind; diff --git a/src/cli/filter_run.zig b/src/cli/filter_run.zig index af4071132f69c9..7ac33ac5318089 100644 --- a/src/cli/filter_run.zig +++ b/src/cli/filter_run.zig @@ -6,7 +6,7 @@ const std = @import("std"); const Fs = @import("../fs.zig"); const RunCommand = @import("run_command.zig").RunCommand; const DependencyMap = @import("../resolver/package_json.zig").DependencyMap; -const SemverString = @import("../install/semver.zig").String; +const SemverString = bun.Semver.String; const CLI = bun.CLI; const Command = CLI.Command; diff --git a/src/cli/pack_command.zig b/src/cli/pack_command.zig index 511342cbf5cfce..dc9db0f63a364d 100644 --- a/src/cli/pack_command.zig +++ b/src/cli/pack_command.zig @@ -15,7 +15,7 @@ const stringZ = bun.stringZ; const libarchive = @import("../libarchive/libarchive.zig").lib; const Archive = libarchive.Archive; const Expr = bun.js_parser.Expr; -const Semver = @import("../install/semver.zig"); +const Semver = bun.Semver; const File = bun.sys.File; const FD = bun.FD; const strings = bun.strings; diff --git a/src/cli/package_manager_command.zig b/src/cli/package_manager_command.zig index 77a833a084cfa0..3fb40fc9dff894 100644 --- a/src/cli/package_manager_command.zig +++ b/src/cli/package_manager_command.zig @@ -17,7 +17,7 @@ const PackageManager = Install.PackageManager; const Lockfile = @import("../install/lockfile.zig"); const NodeModulesFolder = Lockfile.Tree.Iterator(.node_modules).Next; const Path = @import("../resolver/resolve_path.zig"); -const String = @import("../install/semver.zig").String; +const String = bun.Semver.String; const ArrayIdentityContext = bun.ArrayIdentityContext; const DepIdSet = std.ArrayHashMapUnmanaged(DependencyID, void, ArrayIdentityContext, false); const UntrustedCommand = @import("./pm_trusted_command.zig").UntrustedCommand; diff --git a/src/cli/pm_trusted_command.zig b/src/cli/pm_trusted_command.zig index 8d50aafef865b5..fb197f3071e1ea 100644 --- a/src/cli/pm_trusted_command.zig +++ b/src/cli/pm_trusted_command.zig @@ -7,7 +7,7 @@ const Command = @import("../cli.zig").Command; const Install = @import("../install/install.zig"); const LifecycleScriptSubprocess = Install.LifecycleScriptSubprocess; const PackageID = Install.PackageID; -const String = @import("../install/semver.zig").String; +const String = bun.Semver.String; const PackageManager = Install.PackageManager; const PackageManagerCommand = @import("./package_manager_command.zig").PackageManagerCommand; const Lockfile = Install.Lockfile; diff --git a/src/install/bin.zig b/src/install/bin.zig index f47807bef37515..dddf3a52309542 100644 --- a/src/install/bin.zig +++ b/src/install/bin.zig @@ -1,5 +1,5 @@ const ExternalStringList = @import("./install.zig").ExternalStringList; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const Output = bun.Output; diff --git a/src/install/dependency.zig b/src/install/dependency.zig index 2ef640ddbb7290..1f606b39cef188 100644 --- a/src/install/dependency.zig +++ b/src/install/dependency.zig @@ -7,7 +7,7 @@ const ExternalStringList = Install.ExternalStringList; const Features = Install.Features; const PackageNameHash = Install.PackageNameHash; const Repository = @import("./repository.zig").Repository; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const SlicedString = Semver.SlicedString; const String = Semver.String; diff --git a/src/install/extract_tarball.zig b/src/install/extract_tarball.zig index e8b8fb0c481d88..ef78639e45e146 100644 --- a/src/install/extract_tarball.zig +++ b/src/install/extract_tarball.zig @@ -11,7 +11,7 @@ const PackageManager = Install.PackageManager; const Integrity = @import("./integrity.zig").Integrity; const Npm = @import("./npm.zig"); const Resolution = @import("./resolution.zig").Resolution; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const std = @import("std"); const string = @import("../string_types.zig").string; const strings = @import("../string_immutable.zig"); diff --git a/src/install/install.zig b/src/install/install.zig index 96a6ed95dab80d..d08bbfbf868be0 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -145,7 +145,7 @@ const IdentityContext = @import("../identity_context.zig").IdentityContext; const ArrayIdentityContext = @import("../identity_context.zig").ArrayIdentityContext; const NetworkQueue = std.fifo.LinearFifo(*NetworkTask, .{ .Static = 32 }); const PatchTaskFifo = std.fifo.LinearFifo(*PatchTask, .{ .Static = 32 }); -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const GlobalStringBuilder = @import("../string_builder.zig"); diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig index 71ddd3691b6dbc..4d97df2737b134 100644 --- a/src/install/lockfile.zig +++ b/src/install/lockfile.zig @@ -56,7 +56,7 @@ const Lockfile = @This(); const IdentityContext = @import("../identity_context.zig").IdentityContext; const ArrayIdentityContext = @import("../identity_context.zig").ArrayIdentityContext; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const GlobalStringBuilder = @import("../string_builder.zig"); diff --git a/src/install/migration.zig b/src/install/migration.zig index da2c8fa30119e9..fff4faad73baea 100644 --- a/src/install/migration.zig +++ b/src/install/migration.zig @@ -20,7 +20,7 @@ const Npm = @import("./npm.zig"); const Integrity = @import("./integrity.zig").Integrity; const Bin = @import("./bin.zig").Bin; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const String = Semver.String; const ExternalString = Semver.ExternalString; const stringHash = String.Builder.stringHash; diff --git a/src/install/npm.zig b/src/install/npm.zig index 0b343c298b11a9..de733109d600c0 100644 --- a/src/install/npm.zig +++ b/src/install/npm.zig @@ -2,7 +2,7 @@ const URL = @import("../url.zig").URL; const bun = @import("root").bun; const std = @import("std"); const MutableString = @import("../string_mutable.zig").MutableString; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const string = @import("../string_types.zig").string; diff --git a/src/install/repository.zig b/src/install/repository.zig index 8e016bf9656589..3b16f623a5d66b 100644 --- a/src/install/repository.zig +++ b/src/install/repository.zig @@ -8,7 +8,7 @@ const FileSystem = @import("../fs.zig").FileSystem; const Install = @import("./install.zig"); const ExtractData = Install.ExtractData; const PackageManager = Install.PackageManager; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const std = @import("std"); diff --git a/src/install/resolution.zig b/src/install/resolution.zig index d10cbf63b33725..46d4100874f15d 100644 --- a/src/install/resolution.zig +++ b/src/install/resolution.zig @@ -1,5 +1,5 @@ const PackageManager = @import("./install.zig").PackageManager; -const Semver = @import("./semver.zig"); +const Semver = bun.Semver; const ExternalString = Semver.ExternalString; const String = Semver.String; const std = @import("std"); diff --git a/src/install/resolvers/folder_resolver.zig b/src/install/resolvers/folder_resolver.zig index dceff73f4bccff..287e9a4fc9ad2b 100644 --- a/src/install/resolvers/folder_resolver.zig +++ b/src/install/resolvers/folder_resolver.zig @@ -14,8 +14,8 @@ const Features = @import("../install.zig").Features; const IdentityContext = @import("../../identity_context.zig").IdentityContext; const strings = bun.strings; const Resolution = @import("../resolution.zig").Resolution; -const String = @import("../semver.zig").String; -const Semver = @import("../semver.zig"); +const String = bun.Semver.String; +const Semver = bun.Semver; const bun = @import("root").bun; const Dependency = @import("../dependency.zig"); pub const FolderResolution = union(Tag) { diff --git a/src/install/semver.zig b/src/install/semver.zig deleted file mode 100644 index 8beb99e8812392..00000000000000 --- a/src/install/semver.zig +++ /dev/null @@ -1,2889 +0,0 @@ -const std = @import("std"); -const Allocator = std.mem.Allocator; -const bun = @import("root").bun; -const string = bun.string; -const Output = bun.Output; -const Global = bun.Global; -const Environment = bun.Environment; -const strings = bun.strings; -const MutableString = bun.MutableString; -const stringZ = bun.stringZ; -const default_allocator = bun.default_allocator; -const C = bun.C; -const JSC = bun.JSC; -const IdentityContext = @import("../identity_context.zig").IdentityContext; -const OOM = bun.OOM; -const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; -const Lockfile = bun.install.Lockfile; - -/// String type that stores either an offset/length into an external buffer or a string inline directly -pub const String = extern struct { - pub const max_inline_len: usize = 8; - /// This is three different types of string. - /// 1. Empty string. If it's all zeroes, then it's an empty string. - /// 2. If the final bit is set, then it's a string that is stored inline. - /// 3. If the final bit is not set, then it's a string that is stored in an external buffer. - bytes: [max_inline_len]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, - - /// Create an inline string - pub fn from(comptime inlinable_buffer: []const u8) String { - comptime { - if (inlinable_buffer.len > max_inline_len or - inlinable_buffer.len == max_inline_len and - inlinable_buffer[max_inline_len - 1] >= 0x80) - { - @compileError("string constant too long to be inlined"); - } - } - return String.init(inlinable_buffer, inlinable_buffer); - } - - pub const Buf = struct { - bytes: *std.ArrayListUnmanaged(u8), - allocator: std.mem.Allocator, - pool: *Builder.StringPool, - - pub fn init(lockfile: *const Lockfile) Buf { - return .{ - .bytes = &lockfile.buffers.string_bytes, - .allocator = lockfile.allocator, - .pool = &lockfile.string_pool, - }; - } - - pub fn append(this: *Buf, str: string) OOM!String { - if (canInline(str)) { - return String.initInline(str); - } - - const hash = Builder.stringHash(str); - const entry = try this.pool.getOrPut(hash); - if (entry.found_existing) { - return entry.value_ptr.*; - } - - // new entry - const new = try String.initAppend(this.allocator, this.bytes, str); - entry.value_ptr.* = new; - return new; - } - - pub fn appendWithHash(this: *Buf, str: string, hash: u64) OOM!String { - if (canInline(str)) { - return initInline(str); - } - - const entry = try this.pool.getOrPut(hash); - if (entry.found_existing) { - return entry.value_ptr.*; - } - - // new entry - const new = try String.initAppend(this.allocator, this.bytes, str); - entry.value_ptr.* = new; - return new; - } - - pub fn appendExternal(this: *Buf, str: string) OOM!ExternalString { - const hash = Builder.stringHash(str); - - if (canInline(str)) { - return .{ - .value = String.initInline(str), - .hash = hash, - }; - } - - const entry = try this.pool.getOrPut(hash); - if (entry.found_existing) { - return .{ - .value = entry.value_ptr.*, - .hash = hash, - }; - } - - const new = try String.initAppend(this.allocator, this.bytes, str); - entry.value_ptr.* = new; - return .{ - .value = new, - .hash = hash, - }; - } - - pub fn appendExternalWithHash(this: *Buf, str: string, hash: u64) OOM!ExternalString { - if (canInline(str)) { - return .{ - .value = initInline(str), - .hash = hash, - }; - } - - const entry = try this.pool.getOrPut(hash); - if (entry.found_existing) { - return .{ - .value = entry.value_ptr.*, - .hash = hash, - }; - } - - const new = try String.initAppend(this.allocator, this.bytes, str); - entry.value_ptr.* = new; - return .{ - .value = new, - .hash = hash, - }; - } - }; - - pub const Tag = enum { - small, - big, - }; - - pub inline fn fmt(self: *const String, buf: []const u8) Formatter { - return Formatter{ - .buf = buf, - .str = self, - }; - } - - pub const Formatter = struct { - str: *const String, - buf: string, - - pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const str = formatter.str; - try writer.writeAll(str.slice(formatter.buf)); - } - }; - - /// Escapes for json. Expects string to be prequoted - pub inline fn fmtJson(self: *const String, buf: []const u8, opts: JsonFormatter.Options) JsonFormatter { - return .{ - .buf = buf, - .str = self, - .opts = opts, - }; - } - - pub const JsonFormatter = struct { - str: *const String, - buf: string, - opts: Options, - - pub const Options = struct { - quote: bool = true, - }; - - pub fn format(formatter: JsonFormatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - try writer.print("{}", .{bun.fmt.formatJSONStringUTF8(formatter.str.slice(formatter.buf), .{ .quote = formatter.opts.quote })}); - } - }; - - pub fn Sorter(comptime direction: enum { asc, desc }) type { - return struct { - lhs_buf: []const u8, - rhs_buf: []const u8, - pub fn lessThan(this: @This(), lhs: String, rhs: String) bool { - return lhs.order(&rhs, this.lhs_buf, this.rhs_buf) == if (comptime direction == .asc) .lt else .gt; - } - }; - } - - pub inline fn order( - lhs: *const String, - rhs: *const String, - lhs_buf: []const u8, - rhs_buf: []const u8, - ) std.math.Order { - return strings.order(lhs.slice(lhs_buf), rhs.slice(rhs_buf)); - } - - pub inline fn canInline(buf: []const u8) bool { - return switch (buf.len) { - 0...max_inline_len - 1 => true, - max_inline_len => buf[max_inline_len - 1] & 0x80 == 0, - else => false, - }; - } - - pub inline fn isInline(this: String) bool { - return this.bytes[max_inline_len - 1] & 0x80 == 0; - } - - pub inline fn sliced(this: *const String, buf: []const u8) SlicedString { - return if (this.isInline()) - SlicedString.init(this.slice(""), this.slice("")) - else - SlicedString.init(buf, this.slice(buf)); - } - - // https://en.wikipedia.org/wiki/Intel_5-level_paging - // https://developer.arm.com/documentation/101811/0101/Address-spaces-in-AArch64#:~:text=0%2DA%2C%20the%20maximum%20size,2%2DA. - // X64 seems to need some of the pointer bits - const max_addressable_space = u63; - - comptime { - if (@sizeOf(usize) != 8) { - @compileError("This code needs to be updated for non-64-bit architectures"); - } - } - - pub const HashContext = struct { - a_buf: []const u8, - b_buf: []const u8, - - pub fn eql(ctx: HashContext, a: String, b: String) bool { - return a.eql(b, ctx.a_buf, ctx.b_buf); - } - - pub fn hash(ctx: HashContext, a: String) u64 { - const str = a.slice(ctx.a_buf); - return bun.hash(str); - } - }; - - pub const ArrayHashContext = struct { - a_buf: []const u8, - b_buf: []const u8, - - pub fn eql(ctx: ArrayHashContext, a: String, b: String, _: usize) bool { - return a.eql(b, ctx.a_buf, ctx.b_buf); - } - - pub fn hash(ctx: ArrayHashContext, a: String) u32 { - const str = a.slice(ctx.a_buf); - return @as(u32, @truncate(bun.hash(str))); - } - }; - - pub fn init( - buf: string, - in: string, - ) String { - return switch (in.len) { - 0 => String{}, - 1 => String{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, - 2 => String{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, - 3 => String{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, - 4 => String{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, - 5 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, - 6 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, - 7 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, - max_inline_len => - // If they use the final bit, then it's a big string. - // This should only happen for non-ascii strings that are exactly 8 bytes. - // so that's an edge-case - if ((in[max_inline_len - 1]) >= 128) - @as(String, @bitCast((@as( - u64, - 0, - ) | @as( - u64, - @as( - max_addressable_space, - @truncate(@as( - u64, - @bitCast(Pointer.init(buf, in)), - )), - ), - )) | 1 << 63)) - else - String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, - - else => @as( - String, - @bitCast((@as( - u64, - 0, - ) | @as( - u64, - @as( - max_addressable_space, - @truncate(@as( - u64, - @bitCast(Pointer.init(buf, in)), - )), - ), - )) | 1 << 63), - ), - }; - } - - pub fn initInline( - in: string, - ) String { - bun.assertWithLocation(canInline(in), @src()); - return switch (in.len) { - 0 => .{}, - 1 => .{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, - 2 => .{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, - 3 => .{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, - 4 => .{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, - 5 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, - 6 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, - 7 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, - 8 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, - else => unreachable, - }; - } - - pub fn initAppendIfNeeded( - allocator: std.mem.Allocator, - buf: *std.ArrayListUnmanaged(u8), - in: string, - ) OOM!String { - return switch (in.len) { - 0 => .{}, - 1 => .{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, - 2 => .{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, - 3 => .{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, - 4 => .{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, - 5 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, - 6 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, - 7 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, - - max_inline_len => - // If they use the final bit, then it's a big string. - // This should only happen for non-ascii strings that are exactly 8 bytes. - // so that's an edge-case - if ((in[max_inline_len - 1]) >= 128) - try initAppend(allocator, buf, in) - else - .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, - - else => try initAppend(allocator, buf, in), - }; - } - - pub fn initAppend( - allocator: std.mem.Allocator, - buf: *std.ArrayListUnmanaged(u8), - in: string, - ) OOM!String { - try buf.appendSlice(allocator, in); - const in_buf = buf.items[buf.items.len - in.len ..]; - return @bitCast((@as(u64, 0) | @as(u64, @as(max_addressable_space, @truncate(@as(u64, @bitCast(Pointer.init(buf.items, in_buf))))))) | 1 << 63); - } - - pub fn eql(this: String, that: String, this_buf: []const u8, that_buf: []const u8) bool { - if (this.isInline() and that.isInline()) { - return @as(u64, @bitCast(this.bytes)) == @as(u64, @bitCast(that.bytes)); - } else if (this.isInline() != that.isInline()) { - return false; - } else { - const a = this.ptr(); - const b = that.ptr(); - return strings.eql(this_buf[a.off..][0..a.len], that_buf[b.off..][0..b.len]); - } - } - - pub inline fn isEmpty(this: String) bool { - return @as(u64, @bitCast(this.bytes)) == @as(u64, 0); - } - - pub fn len(this: String) usize { - switch (this.bytes[max_inline_len - 1] & 128) { - 0 => { - // Edgecase: string that starts with a 0 byte will be considered empty. - switch (this.bytes[0]) { - 0 => { - return 0; - }, - else => { - comptime var i: usize = 0; - - inline while (i < this.bytes.len) : (i += 1) { - if (this.bytes[i] == 0) return i; - } - - return 8; - }, - } - }, - else => { - const ptr_ = this.ptr(); - return ptr_.len; - }, - } - } - - pub const Pointer = extern struct { - off: u32 = 0, - len: u32 = 0, - - pub inline fn init( - buf: string, - in: string, - ) Pointer { - if (Environment.allow_assert) { - assert(bun.isSliceInBuffer(in, buf)); - } - - return Pointer{ - .off = @as(u32, @truncate(@intFromPtr(in.ptr) - @intFromPtr(buf.ptr))), - .len = @as(u32, @truncate(in.len)), - }; - } - }; - - pub inline fn ptr(this: String) Pointer { - return @as(Pointer, @bitCast(@as(u64, @as(u63, @truncate(@as(u64, @bitCast(this))))))); - } - - pub fn toJS(this: *const String, buffer: []const u8, globalThis: *JSC.JSGlobalObject) JSC.JSValue { - return bun.String.createUTF8ForJS(globalThis, this.slice(buffer)); - } - - // String must be a pointer because we reference it as a slice. It will become a dead pointer if it is copied. - pub fn slice(this: *const String, buf: string) string { - switch (this.bytes[max_inline_len - 1] & 128) { - 0 => { - // Edgecase: string that starts with a 0 byte will be considered empty. - switch (this.bytes[0]) { - 0 => { - return ""; - }, - else => { - comptime var i: usize = 0; - - inline while (i < this.bytes.len) : (i += 1) { - if (this.bytes[i] == 0) return this.bytes[0..i]; - } - - return &this.bytes; - }, - } - }, - else => { - const ptr_ = this.*.ptr(); - return buf[ptr_.off..][0..ptr_.len]; - }, - } - } - - pub const Builder = struct { - len: usize = 0, - cap: usize = 0, - ptr: ?[*]u8 = null, - string_pool: StringPool = undefined, - - pub const StringPool = std.HashMap(u64, String, IdentityContext(u64), 80); - - pub inline fn stringHash(buf: []const u8) u64 { - return bun.Wyhash11.hash(0, buf); - } - - pub inline fn count(this: *Builder, slice_: string) void { - return countWithHash(this, slice_, if (slice_.len >= String.max_inline_len) stringHash(slice_) else std.math.maxInt(u64)); - } - - pub inline fn countWithHash(this: *Builder, slice_: string, hash: u64) void { - if (slice_.len <= String.max_inline_len) return; - - if (!this.string_pool.contains(hash)) { - this.cap += slice_.len; - } - } - - pub inline fn allocatedSlice(this: *Builder) []u8 { - return if (this.cap > 0) - this.ptr.?[0..this.cap] - else - &[_]u8{}; - } - pub fn allocate(this: *Builder, allocator: Allocator) !void { - const ptr_ = try allocator.alloc(u8, this.cap); - this.ptr = ptr_.ptr; - } - - pub fn append(this: *Builder, comptime Type: type, slice_: string) Type { - return @call(bun.callmod_inline, appendWithHash, .{ this, Type, slice_, stringHash(slice_) }); - } - - pub fn appendUTF8WithoutPool(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { - if (slice_.len <= String.max_inline_len) { - if (strings.isAllASCII(slice_)) { - switch (Type) { - String => { - return String.init(this.allocatedSlice(), slice_); - }, - ExternalString => { - return ExternalString.init(this.allocatedSlice(), slice_, hash); - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - } - - if (comptime Environment.allow_assert) { - assert(this.len <= this.cap); // didn't count everything - assert(this.ptr != null); // must call allocate first - } - - bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); - const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; - this.len += slice_.len; - - if (comptime Environment.allow_assert) assert(this.len <= this.cap); - - switch (Type) { - String => { - return String.init(this.allocatedSlice(), final_slice); - }, - ExternalString => { - return ExternalString.init(this.allocatedSlice(), final_slice, hash); - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - - // SlicedString is not supported due to inline strings. - pub fn appendWithoutPool(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { - if (slice_.len <= String.max_inline_len) { - switch (Type) { - String => { - return String.init(this.allocatedSlice(), slice_); - }, - ExternalString => { - return ExternalString.init(this.allocatedSlice(), slice_, hash); - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - if (comptime Environment.allow_assert) { - assert(this.len <= this.cap); // didn't count everything - assert(this.ptr != null); // must call allocate first - } - - bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); - const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; - this.len += slice_.len; - - if (comptime Environment.allow_assert) assert(this.len <= this.cap); - - switch (Type) { - String => { - return String.init(this.allocatedSlice(), final_slice); - }, - ExternalString => { - return ExternalString.init(this.allocatedSlice(), final_slice, hash); - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - - pub fn appendWithHash(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { - if (slice_.len <= String.max_inline_len) { - switch (Type) { - String => { - return String.init(this.allocatedSlice(), slice_); - }, - ExternalString => { - return ExternalString.init(this.allocatedSlice(), slice_, hash); - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - - if (comptime Environment.allow_assert) { - assert(this.len <= this.cap); // didn't count everything - assert(this.ptr != null); // must call allocate first - } - - const string_entry = this.string_pool.getOrPut(hash) catch unreachable; - if (!string_entry.found_existing) { - bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); - const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; - this.len += slice_.len; - - string_entry.value_ptr.* = String.init(this.allocatedSlice(), final_slice); - } - - if (comptime Environment.allow_assert) assert(this.len <= this.cap); - - switch (Type) { - String => { - return string_entry.value_ptr.*; - }, - ExternalString => { - return ExternalString{ - .value = string_entry.value_ptr.*, - .hash = hash, - }; - }, - else => @compileError("Invalid type passed to StringBuilder"), - } - } - }; - - comptime { - if (@sizeOf(String) != @sizeOf(Pointer)) { - @compileError("String types must be the same size"); - } - } -}; - -test "String works" { - { - var buf: string = "hello world"; - const world: string = buf[6..]; - var str = String.init( - buf, - world, - ); - try std.testing.expectEqualStrings("world", str.slice(buf)); - } - - { - const buf: string = "hello"; - const world: string = buf; - var str = String.init( - buf, - world, - ); - try std.testing.expectEqualStrings("hello", str.slice(buf)); - try std.testing.expectEqual(@as(u64, @bitCast(str)), @as(u64, @bitCast([8]u8{ 'h', 'e', 'l', 'l', 'o', 0, 0, 0 }))); - } - - { - const buf: string = &[8]u8{ 'h', 'e', 'l', 'l', 'o', 'k', 'k', 129 }; - const world: string = buf; - var str = String.init( - buf, - world, - ); - try std.testing.expectEqualStrings(buf, str.slice(buf)); - } -} - -pub const ExternalString = extern struct { - value: String = String{}, - hash: u64 = 0, - - pub inline fn fmt(this: *const ExternalString, buf: []const u8) String.Formatter { - return this.value.fmt(buf); - } - - pub fn order(lhs: *const ExternalString, rhs: *const ExternalString, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order { - if (lhs.hash == rhs.hash and lhs.hash > 0) return .eq; - - return lhs.value.order(&rhs.value, lhs_buf, rhs_buf); - } - - /// ExternalString but without the hash - pub inline fn from(in: string) ExternalString { - return ExternalString{ - .value = String.init(in, in), - .hash = bun.Wyhash.hash(0, in), - }; - } - - pub inline fn isInline(this: ExternalString) bool { - return this.value.isInline(); - } - - pub inline fn isEmpty(this: ExternalString) bool { - return this.value.isEmpty(); - } - - pub inline fn len(this: ExternalString) usize { - return this.value.len(); - } - - pub inline fn init(buf: string, in: string, hash: u64) ExternalString { - return ExternalString{ - .value = String.init(buf, in), - .hash = hash, - }; - } - - pub inline fn slice(this: *const ExternalString, buf: string) string { - return this.value.slice(buf); - } -}; - -pub const SlicedString = struct { - buf: string, - slice: string, - - pub inline fn init(buf: string, slice: string) SlicedString { - if (Environment.allow_assert and !@inComptime()) { - if (@intFromPtr(buf.ptr) > @intFromPtr(slice.ptr)) { - @panic("SlicedString.init buf is not in front of slice"); - } - } - return SlicedString{ .buf = buf, .slice = slice }; - } - - pub inline fn external(this: SlicedString) ExternalString { - if (comptime Environment.allow_assert) { - assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); - } - - return ExternalString.init(this.buf, this.slice, bun.Wyhash11.hash(0, this.slice)); - } - - pub inline fn value(this: SlicedString) String { - if (comptime Environment.allow_assert) { - assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); - } - - return String.init(this.buf, this.slice); - } - - pub inline fn sub(this: SlicedString, input: string) SlicedString { - if (Environment.allow_assert) { - if (!(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.buf.ptr) and ((@intFromPtr(input.ptr) + input.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len)))) { - @panic("SlicedString.sub input is not a substring of the slice"); - } - } - return SlicedString{ .buf = this.buf, .slice = input }; - } -}; - -pub const Version = extern struct { - major: u32 = 0, - minor: u32 = 0, - patch: u32 = 0, - _tag_padding: [4]u8 = .{0} ** 4, // [see padding_checker.zig] - tag: Tag = .{}, - - /// Assumes that there is only one buffer for all the strings - pub fn sortGt(ctx: []const u8, lhs: Version, rhs: Version) bool { - return orderFn(ctx, lhs, rhs) == .gt; - } - - pub fn orderFn(ctx: []const u8, lhs: Version, rhs: Version) std.math.Order { - return lhs.order(rhs, ctx, ctx); - } - - pub fn isZero(this: Version) bool { - return this.patch == 0 and this.minor == 0 and this.major == 0; - } - - pub fn parseUTF8(slice: []const u8) ParseResult { - return parse(.{ .buf = slice, .slice = slice }); - } - - pub fn cloneInto(this: Version, slice: []const u8, buf: *[]u8) Version { - return .{ - .major = this.major, - .minor = this.minor, - .patch = this.patch, - .tag = this.tag.cloneInto(slice, buf), - }; - } - - pub inline fn len(this: *const Version) u32 { - return this.tag.build.len + this.tag.pre.len; - } - - pub const Formatter = struct { - version: Version, - input: string, - - pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const self = formatter.version; - try std.fmt.format(writer, "{?d}.{?d}.{?d}", .{ self.major, self.minor, self.patch }); - - if (self.tag.hasPre()) { - const pre = self.tag.pre.slice(formatter.input); - try writer.writeAll("-"); - try writer.writeAll(pre); - } - - if (self.tag.hasBuild()) { - const build = self.tag.build.slice(formatter.input); - try writer.writeAll("+"); - try writer.writeAll(build); - } - } - }; - - pub fn fmt(this: Version, input: string) Formatter { - return .{ .version = this, .input = input }; - } - - pub const DiffFormatter = struct { - version: Version, - buf: string, - other: Version, - other_buf: string, - - pub fn format(this: DiffFormatter, comptime fmt_: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { - if (!Output.enable_ansi_colors) { - // print normally if no colors - const formatter: Formatter = .{ .version = this.version, .input = this.buf }; - return Formatter.format(formatter, fmt_, options, writer); - } - - const diff = this.version.whichVersionIsDifferent(this.other, this.buf, this.other_buf) orelse .none; - - switch (diff) { - .major => try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }), - .minor => { - if (this.version.major == 0) { - try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }); - } else { - try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }); - } - }, - .patch => { - if (this.version.major == 0 and this.version.minor == 0) { - try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }); - } else { - try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }); - } - }, - .none, .pre, .build => try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ - this.version.major, this.version.minor, this.version.patch, - }), - } - - // might be pre or build. loop through all characters, and insert on - // first diff. - - var set_color = false; - if (this.version.tag.hasPre()) { - if (this.other.tag.hasPre()) { - const pre = this.version.tag.pre.slice(this.buf); - const other_pre = this.other.tag.pre.slice(this.other_buf); - - var first = true; - for (pre, 0..) |c, i| { - if (!set_color and i < other_pre.len and c != other_pre[i]) { - set_color = true; - try writer.writeAll(Output.prettyFmt("", true)); - } - if (first) { - first = false; - try writer.writeByte('-'); - } - try writer.writeByte(c); - } - } else { - try writer.print(Output.prettyFmt("-{}", true), .{this.version.tag.pre.fmt(this.buf)}); - set_color = true; - } - } - - if (this.version.tag.hasBuild()) { - if (this.other.tag.hasBuild()) { - const build = this.version.tag.build.slice(this.buf); - const other_build = this.other.tag.build.slice(this.other_buf); - - var first = true; - for (build, 0..) |c, i| { - if (!set_color and i < other_build.len and c != other_build[i]) { - set_color = true; - try writer.writeAll(Output.prettyFmt("", true)); - } - if (first) { - first = false; - try writer.writeByte('+'); - } - try writer.writeByte(c); - } - } else { - if (!set_color) { - try writer.print(Output.prettyFmt("+{}", true), .{this.version.tag.build.fmt(this.buf)}); - } else { - try writer.print("+{}", .{this.version.tag.build.fmt(this.other_buf)}); - } - } - } - - try writer.writeAll(Output.prettyFmt("", true)); - } - }; - - pub fn diffFmt(this: Version, other: Version, this_buf: string, other_buf: string) DiffFormatter { - return .{ - .version = this, - .buf = this_buf, - .other = other, - .other_buf = other_buf, - }; - } - - pub const ChangedVersion = enum { - major, - minor, - patch, - pre, - build, - none, - }; - - pub fn whichVersionIsDifferent( - left: Version, - right: Version, - left_buf: string, - right_buf: string, - ) ?ChangedVersion { - if (left.major != right.major) return .major; - if (left.minor != right.minor) return .minor; - if (left.patch != right.patch) return .patch; - - if (left.tag.hasPre() != right.tag.hasPre()) return .pre; - if (!left.tag.hasPre() and !right.tag.hasPre()) return null; - if (left.tag.orderPre(right.tag, left_buf, right_buf) != .eq) return .pre; - - if (left.tag.hasBuild() != right.tag.hasBuild()) return .build; - if (!left.tag.hasBuild() and !right.tag.hasBuild()) return null; - return if (left.tag.build.order(&right.tag.build, left_buf, right_buf) != .eq) - .build - else - null; - } - - pub fn count(this: *const Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void { - if (this.tag.hasPre() and !this.tag.pre.isInline()) builder.count(this.tag.pre.slice(buf)); - if (this.tag.hasBuild() and !this.tag.build.isInline()) builder.count(this.tag.build.slice(buf)); - } - - pub fn append(this: *const Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) Version { - var that = this.*; - - if (this.tag.hasPre() and !this.tag.pre.isInline()) that.tag.pre = builder.append(ExternalString, this.tag.pre.slice(buf)); - if (this.tag.hasBuild() and !this.tag.build.isInline()) that.tag.build = builder.append(ExternalString, this.tag.build.slice(buf)); - - return that; - } - - pub const Partial = struct { - major: ?u32 = null, - minor: ?u32 = null, - patch: ?u32 = null, - tag: Tag = .{}, - - pub fn min(this: Partial) Version { - return .{ - .major = this.major orelse 0, - .minor = this.minor orelse 0, - .patch = this.patch orelse 0, - .tag = this.tag, - }; - } - - pub fn max(this: Partial) Version { - return .{ - .major = this.major orelse std.math.maxInt(u32), - .minor = this.minor orelse std.math.maxInt(u32), - .patch = this.patch orelse std.math.maxInt(u32), - .tag = this.tag, - }; - } - }; - - const Hashable = extern struct { - major: u32, - minor: u32, - patch: u32, - pre: u64, - build: u64, - }; - - pub fn hash(this: Version) u64 { - const hashable = Hashable{ - .major = this.major, - .minor = this.minor, - .patch = this.patch, - .pre = this.tag.pre.hash, - .build = this.tag.build.hash, - }; - const bytes = std.mem.asBytes(&hashable); - return bun.Wyhash.hash(0, bytes); - } - - pub fn eql(lhs: Version, rhs: Version) bool { - return lhs.major == rhs.major and lhs.minor == rhs.minor and lhs.patch == rhs.patch and rhs.tag.eql(lhs.tag); - } - - pub const HashContext = struct { - pub fn hash(_: @This(), lhs: Version) u32 { - return @as(u32, @truncate(lhs.hash())); - } - - pub fn eql(_: @This(), lhs: Version, rhs: Version) bool { - return lhs.eql(rhs); - } - }; - - pub const PinnedVersion = enum { - major, // ^ - minor, // ~ - patch, // = - }; - - /// Modified version of pnpm's `whichVersionIsPinned` - /// https://github.com/pnpm/pnpm/blob/bc0618cf192a9cafd0ab171a3673e23ed0869bbd/packages/which-version-is-pinned/src/index.ts#L9 - /// - /// Differences: - /// - It's not used for workspaces - /// - `npm:` is assumed already removed from aliased versions - /// - Invalid input is considered major pinned (important because these strings are coming - /// from package.json) - /// - /// The goal of this function is to avoid a complete parse of semver that's unused - pub fn whichVersionIsPinned(input: string) PinnedVersion { - const version = strings.trim(input, &strings.whitespace_chars); - - var i: usize = 0; - - const pinned: PinnedVersion = pinned: { - for (0..version.len) |j| { - switch (version[j]) { - // newlines & whitespace - ' ', - '\t', - '\n', - '\r', - std.ascii.control_code.vt, - std.ascii.control_code.ff, - - // version separators - 'v', - '=', - => {}, - - else => |c| { - i = j; - - switch (c) { - '~', '^' => { - i += 1; - - for (i..version.len) |k| { - switch (version[k]) { - ' ', - '\t', - '\n', - '\r', - std.ascii.control_code.vt, - std.ascii.control_code.ff, - => { - // `v` and `=` not included. - // `~v==1` would update to `^1.1.0` if versions `1.0.0`, `1.0.1`, `1.1.0`, and `2.0.0` are available - // note that `~` changes to `^` - }, - - else => { - i = k; - break :pinned if (c == '~') .minor else .major; - }, - } - } - - // entire version after `~` is whitespace. invalid - return .major; - }, - - '0'...'9' => break :pinned .patch, - - // could be invalid, could also be valid range syntax (>=, ...) - // either way, pin major - else => return .major, - } - }, - } - } - - // entire semver is whitespace, `v`, and `=`. Invalid - return .major; - }; - - // `pinned` is `.major`, `.minor`, or `.patch`. Check for each version core number: - // - if major is missing, return `if (pinned == .patch) .major else pinned` - // - if minor is missing, return `if (pinned == .patch) .minor else pinned` - // - if patch is missing, return `pinned` - // - if there's whitespace or non-digit characters between core numbers, return `.major` - // - if the end is reached, return `pinned` - - // major - if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; - var d = version[i]; - while (std.ascii.isDigit(d)) { - i += 1; - if (i >= version.len) return if (pinned == .patch) .major else pinned; - d = version[i]; - } - - if (d != '.') return .major; - - // minor - i += 1; - if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; - d = version[i]; - while (std.ascii.isDigit(d)) { - i += 1; - if (i >= version.len) return if (pinned == .patch) .minor else pinned; - d = version[i]; - } - - if (d != '.') return .major; - - // patch - i += 1; - if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; - d = version[i]; - while (std.ascii.isDigit(d)) { - i += 1; - - // patch is done and at input end, valid - if (i >= version.len) return pinned; - d = version[i]; - } - - // Skip remaining valid pre/build tag characters and whitespace. - // Does not validate whitespace used inside pre/build tags. - if (!validPreOrBuildTagCharacter(d) or std.ascii.isWhitespace(d)) return .major; - i += 1; - - // at this point the semver is valid so we can return true if it ends - if (i >= version.len) return pinned; - d = version[i]; - while (validPreOrBuildTagCharacter(d) and !std.ascii.isWhitespace(d)) { - i += 1; - if (i >= version.len) return pinned; - d = version[i]; - } - - // We've come across a character that is not valid for tags or is whitespace. - // Trailing whitespace was trimmed so we can assume there's another range - return .major; - } - - fn validPreOrBuildTagCharacter(c: u8) bool { - return switch (c) { - '-', '+', '.', 'A'...'Z', 'a'...'z', '0'...'9' => true, - else => false, - }; - } - - pub fn isTaggedVersionOnly(input: []const u8) bool { - const version = strings.trim(input, &strings.whitespace_chars); - - // first needs to be a-z - if (version.len == 0 or !std.ascii.isAlphabetic(version[0])) return false; - - for (1..version.len) |i| { - if (!std.ascii.isAlphanumeric(version[i])) return false; - } - - return true; - } - - pub fn orderWithoutTag( - lhs: Version, - rhs: Version, - ) std.math.Order { - if (lhs.major < rhs.major) return .lt; - if (lhs.major > rhs.major) return .gt; - if (lhs.minor < rhs.minor) return .lt; - if (lhs.minor > rhs.minor) return .gt; - if (lhs.patch < rhs.patch) return .lt; - if (lhs.patch > rhs.patch) return .gt; - - if (lhs.tag.hasPre()) { - if (!rhs.tag.hasPre()) return .lt; - } else { - if (rhs.tag.hasPre()) return .gt; - } - - return .eq; - } - - pub fn order( - lhs: Version, - rhs: Version, - lhs_buf: []const u8, - rhs_buf: []const u8, - ) std.math.Order { - const order_without_tag = orderWithoutTag(lhs, rhs); - if (order_without_tag != .eq) return order_without_tag; - - return lhs.tag.order(rhs.tag, lhs_buf, rhs_buf); - } - - pub fn orderWithoutBuild( - lhs: Version, - rhs: Version, - lhs_buf: []const u8, - rhs_buf: []const u8, - ) std.math.Order { - const order_without_tag = orderWithoutTag(lhs, rhs); - if (order_without_tag != .eq) return order_without_tag; - - return lhs.tag.orderWithoutBuild(rhs.tag, lhs_buf, rhs_buf); - } - - pub const Tag = extern struct { - pre: ExternalString = ExternalString{}, - build: ExternalString = ExternalString{}, - - pub fn orderPre(lhs: Tag, rhs: Tag, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order { - const lhs_str = lhs.pre.slice(lhs_buf); - const rhs_str = rhs.pre.slice(rhs_buf); - - // 1. split each by '.', iterating through each one looking for integers - // 2. compare as integers, or if not possible compare as string - // 3. whichever is greater is the greater one - // - // 1.0.0-canary.0.0.0.0.0.0 < 1.0.0-canary.0.0.0.0.0.1 - - var lhs_itr = strings.split(lhs_str, "."); - var rhs_itr = strings.split(rhs_str, "."); - - while (true) { - const lhs_part = lhs_itr.next(); - const rhs_part = rhs_itr.next(); - - if (lhs_part == null and rhs_part == null) return .eq; - - // if right is null, left is greater than. - if (rhs_part == null) return .gt; - - // if left is null, left is less than. - if (lhs_part == null) return .lt; - - const lhs_uint: ?u32 = std.fmt.parseUnsigned(u32, lhs_part.?, 10) catch null; - const rhs_uint: ?u32 = std.fmt.parseUnsigned(u32, rhs_part.?, 10) catch null; - - // a part that doesn't parse as an integer is greater than a part that does - // https://github.com/npm/node-semver/blob/816c7b2cbfcb1986958a290f941eddfd0441139e/internal/identifiers.js#L12 - if (lhs_uint != null and rhs_uint == null) return .lt; - if (lhs_uint == null and rhs_uint != null) return .gt; - - if (lhs_uint == null and rhs_uint == null) { - switch (strings.order(lhs_part.?, rhs_part.?)) { - .eq => { - // continue to the next part - continue; - }, - else => |not_equal| return not_equal, - } - } - - switch (std.math.order(lhs_uint.?, rhs_uint.?)) { - .eq => continue, - else => |not_equal| return not_equal, - } - } - - unreachable; - } - - pub fn order( - lhs: Tag, - rhs: Tag, - lhs_buf: []const u8, - rhs_buf: []const u8, - ) std.math.Order { - if (!lhs.pre.isEmpty() and !rhs.pre.isEmpty()) { - return lhs.orderPre(rhs, lhs_buf, rhs_buf); - } - - const pre_order = lhs.pre.order(&rhs.pre, lhs_buf, rhs_buf); - if (pre_order != .eq) return pre_order; - - return lhs.build.order(&rhs.build, lhs_buf, rhs_buf); - } - - pub fn orderWithoutBuild( - lhs: Tag, - rhs: Tag, - lhs_buf: []const u8, - rhs_buf: []const u8, - ) std.math.Order { - if (!lhs.pre.isEmpty() and !rhs.pre.isEmpty()) { - return lhs.orderPre(rhs, lhs_buf, rhs_buf); - } - - return lhs.pre.order(&rhs.pre, lhs_buf, rhs_buf); - } - - pub fn cloneInto(this: Tag, slice: []const u8, buf: *[]u8) Tag { - var pre: String = this.pre.value; - var build: String = this.build.value; - - if (this.pre.isInline()) { - pre = this.pre.value; - } else { - const pre_slice = this.pre.slice(slice); - bun.copy(u8, buf.*, pre_slice); - pre = String.init(buf.*, buf.*[0..pre_slice.len]); - buf.* = buf.*[pre_slice.len..]; - } - - if (this.build.isInline()) { - build = this.build.value; - } else { - const build_slice = this.build.slice(slice); - bun.copy(u8, buf.*, build_slice); - build = String.init(buf.*, buf.*[0..build_slice.len]); - buf.* = buf.*[build_slice.len..]; - } - - return .{ - .pre = .{ - .value = pre, - .hash = this.pre.hash, - }, - .build = .{ - .value = build, - .hash = this.build.hash, - }, - }; - } - - pub inline fn hasPre(this: Tag) bool { - return !this.pre.isEmpty(); - } - - pub inline fn hasBuild(this: Tag) bool { - return !this.build.isEmpty(); - } - - pub fn eql(lhs: Tag, rhs: Tag) bool { - return lhs.pre.hash == rhs.pre.hash; - } - - pub const TagResult = struct { - tag: Tag = Tag{}, - len: u32 = 0, - }; - - var multi_tag_warn = false; - // TODO: support multiple tags - - pub fn parse(sliced_string: SlicedString) TagResult { - return parseWithPreCount(sliced_string, 0); - } - - pub fn parseWithPreCount(sliced_string: SlicedString, initial_pre_count: u32) TagResult { - var input = sliced_string.slice; - var build_count: u32 = 0; - var pre_count: u32 = initial_pre_count; - - for (input) |c| { - switch (c) { - ' ' => break, - '+' => { - build_count += 1; - }, - '-' => { - pre_count += 1; - }, - else => {}, - } - } - - if (build_count == 0 and pre_count == 0) { - return TagResult{ - .len = 0, - }; - } - - const State = enum { none, pre, build }; - var result = TagResult{}; - // Common case: no allocation is necessary. - var state = State.none; - var start: usize = 0; - - var i: usize = 0; - - while (i < input.len) : (i += 1) { - const c = input[i]; - switch (c) { - '+' => { - // qualifier ::= ( '-' pre )? ( '+' build )? - if (state == .pre or state == .none and initial_pre_count > 0) { - result.tag.pre = sliced_string.sub(input[start..i]).external(); - } - - if (state != .build) { - state = .build; - start = i + 1; - } - }, - '-' => { - if (state != .pre) { - state = .pre; - start = i + 1; - } - }, - - // only continue if character is a valid pre/build tag character - // https://semver.org/#spec-item-9 - 'a'...'z', 'A'...'Z', '0'...'9', '.' => {}, - - else => { - switch (state) { - .none => {}, - .pre => { - result.tag.pre = sliced_string.sub(input[start..i]).external(); - - state = State.none; - }, - .build => { - result.tag.build = sliced_string.sub(input[start..i]).external(); - if (comptime Environment.isDebug) { - assert(!strings.containsChar(result.tag.build.slice(sliced_string.buf), '-')); - } - state = State.none; - }, - } - result.len = @truncate(i); - break; - }, - } - } - - if (state == .none and initial_pre_count > 0) { - state = .pre; - start = 0; - } - - switch (state) { - .none => {}, - .pre => { - result.tag.pre = sliced_string.sub(input[start..i]).external(); - // a pre can contain multiple consecutive tags - // checking for "-" prefix is not enough, as --canary.67e7966.0 is a valid tag - state = State.none; - }, - .build => { - // a build can contain multiple consecutive tags - result.tag.build = sliced_string.sub(input[start..i]).external(); - - state = State.none; - }, - } - result.len = @as(u32, @truncate(i)); - - return result; - } - }; - - pub const ParseResult = struct { - wildcard: Query.Token.Wildcard = .none, - valid: bool = true, - version: Version.Partial = .{}, - len: u32 = 0, - }; - - pub fn parse(sliced_string: SlicedString) ParseResult { - var input = sliced_string.slice; - var result = ParseResult{}; - - var part_i: u8 = 0; - var part_start_i: usize = 0; - var last_char_i: usize = 0; - - if (input.len == 0) { - result.valid = false; - return result; - } - var is_done = false; - - var i: usize = 0; - - for (0..input.len) |c| { - switch (input[c]) { - // newlines & whitespace - ' ', - '\t', - '\n', - '\r', - std.ascii.control_code.vt, - std.ascii.control_code.ff, - - // version separators - 'v', - '=', - => {}, - else => { - i = c; - break; - }, - } - } - - if (i == input.len) { - result.valid = false; - return result; - } - - // two passes :( - while (i < input.len) { - if (is_done) { - break; - } - - switch (input[i]) { - ' ' => { - is_done = true; - break; - }, - '|', '^', '#', '&', '%', '!' => { - is_done = true; - if (i > 0) { - i -= 1; - } - break; - }, - '0'...'9' => { - part_start_i = i; - i += 1; - - while (i < input.len and switch (input[i]) { - '0'...'9' => true, - else => false, - }) { - i += 1; - } - - last_char_i = i; - - switch (part_i) { - 0 => { - result.version.major = parseVersionNumber(input[part_start_i..last_char_i]); - part_i = 1; - }, - 1 => { - result.version.minor = parseVersionNumber(input[part_start_i..last_char_i]); - part_i = 2; - }, - 2 => { - result.version.patch = parseVersionNumber(input[part_start_i..last_char_i]); - part_i = 3; - }, - else => {}, - } - - if (i < input.len and switch (input[i]) { - // `.` is expected only if there are remaining core version numbers - '.' => part_i != 3, - else => false, - }) { - i += 1; - } - }, - '.' => { - result.valid = false; - is_done = true; - break; - }, - '-', '+' => { - // Just a plain tag with no version is invalid. - if (part_i < 2 and result.wildcard == .none) { - result.valid = false; - is_done = true; - break; - } - - part_start_i = i; - while (i < input.len and switch (input[i]) { - ' ' => true, - else => false, - }) { - i += 1; - } - const tag_result = Tag.parse(sliced_string.sub(input[part_start_i..])); - result.version.tag = tag_result.tag; - i += tag_result.len; - break; - }, - 'x', '*', 'X' => { - part_start_i = i; - i += 1; - - while (i < input.len and switch (input[i]) { - 'x', '*', 'X' => true, - else => false, - }) { - i += 1; - } - - last_char_i = i; - - if (i < input.len and switch (input[i]) { - '.' => true, - else => false, - }) { - i += 1; - } - - if (result.wildcard == .none) { - switch (part_i) { - 0 => { - result.wildcard = Query.Token.Wildcard.major; - part_i = 1; - }, - 1 => { - result.wildcard = Query.Token.Wildcard.minor; - part_i = 2; - }, - 2 => { - result.wildcard = Query.Token.Wildcard.patch; - part_i = 3; - }, - else => {}, - } - } - }, - else => |c| { - - // Some weirdo npm packages in the wild have a version like "1.0.0rc.1" - // npm just expects that to work...even though it has no "-" qualifier. - if (result.wildcard == .none and part_i >= 2 and switch (c) { - 'a'...'z', 'A'...'Z' => true, - else => false, - }) { - part_start_i = i; - const tag_result = Tag.parseWithPreCount(sliced_string.sub(input[part_start_i..]), 1); - result.version.tag = tag_result.tag; - i += tag_result.len; - is_done = true; - last_char_i = i; - break; - } - - last_char_i = 0; - result.valid = false; - is_done = true; - break; - }, - } - } - - if (result.wildcard == .none) { - switch (part_i) { - 0 => { - result.wildcard = Query.Token.Wildcard.major; - }, - 1 => { - result.wildcard = Query.Token.Wildcard.minor; - }, - 2 => { - result.wildcard = Query.Token.Wildcard.patch; - }, - else => {}, - } - } - - result.len = @as(u32, @intCast(i)); - - return result; - } - - fn parseVersionNumber(input: string) ?u32 { - // max decimal u32 is 4294967295 - var bytes: [10]u8 = undefined; - var byte_i: u8 = 0; - - assert(input[0] != '.'); - - for (input) |char| { - switch (char) { - 'X', 'x', '*' => return null, - '0'...'9' => { - // out of bounds - if (byte_i + 1 > bytes.len) return null; - bytes[byte_i] = char; - byte_i += 1; - }, - ' ', '.' => break, - // ignore invalid characters - else => {}, - } - } - - // If there are no numbers - if (byte_i == 0) return null; - - if (comptime Environment.isDebug) { - return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch |err| { - Output.prettyErrorln("ERROR {s} parsing version: \"{s}\", bytes: {s}", .{ - @errorName(err), - input, - bytes[0..byte_i], - }); - return 0; - }; - } - - return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch 0; - } -}; - -pub const Range = struct { - pub const Op = enum(u8) { - unset = 0, - eql = 1, - lt = 3, - lte = 4, - gt = 5, - gte = 6, - }; - - left: Comparator = .{}, - right: Comparator = .{}, - - pub fn format(this: Range, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - if (this.left.op == .unset and this.right.op == .unset) { - return; - } - - if (this.right.op == .unset) { - try std.fmt.format(writer, "{}", .{this.left}); - } else { - try std.fmt.format(writer, "{} {}", .{ this.left, this.right }); - } - } - - /// * - /// >= 0.0.0 - /// >= 0 - /// >= 0.0 - /// >= x - /// >= 0 - pub fn anyRangeSatisfies(this: *const Range) bool { - return this.left.op == .gte and this.left.version.eql(.{}); - } - - pub fn initWildcard(version: Version, wildcard: Query.Token.Wildcard) Range { - switch (wildcard) { - .none => { - return .{ - .left = .{ - .op = Op.eql, - .version = version, - }, - }; - }, - - .major => { - return .{ - .left = .{ - .op = Op.gte, - .version = .{ - // .raw = version.raw - }, - }, - }; - }, - .minor => { - const lhs = Version{ - .major = version.major +| 1, - // .raw = version.raw - }; - const rhs = Version{ - .major = version.major, - // .raw = version.raw - }; - return .{ - .left = .{ - .op = Op.lt, - .version = lhs, - }, - .right = .{ - .op = Op.gte, - .version = rhs, - }, - }; - }, - .patch => { - const lhs = Version{ - .major = version.major, - .minor = version.minor +| 1, - // .raw = version.raw; - }; - const rhs = Version{ - .major = version.major, - .minor = version.minor, - // .raw = version.raw; - }; - return Range{ - .left = .{ - .op = Op.lt, - .version = lhs, - }, - .right = .{ - .op = Op.gte, - .version = rhs, - }, - }; - }, - } - } - - pub inline fn hasLeft(this: Range) bool { - return this.left.op != Op.unset; - } - - pub inline fn hasRight(this: Range) bool { - return this.right.op != Op.unset; - } - - /// Is the Range equal to another Range - /// This does not evaluate the range. - pub inline fn eql(lhs: Range, rhs: Range) bool { - return lhs.left.eql(rhs.left) and lhs.right.eql(rhs.right); - } - - pub const Formatter = struct { - buffer: []const u8, - range: *const Range, - - pub fn format(this: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - if (this.range.left.op == Op.unset and this.range.right.op == Op.unset) { - return; - } - - if (this.range.right.op == .unset) { - try std.fmt.format(writer, "{}", .{this.range.left.fmt(this.buffer)}); - } else { - try std.fmt.format(writer, "{} {}", .{ this.range.left.fmt(this.buffer), this.range.right.fmt(this.buffer) }); - } - } - }; - - pub fn fmt(this: *const Range, buf: []const u8) @This().Formatter { - return .{ .buffer = buf, .range = this }; - } - - pub const Comparator = struct { - op: Op = .unset, - version: Version = .{}, - - pub inline fn eql(lhs: Comparator, rhs: Comparator) bool { - return lhs.op == rhs.op and lhs.version.eql(rhs.version); - } - - pub const Formatter = struct { - buffer: []const u8, - comparator: *const Comparator, - - pub fn format(this: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - if (this.comparator.op == Op.unset) { - return; - } - - switch (this.comparator.op) { - .unset => unreachable, // see above, - .eql => try writer.writeAll("=="), - .lt => try writer.writeAll("<"), - .lte => try writer.writeAll("<="), - .gt => try writer.writeAll(">"), - .gte => try writer.writeAll(">="), - } - - try std.fmt.format(writer, "{}", .{this.comparator.version.fmt(this.buffer)}); - } - }; - - pub fn fmt(this: *const Comparator, buf: []const u8) @This().Formatter { - return .{ .buffer = buf, .comparator = this }; - } - - pub fn satisfies( - comparator: Comparator, - version: Version, - comparator_buf: string, - version_buf: string, - ) bool { - const order = version.orderWithoutBuild(comparator.version, version_buf, comparator_buf); - - return switch (order) { - .eq => switch (comparator.op) { - .lte, .gte, .eql => true, - else => false, - }, - .gt => switch (comparator.op) { - .gt, .gte => true, - else => false, - }, - .lt => switch (comparator.op) { - .lt, .lte => true, - else => false, - }, - }; - } - }; - - pub fn satisfies(range: Range, version: Version, range_buf: string, version_buf: string) bool { - const has_left = range.hasLeft(); - const has_right = range.hasRight(); - - if (!has_left) { - return true; - } - - if (!range.left.satisfies(version, range_buf, version_buf)) { - return false; - } - - if (has_right and !range.right.satisfies(version, range_buf, version_buf)) { - return false; - } - - return true; - } - - pub fn satisfiesPre(range: Range, version: Version, range_buf: string, version_buf: string, pre_matched: *bool) bool { - if (comptime Environment.allow_assert) { - assert(version.tag.hasPre()); - } - const has_left = range.hasLeft(); - const has_right = range.hasRight(); - - if (!has_left) { - return true; - } - - // If left has prerelease check if major,minor,patch matches with left. If - // not, check the same with right if right exists and has prerelease. - pre_matched.* = pre_matched.* or - (range.left.version.tag.hasPre() and - version.patch == range.left.version.patch and - version.minor == range.left.version.minor and - version.major == range.left.version.major) or - (has_right and - range.right.version.tag.hasPre() and - version.patch == range.right.version.patch and - version.minor == range.right.version.minor and - version.major == range.right.version.major); - - if (!range.left.satisfies(version, range_buf, version_buf)) { - return false; - } - - if (has_right and !range.right.satisfies(version, range_buf, version_buf)) { - return false; - } - - return true; - } -}; - -/// Linked-list of AND ranges -/// "^1 ^2" -/// ----|----- -/// That is two Query -pub const Query = struct { - pub const Op = enum { - none, - AND, - OR, - }; - - range: Range = Range{}, - - // AND - next: ?*Query = null, - - const Formatter = struct { - query: *const Query, - buffer: []const u8, - pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const this = formatter.query; - - if (this.next) |ptr| { - if (ptr.range.hasLeft() or ptr.range.hasRight()) { - try std.fmt.format(writer, "{} && {}", .{ this.range.fmt(formatter.buffer), ptr.range.fmt(formatter.buffer) }); - return; - } - } - - try std.fmt.format(writer, "{}", .{this.range.fmt(formatter.buffer)}); - } - }; - - pub fn fmt(this: *const Query, buf: []const u8) @This().Formatter { - return .{ .query = this, .buffer = buf }; - } - - /// Linked-list of Queries OR'd together - /// "^1 || ^2" - /// ----|----- - /// That is two List - pub const List = struct { - head: Query = Query{}, - tail: ?*Query = null, - - // OR - next: ?*List = null, - - const Formatter = struct { - list: *const List, - buffer: []const u8, - pub fn format(formatter: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const this = formatter.list; - - if (this.next) |ptr| { - try std.fmt.format(writer, "{} || {}", .{ this.head.fmt(formatter.buffer), ptr.fmt(formatter.buffer) }); - } else { - try std.fmt.format(writer, "{}", .{this.head.fmt(formatter.buffer)}); - } - } - }; - - pub fn fmt(this: *const List, buf: []const u8) @This().Formatter { - return .{ .list = this, .buffer = buf }; - } - - pub fn satisfies(list: *const List, version: Version, list_buf: string, version_buf: string) bool { - return list.head.satisfies( - version, - list_buf, - version_buf, - ) or (list.next orelse return false).satisfies( - version, - list_buf, - version_buf, - ); - } - - pub fn satisfiesPre(list: *const List, version: Version, list_buf: string, version_buf: string) bool { - if (comptime Environment.allow_assert) { - assert(version.tag.hasPre()); - } - - // `version` has a prerelease tag: - // - needs to satisfy each comparator in the query ( AND AND ...) like normal comparison - // - if it does, also needs to match major, minor, patch with at least one of the other versions - // with a prerelease - // https://github.com/npm/node-semver/blob/ac9b35769ab0ddfefd5a3af4a3ecaf3da2012352/classes/range.js#L505 - var pre_matched = false; - return (list.head.satisfiesPre( - version, - list_buf, - version_buf, - &pre_matched, - ) and pre_matched) or (list.next orelse return false).satisfiesPre( - version, - list_buf, - version_buf, - ); - } - - pub fn eql(lhs: *const List, rhs: *const List) bool { - if (!lhs.head.eql(&rhs.head)) return false; - - const lhs_next = lhs.next orelse return rhs.next == null; - const rhs_next = rhs.next orelse return false; - - return lhs_next.eql(rhs_next); - } - - pub fn andRange(self: *List, allocator: Allocator, range: Range) !void { - if (!self.head.range.hasLeft() and !self.head.range.hasRight()) { - self.head.range = range; - return; - } - - var tail = try allocator.create(Query); - tail.* = Query{ - .range = range, - }; - tail.range = range; - - var last_tail = self.tail orelse &self.head; - last_tail.next = tail; - self.tail = tail; - } - }; - - pub const Group = struct { - head: List = List{}, - tail: ?*List = null, - allocator: Allocator, - input: string = "", - - flags: FlagsBitSet = FlagsBitSet.initEmpty(), - pub const Flags = struct { - pub const pre = 1; - pub const build = 0; - }; - - const Formatter = struct { - group: *const Group, - buf: string, - - pub fn format(formatter: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { - const this = formatter.group; - - if (this.tail == null and this.head.tail == null and !this.head.head.range.hasLeft()) { - return; - } - - if (this.tail == null and this.head.tail == null) { - try std.fmt.format(writer, "{}", .{this.head.fmt(formatter.buf)}); - return; - } - - var list = &this.head; - while (list.next) |next| { - try std.fmt.format(writer, "{} && ", .{list.fmt(formatter.buf)}); - list = next; - } - - try std.fmt.format(writer, "{}", .{list.fmt(formatter.buf)}); - } - }; - - pub fn fmt(this: *const Group, buf: string) @This().Formatter { - return .{ - .group = this, - .buf = buf, - }; - } - - pub fn jsonStringify(this: *const Group, writer: anytype) !void { - const temp = try std.fmt.allocPrint(bun.default_allocator, "{}", .{this.fmt()}); - defer bun.default_allocator.free(temp); - try std.json.encodeJsonString(temp, .{}, writer); - } - - pub fn deinit(this: *const Group) void { - var list = this.head; - var allocator = this.allocator; - - while (list.next) |next| { - var query = list.head; - while (query.next) |next_query| { - query = next_query.*; - allocator.destroy(next_query); - } - list = next.*; - allocator.destroy(next); - } - } - - pub fn getExactVersion(this: *const Group) ?Version { - const range = this.head.head.range; - if (this.head.next == null and - this.head.head.next == null and - range.hasLeft() and - range.left.op == .eql and - !range.hasRight()) - { - if (comptime Environment.allow_assert) { - assert(this.tail == null); - } - return range.left.version; - } - - return null; - } - - pub fn from(version: Version) Group { - return .{ - .allocator = bun.default_allocator, - .head = .{ - .head = .{ - .range = .{ - .left = .{ - .op = .eql, - .version = version, - }, - }, - }, - }, - }; - } - - pub const FlagsBitSet = bun.bit_set.IntegerBitSet(3); - - pub fn isExact(this: *const Group) bool { - return this.head.next == null and this.head.head.next == null and !this.head.head.range.hasRight() and this.head.head.range.left.op == .eql; - } - - pub fn @"is *"(this: *const Group) bool { - const left = this.head.head.range.left; - return this.head.head.range.right.op == .unset and - left.op == .gte and - this.head.next == null and - this.head.head.next == null and - left.version.isZero() and - !this.flags.isSet(Flags.build); - } - - pub inline fn eql(lhs: Group, rhs: Group) bool { - return lhs.head.eql(&rhs.head); - } - - pub fn toVersion(this: Group) Version { - assert(this.isExact() or this.head.head.range.left.op == .unset); - return this.head.head.range.left.version; - } - - pub fn orVersion(self: *Group, version: Version) !void { - if (self.tail == null and !self.head.head.range.hasLeft()) { - self.head.head.range.left.version = version; - self.head.head.range.left.op = .eql; - return; - } - - var new_tail = try self.allocator.create(List); - new_tail.* = List{}; - new_tail.head.range.left.version = version; - new_tail.head.range.left.op = .eql; - - var prev_tail = self.tail orelse &self.head; - prev_tail.next = new_tail; - self.tail = new_tail; - } - - pub fn andRange(self: *Group, range: Range) !void { - var tail = self.tail orelse &self.head; - try tail.andRange(self.allocator, range); - } - - pub fn orRange(self: *Group, range: Range) !void { - if (self.tail == null and self.head.tail == null and !self.head.head.range.hasLeft()) { - self.head.head.range = range; - return; - } - - var new_tail = try self.allocator.create(List); - new_tail.* = List{}; - new_tail.head.range = range; - - var prev_tail = self.tail orelse &self.head; - prev_tail.next = new_tail; - self.tail = new_tail; - } - - pub inline fn satisfies( - group: *const Group, - version: Version, - group_buf: string, - version_buf: string, - ) bool { - return if (version.tag.hasPre()) - group.head.satisfiesPre(version, group_buf, version_buf) - else - group.head.satisfies(version, group_buf, version_buf); - } - }; - - pub fn eql(lhs: *const Query, rhs: *const Query) bool { - if (!lhs.range.eql(rhs.range)) return false; - - const lhs_next = lhs.next orelse return rhs.next == null; - const rhs_next = rhs.next orelse return false; - - return lhs_next.eql(rhs_next); - } - - pub fn satisfies(query: *const Query, version: Version, query_buf: string, version_buf: string) bool { - return query.range.satisfies( - version, - query_buf, - version_buf, - ) and (query.next orelse return true).satisfies( - version, - query_buf, - version_buf, - ); - } - - pub fn satisfiesPre(query: *const Query, version: Version, query_buf: string, version_buf: string, pre_matched: *bool) bool { - if (comptime Environment.allow_assert) { - assert(version.tag.hasPre()); - } - return query.range.satisfiesPre( - version, - query_buf, - version_buf, - pre_matched, - ) and (query.next orelse return true).satisfiesPre( - version, - query_buf, - version_buf, - pre_matched, - ); - } - - const Token = struct { - tag: Tag = Tag.none, - wildcard: Wildcard = Wildcard.none, - - pub fn toRange(this: Token, version: Version.Partial) Range { - switch (this.tag) { - // Allows changes that do not modify the left-most non-zero element in the [major, minor, patch] tuple - .caret => { - // https://github.com/npm/node-semver/blob/3a8a4309ae986c1967b3073ba88c9e69433d44cb/classes/range.js#L302-L353 - var range = Range{}; - if (version.major) |major| done: { - range.left = .{ - .op = .gte, - .version = .{ - .major = major, - }, - }; - range.right = .{ - .op = .lt, - }; - if (version.minor) |minor| { - range.left.version.minor = minor; - if (version.patch) |patch| { - range.left.version.patch = patch; - range.left.version.tag = version.tag; - if (major == 0) { - if (minor == 0) { - range.right.version.patch = patch +| 1; - } else { - range.right.version.minor = minor +| 1; - } - break :done; - } - } else if (major == 0) { - range.right.version.minor = minor +| 1; - break :done; - } - } - range.right.version.major = major +| 1; - } - return range; - }, - .tilda => { - // https://github.com/npm/node-semver/blob/3a8a4309ae986c1967b3073ba88c9e69433d44cb/classes/range.js#L261-L287 - var range = Range{}; - if (version.major) |major| done: { - range.left = .{ - .op = .gte, - .version = .{ - .major = major, - }, - }; - range.right = .{ - .op = .lt, - }; - if (version.minor) |minor| { - range.left.version.minor = minor; - if (version.patch) |patch| { - range.left.version.patch = patch; - range.left.version.tag = version.tag; - } - range.right.version.major = major; - range.right.version.minor = minor +| 1; - break :done; - } - range.right.version.major = major +| 1; - } - return range; - }, - .none => unreachable, - .version => { - if (this.wildcard != Wildcard.none) { - return Range.initWildcard(version.min(), this.wildcard); - } - - return .{ .left = .{ .op = .eql, .version = version.min() } }; - }, - else => {}, - } - - return switch (this.wildcard) { - .major => .{ - .left = .{ .op = .gte, .version = version.min() }, - .right = .{ - .op = .lte, - .version = .{ - .major = std.math.maxInt(u32), - .minor = std.math.maxInt(u32), - .patch = std.math.maxInt(u32), - }, - }, - }, - .minor => switch (this.tag) { - .lte => .{ - .left = .{ - .op = .lte, - .version = .{ - .major = version.major orelse 0, - .minor = std.math.maxInt(u32), - .patch = std.math.maxInt(u32), - }, - }, - }, - .lt => .{ - .left = .{ - .op = .lt, - .version = .{ - .major = version.major orelse 0, - .minor = 0, - .patch = 0, - }, - }, - }, - - .gt => .{ - .left = .{ - .op = .gt, - .version = .{ - .major = version.major orelse 0, - .minor = std.math.maxInt(u32), - .patch = std.math.maxInt(u32), - }, - }, - }, - - .gte => .{ - .left = .{ - .op = .gte, - .version = .{ - .major = version.major orelse 0, - .minor = 0, - .patch = 0, - }, - }, - }, - else => unreachable, - }, - .patch => switch (this.tag) { - .lte => .{ - .left = .{ - .op = .lte, - .version = .{ - .major = version.major orelse 0, - .minor = version.minor orelse 0, - .patch = std.math.maxInt(u32), - }, - }, - }, - .lt => .{ - .left = .{ - .op = .lt, - .version = .{ - .major = version.major orelse 0, - .minor = version.minor orelse 0, - .patch = 0, - }, - }, - }, - - .gt => .{ - .left = .{ - .op = .gt, - .version = .{ - .major = version.major orelse 0, - .minor = version.minor orelse 0, - .patch = std.math.maxInt(u32), - }, - }, - }, - - .gte => .{ - .left = .{ - .op = .gte, - .version = .{ - .major = version.major orelse 0, - .minor = version.minor orelse 0, - .patch = 0, - }, - }, - }, - else => unreachable, - }, - .none => .{ - .left = .{ - .op = switch (this.tag) { - .gt => .gt, - .gte => .gte, - .lt => .lt, - .lte => .lte, - else => unreachable, - }, - .version = version.min(), - }, - }, - }; - } - - pub const Tag = enum { - none, - gt, - gte, - lt, - lte, - version, - tilda, - caret, - }; - - pub const Wildcard = enum { - none, - major, - minor, - patch, - }; - }; - - pub fn parse( - allocator: Allocator, - input: string, - sliced: SlicedString, - ) bun.OOM!Group { - var i: usize = 0; - var list = Group{ - .allocator = allocator, - .input = input, - }; - - var token = Token{}; - var prev_token = Token{}; - - var count: u8 = 0; - var skip_round = false; - var is_or = false; - - while (i < input.len) { - skip_round = false; - - switch (input[i]) { - '>' => { - if (input.len > i + 1 and input[i + 1] == '=') { - token.tag = .gte; - i += 1; - } else { - token.tag = .gt; - } - - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - '<' => { - if (input.len > i + 1 and input[i + 1] == '=') { - token.tag = .lte; - i += 1; - } else { - token.tag = .lt; - } - - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - '=', 'v' => { - token.tag = .version; - is_or = true; - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - '~' => { - token.tag = .tilda; - i += 1; - - if (i < input.len and input[i] == '>') i += 1; - - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - '^' => { - token.tag = .caret; - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - '0'...'9', 'X', 'x', '*' => { - token.tag = .version; - is_or = true; - }, - '|' => { - i += 1; - - while (i < input.len and input[i] == '|') : (i += 1) {} - while (i < input.len and input[i] == ' ') : (i += 1) {} - is_or = true; - token.tag = Token.Tag.none; - skip_round = true; - }, - '-' => { - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - }, - ' ' => { - i += 1; - while (i < input.len and input[i] == ' ') : (i += 1) {} - skip_round = true; - }, - else => { - i += 1; - token.tag = Token.Tag.none; - - // skip tagged versions - // we are assuming this is the beginning of a tagged version like "boop" - // "1.0.0 || boop" - while (i < input.len and input[i] != ' ' and input[i] != '|') : (i += 1) {} - skip_round = true; - }, - } - - if (!skip_round) { - const parse_result = Version.parse(sliced.sub(input[i..])); - const version = parse_result.version.min(); - if (version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true); - if (version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true); - - token.wildcard = parse_result.wildcard; - - i += parse_result.len; - const rollback = i; - - const maybe_hyphenate = i < input.len and (input[i] == ' ' or input[i] == '-'); - - // TODO: can we do this without rolling back? - const hyphenate: bool = maybe_hyphenate and possibly_hyphenate: { - i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); - if (!(i < input.len and input[i] == '-')) break :possibly_hyphenate false; - i += 1; - i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); - if (i == input.len) break :possibly_hyphenate false; - if (input[i] == 'v' or input[i] == '=') { - i += 1; - } - if (i == input.len) break :possibly_hyphenate false; - i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); - if (i == input.len) break :possibly_hyphenate false; - - if (!(i < input.len and switch (input[i]) { - '0'...'9', 'X', 'x', '*' => true, - else => false, - })) break :possibly_hyphenate false; - - break :possibly_hyphenate true; - }; - - if (!hyphenate) i = rollback; - i += @as(usize, @intFromBool(!hyphenate)); - - if (hyphenate) { - const second_parsed = Version.parse(sliced.sub(input[i..])); - var second_version = second_parsed.version.min(); - if (second_version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true); - if (second_version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true); - const range: Range = brk: { - switch (second_parsed.wildcard) { - .major => { - // "1.0.0 - x" --> ">=1.0.0" - break :brk Range{ - .left = .{ .op = .gte, .version = version }, - }; - }, - .minor => { - // "1.0.0 - 1.x" --> ">=1.0.0 < 2.0.0" - second_version.major +|= 1; - second_version.minor = 0; - second_version.patch = 0; - - break :brk Range{ - .left = .{ .op = .gte, .version = version }, - .right = .{ .op = .lt, .version = second_version }, - }; - }, - .patch => { - // "1.0.0 - 1.0.x" --> ">=1.0.0 <1.1.0" - second_version.minor +|= 1; - second_version.patch = 0; - - break :brk Range{ - .left = .{ .op = .gte, .version = version }, - .right = .{ .op = .lt, .version = second_version }, - }; - }, - .none => { - break :brk Range{ - .left = .{ .op = .gte, .version = version }, - .right = .{ .op = .lte, .version = second_version }, - }; - }, - } - }; - - if (is_or) { - try list.orRange(range); - } else { - try list.andRange(range); - } - - i += second_parsed.len + 1; - } else if (count == 0 and token.tag == .version) { - switch (parse_result.wildcard) { - .none => { - try list.orVersion(version); - }, - else => { - try list.orRange(token.toRange(parse_result.version)); - }, - } - } else if (count == 0) { - // From a semver perspective, treat "--foo" the same as "-foo" - // example: foo/bar@1.2.3@--canary.24 - // ^ - if (token.tag == .none) { - is_or = false; - token.wildcard = .none; - prev_token.tag = .none; - continue; - } - try list.andRange(token.toRange(parse_result.version)); - } else if (is_or) { - try list.orRange(token.toRange(parse_result.version)); - } else { - try list.andRange(token.toRange(parse_result.version)); - } - - is_or = false; - count += 1; - token.wildcard = .none; - prev_token.tag = token.tag; - } - } - - return list; - } -}; - -pub const SemverObject = struct { - pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue { - const object = JSC.JSValue.createEmptyObject(globalThis, 2); - - object.put( - globalThis, - JSC.ZigString.static("satisfies"), - JSC.NewFunction( - globalThis, - JSC.ZigString.static("satisfies"), - 2, - SemverObject.satisfies, - false, - ), - ); - - object.put( - globalThis, - JSC.ZigString.static("order"), - JSC.NewFunction( - globalThis, - JSC.ZigString.static("order"), - 2, - SemverObject.order, - false, - ), - ); - - return object; - } - - pub fn order( - globalThis: *JSC.JSGlobalObject, - callFrame: *JSC.CallFrame, - ) bun.JSError!JSC.JSValue { - var arena = std.heap.ArenaAllocator.init(bun.default_allocator); - defer arena.deinit(); - var stack_fallback = std.heap.stackFallback(512, arena.allocator()); - const allocator = stack_fallback.get(); - - const arguments = callFrame.arguments_old(2).slice(); - if (arguments.len < 2) { - return globalThis.throw("Expected two arguments", .{}); - } - - const left_arg = arguments[0]; - const right_arg = arguments[1]; - - const left_string = left_arg.toStringOrNull(globalThis) orelse return JSC.jsNumber(0); - const right_string = right_arg.toStringOrNull(globalThis) orelse return JSC.jsNumber(0); - - const left = left_string.toSlice(globalThis, allocator); - defer left.deinit(); - const right = right_string.toSlice(globalThis, allocator); - defer right.deinit(); - - if (!strings.isAllASCII(left.slice())) return JSC.jsNumber(0); - if (!strings.isAllASCII(right.slice())) return JSC.jsNumber(0); - - const left_result = Version.parse(SlicedString.init(left.slice(), left.slice())); - const right_result = Version.parse(SlicedString.init(right.slice(), right.slice())); - - if (!left_result.valid) { - return globalThis.throw("Invalid SemVer: {s}\n", .{left.slice()}); - } - - if (!right_result.valid) { - return globalThis.throw("Invalid SemVer: {s}\n", .{right.slice()}); - } - - const left_version = left_result.version.max(); - const right_version = right_result.version.max(); - - return switch (left_version.orderWithoutBuild(right_version, left.slice(), right.slice())) { - .eq => JSC.jsNumber(0), - .gt => JSC.jsNumber(1), - .lt => JSC.jsNumber(-1), - }; - } - - pub fn satisfies(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue { - var arena = std.heap.ArenaAllocator.init(bun.default_allocator); - defer arena.deinit(); - var stack_fallback = std.heap.stackFallback(512, arena.allocator()); - const allocator = stack_fallback.get(); - - const arguments = callFrame.arguments_old(2).slice(); - if (arguments.len < 2) { - return globalThis.throw("Expected two arguments", .{}); - } - - const left_arg = arguments[0]; - const right_arg = arguments[1]; - - const left_string = left_arg.toStringOrNull(globalThis) orelse return .zero; - const right_string = right_arg.toStringOrNull(globalThis) orelse return .zero; - - const left = left_string.toSlice(globalThis, allocator); - defer left.deinit(); - const right = right_string.toSlice(globalThis, allocator); - defer right.deinit(); - - if (!strings.isAllASCII(left.slice())) return .false; - if (!strings.isAllASCII(right.slice())) return .false; - - const left_result = Version.parse(SlicedString.init(left.slice(), left.slice())); - if (left_result.wildcard != .none) { - return .false; - } - - const left_version = left_result.version.min(); - - const right_group = try Query.parse( - allocator, - right.slice(), - SlicedString.init(right.slice(), right.slice()), - ); - defer right_group.deinit(); - - const right_version = right_group.getExactVersion(); - - if (right_version != null) { - return JSC.jsBoolean(left_version.eql(right_version.?)); - } - - return JSC.jsBoolean(right_group.satisfies(left_version, right.slice(), left.slice())); - } -}; - -const assert = bun.assert; diff --git a/src/install/versioned_url.zig b/src/install/versioned_url.zig index ac31f98ece1521..917c03ee303723 100644 --- a/src/install/versioned_url.zig +++ b/src/install/versioned_url.zig @@ -1,5 +1,6 @@ -const Semver = @import("./semver.zig"); -const String = @import("./semver.zig").String; +const bun = @import("root").bun; +const Semver = bun.Semver; +const String = Semver.String; pub const VersionedURL = extern struct { url: String, diff --git a/src/resolver/package_json.zig b/src/resolver/package_json.zig index 21860d42a3b8d3..06a41db4a50452 100644 --- a/src/resolver/package_json.zig +++ b/src/resolver/package_json.zig @@ -28,9 +28,9 @@ pub const MacroImportReplacementMap = bun.StringArrayHashMap(string); pub const MacroMap = bun.StringArrayHashMapUnmanaged(MacroImportReplacementMap); const ScriptsMap = bun.StringArrayHashMap(string); -const Semver = @import("../install/semver.zig"); +const Semver = bun.Semver; const Dependency = @import("../install/dependency.zig"); -const String = @import("../install/semver.zig").String; +const String = Semver.String; const Version = Semver.Version; const Install = @import("../install/install.zig"); const FolderResolver = @import("../install/resolvers/folder_resolver.zig"); diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index fd87fd9a82d782..b714d33ace181c 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -43,7 +43,7 @@ const Install = @import("../install/install.zig"); const Lockfile = @import("../install/lockfile.zig").Lockfile; const Package = @import("../install/lockfile.zig").Package; const Resolution = @import("../install/resolution.zig").Resolution; -const Semver = @import("../install/semver.zig"); +const Semver = bun.Semver; const DotEnv = @import("../env_loader.zig"); pub fn isPackagePath(path: string) bool { diff --git a/src/semver.zig b/src/semver.zig new file mode 100644 index 00000000000000..43b85e34072eee --- /dev/null +++ b/src/semver.zig @@ -0,0 +1,9 @@ +// These are all extern so they can't be top-level structs. +pub const String = @import("./semver/SemverString.zig").String; +pub const ExternalString = @import("./semver/ExternalString.zig").ExternalString; +pub const Version = @import("./semver/Version.zig").Version; + +pub const SlicedString = @import("./semver/SlicedString.zig"); +pub const Range = @import("./semver/SemverRange.zig"); +pub const Query = @import("./semver/SemverQuery.zig"); +pub const SemverObject = @import("./semver/SemverObject.zig"); diff --git a/src/semver/ExternalString.zig b/src/semver/ExternalString.zig new file mode 100644 index 00000000000000..a389a401dcb963 --- /dev/null +++ b/src/semver/ExternalString.zig @@ -0,0 +1,66 @@ +pub const ExternalString = extern struct { + value: String = String{}, + hash: u64 = 0, + + pub inline fn fmt(this: *const ExternalString, buf: []const u8) String.Formatter { + return this.value.fmt(buf); + } + + pub fn order(lhs: *const ExternalString, rhs: *const ExternalString, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order { + if (lhs.hash == rhs.hash and lhs.hash > 0) return .eq; + + return lhs.value.order(&rhs.value, lhs_buf, rhs_buf); + } + + /// ExternalString but without the hash + pub inline fn from(in: string) ExternalString { + return ExternalString{ + .value = String.init(in, in), + .hash = bun.Wyhash.hash(0, in), + }; + } + + pub inline fn isInline(this: ExternalString) bool { + return this.value.isInline(); + } + + pub inline fn isEmpty(this: ExternalString) bool { + return this.value.isEmpty(); + } + + pub inline fn len(this: ExternalString) usize { + return this.value.len(); + } + + pub inline fn init(buf: string, in: string, hash: u64) ExternalString { + return ExternalString{ + .value = String.init(buf, in), + .hash = hash, + }; + } + + pub inline fn slice(this: *const ExternalString, buf: string) string { + return this.value.slice(buf); + } +}; + +const assert = bun.assert; +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = bun.IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const SlicedString = bun.Semver.SlicedString; +const String = bun.Semver.String; diff --git a/src/semver/SemverObject.zig b/src/semver/SemverObject.zig new file mode 100644 index 00000000000000..6c0ccf6dbb18c5 --- /dev/null +++ b/src/semver/SemverObject.zig @@ -0,0 +1,152 @@ +pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue { + const object = JSC.JSValue.createEmptyObject(globalThis, 2); + + object.put( + globalThis, + JSC.ZigString.static("satisfies"), + JSC.NewFunction( + globalThis, + JSC.ZigString.static("satisfies"), + 2, + SemverObject.satisfies, + false, + ), + ); + + object.put( + globalThis, + JSC.ZigString.static("order"), + JSC.NewFunction( + globalThis, + JSC.ZigString.static("order"), + 2, + SemverObject.order, + false, + ), + ); + + return object; +} + +pub fn order( + globalThis: *JSC.JSGlobalObject, + callFrame: *JSC.CallFrame, +) bun.JSError!JSC.JSValue { + var arena = std.heap.ArenaAllocator.init(bun.default_allocator); + defer arena.deinit(); + var stack_fallback = std.heap.stackFallback(512, arena.allocator()); + const allocator = stack_fallback.get(); + + const arguments = callFrame.arguments_old(2).slice(); + if (arguments.len < 2) { + return globalThis.throw("Expected two arguments", .{}); + } + + const left_arg = arguments[0]; + const right_arg = arguments[1]; + + const left_string = left_arg.toStringOrNull(globalThis) orelse return JSC.jsNumber(0); + const right_string = right_arg.toStringOrNull(globalThis) orelse return JSC.jsNumber(0); + + const left = left_string.toSlice(globalThis, allocator); + defer left.deinit(); + const right = right_string.toSlice(globalThis, allocator); + defer right.deinit(); + + if (!strings.isAllASCII(left.slice())) return JSC.jsNumber(0); + if (!strings.isAllASCII(right.slice())) return JSC.jsNumber(0); + + const left_result = Version.parse(SlicedString.init(left.slice(), left.slice())); + const right_result = Version.parse(SlicedString.init(right.slice(), right.slice())); + + if (!left_result.valid) { + return globalThis.throw("Invalid SemVer: {s}\n", .{left.slice()}); + } + + if (!right_result.valid) { + return globalThis.throw("Invalid SemVer: {s}\n", .{right.slice()}); + } + + const left_version = left_result.version.max(); + const right_version = right_result.version.max(); + + return switch (left_version.orderWithoutBuild(right_version, left.slice(), right.slice())) { + .eq => JSC.jsNumber(0), + .gt => JSC.jsNumber(1), + .lt => JSC.jsNumber(-1), + }; +} + +pub fn satisfies(globalThis: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue { + var arena = std.heap.ArenaAllocator.init(bun.default_allocator); + defer arena.deinit(); + var stack_fallback = std.heap.stackFallback(512, arena.allocator()); + const allocator = stack_fallback.get(); + + const arguments = callFrame.arguments_old(2).slice(); + if (arguments.len < 2) { + return globalThis.throw("Expected two arguments", .{}); + } + + const left_arg = arguments[0]; + const right_arg = arguments[1]; + + const left_string = left_arg.toStringOrNull(globalThis) orelse return .zero; + const right_string = right_arg.toStringOrNull(globalThis) orelse return .zero; + + const left = left_string.toSlice(globalThis, allocator); + defer left.deinit(); + const right = right_string.toSlice(globalThis, allocator); + defer right.deinit(); + + if (!strings.isAllASCII(left.slice())) return .false; + if (!strings.isAllASCII(right.slice())) return .false; + + const left_result = Version.parse(SlicedString.init(left.slice(), left.slice())); + if (left_result.wildcard != .none) { + return .false; + } + + const left_version = left_result.version.min(); + + const right_group = try Query.parse( + allocator, + right.slice(), + SlicedString.init(right.slice(), right.slice()), + ); + defer right_group.deinit(); + + const right_version = right_group.getExactVersion(); + + if (right_version != null) { + return JSC.jsBoolean(left_version.eql(right_version.?)); + } + + return JSC.jsBoolean(right_group.satisfies(left_version, right.slice(), left.slice())); +} + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = @import("../identity_context.zig").IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const SlicedString = bun.Semver.SlicedString; +const String = bun.Semver.String; + +const Query = bun.Semver.Query; +const assert = bun.assert; +const Version = bun.Semver.Version; +const SemverObject = @This(); diff --git a/src/semver/SemverQuery.zig b/src/semver/SemverQuery.zig new file mode 100644 index 00000000000000..55a7772578cabd --- /dev/null +++ b/src/semver/SemverQuery.zig @@ -0,0 +1,801 @@ +/// Linked-list of AND ranges +/// "^1 ^2" +/// ----|----- +/// That is two Query +pub const Op = enum { + none, + AND, + OR, +}; + +range: Range = Range{}, + +// AND +next: ?*Query = null, + +const Formatter = struct { + query: *const Query, + buffer: []const u8, + pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const this = formatter.query; + + if (this.next) |ptr| { + if (ptr.range.hasLeft() or ptr.range.hasRight()) { + try std.fmt.format(writer, "{} && {}", .{ this.range.fmt(formatter.buffer), ptr.range.fmt(formatter.buffer) }); + return; + } + } + + try std.fmt.format(writer, "{}", .{this.range.fmt(formatter.buffer)}); + } +}; + +pub fn fmt(this: *const Query, buf: []const u8) @This().Formatter { + return .{ .query = this, .buffer = buf }; +} + +/// Linked-list of Queries OR'd together +/// "^1 || ^2" +/// ----|----- +/// That is two List +pub const List = struct { + head: Query = Query{}, + tail: ?*Query = null, + + // OR + next: ?*List = null, + + const Formatter = struct { + list: *const List, + buffer: []const u8, + pub fn format(formatter: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const this = formatter.list; + + if (this.next) |ptr| { + try std.fmt.format(writer, "{} || {}", .{ this.head.fmt(formatter.buffer), ptr.fmt(formatter.buffer) }); + } else { + try std.fmt.format(writer, "{}", .{this.head.fmt(formatter.buffer)}); + } + } + }; + + pub fn fmt(this: *const List, buf: []const u8) @This().Formatter { + return .{ .list = this, .buffer = buf }; + } + + pub fn satisfies(list: *const List, version: Version, list_buf: string, version_buf: string) bool { + return list.head.satisfies( + version, + list_buf, + version_buf, + ) or (list.next orelse return false).satisfies( + version, + list_buf, + version_buf, + ); + } + + pub fn satisfiesPre(list: *const List, version: Version, list_buf: string, version_buf: string) bool { + if (comptime Environment.allow_assert) { + assert(version.tag.hasPre()); + } + + // `version` has a prerelease tag: + // - needs to satisfy each comparator in the query ( AND AND ...) like normal comparison + // - if it does, also needs to match major, minor, patch with at least one of the other versions + // with a prerelease + // https://github.com/npm/node-semver/blob/ac9b35769ab0ddfefd5a3af4a3ecaf3da2012352/classes/range.js#L505 + var pre_matched = false; + return (list.head.satisfiesPre( + version, + list_buf, + version_buf, + &pre_matched, + ) and pre_matched) or (list.next orelse return false).satisfiesPre( + version, + list_buf, + version_buf, + ); + } + + pub fn eql(lhs: *const List, rhs: *const List) bool { + if (!lhs.head.eql(&rhs.head)) return false; + + const lhs_next = lhs.next orelse return rhs.next == null; + const rhs_next = rhs.next orelse return false; + + return lhs_next.eql(rhs_next); + } + + pub fn andRange(self: *List, allocator: Allocator, range: Range) !void { + if (!self.head.range.hasLeft() and !self.head.range.hasRight()) { + self.head.range = range; + return; + } + + var tail = try allocator.create(Query); + tail.* = Query{ + .range = range, + }; + tail.range = range; + + var last_tail = self.tail orelse &self.head; + last_tail.next = tail; + self.tail = tail; + } +}; + +pub const Group = struct { + head: List = List{}, + tail: ?*List = null, + allocator: Allocator, + input: string = "", + + flags: FlagsBitSet = FlagsBitSet.initEmpty(), + pub const Flags = struct { + pub const pre = 1; + pub const build = 0; + }; + + const Formatter = struct { + group: *const Group, + buf: string, + + pub fn format(formatter: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const this = formatter.group; + + if (this.tail == null and this.head.tail == null and !this.head.head.range.hasLeft()) { + return; + } + + if (this.tail == null and this.head.tail == null) { + try std.fmt.format(writer, "{}", .{this.head.fmt(formatter.buf)}); + return; + } + + var list = &this.head; + while (list.next) |next| { + try std.fmt.format(writer, "{} && ", .{list.fmt(formatter.buf)}); + list = next; + } + + try std.fmt.format(writer, "{}", .{list.fmt(formatter.buf)}); + } + }; + + pub fn fmt(this: *const Group, buf: string) @This().Formatter { + return .{ + .group = this, + .buf = buf, + }; + } + + pub fn jsonStringify(this: *const Group, writer: anytype) !void { + const temp = try std.fmt.allocPrint(bun.default_allocator, "{}", .{this.fmt()}); + defer bun.default_allocator.free(temp); + try std.json.encodeJsonString(temp, .{}, writer); + } + + pub fn deinit(this: *const Group) void { + var list = this.head; + var allocator = this.allocator; + + while (list.next) |next| { + var query = list.head; + while (query.next) |next_query| { + query = next_query.*; + allocator.destroy(next_query); + } + list = next.*; + allocator.destroy(next); + } + } + + pub fn getExactVersion(this: *const Group) ?Version { + const range = this.head.head.range; + if (this.head.next == null and + this.head.head.next == null and + range.hasLeft() and + range.left.op == .eql and + !range.hasRight()) + { + if (comptime Environment.allow_assert) { + assert(this.tail == null); + } + return range.left.version; + } + + return null; + } + + pub fn from(version: Version) Group { + return .{ + .allocator = bun.default_allocator, + .head = .{ + .head = .{ + .range = .{ + .left = .{ + .op = .eql, + .version = version, + }, + }, + }, + }, + }; + } + + pub const FlagsBitSet = bun.bit_set.IntegerBitSet(3); + + pub fn isExact(this: *const Group) bool { + return this.head.next == null and this.head.head.next == null and !this.head.head.range.hasRight() and this.head.head.range.left.op == .eql; + } + + pub fn @"is *"(this: *const Group) bool { + const left = this.head.head.range.left; + return this.head.head.range.right.op == .unset and + left.op == .gte and + this.head.next == null and + this.head.head.next == null and + left.version.isZero() and + !this.flags.isSet(Flags.build); + } + + pub inline fn eql(lhs: Group, rhs: Group) bool { + return lhs.head.eql(&rhs.head); + } + + pub fn toVersion(this: Group) Version { + assert(this.isExact() or this.head.head.range.left.op == .unset); + return this.head.head.range.left.version; + } + + pub fn orVersion(self: *Group, version: Version) !void { + if (self.tail == null and !self.head.head.range.hasLeft()) { + self.head.head.range.left.version = version; + self.head.head.range.left.op = .eql; + return; + } + + var new_tail = try self.allocator.create(List); + new_tail.* = List{}; + new_tail.head.range.left.version = version; + new_tail.head.range.left.op = .eql; + + var prev_tail = self.tail orelse &self.head; + prev_tail.next = new_tail; + self.tail = new_tail; + } + + pub fn andRange(self: *Group, range: Range) !void { + var tail = self.tail orelse &self.head; + try tail.andRange(self.allocator, range); + } + + pub fn orRange(self: *Group, range: Range) !void { + if (self.tail == null and self.head.tail == null and !self.head.head.range.hasLeft()) { + self.head.head.range = range; + return; + } + + var new_tail = try self.allocator.create(List); + new_tail.* = List{}; + new_tail.head.range = range; + + var prev_tail = self.tail orelse &self.head; + prev_tail.next = new_tail; + self.tail = new_tail; + } + + pub inline fn satisfies( + group: *const Group, + version: Version, + group_buf: string, + version_buf: string, + ) bool { + return if (version.tag.hasPre()) + group.head.satisfiesPre(version, group_buf, version_buf) + else + group.head.satisfies(version, group_buf, version_buf); + } +}; + +pub fn eql(lhs: *const Query, rhs: *const Query) bool { + if (!lhs.range.eql(rhs.range)) return false; + + const lhs_next = lhs.next orelse return rhs.next == null; + const rhs_next = rhs.next orelse return false; + + return lhs_next.eql(rhs_next); +} + +pub fn satisfies(query: *const Query, version: Version, query_buf: string, version_buf: string) bool { + return query.range.satisfies( + version, + query_buf, + version_buf, + ) and (query.next orelse return true).satisfies( + version, + query_buf, + version_buf, + ); +} + +pub fn satisfiesPre(query: *const Query, version: Version, query_buf: string, version_buf: string, pre_matched: *bool) bool { + if (comptime Environment.allow_assert) { + assert(version.tag.hasPre()); + } + return query.range.satisfiesPre( + version, + query_buf, + version_buf, + pre_matched, + ) and (query.next orelse return true).satisfiesPre( + version, + query_buf, + version_buf, + pre_matched, + ); +} + +pub const Token = struct { + tag: Tag = Tag.none, + wildcard: Wildcard = Wildcard.none, + + pub fn toRange(this: Token, version: Version.Partial) Range { + switch (this.tag) { + // Allows changes that do not modify the left-most non-zero element in the [major, minor, patch] tuple + .caret => { + // https://github.com/npm/node-semver/blob/3a8a4309ae986c1967b3073ba88c9e69433d44cb/classes/range.js#L302-L353 + var range = Range{}; + if (version.major) |major| done: { + range.left = .{ + .op = .gte, + .version = .{ + .major = major, + }, + }; + range.right = .{ + .op = .lt, + }; + if (version.minor) |minor| { + range.left.version.minor = minor; + if (version.patch) |patch| { + range.left.version.patch = patch; + range.left.version.tag = version.tag; + if (major == 0) { + if (minor == 0) { + range.right.version.patch = patch +| 1; + } else { + range.right.version.minor = minor +| 1; + } + break :done; + } + } else if (major == 0) { + range.right.version.minor = minor +| 1; + break :done; + } + } + range.right.version.major = major +| 1; + } + return range; + }, + .tilda => { + // https://github.com/npm/node-semver/blob/3a8a4309ae986c1967b3073ba88c9e69433d44cb/classes/range.js#L261-L287 + var range = Range{}; + if (version.major) |major| done: { + range.left = .{ + .op = .gte, + .version = .{ + .major = major, + }, + }; + range.right = .{ + .op = .lt, + }; + if (version.minor) |minor| { + range.left.version.minor = minor; + if (version.patch) |patch| { + range.left.version.patch = patch; + range.left.version.tag = version.tag; + } + range.right.version.major = major; + range.right.version.minor = minor +| 1; + break :done; + } + range.right.version.major = major +| 1; + } + return range; + }, + .none => unreachable, + .version => { + if (this.wildcard != Wildcard.none) { + return Range.initWildcard(version.min(), this.wildcard); + } + + return .{ .left = .{ .op = .eql, .version = version.min() } }; + }, + else => {}, + } + + return switch (this.wildcard) { + .major => .{ + .left = .{ .op = .gte, .version = version.min() }, + .right = .{ + .op = .lte, + .version = .{ + .major = std.math.maxInt(u32), + .minor = std.math.maxInt(u32), + .patch = std.math.maxInt(u32), + }, + }, + }, + .minor => switch (this.tag) { + .lte => .{ + .left = .{ + .op = .lte, + .version = .{ + .major = version.major orelse 0, + .minor = std.math.maxInt(u32), + .patch = std.math.maxInt(u32), + }, + }, + }, + .lt => .{ + .left = .{ + .op = .lt, + .version = .{ + .major = version.major orelse 0, + .minor = 0, + .patch = 0, + }, + }, + }, + + .gt => .{ + .left = .{ + .op = .gt, + .version = .{ + .major = version.major orelse 0, + .minor = std.math.maxInt(u32), + .patch = std.math.maxInt(u32), + }, + }, + }, + + .gte => .{ + .left = .{ + .op = .gte, + .version = .{ + .major = version.major orelse 0, + .minor = 0, + .patch = 0, + }, + }, + }, + else => unreachable, + }, + .patch => switch (this.tag) { + .lte => .{ + .left = .{ + .op = .lte, + .version = .{ + .major = version.major orelse 0, + .minor = version.minor orelse 0, + .patch = std.math.maxInt(u32), + }, + }, + }, + .lt => .{ + .left = .{ + .op = .lt, + .version = .{ + .major = version.major orelse 0, + .minor = version.minor orelse 0, + .patch = 0, + }, + }, + }, + + .gt => .{ + .left = .{ + .op = .gt, + .version = .{ + .major = version.major orelse 0, + .minor = version.minor orelse 0, + .patch = std.math.maxInt(u32), + }, + }, + }, + + .gte => .{ + .left = .{ + .op = .gte, + .version = .{ + .major = version.major orelse 0, + .minor = version.minor orelse 0, + .patch = 0, + }, + }, + }, + else => unreachable, + }, + .none => .{ + .left = .{ + .op = switch (this.tag) { + .gt => .gt, + .gte => .gte, + .lt => .lt, + .lte => .lte, + else => unreachable, + }, + .version = version.min(), + }, + }, + }; + } + + pub const Tag = enum { + none, + gt, + gte, + lt, + lte, + version, + tilda, + caret, + }; + + pub const Wildcard = enum { + none, + major, + minor, + patch, + }; +}; + +pub fn parse( + allocator: Allocator, + input: string, + sliced: SlicedString, +) bun.OOM!Group { + var i: usize = 0; + var list = Group{ + .allocator = allocator, + .input = input, + }; + + var token = Token{}; + var prev_token = Token{}; + + var count: u8 = 0; + var skip_round = false; + var is_or = false; + + while (i < input.len) { + skip_round = false; + + switch (input[i]) { + '>' => { + if (input.len > i + 1 and input[i + 1] == '=') { + token.tag = .gte; + i += 1; + } else { + token.tag = .gt; + } + + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + '<' => { + if (input.len > i + 1 and input[i + 1] == '=') { + token.tag = .lte; + i += 1; + } else { + token.tag = .lt; + } + + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + '=', 'v' => { + token.tag = .version; + is_or = true; + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + '~' => { + token.tag = .tilda; + i += 1; + + if (i < input.len and input[i] == '>') i += 1; + + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + '^' => { + token.tag = .caret; + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + '0'...'9', 'X', 'x', '*' => { + token.tag = .version; + is_or = true; + }, + '|' => { + i += 1; + + while (i < input.len and input[i] == '|') : (i += 1) {} + while (i < input.len and input[i] == ' ') : (i += 1) {} + is_or = true; + token.tag = Token.Tag.none; + skip_round = true; + }, + '-' => { + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + }, + ' ' => { + i += 1; + while (i < input.len and input[i] == ' ') : (i += 1) {} + skip_round = true; + }, + else => { + i += 1; + token.tag = Token.Tag.none; + + // skip tagged versions + // we are assuming this is the beginning of a tagged version like "boop" + // "1.0.0 || boop" + while (i < input.len and input[i] != ' ' and input[i] != '|') : (i += 1) {} + skip_round = true; + }, + } + + if (!skip_round) { + const parse_result = Version.parse(sliced.sub(input[i..])); + const version = parse_result.version.min(); + if (version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true); + if (version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true); + + token.wildcard = parse_result.wildcard; + + i += parse_result.len; + const rollback = i; + + const maybe_hyphenate = i < input.len and (input[i] == ' ' or input[i] == '-'); + + // TODO: can we do this without rolling back? + const hyphenate: bool = maybe_hyphenate and possibly_hyphenate: { + i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); + if (!(i < input.len and input[i] == '-')) break :possibly_hyphenate false; + i += 1; + i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); + if (i == input.len) break :possibly_hyphenate false; + if (input[i] == 'v' or input[i] == '=') { + i += 1; + } + if (i == input.len) break :possibly_hyphenate false; + i += strings.lengthOfLeadingWhitespaceASCII(input[i..]); + if (i == input.len) break :possibly_hyphenate false; + + if (!(i < input.len and switch (input[i]) { + '0'...'9', 'X', 'x', '*' => true, + else => false, + })) break :possibly_hyphenate false; + + break :possibly_hyphenate true; + }; + + if (!hyphenate) i = rollback; + i += @as(usize, @intFromBool(!hyphenate)); + + if (hyphenate) { + const second_parsed = Version.parse(sliced.sub(input[i..])); + var second_version = second_parsed.version.min(); + if (second_version.tag.hasBuild()) list.flags.setValue(Group.Flags.build, true); + if (second_version.tag.hasPre()) list.flags.setValue(Group.Flags.pre, true); + const range: Range = brk: { + switch (second_parsed.wildcard) { + .major => { + // "1.0.0 - x" --> ">=1.0.0" + break :brk Range{ + .left = .{ .op = .gte, .version = version }, + }; + }, + .minor => { + // "1.0.0 - 1.x" --> ">=1.0.0 < 2.0.0" + second_version.major +|= 1; + second_version.minor = 0; + second_version.patch = 0; + + break :brk Range{ + .left = .{ .op = .gte, .version = version }, + .right = .{ .op = .lt, .version = second_version }, + }; + }, + .patch => { + // "1.0.0 - 1.0.x" --> ">=1.0.0 <1.1.0" + second_version.minor +|= 1; + second_version.patch = 0; + + break :brk Range{ + .left = .{ .op = .gte, .version = version }, + .right = .{ .op = .lt, .version = second_version }, + }; + }, + .none => { + break :brk Range{ + .left = .{ .op = .gte, .version = version }, + .right = .{ .op = .lte, .version = second_version }, + }; + }, + } + }; + + if (is_or) { + try list.orRange(range); + } else { + try list.andRange(range); + } + + i += second_parsed.len + 1; + } else if (count == 0 and token.tag == .version) { + switch (parse_result.wildcard) { + .none => { + try list.orVersion(version); + }, + else => { + try list.orRange(token.toRange(parse_result.version)); + }, + } + } else if (count == 0) { + // From a semver perspective, treat "--foo" the same as "-foo" + // example: foo/bar@1.2.3@--canary.24 + // ^ + if (token.tag == .none) { + is_or = false; + token.wildcard = .none; + prev_token.tag = .none; + continue; + } + try list.andRange(token.toRange(parse_result.version)); + } else if (is_or) { + try list.orRange(token.toRange(parse_result.version)); + } else { + try list.andRange(token.toRange(parse_result.version)); + } + + is_or = false; + count += 1; + token.wildcard = .none; + prev_token.tag = token.tag; + } + } + + return list; +} + +const Query = @This(); + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = @import("../identity_context.zig").IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const SlicedString = bun.Semver.SlicedString; +const String = bun.Semver.String; +const Version = bun.Semver.Version; +const Range = bun.Semver.Range; +const assert = bun.assert; diff --git a/src/semver/SemverRange.zig b/src/semver/SemverRange.zig new file mode 100644 index 00000000000000..ccc0f4ec5056d1 --- /dev/null +++ b/src/semver/SemverRange.zig @@ -0,0 +1,273 @@ +pub const Op = enum(u8) { + unset = 0, + eql = 1, + lt = 3, + lte = 4, + gt = 5, + gte = 6, +}; + +left: Comparator = .{}, +right: Comparator = .{}, + +pub fn format(this: Range, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + if (this.left.op == .unset and this.right.op == .unset) { + return; + } + + if (this.right.op == .unset) { + try std.fmt.format(writer, "{}", .{this.left}); + } else { + try std.fmt.format(writer, "{} {}", .{ this.left, this.right }); + } +} + +/// * +/// >= 0.0.0 +/// >= 0 +/// >= 0.0 +/// >= x +/// >= 0 +pub fn anyRangeSatisfies(this: *const Range) bool { + return this.left.op == .gte and this.left.version.eql(.{}); +} + +pub fn initWildcard(version: Version, wildcard: Query.Token.Wildcard) Range { + switch (wildcard) { + .none => { + return .{ + .left = .{ + .op = Op.eql, + .version = version, + }, + }; + }, + + .major => { + return .{ + .left = .{ + .op = Op.gte, + .version = .{ + // .raw = version.raw + }, + }, + }; + }, + .minor => { + const lhs = Version{ + .major = version.major +| 1, + // .raw = version.raw + }; + const rhs = Version{ + .major = version.major, + // .raw = version.raw + }; + return .{ + .left = .{ + .op = Op.lt, + .version = lhs, + }, + .right = .{ + .op = Op.gte, + .version = rhs, + }, + }; + }, + .patch => { + const lhs = Version{ + .major = version.major, + .minor = version.minor +| 1, + // .raw = version.raw; + }; + const rhs = Version{ + .major = version.major, + .minor = version.minor, + // .raw = version.raw; + }; + return Range{ + .left = .{ + .op = Op.lt, + .version = lhs, + }, + .right = .{ + .op = Op.gte, + .version = rhs, + }, + }; + }, + } +} + +pub inline fn hasLeft(this: Range) bool { + return this.left.op != Op.unset; +} + +pub inline fn hasRight(this: Range) bool { + return this.right.op != Op.unset; +} + +/// Is the Range equal to another Range +/// This does not evaluate the range. +pub inline fn eql(lhs: Range, rhs: Range) bool { + return lhs.left.eql(rhs.left) and lhs.right.eql(rhs.right); +} + +pub const Formatter = struct { + buffer: []const u8, + range: *const Range, + + pub fn format(this: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + if (this.range.left.op == Op.unset and this.range.right.op == Op.unset) { + return; + } + + if (this.range.right.op == .unset) { + try std.fmt.format(writer, "{}", .{this.range.left.fmt(this.buffer)}); + } else { + try std.fmt.format(writer, "{} {}", .{ this.range.left.fmt(this.buffer), this.range.right.fmt(this.buffer) }); + } + } +}; + +pub fn fmt(this: *const Range, buf: []const u8) @This().Formatter { + return .{ .buffer = buf, .range = this }; +} + +pub const Comparator = struct { + op: Op = .unset, + version: Version = .{}, + + pub inline fn eql(lhs: Comparator, rhs: Comparator) bool { + return lhs.op == rhs.op and lhs.version.eql(rhs.version); + } + + pub const Formatter = struct { + buffer: []const u8, + comparator: *const Comparator, + + pub fn format(this: @This(), comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + if (this.comparator.op == Op.unset) { + return; + } + + switch (this.comparator.op) { + .unset => unreachable, // see above, + .eql => try writer.writeAll("=="), + .lt => try writer.writeAll("<"), + .lte => try writer.writeAll("<="), + .gt => try writer.writeAll(">"), + .gte => try writer.writeAll(">="), + } + + try std.fmt.format(writer, "{}", .{this.comparator.version.fmt(this.buffer)}); + } + }; + + pub fn fmt(this: *const Comparator, buf: []const u8) @This().Formatter { + return .{ .buffer = buf, .comparator = this }; + } + + pub fn satisfies( + comparator: Comparator, + version: Version, + comparator_buf: string, + version_buf: string, + ) bool { + const order = version.orderWithoutBuild(comparator.version, version_buf, comparator_buf); + + return switch (order) { + .eq => switch (comparator.op) { + .lte, .gte, .eql => true, + else => false, + }, + .gt => switch (comparator.op) { + .gt, .gte => true, + else => false, + }, + .lt => switch (comparator.op) { + .lt, .lte => true, + else => false, + }, + }; + } +}; + +pub fn satisfies(range: Range, version: Version, range_buf: string, version_buf: string) bool { + const has_left = range.hasLeft(); + const has_right = range.hasRight(); + + if (!has_left) { + return true; + } + + if (!range.left.satisfies(version, range_buf, version_buf)) { + return false; + } + + if (has_right and !range.right.satisfies(version, range_buf, version_buf)) { + return false; + } + + return true; +} + +pub fn satisfiesPre(range: Range, version: Version, range_buf: string, version_buf: string, pre_matched: *bool) bool { + if (comptime Environment.allow_assert) { + assert(version.tag.hasPre()); + } + const has_left = range.hasLeft(); + const has_right = range.hasRight(); + + if (!has_left) { + return true; + } + + // If left has prerelease check if major,minor,patch matches with left. If + // not, check the same with right if right exists and has prerelease. + pre_matched.* = pre_matched.* or + (range.left.version.tag.hasPre() and + version.patch == range.left.version.patch and + version.minor == range.left.version.minor and + version.major == range.left.version.major) or + (has_right and + range.right.version.tag.hasPre() and + version.patch == range.right.version.patch and + version.minor == range.right.version.minor and + version.major == range.right.version.major); + + if (!range.left.satisfies(version, range_buf, version_buf)) { + return false; + } + + if (has_right and !range.right.satisfies(version, range_buf, version_buf)) { + return false; + } + + return true; +} + +const Range = @This(); + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = @import("../identity_context.zig").IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const SlicedString = bun.Semver.SlicedString; +const String = bun.Semver.String; +const Version = bun.Semver.Version; +const Query = bun.Semver.Query; +const assert = bun.assert; diff --git a/src/semver/SemverString.zig b/src/semver/SemverString.zig new file mode 100644 index 00000000000000..412622d0513e67 --- /dev/null +++ b/src/semver/SemverString.zig @@ -0,0 +1,628 @@ +/// String type that stores either an offset/length into an external buffer or a string inline directly +pub const String = extern struct { + pub const max_inline_len: usize = 8; + /// This is three different types of string. + /// 1. Empty string. If it's all zeroes, then it's an empty string. + /// 2. If the final bit is set, then it's a string that is stored inline. + /// 3. If the final bit is not set, then it's a string that is stored in an external buffer. + bytes: [max_inline_len]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, + + /// Create an inline string + pub fn from(comptime inlinable_buffer: []const u8) String { + comptime { + if (inlinable_buffer.len > max_inline_len or + inlinable_buffer.len == max_inline_len and + inlinable_buffer[max_inline_len - 1] >= 0x80) + { + @compileError("string constant too long to be inlined"); + } + } + return String.init(inlinable_buffer, inlinable_buffer); + } + + pub const Buf = struct { + bytes: *std.ArrayListUnmanaged(u8), + allocator: std.mem.Allocator, + pool: *Builder.StringPool, + + pub fn init(lockfile: *const Lockfile) Buf { + return .{ + .bytes = &lockfile.buffers.string_bytes, + .allocator = lockfile.allocator, + .pool = &lockfile.string_pool, + }; + } + + pub fn append(this: *Buf, str: string) OOM!String { + if (canInline(str)) { + return String.initInline(str); + } + + const hash = Builder.stringHash(str); + const entry = try this.pool.getOrPut(hash); + if (entry.found_existing) { + return entry.value_ptr.*; + } + + // new entry + const new = try String.initAppend(this.allocator, this.bytes, str); + entry.value_ptr.* = new; + return new; + } + + pub fn appendWithHash(this: *Buf, str: string, hash: u64) OOM!String { + if (canInline(str)) { + return initInline(str); + } + + const entry = try this.pool.getOrPut(hash); + if (entry.found_existing) { + return entry.value_ptr.*; + } + + // new entry + const new = try String.initAppend(this.allocator, this.bytes, str); + entry.value_ptr.* = new; + return new; + } + + pub fn appendExternal(this: *Buf, str: string) OOM!ExternalString { + const hash = Builder.stringHash(str); + + if (canInline(str)) { + return .{ + .value = String.initInline(str), + .hash = hash, + }; + } + + const entry = try this.pool.getOrPut(hash); + if (entry.found_existing) { + return .{ + .value = entry.value_ptr.*, + .hash = hash, + }; + } + + const new = try String.initAppend(this.allocator, this.bytes, str); + entry.value_ptr.* = new; + return .{ + .value = new, + .hash = hash, + }; + } + + pub fn appendExternalWithHash(this: *Buf, str: string, hash: u64) OOM!ExternalString { + if (canInline(str)) { + return .{ + .value = initInline(str), + .hash = hash, + }; + } + + const entry = try this.pool.getOrPut(hash); + if (entry.found_existing) { + return .{ + .value = entry.value_ptr.*, + .hash = hash, + }; + } + + const new = try String.initAppend(this.allocator, this.bytes, str); + entry.value_ptr.* = new; + return .{ + .value = new, + .hash = hash, + }; + } + }; + + pub const Tag = enum { + small, + big, + }; + + pub inline fn fmt(self: *const String, buf: []const u8) Formatter { + return Formatter{ + .buf = buf, + .str = self, + }; + } + + pub const Formatter = struct { + str: *const String, + buf: string, + + pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const str = formatter.str; + try writer.writeAll(str.slice(formatter.buf)); + } + }; + + /// Escapes for json. Expects string to be prequoted + pub inline fn fmtJson(self: *const String, buf: []const u8, opts: JsonFormatter.Options) JsonFormatter { + return .{ + .buf = buf, + .str = self, + .opts = opts, + }; + } + + pub const JsonFormatter = struct { + str: *const String, + buf: string, + opts: Options, + + pub const Options = struct { + quote: bool = true, + }; + + pub fn format(formatter: JsonFormatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + try writer.print("{}", .{bun.fmt.formatJSONStringUTF8(formatter.str.slice(formatter.buf), .{ .quote = formatter.opts.quote })}); + } + }; + + pub fn Sorter(comptime direction: enum { asc, desc }) type { + return struct { + lhs_buf: []const u8, + rhs_buf: []const u8, + pub fn lessThan(this: @This(), lhs: String, rhs: String) bool { + return lhs.order(&rhs, this.lhs_buf, this.rhs_buf) == if (comptime direction == .asc) .lt else .gt; + } + }; + } + + pub inline fn order( + lhs: *const String, + rhs: *const String, + lhs_buf: []const u8, + rhs_buf: []const u8, + ) std.math.Order { + return strings.order(lhs.slice(lhs_buf), rhs.slice(rhs_buf)); + } + + pub inline fn canInline(buf: []const u8) bool { + return switch (buf.len) { + 0...max_inline_len - 1 => true, + max_inline_len => buf[max_inline_len - 1] & 0x80 == 0, + else => false, + }; + } + + pub inline fn isInline(this: String) bool { + return this.bytes[max_inline_len - 1] & 0x80 == 0; + } + + pub inline fn sliced(this: *const String, buf: []const u8) SlicedString { + return if (this.isInline()) + SlicedString.init(this.slice(""), this.slice("")) + else + SlicedString.init(buf, this.slice(buf)); + } + + // https://en.wikipedia.org/wiki/Intel_5-level_paging + // https://developer.arm.com/documentation/101811/0101/Address-spaces-in-AArch64#:~:text=0%2DA%2C%20the%20maximum%20size,2%2DA. + // X64 seems to need some of the pointer bits + const max_addressable_space = u63; + + comptime { + if (@sizeOf(usize) != 8) { + @compileError("This code needs to be updated for non-64-bit architectures"); + } + } + + pub const HashContext = struct { + a_buf: []const u8, + b_buf: []const u8, + + pub fn eql(ctx: HashContext, a: String, b: String) bool { + return a.eql(b, ctx.a_buf, ctx.b_buf); + } + + pub fn hash(ctx: HashContext, a: String) u64 { + const str = a.slice(ctx.a_buf); + return bun.hash(str); + } + }; + + pub const ArrayHashContext = struct { + a_buf: []const u8, + b_buf: []const u8, + + pub fn eql(ctx: ArrayHashContext, a: String, b: String, _: usize) bool { + return a.eql(b, ctx.a_buf, ctx.b_buf); + } + + pub fn hash(ctx: ArrayHashContext, a: String) u32 { + const str = a.slice(ctx.a_buf); + return @as(u32, @truncate(bun.hash(str))); + } + }; + + pub fn init( + buf: string, + in: string, + ) String { + return switch (in.len) { + 0 => String{}, + 1 => String{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, + 2 => String{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, + 3 => String{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, + 4 => String{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, + 5 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, + 6 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, + 7 => String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, + max_inline_len => + // If they use the final bit, then it's a big string. + // This should only happen for non-ascii strings that are exactly 8 bytes. + // so that's an edge-case + if ((in[max_inline_len - 1]) >= 128) + @as(String, @bitCast((@as( + u64, + 0, + ) | @as( + u64, + @as( + max_addressable_space, + @truncate(@as( + u64, + @bitCast(Pointer.init(buf, in)), + )), + ), + )) | 1 << 63)) + else + String{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, + + else => @as( + String, + @bitCast((@as( + u64, + 0, + ) | @as( + u64, + @as( + max_addressable_space, + @truncate(@as( + u64, + @bitCast(Pointer.init(buf, in)), + )), + ), + )) | 1 << 63), + ), + }; + } + + pub fn initInline( + in: string, + ) String { + bun.assertWithLocation(canInline(in), @src()); + return switch (in.len) { + 0 => .{}, + 1 => .{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, + 2 => .{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, + 3 => .{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, + 4 => .{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, + 5 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, + 6 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, + 7 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, + 8 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, + else => unreachable, + }; + } + + pub fn initAppendIfNeeded( + allocator: std.mem.Allocator, + buf: *std.ArrayListUnmanaged(u8), + in: string, + ) OOM!String { + return switch (in.len) { + 0 => .{}, + 1 => .{ .bytes = .{ in[0], 0, 0, 0, 0, 0, 0, 0 } }, + 2 => .{ .bytes = .{ in[0], in[1], 0, 0, 0, 0, 0, 0 } }, + 3 => .{ .bytes = .{ in[0], in[1], in[2], 0, 0, 0, 0, 0 } }, + 4 => .{ .bytes = .{ in[0], in[1], in[2], in[3], 0, 0, 0, 0 } }, + 5 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], 0, 0, 0 } }, + 6 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], 0, 0 } }, + 7 => .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], 0 } }, + + max_inline_len => + // If they use the final bit, then it's a big string. + // This should only happen for non-ascii strings that are exactly 8 bytes. + // so that's an edge-case + if ((in[max_inline_len - 1]) >= 128) + try initAppend(allocator, buf, in) + else + .{ .bytes = .{ in[0], in[1], in[2], in[3], in[4], in[5], in[6], in[7] } }, + + else => try initAppend(allocator, buf, in), + }; + } + + pub fn initAppend( + allocator: std.mem.Allocator, + buf: *std.ArrayListUnmanaged(u8), + in: string, + ) OOM!String { + try buf.appendSlice(allocator, in); + const in_buf = buf.items[buf.items.len - in.len ..]; + return @bitCast((@as(u64, 0) | @as(u64, @as(max_addressable_space, @truncate(@as(u64, @bitCast(Pointer.init(buf.items, in_buf))))))) | 1 << 63); + } + + pub fn eql(this: String, that: String, this_buf: []const u8, that_buf: []const u8) bool { + if (this.isInline() and that.isInline()) { + return @as(u64, @bitCast(this.bytes)) == @as(u64, @bitCast(that.bytes)); + } else if (this.isInline() != that.isInline()) { + return false; + } else { + const a = this.ptr(); + const b = that.ptr(); + return strings.eql(this_buf[a.off..][0..a.len], that_buf[b.off..][0..b.len]); + } + } + + pub inline fn isEmpty(this: String) bool { + return @as(u64, @bitCast(this.bytes)) == @as(u64, 0); + } + + pub fn len(this: String) usize { + switch (this.bytes[max_inline_len - 1] & 128) { + 0 => { + // Edgecase: string that starts with a 0 byte will be considered empty. + switch (this.bytes[0]) { + 0 => { + return 0; + }, + else => { + comptime var i: usize = 0; + + inline while (i < this.bytes.len) : (i += 1) { + if (this.bytes[i] == 0) return i; + } + + return 8; + }, + } + }, + else => { + const ptr_ = this.ptr(); + return ptr_.len; + }, + } + } + + pub const Pointer = extern struct { + off: u32 = 0, + len: u32 = 0, + + pub inline fn init( + buf: string, + in: string, + ) Pointer { + if (Environment.allow_assert) { + assert(bun.isSliceInBuffer(in, buf)); + } + + return Pointer{ + .off = @as(u32, @truncate(@intFromPtr(in.ptr) - @intFromPtr(buf.ptr))), + .len = @as(u32, @truncate(in.len)), + }; + } + }; + + pub inline fn ptr(this: String) Pointer { + return @as(Pointer, @bitCast(@as(u64, @as(u63, @truncate(@as(u64, @bitCast(this))))))); + } + + pub fn toJS(this: *const String, buffer: []const u8, globalThis: *JSC.JSGlobalObject) JSC.JSValue { + return bun.String.createUTF8ForJS(globalThis, this.slice(buffer)); + } + + // String must be a pointer because we reference it as a slice. It will become a dead pointer if it is copied. + pub fn slice(this: *const String, buf: string) string { + switch (this.bytes[max_inline_len - 1] & 128) { + 0 => { + // Edgecase: string that starts with a 0 byte will be considered empty. + switch (this.bytes[0]) { + 0 => { + return ""; + }, + else => { + comptime var i: usize = 0; + + inline while (i < this.bytes.len) : (i += 1) { + if (this.bytes[i] == 0) return this.bytes[0..i]; + } + + return &this.bytes; + }, + } + }, + else => { + const ptr_ = this.*.ptr(); + return buf[ptr_.off..][0..ptr_.len]; + }, + } + } + + pub const Builder = struct { + len: usize = 0, + cap: usize = 0, + ptr: ?[*]u8 = null, + string_pool: StringPool = undefined, + + pub const StringPool = std.HashMap(u64, String, IdentityContext(u64), 80); + + pub inline fn stringHash(buf: []const u8) u64 { + return bun.Wyhash11.hash(0, buf); + } + + pub inline fn count(this: *Builder, slice_: string) void { + return countWithHash(this, slice_, if (slice_.len >= String.max_inline_len) stringHash(slice_) else std.math.maxInt(u64)); + } + + pub inline fn countWithHash(this: *Builder, slice_: string, hash: u64) void { + if (slice_.len <= String.max_inline_len) return; + + if (!this.string_pool.contains(hash)) { + this.cap += slice_.len; + } + } + + pub inline fn allocatedSlice(this: *Builder) []u8 { + return if (this.cap > 0) + this.ptr.?[0..this.cap] + else + &[_]u8{}; + } + pub fn allocate(this: *Builder, allocator: Allocator) !void { + const ptr_ = try allocator.alloc(u8, this.cap); + this.ptr = ptr_.ptr; + } + + pub fn append(this: *Builder, comptime Type: type, slice_: string) Type { + return @call(bun.callmod_inline, appendWithHash, .{ this, Type, slice_, stringHash(slice_) }); + } + + pub fn appendUTF8WithoutPool(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { + if (slice_.len <= String.max_inline_len) { + if (strings.isAllASCII(slice_)) { + switch (Type) { + String => { + return String.init(this.allocatedSlice(), slice_); + }, + ExternalString => { + return ExternalString.init(this.allocatedSlice(), slice_, hash); + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + } + + if (comptime Environment.allow_assert) { + assert(this.len <= this.cap); // didn't count everything + assert(this.ptr != null); // must call allocate first + } + + bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); + const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; + this.len += slice_.len; + + if (comptime Environment.allow_assert) assert(this.len <= this.cap); + + switch (Type) { + String => { + return String.init(this.allocatedSlice(), final_slice); + }, + ExternalString => { + return ExternalString.init(this.allocatedSlice(), final_slice, hash); + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + + // SlicedString is not supported due to inline strings. + pub fn appendWithoutPool(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { + if (slice_.len <= String.max_inline_len) { + switch (Type) { + String => { + return String.init(this.allocatedSlice(), slice_); + }, + ExternalString => { + return ExternalString.init(this.allocatedSlice(), slice_, hash); + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + if (comptime Environment.allow_assert) { + assert(this.len <= this.cap); // didn't count everything + assert(this.ptr != null); // must call allocate first + } + + bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); + const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; + this.len += slice_.len; + + if (comptime Environment.allow_assert) assert(this.len <= this.cap); + + switch (Type) { + String => { + return String.init(this.allocatedSlice(), final_slice); + }, + ExternalString => { + return ExternalString.init(this.allocatedSlice(), final_slice, hash); + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + + pub fn appendWithHash(this: *Builder, comptime Type: type, slice_: string, hash: u64) Type { + if (slice_.len <= String.max_inline_len) { + switch (Type) { + String => { + return String.init(this.allocatedSlice(), slice_); + }, + ExternalString => { + return ExternalString.init(this.allocatedSlice(), slice_, hash); + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + + if (comptime Environment.allow_assert) { + assert(this.len <= this.cap); // didn't count everything + assert(this.ptr != null); // must call allocate first + } + + const string_entry = this.string_pool.getOrPut(hash) catch unreachable; + if (!string_entry.found_existing) { + bun.copy(u8, this.ptr.?[this.len..this.cap], slice_); + const final_slice = this.ptr.?[this.len..this.cap][0..slice_.len]; + this.len += slice_.len; + + string_entry.value_ptr.* = String.init(this.allocatedSlice(), final_slice); + } + + if (comptime Environment.allow_assert) assert(this.len <= this.cap); + + switch (Type) { + String => { + return string_entry.value_ptr.*; + }, + ExternalString => { + return ExternalString{ + .value = string_entry.value_ptr.*, + .hash = hash, + }; + }, + else => @compileError("Invalid type passed to StringBuilder"), + } + } + }; + + comptime { + if (@sizeOf(String) != @sizeOf(Pointer)) { + @compileError("String types must be the same size"); + } + } +}; + +const assert = bun.assert; +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = bun.IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const SlicedString = bun.Semver.SlicedString; diff --git a/src/semver/SlicedString.zig b/src/semver/SlicedString.zig new file mode 100644 index 00000000000000..960c20a8b85b97 --- /dev/null +++ b/src/semver/SlicedString.zig @@ -0,0 +1,58 @@ +buf: string, +slice: string, + +pub inline fn init(buf: string, slice: string) SlicedString { + if (Environment.allow_assert and !@inComptime()) { + if (@intFromPtr(buf.ptr) > @intFromPtr(slice.ptr)) { + @panic("SlicedString.init buf is not in front of slice"); + } + } + return SlicedString{ .buf = buf, .slice = slice }; +} + +pub inline fn external(this: SlicedString) ExternalString { + if (comptime Environment.allow_assert) { + assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); + } + + return ExternalString.init(this.buf, this.slice, bun.Wyhash11.hash(0, this.slice)); +} + +pub inline fn value(this: SlicedString) String { + if (comptime Environment.allow_assert) { + assert(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.slice.ptr) and ((@intFromPtr(this.slice.ptr) + this.slice.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len))); + } + + return String.init(this.buf, this.slice); +} + +pub inline fn sub(this: SlicedString, input: string) SlicedString { + if (Environment.allow_assert) { + if (!(@intFromPtr(this.buf.ptr) <= @intFromPtr(this.buf.ptr) and ((@intFromPtr(input.ptr) + input.len) <= (@intFromPtr(this.buf.ptr) + this.buf.len)))) { + @panic("SlicedString.sub input is not a substring of the slice"); + } + } + return SlicedString{ .buf = this.buf, .slice = input }; +} + +const SlicedString = @This(); +const assert = bun.assert; +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = bun.IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const String = bun.Semver.String; diff --git a/src/semver/Version.zig b/src/semver/Version.zig new file mode 100644 index 00000000000000..2073f981484369 --- /dev/null +++ b/src/semver/Version.zig @@ -0,0 +1,1010 @@ +pub const Version = extern struct { + major: u32 = 0, + minor: u32 = 0, + patch: u32 = 0, + _tag_padding: [4]u8 = .{0} ** 4, // [see padding_checker.zig] + tag: Tag = .{}, + + /// Assumes that there is only one buffer for all the strings + pub fn sortGt(ctx: []const u8, lhs: Version, rhs: Version) bool { + return orderFn(ctx, lhs, rhs) == .gt; + } + + pub fn orderFn(ctx: []const u8, lhs: Version, rhs: Version) std.math.Order { + return lhs.order(rhs, ctx, ctx); + } + + pub fn isZero(this: Version) bool { + return this.patch == 0 and this.minor == 0 and this.major == 0; + } + + pub fn parseUTF8(slice: []const u8) ParseResult { + return parse(.{ .buf = slice, .slice = slice }); + } + + pub fn cloneInto(this: Version, slice: []const u8, buf: *[]u8) Version { + return .{ + .major = this.major, + .minor = this.minor, + .patch = this.patch, + .tag = this.tag.cloneInto(slice, buf), + }; + } + + pub inline fn len(this: *const Version) u32 { + return this.tag.build.len + this.tag.pre.len; + } + + pub const Formatter = struct { + version: Version, + input: string, + + pub fn format(formatter: Formatter, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { + const self = formatter.version; + try std.fmt.format(writer, "{?d}.{?d}.{?d}", .{ self.major, self.minor, self.patch }); + + if (self.tag.hasPre()) { + const pre = self.tag.pre.slice(formatter.input); + try writer.writeAll("-"); + try writer.writeAll(pre); + } + + if (self.tag.hasBuild()) { + const build = self.tag.build.slice(formatter.input); + try writer.writeAll("+"); + try writer.writeAll(build); + } + } + }; + + pub fn fmt(this: Version, input: string) Formatter { + return .{ .version = this, .input = input }; + } + + pub const DiffFormatter = struct { + version: Version, + buf: string, + other: Version, + other_buf: string, + + pub fn format(this: DiffFormatter, comptime fmt_: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void { + if (!Output.enable_ansi_colors) { + // print normally if no colors + const formatter: Formatter = .{ .version = this.version, .input = this.buf }; + return Formatter.format(formatter, fmt_, options, writer); + } + + const diff = this.version.whichVersionIsDifferent(this.other, this.buf, this.other_buf) orelse .none; + + switch (diff) { + .major => try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }), + .minor => { + if (this.version.major == 0) { + try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }); + } else { + try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }); + } + }, + .patch => { + if (this.version.major == 0 and this.version.minor == 0) { + try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }); + } else { + try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }); + } + }, + .none, .pre, .build => try writer.print(Output.prettyFmt("{d}.{d}.{d}", true), .{ + this.version.major, this.version.minor, this.version.patch, + }), + } + + // might be pre or build. loop through all characters, and insert on + // first diff. + + var set_color = false; + if (this.version.tag.hasPre()) { + if (this.other.tag.hasPre()) { + const pre = this.version.tag.pre.slice(this.buf); + const other_pre = this.other.tag.pre.slice(this.other_buf); + + var first = true; + for (pre, 0..) |c, i| { + if (!set_color and i < other_pre.len and c != other_pre[i]) { + set_color = true; + try writer.writeAll(Output.prettyFmt("", true)); + } + if (first) { + first = false; + try writer.writeByte('-'); + } + try writer.writeByte(c); + } + } else { + try writer.print(Output.prettyFmt("-{}", true), .{this.version.tag.pre.fmt(this.buf)}); + set_color = true; + } + } + + if (this.version.tag.hasBuild()) { + if (this.other.tag.hasBuild()) { + const build = this.version.tag.build.slice(this.buf); + const other_build = this.other.tag.build.slice(this.other_buf); + + var first = true; + for (build, 0..) |c, i| { + if (!set_color and i < other_build.len and c != other_build[i]) { + set_color = true; + try writer.writeAll(Output.prettyFmt("", true)); + } + if (first) { + first = false; + try writer.writeByte('+'); + } + try writer.writeByte(c); + } + } else { + if (!set_color) { + try writer.print(Output.prettyFmt("+{}", true), .{this.version.tag.build.fmt(this.buf)}); + } else { + try writer.print("+{}", .{this.version.tag.build.fmt(this.other_buf)}); + } + } + } + + try writer.writeAll(Output.prettyFmt("", true)); + } + }; + + pub fn diffFmt(this: Version, other: Version, this_buf: string, other_buf: string) DiffFormatter { + return .{ + .version = this, + .buf = this_buf, + .other = other, + .other_buf = other_buf, + }; + } + + pub const ChangedVersion = enum { + major, + minor, + patch, + pre, + build, + none, + }; + + pub fn whichVersionIsDifferent( + left: Version, + right: Version, + left_buf: string, + right_buf: string, + ) ?ChangedVersion { + if (left.major != right.major) return .major; + if (left.minor != right.minor) return .minor; + if (left.patch != right.patch) return .patch; + + if (left.tag.hasPre() != right.tag.hasPre()) return .pre; + if (!left.tag.hasPre() and !right.tag.hasPre()) return null; + if (left.tag.orderPre(right.tag, left_buf, right_buf) != .eq) return .pre; + + if (left.tag.hasBuild() != right.tag.hasBuild()) return .build; + if (!left.tag.hasBuild() and !right.tag.hasBuild()) return null; + return if (left.tag.build.order(&right.tag.build, left_buf, right_buf) != .eq) + .build + else + null; + } + + pub fn count(this: *const Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) void { + if (this.tag.hasPre() and !this.tag.pre.isInline()) builder.count(this.tag.pre.slice(buf)); + if (this.tag.hasBuild() and !this.tag.build.isInline()) builder.count(this.tag.build.slice(buf)); + } + + pub fn append(this: *const Version, buf: []const u8, comptime StringBuilder: type, builder: StringBuilder) Version { + var that = this.*; + + if (this.tag.hasPre() and !this.tag.pre.isInline()) that.tag.pre = builder.append(ExternalString, this.tag.pre.slice(buf)); + if (this.tag.hasBuild() and !this.tag.build.isInline()) that.tag.build = builder.append(ExternalString, this.tag.build.slice(buf)); + + return that; + } + + pub const Partial = struct { + major: ?u32 = null, + minor: ?u32 = null, + patch: ?u32 = null, + tag: Tag = .{}, + + pub fn min(this: Partial) Version { + return .{ + .major = this.major orelse 0, + .minor = this.minor orelse 0, + .patch = this.patch orelse 0, + .tag = this.tag, + }; + } + + pub fn max(this: Partial) Version { + return .{ + .major = this.major orelse std.math.maxInt(u32), + .minor = this.minor orelse std.math.maxInt(u32), + .patch = this.patch orelse std.math.maxInt(u32), + .tag = this.tag, + }; + } + }; + + const Hashable = extern struct { + major: u32, + minor: u32, + patch: u32, + pre: u64, + build: u64, + }; + + pub fn hash(this: Version) u64 { + const hashable = Hashable{ + .major = this.major, + .minor = this.minor, + .patch = this.patch, + .pre = this.tag.pre.hash, + .build = this.tag.build.hash, + }; + const bytes = std.mem.asBytes(&hashable); + return bun.Wyhash.hash(0, bytes); + } + + pub fn eql(lhs: Version, rhs: Version) bool { + return lhs.major == rhs.major and lhs.minor == rhs.minor and lhs.patch == rhs.patch and rhs.tag.eql(lhs.tag); + } + + pub const HashContext = struct { + pub fn hash(_: @This(), lhs: Version) u32 { + return @as(u32, @truncate(lhs.hash())); + } + + pub fn eql(_: @This(), lhs: Version, rhs: Version) bool { + return lhs.eql(rhs); + } + }; + + pub const PinnedVersion = enum { + major, // ^ + minor, // ~ + patch, // = + }; + + /// Modified version of pnpm's `whichVersionIsPinned` + /// https://github.com/pnpm/pnpm/blob/bc0618cf192a9cafd0ab171a3673e23ed0869bbd/packages/which-version-is-pinned/src/index.ts#L9 + /// + /// Differences: + /// - It's not used for workspaces + /// - `npm:` is assumed already removed from aliased versions + /// - Invalid input is considered major pinned (important because these strings are coming + /// from package.json) + /// + /// The goal of this function is to avoid a complete parse of semver that's unused + pub fn whichVersionIsPinned(input: string) PinnedVersion { + const version = strings.trim(input, &strings.whitespace_chars); + + var i: usize = 0; + + const pinned: PinnedVersion = pinned: { + for (0..version.len) |j| { + switch (version[j]) { + // newlines & whitespace + ' ', + '\t', + '\n', + '\r', + std.ascii.control_code.vt, + std.ascii.control_code.ff, + + // version separators + 'v', + '=', + => {}, + + else => |c| { + i = j; + + switch (c) { + '~', '^' => { + i += 1; + + for (i..version.len) |k| { + switch (version[k]) { + ' ', + '\t', + '\n', + '\r', + std.ascii.control_code.vt, + std.ascii.control_code.ff, + => { + // `v` and `=` not included. + // `~v==1` would update to `^1.1.0` if versions `1.0.0`, `1.0.1`, `1.1.0`, and `2.0.0` are available + // note that `~` changes to `^` + }, + + else => { + i = k; + break :pinned if (c == '~') .minor else .major; + }, + } + } + + // entire version after `~` is whitespace. invalid + return .major; + }, + + '0'...'9' => break :pinned .patch, + + // could be invalid, could also be valid range syntax (>=, ...) + // either way, pin major + else => return .major, + } + }, + } + } + + // entire semver is whitespace, `v`, and `=`. Invalid + return .major; + }; + + // `pinned` is `.major`, `.minor`, or `.patch`. Check for each version core number: + // - if major is missing, return `if (pinned == .patch) .major else pinned` + // - if minor is missing, return `if (pinned == .patch) .minor else pinned` + // - if patch is missing, return `pinned` + // - if there's whitespace or non-digit characters between core numbers, return `.major` + // - if the end is reached, return `pinned` + + // major + if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; + var d = version[i]; + while (std.ascii.isDigit(d)) { + i += 1; + if (i >= version.len) return if (pinned == .patch) .major else pinned; + d = version[i]; + } + + if (d != '.') return .major; + + // minor + i += 1; + if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; + d = version[i]; + while (std.ascii.isDigit(d)) { + i += 1; + if (i >= version.len) return if (pinned == .patch) .minor else pinned; + d = version[i]; + } + + if (d != '.') return .major; + + // patch + i += 1; + if (i >= version.len or !std.ascii.isDigit(version[i])) return .major; + d = version[i]; + while (std.ascii.isDigit(d)) { + i += 1; + + // patch is done and at input end, valid + if (i >= version.len) return pinned; + d = version[i]; + } + + // Skip remaining valid pre/build tag characters and whitespace. + // Does not validate whitespace used inside pre/build tags. + if (!validPreOrBuildTagCharacter(d) or std.ascii.isWhitespace(d)) return .major; + i += 1; + + // at this point the semver is valid so we can return true if it ends + if (i >= version.len) return pinned; + d = version[i]; + while (validPreOrBuildTagCharacter(d) and !std.ascii.isWhitespace(d)) { + i += 1; + if (i >= version.len) return pinned; + d = version[i]; + } + + // We've come across a character that is not valid for tags or is whitespace. + // Trailing whitespace was trimmed so we can assume there's another range + return .major; + } + + fn validPreOrBuildTagCharacter(c: u8) bool { + return switch (c) { + '-', '+', '.', 'A'...'Z', 'a'...'z', '0'...'9' => true, + else => false, + }; + } + + pub fn isTaggedVersionOnly(input: []const u8) bool { + const version = strings.trim(input, &strings.whitespace_chars); + + // first needs to be a-z + if (version.len == 0 or !std.ascii.isAlphabetic(version[0])) return false; + + for (1..version.len) |i| { + if (!std.ascii.isAlphanumeric(version[i])) return false; + } + + return true; + } + + pub fn orderWithoutTag( + lhs: Version, + rhs: Version, + ) std.math.Order { + if (lhs.major < rhs.major) return .lt; + if (lhs.major > rhs.major) return .gt; + if (lhs.minor < rhs.minor) return .lt; + if (lhs.minor > rhs.minor) return .gt; + if (lhs.patch < rhs.patch) return .lt; + if (lhs.patch > rhs.patch) return .gt; + + if (lhs.tag.hasPre()) { + if (!rhs.tag.hasPre()) return .lt; + } else { + if (rhs.tag.hasPre()) return .gt; + } + + return .eq; + } + + pub fn order( + lhs: Version, + rhs: Version, + lhs_buf: []const u8, + rhs_buf: []const u8, + ) std.math.Order { + const order_without_tag = orderWithoutTag(lhs, rhs); + if (order_without_tag != .eq) return order_without_tag; + + return lhs.tag.order(rhs.tag, lhs_buf, rhs_buf); + } + + pub fn orderWithoutBuild( + lhs: Version, + rhs: Version, + lhs_buf: []const u8, + rhs_buf: []const u8, + ) std.math.Order { + const order_without_tag = orderWithoutTag(lhs, rhs); + if (order_without_tag != .eq) return order_without_tag; + + return lhs.tag.orderWithoutBuild(rhs.tag, lhs_buf, rhs_buf); + } + + pub const Tag = extern struct { + pre: ExternalString = ExternalString{}, + build: ExternalString = ExternalString{}, + + pub fn orderPre(lhs: Tag, rhs: Tag, lhs_buf: []const u8, rhs_buf: []const u8) std.math.Order { + const lhs_str = lhs.pre.slice(lhs_buf); + const rhs_str = rhs.pre.slice(rhs_buf); + + // 1. split each by '.', iterating through each one looking for integers + // 2. compare as integers, or if not possible compare as string + // 3. whichever is greater is the greater one + // + // 1.0.0-canary.0.0.0.0.0.0 < 1.0.0-canary.0.0.0.0.0.1 + + var lhs_itr = strings.split(lhs_str, "."); + var rhs_itr = strings.split(rhs_str, "."); + + while (true) { + const lhs_part = lhs_itr.next(); + const rhs_part = rhs_itr.next(); + + if (lhs_part == null and rhs_part == null) return .eq; + + // if right is null, left is greater than. + if (rhs_part == null) return .gt; + + // if left is null, left is less than. + if (lhs_part == null) return .lt; + + const lhs_uint: ?u32 = std.fmt.parseUnsigned(u32, lhs_part.?, 10) catch null; + const rhs_uint: ?u32 = std.fmt.parseUnsigned(u32, rhs_part.?, 10) catch null; + + // a part that doesn't parse as an integer is greater than a part that does + // https://github.com/npm/node-semver/blob/816c7b2cbfcb1986958a290f941eddfd0441139e/internal/identifiers.js#L12 + if (lhs_uint != null and rhs_uint == null) return .lt; + if (lhs_uint == null and rhs_uint != null) return .gt; + + if (lhs_uint == null and rhs_uint == null) { + switch (strings.order(lhs_part.?, rhs_part.?)) { + .eq => { + // continue to the next part + continue; + }, + else => |not_equal| return not_equal, + } + } + + switch (std.math.order(lhs_uint.?, rhs_uint.?)) { + .eq => continue, + else => |not_equal| return not_equal, + } + } + + unreachable; + } + + pub fn order( + lhs: Tag, + rhs: Tag, + lhs_buf: []const u8, + rhs_buf: []const u8, + ) std.math.Order { + if (!lhs.pre.isEmpty() and !rhs.pre.isEmpty()) { + return lhs.orderPre(rhs, lhs_buf, rhs_buf); + } + + const pre_order = lhs.pre.order(&rhs.pre, lhs_buf, rhs_buf); + if (pre_order != .eq) return pre_order; + + return lhs.build.order(&rhs.build, lhs_buf, rhs_buf); + } + + pub fn orderWithoutBuild( + lhs: Tag, + rhs: Tag, + lhs_buf: []const u8, + rhs_buf: []const u8, + ) std.math.Order { + if (!lhs.pre.isEmpty() and !rhs.pre.isEmpty()) { + return lhs.orderPre(rhs, lhs_buf, rhs_buf); + } + + return lhs.pre.order(&rhs.pre, lhs_buf, rhs_buf); + } + + pub fn cloneInto(this: Tag, slice: []const u8, buf: *[]u8) Tag { + var pre: String = this.pre.value; + var build: String = this.build.value; + + if (this.pre.isInline()) { + pre = this.pre.value; + } else { + const pre_slice = this.pre.slice(slice); + bun.copy(u8, buf.*, pre_slice); + pre = String.init(buf.*, buf.*[0..pre_slice.len]); + buf.* = buf.*[pre_slice.len..]; + } + + if (this.build.isInline()) { + build = this.build.value; + } else { + const build_slice = this.build.slice(slice); + bun.copy(u8, buf.*, build_slice); + build = String.init(buf.*, buf.*[0..build_slice.len]); + buf.* = buf.*[build_slice.len..]; + } + + return .{ + .pre = .{ + .value = pre, + .hash = this.pre.hash, + }, + .build = .{ + .value = build, + .hash = this.build.hash, + }, + }; + } + + pub inline fn hasPre(this: Tag) bool { + return !this.pre.isEmpty(); + } + + pub inline fn hasBuild(this: Tag) bool { + return !this.build.isEmpty(); + } + + pub fn eql(lhs: Tag, rhs: Tag) bool { + return lhs.pre.hash == rhs.pre.hash; + } + + pub const TagResult = struct { + tag: Tag = Tag{}, + len: u32 = 0, + }; + + var multi_tag_warn = false; + // TODO: support multiple tags + + pub fn parse(sliced_string: SlicedString) TagResult { + return parseWithPreCount(sliced_string, 0); + } + + pub fn parseWithPreCount(sliced_string: SlicedString, initial_pre_count: u32) TagResult { + var input = sliced_string.slice; + var build_count: u32 = 0; + var pre_count: u32 = initial_pre_count; + + for (input) |c| { + switch (c) { + ' ' => break, + '+' => { + build_count += 1; + }, + '-' => { + pre_count += 1; + }, + else => {}, + } + } + + if (build_count == 0 and pre_count == 0) { + return TagResult{ + .len = 0, + }; + } + + const State = enum { none, pre, build }; + var result = TagResult{}; + // Common case: no allocation is necessary. + var state = State.none; + var start: usize = 0; + + var i: usize = 0; + + while (i < input.len) : (i += 1) { + const c = input[i]; + switch (c) { + '+' => { + // qualifier ::= ( '-' pre )? ( '+' build )? + if (state == .pre or state == .none and initial_pre_count > 0) { + result.tag.pre = sliced_string.sub(input[start..i]).external(); + } + + if (state != .build) { + state = .build; + start = i + 1; + } + }, + '-' => { + if (state != .pre) { + state = .pre; + start = i + 1; + } + }, + + // only continue if character is a valid pre/build tag character + // https://semver.org/#spec-item-9 + 'a'...'z', 'A'...'Z', '0'...'9', '.' => {}, + + else => { + switch (state) { + .none => {}, + .pre => { + result.tag.pre = sliced_string.sub(input[start..i]).external(); + + state = State.none; + }, + .build => { + result.tag.build = sliced_string.sub(input[start..i]).external(); + if (comptime Environment.isDebug) { + assert(!strings.containsChar(result.tag.build.slice(sliced_string.buf), '-')); + } + state = State.none; + }, + } + result.len = @truncate(i); + break; + }, + } + } + + if (state == .none and initial_pre_count > 0) { + state = .pre; + start = 0; + } + + switch (state) { + .none => {}, + .pre => { + result.tag.pre = sliced_string.sub(input[start..i]).external(); + // a pre can contain multiple consecutive tags + // checking for "-" prefix is not enough, as --canary.67e7966.0 is a valid tag + state = State.none; + }, + .build => { + // a build can contain multiple consecutive tags + result.tag.build = sliced_string.sub(input[start..i]).external(); + + state = State.none; + }, + } + result.len = @as(u32, @truncate(i)); + + return result; + } + }; + + pub const ParseResult = struct { + wildcard: Query.Token.Wildcard = .none, + valid: bool = true, + version: Version.Partial = .{}, + len: u32 = 0, + }; + + pub fn parse(sliced_string: SlicedString) ParseResult { + var input = sliced_string.slice; + var result = ParseResult{}; + + var part_i: u8 = 0; + var part_start_i: usize = 0; + var last_char_i: usize = 0; + + if (input.len == 0) { + result.valid = false; + return result; + } + var is_done = false; + + var i: usize = 0; + + for (0..input.len) |c| { + switch (input[c]) { + // newlines & whitespace + ' ', + '\t', + '\n', + '\r', + std.ascii.control_code.vt, + std.ascii.control_code.ff, + + // version separators + 'v', + '=', + => {}, + else => { + i = c; + break; + }, + } + } + + if (i == input.len) { + result.valid = false; + return result; + } + + // two passes :( + while (i < input.len) { + if (is_done) { + break; + } + + switch (input[i]) { + ' ' => { + is_done = true; + break; + }, + '|', '^', '#', '&', '%', '!' => { + is_done = true; + if (i > 0) { + i -= 1; + } + break; + }, + '0'...'9' => { + part_start_i = i; + i += 1; + + while (i < input.len and switch (input[i]) { + '0'...'9' => true, + else => false, + }) { + i += 1; + } + + last_char_i = i; + + switch (part_i) { + 0 => { + result.version.major = parseVersionNumber(input[part_start_i..last_char_i]); + part_i = 1; + }, + 1 => { + result.version.minor = parseVersionNumber(input[part_start_i..last_char_i]); + part_i = 2; + }, + 2 => { + result.version.patch = parseVersionNumber(input[part_start_i..last_char_i]); + part_i = 3; + }, + else => {}, + } + + if (i < input.len and switch (input[i]) { + // `.` is expected only if there are remaining core version numbers + '.' => part_i != 3, + else => false, + }) { + i += 1; + } + }, + '.' => { + result.valid = false; + is_done = true; + break; + }, + '-', '+' => { + // Just a plain tag with no version is invalid. + if (part_i < 2 and result.wildcard == .none) { + result.valid = false; + is_done = true; + break; + } + + part_start_i = i; + while (i < input.len and switch (input[i]) { + ' ' => true, + else => false, + }) { + i += 1; + } + const tag_result = Tag.parse(sliced_string.sub(input[part_start_i..])); + result.version.tag = tag_result.tag; + i += tag_result.len; + break; + }, + 'x', '*', 'X' => { + part_start_i = i; + i += 1; + + while (i < input.len and switch (input[i]) { + 'x', '*', 'X' => true, + else => false, + }) { + i += 1; + } + + last_char_i = i; + + if (i < input.len and switch (input[i]) { + '.' => true, + else => false, + }) { + i += 1; + } + + if (result.wildcard == .none) { + switch (part_i) { + 0 => { + result.wildcard = Query.Token.Wildcard.major; + part_i = 1; + }, + 1 => { + result.wildcard = Query.Token.Wildcard.minor; + part_i = 2; + }, + 2 => { + result.wildcard = Query.Token.Wildcard.patch; + part_i = 3; + }, + else => {}, + } + } + }, + else => |c| { + + // Some weirdo npm packages in the wild have a version like "1.0.0rc.1" + // npm just expects that to work...even though it has no "-" qualifier. + if (result.wildcard == .none and part_i >= 2 and switch (c) { + 'a'...'z', 'A'...'Z' => true, + else => false, + }) { + part_start_i = i; + const tag_result = Tag.parseWithPreCount(sliced_string.sub(input[part_start_i..]), 1); + result.version.tag = tag_result.tag; + i += tag_result.len; + is_done = true; + last_char_i = i; + break; + } + + last_char_i = 0; + result.valid = false; + is_done = true; + break; + }, + } + } + + if (result.wildcard == .none) { + switch (part_i) { + 0 => { + result.wildcard = Query.Token.Wildcard.major; + }, + 1 => { + result.wildcard = Query.Token.Wildcard.minor; + }, + 2 => { + result.wildcard = Query.Token.Wildcard.patch; + }, + else => {}, + } + } + + result.len = @as(u32, @intCast(i)); + + return result; + } + + fn parseVersionNumber(input: string) ?u32 { + // max decimal u32 is 4294967295 + var bytes: [10]u8 = undefined; + var byte_i: u8 = 0; + + assert(input[0] != '.'); + + for (input) |char| { + switch (char) { + 'X', 'x', '*' => return null, + '0'...'9' => { + // out of bounds + if (byte_i + 1 > bytes.len) return null; + bytes[byte_i] = char; + byte_i += 1; + }, + ' ', '.' => break, + // ignore invalid characters + else => {}, + } + } + + // If there are no numbers + if (byte_i == 0) return null; + + if (comptime Environment.isDebug) { + return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch |err| { + Output.prettyErrorln("ERROR {s} parsing version: \"{s}\", bytes: {s}", .{ + @errorName(err), + input, + bytes[0..byte_i], + }); + return 0; + }; + } + + return std.fmt.parseInt(u32, bytes[0..byte_i], 10) catch 0; + } +}; + +const std = @import("std"); +const Allocator = std.mem.Allocator; +const bun = @import("root").bun; +const string = bun.string; +const Output = bun.Output; +const Global = bun.Global; +const Environment = bun.Environment; +const strings = bun.strings; +const MutableString = bun.MutableString; +const stringZ = bun.stringZ; +const default_allocator = bun.default_allocator; +const C = bun.C; +const JSC = bun.JSC; +const IdentityContext = @import("../identity_context.zig").IdentityContext; +const OOM = bun.OOM; +const TruncatedPackageNameHash = bun.install.TruncatedPackageNameHash; +const Lockfile = bun.install.Lockfile; +const ExternalString = bun.Semver.ExternalString; +const SlicedString = bun.Semver.SlicedString; +const String = bun.Semver.String; + +const Query = bun.Semver.Query; +const assert = bun.assert; From cc68f4f025b00856bd01926b783eaa9044385c7c Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Sun, 2 Feb 2025 05:11:15 -0800 Subject: [PATCH 10/29] Fix occasional crash starting debugger thread (#16989) --- src/bun.js/javascript.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index 3d9010143db9f2..ef51a2587e59e5 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1718,7 +1718,8 @@ pub const VirtualMachine = struct { vm.is_main_thread = false; vm.eventLoop().ensureWaker(); - vm.global.vm().holdAPILock(other_vm, @ptrCast(&start)); + const callback = OpaqueWrap(VirtualMachine, start); + vm.global.vm().holdAPILock(other_vm, callback); } pub export fn Debugger__didConnect() void { From 00a5c4af5a36b58617348d0a574df92032284db9 Mon Sep 17 00:00:00 2001 From: Ciro Spaciari Date: Sun, 2 Feb 2025 21:27:22 -0800 Subject: [PATCH 11/29] fix(sql) disable idle timeout when still processing data (#16984) --- src/sql/postgres.zig | 157 +++++++++++++++++++--------------------- test/js/sql/sql.test.ts | 24 +++++- 2 files changed, 96 insertions(+), 85 deletions(-) diff --git a/src/sql/postgres.zig b/src/sql/postgres.zig index cacf84965719b9..a48858f7c08ddb 100644 --- a/src/sql/postgres.zig +++ b/src/sql/postgres.zig @@ -330,7 +330,6 @@ pub const PostgresSQLQuery = struct { } = .{}, pub usingnamespace JSC.Codegen.JSPostgresSQLQuery; - const log = bun.Output.scoped(.PostgresSQLQuery, false); pub fn getTarget(this: *PostgresSQLQuery, globalObject: *JSC.JSGlobalObject) JSC.JSValue { const thisValue = this.thisValue.get(); if (thisValue == .zero) { @@ -700,7 +699,7 @@ pub const PostgresSQLQuery = struct { }; const has_params = signature.fields.len > 0; - var reset_timeout = false; + var did_write = false; enqueue: { if (entry.found_existing) { this.statement = entry.value_ptr.*; @@ -715,7 +714,7 @@ pub const PostgresSQLQuery = struct { .prepared => { if (!connection.hasQueryRunning()) { this.flags.binary = this.statement.?.fields.len > 0; - log("bindAndExecute", .{}); + debug("bindAndExecute", .{}); // bindAndExecute will bind + execute, it will change to running after binding is complete PostgresRequest.bindAndExecute(globalObject, this.statement.?, binding_value, columns_value, PostgresSQLConnection.Writer, writer) catch |err| { if (!globalObject.hasException()) @@ -724,7 +723,7 @@ pub const PostgresSQLQuery = struct { }; this.status = .binding; - reset_timeout = true; + did_write = true; } }, .parsing, .pending => {}, @@ -738,7 +737,7 @@ pub const PostgresSQLQuery = struct { if (can_execute) { // If it does not have params, we can write and execute immediately in one go if (!has_params) { - log("prepareAndQueryWithSignature", .{}); + debug("prepareAndQueryWithSignature", .{}); // prepareAndQueryWithSignature will write + bind + execute, it will change to running after binding is complete PostgresRequest.prepareAndQueryWithSignature(globalObject, query_str.slice(), binding_value, PostgresSQLConnection.Writer, writer, &signature) catch |err| { signature.deinit(); @@ -747,9 +746,9 @@ pub const PostgresSQLQuery = struct { return error.JSError; }; this.status = .binding; - reset_timeout = true; + did_write = true; } else { - log("writeQuery", .{}); + debug("writeQuery", .{}); PostgresRequest.writeQuery(query_str.slice(), signature.prepared_statement_name, signature.fields, PostgresSQLConnection.Writer, writer) catch |err| { signature.deinit(); if (!globalObject.hasException()) @@ -762,7 +761,7 @@ pub const PostgresSQLQuery = struct { return globalObject.throwValue(postgresErrorToJS(globalObject, "failed to flush", err)); return error.JSError; }; - reset_timeout = true; + did_write = true; } } { @@ -781,12 +780,11 @@ pub const PostgresSQLQuery = struct { this.thisValue.upgrade(globalObject); PostgresSQLQuery.targetSetCached(this_value, globalObject, query); - - if (connection.is_ready_for_query) - connection.flushDataAndResetTimeout() - else if (reset_timeout) + if (did_write) { + connection.flushDataAndResetTimeout(); + } else { connection.resetConnectionTimeout(); - + } return .undefined; } @@ -1046,8 +1044,9 @@ pub const PostgresRequest = struct { ) !void { while (true) { reader.markMessageStart(); - - switch (try reader.int(u8)) { + const c = try reader.int(u8); + debug("read: {c}", .{c}); + switch (c) { 'D' => try connection.on(.DataRow, Context, reader), 'd' => try connection.on(.CopyData, Context, reader), 'S' => { @@ -1091,9 +1090,10 @@ pub const PostgresRequest = struct { 'c' => try connection.on(.CopyDone, Context, reader), 'W' => try connection.on(.CopyBothResponse, Context, reader), - else => |c| { - debug("Unknown message: {d}", .{c}); + else => { + debug("Unknown message: {c}", .{c}); const to_skip = try reader.length() -| 1; + debug("to_skip: {d}", .{to_skip}); try reader.skip(@intCast(@max(to_skip, 0))); }, } @@ -1121,13 +1121,9 @@ pub const PostgresSQLConnection = struct { pending_activity_count: std.atomic.Value(u32) = std.atomic.Value(u32).init(0), js_value: JSValue = JSValue.undefined, - is_ready_for_query: bool = false, - backend_parameters: bun.StringMap = bun.StringMap.init(bun.default_allocator, true), backend_key_data: protocol.BackendKeyData = .{}, - pending_disconnect: bool = false, - database: []const u8 = "", user: []const u8 = "", password: []const u8 = "", @@ -1144,6 +1140,8 @@ pub const PostgresSQLConnection = struct { idle_timeout_interval_ms: u32 = 0, connection_timeout_ms: u32 = 0, + flags: ConnectionFlags = .{}, + /// Before being connected, this is a connection timeout timer. /// After being connected, this is an idle timeout timer. timer: JSC.BunTimer.EventLoopTimer = .{ @@ -1166,6 +1164,11 @@ pub const PostgresSQLConnection = struct { }, }, + pub const ConnectionFlags = packed struct { + is_ready_for_query: bool = false, + is_processing_data: bool = false, + }; + pub const TLSStatus = union(enum) { none, pending, @@ -1302,8 +1305,15 @@ pub const PostgresSQLConnection = struct { else => this.connection_timeout_ms, }; } - + pub fn disableConnectionTimeout(this: *PostgresSQLConnection) void { + if (this.timer.state == .ACTIVE) { + this.globalObject.bunVM().timer.remove(&this.timer); + } + this.timer.state = .CANCELLED; + } pub fn resetConnectionTimeout(this: *PostgresSQLConnection) void { + // if we are processing data, don't reset the timeout, wait for the data to be processed + if (this.flags.is_processing_data) return; const interval = this.getTimeoutInterval(); if (this.timer.state == .ACTIVE) { this.globalObject.bunVM().timer.remove(&this.timer); @@ -1379,7 +1389,12 @@ pub const PostgresSQLConnection = struct { pub fn onConnectionTimeout(this: *PostgresSQLConnection) JSC.BunTimer.EventLoopTimer.Arm { debug("onConnectionTimeout", .{}); + this.timer.state = .FIRED; + if (this.flags.is_processing_data) { + return .disarm; + } + if (this.getTimeoutInterval() == 0) { this.resetConnectionTimeout(); return .disarm; @@ -1429,9 +1444,8 @@ pub const PostgresSQLConnection = struct { } pub fn setStatus(this: *PostgresSQLConnection, status: Status) void { - defer this.updateHasPendingActivity(); - if (this.status == status) return; + defer this.updateHasPendingActivity(); this.status = status; this.resetConnectionTimeout(); @@ -1443,7 +1457,6 @@ pub const PostgresSQLConnection = struct { js_value.ensureStillAlive(); this.globalObject.queueMicrotask(on_connect, &[_]JSValue{ JSValue.jsNull(), js_value }); this.poll_ref.unref(this.globalObject.bunVM()); - this.updateHasPendingActivity(); }, else => {}, } @@ -1630,16 +1643,21 @@ pub const PostgresSQLConnection = struct { pub fn onData(this: *PostgresSQLConnection, data: []const u8) void { this.ref(); + this.flags.is_processing_data = true; const vm = this.globalObject.bunVM(); + + this.disableConnectionTimeout(); defer { - if (this.status == .connected and this.requests.readableLength() == 0 and this.write_buffer.remaining().len == 0) { + if (this.status == .connected and !this.hasQueryRunning() and this.write_buffer.remaining().len == 0) { // Don't keep the process alive when there's nothing to do. this.poll_ref.unref(vm); } else if (this.status == .connected) { // Keep the process alive if there's something to do. this.poll_ref.ref(vm); } + this.flags.is_processing_data = false; + // reset the connection timeout after we're done processing the data this.resetConnectionTimeout(); this.deref(); } @@ -1648,6 +1666,9 @@ pub const PostgresSQLConnection = struct { event_loop.enter(); defer event_loop.exit(); SocketMonitor.read(data); + // reset the head to the last message so remaining reflects the right amount of bytes + this.read_buffer.head = this.last_message_start; + if (this.read_buffer.remaining().len == 0) { var consumed: usize = 0; var offset: usize = 0; @@ -1655,20 +1676,11 @@ pub const PostgresSQLConnection = struct { PostgresRequest.onData(this, protocol.StackReader, reader) catch |err| { if (err == error.ShortRead) { if (comptime bun.Environment.allow_assert) { - // if (@errorReturnTrace()) |trace| { - // debug("Received short read: last_message_start: {d}, head: {d}, len: {d}\n{}", .{ - // offset, - // consumed, - // data.len, - // trace, - // }); - // } else { - debug("Received short read: last_message_start: {d}, head: {d}, len: {d}", .{ + debug("read_buffer: empty and received short read: last_message_start: {d}, head: {d}, len: {d}", .{ offset, consumed, data.len, }); - // } } this.read_buffer.head = 0; @@ -1681,42 +1693,32 @@ pub const PostgresSQLConnection = struct { this.fail("Failed to read data", err); } }; + // no need to reset anything, its already empty return; } - - { - this.read_buffer.head = this.last_message_start; - this.read_buffer.write(bun.default_allocator, data) catch @panic("failed to write to read buffer"); - PostgresRequest.onData(this, Reader, this.bufferedReader()) catch |err| { - if (err != error.ShortRead) { - bun.handleErrorReturnTrace(err, @errorReturnTrace()); - this.fail("Failed to read data", err); - return; - } - - if (comptime bun.Environment.allow_assert) { - // if (@errorReturnTrace()) |trace| { - // debug("Received short read: last_message_start: {d}, head: {d}, len: {d}\n{}", .{ - // this.last_message_start, - // this.read_buffer.head, - // this.read_buffer.byte_list.len, - // trace, - // }); - // } else { - debug("Received short read: last_message_start: {d}, head: {d}, len: {d}", .{ - this.last_message_start, - this.read_buffer.head, - this.read_buffer.byte_list.len, - }); - // } - } - + // read buffer is not empty, so we need to write the data to the buffer and then read it + this.read_buffer.write(bun.default_allocator, data) catch @panic("failed to write to read buffer"); + PostgresRequest.onData(this, Reader, this.bufferedReader()) catch |err| { + if (err != error.ShortRead) { + bun.handleErrorReturnTrace(err, @errorReturnTrace()); + this.fail("Failed to read data", err); return; - }; + } - this.last_message_start = 0; - this.read_buffer.head = 0; - } + if (comptime bun.Environment.allow_assert) { + debug("read_buffer: not empty and received short read: last_message_start: {d}, head: {d}, len: {d}", .{ + this.last_message_start, + this.read_buffer.head, + this.read_buffer.byte_list.len, + }); + } + return; + }; + + debug("clean read_buffer", .{}); + // success, we read everything! let's reset the last message start and the head + this.last_message_start = 0; + this.read_buffer.head = 0; } pub fn constructor(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!*PostgresSQLConnection { @@ -2065,7 +2067,7 @@ pub const PostgresSQLConnection = struct { } fn hasQueryRunning(this: *PostgresSQLConnection) bool { - return !this.is_ready_for_query or this.current() != null; + return !this.flags.is_ready_for_query or this.current() != null; } pub const Writer = struct { @@ -2550,9 +2552,6 @@ pub const PostgresSQLConnection = struct { }; fn advance(this: *PostgresSQLConnection) !void { - defer this.updateRef(); - var any = false; - defer if (any) this.resetConnectionTimeout(); while (this.requests.readableLength() > 0) { var req: *PostgresSQLQuery = this.requests.peekItem(0); switch (req.status) { @@ -2566,7 +2565,6 @@ pub const PostgresSQLConnection = struct { req.deref(); this.requests.discard(1); - any = true; continue; }, .prepared => { @@ -2584,7 +2582,6 @@ pub const PostgresSQLConnection = struct { continue; }; req.status = .binding; - any = true; return; }, .pending => { @@ -2611,7 +2608,6 @@ pub const PostgresSQLConnection = struct { req.status = .binding; stmt.status = .parsing; - any = true; return; } const connection_writer = this.writer(); @@ -2637,7 +2633,6 @@ pub const PostgresSQLConnection = struct { continue; }; stmt.status = .parsing; - any = true; return; }, .parsing => { @@ -2655,7 +2650,6 @@ pub const PostgresSQLConnection = struct { .success, .fail => { req.deref(); this.requests.discard(1); - any = true; continue; }, } @@ -2669,7 +2663,7 @@ pub const PostgresSQLConnection = struct { pub fn on(this: *PostgresSQLConnection, comptime MessageType: @Type(.enum_literal), comptime Context: type, reader: protocol.NewReader(Context)) AnyPostgresError!void { debug("on({s})", .{@tagName(MessageType)}); if (comptime MessageType != .ReadyForQuery) { - this.is_ready_for_query = false; + this.flags.is_ready_for_query = false; } switch (comptime MessageType) { @@ -2757,13 +2751,8 @@ pub const PostgresSQLConnection = struct { var ready_for_query: protocol.ReadyForQuery = undefined; try ready_for_query.decodeInternal(Context, reader); - if (this.pending_disconnect) { - this.disconnect(); - return; - } - this.setStatus(.connected); - this.is_ready_for_query = true; + this.flags.is_ready_for_query = true; this.socket.setTimeout(300); try this.advance(); diff --git a/test/js/sql/sql.test.ts b/test/js/sql/sql.test.ts index 42adec74160ae8..84e86cca3c81ff 100644 --- a/test/js/sql/sql.test.ts +++ b/test/js/sql/sql.test.ts @@ -1,4 +1,4 @@ -import { sql, SQL } from "bun"; +import { sql, SQL, randomUUIDv7 } from "bun"; const postgres = (...args) => new sql(...args); import { expect, test, mock, beforeAll, afterAll } from "bun:test"; import { $ } from "bun"; @@ -266,6 +266,28 @@ if (isDockerEnabled()) { expect(result).toEqual([{ x: 3 }]); }); + test("should not timeout in long results", async () => { + await using db = postgres({ ...options, max: 1, idleTimeout: 5 }); + using sql = await db.reserve(); + const random_name = "test_" + randomUUIDv7("hex").replaceAll("-", ""); + + await sql`CREATE TEMPORARY TABLE ${sql(random_name)} (id int, name text)`; + const promises: Promise[] = []; + for (let i = 0; i < 10_000; i++) { + promises.push(sql`INSERT INTO ${sql(random_name)} VALUES (${i}, ${"test" + i})`); + if (i % 50 === 0 && i > 0) { + await Promise.all(promises); + promises.length = 0; + } + } + await Promise.all(promises); + await sql`SELECT * FROM ${sql(random_name)}`; + await sql`SELECT * FROM ${sql(random_name)}`; + await sql`SELECT * FROM ${sql(random_name)}`; + + expect().pass(); + }, 10_000); + test("Handles numeric column names", async () => { // deliberately out of order const result = await sql`select 1 as "1", 2 as "2", 3 as "3", 0 as "0"`; From 06b16fc11e6ec46e6223492d3d79bc3b6dd02b93 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:31:40 -0800 Subject: [PATCH 12/29] fix 16939 (#16991) --- src/bun.js/api/bun/dns_resolver.zig | 24 ++++++++++++------------ src/bun.js/bindings/bindings.zig | 14 ++++++++++---- src/bun.js/webcore/blob.zig | 25 +++++++++++++++++++------ test/js/bun/util/bun-file.test.ts | 23 +++++++++++++++++++++++ 4 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 test/js/bun/util/bun-file.test.ts diff --git a/src/bun.js/api/bun/dns_resolver.zig b/src/bun.js/api/bun/dns_resolver.zig index f960f38828ab9a..8c365c2920fb09 100644 --- a/src/bun.js/api/bun/dns_resolver.zig +++ b/src/bun.js/api/bun/dns_resolver.zig @@ -2519,7 +2519,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolve", "name", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); switch (record_type) { RecordType.A => { @@ -2582,7 +2582,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("reverse", "ip", "non-empty string"); } - const ip_slice = ip_str.toSliceClone(globalThis, bun.default_allocator); + const ip_slice = try ip_str.toSliceClone(globalThis, bun.default_allocator); const ip = ip_slice.slice(); const channel: *c_ares.Channel = switch (this.getChannel()) { .result => |res| res, @@ -2718,7 +2718,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveSrv", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_srv_reply, "srv", name.slice(), globalThis); } @@ -2744,7 +2744,7 @@ pub const DNSResolver = struct { return .zero; }; - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_soa_reply, "soa", name.slice(), globalThis); } @@ -2774,7 +2774,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveCaa", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_caa_reply, "caa", name.slice(), globalThis); } @@ -2800,7 +2800,7 @@ pub const DNSResolver = struct { return .zero; }; - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_hostent, "ns", name.slice(), globalThis); } @@ -2830,7 +2830,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolvePtr", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_hostent, "ptr", name.slice(), globalThis); } @@ -2860,7 +2860,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveCname", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_hostent, "cname", name.slice(), globalThis); } @@ -2890,7 +2890,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveMx", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_mx_reply, "mx", name.slice(), globalThis); } @@ -2920,7 +2920,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveNaptr", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_naptr_reply, "naptr", name.slice(), globalThis); } @@ -2950,7 +2950,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveTxt", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_ares_txt_reply, "txt", name.slice(), globalThis); } @@ -2980,7 +2980,7 @@ pub const DNSResolver = struct { return globalThis.throwInvalidArgumentType("resolveAny", "hostname", "non-empty string"); } - const name = name_str.toSliceClone(globalThis, bun.default_allocator); + const name = try name_str.toSliceClone(globalThis, bun.default_allocator); return this.doResolveCAres(c_ares.struct_any_reply, "any", name.slice(), globalThis); } diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 8727946521c3b5..95c2ca06ec1cdb 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -610,7 +610,13 @@ pub const ZigString = extern struct { return !this.allocator.isNull(); } - pub fn clone(this: Slice, allocator: std.mem.Allocator) !Slice { + pub fn toOwned(this: Slice, allocator: std.mem.Allocator) OOM!Slice { + const duped = try allocator.dupe(u8, this.ptr[0..this.len]); + return .{ .allocator = .init(allocator), .ptr = duped.ptr, .len = this.len }; + } + + // TODO: this is identical to `cloneIfNeeded` + pub fn clone(this: Slice, allocator: std.mem.Allocator) OOM!Slice { if (this.isAllocated()) { return Slice{ .allocator = this.allocator, .ptr = this.ptr, .len = this.len }; } @@ -951,10 +957,10 @@ pub const ZigString = extern struct { }; } - pub fn toSliceClone(this: ZigString, allocator: std.mem.Allocator) Slice { + pub fn toSliceClone(this: ZigString, allocator: std.mem.Allocator) OOM!Slice { if (this.len == 0) return Slice.empty; - const buffer = this.toOwnedSlice(allocator) catch unreachable; + const buffer = try this.toOwnedSlice(allocator); return Slice{ .allocator = NullableAllocator.init(allocator), .ptr = buffer.ptr, @@ -1983,7 +1989,7 @@ pub const JSString = extern struct { this: *JSString, global: *JSGlobalObject, allocator: std.mem.Allocator, - ) ZigString.Slice { + ) JSError!ZigString.Slice { var str = ZigString.init(""); this.toZigString(global, &str); return str.toSliceClone(allocator); diff --git a/src/bun.js/webcore/blob.zig b/src/bun.js/webcore/blob.zig index c39153baa01acd..9b29a52dce8e02 100644 --- a/src/bun.js/webcore/blob.zig +++ b/src/bun.js/webcore/blob.zig @@ -3489,10 +3489,15 @@ pub const Blob = struct { // milliseconds since ECMAScript epoch last_modified: JSC.JSTimeType = JSC.init_timestamp, - pub fn unlink(this: *const FileStore, globalThis: *JSC.JSGlobalObject) JSValue { + pub fn unlink(this: *const FileStore, globalThis: *JSC.JSGlobalObject) bun.JSError!JSValue { return switch (this.pathlike) { .path => |path_like| JSC.Node.Async.unlink.create(globalThis, undefined, .{ - .path = .{ .encoded_slice = ZigString.init(path_like.slice()).toSliceClone(bun.default_allocator) }, + .path = .{ + .encoded_slice = switch (path_like) { + .encoded_slice => |slice| try slice.toOwned(bun.default_allocator), + else => try ZigString.init(path_like.slice()).toSliceClone(bun.default_allocator), + }, + }, }, globalThis.bunVM()), .fd => JSC.JSPromise.resolvedPromiseValue(globalThis, globalThis.createInvalidArgs("Is not possible to unlink a file descriptor", .{})), }; @@ -4750,15 +4755,23 @@ pub const Blob = struct { comptime { _ = Bun__Blob__getSizeForBindings; } - pub fn getStat(this: *Blob, globalThis: *JSC.JSGlobalObject, callback: *JSC.CallFrame) JSC.JSValue { + pub fn getStat(this: *Blob, globalThis: *JSC.JSGlobalObject, callback: *JSC.CallFrame) bun.JSError!JSC.JSValue { const store = this.store orelse return JSC.JSValue.jsUndefined(); // TODO: make this async for files return switch (store.data) { .file => |*file| { return switch (file.pathlike) { - .path => |path_like| JSC.Node.Async.stat.create(globalThis, undefined, .{ - .path = .{ .encoded_slice = ZigString.init(path_like.slice()).toSliceClone(bun.default_allocator) }, - }, globalThis.bunVM()), + .path => |path_like| { + return JSC.Node.Async.stat.create(globalThis, undefined, .{ + .path = .{ + .encoded_slice = switch (path_like) { + // it's already converted to utf8 + .encoded_slice => |slice| try slice.toOwned(bun.default_allocator), + else => try ZigString.init(path_like.slice()).toSliceClone(bun.default_allocator), + }, + }, + }, globalThis.bunVM()); + }, .fd => |fd| JSC.Node.Async.fstat.create(globalThis, undefined, .{ .fd = fd }, globalThis.bunVM()), }; }, diff --git a/test/js/bun/util/bun-file.test.ts b/test/js/bun/util/bun-file.test.ts new file mode 100644 index 00000000000000..33976872d1c79e --- /dev/null +++ b/test/js/bun/util/bun-file.test.ts @@ -0,0 +1,23 @@ +import { test, expect } from "bun:test"; +import { tmpdirSync } from "harness"; +import { join } from "path"; + +test("delete() and stat() should work with unicode paths", async () => { + const testDir = tmpdirSync(); + const filename = join(testDir, "🌟.txt"); + + expect(async () => { + await Bun.file(filename).delete(); + }).toThrow(`ENOENT: no such file or directory, unlink '${filename}'`); + + expect(async () => { + await Bun.file(filename).stat(); + }).toThrow(`ENOENT: no such file or directory, stat '${filename}'`); + + await Bun.write(filename, "HI"); + + expect(await Bun.file(filename).stat()).toMatchObject({ size: 2 }); + expect(await Bun.file(filename).delete()).toBe(undefined); + + expect(await Bun.file(filename).exists()).toBe(false); +}); From fa502506e564a328ca56eca2b9b5011986f28d5a Mon Sep 17 00:00:00 2001 From: Minsoo Choo Date: Mon, 3 Feb 2025 00:34:58 -0500 Subject: [PATCH 13/29] Fix formatting for extern "c" (#16983) --- .cursor/rules/javascriptcore-class.mdc | 2 +- src/bun.js/api/Timer.zig | 2 +- src/bun.js/api/bun/process.zig | 8 ++-- src/bun.js/api/ffi.zig | 48 +++++++++++----------- src/bun.js/base.zig | 8 ++-- src/bun.js/bindings/CPUFeatures.zig | 2 +- src/bun.js/bindings/JSPropertyIterator.zig | 12 +++--- src/bun.js/bindings/bindings.zig | 10 ++--- src/bun.js/event_loop.zig | 2 +- src/bun.js/javascript.zig | 6 +-- src/bun.js/module_loader.zig | 2 +- src/bun.js/node/path.zig | 2 +- src/bun.zig | 8 ++-- src/c.zig | 8 ++-- src/crash_handler.zig | 2 +- src/darwin_c.zig | 2 +- src/deps/uws.zig | 2 +- src/io/io.zig | 2 +- src/js_ast.zig | 2 +- src/linux_c.zig | 10 ++--- src/main.zig | 4 +- src/output.zig | 2 +- src/shell/shell.zig | 2 +- src/sys.zig | 2 +- 24 files changed, 75 insertions(+), 75 deletions(-) diff --git a/.cursor/rules/javascriptcore-class.mdc b/.cursor/rules/javascriptcore-class.mdc index 62fedefb5688f3..6a6ebc6498c9e8 100644 --- a/.cursor/rules/javascriptcore-class.mdc +++ b/.cursor/rules/javascriptcore-class.mdc @@ -349,7 +349,7 @@ extern "C" JSC::EncodedJSValue Bun__JSBigIntStatsObjectConstructor(Zig::GlobalOb Zig: ```zig -extern "C" fn Bun__JSBigIntStatsObjectConstructor(*JSC.JSGlobalObject) JSC.JSValue; +extern "c" fn Bun__JSBigIntStatsObjectConstructor(*JSC.JSGlobalObject) JSC.JSValue; pub const getBigIntStatsConstructor = Bun__JSBigIntStatsObjectConstructor; ``` diff --git a/src/bun.js/api/Timer.zig b/src/bun.js/api/Timer.zig index 0c9bae6db207d1..dd9382126b7762 100644 --- a/src/bun.js/api/Timer.zig +++ b/src/bun.js/api/Timer.zig @@ -446,7 +446,7 @@ pub const TimerObject = struct { pub usingnamespace JSC.Codegen.JSTimeout; pub usingnamespace bun.NewRefCounted(@This(), deinit, null); - extern "C" fn Bun__JSTimeout__call(encodedTimeoutValue: JSValue, globalObject: *JSC.JSGlobalObject) void; + extern "c" fn Bun__JSTimeout__call(encodedTimeoutValue: JSValue, globalObject: *JSC.JSGlobalObject) void; pub fn runImmediateTask(this: *TimerObject, vm: *VirtualMachine) void { if (this.has_cleared_timer) { diff --git a/src/bun.js/api/bun/process.zig b/src/bun.js/api/bun/process.zig index 9f69ce021c9d2d..b6fed57c8a502d 100644 --- a/src/bun.js/api/bun/process.zig +++ b/src/bun.js/api/bun/process.zig @@ -2042,16 +2042,16 @@ pub const sync = struct { } // Forward signals from parent to the child process. - extern "C" fn Bun__registerSignalsForForwarding() void; - extern "C" fn Bun__unregisterSignalsForForwarding() void; + extern "c" fn Bun__registerSignalsForForwarding() void; + extern "c" fn Bun__unregisterSignalsForForwarding() void; // The PID to forward signals to. // Set to 0 when unregistering. - extern "C" var Bun__currentSyncPID: i64; + extern "c" var Bun__currentSyncPID: i64; // Race condition: a signal could be sent before spawnProcessPosix returns. // We need to make sure to send it after the process is spawned. - extern "C" fn Bun__sendPendingSignalIfNecessary() void; + extern "c" fn Bun__sendPendingSignalIfNecessary() void; fn spawnPosix( options: *const Options, diff --git a/src/bun.js/api/ffi.zig b/src/bun.js/api/ffi.zig index a50392f7ce4b60..6c23fcc0aa1a5e 100644 --- a/src/bun.js/api/ffi.zig +++ b/src/bun.js/api/ffi.zig @@ -81,8 +81,8 @@ const Offsets = extern struct { JSArrayBufferView__offsetOfVector: u32, JSCell__offsetOfType: u32, - extern "C" var Bun__FFI__offsets: Offsets; - extern "C" fn Bun__FFI__ensureOffsetsAreLoaded() void; + extern "c" var Bun__FFI__offsets: Offsets; + extern "c" fn Bun__FFI__ensureOffsetsAreLoaded() void; fn loadOnce() void { Bun__FFI__ensureOffsetsAreLoaded(); } @@ -165,27 +165,27 @@ pub const FFI = struct { }; const stdarg = struct { - extern "C" fn ffi_vfprintf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_vprintf([*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_fprintf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_printf([*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_fscanf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_scanf([*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_sscanf([*:0]const u8, [*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_vsscanf([*:0]const u8, [*:0]const u8, ...) callconv(.C) c_int; - extern "C" fn ffi_fopen([*:0]const u8, [*:0]const u8) callconv(.C) *anyopaque; - extern "C" fn ffi_fclose(*anyopaque) callconv(.C) c_int; - extern "C" fn ffi_fgetc(*anyopaque) callconv(.C) c_int; - extern "C" fn ffi_fputc(c: c_int, *anyopaque) callconv(.C) c_int; - extern "C" fn ffi_feof(*anyopaque) callconv(.C) c_int; - extern "C" fn ffi_fileno(*anyopaque) callconv(.C) c_int; - extern "C" fn ffi_ungetc(c: c_int, *anyopaque) callconv(.C) c_int; - extern "C" fn ffi_ftell(*anyopaque) callconv(.C) c_long; - extern "C" fn ffi_fseek(*anyopaque, c_long, c_int) callconv(.C) c_int; - extern "C" fn ffi_fflush(*anyopaque) callconv(.C) c_int; - - extern "C" fn calloc(nmemb: usize, size: usize) callconv(.C) ?*anyopaque; - extern "C" fn perror([*:0]const u8) callconv(.C) void; + extern "c" fn ffi_vfprintf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_vprintf([*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_fprintf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_printf([*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_fscanf(*anyopaque, [*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_scanf([*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_sscanf([*:0]const u8, [*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_vsscanf([*:0]const u8, [*:0]const u8, ...) callconv(.C) c_int; + extern "c" fn ffi_fopen([*:0]const u8, [*:0]const u8) callconv(.C) *anyopaque; + extern "c" fn ffi_fclose(*anyopaque) callconv(.C) c_int; + extern "c" fn ffi_fgetc(*anyopaque) callconv(.C) c_int; + extern "c" fn ffi_fputc(c: c_int, *anyopaque) callconv(.C) c_int; + extern "c" fn ffi_feof(*anyopaque) callconv(.C) c_int; + extern "c" fn ffi_fileno(*anyopaque) callconv(.C) c_int; + extern "c" fn ffi_ungetc(c: c_int, *anyopaque) callconv(.C) c_int; + extern "c" fn ffi_ftell(*anyopaque) callconv(.C) c_long; + extern "c" fn ffi_fseek(*anyopaque, c_long, c_int) callconv(.C) c_int; + extern "c" fn ffi_fflush(*anyopaque) callconv(.C) c_int; + + extern "c" fn calloc(nmemb: usize, size: usize) callconv(.C) ?*anyopaque; + extern "c" fn perror([*:0]const u8) callconv(.C) void; const mac = if (Environment.isMac) struct { var ffi_stdinp: *anyopaque = @extern(*anyopaque, .{ .name = "__stdinp" }); @@ -1471,7 +1471,7 @@ pub const FFI = struct { return val.return_type == ABIType.napi_value; } - extern "C" fn FFICallbackFunctionWrapper_destroy(*anyopaque) void; + extern "c" fn FFICallbackFunctionWrapper_destroy(*anyopaque) void; pub fn deinit(val: *Function, globalThis: *JSC.JSGlobalObject, allocator: std.mem.Allocator) void { JSC.markBinding(@src()); diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig index 8f58a2b083e71c..01c099782e2fa2 100644 --- a/src/bun.js/base.zig +++ b/src/bun.js/base.zig @@ -408,7 +408,7 @@ pub const ArrayBuffer = extern struct { return Bun__createUint8ArrayForCopy(globalThis, bytes.ptr, bytes.len, false); } - extern "C" fn Bun__allocUint8ArrayForCopy(*JSC.JSGlobalObject, usize, **anyopaque) JSC.JSValue; + extern "c" fn Bun__allocUint8ArrayForCopy(*JSC.JSGlobalObject, usize, **anyopaque) JSC.JSValue; pub fn allocBuffer(globalThis: *JSC.JSGlobalObject, len: usize) struct { JSC.JSValue, []u8 } { var ptr: [*]u8 = undefined; const buffer = Bun__allocUint8ArrayForCopy(globalThis, len, @ptrCast(&ptr)); @@ -418,8 +418,8 @@ pub const ArrayBuffer = extern struct { return .{ buffer, ptr[0..len] }; } - extern "C" fn Bun__createUint8ArrayForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize, buffer: bool) JSC.JSValue; - extern "C" fn Bun__createArrayBufferForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize) JSC.JSValue; + extern "c" fn Bun__createUint8ArrayForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize, buffer: bool) JSC.JSValue; + extern "c" fn Bun__createArrayBufferForCopy(*JSC.JSGlobalObject, ptr: ?*const anyopaque, len: usize) JSC.JSValue; pub fn fromTypedArray(ctx: JSC.C.JSContextRef, value: JSC.JSValue) ArrayBuffer { var out = std.mem.zeroes(ArrayBuffer); @@ -429,7 +429,7 @@ pub const ArrayBuffer = extern struct { return out; } - extern "C" fn JSArrayBuffer__fromDefaultAllocator(*JSC.JSGlobalObject, ptr: [*]u8, len: usize) JSC.JSValue; + extern "c" fn JSArrayBuffer__fromDefaultAllocator(*JSC.JSGlobalObject, ptr: [*]u8, len: usize) JSC.JSValue; pub fn toJSFromDefaultAllocator(globalThis: *JSC.JSGlobalObject, bytes: []u8) JSC.JSValue { return JSArrayBuffer__fromDefaultAllocator(globalThis, bytes.ptr, bytes.len); } diff --git a/src/bun.js/bindings/CPUFeatures.zig b/src/bun.js/bindings/CPUFeatures.zig index a5f6f444912d76..76cb6b7d78816e 100644 --- a/src/bun.js/bindings/CPUFeatures.zig +++ b/src/bun.js/bindings/CPUFeatures.zig @@ -84,6 +84,6 @@ else } }; -extern "C" fn bun_cpu_features() u8; +extern "c" fn bun_cpu_features() u8; const assert = bun.debugAssert; diff --git a/src/bun.js/bindings/JSPropertyIterator.zig b/src/bun.js/bindings/JSPropertyIterator.zig index 56f763551fd87d..854128256d44a4 100644 --- a/src/bun.js/bindings/JSPropertyIterator.zig +++ b/src/bun.js/bindings/JSPropertyIterator.zig @@ -2,12 +2,12 @@ const bun = @import("root").bun; const JSC = bun.JSC; //extern "C" EncodedJSValue Bun__JSPropertyIterator__getNameAndValue(JSPropertyIterator* iter, JSC::JSGlobalObject* globalObject, JSC::JSObject* object, BunString* propertyName, size_t i) -extern "C" fn Bun__JSPropertyIterator__create(globalObject: *JSC.JSGlobalObject, encodedValue: JSC.JSValue, *usize, own_properties_only: bool, only_non_index_properties: bool) ?*anyopaque; -extern "C" fn Bun__JSPropertyIterator__getNameAndValue(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque, propertyName: *bun.String, i: usize) JSC.JSValue; -extern "C" fn Bun__JSPropertyIterator__getNameAndValueNonObservable(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque, propertyName: *bun.String, i: usize) JSC.JSValue; -extern "C" fn Bun__JSPropertyIterator__getName(iter: ?*anyopaque, propertyName: *bun.String, i: usize) void; -extern "C" fn Bun__JSPropertyIterator__deinit(iter: ?*anyopaque) void; -extern "C" fn Bun__JSPropertyIterator__getLongestPropertyName(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque) usize; +extern "c" fn Bun__JSPropertyIterator__create(globalObject: *JSC.JSGlobalObject, encodedValue: JSC.JSValue, *usize, own_properties_only: bool, only_non_index_properties: bool) ?*anyopaque; +extern "c" fn Bun__JSPropertyIterator__getNameAndValue(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque, propertyName: *bun.String, i: usize) JSC.JSValue; +extern "c" fn Bun__JSPropertyIterator__getNameAndValueNonObservable(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque, propertyName: *bun.String, i: usize) JSC.JSValue; +extern "c" fn Bun__JSPropertyIterator__getName(iter: ?*anyopaque, propertyName: *bun.String, i: usize) void; +extern "c" fn Bun__JSPropertyIterator__deinit(iter: ?*anyopaque) void; +extern "c" fn Bun__JSPropertyIterator__getLongestPropertyName(iter: ?*anyopaque, globalObject: *JSC.JSGlobalObject, object: *anyopaque) usize; pub const JSPropertyIteratorOptions = struct { skip_empty_name: bool, include_value: bool, diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 95c2ca06ec1cdb..4c0ba9e4f6d097 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -192,7 +192,7 @@ pub const CachedBytecode = opaque { return null; } - extern "C" fn CachedBytecode__deref(this: *CachedBytecode) void; + extern "c" fn CachedBytecode__deref(this: *CachedBytecode) void; pub fn deref(this: *CachedBytecode) void { return CachedBytecode__deref(this); } @@ -1338,7 +1338,7 @@ pub const FetchHeaders = opaque { }); } - extern "C" fn WebCore__FetchHeaders__createFromJS(*JSC.JSGlobalObject, JSValue) ?*FetchHeaders; + extern "c" fn WebCore__FetchHeaders__createFromJS(*JSC.JSGlobalObject, JSValue) ?*FetchHeaders; /// Construct a `Headers` object from a JSValue. /// /// This can be: @@ -2999,7 +2999,7 @@ pub const JSGlobalObject = opaque { return this.ERR_INVALID_ARG_VALUE("The \"{s}\" argument is invalid. Received {}", .{ argname, actual_string_value }).throw(); } - extern "C" fn Bun__ErrorCode__determineSpecificType(*JSGlobalObject, JSValue) String; + extern "c" fn Bun__ErrorCode__determineSpecificType(*JSGlobalObject, JSValue) String; pub fn determineSpecificType(global: *JSGlobalObject, value: JSValue) JSError!String { const str = Bun__ErrorCode__determineSpecificType(global, value); @@ -4251,7 +4251,7 @@ pub const JSValue = enum(i64) { @import("./headers.zig").JSC__JSValue__put(value, global, key, result); } - extern "C" fn JSC__JSValue__putBunString(value: JSValue, global: *JSGlobalObject, key: *const bun.String, result: JSC.JSValue) void; + extern "c" fn JSC__JSValue__putBunString(value: JSValue, global: *JSGlobalObject, key: *const bun.String, result: JSC.JSValue) void; fn putBunString(value: JSValue, global: *JSGlobalObject, key: *const bun.String, result: JSC.JSValue) void { if (comptime bun.Environment.isDebug) JSC.markBinding(@src()); @@ -4650,7 +4650,7 @@ pub const JSValue = enum(i64) { }); } - extern "C" fn JSC__JSValue__hasOwnPropertyValue(JSValue, *JSGlobalObject, JSValue) bool; + extern "c" fn JSC__JSValue__hasOwnPropertyValue(JSValue, *JSGlobalObject, JSValue) bool; /// Calls `Object.hasOwnProperty(value)`. /// Returns true if the object has the property, false otherwise /// diff --git a/src/bun.js/event_loop.zig b/src/bun.js/event_loop.zig index 59e3347d26f9f9..1b8d98eef498b5 100644 --- a/src/bun.js/event_loop.zig +++ b/src/bun.js/event_loop.zig @@ -2509,7 +2509,7 @@ pub const PosixSignalHandle = struct { pub const PosixSignalTask = struct { number: u8, - extern "C" fn Bun__onSignalForJS(number: i32, globalObject: *JSC.JSGlobalObject) void; + extern "c" fn Bun__onSignalForJS(number: i32, globalObject: *JSC.JSGlobalObject) void; pub usingnamespace bun.New(@This()); pub fn runFromJSThread(number: u8, globalObject: *JSC.JSGlobalObject) void { diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index ef51a2587e59e5..d4667d97282669 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -1584,9 +1584,9 @@ pub const VirtualMachine = struct { pub const log = Output.scoped(.debugger, false); - extern "C" fn Bun__createJSDebugger(*JSGlobalObject) u32; - extern "C" fn Bun__ensureDebugger(u32, bool) void; - extern "C" fn Bun__startJSDebuggerThread(*JSGlobalObject, u32, *bun.String, c_int, bool) void; + extern "c" fn Bun__createJSDebugger(*JSGlobalObject) u32; + extern "c" fn Bun__ensureDebugger(u32, bool) void; + extern "c" fn Bun__startJSDebuggerThread(*JSGlobalObject, u32, *bun.String, c_int, bool) void; var futex_atomic: std.atomic.Value(u32) = undefined; pub fn waitForDebuggerIfNecessary(this: *VirtualMachine) void { diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig index 191b346f28bb12..240e64ee2c36b7 100644 --- a/src/bun.js/module_loader.zig +++ b/src/bun.js/module_loader.zig @@ -1459,7 +1459,7 @@ pub const ModuleLoader = struct { bun.default_allocator.free(this.string_buf); } - extern "C" fn Bun__onFulfillAsyncModule( + extern "c" fn Bun__onFulfillAsyncModule( globalObject: *JSGlobalObject, promiseValue: JSValue, res: *JSC.ErrorableResolvedSource, diff --git a/src/bun.js/node/path.zig b/src/bun.js/node/path.zig index d12b1e74ce1bf2..cabfc69be5d1ca 100644 --- a/src/bun.js/node/path.zig +++ b/src/bun.js/node/path.zig @@ -2814,7 +2814,7 @@ pub fn resolveJS_T(comptime T: type, globalObject: *JSC.JSGlobalObject, allocato return if (isWindows) resolveWindowsJS_T(T, globalObject, paths, buf, buf2) else resolvePosixJS_T(T, globalObject, paths, buf, buf2); } -extern "C" fn Process__getCachedCwd(*JSC.JSGlobalObject) JSC.JSValue; +extern "c" fn Process__getCachedCwd(*JSC.JSGlobalObject) JSC.JSValue; pub fn resolve(globalObject: *JSC.JSGlobalObject, isWindows: bool, args_ptr: [*]JSC.JSValue, args_len: u16) callconv(JSC.conv) JSC.JSValue { var arena = bun.ArenaAllocator.init(bun.default_allocator); diff --git a/src/bun.zig b/src/bun.zig index beae14b002cd61..d1e54e51fff787 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -1832,7 +1832,7 @@ pub fn reloadProcess( } } else if (comptime Environment.isPosix) { const on_before_reload_process_linux = struct { - pub extern "C" fn on_before_reload_process_linux() void; + pub extern "c" fn on_before_reload_process_linux() void; }.on_before_reload_process_linux; on_before_reload_process_linux(); @@ -3251,7 +3251,7 @@ pub fn NewThreadSafeRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: pub fn exitThread() noreturn { const exiter = struct { - pub extern "C" fn pthread_exit(?*anyopaque) noreturn; + pub extern "c" fn pthread_exit(?*anyopaque) noreturn; pub extern "kernel32" fn ExitThread(windows.DWORD) noreturn; }; @@ -3882,7 +3882,7 @@ pub fn tagName(comptime Enum: type, value: Enum) ?[:0]const u8 { if (@intFromEnum(value) == f.value) break f.name; } else null; } -extern "C" fn Bun__ramSize() usize; +extern "c" fn Bun__ramSize() usize; pub fn getTotalMemorySize() usize { return Bun__ramSize(); } @@ -4289,7 +4289,7 @@ pub const StackCheck = struct { Bun__StackCheck__initialize(); } - extern "C" fn Bun__StackCheck__getMaxStack() usize; + extern "c" fn Bun__StackCheck__getMaxStack() usize; fn getStackEnd() usize { return Bun__StackCheck__getMaxStack(); } diff --git a/src/c.zig b/src/c.zig index d21250a90529ec..3b4b59383c4220 100644 --- a/src/c.zig +++ b/src/c.zig @@ -488,11 +488,11 @@ pub fn dlopen(filename: [:0]const u8, flags: C.RTLD) ?*anyopaque { return std.c.dlopen(filename, flags); } -pub extern "C" fn Bun__ttySetMode(fd: c_int, mode: c_int) c_int; +pub extern "c" fn Bun__ttySetMode(fd: c_int, mode: c_int) c_int; -pub extern "C" fn bun_initialize_process() void; -pub extern "C" fn bun_restore_stdio() void; -pub extern "C" fn open_as_nonblocking_tty(i32, i32) i32; +pub extern "c" fn bun_initialize_process() void; +pub extern "c" fn bun_restore_stdio() void; +pub extern "c" fn open_as_nonblocking_tty(i32, i32) i32; pub extern fn strlen(ptr: [*c]const u8) usize; diff --git a/src/crash_handler.zig b/src/crash_handler.zig index 0692f384f2754d..1098ef91077660 100644 --- a/src/crash_handler.zig +++ b/src/crash_handler.zig @@ -868,7 +868,7 @@ pub fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) callconv(windows ); } -extern "C" fn gnu_get_libc_version() ?[*:0]const u8; +extern "c" fn gnu_get_libc_version() ?[*:0]const u8; pub fn printMetadata(writer: anytype) !void { if (Output.enable_ansi_colors) { diff --git a/src/darwin_c.zig b/src/darwin_c.zig index acbcf178544d6f..c2d36a4648fdc7 100644 --- a/src/darwin_c.zig +++ b/src/darwin_c.zig @@ -66,7 +66,7 @@ pub const COPYFILE_CONTINUE = @as(c_int, 0); pub const COPYFILE_SKIP = @as(c_int, 1); pub const COPYFILE_QUIT = @as(c_int, 2); -pub extern "C" fn memmem(haystack: [*]const u8, haystacklen: usize, needle: [*]const u8, needlelen: usize) ?[*]const u8; +pub extern "c" fn memmem(haystack: [*]const u8, haystacklen: usize, needle: [*]const u8, needlelen: usize) ?[*]const u8; // int clonefileat(int src_dirfd, const char * src, int dst_dirfd, const char * dst, int flags); pub extern "c" fn clonefileat(c_int, [*:0]const u8, c_int, [*:0]const u8, uint32_t: c_int) c_int; diff --git a/src/deps/uws.zig b/src/deps/uws.zig index f36ed289b36362..a56e2cbf3847fa 100644 --- a/src/deps/uws.zig +++ b/src/deps/uws.zig @@ -20,7 +20,7 @@ pub const Socket = opaque { debug("us_socket_write2({d}, {d}) = {d}", .{ first.len, second.len, rc }); return rc; } - extern "C" fn us_socket_write2(ssl: i32, *Socket, header: ?[*]const u8, len: usize, payload: ?[*]const u8, usize) i32; + extern "c" fn us_socket_write2(ssl: i32, *Socket, header: ?[*]const u8, len: usize, payload: ?[*]const u8, usize) i32; }; pub const ConnectingSocket = opaque {}; const debug = bun.Output.scoped(.uws, false); diff --git a/src/io/io.zig b/src/io/io.zig index 279fbed6251d08..2353a33b265c78 100644 --- a/src/io/io.zig +++ b/src/io/io.zig @@ -291,7 +291,7 @@ pub const Loop = struct { updateTimespec(&this.cached_now); } - extern "C" fn clock_gettime_monotonic(sec: *i64, nsec: *i64) c_int; + extern "c" fn clock_gettime_monotonic(sec: *i64, nsec: *i64) c_int; pub fn updateTimespec(timespec: *posix.timespec) void { if (comptime Environment.isLinux) { const rc = linux.clock_gettime(linux.CLOCK.MONOTONIC, timespec); diff --git a/src/js_ast.zig b/src/js_ast.zig index caf47d46d17e35..530eb4ee54ebd2 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -8527,7 +8527,7 @@ pub const Macro = struct { }); } - extern "C" fn Bun__startMacro(function: *const anyopaque, *anyopaque) void; + extern "c" fn Bun__startMacro(function: *const anyopaque, *anyopaque) void; }; }; diff --git a/src/linux_c.zig b/src/linux_c.zig index 7187f120b9afac..d8cb012fdee596 100644 --- a/src/linux_c.zig +++ b/src/linux_c.zig @@ -1,6 +1,6 @@ const std = @import("std"); const bun = @import("root").bun; -pub extern "C" fn memmem(haystack: [*]const u8, haystacklen: usize, needle: [*]const u8, needlelen: usize) ?[*]const u8; +pub extern "c" fn memmem(haystack: [*]const u8, haystacklen: usize, needle: [*]const u8, needlelen: usize) ?[*]const u8; pub const SystemErrno = enum(u8) { SUCCESS = 0, EPERM = 1, @@ -606,7 +606,7 @@ pub const RWFFlagSupport = enum(u8) { } }; -pub extern "C" fn sys_preadv2( +pub extern "c" fn sys_preadv2( fd: c_int, iov: [*]const std.posix.iovec, iovcnt: c_int, @@ -614,7 +614,7 @@ pub extern "C" fn sys_preadv2( flags: c_uint, ) isize; -pub extern "C" fn sys_pwritev2( +pub extern "c" fn sys_pwritev2( fd: c_int, iov: [*]const std.posix.iovec_const, iovcnt: c_int, @@ -630,8 +630,8 @@ pub const RENAME_NOREPLACE = 1 << 0; pub const RENAME_EXCHANGE = 1 << 1; pub const RENAME_WHITEOUT = 1 << 2; -pub extern "C" fn quick_exit(code: c_int) noreturn; -pub extern "C" fn memrchr(ptr: [*]const u8, val: c_int, len: usize) ?[*]const u8; +pub extern "c" fn quick_exit(code: c_int) noreturn; +pub extern "c" fn memrchr(ptr: [*]const u8, val: c_int, len: usize) ?[*]const u8; export fn sys_epoll_pwait2(epfd: i32, events: ?[*]std.os.linux.epoll_event, maxevents: i32, timeout: ?*const std.os.linux.timespec, sigmask: ?*const std.os.linux.sigset_t) isize { return @bitCast( diff --git a/src/main.zig b/src/main.zig index 338fc2e2432ea4..5dfc2f2bac11ef 100644 --- a/src/main.zig +++ b/src/main.zig @@ -16,8 +16,8 @@ comptime { } extern fn bun_warn_avx_missing(url: [*:0]const u8) void; -pub extern "C" var _environ: ?*anyopaque; -pub extern "C" var environ: ?*anyopaque; +pub extern "c" var _environ: ?*anyopaque; +pub extern "c" var environ: ?*anyopaque; pub fn main() void { bun.crash_handler.init(); diff --git a/src/output.zig b/src/output.zig index 47b9808cb5a8be..5f793d4c7b670b 100644 --- a/src/output.zig +++ b/src/output.zig @@ -228,7 +228,7 @@ pub const Source = struct { }; pub const Stdio = struct { - extern "C" var bun_is_stdio_null: [3]i32; + extern "c" var bun_is_stdio_null: [3]i32; pub fn isStderrNull() bool { return bun_is_stdio_null[2] == 1; diff --git a/src/shell/shell.zig b/src/shell/shell.zig index 352ca854908a4d..ce13900af1a05a 100644 --- a/src/shell/shell.zig +++ b/src/shell/shell.zig @@ -165,7 +165,7 @@ pub const ParseError = error{ Lex, }; -extern "C" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: i32) i32; +extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: i32) i32; fn setEnv(name: [*:0]const u8, value: [*:0]const u8) void { // TODO: windows diff --git a/src/sys.zig b/src/sys.zig index 1d6dc575beb23c..b90fbbbe2095c7 100644 --- a/src/sys.zig +++ b/src/sys.zig @@ -3379,7 +3379,7 @@ pub fn existsAt(fd: bun.FileDescriptor, subpath: [:0]const u8) bool { @compileError("TODO: existsAtOSPath"); } -pub extern "C" fn is_executable_file(path: [*:0]const u8) bool; +pub extern "c" fn is_executable_file(path: [*:0]const u8) bool; pub fn isExecutableFileOSPath(path: bun.OSPathSliceZ) bool { if (comptime Environment.isPosix) { From ec751159c69ba17c36faa89a511d6776bd22a6ab Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 02:40:20 -0800 Subject: [PATCH 14/29] Update typescript.md --- docs/runtime/typescript.md | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/docs/runtime/typescript.md b/docs/runtime/typescript.md index 752dc2b9b93661..d7b5f7726ef32b 100644 --- a/docs/runtime/typescript.md +++ b/docs/runtime/typescript.md @@ -58,3 +58,82 @@ export const foo = "Hello world!" ``` {% /codetabs %} + +## Experimental Decorators + +Bun supports the pre-TypeScript 5.0 experimental decorators syntax. + +```ts#hello.ts +// Simple logging decorator +function log(target: any, propertyKey: string, descriptor: PropertyDescriptor) { + const originalMethod = descriptor.value; + + descriptor.value = function(...args: any[]) { + console.log(`Calling ${propertyKey} with:`, args); + return originalMethod.apply(this, args); + }; +} + +class Example { + @log + greet(name: string) { + return `Hello ${name}!`; + } +} + +// Usage +const example = new Example(); +example.greet("world"); // Logs: "Calling greet with: ['world']" +``` + +To enable it, add `"experimentalDecorators": true` to your `tsconfig.json`: + +```jsonc#tsconfig.json +{ + "compilerOptions": { + // ... rest of your config + "experimentalDecorators": true, + }, +} +``` + +We generally don't recommend using this in new codebases, but plenty of existing codebases have come to rely on it. + +### emitDecoratorMetadata + +Bun supports `emitDecoratorMetadata` in your `tsconfig.json`. This enables emitting design-time type metadata for decorated declarations in source files. + +```ts#emit-decorator-metadata.ts +import "reflect-metadata"; + +class User { + id: number; + name: string; +} + +function Injectable(target: Function) { + // Get metadata about constructor parameters + const params = Reflect.getMetadata("design:paramtypes", target); + console.log("Dependencies:", params); // [User] +} + +@Injectable +class UserService { + constructor(private user: User) {} +} + +// Creates new UserService instance with dependencies +const container = new UserService(new User()); +``` + +To enable it, add `"emitDecoratorMetadata": true` to your `tsconfig.json`: + +```jsonc#tsconfig.json +{ + "compilerOptions": { + // ... rest of your config + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + }, +} +``` From 1ea14f483c50754ee5078bd4b8143650cad70a36 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 04:06:12 -0800 Subject: [PATCH 15/29] Introduce `bun ./index.html` (#16993) --- docs/bundler/fullstack.md | 7 +- docs/bundler/html.md | 235 ++++++++- docs/nav.ts | 2 +- src/bun.js/api/server.zig | 38 +- src/bun.js/api/server/HTMLBundle.zig | 1 + src/bun.js/bindings/HTMLEntryPoint.cpp | 41 ++ src/bun.js/javascript.zig | 24 +- src/bun.zig | 13 +- src/bun_js.zig | 5 +- src/cli.zig | 2 +- src/cli/run_command.zig | 27 +- src/js/internal/html.ts | 350 +++++++++++++ test/js/bun/http/bun-serve-html-entry.test.ts | 477 ++++++++++++++++++ test/js/bun/http/bun-serve-html.test.ts | 136 ++++- 14 files changed, 1298 insertions(+), 60 deletions(-) create mode 100644 src/bun.js/bindings/HTMLEntryPoint.cpp create mode 100644 src/js/internal/html.ts create mode 100644 test/js/bun/http/bun-serve-html-entry.test.ts diff --git a/docs/bundler/fullstack.md b/docs/bundler/fullstack.md index c6c5ad3ad9f1b9..0496899cf09cb5 100644 --- a/docs/bundler/fullstack.md +++ b/docs/bundler/fullstack.md @@ -1,6 +1,6 @@ -As of Bun v1.1.44, we've added initial support for bundling frontend apps directly in Bun's HTTP server: `Bun.serve()`. Run your frontend and backend in the same app with no extra steps. +Using `Bun.serve()`'s `static` option, you can run your frontend and backend in the same app with no extra steps. -To get started, import your HTML files and pass them to the `static` option in `Bun.serve()`. +To get started, import HTML files and pass them to the `static` option in `Bun.serve()`. ```ts import dashboard from "./dashboard.html"; @@ -33,7 +33,7 @@ const server = Bun.serve({ }, }); -console.log(`Listening on ${server.url}`) +console.log(`Listening on ${server.url}`); ``` ```bash @@ -211,6 +211,7 @@ For example, enable TailwindCSS on your routes by installing and adding the `bun ```sh $ bun add bun-plugin-tailwind ``` + ```toml#bunfig.toml [serve.static] plugins = ["bun-plugin-tailwind"] diff --git a/docs/bundler/html.md b/docs/bundler/html.md index e295a7962873ae..b62b6f601b773f 100644 --- a/docs/bundler/html.md +++ b/docs/bundler/html.md @@ -1,4 +1,4 @@ -As of Bun v1.1.43, Bun's bundler now has first-class support for HTML. Build static sites, landing pages, and web applications with zero configuration. Just point Bun at your HTML file and it handles everything else. +Bun's bundler has first-class support for HTML. Build static sites, landing pages, and web applications with zero configuration. Just point Bun at your HTML file and it handles everything else. ```html#index.html @@ -13,45 +13,221 @@ As of Bun v1.1.43, Bun's bundler now has first-class support for HTML. Build sta ``` -One command is all you need (won't be experimental after Bun v1.2): +To get started, pass HTML files to `bun`. + +{% bunDevServerTerminal alt="bun ./index.html" path="./index.html" routes="" /%} + +Bun's development server provides powerful features with zero configuration: + +- **Automatic Bundling** - Bundles and serves your HTML, JavaScript, and CSS +- **Multi-Entry Support** - Handles multiple HTML entry points and glob entry points +- **Modern JavaScript** - TypeScript & JSX support out of the box +- **Smart Configuration** - Reads `tsconfig.json` for paths, JSX options, experimental decorators, and more +- **Plugins** - Plugins for TailwindCSS and more +- **ESM & CommonJS** - Use ESM and CommonJS in your JavaScript, TypeScript, and JSX files +- **CSS Bundling & Minification** - Bundles CSS from `` tags and `@import` statements +- **Asset Management** + - Automatic copying & hashing of images and assets + - Rewrites asset paths in JavaScript, CSS, and HTML + +## Single Page Apps (SPA) + +When you pass a single .html file to Bun, Bun will use it as a fallback route for all paths. This makes it perfect for single page apps that use client-side routing: + +{% bunDevServerTerminal alt="bun index.html" path="index.html" routes="" /%} + +Your React or other SPA will work out of the box — no configuration needed. All routes like `/about`, `/users/123`, etc. will serve the same HTML file, letting your client-side router handle the navigation. + +```html#index.html + + + + My SPA + + + +
+ + +``` + +## Multi-page apps (MPA) + +Some projects have several separate routes or HTML files as entry points. To support multiple entry points, pass them all to `bun` + +{% bunDevServerTerminal alt="bun ./index.html ./about.html" path="./index.html ./about.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about.html\"}]" /%} + +This will serve: + +- `index.html` at `/` +- `about.html` at `/about` + +### Glob patterns + +To specify multiple files, you can use glob patterns that end in `.html`: + +{% bunDevServerTerminal alt="bun ./**/*.html" path="./**/*.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about.html\"}]" /%} + +### Path normalization + +The base path is chosen from the longest common prefix among all the files. + +{% bunDevServerTerminal alt="bun ./index.html ./about/index.html ./about/foo/index.html" path="./index.html ./about/index.html ./about/foo/index.html" routes="[{\"path\": \"/\", \"file\": \"./index.html\"}, {\"path\": \"/about\", \"file\": \"./about/index.html\"}, {\"path\": \"/about/foo\", \"file\": \"./about/foo/index.html\"}]" /%} + +## JavaScript, TypeScript, and JSX + +Bun's transpiler natively implements JavaScript, TypeScript, and JSX support. [Learn more about loaders in Bun](/docs/bundler/loaders). + +Bun's transpiler is also used at runtime. + +### ES Modules & CommonJS + +You can use ESM and CJS in your JavaScript, TypeScript, and JSX files. Bun will handle the transpilation and bundling automatically. + +There is no pre-build or separate optimization step. It's all done at the same time. + +Learn more about [module resolution in Bun](/docs/runtime/modules). + +## CSS + +Bun's CSS parser is also natively implemented (clocking in around 58,000 lines of Zig). + +It's also a CSS bundler. You can use `@import` in your CSS files to import other CSS files. + +For example: + +```css#styles.css +@import "./abc.css"; + +.container { + background-color: blue; +} +``` + +```css#abc.css +body { + background-color: red; +} +``` + +This outputs: + +```css#styles.css +body { + background-color: red; +} + +.container { + background-color: blue; +} +``` + +### Referencing local assets in CSS + +You can reference local assets in your CSS files. + +```css#styles.css +body { + background-image: url("./logo.png"); +} +``` + +This will copy `./logo.png` to the output directory and rewrite the path in the CSS file to include a content hash. + +```css#styles.css +body { + background-image: url("./logo-[ABC123].png"); +} +``` + +### Importing CSS in JavaScript + +To associate a CSS file with a JavaScript file, you can import it in your JavaScript file. + +```ts#app.ts +import "./styles.css"; +import "./more-styles.css"; +``` + +This generates `./app.css` and `./app.js` in the output directory. All CSS files imported from JavaScript will be bundled into a single CSS file per entry point. If you import the same CSS file from multiple JavaScript files, it will only be included once in the output CSS file. + +## Plugins + +The dev server supports plugins. + +### Tailwind CSS + +To use TailwindCSS, add the plugin to your `bunfig.toml`: + +```toml +[serve.static] +plugins = ["bun-plugin-tailwind"] +``` + +Then, reference TailwindCSS in your HTML via `` tag, `@import` in CSS, or `import` in JavaScript. + +{% codetabs %} + +```html#index.html + + +``` + +```css#styles.css +/* Import TailwindCSS in your CSS */ +@import "tailwindcss"; +``` + +```ts#app.ts +/* Import TailwindCSS in your JavaScript */ +import "tailwindcss"; +``` + +{% /codetabs %} + +Only one of those are necessary, not all three. + +## Keyboard Shortcuts + +While the server is running: + +- `o + Enter` - Open in browser +- `c + Enter` - Clear console +- `q + Enter` (or Ctrl+C) - Quit server + +## Build for Production + +When you're ready to deploy, use `bun build` to create optimized production bundles: {% codetabs %} ```bash#CLI -$ bun build ./index.html --outdir=dist +$ bun build ./index.html --minify --outdir=dist ``` ```ts#API Bun.build({ entrypoints: ["./index.html"], outdir: "./dist", + minify: { + whitespace: true, + identifiers: true, + syntax: true, + } }); ``` {% /codetabs %} -Bun automatically: +Currently, plugins are only supported through `Bun.build`'s API or through `bunfig.toml` with the frontend dev server - not yet supported in `bun build`'s CLI. -- Bundles, tree-shakes, and optimizes your JavaScript, JSX and TypeScript -- Bundles and optimizes your CSS -- Copies & hashes images and other assets -- Updates all references to local files or packages in your HTML +### Watch Mode -## Zero Config, Maximum Performance - -The HTML bundler is enabled by default after Bun v1.2+. Drop in your existing HTML files and Bun will handle: - -- **TypeScript & JSX** - Write modern JavaScript for browsers without the setup -- **CSS** - Bundle CSS stylesheets directly from `` or `@import` -- **Images & Assets** - Automatic copying & hashing & rewriting of assets in JavaScript, CSS, and HTML - -## Watch mode - -You can run `bun build --watch` to watch for changes and rebuild automatically. +You can run `bun build --watch` to watch for changes and rebuild automatically. This works nicely for library development. You've never seen a watch mode this fast. -## Plugin API +### Plugin API Need more control? Configure the bundler through the JavaScript API and use Bun's builtin `HTMLRewriter` to preprocess HTML. @@ -102,3 +278,22 @@ Bun automatically handles all common web assets: - Any `` tag with an `href` attribute pointing to a local file is rewritten to the new path, and hashed All paths are resolved relative to your HTML file, making it easy to organize your project however you want. + +## This is a work in progress + +- No HMR support yet +- Need more plugins +- Need more configuration options for things like asset handling +- Need a way to configure CORS, headers, etc. + +If you want to submit a PR, most of the [code is here](https://github.com/oven-sh/bun/blob/main/src/js/internal/html.ts). You could even copy paste that file into your project and use it as a starting point. + +## How this works + +This is a small wrapper around Bun's support for HTML imports in JavaScript. + +### Adding a backend to your frontend + +To add a backend to your frontend, you can use the `"static"` option in `Bun.serve`. + +Learn more in [the full-stack docs](/docs/bundler/fullstack). diff --git a/docs/nav.ts b/docs/nav.ts index 615c1ce7df4af7..ff4f803e34e9f6 100644 --- a/docs/nav.ts +++ b/docs/nav.ts @@ -214,7 +214,7 @@ export default { page("bundler", "`Bun.build`", { description: "Bundle code for consumption in the browser with Bun's native bundler.", }), - page("bundler/html", "HTML", { + page("bundler/html", "Frontend & static sites", { description: `Bundle html files with Bun's native bundler.`, }), page("bundler/fullstack", "Fullstack Dev Server", { diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 304f30fbece051..6b04ccd5ae3439 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -1110,7 +1110,7 @@ pub const ServerConfig = struct { var port = args.address.tcp.port; if (arguments.vm.transpiler.options.transform_options.origin) |origin| { - args.base_uri = origin; + args.base_uri = try bun.default_allocator.dupeZ(u8, origin); } defer { @@ -1150,16 +1150,15 @@ pub const ServerConfig = struct { while (try iter.next()) |key| { const path, const is_ascii = key.toOwnedSliceReturningAllASCII(bun.default_allocator) catch bun.outOfMemory(); + errdefer bun.default_allocator.free(path); const value = iter.value; - if (path.len == 0 or path[0] != '/') { - bun.default_allocator.free(path); + if (path.len == 0 or (path[0] != '/' and path[0] != '*')) { return global.throwInvalidArguments("Invalid static route \"{s}\". path must start with '/'", .{path}); } if (!is_ascii) { - bun.default_allocator.free(path); return global.throwInvalidArguments("Invalid static route \"{s}\". Please encode all non-ASCII characters in the path.", .{path}); } @@ -1219,6 +1218,9 @@ pub const ServerConfig = struct { if (sliced.len > 0) { defer sliced.deinit(); + if (args.base_uri.len > 0) { + bun.default_allocator.free(@constCast(args.base_uri)); + } args.base_uri = bun.default_allocator.dupe(u8, sliced.slice()) catch unreachable; } } @@ -1413,6 +1415,8 @@ pub const ServerConfig = struct { const protocol: string = if (args.ssl_config != null) "https" else "http"; const hostname = args.base_url.hostname; const needsBrackets: bool = strings.isIPV6Address(hostname) and hostname[0] != '['; + const original_base_uri = args.base_uri; + defer bun.default_allocator.free(@constCast(original_base_uri)); if (needsBrackets) { args.base_uri = (if ((port == 80 and args.ssl_config == null) or (port == 443 and args.ssl_config != null)) std.fmt.allocPrint(bun.default_allocator, "{s}://[{s}]/{s}", .{ @@ -7449,8 +7453,30 @@ pub fn NewServer(comptime NamespaceType: type, comptime ssl_enabled_: bool, comp if (this.dev_server) |dev| { dev.attachRoutes(this) catch bun.outOfMemory(); } else { - bun.assert(this.config.onRequest != .zero); - app.any("/*", *ThisServer, this, onRequest); + const @"has /*" = brk: { + for (this.config.static_routes.items) |route| { + if (strings.eqlComptime(route.path, "/*")) { + break :brk true; + } + } + + break :brk false; + }; + + // "/*" routes are added backwards, so if they have a static route, it will never be matched + // so we need to check for that first + if (!@"has /*") { + bun.assert(this.config.onRequest != .zero); + app.any("/*", *ThisServer, this, onRequest); + } else if (this.config.onRequest != .zero) { + app.post("/*", *ThisServer, this, onRequest); + app.put("/*", *ThisServer, this, onRequest); + app.patch("/*", *ThisServer, this, onRequest); + app.delete("/*", *ThisServer, this, onRequest); + app.options("/*", *ThisServer, this, onRequest); + app.trace("/*", *ThisServer, this, onRequest); + app.connect("/*", *ThisServer, this, onRequest); + } } } diff --git a/src/bun.js/api/server/HTMLBundle.zig b/src/bun.js/api/server/HTMLBundle.zig index 39bc5ac5198442..a35407720698fa 100644 --- a/src/bun.js/api/server/HTMLBundle.zig +++ b/src/bun.js/api/server/HTMLBundle.zig @@ -68,6 +68,7 @@ pub const HTMLBundleRoute = struct { } pub fn init(html_bundle: *HTMLBundle) *HTMLBundleRoute { + html_bundle.ref(); return HTMLBundleRoute.new(.{ .html_bundle = html_bundle, .pending_responses = .{}, diff --git a/src/bun.js/bindings/HTMLEntryPoint.cpp b/src/bun.js/bindings/HTMLEntryPoint.cpp new file mode 100644 index 00000000000000..c805fea3f0373a --- /dev/null +++ b/src/bun.js/bindings/HTMLEntryPoint.cpp @@ -0,0 +1,41 @@ +#include "root.h" + +#include "JavaScriptCore/CallData.h" +#include +#include "InternalModuleRegistry.h" +#include "ModuleLoader.h" +#include "ZigGlobalObject.h" +#include + +namespace Bun { +using namespace JSC; +extern "C" JSInternalPromise* Bun__loadHTMLEntryPoint(Zig::GlobalObject* globalObject) +{ + auto& vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + JSInternalPromise* promise = JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); + + JSValue htmlModule = globalObject->internalModuleRegistry()->requireId(globalObject, vm, InternalModuleRegistry::InternalHtml); + if (UNLIKELY(scope.exception())) { + return promise->rejectWithCaughtException(globalObject, scope); + } + + JSObject* htmlModuleObject = htmlModule.getObject(); + if (UNLIKELY(!htmlModuleObject)) { + BUN_PANIC("Failed to load HTML entry point"); + } + + MarkedArgumentBuffer args; + JSValue result = JSC::call(globalObject, htmlModuleObject, args, "Failed to load HTML entry point"_s); + if (UNLIKELY(scope.exception())) { + return promise->rejectWithCaughtException(globalObject, scope); + } + + promise = jsDynamicCast(result); + if (UNLIKELY(!promise)) { + BUN_PANIC("Failed to load HTML entry point"); + } + return promise; +} + +} diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index d4667d97282669..a5c975c2e9f40d 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -766,6 +766,7 @@ pub const VirtualMachine = struct { console: *ConsoleObject, log: *logger.Log, main: string = "", + main_is_html_entrypoint: bool = false, main_resolved_path: bun.String = bun.String.empty, main_hash: u32 = 0, process: bun.JSC.C.JSObjectRef = null, @@ -3098,6 +3099,8 @@ pub const VirtualMachine = struct { } } + extern fn Bun__loadHTMLEntryPoint(global: *JSGlobalObject) *JSInternalPromise; + pub fn reloadEntryPoint(this: *VirtualMachine, entry_path: []const u8) !*JSInternalPromise { this.has_loaded = false; this.main = entry_path; @@ -3105,13 +3108,14 @@ pub const VirtualMachine = struct { try this.ensureDebugger(true); - try this.entry_point.generate( - this.allocator, - this.bun_watcher != .none, - entry_path, - main_file_name, - ); - this.eventLoop().ensureWaker(); + if (!this.main_is_html_entrypoint) { + try this.entry_point.generate( + this.allocator, + this.bun_watcher != .none, + entry_path, + main_file_name, + ); + } if (!this.transpiler.options.disable_transpilation) { if (try this.loadPreloads()) |promise| { @@ -3121,7 +3125,11 @@ pub const VirtualMachine = struct { return promise; } - const promise = JSModuleLoader.loadAndEvaluateModule(this.global, &String.init(main_file_name)) orelse return error.JSError; + const promise = if (!this.main_is_html_entrypoint) + JSModuleLoader.loadAndEvaluateModule(this.global, &String.init(main_file_name)) orelse return error.JSError + else + Bun__loadHTMLEntryPoint(this.global); + this.pending_internal_promise = promise; JSValue.fromCell(promise).ensureStillAlive(); return promise; diff --git a/src/bun.zig b/src/bun.zig index d1e54e51fff787..e6a9b97dde0f1e 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -3164,11 +3164,18 @@ pub fn NewRefCounted(comptime T: type, comptime deinit_fn: ?fn (self: *T) void, } pub fn deref(self: *T) void { - if (Environment.isDebug) log("0x{x} deref {d} - 1 = {d}", .{ @intFromPtr(self), self.ref_count, self.ref_count - 1 }); + const ref_count = self.ref_count; + if (Environment.isDebug) { + if (ref_count == 0 or ref_count == std.math.maxInt(@TypeOf(ref_count))) { + @panic("Use after-free detected on " ++ output_name); + } + } - self.ref_count -= 1; + if (Environment.isDebug) log("0x{x} deref {d} - 1 = {d}", .{ @intFromPtr(self), ref_count, ref_count - 1 }); - if (self.ref_count == 0) { + self.ref_count = ref_count - 1; + + if (ref_count == 1) { if (comptime deinit_fn) |deinit| { deinit(self); } else { diff --git a/src/bun_js.zig b/src/bun_js.zig index 904c16d0388a3e..0a96ee2a1b3bc2 100644 --- a/src/bun_js.zig +++ b/src/bun_js.zig @@ -42,6 +42,7 @@ pub const Run = struct { entry_path: string, arena: Arena, any_unhandled: bool = false, + is_html_entrypoint: bool = false, pub fn bootStandalone(ctx: Command.Context, entry_path: string, graph: bun.StandaloneModuleGraph) !void { JSC.markBinding(@src()); @@ -170,7 +171,7 @@ pub const Run = struct { return bun.shell.Interpreter.initAndRunFromFile(ctx, mini, entry_path); } - pub fn boot(ctx: Command.Context, entry_path: string) !void { + pub fn boot(ctx: Command.Context, entry_path: string, loader: ?bun.options.Loader) !void { JSC.markBinding(@src()); if (!ctx.debug.loaded_bunfig) { @@ -277,6 +278,8 @@ pub const Run = struct { doPreconnect(ctx.runtime_options.preconnect); + vm.main_is_html_entrypoint = (loader orelse vm.transpiler.options.loader(std.fs.path.extension(entry_path))) == .html; + const callback = OpaqueWrap(Run, Run.start); vm.global.vm().holdAPILock(&run, callback); } diff --git a/src/cli.zig b/src/cli.zig index 54a05dad0ced89..721ba19eb3705f 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -2196,7 +2196,7 @@ pub const Command = struct { var entry_point_buf: [bun.MAX_PATH_BYTES + trigger.len]u8 = undefined; const cwd = try std.posix.getcwd(&entry_point_buf); @memcpy(entry_point_buf[cwd.len..][0..trigger.len], trigger); - try BunJS.Run.boot(ctx, entry_point_buf[0 .. cwd.len + trigger.len]); + try BunJS.Run.boot(ctx, entry_point_buf[0 .. cwd.len + trigger.len], null); return; } diff --git a/src/cli/run_command.zig b/src/cli/run_command.zig index d7ae1c799c9ef4..ec7ba403c8a67d 100644 --- a/src/cli/run_command.zig +++ b/src/cli/run_command.zig @@ -1262,9 +1262,9 @@ pub const RunCommand = struct { Output.flush(); } - fn _bootAndHandleError(ctx: Command.Context, path: string) bool { + fn _bootAndHandleError(ctx: Command.Context, path: string, loader: ?bun.options.Loader) bool { Global.configureAllocator(.{ .long_running = true }); - Run.boot(ctx, ctx.allocator.dupe(u8, path) catch return false) catch |err| { + Run.boot(ctx, ctx.allocator.dupe(u8, path) catch return false, loader) catch |err| { ctx.log.print(Output.errorWriter()) catch {}; Output.prettyErrorln("error: Failed to run {s} due to error {s}", .{ @@ -1348,7 +1348,7 @@ pub const RunCommand = struct { bun.CLI.Arguments.loadConfigPath(ctx.allocator, true, "bunfig.toml", ctx, .RunCommand) catch {}; } - _ = _bootAndHandleError(ctx, absolute_script_path.?); + _ = _bootAndHandleError(ctx, absolute_script_path.?, null); return true; } pub fn exec( @@ -1441,7 +1441,7 @@ pub const RunCommand = struct { @memcpy(entry_point_buf[cwd.len..][0..trigger.len], trigger); const entry_path = entry_point_buf[0 .. cwd.len + trigger.len]; - Run.boot(ctx, ctx.allocator.dupe(u8, entry_path) catch return false) catch |err| { + Run.boot(ctx, ctx.allocator.dupe(u8, entry_path) catch return false, null) catch |err| { ctx.log.print(Output.errorWriter()) catch {}; Output.prettyErrorln("error: Failed to run {s} due to error {s}", .{ @@ -1528,13 +1528,20 @@ pub const RunCommand = struct { var resolved_mutable = resolved; const path = resolved_mutable.path().?; const loader: bun.options.Loader = this_transpiler.options.loaders.get(path.name.ext) orelse .tsx; - if (loader.canBeRunByBun()) { + if (loader.canBeRunByBun() or loader == .html) { log("Resolved to: `{s}`", .{path.text}); - return _bootAndHandleError(ctx, path.text); + return _bootAndHandleError(ctx, path.text, loader); } else { log("Resolved file `{s}` but ignoring because loader is {s}", .{ path.text, @tagName(loader) }); } - } else |_| {} + } else |_| { + // Support globs for HTML entry points. + if (strings.hasSuffixComptime(target_name, ".html")) { + if (strings.containsChar(target_name, '*')) { + return _bootAndHandleError(ctx, target_name, .html); + } + } + } // execute a node_modules/.bin/ command, or (run only) a system command like 'ls' @@ -1623,7 +1630,7 @@ pub const RunCommand = struct { var entry_point_buf: [bun.MAX_PATH_BYTES + trigger.len]u8 = undefined; const cwd = try std.posix.getcwd(&entry_point_buf); @memcpy(entry_point_buf[cwd.len..][0..trigger.len], trigger); - try Run.boot(ctx, entry_point_buf[0 .. cwd.len + trigger.len]); + try Run.boot(ctx, entry_point_buf[0 .. cwd.len + trigger.len], null); return; } @@ -1653,7 +1660,7 @@ pub const RunCommand = struct { ); }; - Run.boot(ctx, normalized_filename) catch |err| { + Run.boot(ctx, normalized_filename, null) catch |err| { ctx.log.print(Output.errorWriter()) catch {}; Output.err(err, "Failed to run script \"{s}\"", .{std.fs.path.basename(normalized_filename)}); @@ -1728,7 +1735,7 @@ pub const BunXFastPath = struct { bun.reinterpretSlice(u8, &direct_launch_buffer), wpath, ) catch return; - Run.boot(ctx, utf8) catch |err| { + Run.boot(ctx, utf8, null) catch |err| { ctx.log.print(Output.errorWriter()) catch {}; Output.err(err, "Failed to run bin \"{s}\"", .{std.fs.path.basename(utf8)}); Global.exit(1); diff --git a/src/js/internal/html.ts b/src/js/internal/html.ts new file mode 100644 index 00000000000000..d01fdf8d027d58 --- /dev/null +++ b/src/js/internal/html.ts @@ -0,0 +1,350 @@ +// This is the file that loads when you pass a, .html entry point to Bun. +import type { HTMLBundle, Server } from "bun"; +const initital = performance.now(); +const argv = process.argv; + +// `import` cannot be used in this file and only Bun builtin modules can be used. +const path = require("node:path"); + +const env = Bun.env; + +// This function is called at startup. +async function start() { + let args: string[] = []; + const cwd = process.cwd(); + let hostname = "localhost"; + let port: number | undefined = undefined; + + // Step 1. Resolve all HTML entry points + for (let i = 1, argvLength = argv.length; i < argvLength; i++) { + const arg = argv[i]; + + if (!arg.endsWith(".html")) { + if (arg.startsWith("--hostname=")) { + hostname = arg.slice("--hostname=".length); + if (hostname.includes(":")) { + const [host, portString] = hostname.split(":"); + hostname = host; + port = parseInt(portString, 10); + } + } else if (arg.startsWith("--port=")) { + port = parseInt(arg.slice("--port=".length), 10); + } else if (arg.startsWith("--host=")) { + hostname = arg.slice("--host=".length); + if (hostname.includes(":")) { + const [host, portString] = hostname.split(":"); + hostname = host; + port = parseInt(portString, 10); + } + } + + if (arg === "--help") { + console.log(` +Bun v${Bun.version} (html) + +Usage: + bun [...html-files] [options] + +Options: + + --port= + --host=, --hostname= + +Examples: + + bun index.html + bun ./index.html ./about.html --port=3000 + bun index.html --host=localhost:3000 + bun index.html --hostname=localhost:3000 + bun ./*.html + +This is a small wrapper around Bun.serve() that automatically serves the HTML files you pass in without +having to manually call Bun.serve() or write the boilerplate yourself. This runs Bun's bundler on +the HTML files, their JavaScript, and CSS, and serves them up. This doesn't do anything you can't do +yourself with Bun.serve(). +`); + process.exit(0); + } + + continue; + } + + if (arg.includes("*") || arg.includes("**") || arg.includes("{")) { + const glob = new Bun.Glob(arg); + + for (const file of glob.scanSync(cwd)) { + let resolved = path.resolve(cwd, file); + try { + resolved = Bun.resolveSync(resolved, cwd); + } catch { + resolved = Bun.resolveSync("./" + resolved, cwd); + } + + args.push(resolved); + } + } else { + let resolved = arg; + try { + resolved = Bun.resolveSync(arg, cwd); + } catch { + resolved = Bun.resolveSync("./" + arg, cwd); + } + + args.push(resolved); + } + + if (args.length > 1) { + args = [...new Set(args)]; + } + } + + if (args.length === 0) { + throw new Error("No HTML files found matching " + JSON.stringify(Bun.main)); + } + + // Add cwd to find longest common path + let needsPop = false; + if (args.length === 1) { + args.push(process.cwd()); + needsPop = true; + } + + // Find longest common path prefix to use as the base path when there are + // multiple entry points + let longestCommonPath = args.reduce((acc, curr) => { + if (!acc) return curr; + let i = 0; + while (i < acc.length && i < curr.length && acc[i] === curr[i]) i++; + return acc.slice(0, i); + }); + + if (path.platform === "win32") { + longestCommonPath = longestCommonPath.replaceAll("\\", "/"); + } + + if (needsPop) { + // Remove cwd from args + args.pop(); + } + + // Transform file paths into friendly URL paths + // - "index.html" -> "/" + // - "about/index.html" -> "/about" + // - "about/foo.html" -> "/about/foo" + // - "foo.html" -> "/foo" + const servePaths = args.map(arg => { + if (process.platform === "win32") { + arg = arg.replaceAll("\\", "/"); + } + const basename = path.basename(arg); + const isIndexHtml = basename === "index.html"; + + let servePath = arg; + if (servePath.startsWith(longestCommonPath)) { + servePath = servePath.slice(longestCommonPath.length); + } else { + const relative = path.relative(longestCommonPath, servePath); + if (!relative.startsWith("..")) { + servePath = relative; + } + } + + if (isIndexHtml && servePath.length === 0) { + servePath = "/"; + } else if (isIndexHtml) { + servePath = servePath.slice(0, -"index.html".length); + } + + if (servePath.endsWith(".html")) { + servePath = servePath.slice(0, -".html".length); + } + + if (servePath.endsWith("/")) { + servePath = servePath.slice(0, -1); + } + + if (servePath.startsWith("/")) { + servePath = servePath.slice(1); + } + + if (servePath === "/") servePath = ""; + + return servePath; + }); + + const htmlImports = await Promise.all( + args.map(arg => { + return import(arg).then(m => m.default); + }), + ); + + // If you're only providing one entry point, then match everything to it. + // (except for assets, which have higher precedence) + if (htmlImports.length === 1 && servePaths[0] === "") { + servePaths[0] = "*"; + } + + const staticRoutes = htmlImports.reduce( + (acc, htmlImport, index) => { + const html = htmlImport; + const servePath = servePaths[index]; + + acc["/" + servePath] = html; + return acc; + }, + {} as Record, + ); + var server: Server; + getServer: { + try { + server = Bun.serve({ + static: staticRoutes, + development: env.NODE_ENV !== "production", + + hostname, + port, + + // use the default port via existing port detection code. + // port: 3000, + + fetch(req: Request) { + return new Response("Not found", { status: 404 }); + }, + }); + break getServer; + } catch (error: any) { + if (error?.code === "EADDRINUSE") { + let defaultPort = port || parseInt(env.PORT || env.BUN_PORT || env.NODE_PORT || "3000", 10); + for (let remainingTries = 5; remainingTries > 0; remainingTries--) { + try { + server = Bun.serve({ + static: staticRoutes, + development: env.NODE_ENV !== "production", + + hostname, + + // Retry with a different port up to 4 times. + port: defaultPort++, + + fetch(req: Request) { + return new Response("Not found", { status: 404 }); + }, + }); + break getServer; + } catch (error: any) { + if (error?.code === "EADDRINUSE") { + continue; + } + throw error; + } + } + } + + throw error; + } + } + const elapsed = (performance.now() - initital).toFixed(2); + const enableANSIColors = Bun.enableANSIColors; + function printInitialMessage(isFirst: boolean) { + if (enableANSIColors) { + let topLine = `\n\x1b[1;34m\x1b[5mBun\x1b[0m \x1b[1;34mv${Bun.version}\x1b[0m`; + if (isFirst) { + topLine += ` \x1b[2mready in\x1b[0m \x1b[1m${elapsed}\x1b[0m ms`; + } + console.log(topLine + "\n"); + console.log(`\x1b[1;34m➜\x1b[0m \x1b[36m${server!.url.href}\x1b[0m`); + } else { + let topLine = `\n Bun v${Bun.version}`; + if (isFirst) { + topLine += ` ready in ${elapsed} ms`; + } + console.log(topLine + "\n"); + console.log(`url: ${server!.url.href}`); + } + if (htmlImports.length > 1 || (servePaths[0] !== "" && servePaths[0] !== "*")) { + console.log("\nRoutes:"); + + const pairs: { route: string; importPath: string }[] = []; + + for (let i = 0, length = servePaths.length; i < length; i++) { + const route = servePaths[i]; + const importPath = args[i]; + pairs.push({ route, importPath }); + } + pairs.sort((a, b) => { + if (b.route === "") return 1; + if (a.route === "") return -1; + return a.route.localeCompare(b.route); + }); + for (let i = 0, length = pairs.length; i < length; i++) { + const { route, importPath } = pairs[i]; + const isLast = i === length - 1; + const prefix = isLast ? " └── " : " ├── "; + if (enableANSIColors) { + console.log(`${prefix}\x1b[36m/${route}\x1b[0m \x1b[2m→ ${path.relative(process.cwd(), importPath)}\x1b[0m`); + } else { + console.log(`${prefix}/${route} → ${path.relative(process.cwd(), importPath)}`); + } + } + } + + if (isFirst && process.stdin.isTTY) { + if (enableANSIColors) { + console.log(); + console.log("\x1b[2mPress \x1b[2;36mh + Enter\x1b[39;2m to show shortcuts\x1b[0m"); + } else { + console.log(); + console.log("Press h + Enter to show shortcuts"); + } + } + } + + printInitialMessage(true); + + // Keyboard shortcuts + if (process.stdin.isTTY) { + // Handle Ctrl+C and other termination signals + process.on("SIGINT", () => process.exit()); + process.on("SIGHUP", () => process.exit()); + process.on("SIGTERM", () => process.exit()); + process.stdin.on("data", data => { + const key = data.toString().toLowerCase().replaceAll("\r\n", "\n"); + + switch (key) { + case "\x03": // Ctrl+C + case "q\n": + process.exit(); + break; + + case "c\n": + console.clear(); + printInitialMessage(false); + break; + + case "o\n": + const url = server.url.toString(); + + if (process.platform === "darwin") { + // TODO: copy the AppleScript from create-react-app or Vite. + Bun.spawn(["open", url]).exited.catch(() => {}); + } else if (process.platform === "win32") { + Bun.spawn(["start", url]).exited.catch(() => {}); + } else { + Bun.spawn(["xdg-open", url]).exited.catch(() => {}); + } + break; + + case "h\n": + console.clear(); + printInitialMessage(false); + console.log("\n Shortcuts\x1b[2m:\x1b[0m\n"); + console.log(" \x1b[2m→\x1b[0m \x1b[36mc + Enter\x1b[0m clear screen"); + console.log(" \x1b[2m→\x1b[0m \x1b[36mo + Enter\x1b[0m open in browser"); + console.log(" \x1b[2m→\x1b[0m \x1b[36mq + Enter\x1b[0m quit (or Ctrl+C)\n"); + break; + } + }); + } +} + +export default start; diff --git a/test/js/bun/http/bun-serve-html-entry.test.ts b/test/js/bun/http/bun-serve-html-entry.test.ts new file mode 100644 index 00000000000000..250629671db154 --- /dev/null +++ b/test/js/bun/http/bun-serve-html-entry.test.ts @@ -0,0 +1,477 @@ +import type { Subprocess, Server } from "bun"; +import { describe, test, expect } from "bun:test"; +import { bunEnv, bunExe, tempDirWithFiles } from "harness"; +import { join } from "path"; + +async function getServerUrl(process: Subprocess) { + // Read the port number from stdout + const decoder = new TextDecoder(); + let serverUrl = ""; + let text = ""; + for await (const chunk of process.stdout) { + const textChunk = decoder.decode(chunk, { stream: true }); + text += textChunk; + console.log(textChunk); + + if (text.includes("http://")) { + serverUrl = text.trim(); + serverUrl = serverUrl.slice(serverUrl.indexOf("http://")); + + serverUrl = serverUrl.slice(0, serverUrl.indexOf("\n")); + if (URL.canParse(serverUrl)) { + break; + } + + serverUrl = serverUrl.slice(0, serverUrl.indexOf("/n")); + serverUrl = serverUrl.slice(0, serverUrl.lastIndexOf("/")); + serverUrl = serverUrl.trim(); + + if (URL.canParse(serverUrl)) { + break; + } + } + } + + if (!serverUrl) { + throw new Error("Could not find server URL in stdout"); + } + + return serverUrl; +} + +test("bun ./index.html", async () => { + const dir = tempDirWithFiles("html-entry-test", { + "index.html": /*html*/ ` + + + + HTML Entry Test + + + + +
+

Hello from Bun!

+ +
+ + + `, + "styles.css": /*css*/ ` + .container { + max-width: 800px; + margin: 2rem auto; + text-align: center; + font-family: system-ui, sans-serif; + } + + button { + padding: 0.5rem 1rem; + font-size: 1.25rem; + border-radius: 0.25rem; + border: 2px solid #000; + background: #fff; + cursor: pointer; + transition: all 0.2s; + } + + button:hover { + background: #000; + color: #fff; + } + `, + "app.js": /*js*/ ` + const button = document.getElementById('counter'); + let count = 0; + button.addEventListener('click', () => { + count++; + button.textContent = \`Click me: \${count}\`; + }); + `, + }); + + // Start the server by running bun with the HTML file + await using process = Bun.spawn({ + cmd: [bunExe(), "index.html", "--port=0"], + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + cwd: dir, + stdout: "pipe", + }); + + const serverUrl = await getServerUrl(process); + + try { + // Make a request to the server using the detected URL + const response = await fetch(serverUrl); + expect(response.status).toBe(200); + expect(response.headers.get("content-type")).toContain("text/html"); + + const html = await response.text(); + + // Verify the HTML content + expect(html).toContain("HTML Entry Test"); + expect(html).toContain('
'); + + // The bundler should have processed the CSS and JS files and injected them + expect(html).toMatch(//); + expect(html).toMatch(/ + + +
+

Welcome Home

+ About + +
+ + + `, + "about.html": /*html*/ ` + + + + About Page + + + + +
+

About Us

+ Home +

This is the about page

+
+ + + `, + "styles.css": /*css*/ ` + .container { + max-width: 800px; + margin: 2rem auto; + text-align: center; + font-family: system-ui, sans-serif; + } + a { + display: block; + margin: 1rem 0; + color: blue; + } + `, + "home.js": /*js*/ ` + const button = document.getElementById('counter'); + let count = 0; + button.addEventListener('click', () => { + count++; + button.textContent = \`Click me: \${count}\`; + }); + `, + "about.js": /*js*/ ` + const message = document.getElementById('message'); + message.textContent += " - Updated via JS"; + `, + }); + + // Start the server by running bun with multiple HTML files + await using process = Bun.spawn({ + cmd: [bunExe(), "index.html", "about.html", "--port=0"], + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + cwd: dir, + stdout: "pipe", + }); + + const serverUrl = await getServerUrl(process); + + if (!serverUrl) { + throw new Error("Could not find server URL in stdout"); + } + + try { + // Test the home page + + const homeResponse = await fetch(serverUrl); + expect(homeResponse.status).toBe(200); + expect(homeResponse.headers.get("content-type")).toContain("text/html"); + + const homeHtml = await homeResponse.text(); + expect(homeHtml).toContain("Home Page"); + expect(homeHtml).toContain('About'); + expect(homeHtml).toMatch(/ + + + +
+

Welcome Home

+ +
+ + + `, + "about.html": /*html*/ ` + + + + About Page + + + + + +
+

About Us

+

This is the about page

+
+ + + `, + "contact.html": /*html*/ ` + + + + Contact Page + + + + + +
+

Contact Us

+
+ + +
+
+ + + `, + "shared.css": /*css*/ ` + nav { + padding: 1rem; + background: #f0f0f0; + text-align: center; + } + nav a { + margin: 0 1rem; + color: blue; + } + .container { + max-width: 800px; + margin: 2rem auto; + text-align: center; + font-family: system-ui, sans-serif; + } + form { + display: flex; + flex-direction: column; + gap: 1rem; + max-width: 300px; + margin: 0 auto; + } + input, button { + padding: 0.5rem; + font-size: 1rem; + } + `, + "home.js": /*js*/ ` + const button = document.getElementById('counter'); + let count = 0; + button.addEventListener('click', () => { + count++; + button.textContent = \`Click me: \${count}\`; + }); + `, + "about.js": /*js*/ ` + const message = document.getElementById('message'); + message.textContent += " - Updated via JS"; + `, + "contact.js": /*js*/ ` + const form = document.getElementById('contact-form'); + form.addEventListener('submit', (e) => { + e.preventDefault(); + const input = form.querySelector('input'); + alert(\`Thanks for your message, \${input.value}!\`); + input.value = ''; + }); + `, + // Add a non-HTML file to verify it's not picked up + "README.md": "# Test Project\nThis file should be ignored by the glob.", + }); + + // Start the server using glob pattern + await using process = Bun.spawn({ + cmd: [bunExe(), "*.html", "--port=0"], + env: { + ...bunEnv, + NODE_ENV: undefined, + }, + cwd: dir, + stdout: "pipe", + }); + console.log({ cwd: dir }); + const serverUrl = await getServerUrl(process); + + try { + // Test all three pages are served + const pages = ["", "about", "contact"]; + const titles = ["Home Page", "About Page", "Contact Page"]; + + for (const [i, route] of pages.entries()) { + const response = await fetch(new URL(route, serverUrl).href); + expect(response.status).toBe(200); + expect(response.headers.get("content-type")).toContain("text/html"); + + const html = await response.text(); + expect(html).toContain(`${titles[i]}`); + expect(html).toMatch(/ + + + `, + "error.js": /*js*/ ` + throw new Error("Error on purpose"); + `, + }); + async function getServers() { + const path = join(dir, "index.html"); + + const { default: html } = await import(path); + let servers: Server[] = []; + for (let i = 0; i < 10; i++) { + servers.push( + Bun.serve({ + port: 0, + static: { + "/": html, + }, + development: true, + fetch(req) { + return new Response("Not found", { status: 404 }); + }, + }), + ); + } + + delete require.cache[path]; + + return servers; + } + + { + let servers = await getServers(); + Bun.gc(); + await Bun.sleep(1); + for (const server of servers) { + await server.stop(true); + } + servers = []; + Bun.gc(); + } + + Bun.gc(true); +}); + +test("wildcard static routes", async () => { + const dir = tempDirWithFiles("bun-serve-html-error-handling", { + "index.html": /*html*/ ` + + + + + + Error Page +

Error Page

+ + + + `, + "error.js": /*js*/ ` + throw new Error("Error on purpose"); + `, + }); + const { default: html } = await import(join(dir, "index.html")); + for (let development of [true, false]) { + using server = Bun.serve({ + port: 0, + static: { + "/*": html, + }, + development, + fetch(req) { + return new Response("Not found", { status: 404 }); + }, + }); + + for (let url of [server.url, new URL("/potato", server.url)]) { + const response = await fetch(url); + expect(response.status).toBe(200); + expect(response.headers.get("content-type")).toContain("text/html"); + const text = await response.text(); + expect(text).toContain("Error Page"); + } + } +}); From 97ae35dfdef19a152820d569fe83f229374eb26b Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 04:05:36 -0800 Subject: [PATCH 16/29] Update html.md --- docs/bundler/html.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/bundler/html.md b/docs/bundler/html.md index b62b6f601b773f..0edee9835f3358 100644 --- a/docs/bundler/html.md +++ b/docs/bundler/html.md @@ -157,7 +157,14 @@ The dev server supports plugins. ### Tailwind CSS -To use TailwindCSS, add the plugin to your `bunfig.toml`: +To use TailwindCSS, install the `bun-plugin-tailwind` plugin: + +```bash +# Or any npm client +$ bun install --dev bun-plugin-tailwind +``` + +Then, add the plugin to your `bunfig.toml`: ```toml [serve.static] From 9cfa3a558b7f76c46e9e4355cdde3556e0ded4e9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 07:15:33 -0800 Subject: [PATCH 17/29] Bump --- LATEST | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LATEST b/LATEST index cb174d58a5349f..d2d61a7e8e4372 100644 --- a/LATEST +++ b/LATEST @@ -1 +1 @@ -1.2.1 \ No newline at end of file +1.2.2 \ No newline at end of file diff --git a/package.json b/package.json index ef4a27cf7ea47e..45c9ed7b50a362 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "bun", - "version": "1.2.2", + "version": "1.2.3", "workspaces": [ "./packages/bun-types" ], From 7bef46225777301fdd74d0741dc983d5f99974bd Mon Sep 17 00:00:00 2001 From: Bkh <62846961+khajimatov@users.noreply.github.com> Date: Tue, 4 Feb 2025 01:28:19 +0500 Subject: [PATCH 18/29] Fix typo in html.ts (#17023) --- src/js/internal/html.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/internal/html.ts b/src/js/internal/html.ts index d01fdf8d027d58..471fd1879be9dd 100644 --- a/src/js/internal/html.ts +++ b/src/js/internal/html.ts @@ -1,6 +1,6 @@ // This is the file that loads when you pass a, .html entry point to Bun. import type { HTMLBundle, Server } from "bun"; -const initital = performance.now(); +const initial = performance.now(); const argv = process.argv; // `import` cannot be used in this file and only Bun builtin modules can be used. @@ -243,7 +243,7 @@ yourself with Bun.serve(). throw error; } } - const elapsed = (performance.now() - initital).toFixed(2); + const elapsed = (performance.now() - initial).toFixed(2); const enableANSIColors = Bun.enableANSIColors; function printInitialMessage(isFirst: boolean) { if (enableANSIColors) { From 7a918d24a73f4391e78b9b570fcda45d65466547 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 14:10:09 -0800 Subject: [PATCH 19/29] Fix loading react-jsxdev instead of react-jsx (#17013) Co-authored-by: chloe caruso --- src/bun.js/api/JSBundler.zig | 1 + src/bun.js/api/server/HTMLBundle.zig | 4 ++ src/bundler/bundle_v2.zig | 30 ++++++++--- src/crash_handler.zig | 8 ++- src/js/internal/html.ts | 10 ++-- src/js_parser.zig | 5 +- src/options.zig | 41 ++++++++++---- src/resolver/tsconfig_json.zig | 10 ++-- src/transpiler.zig | 23 ++++++-- test/bundler/transpiler/jsx-dev/jsx-dev.tsx | 37 +++++++++++++ test/bundler/transpiler/jsx-dev/tsconfig.json | 6 +++ .../transpiler/jsx-production-entry.ts | 1 + .../bundler/transpiler/jsx-production.test.ts | 36 +++++++++++++ test/bundler/transpiler/jsx-production.tsx | 37 +++++++++++++ test/bundler/transpiler/tsconfig.json | 6 +++ test/js/bun/http/bun-serve-html.test.ts | 53 +++++++++++++++++++ test/js/bun/http/jsx-runtime/app.jsx | 13 +++++ test/js/bun/http/jsx-runtime/index.html | 10 ++++ 18 files changed, 304 insertions(+), 27 deletions(-) create mode 100644 test/bundler/transpiler/jsx-dev/jsx-dev.tsx create mode 100644 test/bundler/transpiler/jsx-dev/tsconfig.json create mode 100644 test/bundler/transpiler/jsx-production-entry.ts create mode 100644 test/bundler/transpiler/jsx-production.test.ts create mode 100644 test/bundler/transpiler/jsx-production.tsx create mode 100644 test/bundler/transpiler/tsconfig.json create mode 100644 test/js/bun/http/jsx-runtime/app.jsx create mode 100644 test/js/bun/http/jsx-runtime/index.html diff --git a/src/bun.js/api/JSBundler.zig b/src/bun.js/api/JSBundler.zig index b5d4a6a6775fa7..cf6abc15f8caac 100644 --- a/src/bun.js/api/JSBundler.zig +++ b/src/bun.js/api/JSBundler.zig @@ -58,6 +58,7 @@ pub const JSBundler = struct { rootdir: OwnedString = OwnedString.initEmpty(bun.default_allocator), serve: Serve = .{}, jsx: options.JSX.Pragma = .{}, + force_node_env: options.BundleOptions.ForceNodeEnv = .unspecified, code_splitting: bool = false, minify: Minify = .{}, no_macros: bool = false, diff --git a/src/bun.js/api/server/HTMLBundle.zig b/src/bun.js/api/server/HTMLBundle.zig index a35407720698fa..5af4f1b8d2a10a 100644 --- a/src/bun.js/api/server/HTMLBundle.zig +++ b/src/bun.js/api/server/HTMLBundle.zig @@ -288,6 +288,10 @@ pub const HTMLBundleRoute = struct { if (!server.config().development) { config.define.put("process.env.NODE_ENV", "\"production\"") catch bun.outOfMemory(); + config.jsx.development = false; + } else { + config.force_node_env = .development; + config.jsx.development = true; } config.source_map = .linked; diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig index c1003b858741b8..fb9ff6757461f3 100644 --- a/src/bundler/bundle_v2.zig +++ b/src/bundler/bundle_v2.zig @@ -913,7 +913,14 @@ pub const BundleV2 = struct { task.tree_shaking = this.linker.options.tree_shaking; task.is_entry_point = is_entry_point; task.known_target = target; - task.jsx.development = this.bundlerForTarget(target).options.jsx.development; + { + const bundler = this.bundlerForTarget(target); + task.jsx.development = switch (bundler.options.force_node_env) { + .development => true, + .production => false, + .unspecified => bundler.options.jsx.development, + }; + } // Handle onLoad plugins as entry points if (!this.enqueueOnLoadPluginIfNeeded(task)) { @@ -1753,6 +1760,9 @@ pub const BundleV2 = struct { ); transpiler.options.env.behavior = config.env_behavior; transpiler.options.env.prefix = config.env_prefix.slice(); + if (config.force_node_env != .unspecified) { + transpiler.options.force_node_env = config.force_node_env; + } transpiler.options.entry_points = config.entry_points.keys(); transpiler.options.jsx = config.jsx; @@ -2875,7 +2885,11 @@ pub const BundleV2 = struct { resolve_task.secondary_path_for_commonjs_interop = secondary_path_to_copy; resolve_task.known_target = target; resolve_task.jsx = resolve_result.jsx; - resolve_task.jsx.development = this.bundlerForTarget(target).options.jsx.development; + resolve_task.jsx.development = switch (transpiler.options.force_node_env) { + .development => true, + .production => false, + .unspecified => transpiler.options.jsx.development, + }; // Figure out the loader. { @@ -3542,7 +3556,7 @@ pub const ParseTask = struct { }; }; - const debug = Output.scoped(.ParseTask, false); + const debug = Output.scoped(.ParseTask, true); pub fn init(resolve_result: *const _resolver.Result, source_index: Index, ctx: *BundleV2) ParseTask { return .{ @@ -7545,7 +7559,7 @@ pub const LinkerContext = struct { continue; } - _ = this.validateTLA(id, tla_keywords, tla_checks, input_files, import_records, flags); + _ = this.validateTLA(id, tla_keywords, tla_checks, input_files, import_records, flags, import_records_list); for (import_records) |record| { if (!record.source_index.isValid()) { @@ -11027,6 +11041,7 @@ pub const LinkerContext = struct { input_files: []Logger.Source, import_records: []ImportRecord, meta_flags: []JSMeta.Flags, + ast_import_records: []bun.BabyList(ImportRecord), ) js_ast.TlaCheck { var result_tla_check: *js_ast.TlaCheck = &tla_checks[source_index]; @@ -11038,7 +11053,7 @@ pub const LinkerContext = struct { for (import_records, 0..) |record, import_record_index| { if (Index.isValid(record.source_index) and (record.kind == .require or record.kind == .stmt)) { - const parent = c.validateTLA(record.source_index.get(), tla_keywords, tla_checks, input_files, import_records, meta_flags); + const parent = c.validateTLA(record.source_index.get(), tla_keywords, tla_checks, input_files, import_records, meta_flags, ast_import_records); if (Index.isInvalid(Index.init(parent.parent))) { continue; } @@ -11065,9 +11080,11 @@ pub const LinkerContext = struct { const parent_source_index = other_source_index; if (parent_result_tla_keyword.len > 0) { - tla_pretty_path = input_files[other_source_index].path.pretty; + const source = input_files[other_source_index]; + tla_pretty_path = source.path.pretty; notes.append(Logger.Data{ .text = std.fmt.allocPrint(c.allocator, "The top-level await in {s} is here:", .{tla_pretty_path}) catch bun.outOfMemory(), + .location = .initOrNull(&source, parent_result_tla_keyword), }) catch bun.outOfMemory(); break; } @@ -11086,6 +11103,7 @@ pub const LinkerContext = struct { input_files[parent_source_index].path.pretty, input_files[other_source_index].path.pretty, }) catch bun.outOfMemory(), + .location = .initOrNull(&input_files[parent_source_index], ast_import_records[parent_source_index].slice()[tla_checks[parent_source_index].import_record_index].range), }) catch bun.outOfMemory(); } diff --git a/src/crash_handler.zig b/src/crash_handler.zig index 1098ef91077660..982a2970a8abde 100644 --- a/src/crash_handler.zig +++ b/src/crash_handler.zig @@ -301,7 +301,13 @@ pub fn crashHandler( var trace_buf: std.builtin.StackTrace = undefined; // If a trace was not provided, compute one now - const trace = error_return_trace orelse get_backtrace: { + const trace = @as(?*std.builtin.StackTrace, if (error_return_trace) |ert| + if (ert.index > 0) + ert + else + null + else + null) orelse get_backtrace: { trace_buf = std.builtin.StackTrace{ .index = 0, .instruction_addresses = &addr_buf, diff --git a/src/js/internal/html.ts b/src/js/internal/html.ts index 471fd1879be9dd..d1f2f9cf67ef29 100644 --- a/src/js/internal/html.ts +++ b/src/js/internal/html.ts @@ -1,4 +1,5 @@ -// This is the file that loads when you pass a, .html entry point to Bun. +// This is the file that loads when you pass a '.html' entry point to Bun. +// It imports the entry points and initializes a server. import type { HTMLBundle, Server } from "bun"; const initial = performance.now(); const argv = process.argv; @@ -247,15 +248,18 @@ yourself with Bun.serve(). const enableANSIColors = Bun.enableANSIColors; function printInitialMessage(isFirst: boolean) { if (enableANSIColors) { - let topLine = `\n\x1b[1;34m\x1b[5mBun\x1b[0m \x1b[1;34mv${Bun.version}\x1b[0m`; + let topLine = `${server.development ? "\x1b[34;7m DEV \x1b[0m " : ""}\x1b[1;34m\x1b[5mBun\x1b[0m \x1b[1;34mv${Bun.version}\x1b[0m`; if (isFirst) { topLine += ` \x1b[2mready in\x1b[0m \x1b[1m${elapsed}\x1b[0m ms`; } console.log(topLine + "\n"); console.log(`\x1b[1;34m➜\x1b[0m \x1b[36m${server!.url.href}\x1b[0m`); } else { - let topLine = `\n Bun v${Bun.version}`; + let topLine = `Bun v${Bun.version}`; if (isFirst) { + if (server.development) { + topLine += " dev server"; + } topLine += ` ready in ${elapsed} ms`; } console.log(topLine + "\n"); diff --git a/src/js_parser.zig b/src/js_parser.zig index 7d9a1d1389ae21..c99fd26db8bf12 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -6812,7 +6812,10 @@ fn NewParser_( if (p.lexer.jsx_pragma.jsxRuntime()) |runtime| { if (options.JSX.RuntimeMap.get(runtime.text)) |jsx_runtime| { - p.options.jsx.runtime = jsx_runtime; + p.options.jsx.runtime = jsx_runtime.runtime; + if (jsx_runtime.development) |dev| { + p.options.jsx.development = dev; + } } else { // make this a warning instead of an error because we don't support "preserve" right now try p.log.addRangeWarningFmt(p.source, runtime.range, p.allocator, "Unsupported JSX runtime: \"{s}\"", .{runtime.text}); diff --git a/src/options.zig b/src/options.zig index 93a309ddc3a4b9..5388884980653d 100644 --- a/src/options.zig +++ b/src/options.zig @@ -991,13 +991,18 @@ pub const ESMConditions = struct { }; pub const JSX = struct { - pub const RuntimeMap = bun.ComptimeStringMap(JSX.Runtime, .{ - .{ "classic", .classic }, - .{ "automatic", .automatic }, - .{ "react", .classic }, - .{ "react-jsx", .automatic }, - .{ "react-jsxdev", .automatic }, - .{ "solid", .solid }, + const RuntimeDevelopmentPair = struct { + runtime: JSX.Runtime, + development: ?bool, + }; + + pub const RuntimeMap = bun.ComptimeStringMap(RuntimeDevelopmentPair, .{ + .{ "classic", RuntimeDevelopmentPair{ .runtime = .classic, .development = null } }, + .{ "automatic", RuntimeDevelopmentPair{ .runtime = .automatic, .development = true } }, + .{ "react", RuntimeDevelopmentPair{ .runtime = .classic, .development = null } }, + .{ "react-jsx", RuntimeDevelopmentPair{ .runtime = .automatic, .development = true } }, + .{ "react-jsxdev", RuntimeDevelopmentPair{ .runtime = .automatic, .development = true } }, + .{ "solid", RuntimeDevelopmentPair{ .runtime = .solid, .development = null } }, }); pub const Pragma = struct { @@ -1013,6 +1018,10 @@ pub const JSX = struct { classic_import_source: string = "react", package_name: []const u8 = "react", + /// Configuration Priority: + /// - `--define=process.env.NODE_ENV=...` + /// - `NODE_ENV=...` + /// - tsconfig.json's `compilerOptions.jsx` (`react-jsx` or `react-jsxdev`) development: bool = true, parse: bool = true, @@ -1575,13 +1584,27 @@ pub const BundleOptions = struct { supports_multiple_outputs: bool = true, + /// This is set by the process environment, which is used to override the + /// JSX configuration. When this is unspecified, the tsconfig.json is used + /// to determine if a development jsx-runtime is used (by going between + /// "react-jsx" or "react-jsx-dev-runtime") + force_node_env: ForceNodeEnv = .unspecified, + + pub const ForceNodeEnv = enum { + unspecified, + development, + production, + }; + pub fn isTest(this: *const BundleOptions) bool { return this.rewrite_jest_for_tests; } pub fn setProduction(this: *BundleOptions, value: bool) void { - this.production = value; - this.jsx.development = !value; + if (this.force_node_env == .unspecified) { + this.production = value; + this.jsx.development = !value; + } } pub const default_unwrap_commonjs_packages = [_]string{ diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index 0eb8a1832154e2..2da0564e736a29 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -216,12 +216,14 @@ pub const TSConfigJSON = struct { defer allocator.free(str_lower); _ = strings.copyLowercase(str, str_lower); // - We don't support "preserve" yet - // - We rely on NODE_ENV for "jsx" or "jsxDEV" - // - We treat "react-jsx" and "react-jsxDEV" identically - // because it is too easy to auto-import the wrong one. if (options.JSX.RuntimeMap.get(str_lower)) |runtime| { - result.jsx.runtime = runtime; + result.jsx.runtime = runtime.runtime; result.jsx_flags.insert(.runtime); + + if (runtime.development) |dev| { + result.jsx.development = dev; + result.jsx_flags.insert(.development); + } } } } diff --git a/src/transpiler.zig b/src/transpiler.zig index 7ac0299e04de43..acaf18b6388248 100644 --- a/src/transpiler.zig +++ b/src/transpiler.zig @@ -553,6 +553,7 @@ pub const Transpiler = struct { const has_production_env = this.env.isProduction(); if (!was_production and has_production_env) { this.options.setProduction(true); + this.resolver.opts.setProduction(true); } if (this.options.isTest() or this.env.isTest()) { @@ -567,6 +568,7 @@ pub const Transpiler = struct { this.env.loadProcess(); if (this.env.isProduction()) { this.options.setProduction(true); + this.resolver.opts.setProduction(true); } }, else => {}, @@ -590,7 +592,7 @@ pub const Transpiler = struct { try this.runEnvLoader(false); - this.options.jsx.setProduction(this.env.isProduction()); + var is_production = this.env.isProduction(); js_ast.Expr.Data.Store.create(); js_ast.Stmt.Data.Store.create(); @@ -600,11 +602,26 @@ pub const Transpiler = struct { try this.options.loadDefines(this.allocator, this.env, &this.options.env); + var is_development = false; if (this.options.define.dots.get("NODE_ENV")) |NODE_ENV| { - if (NODE_ENV.len > 0 and NODE_ENV[0].data.value == .e_string and NODE_ENV[0].data.value.e_string.eqlComptime("production")) { - this.options.production = true; + if (NODE_ENV.len > 0 and NODE_ENV[0].data.value == .e_string) { + if (NODE_ENV[0].data.value.e_string.eqlComptime("production")) { + is_production = true; + } else if (NODE_ENV[0].data.value.e_string.eqlComptime("development")) { + is_development = true; + } } } + + if (is_development) { + this.options.setProduction(false); + this.resolver.opts.setProduction(false); + this.options.force_node_env = .development; + this.resolver.opts.force_node_env = .development; + } else if (is_production) { + this.options.setProduction(true); + this.resolver.opts.setProduction(true); + } } pub fn resetStore(_: *const Transpiler) void { diff --git a/test/bundler/transpiler/jsx-dev/jsx-dev.tsx b/test/bundler/transpiler/jsx-dev/jsx-dev.tsx new file mode 100644 index 00000000000000..ee854a800268c0 --- /dev/null +++ b/test/bundler/transpiler/jsx-dev/jsx-dev.tsx @@ -0,0 +1,37 @@ +import { renderToReadableStream } from "react-dom/server.browser"; + +const HelloWorld = () => { + return
Hello World
; +}; + +const stream = new Response(await renderToReadableStream()); + +console.log(await stream.text()); + +if (!process.env.NO_BUILD) { + const self = await Bun.build({ + entrypoints: [import.meta.path], + define: { + "process.env.NODE_ENV": JSON.stringify(process.env.CHILD_NODE_ENV), + "process.env.NO_BUILD": "1", + }, + }); + const code = await self.outputs[0].text(); + let shouldHaveJSXDev = process.env.CHILD_NODE_ENV === "development"; + let shouldHaveJSX = process.env.CHILD_NODE_ENV === "production"; + + if (shouldHaveJSXDev) { + if (!code.includes("jsx_dev_runtime.jsxDEV")) { + throw new Error("jsxDEV is not included"); + } + } + + if (shouldHaveJSX) { + if (!code.includes("jsx_runtime.jsx")) { + throw new Error("Jsx is not included"); + } + } + + const url = URL.createObjectURL(self.outputs[0]); + await import(url); +} diff --git a/test/bundler/transpiler/jsx-dev/tsconfig.json b/test/bundler/transpiler/jsx-dev/tsconfig.json new file mode 100644 index 00000000000000..12a075f81a9734 --- /dev/null +++ b/test/bundler/transpiler/jsx-dev/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "jsx": "react-jsxdev" + } +} diff --git a/test/bundler/transpiler/jsx-production-entry.ts b/test/bundler/transpiler/jsx-production-entry.ts new file mode 100644 index 00000000000000..eec766abee1578 --- /dev/null +++ b/test/bundler/transpiler/jsx-production-entry.ts @@ -0,0 +1 @@ +import "./jsx-production"; diff --git a/test/bundler/transpiler/jsx-production.test.ts b/test/bundler/transpiler/jsx-production.test.ts new file mode 100644 index 00000000000000..7fd7ad30d3062b --- /dev/null +++ b/test/bundler/transpiler/jsx-production.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, test, afterAll } from "bun:test"; +import path from "path"; +import { bunExe, bunEnv } from "harness"; + +const original_node_env = bunEnv.NODE_ENV; + +// https://github.com/oven-sh/bun/issues/3768 +describe("jsx", () => { + for (const node_env of ["production", "development", "test", ""]) { + for (const child_node_env of ["production", "development", "test", ""]) { + test(`react-jsxDEV parent: ${node_env} child: ${child_node_env} should work`, async () => { + bunEnv.NODE_ENV = node_env; + bunEnv.CHILD_NODE_ENV = child_node_env; + bunEnv.TSCONFIG_JSX = "react-jsxdev"; + expect([path.join(import.meta.dirname, "jsx-dev", "jsx-dev.tsx")]).toRun( + "
Hello World
" + "\n" + "
Hello World
" + "\n", + ); + }); + + test(`react-jsx parent: ${node_env} child: ${child_node_env} should work`, async () => { + bunEnv.NODE_ENV = node_env; + bunEnv.CHILD_NODE_ENV = child_node_env; + bunEnv.TSCONFIG_JSX = "react-jsx"; + expect([path.join(import.meta.dirname, "jsx-production-entry.ts")]).toRun( + "
Hello World
" + "\n" + "
Hello World
" + "\n", + ); + }); + } + } + + afterAll(() => { + bunEnv.NODE_ENV = original_node_env; + delete bunEnv.CHILD_NODE_ENV; + delete bunEnv.TSCONFIG_JSX; + }); +}); diff --git a/test/bundler/transpiler/jsx-production.tsx b/test/bundler/transpiler/jsx-production.tsx new file mode 100644 index 00000000000000..ee854a800268c0 --- /dev/null +++ b/test/bundler/transpiler/jsx-production.tsx @@ -0,0 +1,37 @@ +import { renderToReadableStream } from "react-dom/server.browser"; + +const HelloWorld = () => { + return
Hello World
; +}; + +const stream = new Response(await renderToReadableStream()); + +console.log(await stream.text()); + +if (!process.env.NO_BUILD) { + const self = await Bun.build({ + entrypoints: [import.meta.path], + define: { + "process.env.NODE_ENV": JSON.stringify(process.env.CHILD_NODE_ENV), + "process.env.NO_BUILD": "1", + }, + }); + const code = await self.outputs[0].text(); + let shouldHaveJSXDev = process.env.CHILD_NODE_ENV === "development"; + let shouldHaveJSX = process.env.CHILD_NODE_ENV === "production"; + + if (shouldHaveJSXDev) { + if (!code.includes("jsx_dev_runtime.jsxDEV")) { + throw new Error("jsxDEV is not included"); + } + } + + if (shouldHaveJSX) { + if (!code.includes("jsx_runtime.jsx")) { + throw new Error("Jsx is not included"); + } + } + + const url = URL.createObjectURL(self.outputs[0]); + await import(url); +} diff --git a/test/bundler/transpiler/tsconfig.json b/test/bundler/transpiler/tsconfig.json new file mode 100644 index 00000000000000..2431b86fe43ab9 --- /dev/null +++ b/test/bundler/transpiler/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "jsx": "react-jsx" + } +} diff --git a/test/js/bun/http/bun-serve-html.test.ts b/test/js/bun/http/bun-serve-html.test.ts index 39295e84b4a394..4c0860fec4cb0d 100644 --- a/test/js/bun/http/bun-serve-html.test.ts +++ b/test/js/bun/http/bun-serve-html.test.ts @@ -716,3 +716,56 @@ test("wildcard static routes", async () => { } } }); + +test("serve html with JSX runtime in development mode", async () => { + const dir = join(import.meta.dir, "jsx-runtime"); + const { default: html } = await import(join(dir, "index.html")); + + using server = Bun.serve({ + port: 0, + development: true, + static: { + "/": html, + }, + fetch(req) { + return new Response("Not found", { status: 404 }); + }, + }); + + const response = await fetch(server.url); + expect(response.status).toBe(200); + const htmlText = await response.text(); + const jsSrc = htmlText.match(/ + + +
+ + From 0861c03b37301bafd1bbb329102fd3a3d269ee97 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 3 Feb 2025 17:38:17 -0800 Subject: [PATCH 20/29] Fix memory leak in the SQL query string (#17026) Co-authored-by: Ciro Spaciari --- src/sql/postgres.zig | 1 - test/js/sql/sql.test.ts | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/sql/postgres.zig b/src/sql/postgres.zig index a48858f7c08ddb..01dd450adce4ac 100644 --- a/src/sql/postgres.zig +++ b/src/sql/postgres.zig @@ -633,7 +633,6 @@ pub const PostgresSQLQuery = struct { .bigint = bigint, }, }; - ptr.query.ref(); PostgresSQLQuery.bindingSetCached(this_value, globalThis, values); PostgresSQLQuery.pendingValueSetCached(this_value, globalThis, pending_value); diff --git a/test/js/sql/sql.test.ts b/test/js/sql/sql.test.ts index 84e86cca3c81ff..a00acc03d0364c 100644 --- a/test/js/sql/sql.test.ts +++ b/test/js/sql/sql.test.ts @@ -298,6 +298,28 @@ if (isDockerEnabled()) { Bun.inspect(result); }); + test("query string memory leak test", async () => { + Bun.gc(true); + const rss = process.memoryUsage.rss(); + for (let potato of Array.from({ length: 8 * 1024 }, a => "okkk" + a)) { + await sql` + select 1 as abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde + , 2 as ${sql(potato)} + `; + } + + Bun.gc(true); + const after = process.memoryUsage.rss(); + console.log({ after, rss }); + // Previously: + // { + // after: 507150336, + // rss: 49152000, + // } + // ~440 MB. + expect((after - rss) / 1024 / 1024).toBeLessThan(200); + }); + // Last one wins. test("Handles duplicate numeric column names", async () => { const result = await sql`select 1 as "1", 2 as "1", 3 as "1"`; From a8d159da22ef8de750a99a548f3a5372857753dd Mon Sep 17 00:00:00 2001 From: 190n Date: Mon, 3 Feb 2025 21:49:27 -0800 Subject: [PATCH 21/29] Fix napi_is_buffer/napi_is_typedarray to match Node.js (#17034) --- src/bun.js/api/BunObject.zig | 2 +- src/bun.js/api/html_rewriter.zig | 2 +- src/bun.js/bindings/bindings.zig | 2 +- src/bun.js/bindings/napi.cpp | 24 ++++++++++++++++++++++++ src/bun.js/webcore/body.zig | 2 +- src/napi/napi.zig | 20 ++++---------------- src/sql/postgres/postgres_types.zig | 2 +- test/napi/napi-app/main.cpp | 19 +++++++++++++++++++ test/napi/napi.test.ts | 21 +++++++++++++++++++++ 9 files changed, 73 insertions(+), 21 deletions(-) diff --git a/src/bun.js/api/BunObject.zig b/src/bun.js/api/BunObject.zig index 0afc440aadde56..e51a3535f174f0 100644 --- a/src/bun.js/api/BunObject.zig +++ b/src/bun.js/api/BunObject.zig @@ -3529,7 +3529,7 @@ const UnsafeObject = struct { callframe: *JSC.CallFrame, ) bun.JSError!JSC.JSValue { const args = callframe.arguments_old(2).slice(); - if (args.len < 1 or !args[0].isCell() or !args[0].jsType().isTypedArray()) { + if (args.len < 1 or !args[0].isCell() or !args[0].jsType().isTypedArrayOrArrayBuffer()) { return globalThis.throwInvalidArguments("Expected an ArrayBuffer", .{}); } diff --git a/src/bun.js/api/html_rewriter.zig b/src/bun.js/api/html_rewriter.zig index 4eaa5441e14413..f8f835fbb341e1 100644 --- a/src/bun.js/api/html_rewriter.zig +++ b/src/bun.js/api/html_rewriter.zig @@ -189,7 +189,7 @@ pub const HTMLRewriter = struct { const kind: ResponseKind = brk: { if (response_value.isString()) break :brk .string - else if (response_value.jsType().isTypedArray()) + else if (response_value.jsType().isTypedArrayOrArrayBuffer()) break :brk .array_buffer else break :brk .other; diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 4c0ba9e4f6d097..f0a0fa6cc4f1d0 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -3805,7 +3805,7 @@ pub const JSValue = enum(i64) { }; } - pub fn isTypedArray(this: JSType) bool { + pub fn isTypedArrayOrArrayBuffer(this: JSType) bool { return switch (this) { .ArrayBuffer, .BigInt64Array, diff --git a/src/bun.js/bindings/napi.cpp b/src/bun.js/bindings/napi.cpp index f68fd228f902e4..bd028319ffef53 100644 --- a/src/bun.js/bindings/napi.cpp +++ b/src/bun.js/bindings/napi.cpp @@ -895,6 +895,30 @@ extern "C" napi_status napi_create_arraybuffer(napi_env env, NAPI_RETURN_SUCCESS(env); } +extern "C" napi_status napi_is_buffer(napi_env env, napi_value value, bool* result) +{ + NAPI_PREAMBLE(env); + NAPI_CHECK_ARG(env, value); + NAPI_CHECK_ARG(env, result); + + auto jsValue = toJS(value); + // Despite documentation, Node.js's version of this function returns true for all kinds of + // TypedArray, not just Uint8Array + *result = jsValue.isCell() && isTypedArrayTypeIncludingDataView(jsValue.asCell()->type()); + NAPI_RETURN_SUCCESS(env); +} + +extern "C" napi_status napi_is_typedarray(napi_env env, napi_value value, bool* result) +{ + NAPI_PREAMBLE(env); + NAPI_CHECK_ARG(env, value); + NAPI_CHECK_ARG(env, result); + + auto jsValue = toJS(value); + *result = jsValue.isCell() && isTypedArrayType(jsValue.asCell()->type()); + NAPI_RETURN_SUCCESS(env); +} + // This is more efficient than using WTF::String::FromUTF8 // it doesn't copy the string // but it's only safe to use if we are not setting a property diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig index 17d95af117663c..3452ec5e662d55 100644 --- a/src/bun.js/webcore/body.zig +++ b/src/bun.js/webcore/body.zig @@ -578,7 +578,7 @@ pub const Body = struct { }; } - if (js_type.isTypedArray()) { + if (js_type.isTypedArrayOrArrayBuffer()) { if (value.asArrayBuffer(globalThis)) |buffer| { const bytes = buffer.byteSlice(); diff --git a/src/napi/napi.zig b/src/napi/napi.zig index ff738aa8a0f687..0dce7c9bda5aa9 100644 --- a/src/napi/napi.zig +++ b/src/napi/napi.zig @@ -846,13 +846,9 @@ pub export fn napi_get_arraybuffer_info(env: napi_env, arraybuffer_: napi_value, len.* = slice.len; return env.ok(); } -pub export fn napi_is_typedarray(env: napi_env, value_: napi_value, result_: ?*bool) napi_status { - log("napi_is_typedarray", .{}); - const value = value_.get(); - const result = result_ orelse return env.invalidArg(); - result.* = value.jsTypeLoose().isTypedArray(); - return env.ok(); -} + +pub extern fn napi_is_typedarray(napi_env, napi_value, *bool) napi_status; + pub export fn napi_create_typedarray(env: napi_env, @"type": napi_typedarray_type, length: usize, arraybuffer_: napi_value, byte_offset: usize, result_: ?*napi_value) napi_status { log("napi_create_typedarray", .{}); const arraybuffer = arraybuffer_.get(); @@ -1240,15 +1236,7 @@ pub export fn napi_create_buffer_copy(env: napi_env, length: usize, data: [*]u8, return env.ok(); } -pub export fn napi_is_buffer(env: napi_env, value_: napi_value, result_: ?*bool) napi_status { - log("napi_is_buffer", .{}); - const result = result_ orelse { - return env.invalidArg(); - }; - const value = value_.get(); - result.* = value.isBuffer(env.toJS()); - return env.ok(); -} +extern fn napi_is_buffer(napi_env, napi_value, *bool) napi_status; pub export fn napi_get_buffer_info(env: napi_env, value_: napi_value, data: ?*[*]u8, length: ?*usize) napi_status { log("napi_get_buffer_info", .{}); const value = value_.get(); diff --git a/src/sql/postgres/postgres_types.zig b/src/sql/postgres/postgres_types.zig index 83a1e8488138cc..9a62d07bf18223 100644 --- a/src/sql/postgres/postgres_types.zig +++ b/src/sql/postgres/postgres_types.zig @@ -345,7 +345,7 @@ pub const Tag = enum(short) { return .timestamptz; } - if (tag.isTypedArray()) { + if (tag.isTypedArrayOrArrayBuffer()) { if (tag == .Int32Array) return .int4_array; diff --git a/test/napi/napi-app/main.cpp b/test/napi/napi-app/main.cpp index 5e99b118d07425..dd5aee63f963c9 100644 --- a/test/napi/napi-app/main.cpp +++ b/test/napi/napi-app/main.cpp @@ -1131,6 +1131,22 @@ static napi_value test_extended_error_messages(const Napi::CallbackInfo &info) { return ok(env); } +static napi_value test_is_buffer(const Napi::CallbackInfo &info) { + bool result; + napi_env env = info.Env(); + NODE_API_CALL(info.Env(), napi_is_buffer(env, info[1], &result)); + printf("napi_is_buffer -> %s\n", result ? "true" : "false"); + return ok(env); +} + +static napi_value test_is_typedarray(const Napi::CallbackInfo &info) { + bool result; + napi_env env = info.Env(); + NODE_API_CALL(info.Env(), napi_is_typedarray(env, info[1], &result)); + printf("napi_is_typedarray -> %s\n", result ? "true" : "false"); + return ok(env); +} + Napi::Value RunCallback(const Napi::CallbackInfo &info) { Napi::Env env = info.Env(); // this function is invoked without the GC callback @@ -1204,6 +1220,9 @@ Napi::Object InitAll(Napi::Env env, Napi::Object exports1) { Napi::Function::New(env, create_weird_bigints)); exports.Set("test_extended_error_messages", Napi::Function::New(env, test_extended_error_messages)); + exports.Set("test_is_buffer", Napi::Function::New(env, test_is_buffer)); + exports.Set("test_is_typedarray", + Napi::Function::New(env, test_is_typedarray)); napitests::register_wrap_tests(env, exports); diff --git a/test/napi/napi.test.ts b/test/napi/napi.test.ts index 8d8f1bc62e15c2..d16b7fd9f9e419 100644 --- a/test/napi/napi.test.ts +++ b/test/napi/napi.test.ts @@ -387,6 +387,27 @@ describe("napi", () => { }); }); + describe.each(["buffer", "typedarray"])("napi_is_%s", kind => { + const tests: Array<[string, boolean]> = [ + ["new Uint8Array()", true], + ["new BigUint64Array()", true], + ["new ArrayBuffer()", false], + ["Buffer.alloc(0)", true], + ["new DataView(new ArrayBuffer())", kind == "buffer"], + ["new (class Foo extends Uint8Array {})()", true], + ["false", false], + ["[1, 2, 3]", false], + ["'hello'", false], + ]; + it("returns consistent values with node.js", () => { + for (const [value, expected] of tests) { + // main.js does eval then spread so to pass a single value we need to wrap in an array + const output = checkSameOutput(`test_is_${kind}`, "[" + value + "]"); + expect(output).toBe(`napi_is_${kind} -> ${expected.toString()}`); + } + }); + }); + it.each([ ["nullptr", { number: 123 }], ["null", null], From fa55ca31e1f64ab1900fcdabce64e34c6ebf6091 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:22:28 -0800 Subject: [PATCH 22/29] Fix occasional crash on `FilePoll` deinit (#17050) --- src/async/posix_event_loop.zig | 6 ++++-- src/async/windows_event_loop.zig | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/async/posix_event_loop.zig b/src/async/posix_event_loop.zig index 6ab59c66f7330c..7ee6c5d31d362c 100644 --- a/src/async/posix_event_loop.zig +++ b/src/async/posix_event_loop.zig @@ -592,8 +592,10 @@ pub const FilePoll = struct { poll.flags.insert(.ignore_updates); this.pending_free_tail = poll; - bun.assert(vm.after_event_loop_callback == null or vm.after_event_loop_callback == @as(?JSC.OpaqueCallback, @ptrCast(&processDeferredFrees))); - vm.after_event_loop_callback = @ptrCast(&processDeferredFrees); + + const callback = JSC.OpaqueWrap(Store, processDeferredFrees); + bun.assert(vm.after_event_loop_callback == null or vm.after_event_loop_callback == @as(?JSC.OpaqueCallback, callback)); + vm.after_event_loop_callback = callback; vm.after_event_loop_callback_ctx = this; } }; diff --git a/src/async/windows_event_loop.zig b/src/async/windows_event_loop.zig index 0943d1959b1938..6ac815a8494808 100644 --- a/src/async/windows_event_loop.zig +++ b/src/async/windows_event_loop.zig @@ -358,8 +358,10 @@ pub const FilePoll = struct { poll.flags.insert(.ignore_updates); this.pending_free_tail = poll; - bun.assert(vm.after_event_loop_callback == null or vm.after_event_loop_callback == @as(?JSC.OpaqueCallback, @ptrCast(&processDeferredFrees))); - vm.after_event_loop_callback = @ptrCast(&processDeferredFrees); + + const callback = JSC.OpaqueWrap(Store, processDeferredFrees); + bun.assert(vm.after_event_loop_callback == null or vm.after_event_loop_callback == @as(?JSC.OpaqueCallback, callback)); + vm.after_event_loop_callback = callback; vm.after_event_loop_callback_ctx = this; } }; From d63fe71a6da45ae7278dbd5aa5dec815a977c2c9 Mon Sep 17 00:00:00 2001 From: Kai Tamkun <13513421+heimskr@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:22:44 -0800 Subject: [PATCH 23/29] Fix node:dgram `addMembership`/`dropMembership` segfault (#17049) --- packages/bun-usockets/src/bsd.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/bun-usockets/src/bsd.c b/packages/bun-usockets/src/bsd.c index 8bc993bf945ef3..5b4e24a1b4b07d 100644 --- a/packages/bun-usockets/src/bsd.c +++ b/packages/bun-usockets/src/bsd.c @@ -387,8 +387,15 @@ int bsd_socket_multicast_interface(LIBUS_SOCKET_DESCRIPTOR fd, const struct sock static int bsd_socket_set_membership4(LIBUS_SOCKET_DESCRIPTOR fd, const struct sockaddr_in *addr, const struct sockaddr_in *iface, int drop) { struct ip_mreq mreq; memset(&mreq, 0, sizeof(mreq)); + mreq.imr_multiaddr.s_addr = addr->sin_addr.s_addr; - mreq.imr_interface.s_addr = iface->sin_addr.s_addr; + + if (iface != NULL) { + mreq.imr_interface.s_addr = iface->sin_addr.s_addr; + } else { + mreq.imr_interface.s_addr = htonl(INADDR_ANY); + } + int option = drop ? IP_DROP_MEMBERSHIP : IP_ADD_MEMBERSHIP; return setsockopt(fd, IPPROTO_IP, option, &mreq, sizeof(mreq)); } @@ -397,13 +404,15 @@ static int bsd_socket_set_membership6(LIBUS_SOCKET_DESCRIPTOR fd, const struct s struct ipv6_mreq mreq; memset(&mreq, 0, sizeof(mreq)); mreq.ipv6mr_multiaddr = addr->sin6_addr; - mreq.ipv6mr_interface = iface->sin6_scope_id; + if (iface != NULL) { + mreq.ipv6mr_interface = iface->sin6_scope_id; + } int option = drop ? IPV6_LEAVE_GROUP : IPV6_JOIN_GROUP; return setsockopt(fd, IPPROTO_IP, option, &mreq, sizeof(mreq)); } int bsd_socket_set_membership(LIBUS_SOCKET_DESCRIPTOR fd, const struct sockaddr_storage *addr, const struct sockaddr_storage *iface, int drop) { - if (addr->ss_family != iface->ss_family) { + if (iface != NULL && addr->ss_family != iface->ss_family) { errno = EINVAL; return -1; } From b39d84690ca4a9e57e36d81a339af7bda26cdcc4 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 4 Feb 2025 17:59:48 -0800 Subject: [PATCH 24/29] implement process.binding('buffer') (#16741) Co-authored-by: Jarred Sumner --- cmake/targets/BuildBun.cmake | 2 + src/bun.js/bindings/BunProcess.cpp | 3 +- src/bun.js/bindings/ProcessBindingBuffer.cpp | 159 +++++++++++++++++++ src/bun.js/bindings/ProcessBindingBuffer.h | 37 +++++ src/bun.js/bindings/ZigGlobalObject.cpp | 10 ++ src/bun.js/bindings/ZigGlobalObject.h | 2 + test/js/node/process/process.test.js | 43 ++++- 7 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 src/bun.js/bindings/ProcessBindingBuffer.cpp create mode 100644 src/bun.js/bindings/ProcessBindingBuffer.h diff --git a/cmake/targets/BuildBun.cmake b/cmake/targets/BuildBun.cmake index ad1ce07f33ddc6..1066e31a5d0500 100644 --- a/cmake/targets/BuildBun.cmake +++ b/cmake/targets/BuildBun.cmake @@ -404,6 +404,7 @@ set(BUN_OBJECT_LUT_SOURCES ${CWD}/src/bun.js/bindings/ZigGlobalObject.lut.txt ${CWD}/src/bun.js/bindings/JSBuffer.cpp ${CWD}/src/bun.js/bindings/BunProcess.cpp + ${CWD}/src/bun.js/bindings/ProcessBindingBuffer.cpp ${CWD}/src/bun.js/bindings/ProcessBindingConstants.cpp ${CWD}/src/bun.js/bindings/ProcessBindingNatives.cpp ${CWD}/src/bun.js/modules/NodeModuleModule.cpp @@ -415,6 +416,7 @@ set(BUN_OBJECT_LUT_OUTPUTS ${CODEGEN_PATH}/ZigGlobalObject.lut.h ${CODEGEN_PATH}/JSBuffer.lut.h ${CODEGEN_PATH}/BunProcess.lut.h + ${CODEGEN_PATH}/ProcessBindingBuffer.lut.h ${CODEGEN_PATH}/ProcessBindingConstants.lut.h ${CODEGEN_PATH}/ProcessBindingNatives.lut.h ${CODEGEN_PATH}/NodeModuleModule.lut.h diff --git a/src/bun.js/bindings/BunProcess.cpp b/src/bun.js/bindings/BunProcess.cpp index 39732082f27b80..a3063b71420077 100644 --- a/src/bun.js/bindings/BunProcess.cpp +++ b/src/bun.js/bindings/BunProcess.cpp @@ -2565,10 +2565,11 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionBinding, (JSGlobalObject * jsGlobalObje auto globalObject = jsCast(jsGlobalObject); auto process = jsCast(globalObject->processObject()); auto moduleName = callFrame->argument(0).toWTFString(globalObject); + RETURN_IF_EXCEPTION(throwScope, {}); // clang-format off if (moduleName == "async_wrap"_s) PROCESS_BINDING_NOT_IMPLEMENTED("async_wrap"); - if (moduleName == "buffer"_s) PROCESS_BINDING_NOT_IMPLEMENTED_ISSUE("buffer", "2020"); + if (moduleName == "buffer"_s) return JSValue::encode(globalObject->processBindingBuffer()); if (moduleName == "cares_wrap"_s) PROCESS_BINDING_NOT_IMPLEMENTED("cares_wrap"); if (moduleName == "config"_s) return JSValue::encode(processBindingConfig(globalObject, vm)); if (moduleName == "constants"_s) return JSValue::encode(globalObject->processBindingConstants()); diff --git a/src/bun.js/bindings/ProcessBindingBuffer.cpp b/src/bun.js/bindings/ProcessBindingBuffer.cpp new file mode 100644 index 00000000000000..c0bb0f079c68e0 --- /dev/null +++ b/src/bun.js/bindings/ProcessBindingBuffer.cpp @@ -0,0 +1,159 @@ + +#include "ProcessBindingBuffer.h" +#include +#include "JSBuffer.h" + +namespace Bun { +using namespace JSC; + +#define PROCESS_BINDING_NOT_IMPLEMENTED(str) \ + JSC_DEFINE_HOST_FUNCTION(ProcessBinding_Buffer_##str, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::CallFrame * callFrame)) \ + { \ + { \ + auto& vm = JSC::getVM(lexicalGlobalObject); \ + auto throwScope = DECLARE_THROW_SCOPE(vm); \ + auto prelude = "process.binding('buffer')."_s; \ + auto name = WTF::ASCIILiteral::fromLiteralUnsafe(#str); \ + auto finale = " is not implemented in Bun. If that breaks something, please file an issue and include a reproducible code sample."_s; \ + auto message = makeString(prelude, name, finale); \ + throwScope.throwException(lexicalGlobalObject, createError(lexicalGlobalObject, message)); \ + return {}; \ + } \ + } + +PROCESS_BINDING_NOT_IMPLEMENTED(asciiSlice) + +PROCESS_BINDING_NOT_IMPLEMENTED(asciiWriteStatic) + +PROCESS_BINDING_NOT_IMPLEMENTED(atob) + +PROCESS_BINDING_NOT_IMPLEMENTED(base64Slice) + +PROCESS_BINDING_NOT_IMPLEMENTED(base64Write) + +PROCESS_BINDING_NOT_IMPLEMENTED(base64urlSlice) + +PROCESS_BINDING_NOT_IMPLEMENTED(base64urlWrite) + +PROCESS_BINDING_NOT_IMPLEMENTED(btoa) + +PROCESS_BINDING_NOT_IMPLEMENTED(byteLengthUtf8) + +PROCESS_BINDING_NOT_IMPLEMENTED(compare) + +PROCESS_BINDING_NOT_IMPLEMENTED(compareOffset) + +PROCESS_BINDING_NOT_IMPLEMENTED(copy) + +PROCESS_BINDING_NOT_IMPLEMENTED(copyArrayBuffer) + +PROCESS_BINDING_NOT_IMPLEMENTED(detachArrayBuffer) + +PROCESS_BINDING_NOT_IMPLEMENTED(fill) + +PROCESS_BINDING_NOT_IMPLEMENTED(getZeroFillToggle) + +PROCESS_BINDING_NOT_IMPLEMENTED(hexSlice) + +PROCESS_BINDING_NOT_IMPLEMENTED(hexWrite) + +PROCESS_BINDING_NOT_IMPLEMENTED(indexOfBuffer) + +PROCESS_BINDING_NOT_IMPLEMENTED(indexOfNumber) + +PROCESS_BINDING_NOT_IMPLEMENTED(indexOfString) + +PROCESS_BINDING_NOT_IMPLEMENTED(isAscii) + +PROCESS_BINDING_NOT_IMPLEMENTED(isUtf8) + +PROCESS_BINDING_NOT_IMPLEMENTED(latin1Slice) + +PROCESS_BINDING_NOT_IMPLEMENTED(latin1WriteStatic) + +PROCESS_BINDING_NOT_IMPLEMENTED(swap16) + +PROCESS_BINDING_NOT_IMPLEMENTED(swap32) + +PROCESS_BINDING_NOT_IMPLEMENTED(swap64) + +PROCESS_BINDING_NOT_IMPLEMENTED(ucs2Slice) + +PROCESS_BINDING_NOT_IMPLEMENTED(ucs2Write) + +PROCESS_BINDING_NOT_IMPLEMENTED(utf8Slice) + +PROCESS_BINDING_NOT_IMPLEMENTED(utf8WriteStatic) + +/* Source for ProcessBindingBuffer.lut.h +@begin processBindingBufferTable + asciiSlice ProcessBinding_Buffer_asciiSlice Function 1 + asciiWriteStatic ProcessBinding_Buffer_asciiWriteStatic Function 1 + atob ProcessBinding_Buffer_atob Function 1 + base64Slice ProcessBinding_Buffer_base64Slice Function 1 + base64Write ProcessBinding_Buffer_base64Write Function 1 + base64urlSlice ProcessBinding_Buffer_base64urlSlice Function 1 + base64urlWrite ProcessBinding_Buffer_base64urlWrite Function 1 + btoa ProcessBinding_Buffer_btoa Function 1 + byteLengthUtf8 ProcessBinding_Buffer_byteLengthUtf8 Function 1 + compare ProcessBinding_Buffer_compare Function 1 + compareOffset ProcessBinding_Buffer_compareOffset Function 1 + copy ProcessBinding_Buffer_copy Function 1 + copyArrayBuffer ProcessBinding_Buffer_copyArrayBuffer Function 1 + detachArrayBuffer ProcessBinding_Buffer_detachArrayBuffer Function 1 + fill ProcessBinding_Buffer_fill Function 1 + getZeroFillToggle ProcessBinding_Buffer_getZeroFillToggle Function 1 + hexSlice ProcessBinding_Buffer_hexSlice Function 1 + hexWrite ProcessBinding_Buffer_hexWrite Function 1 + indexOfBuffer ProcessBinding_Buffer_indexOfBuffer Function 1 + indexOfNumber ProcessBinding_Buffer_indexOfNumber Function 1 + indexOfString ProcessBinding_Buffer_indexOfString Function 1 + isAscii ProcessBinding_Buffer_isAscii Function 1 + isUtf8 ProcessBinding_Buffer_isUtf8 Function 1 + latin1Slice ProcessBinding_Buffer_latin1Slice Function 1 + latin1WriteStatic ProcessBinding_Buffer_latin1WriteStatic Function 1 + swap16 ProcessBinding_Buffer_swap16 Function 1 + swap32 ProcessBinding_Buffer_swap32 Function 1 + swap64 ProcessBinding_Buffer_swap64 Function 1 + ucs2Slice ProcessBinding_Buffer_ucs2Slice Function 1 + ucs2Write ProcessBinding_Buffer_ucs2Write Function 1 + utf8Slice ProcessBinding_Buffer_utf8Slice Function 1 + utf8WriteStatic ProcessBinding_Buffer_utf8WriteStatic Function 1 +@end +*/ +#include "ProcessBindingBuffer.lut.h" + +const ClassInfo ProcessBindingBuffer::s_info = { "ProcessBindingBuffer"_s, &Base::s_info, &processBindingBufferTable, nullptr, CREATE_METHOD_TABLE(ProcessBindingBuffer) }; + +ProcessBindingBuffer* ProcessBindingBuffer::create(VM& vm, Structure* structure) +{ + ProcessBindingBuffer* obj = new (NotNull, allocateCell(vm)) ProcessBindingBuffer(vm, structure); + obj->finishCreation(vm); + return obj; +} + +Structure* ProcessBindingBuffer::createStructure(VM& vm, JSGlobalObject* globalObject) +{ + return Structure::create(vm, globalObject, jsNull(), TypeInfo(ObjectType, StructureFlags), ProcessBindingBuffer::info()); +} + +void ProcessBindingBuffer::finishCreation(JSC::VM& vm) +{ + Base::finishCreation(vm); + ASSERT(inherits(info())); + + putDirect(vm, Identifier::fromString(vm, "kMaxLength"_s), jsNumber(Bun::Buffer::kMaxLength), 0); + putDirect(vm, Identifier::fromString(vm, "kStringMaxLength"_s), jsNumber(Bun::Buffer::kStringMaxLength), 0); +} + +template +void ProcessBindingBuffer::visitChildrenImpl(JSCell* cell, Visitor& visitor) +{ + ProcessBindingBuffer* thisObject = jsCast(cell); + ASSERT_GC_OBJECT_INHERITS(thisObject, info()); + Base::visitChildren(thisObject, visitor); +} + +DEFINE_VISIT_CHILDREN(ProcessBindingBuffer); + +} // namespace Bun diff --git a/src/bun.js/bindings/ProcessBindingBuffer.h b/src/bun.js/bindings/ProcessBindingBuffer.h new file mode 100644 index 00000000000000..62add4ca3ec4f0 --- /dev/null +++ b/src/bun.js/bindings/ProcessBindingBuffer.h @@ -0,0 +1,37 @@ +#pragma once +#include "root.h" + +namespace Bun { + +using namespace JSC; + +// The object returned from process.binding('buffer') +class ProcessBindingBuffer final : public JSC::JSNonFinalObject { +public: + DECLARE_INFO; + DECLARE_VISIT_CHILDREN; + + using Base = JSC::JSNonFinalObject; + + static constexpr unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; + + static ProcessBindingBuffer* create(JSC::VM& vm, JSC::Structure* structure); + static Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject); + + template + static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm) + { + STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(ProcessBindingBuffer, Base); + return &vm.plainObjectSpace(); + } + +private: + void finishCreation(JSC::VM& vm); + + ProcessBindingBuffer(JSC::VM& vm, JSC::Structure* structure) + : Base(vm, structure) + { + } +}; + +} // namespace Bun diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 0ab051cfb81154..c0d2156bed36c7 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -161,7 +161,9 @@ #include "JSX509Certificate.h" #include "JSS3File.h" #include "S3Error.h" +#include "ProcessBindingBuffer.h" #include + #if ENABLE(REMOTE_INSPECTOR) #include "JavaScriptCore/RemoteInspectorServer.h" #endif @@ -3224,6 +3226,14 @@ void GlobalObject::finishCreation(VM& vm) InternalModuleRegistry::createStructure(init.vm, init.owner))); }); + m_processBindingBuffer.initLater( + [](const JSC::LazyProperty::Initializer& init) { + init.set( + ProcessBindingBuffer::create( + init.vm, + ProcessBindingBuffer::createStructure(init.vm, init.owner))); + }); + m_processBindingConstants.initLater( [](const JSC::LazyProperty::Initializer& init) { init.set( diff --git a/src/bun.js/bindings/ZigGlobalObject.h b/src/bun.js/bindings/ZigGlobalObject.h index 8aefbaa7302437..b34cb5aec5150c 100644 --- a/src/bun.js/bindings/ZigGlobalObject.h +++ b/src/bun.js/bindings/ZigGlobalObject.h @@ -248,6 +248,7 @@ class GlobalObject : public Bun::GlobalScope { JSObject* requireResolveFunctionUnbound() const { return m_requireResolveFunctionUnbound.getInitializedOnMainThread(this); } Bun::InternalModuleRegistry* internalModuleRegistry() const { return m_internalModuleRegistry.getInitializedOnMainThread(this); } + JSObject* processBindingBuffer() const { return m_processBindingBuffer.getInitializedOnMainThread(this); } JSObject* processBindingConstants() const { return m_processBindingConstants.getInitializedOnMainThread(this); } JSObject* lazyRequireCacheObject() const { return m_lazyRequireCacheObject.getInitializedOnMainThread(this); } @@ -579,6 +580,7 @@ class GlobalObject : public Bun::GlobalScope { LazyProperty m_requireFunctionUnbound; LazyProperty m_requireResolveFunctionUnbound; LazyProperty m_internalModuleRegistry; + LazyProperty m_processBindingBuffer; LazyProperty m_processBindingConstants; LazyProperty m_importMetaObjectStructure; LazyProperty m_asyncBoundFunctionStructure; diff --git a/test/js/node/process/process.test.js b/test/js/node/process/process.test.js index 965105f56bf5a9..b4c71924f9140f 100644 --- a/test/js/node/process/process.test.js +++ b/test/js/node/process/process.test.js @@ -319,7 +319,48 @@ it("process.execArgv", () => { }); it("process.binding", () => { - expect(() => process.binding("buffer")).toThrow(); + expect(() => process.binding("async_wrap")).toThrow(); + expect(() => process.binding("buffer")).not.toThrow(); + expect(() => process.binding("cares_wrap")).toThrow(); + expect(() => process.binding("config")).not.toThrow(); + expect(() => process.binding("constants")).not.toThrow(); + expect(() => process.binding("contextify")).toThrow(); + expect(() => process.binding("crypto")).toThrow(); + expect(() => process.binding("crypto/x509")).not.toThrow(); + expect(() => process.binding("fs")).toThrow(); + expect(() => process.binding("fs_event_wrap")).toThrow(); + expect(() => process.binding("http_parser")).toThrow(); + expect(() => process.binding("icu")).toThrow(); + expect(() => process.binding("inspector")).toThrow(); + expect(() => process.binding("js_stream")).toThrow(); + expect(() => process.binding("natives")).not.toThrow(); + expect(() => process.binding("os")).toThrow(); + expect(() => process.binding("pipe_wrap")).toThrow(); + expect(() => process.binding("process_wrap")).toThrow(); + expect(() => process.binding("signal_wrap")).toThrow(); + expect(() => process.binding("spawn_sync")).toThrow(); + expect(() => process.binding("stream_wrap")).toThrow(); + expect(() => process.binding("tcp_wrap")).toThrow(); + expect(() => process.binding("tls_wrap")).toThrow(); + expect(() => process.binding("tty_wrap")).not.toThrow(); + expect(() => process.binding("udp_wrap")).toThrow(); + expect(() => process.binding("url")).toThrow(); + expect(() => process.binding("util")).not.toThrow(); + expect(() => process.binding("uv")).not.toThrow(); + expect(() => process.binding("v8")).toThrow(); + expect(() => process.binding("zlib")).toThrow(); + + expect(() => process.binding()).toThrow(); + expect(() => process.binding(10)).toThrow(); + expect(() => process.binding(10n)).toThrow(); + expect(() => process.binding(null)).toThrow(); + expect(() => process.binding(true)).toThrow(); + expect(() => process.binding("")).toThrow(); + expect(() => process.binding(function () {})).toThrow(); + expect(() => process.binding(() => {})).toThrow(); + expect(() => process.binding(Symbol("ab"))).toThrow(); + expect(() => process.binding({})).toThrow(); + expect(() => process.binding(Object.freeze({ __proto__: null }))).toThrow(); }); it("process.argv in testing", () => { From 1819b01932ffab62333dd74547a9c0bb5f731678 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 4 Feb 2025 19:52:11 -0800 Subject: [PATCH 25/29] node: fix test-buffer-fill.js (#16738) --- .../js/node/test/parallel/test-buffer-fill.js | 444 ++++++++++++++++++ 1 file changed, 444 insertions(+) create mode 100644 test/js/node/test/parallel/test-buffer-fill.js diff --git a/test/js/node/test/parallel/test-buffer-fill.js b/test/js/node/test/parallel/test-buffer-fill.js new file mode 100644 index 00000000000000..55e5d3399f241f --- /dev/null +++ b/test/js/node/test/parallel/test-buffer-fill.js @@ -0,0 +1,444 @@ +// Flags: --expose-internals +'use strict'; +const common = require('../common'); +const assert = require('assert'); +// const { codes: { ERR_OUT_OF_RANGE } } = require('internal/errors'); +// const { internalBinding } = require('internal/test/binding'); +const SIZE = 28; + +const buf1 = Buffer.allocUnsafe(SIZE); +const buf2 = Buffer.allocUnsafe(SIZE); + +// Default encoding +testBufs('abc'); +testBufs('\u0222aa'); +testBufs('a\u0234b\u0235c\u0236'); +testBufs('abc', 4); +testBufs('abc', 5); +testBufs('abc', SIZE); +testBufs('\u0222aa', 2); +testBufs('\u0222aa', 8); +testBufs('a\u0234b\u0235c\u0236', 4); +testBufs('a\u0234b\u0235c\u0236', 12); +testBufs('abc', 4, 1); +testBufs('abc', 5, 1); +testBufs('\u0222aa', 8, 1); +testBufs('a\u0234b\u0235c\u0236', 4, 1); +testBufs('a\u0234b\u0235c\u0236', 12, 1); + +// UTF8 +testBufs('abc', 'utf8'); +testBufs('\u0222aa', 'utf8'); +testBufs('a\u0234b\u0235c\u0236', 'utf8'); +testBufs('abc', 4, 'utf8'); +testBufs('abc', 5, 'utf8'); +testBufs('abc', SIZE, 'utf8'); +testBufs('\u0222aa', 2, 'utf8'); +testBufs('\u0222aa', 8, 'utf8'); +testBufs('a\u0234b\u0235c\u0236', 4, 'utf8'); +testBufs('a\u0234b\u0235c\u0236', 12, 'utf8'); +testBufs('abc', 4, 1, 'utf8'); +testBufs('abc', 5, 1, 'utf8'); +testBufs('\u0222aa', 8, 1, 'utf8'); +testBufs('a\u0234b\u0235c\u0236', 4, 1, 'utf8'); +testBufs('a\u0234b\u0235c\u0236', 12, 1, 'utf8'); +assert.strictEqual(Buffer.allocUnsafe(1).fill(0).fill('\u0222')[0], 0xc8); + +// BINARY +testBufs('abc', 'binary'); +testBufs('\u0222aa', 'binary'); +testBufs('a\u0234b\u0235c\u0236', 'binary'); +testBufs('abc', 4, 'binary'); +testBufs('abc', 5, 'binary'); +testBufs('abc', SIZE, 'binary'); +testBufs('\u0222aa', 2, 'binary'); +testBufs('\u0222aa', 8, 'binary'); +testBufs('a\u0234b\u0235c\u0236', 4, 'binary'); +testBufs('a\u0234b\u0235c\u0236', 12, 'binary'); +testBufs('abc', 4, 1, 'binary'); +testBufs('abc', 5, 1, 'binary'); +testBufs('\u0222aa', 8, 1, 'binary'); +testBufs('a\u0234b\u0235c\u0236', 4, 1, 'binary'); +testBufs('a\u0234b\u0235c\u0236', 12, 1, 'binary'); + +// LATIN1 +testBufs('abc', 'latin1'); +testBufs('\u0222aa', 'latin1'); +testBufs('a\u0234b\u0235c\u0236', 'latin1'); +testBufs('abc', 4, 'latin1'); +testBufs('abc', 5, 'latin1'); +testBufs('abc', SIZE, 'latin1'); +testBufs('\u0222aa', 2, 'latin1'); +testBufs('\u0222aa', 8, 'latin1'); +testBufs('a\u0234b\u0235c\u0236', 4, 'latin1'); +testBufs('a\u0234b\u0235c\u0236', 12, 'latin1'); +testBufs('abc', 4, 1, 'latin1'); +testBufs('abc', 5, 1, 'latin1'); +testBufs('\u0222aa', 8, 1, 'latin1'); +testBufs('a\u0234b\u0235c\u0236', 4, 1, 'latin1'); +testBufs('a\u0234b\u0235c\u0236', 12, 1, 'latin1'); + +// UCS2 +testBufs('abc', 'ucs2'); +testBufs('\u0222aa', 'ucs2'); +testBufs('a\u0234b\u0235c\u0236', 'ucs2'); +testBufs('abc', 4, 'ucs2'); +testBufs('abc', SIZE, 'ucs2'); +testBufs('\u0222aa', 2, 'ucs2'); +testBufs('\u0222aa', 8, 'ucs2'); +testBufs('a\u0234b\u0235c\u0236', 4, 'ucs2'); +testBufs('a\u0234b\u0235c\u0236', 12, 'ucs2'); +testBufs('abc', 4, 1, 'ucs2'); +testBufs('abc', 5, 1, 'ucs2'); +testBufs('\u0222aa', 8, 1, 'ucs2'); +testBufs('a\u0234b\u0235c\u0236', 4, 1, 'ucs2'); +testBufs('a\u0234b\u0235c\u0236', 12, 1, 'ucs2'); +assert.strictEqual(Buffer.allocUnsafe(1).fill('\u0222', 'ucs2')[0], 0x22); + +// HEX +testBufs('616263', 'hex'); +testBufs('c8a26161', 'hex'); +testBufs('61c8b462c8b563c8b6', 'hex'); +testBufs('616263', 4, 'hex'); +testBufs('616263', 5, 'hex'); +testBufs('616263', SIZE, 'hex'); +testBufs('c8a26161', 2, 'hex'); +testBufs('c8a26161', 8, 'hex'); +testBufs('61c8b462c8b563c8b6', 4, 'hex'); +testBufs('61c8b462c8b563c8b6', 12, 'hex'); +testBufs('616263', 4, 1, 'hex'); +testBufs('616263', 5, 1, 'hex'); +testBufs('c8a26161', 8, 1, 'hex'); +testBufs('61c8b462c8b563c8b6', 4, 1, 'hex'); +testBufs('61c8b462c8b563c8b6', 12, 1, 'hex'); + +assert.throws(() => { + const buf = Buffer.allocUnsafe(SIZE); + + buf.fill('yKJh', 'hex'); +}, { + code: 'ERR_INVALID_ARG_VALUE', + name: 'TypeError' +}); + +assert.throws(() => { + const buf = Buffer.allocUnsafe(SIZE); + + buf.fill('\u0222', 'hex'); +}, { + code: 'ERR_INVALID_ARG_VALUE', + name: 'TypeError' +}); + +// BASE64 +testBufs('YWJj', 'base64'); +testBufs('yKJhYQ==', 'base64'); +testBufs('Yci0Ysi1Y8i2', 'base64'); +testBufs('YWJj', 4, 'base64'); +testBufs('YWJj', SIZE, 'base64'); +testBufs('yKJhYQ==', 2, 'base64'); +testBufs('yKJhYQ==', 8, 'base64'); +testBufs('Yci0Ysi1Y8i2', 4, 'base64'); +testBufs('Yci0Ysi1Y8i2', 12, 'base64'); +testBufs('YWJj', 4, 1, 'base64'); +testBufs('YWJj', 5, 1, 'base64'); +testBufs('yKJhYQ==', 8, 1, 'base64'); +testBufs('Yci0Ysi1Y8i2', 4, 1, 'base64'); +testBufs('Yci0Ysi1Y8i2', 12, 1, 'base64'); + +// BASE64URL +testBufs('YWJj', 'base64url'); +testBufs('yKJhYQ', 'base64url'); +testBufs('Yci0Ysi1Y8i2', 'base64url'); +testBufs('YWJj', 4, 'base64url'); +testBufs('YWJj', SIZE, 'base64url'); +testBufs('yKJhYQ', 2, 'base64url'); +testBufs('yKJhYQ', 8, 'base64url'); +testBufs('Yci0Ysi1Y8i2', 4, 'base64url'); +testBufs('Yci0Ysi1Y8i2', 12, 'base64url'); +testBufs('YWJj', 4, 1, 'base64url'); +testBufs('YWJj', 5, 1, 'base64url'); +testBufs('yKJhYQ', 8, 1, 'base64url'); +testBufs('Yci0Ysi1Y8i2', 4, 1, 'base64url'); +testBufs('Yci0Ysi1Y8i2', 12, 1, 'base64url'); + +// Buffer +function deepStrictEqualValues(buf, arr) { + for (const [index, value] of buf.entries()) { + assert.deepStrictEqual(value, arr[index]); + } +} + +const buf2Fill = Buffer.allocUnsafe(1).fill(2); +deepStrictEqualValues(genBuffer(4, [buf2Fill]), [2, 2, 2, 2]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1]), [0, 2, 2, 2]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 3]), [0, 2, 2, 0]); +deepStrictEqualValues(genBuffer(4, [buf2Fill, 1, 1]), [0, 0, 0, 0]); +const hexBufFill = Buffer.allocUnsafe(2).fill(0).fill('0102', 'hex'); +deepStrictEqualValues(genBuffer(4, [hexBufFill]), [1, 2, 1, 2]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1]), [0, 1, 2, 1]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 3]), [0, 1, 2, 0]); +deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, 1]), [0, 0, 0, 0]); + +// Check exceptions +[ + [0, -1], + [0, 0, buf1.length + 1], + ['', -1], + ['', 0, buf1.length + 1], + ['', 1, -1], +].forEach((args) => { + assert.throws( + () => buf1.fill(...args), + { code: 'ERR_OUT_OF_RANGE' } + ); +}); + +assert.throws( + () => buf1.fill('a', 0, buf1.length, 'node rocks!'), + { + code: 'ERR_UNKNOWN_ENCODING', + name: 'TypeError', + message: 'Unknown encoding: node rocks!' + } +); + +[ + ['a', 0, 0, NaN], + ['a', 0, 0, false], +].forEach((args) => { + assert.throws( + () => buf1.fill(...args), + { + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "encoding" argument must be of type ' + + `string.${common.invalidArgTypeHelper(args[3])}` + } + ); +}); + +assert.throws( + () => buf1.fill('a', 0, 0, 'foo'), + { + code: 'ERR_UNKNOWN_ENCODING', + name: 'TypeError', + message: 'Unknown encoding: foo' + } +); + +function genBuffer(size, args) { + const b = Buffer.allocUnsafe(size); + return b.fill(0).fill.apply(b, args); +} + +function bufReset() { + buf1.fill(0); + buf2.fill(0); +} + +// This is mostly accurate. Except write() won't write partial bytes to the +// string while fill() blindly copies bytes into memory. To account for that an +// error will be thrown if not all the data can be written, and the SIZE has +// been massaged to work with the input characters. +function writeToFill(string, offset, end, encoding) { + if (typeof offset === 'string') { + encoding = offset; + offset = 0; + end = buf2.length; + } else if (typeof end === 'string') { + encoding = end; + end = buf2.length; + } else if (end === undefined) { + end = buf2.length; + } + + // Should never be reached. + if (offset < 0 || end > buf2.length) + throw new ERR_OUT_OF_RANGE(); + + if (end <= offset) + return buf2; + + offset >>>= 0; + end >>>= 0; + assert(offset <= buf2.length); + + // Convert "end" to "length" (which write understands). + const length = end - offset < 0 ? 0 : end - offset; + + let wasZero = false; + do { + const written = buf2.write(string, offset, length, encoding); + offset += written; + // Safety check in case write falls into infinite loop. + if (written === 0) { + if (wasZero) + throw new Error('Could not write all data to Buffer'); + else + wasZero = true; + } + } while (offset < buf2.length); + + return buf2; +} + +function testBufs(string, offset, length, encoding) { + bufReset(); + buf1.fill.apply(buf1, arguments); + // Swap bytes on BE archs for ucs2 encoding. + assert.deepStrictEqual(buf1.fill.apply(buf1, arguments), + writeToFill.apply(null, arguments)); +} + +// Make sure these throw. +assert.throws( + () => Buffer.allocUnsafe(8).fill('a', -1), + { code: 'ERR_OUT_OF_RANGE' }); +assert.throws( + () => Buffer.allocUnsafe(8).fill('a', 0, 9), + { code: 'ERR_OUT_OF_RANGE' }); + +// Make sure this doesn't hang indefinitely. +Buffer.allocUnsafe(8).fill(''); +Buffer.alloc(8, ''); + +{ + const buf = Buffer.alloc(64, 10); + for (let i = 0; i < buf.length; i++) + assert.strictEqual(buf[i], 10); + + buf.fill(11, 0, buf.length >> 1); + for (let i = 0; i < buf.length >> 1; i++) + assert.strictEqual(buf[i], 11); + for (let i = (buf.length >> 1) + 1; i < buf.length; i++) + assert.strictEqual(buf[i], 10); + + buf.fill('h'); + for (let i = 0; i < buf.length; i++) + assert.strictEqual(buf[i], 'h'.charCodeAt(0)); + + buf.fill(0); + for (let i = 0; i < buf.length; i++) + assert.strictEqual(buf[i], 0); + + buf.fill(null); + for (let i = 0; i < buf.length; i++) + assert.strictEqual(buf[i], 0); + + buf.fill(1, 16, 32); + for (let i = 0; i < 16; i++) + assert.strictEqual(buf[i], 0); + for (let i = 16; i < 32; i++) + assert.strictEqual(buf[i], 1); + for (let i = 32; i < buf.length; i++) + assert.strictEqual(buf[i], 0); +} + +{ + const buf = Buffer.alloc(10, 'abc'); + assert.strictEqual(buf.toString(), 'abcabcabca'); + buf.fill('է'); + assert.strictEqual(buf.toString(), 'էէէէէ'); +} + +// Testing process.binding. Make sure "start" is properly checked for range errors. +// assert.throws( +// () => { process.binding('buffer').fill(Buffer.alloc(1), 1, -1, 0, 1); }, +// { code: 'ERR_OUT_OF_RANGE' } +// ); + +// Make sure "end" is properly checked, even if it's magically mangled using +// Symbol.toPrimitive. +{ + assert.throws(() => { + const end = { + [Symbol.toPrimitive]() { + return 1; + } + }; + Buffer.alloc(1).fill(Buffer.alloc(1), 0, end); + }, { + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "end" argument must be of type number. Received an ' + + 'instance of Object' + }); +} + +// Testing process.binding. Make sure "end" is properly checked for range errors. +// assert.throws( +// () => { internalBinding('buffer').fill(Buffer.alloc(1), 1, 1, -2, 1); }, +// { code: 'ERR_OUT_OF_RANGE' } +// ); + +// Test that bypassing 'length' won't cause an abort. +// assert.throws(() => { +// const buf = Buffer.from('w00t'); +// Object.defineProperty(buf, 'length', { +// value: 1337, +// enumerable: true +// }); +// buf.fill(''); +// }, { +// code: 'ERR_BUFFER_OUT_OF_BOUNDS', +// name: 'RangeError', +// message: 'Attempt to access memory outside buffer bounds' +// }); + +assert.deepStrictEqual( + Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'), + Buffer.from('61006200610062006100620061006200', 'hex')); + +assert.deepStrictEqual( + Buffer.allocUnsafeSlow(15).fill('ab', 'utf16le'), + Buffer.from('610062006100620061006200610062', 'hex')); + +assert.deepStrictEqual( + Buffer.allocUnsafeSlow(16).fill('ab', 'utf16le'), + Buffer.from('61006200610062006100620061006200', 'hex')); +assert.deepStrictEqual( + Buffer.allocUnsafeSlow(16).fill('a', 'utf16le'), + Buffer.from('61006100610061006100610061006100', 'hex')); + +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('a', 'utf16le').toString('utf16le'), + 'a'.repeat(8)); +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('a', 'latin1').toString('latin1'), + 'a'.repeat(16)); +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('a', 'utf8').toString('utf8'), + 'a'.repeat(16)); + +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('Љ', 'utf16le').toString('utf16le'), + 'Љ'.repeat(8)); +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('Љ', 'latin1').toString('latin1'), + '\t'.repeat(16)); +assert.strictEqual( + Buffer.allocUnsafeSlow(16).fill('Љ', 'utf8').toString('utf8'), + 'Љ'.repeat(8)); + +assert.throws(() => { + const buf = Buffer.from('a'.repeat(1000)); + + buf.fill('This is not correctly encoded', 'hex'); +}, { + code: 'ERR_INVALID_ARG_VALUE', + name: 'TypeError' +}); + + +{ + const bufEmptyString = Buffer.alloc(5, ''); + assert.strictEqual(bufEmptyString.toString(), '\x00\x00\x00\x00\x00'); + + const bufEmptyArray = Buffer.alloc(5, []); + assert.strictEqual(bufEmptyArray.toString(), '\x00\x00\x00\x00\x00'); + + const bufEmptyBuffer = Buffer.alloc(5, Buffer.alloc(5)); + assert.strictEqual(bufEmptyBuffer.toString(), '\x00\x00\x00\x00\x00'); + + const bufZero = Buffer.alloc(5, 0); + assert.strictEqual(bufZero.toString(), '\x00\x00\x00\x00\x00'); +} From 8634ee30658be39e0b55457b0fedc01afef9a14f Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 4 Feb 2025 20:19:22 -0800 Subject: [PATCH 26/29] fix test-buffer-copy.js (#16640) --- src/bun.js/bindings/JSBuffer.cpp | 60 ++++- .../js/node/test/parallel/test-buffer-copy.js | 237 ++++++++++++++++++ 2 files changed, 285 insertions(+), 12 deletions(-) create mode 100644 test/js/node/test/parallel/test-buffer-copy.js diff --git a/src/bun.js/bindings/JSBuffer.cpp b/src/bun.js/bindings/JSBuffer.cpp index 79d1b76221c86a..662bad2b86a2ea 100644 --- a/src/bun.js/bindings/JSBuffer.cpp +++ b/src/bun.js/bindings/JSBuffer.cpp @@ -231,6 +231,7 @@ static JSUint8Array* allocBuffer(JSC::JSGlobalObject* lexicalGlobalObject, size_ return uint8Array; } + static JSUint8Array* allocBufferUnsafe(JSC::JSGlobalObject* lexicalGlobalObject, size_t byteLength) { @@ -544,12 +545,11 @@ static JSC::EncodedJSValue constructFromEncoding(JSGlobalObject* lexicalGlobalOb static inline JSC::EncodedJSValue constructBufferFromStringAndEncoding(JSC::JSGlobalObject* lexicalGlobalObject, JSValue arg0, JSValue arg1) { auto& vm = JSC::getVM(lexicalGlobalObject); - WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; - auto scope = DECLARE_THROW_SCOPE(vm); - auto* str = arg0.toString(lexicalGlobalObject); + WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; + auto* str = arg0.toString(lexicalGlobalObject); RETURN_IF_EXCEPTION(scope, {}); if (arg1 && arg1.isString()) { @@ -680,7 +680,9 @@ JSC_DEFINE_HOST_FUNCTION(constructSlowBuffer, (JSGlobalObject * lexicalGlobalObj static inline JSC::EncodedJSValue jsBufferByteLengthFromStringAndEncoding(JSC::JSGlobalObject* lexicalGlobalObject, JSString* str, WebCore::BufferEncodingType encoding) { - auto scope = DECLARE_THROW_SCOPE(lexicalGlobalObject->vm()); + auto& vm = JSC::getVM(lexicalGlobalObject); + auto scope = DECLARE_THROW_SCOPE(vm); + if (!str) { throwTypeError(lexicalGlobalObject, scope, "byteLength() expects a string"_s); return {}; @@ -695,16 +697,15 @@ static inline JSC::EncodedJSValue jsBufferByteLengthFromStringAndEncoding(JSC::J return {}; } + static inline JSC::EncodedJSValue jsBufferConstructorFunction_byteLengthBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { auto& vm = JSC::getVM(lexicalGlobalObject); + auto scope = DECLARE_THROW_SCOPE(vm); WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; - auto scope = DECLARE_THROW_SCOPE(vm); - EnsureStillAliveScope arg0 = callFrame->argument(0); - EnsureStillAliveScope arg1 = callFrame->argument(1); if (callFrame->argumentCount() > 1) { @@ -783,9 +784,12 @@ static inline JSC::EncodedJSValue jsBufferConstructorFunction_compareBody(JSC::J static inline JSC::EncodedJSValue jsBufferConstructorFunction_concatBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame) { - auto& vm = lexicalGlobalObject->vm(); - + auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); + + if (callFrame->argumentCount() < 1) { + return constructBufferEmpty(lexicalGlobalObject); + } auto listValue = callFrame->argument(0); Bun::V::validateArray(throwScope, lexicalGlobalObject, listValue, "list"_s, jsUndefined()); @@ -1167,6 +1171,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_equalsBody(JSC::JSGl { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); + if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, throwScope, createNotEnoughArgumentsError(lexicalGlobalObject)); return {}; @@ -1197,6 +1202,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_equalsBody(JSC::JSGl RELEASE_AND_RETURN(throwScope, JSC::JSValue::encode(JSC::jsBoolean(normalizeCompareVal(result, a_length, b_length) == 0))); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_fillBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); @@ -1350,6 +1356,7 @@ static int64_t indexOf(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); + if (callFrame->argumentCount() < 1) { throwVMError(lexicalGlobalObject, scope, createNotEnoughArgumentsError(lexicalGlobalObject)); return -1; @@ -1456,16 +1463,19 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_includesBody(JSC::JS auto index = indexOf(lexicalGlobalObject, callFrame, castedThis, false); return JSC::JSValue::encode(jsBoolean(index != -1)); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_indexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto index = indexOf(lexicalGlobalObject, callFrame, castedThis, false); return JSC::JSValue::encode(jsNumber(index)); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_lastIndexOfBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto index = indexOf(lexicalGlobalObject, callFrame, castedThis, true); return JSC::JSValue::encode(jsNumber(index)); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap16Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); @@ -1495,6 +1505,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap16Body(JSC::JSGl return JSC::JSValue::encode(castedThis); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap32Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); @@ -1529,6 +1540,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap32Body(JSC::JSGl return JSC::JSValue::encode(castedThis); } + static inline JSC::EncodedJSValue jsBufferPrototypeFunction_swap64Body(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); @@ -1661,6 +1673,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_toStringBody(JSC::JS { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); + uint32_t start = 0; uint32_t end = castedThis->byteLength(); uint32_t byteLength = end; @@ -1715,6 +1728,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_SliceWithEncoding(JS { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); + auto* castedThis = JSC::jsDynamicCast(callFrame->thisValue()); const JSValue startValue = callFrame->argument(0); const JSValue endValue = callFrame->argument(1); @@ -1807,6 +1821,7 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunctionWriteWithEncoding(JSC { auto& vm = JSC::getVM(lexicalGlobalObject); auto scope = DECLARE_THROW_SCOPE(vm); + auto* castedThis = JSC::jsDynamicCast(callFrame->thisValue()); JSString* text = callFrame->argument(0).toStringOrNull(lexicalGlobalObject); @@ -1831,13 +1846,13 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunctionWriteWithEncoding(JSC static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation::ClassParameter castedThis) { auto& vm = JSC::getVM(lexicalGlobalObject); + auto scope = DECLARE_THROW_SCOPE(vm); + uint32_t offset = 0; uint32_t length = castedThis->byteLength(); uint32_t max = length; WebCore::BufferEncodingType encoding = WebCore::BufferEncodingType::utf8; - auto scope = DECLARE_THROW_SCOPE(vm); - if (UNLIKELY(callFrame->argumentCount() == 0)) { throwTypeError(lexicalGlobalObject, scope, "Not enough arguments"_s); return {}; @@ -1922,7 +1937,6 @@ static inline JSC::EncodedJSValue jsBufferPrototypeFunction_writeBody(JSC::JSGlo extern "C" JSC::EncodedJSValue JSBuffer__fromMmap(Zig::GlobalObject* globalObject, void* ptr, size_t length) { - auto& vm = JSC::getVM(globalObject); auto scope = DECLARE_THROW_SCOPE(vm); @@ -1950,14 +1964,17 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_alloc, (JSGlobalObject * le { return jsBufferConstructorFunction_allocBody(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafe, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferConstructorFunction_allocUnsafeBody(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_allocUnsafeSlow, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferConstructorFunction_allocUnsafeSlowBody(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferConstructorFunction_byteLength, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferConstructorFunction_byteLengthBody(lexicalGlobalObject, callFrame); @@ -2076,46 +2093,57 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_compare, (JSGlobalObject * le { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "compare"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_copy, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "copy"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_equals, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "equals"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_fill, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "fill"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_includes, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "includes"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_indexOf, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "indexOf"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_lastIndexOf, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "lastIndexOf"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_swap16, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "swap16"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_swap32, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "swap32"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_swap64, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "swap64"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_toString, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "toString"); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_write, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation::call(*lexicalGlobalObject, *callFrame, "write"); @@ -2160,26 +2188,32 @@ JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_utf8Slice, (JSGlobalObject * { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_utf16leSlice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_latin1Slice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_asciiSlice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_base64Slice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_base64urlSlice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); } + JSC_DEFINE_HOST_FUNCTION(jsBufferPrototypeFunction_hexSlice, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return jsBufferPrototypeFunction_SliceWithEncoding(lexicalGlobalObject, callFrame); @@ -2366,6 +2400,7 @@ JSC::JSObject* createBufferPrototype(JSC::VM& vm, JSC::JSGlobalObject* globalObj { return JSBufferPrototype::create(vm, globalObject, JSBufferPrototype::createStructure(vm, globalObject, globalObject->m_typedArrayUint8.prototype(globalObject))); } + JSC::JSObject* createBufferConstructor(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSObject* bufferPrototype) { return JSBufferConstructor::create( @@ -2381,6 +2416,7 @@ static inline JSC::EncodedJSValue createJSBufferFromJS(JSC::JSGlobalObject* lexi { auto& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); + size_t argsCount = args.size(); if (argsCount == 0) { RELEASE_AND_RETURN(throwScope, constructBufferEmpty(lexicalGlobalObject)); diff --git a/test/js/node/test/parallel/test-buffer-copy.js b/test/js/node/test/parallel/test-buffer-copy.js new file mode 100644 index 00000000000000..16a638a51181e6 --- /dev/null +++ b/test/js/node/test/parallel/test-buffer-copy.js @@ -0,0 +1,237 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); + +const b = Buffer.allocUnsafe(1024); +const c = Buffer.allocUnsafe(512); + +let cntr = 0; + +{ + // copy 512 bytes, from 0 to 512. + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 512); + assert.strictEqual(copied, 512); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // Current behavior is to coerce values to integers. + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, '0', '0', '512'); + assert.strictEqual(copied, 512); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // Floats will be converted to integers via `Math.floor` + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 512.5); + assert.strictEqual(copied, 512); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // Copy c into b, without specifying sourceEnd + b.fill(++cntr); + c.fill(++cntr); + const copied = c.copy(b, 0, 0); + assert.strictEqual(copied, c.length); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // Copy c into b, without specifying sourceStart + b.fill(++cntr); + c.fill(++cntr); + const copied = c.copy(b, 0); + assert.strictEqual(copied, c.length); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // Copied source range greater than source length + b.fill(++cntr); + c.fill(++cntr); + const copied = c.copy(b, 0, 0, c.length + 1); + assert.strictEqual(copied, c.length); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(b[i], c[i]); + } +} + +{ + // Copy longer buffer b to shorter c without targetStart + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c); + assert.strictEqual(copied, c.length); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // Copy starting near end of b to c + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, b.length - Math.floor(c.length / 2)); + assert.strictEqual(copied, Math.floor(c.length / 2)); + for (let i = 0; i < Math.floor(c.length / 2); i++) { + assert.strictEqual(c[i], b[b.length - Math.floor(c.length / 2) + i]); + } + for (let i = Math.floor(c.length / 2) + 1; i < c.length; i++) { + assert.strictEqual(c[c.length - 1], c[i]); + } +} + +{ + // Try to copy 513 bytes, and check we don't overrun c + b.fill(++cntr); + c.fill(++cntr); + const copied = b.copy(c, 0, 0, 513); + assert.strictEqual(copied, c.length); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +{ + // copy 768 bytes from b into b + b.fill(++cntr); + b.fill(++cntr, 256); + const copied = b.copy(b, 0, 256, 1024); + assert.strictEqual(copied, 768); + for (let i = 0; i < b.length; i++) { + assert.strictEqual(b[i], cntr); + } +} + +// Copy string longer than buffer length (failure will segfault) +const bb = Buffer.allocUnsafe(10); +bb.fill('hello crazy world'); + + +// Try to copy from before the beginning of b. Should not throw. +b.copy(c, 0, 100, 10); + +// Throw with invalid source type +assert.throws( + () => Buffer.prototype.copy.call(0), + { + // code: 'ERR_INVALID_ARG_TYPE', + code: 'ERR_INVALID_THIS', + name: 'TypeError', + } +); + +// Copy throws at negative targetStart +assert.throws( + () => Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), -1, 0), + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError', + message: 'The value of "targetStart" is out of range. ' + + 'It must be >= 0 and <= 5. Received -1' + } +); + +// Copy throws at negative sourceStart +assert.throws( + () => Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, -1), + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError', + } +); + +// Copy throws if sourceStart is greater than length of source +assert.throws( + () => Buffer.allocUnsafe(5).copy(Buffer.allocUnsafe(5), 0, 100), + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError', + } +); + +{ + // Check sourceEnd resets to targetEnd if former is greater than the latter + b.fill(++cntr); + c.fill(++cntr); + b.copy(c, 0, 0, 1025); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], b[i]); + } +} + +// Throw with negative sourceEnd +assert.throws( + () => b.copy(c, 0, 0, -1), + { + code: 'ERR_OUT_OF_RANGE', + name: 'RangeError', + message: 'The value of "sourceEnd" is out of range. ' + + 'It must be >= 0 and <= 1024. Received -1' + } +); + +// When sourceStart is greater than sourceEnd, zero copied +assert.strictEqual(b.copy(c, 0, 100, 10), 0); + +// When targetStart > targetLength, zero copied +assert.strictEqual(b.copy(c, 512, 0, 10), 0); + +// Test that the `target` can be a Uint8Array. +{ + const d = new Uint8Array(c); + // copy 512 bytes, from 0 to 512. + b.fill(++cntr); + d.fill(++cntr); + const copied = b.copy(d, 0, 0, 512); + assert.strictEqual(copied, 512); + for (let i = 0; i < d.length; i++) { + assert.strictEqual(d[i], b[i]); + } +} + +// Test that the source can be a Uint8Array, too. +{ + const e = new Uint8Array(b); + // copy 512 bytes, from 0 to 512. + e.fill(++cntr); + c.fill(++cntr); + const copied = Buffer.prototype.copy.call(e, c, 0, 0, 512); + assert.strictEqual(copied, 512); + for (let i = 0; i < c.length; i++) { + assert.strictEqual(c[i], e[i]); + } +} + +// https://github.com/nodejs/node/issues/23668: Do not crash for invalid input. +c.fill('c'); +b.copy(c, 'not a valid offset'); +// Make sure this acted like a regular copy with `0` offset. +assert.deepStrictEqual(c, b.slice(0, c.length)); + +{ + c.fill('C'); + assert.throws(() => { + b.copy(c, { [Symbol.toPrimitive]() { throw new Error('foo'); } }); + }, /foo/); + // No copying took place: + assert.deepStrictEqual(c.toString(), 'C'.repeat(c.length)); +} From dcf0b719a50952b5bee0ebce98451c7849de1e6d Mon Sep 17 00:00:00 2001 From: Zack Radisic <56137411+zackradisic@users.noreply.github.com> Date: Tue, 4 Feb 2025 22:50:41 -0800 Subject: [PATCH 27/29] CSS Fixes: light dark, color down-leveling bugs, implement minify for box-shadow (#17055) --- packages/bun-native-plugin-rs/Cargo.toml | 6 +- packages/bun-native-plugin-rs/src/lib.rs | 39 ++- src/css/context.zig | 6 +- src/css/declaration.zig | 8 + src/css/properties/box_shadow.zig | 143 ++++++++- src/css/properties/custom.zig | 5 +- src/css/properties/generate_properties.ts | 8 +- src/css/properties/properties_generated.zig | 45 ++- src/css/properties/ui.zig | 119 +++++++ src/css/rules/rules.zig | 4 +- src/css/values/color.zig | 24 +- src/css/values/length.zig | 4 + test/js/bun/css/css.test.ts | 332 +++++++++++++++++++- 13 files changed, 692 insertions(+), 51 deletions(-) diff --git a/packages/bun-native-plugin-rs/Cargo.toml b/packages/bun-native-plugin-rs/Cargo.toml index 8ab8e3fa7fb9b8..b6ebc1206391f9 100644 --- a/packages/bun-native-plugin-rs/Cargo.toml +++ b/packages/bun-native-plugin-rs/Cargo.toml @@ -2,16 +2,12 @@ name = "bun-native-plugin" description = "Rustified wrapper for writing native plugins for Bun." license = "MIT" -version = "0.1.2" +version = "0.2.0" edition = "2021" [dependencies] anyhow = "1.0.94" # use local path in dev and publish to crates.io in prod bun-macro = { path = "./bun-macro", version = "0.1.0" } -napi = { version = "2.14.1", default-features = false, features = ["napi4"] } -[features] -default = ["napi"] -napi = [] diff --git a/packages/bun-native-plugin-rs/src/lib.rs b/packages/bun-native-plugin-rs/src/lib.rs index e477bc5645b7a9..b732578a4c063b 100644 --- a/packages/bun-native-plugin-rs/src/lib.rs +++ b/packages/bun-native-plugin-rs/src/lib.rs @@ -473,6 +473,10 @@ impl<'a> OnBeforeParse<'a> { } } + /// # Safety + /// This is unsafe as you must ensure that no other invocation of the plugin (or JS!) + /// simultaneously holds a mutable reference to the external. + /// /// Get the external object from the `OnBeforeParse` arguments. /// /// The external object is set by the plugin definition inside of JS: @@ -521,42 +525,35 @@ impl<'a> OnBeforeParse<'a> { /// }, /// }; /// ``` - pub unsafe fn external(&self) -> PluginResult> { + pub unsafe fn external<'b, T: 'static + Sync>( + &self, + from_raw: unsafe fn(*mut c_void) -> Option<&'b T>, + ) -> PluginResult> { if unsafe { (*self.args_raw).external.is_null() } { return Ok(None); } - let external: *mut TaggedObject = - unsafe { (*self.args_raw).external as *mut TaggedObject }; - - unsafe { - if (*external).type_id != TypeId::of::() { - return Err(Error::ExternalTypeMismatch); - } + let external = unsafe { from_raw((*self.args_raw).external as *mut _) }; - Ok((*external).object.as_ref()) - } + Ok(external) } /// The same as [`crate::bun_native_plugin::OnBeforeParse::external`], but returns a mutable reference. /// - /// This is unsafe as you must ensure that no other invocation of the plugin + /// # Safety + /// This is unsafe as you must ensure that no other invocation of the plugin (or JS!) /// simultaneously holds a mutable reference to the external. - pub unsafe fn external_mut(&mut self) -> PluginResult> { + pub unsafe fn external_mut<'b, T: 'static + Sync>( + &mut self, + from_raw: unsafe fn(*mut c_void) -> Option<&'b mut T>, + ) -> PluginResult> { if unsafe { (*self.args_raw).external.is_null() } { return Ok(None); } - let external: *mut TaggedObject = - unsafe { (*self.args_raw).external as *mut TaggedObject }; + let external = unsafe { from_raw((*self.args_raw).external as *mut _) }; - unsafe { - if (*external).type_id != TypeId::of::() { - return Err(Error::ExternalTypeMismatch); - } - - Ok((*external).object.as_mut()) - } + Ok(external) } /// Get the input source code for the current file. diff --git a/src/css/context.zig b/src/css/context.zig index 09c9e59373c206..7a76deafbaedc0 100644 --- a/src/css/context.zig +++ b/src/css/context.zig @@ -81,6 +81,10 @@ pub const PropertyHandlerContext = struct { }; } + pub fn addDarkRule(this: *@This(), allocator: Allocator, property: css.Property) void { + this.dark.append(allocator, property) catch bun.outOfMemory(); + } + pub fn addLogicalRule(this: *@This(), allocator: Allocator, ltr: css.Property, rtl: css.Property) void { this.ltr.append(allocator, ltr) catch unreachable; this.rtl.append(allocator, rtl) catch unreachable; @@ -171,7 +175,7 @@ pub const PropertyHandlerContext = struct { .feature = MediaFeature{ .plain = .{ .name = .{ .standard = MediaFeatureId.@"prefers-color-scheme" }, - .value = .{ .ident = .{ .v = "dark " } }, + .value = .{ .ident = .{ .v = "dark" } }, }, }, }, diff --git a/src/css/declaration.zig b/src/css/declaration.zig index 6c09604cd3ad70..c2bb443209248b 100644 --- a/src/css/declaration.zig +++ b/src/css/declaration.zig @@ -27,6 +27,8 @@ const FlexHandler = css.css_properties.flex.FlexHandler; const AlignHandler = css.css_properties.@"align".AlignHandler; const TransitionHandler = css.css_properties.transition.TransitionHandler; const TransformHandler = css.css_properties.transform.TransformHandler; +const ColorSchemeHandler = css.css_properties.ui.ColorSchemeHandler; +const BoxShadowHandler = css.css_properties.box_shadow.BoxShadowHandler; // const GridHandler = css.css_properties.g /// A CSS declaration block. @@ -347,6 +349,8 @@ pub const DeclarationHandler = struct { font: FontHandler = .{}, inset: InsetHandler = .{}, transform: TransformHandler = .{}, + box_shadow: BoxShadowHandler = .{}, + color_scheme: ColorSchemeHandler = .{}, fallback: FallbackHandler = .{}, direction: ?css.css_properties.text.Direction, decls: DeclarationList, @@ -375,6 +379,8 @@ pub const DeclarationHandler = struct { this.font.finalize(&this.decls, context); this.inset.finalize(&this.decls, context); this.transform.finalize(&this.decls, context); + this.box_shadow.finalize(&this.decls, context); + this.color_scheme.finalize(&this.decls, context); this.fallback.finalize(&this.decls, context); } @@ -392,6 +398,8 @@ pub const DeclarationHandler = struct { this.font.handleProperty(property, &this.decls, context) or this.inset.handleProperty(property, &this.decls, context) or this.transform.handleProperty(property, &this.decls, context) or + this.box_shadow.handleProperty(property, &this.decls, context) or + this.color_scheme.handleProperty(property, &this.decls, context) or this.fallback.handleProperty(property, &this.decls, context); } diff --git a/src/css/properties/box_shadow.zig b/src/css/properties/box_shadow.zig index dea6c1bf535f01..472ca82ee87ab3 100644 --- a/src/css/properties/box_shadow.zig +++ b/src/css/properties/box_shadow.zig @@ -19,10 +19,15 @@ const DashedIdent = css.css_values.ident.DashedIdent; const Image = css.css_values.image.Image; const CssColor = css.css_values.color.CssColor; const Ratio = css.css_values.ratio.Ratio; -const Length = css.css_values.length.LengthValue; +const Length = css.css_values.length.Length; const Rect = css.css_values.rect.Rect; const NumberOrPercentage = css.css_values.percentage.NumberOrPercentage; +const VendorPrefix = css.VendorPrefix; +const Property = css.Property; +const PropertyId = css.PropertyId; +const Feature = css.prefixes.Feature; + /// A value for the [box-shadow](https://drafts.csswg.org/css-backgrounds/#box-shadow) property. pub const BoxShadow = struct { /// The color of the box shadow. @@ -128,4 +133,140 @@ pub const BoxShadow = struct { pub fn eql(lhs: *const @This(), rhs: *const @This()) bool { return css.implementEql(@This(), lhs, rhs); } + + pub fn isCompatible(this: *const @This(), browsers: css.targets.Browsers) bool { + return this.color.isCompatible(browsers) and + this.x_offset.isCompatible(browsers) and + this.y_offset.isCompatible(browsers) and + this.blur.isCompatible(browsers) and + this.spread.isCompatible(browsers); + } +}; + +pub const BoxShadowHandler = struct { + box_shadows: ?struct { SmallList(BoxShadow, 1), VendorPrefix } = null, + flushed: bool = false, + + pub fn handleProperty(this: *@This(), property: *const Property, dest: *css.DeclarationList, context: *css.PropertyHandlerContext) bool { + switch (property.*) { + .@"box-shadow" => |*b| { + const box_shadows: *const SmallList(BoxShadow, 1) = &b.*[0]; + const prefix: VendorPrefix = b.*[1]; + if (this.box_shadows != null and context.targets.browsers != null and !box_shadows.isCompatible(context.targets.browsers.?)) { + this.flush(dest, context); + } + + if (this.box_shadows) |*bxs| { + const val: *SmallList(BoxShadow, 1) = &bxs.*[0]; + const prefixes: *VendorPrefix = &bxs.*[1]; + if (!val.eql(box_shadows) and !prefixes.contains(prefix)) { + this.flush(dest, context); + this.box_shadows = .{ + box_shadows.deepClone(context.allocator), + prefix, + }; + } else { + val.* = box_shadows.deepClone(context.allocator); + prefixes.insert(prefix); + } + } else { + this.box_shadows = .{ + box_shadows.deepClone(context.allocator), + prefix, + }; + } + }, + .unparsed => |unp| { + if (unp.property_id == .@"box-shadow") { + this.flush(dest, context); + + var unparsed = unp.deepClone(context.allocator); + context.addUnparsedFallbacks(&unparsed); + dest.append(context.allocator, .{ .unparsed = unparsed }) catch bun.outOfMemory(); + this.flushed = true; + } else return false; + }, + else => return false, + } + + return true; + } + + pub fn finalize(this: *@This(), dest: *css.DeclarationList, context: *css.PropertyHandlerContext) void { + this.flush(dest, context); + this.flushed = false; + } + + pub fn flush(this: *@This(), dest: *css.DeclarationList, context: *css.PropertyHandlerContext) void { + if (this.box_shadows == null) return; + + const box_shadows: SmallList(BoxShadow, 1), const prefixes2: VendorPrefix = bun.take(&this.box_shadows) orelse { + this.flushed = true; + return; + }; + + if (!this.flushed) { + const ColorFallbackKind = css.ColorFallbackKind; + var prefixes = context.targets.prefixes(prefixes2, Feature.box_shadow); + var fallbacks = ColorFallbackKind.empty(); + for (box_shadows.slice()) |*shadow| { + fallbacks.insert(shadow.color.getNecessaryFallbacks(context.targets)); + } + + if (fallbacks.contains(ColorFallbackKind{ .rgb = true })) { + var rgb = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); + rgb.setLen(box_shadows.len()); + for (box_shadows.slice(), rgb.slice_mut()) |*input, *output| { + output.color = input.color.toRGB(context.allocator) orelse input.color.deepClone(context.allocator); + const fields = std.meta.fields(BoxShadow); + inline for (fields) |field| { + if (comptime std.mem.eql(u8, field.name, "color")) continue; + @field(output, field.name) = css.generic.deepClone(field.type, &@field(input, field.name), context.allocator); + } + } + + dest.append(context.allocator, .{ .@"box-shadow" = .{ rgb, prefixes } }) catch bun.outOfMemory(); + if (prefixes.contains(VendorPrefix.NONE)) { + prefixes = VendorPrefix.NONE; + } else { + // Only output RGB for prefixed property (e.g. -webkit-box-shadow) + return; + } + } + + if (fallbacks.contains(ColorFallbackKind.P3)) { + var p3 = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); + p3.setLen(box_shadows.len()); + for (box_shadows.slice(), p3.slice_mut()) |*input, *output| { + output.color = input.color.toP3(context.allocator) orelse input.color.deepClone(context.allocator); + const fields = std.meta.fields(BoxShadow); + inline for (fields) |field| { + if (comptime std.mem.eql(u8, field.name, "color")) continue; + @field(output, field.name) = css.generic.deepClone(field.type, &@field(input, field.name), context.allocator); + } + } + dest.append(context.allocator, .{ .@"box-shadow" = .{ p3, VendorPrefix.NONE } }) catch bun.outOfMemory(); + } + + if (fallbacks.contains(ColorFallbackKind.LAB)) { + var lab = SmallList(BoxShadow, 1).initCapacity(context.allocator, box_shadows.len()); + lab.setLen(box_shadows.len()); + for (box_shadows.slice(), lab.slice_mut()) |*input, *output| { + output.color = input.color.toLAB(context.allocator) orelse input.color.deepClone(context.allocator); + const fields = std.meta.fields(BoxShadow); + inline for (fields) |field| { + if (comptime std.mem.eql(u8, field.name, "color")) continue; + @field(output, field.name) = css.generic.deepClone(field.type, &@field(input, field.name), context.allocator); + } + } + dest.append(context.allocator, .{ .@"box-shadow" = .{ lab, VendorPrefix.NONE } }) catch bun.outOfMemory(); + } else { + dest.append(context.allocator, .{ .@"box-shadow" = .{ box_shadows, prefixes } }) catch bun.outOfMemory(); + } + } else { + dest.append(context.allocator, .{ .@"box-shadow" = .{ box_shadows, prefixes2 } }) catch bun.outOfMemory(); + } + + this.flushed = true; + } }; diff --git a/src/css/properties/custom.zig b/src/css/properties/custom.zig index d955f6566704f4..29ac1c3f87a85d 100644 --- a/src/css/properties/custom.zig +++ b/src/css/properties/custom.zig @@ -859,13 +859,12 @@ pub const UnresolvedColor = union(enum) { const dark: *const TokenList = &ld.dark; if (!dest.targets.isCompatible(.light_dark)) { - // TODO(zack): lightningcss -> buncss - try dest.writeStr("var(--lightningcss-light)"); + try dest.writeStr("var(--buncss-light"); try dest.delim(',', false); try light.toCss(W, dest, is_custom_property); try dest.writeChar(')'); try dest.whitespace(); - try dest.writeStr("var(--lightningcss-dark"); + try dest.writeStr("var(--buncss-dark"); try dest.delim(',', false); try dark.toCss(W, dest, is_custom_property); return dest.writeChar(')'); diff --git a/src/css/properties/generate_properties.ts b/src/css/properties/generate_properties.ts index e78ec97844dcd7..2dbe7defa422cf 100644 --- a/src/css/properties/generate_properties.ts +++ b/src/css/properties/generate_properties.ts @@ -1755,9 +1755,9 @@ generateCode({ // "view-transition-name": { // ty: "CustomIdent", // }, - // "color-scheme": { - // ty: "ColorScheme", - // }, + "color-scheme": { + ty: "ColorScheme", + }, }); function prelude() { @@ -1781,6 +1781,8 @@ const CustomProperty = css.css_properties.custom.CustomProperty; const Targets = css.targets.Targets; const Feature = css.prefixes.Feature; +const ColorScheme = css.css_properties.ui.ColorScheme; + const TransformList = css.css_properties.transform.TransformList; const TransformStyle = css.css_properties.transform.TransformStyle; const TransformBox = css.css_properties.transform.TransformBox; diff --git a/src/css/properties/properties_generated.zig b/src/css/properties/properties_generated.zig index 676fe2b96376e7..16e6bc6d97af8e 100644 --- a/src/css/properties/properties_generated.zig +++ b/src/css/properties/properties_generated.zig @@ -17,6 +17,8 @@ const CustomProperty = css.css_properties.custom.CustomProperty; const Targets = css.targets.Targets; const Feature = css.prefixes.Feature; +const ColorScheme = css.css_properties.ui.ColorScheme; + const TransformList = css.css_properties.transform.TransformList; const TransformStyle = css.css_properties.transform.TransformStyle; const TransformBox = css.css_properties.transform.TransformBox; @@ -501,6 +503,7 @@ pub const Property = union(PropertyIdTag) { @"mask-box-image-width": struct { Rect(BorderImageSideWidth), VendorPrefix }, @"mask-box-image-outset": struct { Rect(LengthOrNumber), VendorPrefix }, @"mask-box-image-repeat": struct { BorderImageRepeat, VendorPrefix }, + @"color-scheme": ColorScheme, all: CSSWideKeyword, unparsed: UnparsedProperty, custom: CustomProperty, @@ -4295,6 +4298,22 @@ pub const Property = union(PropertyIdTag) { compile_error = compile_error ++ @typeName(BorderImageRepeat) ++ ": does not have a eql() function.\n"; } + if (!@hasDecl(ColorScheme, "deepClone")) { + compile_error = compile_error ++ @typeName(ColorScheme) ++ ": does not have a deepClone() function.\n"; + } + + if (!@hasDecl(ColorScheme, "parse")) { + compile_error = compile_error ++ @typeName(ColorScheme) ++ ": does not have a parse() function.\n"; + } + + if (!@hasDecl(ColorScheme, "toCss")) { + compile_error = compile_error ++ @typeName(ColorScheme) ++ ": does not have a toCss() function.\n"; + } + + if (!@hasDecl(ColorScheme, "eql")) { + compile_error = compile_error ++ @typeName(ColorScheme) ++ ": does not have a eql() function.\n"; + } + const final_compile_error = compile_error; break :compile_error final_compile_error; }; @@ -6027,6 +6046,13 @@ pub const Property = union(PropertyIdTag) { } } }, + .@"color-scheme" => { + if (css.generic.parseWithOptions(ColorScheme, input, options).asValue()) |c| { + if (input.expectExhausted().isOk()) { + return .{ .result = .{ .@"color-scheme" = c } }; + } + } + }, .all => return .{ .result = .{ .all = switch (CSSWideKeyword.parse(input)) { .result => |v| v, .err => |e| return .{ .err = e }, @@ -6296,6 +6322,7 @@ pub const Property = union(PropertyIdTag) { .@"mask-box-image-width" => |*v| PropertyId{ .@"mask-box-image-width" = v[1] }, .@"mask-box-image-outset" => |*v| PropertyId{ .@"mask-box-image-outset" = v[1] }, .@"mask-box-image-repeat" => |*v| PropertyId{ .@"mask-box-image-repeat" = v[1] }, + .@"color-scheme" => .@"color-scheme", .all => PropertyId.all, .unparsed => |unparsed| unparsed.property_id, .custom => |c| .{ .custom = c.name }, @@ -6549,6 +6576,7 @@ pub const Property = union(PropertyIdTag) { .@"mask-box-image-width" => |*v| .{ .@"mask-box-image-width" = .{ v[0].deepClone(allocator), v[1] } }, .@"mask-box-image-outset" => |*v| .{ .@"mask-box-image-outset" = .{ v[0].deepClone(allocator), v[1] } }, .@"mask-box-image-repeat" => |*v| .{ .@"mask-box-image-repeat" = .{ v[0].deepClone(allocator), v[1] } }, + .@"color-scheme" => |*v| .{ .@"color-scheme" = v.deepClone(allocator) }, .all => |*a| return .{ .all = a.deepClone(allocator) }, .unparsed => |*u| return .{ .unparsed = u.deepClone(allocator) }, .custom => |*c| return .{ .custom = c.deepClone(allocator) }, @@ -6812,6 +6840,7 @@ pub const Property = union(PropertyIdTag) { .@"mask-box-image-width" => |*x| .{ "mask-box-image-width", x.@"1" }, .@"mask-box-image-outset" => |*x| .{ "mask-box-image-outset", x.@"1" }, .@"mask-box-image-repeat" => |*x| .{ "mask-box-image-repeat", x.@"1" }, + .@"color-scheme" => .{ "color-scheme", VendorPrefix{ .none = true } }, .all => .{ "all", VendorPrefix{ .none = true } }, .unparsed => |*unparsed| brk: { var prefix = unparsed.property_id.prefix(); @@ -7072,6 +7101,7 @@ pub const Property = union(PropertyIdTag) { .@"mask-box-image-width" => |*value| value[0].toCss(W, dest), .@"mask-box-image-outset" => |*value| value[0].toCss(W, dest), .@"mask-box-image-repeat" => |*value| value[0].toCss(W, dest), + .@"color-scheme" => |*value| value.toCss(W, dest), .all => |*keyword| keyword.toCss(W, dest), .unparsed => |*unparsed| unparsed.value.toCss(W, dest, false), .custom => |*c| c.value.toCss(W, dest, c.name == .custom), @@ -7402,6 +7432,7 @@ pub const Property = union(PropertyIdTag) { .@"mask-box-image-width" => |*v| css.generic.eql(Rect(BorderImageSideWidth), &v[0], &rhs.@"mask-box-image-width"[0]) and v[1].eq(rhs.@"mask-box-image-width"[1]), .@"mask-box-image-outset" => |*v| css.generic.eql(Rect(LengthOrNumber), &v[0], &rhs.@"mask-box-image-outset"[0]) and v[1].eq(rhs.@"mask-box-image-outset"[1]), .@"mask-box-image-repeat" => |*v| css.generic.eql(BorderImageRepeat, &v[0], &rhs.@"mask-box-image-repeat"[0]) and v[1].eq(rhs.@"mask-box-image-repeat"[1]), + .@"color-scheme" => |*v| css.generic.eql(ColorScheme, v, &rhs.@"color-scheme"), .unparsed => |*u| u.eql(&rhs.unparsed), .all => true, .custom => |*c| c.eql(&rhs.custom), @@ -7654,6 +7685,7 @@ pub const PropertyId = union(PropertyIdTag) { @"mask-box-image-width": VendorPrefix, @"mask-box-image-outset": VendorPrefix, @"mask-box-image-repeat": VendorPrefix, + @"color-scheme", all, unparsed, custom: CustomPropertyName, @@ -7914,12 +7946,13 @@ pub const PropertyId = union(PropertyIdTag) { .@"mask-box-image-width" => |p| p, .@"mask-box-image-outset" => |p| p, .@"mask-box-image-repeat" => |p| p, + .@"color-scheme" => VendorPrefix.empty(), .all, .custom, .unparsed => VendorPrefix.empty(), }; } pub fn fromNameAndPrefix(name1: []const u8, pre: VendorPrefix) ?PropertyId { - const Enum = enum { @"background-color", @"background-image", @"background-position-x", @"background-position-y", @"background-position", @"background-size", @"background-repeat", @"background-attachment", @"background-clip", @"background-origin", background, @"box-shadow", opacity, color, display, visibility, width, height, @"min-width", @"min-height", @"max-width", @"max-height", @"block-size", @"inline-size", @"min-block-size", @"min-inline-size", @"max-block-size", @"max-inline-size", @"box-sizing", @"aspect-ratio", overflow, @"overflow-x", @"overflow-y", @"text-overflow", position, top, bottom, left, right, @"inset-block-start", @"inset-block-end", @"inset-inline-start", @"inset-inline-end", @"inset-block", @"inset-inline", inset, @"border-spacing", @"border-top-color", @"border-bottom-color", @"border-left-color", @"border-right-color", @"border-block-start-color", @"border-block-end-color", @"border-inline-start-color", @"border-inline-end-color", @"border-top-style", @"border-bottom-style", @"border-left-style", @"border-right-style", @"border-block-start-style", @"border-block-end-style", @"border-inline-start-style", @"border-inline-end-style", @"border-top-width", @"border-bottom-width", @"border-left-width", @"border-right-width", @"border-block-start-width", @"border-block-end-width", @"border-inline-start-width", @"border-inline-end-width", @"border-top-left-radius", @"border-top-right-radius", @"border-bottom-left-radius", @"border-bottom-right-radius", @"border-start-start-radius", @"border-start-end-radius", @"border-end-start-radius", @"border-end-end-radius", @"border-radius", @"border-image-source", @"border-image-outset", @"border-image-repeat", @"border-image-width", @"border-image-slice", @"border-image", @"border-color", @"border-style", @"border-width", @"border-block-color", @"border-block-style", @"border-block-width", @"border-inline-color", @"border-inline-style", @"border-inline-width", border, @"border-top", @"border-bottom", @"border-left", @"border-right", @"border-block", @"border-block-start", @"border-block-end", @"border-inline", @"border-inline-start", @"border-inline-end", outline, @"outline-color", @"outline-style", @"outline-width", @"flex-direction", @"flex-wrap", @"flex-flow", @"flex-grow", @"flex-shrink", @"flex-basis", flex, order, @"align-content", @"justify-content", @"place-content", @"align-self", @"justify-self", @"place-self", @"align-items", @"justify-items", @"place-items", @"row-gap", @"column-gap", gap, @"box-orient", @"box-direction", @"box-ordinal-group", @"box-align", @"box-flex", @"box-flex-group", @"box-pack", @"box-lines", @"flex-pack", @"flex-order", @"flex-align", @"flex-item-align", @"flex-line-pack", @"flex-positive", @"flex-negative", @"flex-preferred-size", @"margin-top", @"margin-bottom", @"margin-left", @"margin-right", @"margin-block-start", @"margin-block-end", @"margin-inline-start", @"margin-inline-end", @"margin-block", @"margin-inline", margin, @"padding-top", @"padding-bottom", @"padding-left", @"padding-right", @"padding-block-start", @"padding-block-end", @"padding-inline-start", @"padding-inline-end", @"padding-block", @"padding-inline", padding, @"scroll-margin-top", @"scroll-margin-bottom", @"scroll-margin-left", @"scroll-margin-right", @"scroll-margin-block-start", @"scroll-margin-block-end", @"scroll-margin-inline-start", @"scroll-margin-inline-end", @"scroll-margin-block", @"scroll-margin-inline", @"scroll-margin", @"scroll-padding-top", @"scroll-padding-bottom", @"scroll-padding-left", @"scroll-padding-right", @"scroll-padding-block-start", @"scroll-padding-block-end", @"scroll-padding-inline-start", @"scroll-padding-inline-end", @"scroll-padding-block", @"scroll-padding-inline", @"scroll-padding", @"font-weight", @"font-size", @"font-stretch", @"font-family", @"font-style", @"font-variant-caps", @"line-height", font, @"transition-property", @"transition-duration", @"transition-delay", @"transition-timing-function", transition, transform, @"transform-origin", @"transform-style", @"transform-box", @"backface-visibility", perspective, @"perspective-origin", translate, rotate, scale, @"text-decoration-color", @"text-emphasis-color", @"text-shadow", direction, composes, @"mask-image", @"mask-mode", @"mask-repeat", @"mask-position-x", @"mask-position-y", @"mask-position", @"mask-clip", @"mask-origin", @"mask-size", @"mask-composite", @"mask-type", mask, @"mask-border-source", @"mask-border-mode", @"mask-border-slice", @"mask-border-width", @"mask-border-outset", @"mask-border-repeat", @"mask-border", @"-webkit-mask-composite", @"mask-source-type", @"mask-box-image", @"mask-box-image-source", @"mask-box-image-slice", @"mask-box-image-width", @"mask-box-image-outset", @"mask-box-image-repeat" }; + const Enum = enum { @"background-color", @"background-image", @"background-position-x", @"background-position-y", @"background-position", @"background-size", @"background-repeat", @"background-attachment", @"background-clip", @"background-origin", background, @"box-shadow", opacity, color, display, visibility, width, height, @"min-width", @"min-height", @"max-width", @"max-height", @"block-size", @"inline-size", @"min-block-size", @"min-inline-size", @"max-block-size", @"max-inline-size", @"box-sizing", @"aspect-ratio", overflow, @"overflow-x", @"overflow-y", @"text-overflow", position, top, bottom, left, right, @"inset-block-start", @"inset-block-end", @"inset-inline-start", @"inset-inline-end", @"inset-block", @"inset-inline", inset, @"border-spacing", @"border-top-color", @"border-bottom-color", @"border-left-color", @"border-right-color", @"border-block-start-color", @"border-block-end-color", @"border-inline-start-color", @"border-inline-end-color", @"border-top-style", @"border-bottom-style", @"border-left-style", @"border-right-style", @"border-block-start-style", @"border-block-end-style", @"border-inline-start-style", @"border-inline-end-style", @"border-top-width", @"border-bottom-width", @"border-left-width", @"border-right-width", @"border-block-start-width", @"border-block-end-width", @"border-inline-start-width", @"border-inline-end-width", @"border-top-left-radius", @"border-top-right-radius", @"border-bottom-left-radius", @"border-bottom-right-radius", @"border-start-start-radius", @"border-start-end-radius", @"border-end-start-radius", @"border-end-end-radius", @"border-radius", @"border-image-source", @"border-image-outset", @"border-image-repeat", @"border-image-width", @"border-image-slice", @"border-image", @"border-color", @"border-style", @"border-width", @"border-block-color", @"border-block-style", @"border-block-width", @"border-inline-color", @"border-inline-style", @"border-inline-width", border, @"border-top", @"border-bottom", @"border-left", @"border-right", @"border-block", @"border-block-start", @"border-block-end", @"border-inline", @"border-inline-start", @"border-inline-end", outline, @"outline-color", @"outline-style", @"outline-width", @"flex-direction", @"flex-wrap", @"flex-flow", @"flex-grow", @"flex-shrink", @"flex-basis", flex, order, @"align-content", @"justify-content", @"place-content", @"align-self", @"justify-self", @"place-self", @"align-items", @"justify-items", @"place-items", @"row-gap", @"column-gap", gap, @"box-orient", @"box-direction", @"box-ordinal-group", @"box-align", @"box-flex", @"box-flex-group", @"box-pack", @"box-lines", @"flex-pack", @"flex-order", @"flex-align", @"flex-item-align", @"flex-line-pack", @"flex-positive", @"flex-negative", @"flex-preferred-size", @"margin-top", @"margin-bottom", @"margin-left", @"margin-right", @"margin-block-start", @"margin-block-end", @"margin-inline-start", @"margin-inline-end", @"margin-block", @"margin-inline", margin, @"padding-top", @"padding-bottom", @"padding-left", @"padding-right", @"padding-block-start", @"padding-block-end", @"padding-inline-start", @"padding-inline-end", @"padding-block", @"padding-inline", padding, @"scroll-margin-top", @"scroll-margin-bottom", @"scroll-margin-left", @"scroll-margin-right", @"scroll-margin-block-start", @"scroll-margin-block-end", @"scroll-margin-inline-start", @"scroll-margin-inline-end", @"scroll-margin-block", @"scroll-margin-inline", @"scroll-margin", @"scroll-padding-top", @"scroll-padding-bottom", @"scroll-padding-left", @"scroll-padding-right", @"scroll-padding-block-start", @"scroll-padding-block-end", @"scroll-padding-inline-start", @"scroll-padding-inline-end", @"scroll-padding-block", @"scroll-padding-inline", @"scroll-padding", @"font-weight", @"font-size", @"font-stretch", @"font-family", @"font-style", @"font-variant-caps", @"line-height", font, @"transition-property", @"transition-duration", @"transition-delay", @"transition-timing-function", transition, transform, @"transform-origin", @"transform-style", @"transform-box", @"backface-visibility", perspective, @"perspective-origin", translate, rotate, scale, @"text-decoration-color", @"text-emphasis-color", @"text-shadow", direction, composes, @"mask-image", @"mask-mode", @"mask-repeat", @"mask-position-x", @"mask-position-y", @"mask-position", @"mask-clip", @"mask-origin", @"mask-size", @"mask-composite", @"mask-type", mask, @"mask-border-source", @"mask-border-mode", @"mask-border-slice", @"mask-border-width", @"mask-border-outset", @"mask-border-repeat", @"mask-border", @"-webkit-mask-composite", @"mask-source-type", @"mask-box-image", @"mask-box-image-source", @"mask-box-image-slice", @"mask-box-image-width", @"mask-box-image-outset", @"mask-box-image-repeat", @"color-scheme" }; const Map = comptime bun.ComptimeEnumMap(Enum); if (Map.getASCIIICaseInsensitive(name1)) |prop| { switch (prop) { @@ -8903,6 +8936,10 @@ pub const PropertyId = union(PropertyIdTag) { const allowed_prefixes = VendorPrefix{ .none = true, .webkit = true }; if (allowed_prefixes.contains(pre)) return .{ .@"mask-box-image-repeat" = pre }; }, + .@"color-scheme" => { + const allowed_prefixes = VendorPrefix{ .none = true }; + if (allowed_prefixes.contains(pre)) return .@"color-scheme"; + }, } } @@ -9156,6 +9193,7 @@ pub const PropertyId = union(PropertyIdTag) { .@"mask-box-image-width" => .{ .@"mask-box-image-width" = pre }, .@"mask-box-image-outset" => .{ .@"mask-box-image-outset" = pre }, .@"mask-box-image-repeat" => .{ .@"mask-box-image-repeat" = pre }, + .@"color-scheme" => .@"color-scheme", else => this.*, }; } @@ -9537,6 +9575,7 @@ pub const PropertyId = union(PropertyIdTag) { .@"mask-box-image-repeat" => |*p| { p.insert(pre); }, + .@"color-scheme" => {}, else => {}, }; } @@ -9937,6 +9976,7 @@ pub const PropertyId = union(PropertyIdTag) { .@"mask-box-image-width" => {}, .@"mask-box-image-outset" => {}, .@"mask-box-image-repeat" => {}, + .@"color-scheme" => {}, else => {}, } } @@ -10187,6 +10227,7 @@ pub const PropertyIdTag = enum(u16) { @"mask-box-image-width", @"mask-box-image-outset", @"mask-box-image-repeat", + @"color-scheme", all, unparsed, custom, @@ -10440,6 +10481,7 @@ pub const PropertyIdTag = enum(u16) { .@"mask-box-image-width" => true, .@"mask-box-image-outset" => true, .@"mask-box-image-repeat" => true, + .@"color-scheme" => false, .unparsed => false, .custom => false, .all => false, @@ -10695,6 +10737,7 @@ pub const PropertyIdTag = enum(u16) { .@"mask-box-image-width" => Rect(BorderImageSideWidth), .@"mask-box-image-outset" => Rect(LengthOrNumber), .@"mask-box-image-repeat" => BorderImageRepeat, + .@"color-scheme" => ColorScheme, .all => CSSWideKeyword, .unparsed => UnparsedProperty, .custom => CustomProperty, diff --git a/src/css/properties/ui.zig b/src/css/properties/ui.zig index 58b7cec84d52c4..3740c9418eef30 100644 --- a/src/css/properties/ui.zig +++ b/src/css/properties/ui.zig @@ -41,6 +41,69 @@ pub const ColorScheme = packed struct(u8) { dark: bool = false, /// Forbids the user agent from overriding the color scheme for the element. only: bool = false, + __unused: u5 = 0, + + pub usingnamespace css.Bitflags(@This()); + + const Map = bun.ComptimeEnumMap(enum { normal, only, light, dark }); + + pub fn parse(input: *css.Parser) css.Result(ColorScheme) { + var res = ColorScheme.empty(); + const ident = switch (input.expectIdent()) { + .result => |ident| ident, + .err => |e| return .{ .err = e }, + }; + + if (Map.get(ident)) |value| switch (value) { + .normal => return .{ .result = res }, + .only => res.insert(ColorScheme{ .only = true }), + .light => res.insert(ColorScheme{ .light = true }), + .dark => res.insert(ColorScheme{ .dark = true }), + }; + + while (input.tryParse(css.Parser.expectIdent, .{}).asValue()) |i| { + if (Map.get(i)) |value| switch (value) { + .normal => return .{ .err = input.newCustomError(css.ParserError.invalid_value) }, + .only => { + // Only must be at the start or the end, not in the middle + if (res.contains(ColorScheme{ .only = true })) { + return .{ .err = input.newCustomError(css.ParserError.invalid_value) }; + } + res.insert(ColorScheme{ .only = true }); + return .{ .result = res }; + }, + .light => res.insert(ColorScheme{ .light = true }), + .dark => res.insert(ColorScheme{ .dark = true }), + }; + } + + return .{ .result = res }; + } + + pub fn toCss(this: *const ColorScheme, comptime W: type, dest: *Printer(W)) css.PrintErr!void { + if (this.isEmpty()) { + return dest.writeStr("normal"); + } + + if (this.contains(ColorScheme{ .light = true })) { + try dest.writeStr("light"); + if (this.contains(ColorScheme{ .dark = true })) { + try dest.writeChar(' '); + } + } + + if (this.contains(ColorScheme{ .dark = true })) { + try dest.writeStr("dark"); + } + + if (this.contains(ColorScheme{ .only = true })) { + try dest.writeStr(" only"); + } + } + + pub fn deepClone(this: *const @This(), allocator: Allocator) @This() { + return css.implementDeepClone(@This(), this, allocator); + } }; /// A value for the [resize](https://www.w3.org/TR/2021/WD-css-ui-4-20210316/#resize) property. @@ -107,3 +170,59 @@ pub const Appearance = union(enum) { textarea, non_standard: []const u8, }; + +pub const ColorSchemeHandler = struct { + pub fn handleProperty(_: *@This(), property: *const css.Property, dest: *css.DeclarationList, context: *css.PropertyHandlerContext) bool { + switch (property.*) { + .@"color-scheme" => |*color_scheme_| { + const color_scheme: *const ColorScheme = color_scheme_; + if (!context.targets.isCompatible(css.compat.Feature.light_dark)) { + if (color_scheme.contains(ColorScheme{ .light = true })) { + dest.append( + context.allocator, + defineVar(context.allocator, "--buncss-light", .{ .ident = "initial" }), + ) catch bun.outOfMemory(); + dest.append( + context.allocator, + defineVar(context.allocator, "--buncss-dark", .{ .whitespace = " " }), + ) catch bun.outOfMemory(); + + if (color_scheme.contains(ColorScheme{ .dark = true })) { + context.addDarkRule( + context.allocator, + defineVar(context.allocator, "--buncss-light", .{ .whitespace = " " }), + ); + context.addDarkRule( + context.allocator, + defineVar(context.allocator, "--buncss-dark", .{ .ident = "initial" }), + ); + } + } else if (color_scheme.contains(ColorScheme{ .dark = true })) { + dest.append(context.allocator, defineVar(context.allocator, "--buncss-light", .{ .whitespace = " " })) catch bun.outOfMemory(); + dest.append(context.allocator, defineVar(context.allocator, "--buncss-dark", .{ .ident = "initial" })) catch bun.outOfMemory(); + } + } + dest.append(context.allocator, property.deepClone(context.allocator)) catch bun.outOfMemory(); + return true; + }, + else => return false, + } + } + + pub fn finalize(_: *@This(), _: *css.DeclarationList, _: *css.PropertyHandlerContext) void {} +}; + +fn defineVar(allocator: Allocator, name: []const u8, value: css.Token) css.Property { + return css.Property{ + .custom = css.css_properties.custom.CustomProperty{ + .name = css.css_properties.custom.CustomPropertyName{ .custom = css.DashedIdent{ .v = name } }, + .value = css.TokenList{ + .v = brk: { + var list = ArrayList(css.css_properties.custom.TokenOrValue){}; + list.append(allocator, css.css_properties.custom.TokenOrValue{ .token = value }) catch bun.outOfMemory(); + break :brk list; + }, + }, + }, + }; +} diff --git a/src/css/rules/rules.zig b/src/css/rules/rules.zig index 25f7bdec6b3c59..191e55240efb6c 100644 --- a/src/css/rules/rules.zig +++ b/src/css/rules/rules.zig @@ -409,7 +409,9 @@ pub fn CssRuleList(comptime AtRule: type) type { } if (logical.items.len > 0) { - debug("Adding logical: {}\n", .{logical.items[0].style.selectors.debug()}); + if (bun.Environment.isDebug and logical.items[0] == .style) { + debug("Adding logical: {}\n", .{logical.items[0].style.selectors.debug()}); + } var log = CssRuleList(AtRule){ .v = logical }; try log.minify(context, parent_is_unused); rules.appendSlice(context.allocator, log.v.items) catch bun.outOfMemory(); diff --git a/src/css/values/color.zig b/src/css/values/color.zig index 01ef1cf9c1c7db..31331bd72aed4d 100644 --- a/src/css/values/color.zig +++ b/src/css/values/color.zig @@ -230,16 +230,14 @@ pub const CssColor = union(enum) { }, .light_dark => |*light_dark| { if (!dest.targets.isCompatible(css.compat.Feature.light_dark)) { - // TODO(zack): lightningcss -> buncss - try dest.writeStr("var(--lightningcss-light"); + try dest.writeStr("var(--buncss-light"); try dest.delim(',', false); try light_dark.light.toCss(W, dest); try dest.writeChar(')'); try dest.whitespace(); - try dest.writeStr("var(--lightningcss-dark"); + try dest.writeStr("var(--buncss-dark"); try dest.delim(',', false); try light_dark.dark.toCss(W, dest); - try light_dark.dark.toCss(W, dest); return dest.writeChar(')'); } @@ -365,7 +363,7 @@ pub const CssColor = union(enum) { if (this.* == .light_dark or other.* == .light_dark) { const this_light_dark = this.toLightDark(allocator); - const other_light_dark = this.toLightDark(allocator); + const other_light_dark = other.toLightDark(allocator); const al = this_light_dark.light_dark.light; const ad = this_light_dark.light_dark.dark; @@ -508,7 +506,8 @@ pub const CssColor = union(enum) { } if (fallbacks.contains(ColorFallbackKind{ .lab = true })) { - this.* = this.toLAB(allocator).?; + const foo = this.toLAB(allocator).?; + this.* = foo; } return res; @@ -532,7 +531,7 @@ pub const CssColor = union(enum) { if (lab.* == .lab or lab.* == .lch and targets.shouldCompileSame(.lab_colors)) break :brk ColorFallbackKind.andBelow(.{ .lab = true }); if (lab.* == .oklab or lab.* == .oklch and targets.shouldCompileSame(.oklab_colors)) - break :brk ColorFallbackKind.andBelow(.{ .lab = true }); + break :brk ColorFallbackKind.andBelow(.{ .oklab = true }); return ColorFallbackKind.empty(); }, .predefined => |predefined| brk: { @@ -2791,6 +2790,7 @@ pub fn parseColorMix(input: *css.Parser) Result(CssColor) { } else .{ .result = HueInterpolationMethod.shorter }; const hue_method = hue_method_.unwrapOr(HueInterpolationMethod.shorter); + if (input.expectComma().asErr()) |e| return .{ .err = e }; const first_percent_ = input.tryParse(css.Parser.expectPercentage, .{}); const first_color = switch (CssColor.parse(input)) { @@ -2820,9 +2820,9 @@ pub fn parseColorMix(input: *css.Parser) Result(CssColor) { }; // https://drafts.csswg.org/css-color-5/#color-mix-percent-norm - const p1, const p2 = if (first_percent == null and second_percent == null) .{ 0.5, 0.5 } else brk: { - const p2 = second_percent orelse (1.0 - first_percent.?); - const p1 = first_percent orelse (1.0 - second_percent.?); + const p1: f32, const p2: f32 = if (first_percent == null and second_percent == null) .{ @as(f32, 0.5), @as(f32, 0.5) } else brk: { + const p2 = second_percent orelse (@as(f32, 1.0) - first_percent.?); + const p1 = first_percent orelse (@as(f32, 1.0) - second_percent.?); break :brk .{ p1, p2 }; }; @@ -4011,7 +4011,7 @@ const color_conversions = struct { const xyz = _xyz.resolveMissing(); const x = xyz.x / D50[0]; const y = xyz.y / D50[1]; - const z = xyz.y / D50[2]; + const z = xyz.z / D50[2]; // now compute f @@ -4023,7 +4023,7 @@ const color_conversions = struct { const l = ((116.0 * f1) - 16.0) / 100.0; const a = 500.0 * (f0 - f1); - const b = 500.0 * (f1 - f2); + const b = 200.0 * (f1 - f2); return LAB{ .l = l, diff --git a/src/css/values/length.zig b/src/css/values/length.zig index b256a0c463700e..2983788a971602 100644 --- a/src/css/values/length.zig +++ b/src/css/values/length.zig @@ -524,6 +524,10 @@ pub const Length = union(enum) { /// A computed length value using `calc()`. calc: *Calc(Length), + pub fn zero() Length { + return .{ .value = LengthValue.zero() }; + } + pub fn deepClone(this: *const Length, allocator: Allocator) Length { return switch (this.*) { .value => |v| .{ .value = v }, diff --git a/test/js/bun/css/css.test.ts b/test/js/bun/css/css.test.ts index 1d60d337f6c627..375e1317272802 100644 --- a/test/js/bun/css/css.test.ts +++ b/test/js/bun/css/css.test.ts @@ -1580,6 +1580,175 @@ describe("css tests", () => { ); }); + describe("box-shadow", () => { + minify_test( + ".foo { box-shadow: 64px 64px 12px 40px rgba(0,0,0,0.4) }", + ".foo{box-shadow:64px 64px 12px 40px #0006}", + ); + minify_test( + ".foo { box-shadow: 12px 12px 0px 8px rgba(0,0,0,0.4) inset }", + ".foo{box-shadow:inset 12px 12px 0 8px #0006}", + ); + minify_test( + ".foo { box-shadow: inset 12px 12px 0px 8px rgba(0,0,0,0.4) }", + ".foo{box-shadow:inset 12px 12px 0 8px #0006}", + ); + minify_test(".foo { box-shadow: 12px 12px 8px 0px rgba(0,0,0,0.4) }", ".foo{box-shadow:12px 12px 8px #0006}"); + minify_test(".foo { box-shadow: 12px 12px 0px 0px rgba(0,0,0,0.4) }", ".foo{box-shadow:12px 12px #0006}"); + minify_test( + ".foo { box-shadow: 64px 64px 12px 40px rgba(0,0,0,0.4), 12px 12px 0px 8px rgba(0,0,0,0.4) inset }", + ".foo{box-shadow:64px 64px 12px 40px #0006,inset 12px 12px 0 8px #0006}", + ); + + prefix_test( + ".foo { box-shadow: 12px 12px lab(40% 56.6 39) }", + `.foo { + box-shadow: 12px 12px #b32323; + box-shadow: 12px 12px lab(40% 56.6 39); + } + `, + { chrome: Some(90 << 16) }, + ); + + prefix_test( + ".foo { box-shadow: 12px 12px lab(40% 56.6 39) }", + `.foo { + -webkit-box-shadow: 12px 12px #b32323; + box-shadow: 12px 12px #b32323; + box-shadow: 12px 12px lab(40% 56.6 39); + } + `, + { chrome: Some(4 << 16) }, + ); + + prefix_test( + ".foo { box-shadow: 12px 12px lab(40% 56.6 39), 12px 12px yellow }", + `.foo { + -webkit-box-shadow: 12px 12px #b32323, 12px 12px #ff0; + box-shadow: 12px 12px #b32323, 12px 12px #ff0; + box-shadow: 12px 12px lab(40% 56.6 39), 12px 12px #ff0; + } + `, + { chrome: Some(4 << 16) }, + ); + + prefix_test( + ".foo { -webkit-box-shadow: 12px 12px #0006 }", + `.foo { + -webkit-box-shadow: 12px 12px rgba(0, 0, 0, .4); + } + `, + { chrome: Some(4 << 16) }, + ); + + prefix_test( + `.foo { + -webkit-box-shadow: 12px 12px #0006; + -moz-box-shadow: 12px 12px #0009; + }`, + `.foo { + -webkit-box-shadow: 12px 12px rgba(0, 0, 0, .4); + -moz-box-shadow: 12px 12px rgba(0, 0, 0, .6); + } + `, + { chrome: Some(4 << 16) }, + ); + + prefix_test( + `.foo { + -webkit-box-shadow: 12px 12px #0006; + -moz-box-shadow: 12px 12px #0006; + box-shadow: 12px 12px #0006; + }`, + `.foo { + box-shadow: 12px 12px #0006; + } + `, + { chrome: Some(95 << 16) }, + ); + + prefix_test( + ".foo { box-shadow: var(--foo) 12px lab(40% 56.6 39) }", + `.foo { + box-shadow: var(--foo) 12px #b32323; + } + + @supports (color: lab(0% 0 0)) { + .foo { + box-shadow: var(--foo) 12px lab(40% 56.6 39); + } + } + `, + { chrome: Some(90 << 16) }, + ); + + prefix_test( + `.foo { + box-shadow: 0px 0px 22px red; + box-shadow: 0px 0px max(2cqw, 22px) red; + } + `, + `.foo { + box-shadow: 0 0 22px red; + box-shadow: 0 0 max(2cqw, 22px) red; + } + `, + { safari: Some(14 << 16) }, + ); + prefix_test( + `.foo { + box-shadow: 0px 0px 22px red; + box-shadow: 0px 0px max(2cqw, 22px) red; + } + `, + `.foo { + box-shadow: 0 0 max(2cqw, 22px) red; + } + `, + { safari: Some(16 << 16) }, + ); + + prefix_test( + `.foo { + box-shadow: 0px 0px 22px red; + box-shadow: 0px 0px 22px lab(40% 56.6 39); + } + `, + `.foo { + box-shadow: 0 0 22px red; + box-shadow: 0 0 22px lab(40% 56.6 39); + } + `, + { safari: Some(14 << 16) }, + ); + prefix_test( + `.foo { + box-shadow: 0px 0px 22px red; + box-shadow: 0px 0px 22px lab(40% 56.6 39); + } + `, + `.foo { + box-shadow: 0 0 22px lab(40% 56.6 39); + } + `, + { safari: Some(16 << 16) }, + ); + + prefix_test( + `.foo { + box-shadow: var(--fallback); + box-shadow: 0px 0px 22px lab(40% 56.6 39); + } + `, + `.foo { + box-shadow: var(--fallback); + box-shadow: 0 0 22px lab(40% 56.6 39); + } + `, + { safari: Some(16 << 16) }, + ); + }); + describe("margin", () => { cssTest( ` @@ -6754,7 +6923,7 @@ describe("css tests", () => { ".foo{transform:matrix3d(1,0,0,0,0,1,6,0,0,0,1,0,50,100,0,1.1)}", ); // TODO: Re-enable with a better solution - // See: https://github.com/parcel-bundler/lightningcss/issues/288 + // See: https://github.com/parcel-bundler/buncss/issues/288 // minify_test( // ".foo{transform:translate(100px,200px) rotate(45deg) skew(10deg) scale(2)}", // ".foo{transform:matrix(1.41421,1.41421,-1.16485,1.66358,100,200)}", @@ -6772,7 +6941,7 @@ describe("css tests", () => { ".foo{transform:rotate3d(1,1,1,45deg)translate3d(100px,100px,10px)}", ); // TODO: Re-enable with a better solution - // See: https://github.com/parcel-bundler/lightningcss/issues/288 + // See: https://github.com/parcel-bundler/buncss/issues/288 // minify_test( // ".foo{transform:translate3d(100px, 100px, 10px) skew(10deg) scale3d(2, 3, 4)}", // ".foo{transform:matrix3d(2,0,0,0,.528981,3,0,0,0,0,4,0,100,100,10,1)}", @@ -6842,7 +7011,7 @@ describe("css tests", () => { minify_test(".foo { scale: 1 0 0 }", ".foo{scale:1 0 0}"); // TODO: Re-enable with a better solution - // See: https://github.com/parcel-bundler/lightningcss/issues/288 + // See: https://github.com/parcel-bundler/buncss/issues/288 // minify_test(".foo { transform: scale(3); scale: 0.5 }", ".foo{transform:scale(1.5)}"); minify_test(".foo { scale: 0.5; transform: scale(3); }", ".foo{transform:scale(3)}"); @@ -6898,4 +7067,161 @@ describe("css tests", () => { `, ); }); + + describe("color-scheme", () => { + minify_test(".foo { color-scheme: normal; }", ".foo{color-scheme:normal}"); + minify_test(".foo { color-scheme: light; }", ".foo{color-scheme:light}"); + minify_test(".foo { color-scheme: dark; }", ".foo{color-scheme:dark}"); + minify_test(".foo { color-scheme: light dark; }", ".foo{color-scheme:light dark}"); + minify_test(".foo { color-scheme: dark light; }", ".foo{color-scheme:light dark}"); + minify_test(".foo { color-scheme: only light; }", ".foo{color-scheme:light only}"); + minify_test(".foo { color-scheme: only dark; }", ".foo{color-scheme:dark only}"); + minify_test(".foo { color-scheme: dark light only; }", ".foo{color-scheme:light dark only}"); + minify_test(".foo { color-scheme: foo bar light; }", ".foo{color-scheme:light}"); + minify_test(".foo { color-scheme: only foo dark bar; }", ".foo{color-scheme:dark only}"); + prefix_test( + ".foo { color-scheme: dark; }", + `.foo { + --buncss-light: ; + --buncss-dark: initial; + color-scheme: dark; + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color-scheme: light; }", + `.foo { + --buncss-light: initial; + --buncss-dark: ; + color-scheme: light; + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color-scheme: light dark; }", + `.foo { + --buncss-light: initial; + --buncss-dark: ; + color-scheme: light dark; + } + + @media (prefers-color-scheme: dark) { + .foo { + --buncss-light: ; + --buncss-dark: initial; + } + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color-scheme: light dark; }", + `.foo { + color-scheme: light dark; + } + `, + { firefox: Some(120 << 16) }, + ); + + minify_test(".foo { color: light-dark(yellow, red); }", ".foo{color:light-dark(#ff0,red)}"); + minify_test( + ".foo { color: light-dark(light-dark(yellow, red), light-dark(yellow, red)); }", + ".foo{color:light-dark(#ff0,red)}", + ); + minify_test( + ".foo { color: light-dark(rgb(0, 0, 255), hsl(120deg, 50%, 50%)); }", + ".foo{color:light-dark(#00f,#40bf40)}", + ); + prefix_test( + ".foo { color: light-dark(oklch(40% 0.1268735435 34.568626), oklab(59.686% 0.1009 0.1192)); }", + `.foo { + color: var(--buncss-light, #7e250f) var(--buncss-dark, #c65d07); + color: var(--buncss-light, lab(29.2661% 38.2437 35.3889)) var(--buncss-dark, lab(52.2319% 40.1449 59.9171)); + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color: light-dark(oklch(40% 0.1268735435 34.568626), oklab(59.686% 0.1009 0.1192)); }", + `.foo { + color: light-dark(oklch(40% .126874 34.5686), oklab(59.686% .1009 .1192)); + } + `, + { firefox: Some(120 << 16) }, + ); + prefix_test( + ` + .foo { + box-shadow: + oklch(100% 0 0deg / 50%) 0 0.63rem 0.94rem -0.19rem, + currentColor 0 0.44rem 0.8rem -0.58rem; + } + `, + `.foo { + box-shadow: 0 .63rem .94rem -.19rem #ffffff80, 0 .44rem .8rem -.58rem; + box-shadow: 0 .63rem .94rem -.19rem lab(100% 0 0 / .5), 0 .44rem .8rem -.58rem; + } + `, + { chrome: Some(95 << 16) }, + ); + prefix_test( + ` + .foo { + box-shadow: + oklch(100% 0 0deg / 50%) 0 0.63rem 0.94rem -0.19rem, + currentColor 0 0.44rem 0.8rem -0.58rem; + } + `, + `.foo { + box-shadow: 0 .63rem .94rem -.19rem color(display-p3 1 1 1 / .5), 0 .44rem .8rem -.58rem; + box-shadow: 0 .63rem .94rem -.19rem lab(100% 0 0 / .5), 0 .44rem .8rem -.58rem; + } + `, + { safari: Some(14 << 16) }, + ); + + prefix_test( + ".foo { color: light-dark(var(--light), var(--dark)); }", + `.foo { + color: var(--buncss-light, var(--light)) var(--buncss-dark, var(--dark)); + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color: rgb(from light-dark(yellow, red) r g b / 10%); }", + `.foo { + color: var(--buncss-light, #ffff001a) var(--buncss-dark, #ff00001a); + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color: rgb(from light-dark(yellow, red) r g b / var(--alpha)); }", + `.foo { + color: var(--buncss-light, rgb(255 255 0 / var(--alpha))) var(--buncss-dark, rgb(255 0 0 / var(--alpha))); + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color: color(from light-dark(yellow, red) srgb r g b / 10%); }", + `.foo { + color: var(--buncss-light, #ffff001a) var(--buncss-dark, #ff00001a); + color: var(--buncss-light, color(srgb 1 1 0 / .1)) var(--buncss-dark, color(srgb 1 0 0 / .1)); + } + `, + { chrome: Some(90 << 16) }, + ); + prefix_test( + ".foo { color: color-mix(in srgb, light-dark(yellow, red), light-dark(red, pink)); }", + `.foo { + color: var(--buncss-light, #ff8000) var(--buncss-dark, #ff6066); + } + `, + { chrome: Some(90 << 16) }, + ); + }); }); From 4d004b90cad97debfb4cf1e22a6c6327f300649f Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Tue, 4 Feb 2025 23:55:57 -0800 Subject: [PATCH 28/29] Fix `bun.lock` formatting of `bin` (#17041) --- src/install/bin.zig | 20 +- src/install/bun.lock.zig | 16 +- src/install/install.zig | 5 +- src/semver/SemverString.zig | 2 +- .../__snapshots__/bun-lock.test.ts.snap | 121 ++++++++++++ test/cli/install/bun-lock.test.ts | 178 +++++++++++++++++- 6 files changed, 319 insertions(+), 23 deletions(-) diff --git a/src/install/bin.zig b/src/install/bin.zig index dddf3a52309542..4da91e8a0ba5cd 100644 --- a/src/install/bin.zig +++ b/src/install/bin.zig @@ -327,7 +327,7 @@ pub const Bin = extern struct { try writer.writeAll("{\n"); indent.* += 1; try writeIndent(writer, indent); - try writer.print("{}: {}\n", .{ + try writer.print("{}: {},\n", .{ this.value.named_file[0].fmtJson(buf, .{}), this.value.named_file[1].fmtJson(buf, .{}), }); @@ -339,23 +339,29 @@ pub const Bin = extern struct { try writer.print("{}", .{this.value.dir.fmtJson(buf, .{})}); }, .map => { - try writer.writeAll("{\n"); + try writer.writeByte('{'); indent.* += 1; const list = this.value.map.get(extern_strings); - var first = true; + var any = false; var i: usize = 0; while (i < list.len) : (i += 2) { - if (!first) { - try writer.writeByte(','); + if (!any) { + any = true; + try writer.writeByte('\n'); } try writeIndent(writer, indent); - first = false; - try writer.print("{}: {}", .{ + try writer.print("{}: {},\n", .{ list[i].value.fmtJson(buf, .{}), list[i + 1].value.fmtJson(buf, .{}), }); } + if (!any) { + try writer.writeByte('}'); + indent.* -= 1; + return; + } + indent.* -= 1; try writeIndent(writer, indent); try writer.writeByte('}'); diff --git a/src/install/bun.lock.zig b/src/install/bun.lock.zig index 83ecb7b1de6ad9..80e7702f774a5c 100644 --- a/src/install/bun.lock.zig +++ b/src/install/bun.lock.zig @@ -510,9 +510,9 @@ pub const Stringifier = struct { const name_and_version, const patch_path = value.*; try writeIndent(writer, indent); try writer.print( - \\"{s}": "{s}", + \\{}: {}, \\ - , .{ name_and_version, patch_path.slice(buf) }); + , .{ bun.fmt.formatJSONStringUTF8(name_and_version, .{}), patch_path.fmtJson(buf, .{}) }); } try decIndent(writer, indent); @@ -534,9 +534,9 @@ pub const Stringifier = struct { const name, const version = value.*; try writeIndent(writer, indent); try writer.print( - \\"{s}": "{s}", + \\{}: {}, \\ - , .{ name.slice(buf), version.literal.slice(buf) }); + , .{ name.fmtJson(buf, .{}), version.literal.fmtJson(buf, .{}) }); } try decIndent(writer, indent); @@ -940,9 +940,7 @@ pub const Stringifier = struct { } else { any = true; } - try writer.writeAll( - \\ "os": - ); + try writer.writeAll(" \"os\": "); try Negatable(Npm.OperatingSystem).toJson(meta.os, writer); } @@ -952,9 +950,7 @@ pub const Stringifier = struct { } else { any = true; } - try writer.writeAll( - \\ "cpu": - ); + try writer.writeAll(" \"cpu\": "); try Negatable(Npm.Architecture).toJson(meta.arch, writer); } diff --git a/src/install/install.zig b/src/install/install.zig index d08bbfbf868be0..9001b581c945b3 100644 --- a/src/install/install.zig +++ b/src/install/install.zig @@ -15014,10 +15014,7 @@ pub const PackageManager = struct { if (manager.options.do.summary) { // TODO(dylan-conway): packages aren't installed but we can still print // added/removed/updated direct dependencies. - Output.pretty( - \\ - \\Saved {s} ({d} package{s}) - , .{ + Output.pretty("\nSaved {s} ({d} package{s}) ", .{ switch (save_format) { .text => "bun.lock", .binary => "bun.lockb", diff --git a/src/semver/SemverString.zig b/src/semver/SemverString.zig index 412622d0513e67..04d3f75dc80212 100644 --- a/src/semver/SemverString.zig +++ b/src/semver/SemverString.zig @@ -139,7 +139,7 @@ pub const String = extern struct { } }; - /// Escapes for json. Expects string to be prequoted + /// Escapes for json. Defaults to quoting the string. pub inline fn fmtJson(self: *const String, buf: []const u8, opts: JsonFormatter.Options) JsonFormatter { return .{ .buf = buf, diff --git a/test/cli/install/__snapshots__/bun-lock.test.ts.snap b/test/cli/install/__snapshots__/bun-lock.test.ts.snap index b8c6d8e01c9abc..2523c5077033ac 100644 --- a/test/cli/install/__snapshots__/bun-lock.test.ts.snap +++ b/test/cli/install/__snapshots__/bun-lock.test.ts.snap @@ -283,3 +283,124 @@ exports[`should not deduplicate bundled packages with un-bundled packages 1`] = "3 packages installed", ] `; + +exports[`should not change formatting unexpectedly 1`] = ` +[ + "preinstall", + "", + "+ optional-native@1.0.0", + "+ optional-peer-deps@1.0.0 (v1.0.1 available)", + "+ uses-what-bin@1.0.0 (v1.5.0 available)", + "", + "13 packages installed", +] +`; + +exports[`should not change formatting unexpectedly 2`] = ` +"{ + "lockfileVersion": 1, + "workspaces": { + "": { + "name": "pkg-root", + "dependencies": { + "uses-what-bin": "1.0.0", + }, + "devDependencies": { + "optional-peer-deps": "1.0.0", + }, + "optionalDependencies": { + "optional-native": "1.0.0", + }, + }, + "packages/pkg1": { + "name": "pkg1", + "version": "2.2.2", + "bin": { + "pkg1-1": "bin-1.js", + "pkg1-2": "bin-2.js", + "pkg1-3": "bin-3.js", + }, + "dependencies": { + "bundled-1": "1.0.0", + }, + "peerDependencies": { + "a-dep": "1.0.1", + }, + "optionalPeers": [ + "a-dep", + ], + }, + "packages/pkg2": { + "name": "pkg2", + "bin": { + "pkg2-1": "bin-1.js", + }, + "dependencies": { + "map-bin": "1.0.2", + }, + }, + "packages/pkg3": { + "name": "pkg3", + "binDir": "bin", + "devDependencies": { + "hoist-lockfile-1": "1.0.0", + }, + }, + }, + "trustedDependencies": [ + "uses-what-bin", + ], + "patchedDependencies": { + "optional-peer-deps@1.0.0": "patches/optional-peer-deps@1.0.0.patch", + }, + "overrides": { + "hoist-lockfile-shared": "1.0.1", + }, + "packages": { + "bundled-1": ["bundled-1@1.0.0", "http://localhost:1234/bundled-1/-/bundled-1-1.0.0.tgz", { "dependencies": { "no-deps": "1.0.0" } }, "sha512-YQ/maWZliKQyp1VIdYnPBH6qBHLCQ8Iy6G5vRZFXUHVXufiXT5aTjPVnLQ7xpVAgURFrzd/Fu1113ROLlaJBkQ=="], + + "hoist-lockfile-1": ["hoist-lockfile-1@1.0.0", "http://localhost:1234/hoist-lockfile-1/-/hoist-lockfile-1-1.0.0.tgz", { "dependencies": { "hoist-lockfile-shared": "*" } }, "sha512-E2nwR7egMFDoYjeRno7CAa59kiwkLGfhTFy2Q335JWp2r2bDkwoAt1LdChd5PdGYkbo7SfViHkW44ga+WXA+eA=="], + + "hoist-lockfile-shared": ["hoist-lockfile-shared@1.0.1", "http://localhost:1234/hoist-lockfile-shared/-/hoist-lockfile-shared-1.0.1.tgz", {}, "sha512-wPw8pTRj2OeZ/n7NeixjaSeI7FoM9DbMHWzdLv1kuBesSXJn+17UA0N7LV7t9dREnIMLw7ycRomhDL+56NRBmQ=="], + + "map-bin": ["map-bin@1.0.2", "http://localhost:1234/map-bin/-/map-bin-1.0.2.tgz", { "bin": { "map-bin": "bin/map-bin", "map_bin": "bin/map-bin" } }, "sha512-d5+2d5socrCT/99w16Gdl/wQu+C3WHflIE/3idFuJOW9xuvt+8VW4bDND/kptCNI63w/ePSJoYm327Sn+I7QCQ=="], + + "native-bar-x64": ["native-bar-x64@1.0.0", "http://localhost:1234/native-bar-x64/-/native-bar-x64-1.0.0.tgz", { "os": "none", "cpu": "x64" }, "sha512-wNjF++hO2mWgeg1uyFzyTUq1tWiO/1kEjKqvgf344NmKJ3JiUp58dSaes4b26AoUT/rrrHEU9SGUu550E9/sUA=="], + + "native-foo-x64": ["native-foo-x64@1.0.0", "http://localhost:1234/native-foo-x64/-/native-foo-x64-1.0.0.tgz", { "os": "none", "cpu": "x64" }, "sha512-+KlZNC/c4RF1wx4ZYdrr2ZfouSHMWM4YLT/yCfh97dlIW1JuRs9LnbdUwrsM007hVF0khUGM9TSVcx+elB6NpQ=="], + + "native-foo-x86": ["native-foo-x86@1.0.0", "http://localhost:1234/native-foo-x86/-/native-foo-x86-1.0.0.tgz", { "os": "none", "cpu": "none" }, "sha512-pUktFGar8JctgQh4Ow5Y9bMp3PB5bHBgbC6M3igED5q99z51WErG2GO3LnPG651SyHtRf+zdeMdhGFWzP54apQ=="], + + "native-libc-glibc": ["native-libc-glibc@1.0.0", "http://localhost:1234/native-libc-glibc/-/native-libc-glibc-1.0.0.tgz", {}, "sha512-D7ivPUqV+bs4jZCFt/fm0BRchhE1kO3XMKZ7/Tt3cF2gfJcewMy/zuId79iaVn9aztJYkOk1GWFpMPXmX5rJHA=="], + + "native-libc-musl": ["native-libc-musl@1.0.0", "http://localhost:1234/native-libc-musl/-/native-libc-musl-1.0.0.tgz", {}, "sha512-1uffg8IA4EJ4VUnuZU4zyRO9EyduuNfbqg2MMVCWSMAsQkfzZnNR0hqtL0GW/EuhE8FWU/FE//Srf1px1pnN2Q=="], + + "optional-native": ["optional-native@1.0.0", "http://localhost:1234/optional-native/-/optional-native-1.0.0.tgz", { "optionalDependencies": { "native-bar-x64": "1.0.0", "native-foo-x64": "1.0.0", "native-foo-x86": "1.0.0", "native-libc-glibc": "1.0.0", "native-libc-musl": "1.0.0" } }, "sha512-E+XTkTpxRqU09BnKGkOkS9vk0sPDhPtArBw6FfL5ciYkb7k6EljnqXEQ1b9l0S1YCVZxZkOZIJCYZfCwj7AgSw=="], + + "optional-peer-deps": ["optional-peer-deps@1.0.0", "http://localhost:1234/optional-peer-deps/-/optional-peer-deps-1.0.0.tgz", { "peerDependencies": { "no-deps": "*" }, "optionalPeers": ["no-deps"] }, "sha512-gJZ2WKSXFwQHjjYNxAjYYIwtgNvDnL+CKURXTtOKNDX27XZN0a9bt+cDgLcCVBTy0V/nQ8h6yW7a6fO34Lv22w=="], + + "pkg1": ["pkg1@workspace:packages/pkg1"], + + "pkg2": ["pkg2@workspace:packages/pkg2"], + + "pkg3": ["pkg3@workspace:packages/pkg3"], + + "uses-what-bin": ["uses-what-bin@1.0.0", "http://localhost:1234/uses-what-bin/-/uses-what-bin-1.0.0.tgz", { "dependencies": { "what-bin": "1.0.0" } }, "sha512-87/Emb1Hh7HtsMMU1yXXhI/+/5opQFbnqtR0Yq/1rgr7jp4mzkMU8wQBiYtS8C45GJY6YfdIqq1Dci+0ivJB2g=="], + + "what-bin": ["what-bin@1.0.0", "http://localhost:1234/what-bin/-/what-bin-1.0.0.tgz", { "bin": { "what-bin": "what-bin.js" } }, "sha512-sa99On1k5aDqCvpni/TQ6rLzYprUWBlb8fNwWOzbjDlM24fRr7FKDOuaBO/Y9WEIcZuzoPkCW5EkBCpflj8REQ=="], + + "bundled-1/no-deps": ["no-deps@1.0.0", "http://localhost:1234/no-deps/-/no-deps-1.0.0.tgz", { "bundled": true }, "sha512-v4w12JRjUGvfHDUP8vFDwu0gUWu04j0cv9hLb1Abf9VdaXu4XcrddYFTMVBVvmldKViGWH7jrb6xPJRF0wq6gw=="], + } +} +" +`; + +exports[`should not change formatting unexpectedly 3`] = ` +[ + "preinstall", + "", + "+ bundled-1@1.0.0", + "", + "13 packages installed", +] +`; diff --git a/test/cli/install/bun-lock.test.ts b/test/cli/install/bun-lock.test.ts index 764375bcb995b9..b636435ae97472 100644 --- a/test/cli/install/bun-lock.test.ts +++ b/test/cli/install/bun-lock.test.ts @@ -1,9 +1,13 @@ import { spawn, write, file } from "bun"; import { expect, it, beforeAll, afterAll } from "bun:test"; import { access, copyFile, open, writeFile, exists, cp, rm } from "fs/promises"; -import { bunExe, bunEnv as env, isWindows, VerdaccioRegistry, runBunInstall } from "harness"; +import { bunExe, bunEnv as env, isWindows, VerdaccioRegistry, runBunInstall, toBeValidBin } from "harness"; import { join } from "path"; +expect.extend({ + toBeValidBin, +}); + var registry = new VerdaccioRegistry(); beforeAll(async () => { @@ -273,3 +277,175 @@ it("should not deduplicate bundled packages with un-bundled packages", async () .slice(1); expect(out2).toEqual(out1); }); + +it("should not change formatting unexpectedly", async () => { + const { packageDir, packageJson } = await registry.createTestDir(); + + const patch = `diff --git a/package.json b/package.json +index d156130662798530e852e1afaec5b1c03d429cdc..b4ddf35975a952fdaed99f2b14236519694f850d 100644 +--- a/package.json ++++ b/package.json +@@ -1,6 +1,7 @@ + { + "name": "optional-peer-deps", + "version": "1.0.0", ++ "hi": true, + "peerDependencies": { + "no-deps": "*" + }, +`; + + // attempt to snapshot most things that can be printed + await Promise.all([ + write( + packageJson, + JSON.stringify({ + name: "pkg-root", + version: "1.0.0", + workspaces: ["packages/*"], + scripts: { + preinstall: "echo 'preinstall'", + }, + overrides: { + "hoist-lockfile-shared": "1.0.1", + }, + bin: "index.js", + optionalDependencies: { + "optional-native": "1.0.0", + }, + devDependencies: { + "optional-peer-deps": "1.0.0", + }, + dependencies: { + "uses-what-bin": "1.0.0", + }, + trustedDependencies: ["uses-what-bin"], + patchedDependencies: { + "optional-peer-deps@1.0.0": "patches/optional-peer-deps@1.0.0.patch", + }, + }), + ), + write(join(packageDir, "patches", "optional-peer-deps@1.0.0.patch"), patch), + write(join(packageDir, "index.js"), "console.log('hello world')"), + write( + join(packageDir, "packages", "pkg1", "package.json"), + JSON.stringify({ + name: "pkg1", + version: "2.2.2", + peerDependenciesMeta: { + "a-dep": { + optional: true, + }, + }, + peerDependencies: { + "a-dep": "1.0.1", + }, + dependencies: { + "bundled-1": "1.0.0", + }, + bin: { + "pkg1-1": "bin-1.js", + "pkg1-2": "bin-2.js", + "pkg1-3": "bin-3.js", + }, + scripts: { + install: "echo 'install'", + postinstall: "echo 'postinstall'", + }, + }), + ), + write(join(packageDir, "packages", "pkg1", "bin-1.js"), "console.log('bin-1')"), + write(join(packageDir, "packages", "pkg1", "bin-2.js"), "console.log('bin-2')"), + write(join(packageDir, "packages", "pkg1", "bin-3.js"), "console.log('bin-3')"), + write( + join(packageDir, "packages", "pkg2", "package.json"), + JSON.stringify({ + name: "pkg2", + bin: { + "pkg2-1": "bin-1.js", + }, + dependencies: { + "map-bin": "1.0.2", + }, + }), + ), + write(join(packageDir, "packages", "pkg2", "bin-1.js"), "console.log('bin-1')"), + write( + join(packageDir, "packages", "pkg3", "package.json"), + JSON.stringify({ + name: "pkg3", + directories: { + bin: "bin", + }, + devDependencies: { + "hoist-lockfile-1": "1.0.0", + }, + }), + ), + write(join(packageDir, "packages", "pkg3", "bin", "bin-1.js"), "console.log('bin-1')"), + ]); + + async function checkInstall() { + expect( + await Promise.all([ + exists(join(packageDir, "node_modules", "pkg1", "package.json")), + exists(join(packageDir, "node_modules", "pkg2", "package.json")), + exists(join(packageDir, "node_modules", "pkg3", "package.json")), + file(join(packageDir, "node_modules", "hoist-lockfile-shared", "package.json")).json(), + exists(join(packageDir, "node_modules", "uses-what-bin", "what-bin.txt")), + file(join(packageDir, "node_modules", "optional-peer-deps", "package.json")).json(), + ]), + ).toMatchObject([true, true, true, { name: "hoist-lockfile-shared", version: "1.0.1" }, true, { hi: true }]); + expect(join(packageDir, "node_modules", ".bin", "bin-1.js")).toBeValidBin(join("..", "pkg3", "bin", "bin-1.js")); + expect(join(packageDir, "node_modules", ".bin", "map-bin")).toBeValidBin(join("..", "map-bin", "bin", "map-bin")); + expect(join(packageDir, "node_modules", ".bin", "map_bin")).toBeValidBin(join("..", "map-bin", "bin", "map-bin")); + expect(join(packageDir, "node_modules", ".bin", "pkg1-1")).toBeValidBin(join("..", "pkg1", "bin-1.js")); + expect(join(packageDir, "node_modules", ".bin", "pkg1-2")).toBeValidBin(join("..", "pkg1", "bin-2.js")); + expect(join(packageDir, "node_modules", ".bin", "pkg1-3")).toBeValidBin(join("..", "pkg1", "bin-3.js")); + expect(join(packageDir, "node_modules", ".bin", "pkg2-1")).toBeValidBin(join("..", "pkg2", "bin-1.js")); + expect(join(packageDir, "node_modules", ".bin", "what-bin")).toBeValidBin(join("..", "what-bin", "what-bin.js")); + } + + let { exited, stdout } = spawn({ + cmd: [bunExe(), "install"], + cwd: packageDir, + env, + stdout: "pipe", + stderr: "inherit", + }); + + expect(await exited).toBe(0); + const out1 = (await Bun.readableStreamToText(stdout)) + .replaceAll(/\s*\[[0-9\.]+m?s\]\s*$/g, "") + .split(/\r?\n/) + .slice(1); + expect(out1).toMatchSnapshot(); + + await checkInstall(); + + const lockfile = (await file(join(packageDir, "bun.lock")).text()).replaceAll(/localhost:\d+/g, "localhost:1234"); + expect(lockfile).toMatchSnapshot(); + + await rm(join(packageDir, "node_modules"), { recursive: true, force: true }); + + ({ exited, stdout } = spawn({ + cmd: [bunExe(), "install"], + cwd: join(packageDir, "packages", "pkg1"), + env, + stdout: "pipe", + stderr: "inherit", + })); + + expect(await exited).toBe(0); + const out2 = (await Bun.readableStreamToText(stdout)) + .replaceAll(/\s*\[[0-9\.]+m?s\]\s*$/g, "") + .split(/\r?\n/) + .slice(1); + expect(out2).toMatchSnapshot(); + + await checkInstall(); + + expect((await file(join(packageDir, "bun.lock")).text()).replaceAll(/localhost:\d+/g, "localhost:1234")).toBe( + lockfile, + ); +}); From 1ccc13ecf79861eb0b5a697c0b5571772d42a28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Kalemba?= Date: Wed, 5 Feb 2025 08:56:12 +0100 Subject: [PATCH 29/29] docs(bunfig): update test runner options (#17040) --- docs/runtime/bunfig.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/runtime/bunfig.md b/docs/runtime/bunfig.md index 36dfa750439307..01c2843f361ee1 100644 --- a/docs/runtime/bunfig.md +++ b/docs/runtime/bunfig.md @@ -180,6 +180,25 @@ Whether to skip test files when computing coverage statistics. Default `false`. coverageSkipTestFiles = false ``` +### `test.coverageReporter` + +By default, coverage reports will be printed to the console. For persistent code coverage reports in CI environments and for other tools use `lcov`. + +```toml +[test] +coverageReporter = ["text", "lcov"] # default ["text"] +``` + +### `test.coverageDir` + +Set path where coverage reports will be saved. Please notice, that it works only for persistent `coverageReporter` like `lcov`. + +```toml +[test] +coverageDir = "path/to/somewhere" # default "coverage" +``` + + ## Package manager Package management is a complex issue; to support a range of use cases, the behavior of `bun install` can be configured under the `[install]` section.