From 3f360b0682d8278b23706554af2ce6398f7cc2cb Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 12 May 2025 17:12:17 -0700 Subject: [PATCH] chore: format packages/scripts folder (#19611) Co-authored-by: Jarred-Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- package.json | 2 +- .../bun-build-mdx-rs/__test__/index.spec.mjs | 10 +- .../npm/darwin-arm64/package.json | 2 +- .../npm/darwin-x64/package.json | 2 +- .../npm/linux-arm64-gnu/package.json | 2 +- .../npm/linux-arm64-musl/package.json | 2 +- .../npm/linux-x64-gnu/package.json | 2 +- .../npm/linux-x64-musl/package.json | 2 +- .../npm/win32-x64-msvc/package.json | 2 +- packages/bun-build-mdx-rs/package.json | 2 +- packages/bun-error/bun-error.css | 13 +- packages/bun-error/index.tsx | 3 +- packages/bun-error/markdown.ts | 2 +- packages/bun-error/runtime-error.ts | 2 +- packages/bun-error/stack-trace-parser.ts | 10 +- packages/bun-error/tsconfig.json | 9 +- packages/bun-inspector-protocol/index.ts | 2 +- .../scripts/generate-protocol.ts | 4 +- .../runners/bun/runner.test.ts | 6 +- .../bun-internal-test/runners/bun/runner.ts | 4 +- .../bun-internal-test/runners/qunit/assert.ts | 2 +- .../bun-internal-test/runners/qunit/qunit.ts | 4 +- .../scripts/run-bun-tests.ts | 7 +- .../scripts/run-ecosystem-tests.ts | 7 +- .../bun-internal-test/src/runner.node.mjs | 6 +- .../bun-internal-test/types/bun-test.d.ts | 2 +- packages/bun-lambda/runtime.ts | 2 +- packages/bun-lambda/scripts/build-layer.ts | 4 +- packages/bun-plugin-svelte/src/index.spec.ts | 2 +- packages/bun-plugin-svelte/src/index.ts | 6 +- .../bun-plugin-svelte/src/options.spec.ts | 2 +- packages/bun-plugin-svelte/src/options.ts | 2 +- packages/bun-plugin-svelte/test/index.test.ts | 6 +- packages/bun-plugin-yaml/index.test.ts | 3 +- packages/bun-release/scripts/npm-exec.ts | 2 +- packages/bun-release/scripts/upload-assets.ts | 8 +- packages/bun-release/scripts/upload-npm.ts | 25 ++- packages/bun-release/scripts/upload-s3.ts | 2 +- packages/bun-release/src/console.ts | 2 +- packages/bun-release/src/fs.ts | 4 +- packages/bun-release/src/github.ts | 2 +- packages/bun-release/src/npm/install.ts | 10 +- packages/bun-release/src/platform.ts | 4 +- packages/bun-release/tsconfig.json | 5 +- packages/bun-types/scripts/build.ts | 11 +- packages/bun-usockets/misc/manual.md | 7 + packages/bun-uws/misc/READMORE.md | 43 +++-- packages/bun-vscode/assets/bun.lock.json | 2 +- packages/bun-vscode/assets/vscode.css | 164 ++++++++++++------ .../example/bake-test/pages/index.tsx | 15 +- packages/bun-vscode/example/example.test.ts | 2 +- packages/bun-vscode/package.json | 2 +- packages/bun-vscode/src/features/debug.ts | 16 +- .../src/features/diagnostics/diagnostics.ts | 2 +- .../bun-vscode/src/features/lockfile/index.ts | 6 +- .../src/features/tasks/package.json.ts | 1 - .../bun-vscode/src/features/tests/index.ts | 1 - packages/bun-vscode/src/vscode-js-debug.d.ts | 62 +++---- packages/bun-wasm/index.ts | 6 +- packages/bun-wasm/test/node.mjs | 2 +- packages/bun-wasm/tsconfig.json | 7 +- scripts/agent.mjs | 24 +-- scripts/build.mjs | 2 +- scripts/features.mjs | 2 +- scripts/glob-sources.mjs | 4 +- scripts/google.mjs | 2 +- scripts/machine.mjs | 47 +++-- scripts/nav2readme.ts | 2 +- scripts/orbstack.mjs | 2 +- scripts/runner.node.mjs | 6 +- scripts/utils.mjs | 2 +- 71 files changed, 350 insertions(+), 294 deletions(-) diff --git a/package.json b/package.json index b177f4aa6f..68e4a425ca 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "clang-tidy:diff": "bun run analysis --target clang-tidy-diff", "zig-format": "bun run analysis:no-llvm --target zig-format", "zig-format:check": "bun run analysis:no-llvm --target zig-format-check", - "prettier": "bunx prettier@latest --plugin=prettier-plugin-organize-imports --config .prettierrc --write src docs 'test/**/*.{test,spec}.{ts,tsx,js,jsx,mts,mjs,cjs,cts}' '!test/**/*fixture*.*'", + "prettier": "bunx prettier@latest --plugin=prettier-plugin-organize-imports --config .prettierrc --write scripts packages src docs 'test/**/*.{test,spec}.{ts,tsx,js,jsx,mts,mjs,cjs,cts}' '!test/**/*fixture*.*'", "node:test": "node ./scripts/runner.node.mjs --quiet --exec-path=$npm_execpath --node-tests ", "clean:zig": "rm -rf build/debug/cache/zig build/debug/CMakeCache.txt 'build/debug/*.o' .zig-cache zig-out || true" } diff --git a/packages/bun-build-mdx-rs/__test__/index.spec.mjs b/packages/bun-build-mdx-rs/__test__/index.spec.mjs index 1ade4cafe8..55f083ffd6 100644 --- a/packages/bun-build-mdx-rs/__test__/index.spec.mjs +++ b/packages/bun-build-mdx-rs/__test__/index.spec.mjs @@ -1,7 +1,7 @@ -import test from 'ava' +import test from "ava"; -import { sum } from '../index.js' +import { sum } from "../index.js"; -test('sum from native', (t) => { - t.is(sum(1, 2), 3) -}) +test("sum from native", t => { + t.is(sum(1, 2), 3); +}); diff --git a/packages/bun-build-mdx-rs/npm/darwin-arm64/package.json b/packages/bun-build-mdx-rs/npm/darwin-arm64/package.json index a49f40f89e..951d585f7c 100644 --- a/packages/bun-build-mdx-rs/npm/darwin-arm64/package.json +++ b/packages/bun-build-mdx-rs/npm/darwin-arm64/package.json @@ -15,4 +15,4 @@ "engines": { "node": ">= 10" } -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/darwin-x64/package.json b/packages/bun-build-mdx-rs/npm/darwin-x64/package.json index 41bd00cd3f..c06d5dcb3f 100644 --- a/packages/bun-build-mdx-rs/npm/darwin-x64/package.json +++ b/packages/bun-build-mdx-rs/npm/darwin-x64/package.json @@ -15,4 +15,4 @@ "engines": { "node": ">= 10" } -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/linux-arm64-gnu/package.json b/packages/bun-build-mdx-rs/npm/linux-arm64-gnu/package.json index 6d8fc3cd88..3306e1c73b 100644 --- a/packages/bun-build-mdx-rs/npm/linux-arm64-gnu/package.json +++ b/packages/bun-build-mdx-rs/npm/linux-arm64-gnu/package.json @@ -18,4 +18,4 @@ "libc": [ "glibc" ] -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/linux-arm64-musl/package.json b/packages/bun-build-mdx-rs/npm/linux-arm64-musl/package.json index 02344ef80a..f157254b73 100644 --- a/packages/bun-build-mdx-rs/npm/linux-arm64-musl/package.json +++ b/packages/bun-build-mdx-rs/npm/linux-arm64-musl/package.json @@ -18,4 +18,4 @@ "libc": [ "musl" ] -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/linux-x64-gnu/package.json b/packages/bun-build-mdx-rs/npm/linux-x64-gnu/package.json index b45a64b866..2118f18b97 100644 --- a/packages/bun-build-mdx-rs/npm/linux-x64-gnu/package.json +++ b/packages/bun-build-mdx-rs/npm/linux-x64-gnu/package.json @@ -18,4 +18,4 @@ "libc": [ "glibc" ] -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/linux-x64-musl/package.json b/packages/bun-build-mdx-rs/npm/linux-x64-musl/package.json index 8a3f90cd98..107c980f24 100644 --- a/packages/bun-build-mdx-rs/npm/linux-x64-musl/package.json +++ b/packages/bun-build-mdx-rs/npm/linux-x64-musl/package.json @@ -18,4 +18,4 @@ "libc": [ "musl" ] -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/npm/win32-x64-msvc/package.json b/packages/bun-build-mdx-rs/npm/win32-x64-msvc/package.json index 738081cb77..2af78fa8b1 100644 --- a/packages/bun-build-mdx-rs/npm/win32-x64-msvc/package.json +++ b/packages/bun-build-mdx-rs/npm/win32-x64-msvc/package.json @@ -15,4 +15,4 @@ "engines": { "node": ">= 10" } -} \ No newline at end of file +} diff --git a/packages/bun-build-mdx-rs/package.json b/packages/bun-build-mdx-rs/package.json index 280221f8c6..8bd5af45fe 100644 --- a/packages/bun-build-mdx-rs/package.json +++ b/packages/bun-build-mdx-rs/package.json @@ -34,4 +34,4 @@ "universal": "napi universal", "version": "napi version" } -} \ No newline at end of file +} diff --git a/packages/bun-error/bun-error.css b/packages/bun-error/bun-error.css index 40ddf8aeec..dff68f46eb 100644 --- a/packages/bun-error/bun-error.css +++ b/packages/bun-error/bun-error.css @@ -1,7 +1,7 @@ :host { --bun-error-color: #e33737; - --bun-error-monospace: ui-monospace, Menlo, Monaco, "Cascadia Mono", - "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", + --bun-error-monospace: + ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace; --bun-error-width: 512px; } @@ -15,7 +15,9 @@ text-decoration: underline; } #BunErrorOverlay-container { - box-shadow: 0px 16px 24px rgba(0, 0, 0, 0.06), 0px 2px 6px rgba(0, 0, 0, 0.1), + box-shadow: + 0px 16px 24px rgba(0, 0, 0, 0.06), + 0px 2px 6px rgba(0, 0, 0, 0.1), 0px 0px 1px rgba(0, 0, 0, 0.04); backdrop-filter: blur(42px); backface-visibility: visible; @@ -29,8 +31,9 @@ right: 48px; z-index: 999999; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, - Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + font-family: + -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", + "Segoe UI Emoji", "Segoe UI Symbol"; } .BunErrorRoot--FullPage #BunErrorOverlay-container { diff --git a/packages/bun-error/index.tsx b/packages/bun-error/index.tsx index ab5212bae2..d026a761c4 100644 --- a/packages/bun-error/index.tsx +++ b/packages/bun-error/index.tsx @@ -1,5 +1,4 @@ -import React from "react"; -import { useContext, createContext } from "react"; +import React, { createContext, useContext } from "react"; import { render, unmountComponentAtNode } from "react-dom"; import type { FallbackMessageContainer, diff --git a/packages/bun-error/markdown.ts b/packages/bun-error/markdown.ts index 52c4251e55..a87970d8a7 100644 --- a/packages/bun-error/markdown.ts +++ b/packages/bun-error/markdown.ts @@ -1,5 +1,5 @@ -import { normalizedFilename, StackFrameIdentifier, thisCwd, StackFrameScope } from "./index"; import type { JSException, JSException as JSExceptionType, Message, Problems } from "../../src/api/schema"; +import { normalizedFilename, StackFrameIdentifier, StackFrameScope, thisCwd } from "./index"; export function problemsToMarkdown(problems: Problems) { var markdown = ""; diff --git a/packages/bun-error/runtime-error.ts b/packages/bun-error/runtime-error.ts index 7827aa1bc9..4a739edf3e 100644 --- a/packages/bun-error/runtime-error.ts +++ b/packages/bun-error/runtime-error.ts @@ -1,6 +1,6 @@ // Based on https://github.com/stacktracejs/error-stack-parser/blob/master/error-stack-parser.js -import type { StackFrame as StackFrameType, StackFramePosition, StackFrameScope } from "../../src/api/schema"; +import type { StackFramePosition, StackFrameScope, StackFrame as StackFrameType } from "../../src/api/schema"; export class StackFrame implements StackFrameType { function_name: string; diff --git a/packages/bun-error/stack-trace-parser.ts b/packages/bun-error/stack-trace-parser.ts index 9fd9abcb93..b18fc8e2ae 100644 --- a/packages/bun-error/stack-trace-parser.ts +++ b/packages/bun-error/stack-trace-parser.ts @@ -1,13 +1,5 @@ const UNKNOWN_FUNCTION = ""; -import type { - FallbackMessageContainer, - JSException, - Location, - Message, - SourceLine, - StackFrame, - WebsocketMessageBuildFailure, -} from "../../src/api/schema"; +import type { StackFrame } from "../../src/api/schema"; /** * This parses the different stack traces and puts them into one format diff --git a/packages/bun-error/tsconfig.json b/packages/bun-error/tsconfig.json index ddf84fcae7..f47d1cc832 100644 --- a/packages/bun-error/tsconfig.json +++ b/packages/bun-error/tsconfig.json @@ -1,13 +1,10 @@ { "compilerOptions": { "jsx": "react", - "lib": [ - "ESNext", - "DOM" - ], + "lib": ["ESNext", "DOM"], "module": "esnext", "target": "esnext", "moduleResolution": "node", - "allowSyntheticDefaultImports": true, + "allowSyntheticDefaultImports": true } -} \ No newline at end of file +} diff --git a/packages/bun-inspector-protocol/index.ts b/packages/bun-inspector-protocol/index.ts index 957f446391..496bfd28b1 100644 --- a/packages/bun-inspector-protocol/index.ts +++ b/packages/bun-inspector-protocol/index.ts @@ -1,5 +1,5 @@ export type * from "./src/inspector/index"; -export * from "./src/inspector/websocket"; export * from "./src/inspector/node-socket"; +export * from "./src/inspector/websocket"; export type * from "./src/protocol/index"; export * from "./src/util/preview"; diff --git a/packages/bun-inspector-protocol/scripts/generate-protocol.ts b/packages/bun-inspector-protocol/scripts/generate-protocol.ts index 65c2976715..3157614372 100644 --- a/packages/bun-inspector-protocol/scripts/generate-protocol.ts +++ b/packages/bun-inspector-protocol/scripts/generate-protocol.ts @@ -1,7 +1,7 @@ import { spawnSync } from "node:child_process"; -import { readFileSync, writeFileSync, realpathSync } from "node:fs"; -import type { Domain, Property, Protocol } from "../src/protocol/schema"; +import { readFileSync, realpathSync, writeFileSync } from "node:fs"; import path from "node:path"; +import type { Property, Protocol } from "../src/protocol/schema"; function formatProtocol(protocol: Protocol, extraTs?: string): string { const { name, domains } = protocol; diff --git a/packages/bun-internal-test/runners/bun/runner.test.ts b/packages/bun-internal-test/runners/bun/runner.test.ts index 72d49ff9a3..aad8a5754a 100644 --- a/packages/bun-internal-test/runners/bun/runner.test.ts +++ b/packages/bun-internal-test/runners/bun/runner.test.ts @@ -1,9 +1,9 @@ -import { describe, test, expect } from "bun:test"; +import { describe, expect, test } from "bun:test"; +import { mkdirSync, mkdtempSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; -import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs"; import { join } from "node:path"; import type { FindTestOptions, ParseTestResult, RunTestResult } from "./runner"; -import { bunSpawn, nodeSpawn, findTests, runTest, runTests } from "./runner"; +import { bunSpawn, findTests, nodeSpawn, runTest, runTests } from "./runner"; describe("runTests()", () => { const cwd = createFs({ diff --git a/packages/bun-internal-test/runners/bun/runner.ts b/packages/bun-internal-test/runners/bun/runner.ts index 43bf4586f5..4ddb55c468 100644 --- a/packages/bun-internal-test/runners/bun/runner.ts +++ b/packages/bun-internal-test/runners/bun/runner.ts @@ -3,9 +3,9 @@ // // In the future, a version of this will be built-in to Bun. -import { join } from "node:path"; -import { readdirSync, writeSync, fsyncSync, symlinkSync, unlinkSync } from "node:fs"; import { spawn } from "node:child_process"; +import { fsyncSync, readdirSync, symlinkSync, unlinkSync, writeSync } from "node:fs"; +import { join } from "node:path"; export type TestInfo = { name: string; diff --git a/packages/bun-internal-test/runners/qunit/assert.ts b/packages/bun-internal-test/runners/qunit/assert.ts index 007b34a558..4147c17560 100644 --- a/packages/bun-internal-test/runners/qunit/assert.ts +++ b/packages/bun-internal-test/runners/qunit/assert.ts @@ -1,5 +1,5 @@ -import type { Assert } from "./qunit.d"; import type { BunExpect } from "bun-test"; +import type { Assert } from "./qunit.d"; export { $Assert as Assert }; diff --git a/packages/bun-internal-test/runners/qunit/qunit.ts b/packages/bun-internal-test/runners/qunit/qunit.ts index 33b95f6c02..267a331e70 100644 --- a/packages/bun-internal-test/runners/qunit/qunit.ts +++ b/packages/bun-internal-test/runners/qunit/qunit.ts @@ -1,7 +1,7 @@ -import type { DataInit, EachFn, Fn, Hooks, HooksFn, ModuleFn, TestEachFn, TestFn, TestOrEachFn } from "./qunit.d"; +import { deepEquals, inspect } from "bun"; import type { TestContext } from "bun-test"; -import { inspect, deepEquals } from "bun"; import { Assert } from "./assert"; +import type { DataInit, EachFn, Fn, Hooks, HooksFn, ModuleFn, TestEachFn, TestFn, TestOrEachFn } from "./qunit.d"; type Status = "todo" | "skip" | "only" | undefined; diff --git a/packages/bun-internal-test/scripts/run-bun-tests.ts b/packages/bun-internal-test/scripts/run-bun-tests.ts index 3cef5eeab3..f00e9ab4b5 100644 --- a/packages/bun-internal-test/scripts/run-bun-tests.ts +++ b/packages/bun-internal-test/scripts/run-bun-tests.ts @@ -1,8 +1,7 @@ +import { a, br, code, count, duration, h, table, ul } from "html"; import { appendFileSync } from "node:fs"; -import { resolve, basename } from "node:path"; -import { a, h, count, duration, table, br, ul, code } from "html"; -import { TestError, TestStatus, printTest } from "runner"; -import { runTests } from "runner"; +import { basename, resolve } from "node:path"; +import { TestError, TestStatus, printTest, runTests } from "runner"; const cwd = resolve(import.meta.dir, "..", "..", "..", "test"); const filters = process.argv.slice(2); // TODO diff --git a/packages/bun-internal-test/scripts/run-ecosystem-tests.ts b/packages/bun-internal-test/scripts/run-ecosystem-tests.ts index 0b604f414b..3ad4a6b380 100644 --- a/packages/bun-internal-test/scripts/run-ecosystem-tests.ts +++ b/packages/bun-internal-test/scripts/run-ecosystem-tests.ts @@ -1,8 +1,7 @@ -import { readFileSync, existsSync, appendFileSync } from "node:fs"; -import { spawnSync } from "node:child_process"; -import { TestSummary, TestError, TestStatus, TestFile, Test, printTest } from "runner"; -import { runTests } from "runner"; import { a, br, code, count, details, duration, h, percent, table, ul } from "html"; +import { spawnSync } from "node:child_process"; +import { appendFileSync, existsSync, readFileSync } from "node:fs"; +import { Test, TestError, TestFile, TestStatus, TestSummary, printTest, runTests } from "runner"; const [filter] = process.argv.slice(2); const packagesText = readFileSync(resolve("resources/packages.json"), "utf8"); diff --git a/packages/bun-internal-test/src/runner.node.mjs b/packages/bun-internal-test/src/runner.node.mjs index d6d76d3205..161924ef5a 100644 --- a/packages/bun-internal-test/src/runner.node.mjs +++ b/packages/bun-internal-test/src/runner.node.mjs @@ -1,12 +1,12 @@ import * as action from "@actions/core"; import { spawn, spawnSync } from "child_process"; -import { rmSync, writeFileSync, readFileSync, mkdirSync, openSync, closeSync } from "fs"; +import { closeSync, mkdirSync, openSync, readFileSync, rmSync, writeFileSync } from "fs"; import { readdirSync } from "node:fs"; -import { resolve, basename } from "node:path"; +import { basename, resolve } from "node:path"; import { cpus, hostname, tmpdir, totalmem, userInfo } from "os"; +import PQueue from "p-queue"; import { join, normalize, posix, relative } from "path"; import { fileURLToPath } from "url"; -import PQueue from "p-queue"; const run_start = new Date(); const TIMEOUT_DURATION = 1000 * 60 * 5; diff --git a/packages/bun-internal-test/types/bun-test.d.ts b/packages/bun-internal-test/types/bun-test.d.ts index 13d3b06ba8..267ea9d6bc 100644 --- a/packages/bun-internal-test/types/bun-test.d.ts +++ b/packages/bun-internal-test/types/bun-test.d.ts @@ -1,4 +1,4 @@ -import type { Expect, test, describe, beforeAll, beforeEach, afterAll, afterEach } from "bun:test"; +import type { afterAll, afterEach, beforeAll, beforeEach, describe, Expect, test } from "bun:test"; export type BunExpect = (value: unknown) => Expect; export type BunDescribe = typeof describe; diff --git a/packages/bun-lambda/runtime.ts b/packages/bun-lambda/runtime.ts index 791624b52b..79183c6a65 100755 --- a/packages/bun-lambda/runtime.ts +++ b/packages/bun-lambda/runtime.ts @@ -1,5 +1,5 @@ -import type { Server, ServerWebSocket } from "bun"; import { AwsClient } from "aws4fetch"; +import type { Server, ServerWebSocket } from "bun"; type Lambda = { fetch: (request: Request, server: Server) => Promise; diff --git a/packages/bun-lambda/scripts/build-layer.ts b/packages/bun-lambda/scripts/build-layer.ts index fd930d4883..d752959fce 100644 --- a/packages/bun-lambda/scripts/build-layer.ts +++ b/packages/bun-lambda/scripts/build-layer.ts @@ -2,10 +2,10 @@ process.stdout.getWindowSize = () => [80, 80]; process.stderr.getWindowSize = () => [80, 80]; -import { createReadStream, writeFileSync } from "node:fs"; -import { join } from "node:path"; import { Command, Flags } from "@oclif/core"; import JSZip from "jszip"; +import { createReadStream, writeFileSync } from "node:fs"; +import { join } from "node:path"; export class BuildCommand extends Command { static summary = "Build a custom Lambda layer for Bun."; diff --git a/packages/bun-plugin-svelte/src/index.spec.ts b/packages/bun-plugin-svelte/src/index.spec.ts index ccf550a59c..4f73094a09 100644 --- a/packages/bun-plugin-svelte/src/index.spec.ts +++ b/packages/bun-plugin-svelte/src/index.spec.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from "bun:test"; +import { describe, expect, it } from "bun:test"; import { SveltePlugin } from "./index"; describe("SveltePlugin", () => { diff --git a/packages/bun-plugin-svelte/src/index.ts b/packages/bun-plugin-svelte/src/index.ts index 2c8784639b..5059c065df 100644 --- a/packages/bun-plugin-svelte/src/index.ts +++ b/packages/bun-plugin-svelte/src/index.ts @@ -1,12 +1,12 @@ -import type { BunPlugin, BuildConfig, OnLoadResult } from "bun"; +import type { BuildConfig, BunPlugin, OnLoadResult } from "bun"; import { basename } from "node:path"; import { compile, compileModule } from "svelte/compiler"; import { getBaseCompileOptions, + getBaseModuleCompileOptions, + hash, validateOptions, type SvelteOptions, - hash, - getBaseModuleCompileOptions, } from "./options"; const kEmptyObject = Object.create(null); diff --git a/packages/bun-plugin-svelte/src/options.spec.ts b/packages/bun-plugin-svelte/src/options.spec.ts index 10960e2d29..280d3f9bc8 100644 --- a/packages/bun-plugin-svelte/src/options.spec.ts +++ b/packages/bun-plugin-svelte/src/options.spec.ts @@ -1,5 +1,5 @@ -import { describe, beforeAll, it, expect } from "bun:test"; import type { BuildConfig } from "bun"; +import { beforeAll, describe, expect, it } from "bun:test"; import type { CompileOptions } from "svelte/compiler"; import { getBaseCompileOptions, validateOptions, type SvelteOptions } from "./options"; diff --git a/packages/bun-plugin-svelte/src/options.ts b/packages/bun-plugin-svelte/src/options.ts index 7e69abc180..21fe9dccde 100644 --- a/packages/bun-plugin-svelte/src/options.ts +++ b/packages/bun-plugin-svelte/src/options.ts @@ -1,5 +1,5 @@ -import { strict as assert } from "node:assert"; import { type BuildConfig } from "bun"; +import { strict as assert } from "node:assert"; import type { CompileOptions, ModuleCompileOptions } from "svelte/compiler"; type OverrideCompileOptions = Pick; diff --git a/packages/bun-plugin-svelte/test/index.test.ts b/packages/bun-plugin-svelte/test/index.test.ts index f0add2eb11..97bd489652 100644 --- a/packages/bun-plugin-svelte/test/index.test.ts +++ b/packages/bun-plugin-svelte/test/index.test.ts @@ -1,10 +1,10 @@ -import { describe, beforeAll, it, expect, afterEach, afterAll } from "bun:test"; -import path from "node:path"; +import type { BuildOutput } from "bun"; +import { afterAll, afterEach, beforeAll, describe, expect, it } from "bun:test"; import fs from "node:fs"; import os from "node:os"; +import path from "node:path"; import { render } from "svelte/server"; import { SveltePlugin } from "../src"; -import type { BuildOutput } from "bun"; const fixturePath = (...segs: string[]) => path.join(import.meta.dirname, "fixtures", ...segs); diff --git a/packages/bun-plugin-yaml/index.test.ts b/packages/bun-plugin-yaml/index.test.ts index e8a41b8229..84825e77bc 100644 --- a/packages/bun-plugin-yaml/index.test.ts +++ b/packages/bun-plugin-yaml/index.test.ts @@ -1,6 +1,5 @@ -import { test, expect } from "bun:test"; +import { expect, test } from "bun:test"; import YamlPlugin from "."; -import data from "./data.yml"; test("yaml loader - no plugin", async () => { expect(async () => { diff --git a/packages/bun-release/scripts/npm-exec.ts b/packages/bun-release/scripts/npm-exec.ts index 5938f43837..c8a9f4aeab 100644 --- a/packages/bun-release/scripts/npm-exec.ts +++ b/packages/bun-release/scripts/npm-exec.ts @@ -1,5 +1,5 @@ -import { importBun, optimizeBun } from "../src/npm/install"; import { execFileSync } from "child_process"; +import { importBun } from "../src/npm/install"; importBun() .then(bun => { diff --git a/packages/bun-release/scripts/upload-assets.ts b/packages/bun-release/scripts/upload-assets.ts index aeab55c040..38aff71358 100644 --- a/packages/bun-release/scripts/upload-assets.ts +++ b/packages/bun-release/scripts/upload-assets.ts @@ -1,8 +1,8 @@ -import { getRelease, uploadAsset } from "../src/github"; -import { fetch } from "../src/fetch"; -import { spawn } from "../src/spawn"; import { confirm, exit, log, stdin, warn } from "../src/console"; -import { hash, join, rm, tmp, write, basename, blob } from "../src/fs"; +import { fetch } from "../src/fetch"; +import { basename, blob, hash, join, rm, tmp, write } from "../src/fs"; +import { getRelease, uploadAsset } from "../src/github"; +import { spawn } from "../src/spawn"; const [tag, ...paths] = process.argv.slice(2); diff --git a/packages/bun-release/scripts/upload-npm.ts b/packages/bun-release/scripts/upload-npm.ts index 0d7769c360..9cd35783a8 100644 --- a/packages/bun-release/scripts/upload-npm.ts +++ b/packages/bun-release/scripts/upload-npm.ts @@ -1,20 +1,19 @@ -import { join, copy, exists, chmod, write, writeJson } from "../src/fs"; -import { mkdtemp } from "fs/promises"; -import { rmSync, mkdirSync } from "fs"; -import { tmpdir } from "os"; -import { dirname } from "path"; -import { fetch } from "../src/fetch"; -import { spawn } from "../src/spawn"; -import type { Platform } from "../src/platform"; -import { platforms } from "../src/platform"; -import { getSemver } from "../src/github"; -import { getRelease } from "../src/github"; +import { expect } from "bun:test"; import type { BuildOptions } from "esbuild"; import { buildSync, formatMessagesSync } from "esbuild"; +import { mkdirSync, rmSync } from "fs"; +import { mkdtemp } from "fs/promises"; import type { JSZipObject } from "jszip"; import { loadAsync } from "jszip"; -import { debug, log, error } from "../src/console"; -import { expect } from "bun:test"; +import { tmpdir } from "os"; +import { dirname } from "path"; +import { debug, error, log } from "../src/console"; +import { fetch } from "../src/fetch"; +import { chmod, copy, exists, join, write, writeJson } from "../src/fs"; +import { getRelease, getSemver } from "../src/github"; +import type { Platform } from "../src/platform"; +import { platforms } from "../src/platform"; +import { spawn } from "../src/spawn"; const module = "bun"; const owner = "@oven"; diff --git a/packages/bun-release/scripts/upload-s3.ts b/packages/bun-release/scripts/upload-s3.ts index 1e5e5a8aeb..937ddf28c0 100644 --- a/packages/bun-release/scripts/upload-s3.ts +++ b/packages/bun-release/scripts/upload-s3.ts @@ -1,6 +1,6 @@ import { AwsClient } from "aws4fetch"; -import { getBuild, getRelease, getSemver, getSha } from "../src/github"; import { join, tmp } from "../src/fs"; +import { getBuild, getRelease, getSemver, getSha } from "../src/github"; // The source of truth for the git sha is what's in the local build, extracted from features.json // NOT the git tag revision. diff --git a/packages/bun-release/src/console.ts b/packages/bun-release/src/console.ts index 5c9db88728..2ada0cdcd6 100644 --- a/packages/bun-release/src/console.ts +++ b/packages/bun-release/src/console.ts @@ -1,5 +1,5 @@ -import { isatty } from "tty"; import { createInterface } from "readline"; +import { isatty } from "tty"; export const isAction = !!process.env["GITHUB_ACTION"]; diff --git a/packages/bun-release/src/fs.ts b/packages/bun-release/src/fs.ts index 34b1c40766..66481b5b24 100644 --- a/packages/bun-release/src/fs.ts +++ b/packages/bun-release/src/fs.ts @@ -1,7 +1,7 @@ -import path from "path"; +import crypto from "crypto"; import fs from "fs"; import os from "os"; -import crypto from "crypto"; +import path from "path"; import { debug } from "./console"; export function join(...paths: (string | string[])[]): string { diff --git a/packages/bun-release/src/github.ts b/packages/bun-release/src/github.ts index e61e77070b..bba0fbfa3d 100644 --- a/packages/bun-release/src/github.ts +++ b/packages/bun-release/src/github.ts @@ -1,7 +1,7 @@ import type { Endpoints, RequestParameters, Route } from "@octokit/types"; import { Octokit } from "octokit"; +import { debug, error, log, warn } from "./console"; import { fetch } from "./fetch"; -import { debug, log, warn, error } from "./console"; const [owner, repo] = process.env["GITHUB_REPOSITORY"]?.split("/") ?? ["oven-sh", "bun"]; diff --git a/packages/bun-release/src/npm/install.ts b/packages/bun-release/src/npm/install.ts index f2f65d1a70..f6e7d48437 100644 --- a/packages/bun-release/src/npm/install.ts +++ b/packages/bun-release/src/npm/install.ts @@ -1,10 +1,10 @@ -import { fetch } from "../fetch"; -import { spawn } from "../spawn"; -import { chmod, join, rename, rm, tmp, write } from "../fs"; import { unzipSync } from "zlib"; -import type { Platform } from "../platform"; -import { os, arch, abi, supportedPlatforms } from "../platform"; import { debug, error } from "../console"; +import { fetch } from "../fetch"; +import { chmod, join, rename, rm, tmp, write } from "../fs"; +import type { Platform } from "../platform"; +import { abi, arch, os, supportedPlatforms } from "../platform"; +import { spawn } from "../spawn"; declare const version: string; declare const module: string; diff --git a/packages/bun-release/src/platform.ts b/packages/bun-release/src/platform.ts index 39d581fbb0..171c4c3b1f 100644 --- a/packages/bun-release/src/platform.ts +++ b/packages/bun-release/src/platform.ts @@ -1,6 +1,6 @@ -import { spawn } from "./spawn"; -import { exists, read } from "./fs"; import { debug } from "./console"; +import { exists, read } from "./fs"; +import { spawn } from "./spawn"; export const os = process.platform; diff --git a/packages/bun-release/tsconfig.json b/packages/bun-release/tsconfig.json index b7194ece3f..9bd5ee44ab 100644 --- a/packages/bun-release/tsconfig.json +++ b/packages/bun-release/tsconfig.json @@ -10,8 +10,5 @@ "strict": true, "resolveJsonModule": true }, - "include": [ - "src", - "scripts" - ] + "include": ["src", "scripts"] } diff --git a/packages/bun-types/scripts/build.ts b/packages/bun-types/scripts/build.ts index 536a988724..e3dacef9f8 100644 --- a/packages/bun-types/scripts/build.ts +++ b/packages/bun-types/scripts/build.ts @@ -2,13 +2,6 @@ import { join } from "node:path"; import pkg from "../package.json"; -const BUN_VERSION = ( - process.env.BUN_VERSION || - Bun.version || - process.versions.bun -).replace(/^.*v/, ""); +const BUN_VERSION = (process.env.BUN_VERSION || Bun.version || process.versions.bun).replace(/^.*v/, ""); -Bun.write( - join(import.meta.dir, "..", "package.json"), - JSON.stringify({ version: BUN_VERSION, ...pkg }, null, 2), -); +Bun.write(join(import.meta.dir, "..", "package.json"), JSON.stringify({ version: BUN_VERSION, ...pkg }, null, 2)); diff --git a/packages/bun-usockets/misc/manual.md b/packages/bun-usockets/misc/manual.md index 13d3dc6ca4..5fab9b3134 100644 --- a/packages/bun-usockets/misc/manual.md +++ b/packages/bun-usockets/misc/manual.md @@ -1,15 +1,19 @@ # libusockets.h + This is the only header you include. Following documentation has been extracted from this header. It may be outdated, go read the header directly for up-to-date documentation. These interfaces are "beta" and subject to smaller changes. Last updated **2019-06-11**. # A quick note on compilation + Major differences in performance can be seen based solely on compiler and/or linker options. Important is to compile with some kind of link-time-optimization mode, preferably with static linking of this library such as including all C source files in the user program build step itself. Proper compilation and linking can lead to over 25% performance increase (in my case, YMMV). # Cross-platform benchmarks + While the library is compatible with many platforms, Linux in particular is the preferred production system. Benchmarking has been done on Windows, Linux and macOS where Linux clearly stood out as significant winner. Windows performed about half that of Linux and macOS was not much better than Windows. Do run your production systems on Linux. # us_loop_t - The root per-thread resource and callback emitter + ```c /* Returns a new event loop with user data extension */ WIN32_EXPORT struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size); @@ -35,6 +39,7 @@ WIN32_EXPORT long long us_loop_iteration_number(struct us_loop_t *loop); ``` # us_socket_context_t - The per-behavior group of networking sockets + ```c struct us_socket_context_options_t { const char *key_file_name; @@ -87,6 +92,7 @@ WIN32_EXPORT struct us_socket_context_t *us_create_child_socket_context(int ssl, ``` # us_socket_t - The network connection (SSL or non-SSL) + ```c /* Write up to length bytes of data. Returns actual bytes written. Will call the on_writable callback of active socket context on failure to write everything off in one go. * Set hint msg_more if you have more immediate data to write. */ @@ -145,6 +151,7 @@ WIN32_EXPORT struct us_loop_t *us_timer_loop(struct us_timer_t *t); ``` ## us_poll_t - The eventing foundation of a socket or anything that has a file descriptor + ```c /* A fallthrough poll does not keep the loop running, it falls through */ WIN32_EXPORT struct us_poll_t *us_create_poll(struct us_loop_t *loop, int fallthrough, unsigned int ext_size); diff --git a/packages/bun-uws/misc/READMORE.md b/packages/bun-uws/misc/READMORE.md index 93fde858b0..f35de0aa50 100644 --- a/packages/bun-uws/misc/READMORE.md +++ b/packages/bun-uws/misc/READMORE.md @@ -12,6 +12,7 @@ It comes with built-in pub/sub support, URL routing, TLS 1.3, SNI, IPv6, permess Unlike other "pub/sub brokers", µWS does not assume or push any particular application protocol but only operates over raw, standard WebSockets. You need nothing but a standards compliant web browser and a handful of standards compliant JavaScript to communicate with it. No particular client library is needed or enforced - this unlike inadequate solutions like Socket.IO where you end up locked to a set of proprietary non-standard protocols with horrible performance. ### Performant + The implementation is header-only C++17 (but examples use C++20 features for brevity and elegance!), cross-platform and compiles down to a tiny binary of a handful kilobytes. It depends on µSockets, which is a standard C project for Linux, macOS & Windows. @@ -20,6 +21,7 @@ Performance wise you can expect to outperform, or equal, just about anything sim We've [openly presented](https://medium.com/swlh/100k-secure-websockets-with-raspberry-pi-4-1ba5d2127a23) detailed cases where a single Raspberry Pi 4 can serve more than 100k very active TLS 1.3 WebSockets, simultaneously, with excellent stability. This is entirely impossible with the vast majority of alternative solutions. Most solutions cramp up and become unreliable at a tiny fraction of this load, on such a limited hardware. We also have measurements where we [serve 12x the HTTP requests per second](https://levelup.gitconnected.com/serving-100k-requests-second-from-a-fanless-raspberry-pi-4-over-ethernet-fdd2c2e05a1e) as compared to Node.js. ### Simple to use + Another goal of the project is minimalism, simplicity and elegance. Design wise it follows an ExpressJS-like interface where you attach callbacks to different URL routes. This way you can easily build complete REST/WebSocket services in a few lines of code. @@ -29,23 +31,26 @@ Boilerplate logic like heartbeat timeouts, backpressure handling, ping/pong and The project is async only and runs local to one thread. You scale it as individual threads much like Node.js scales as individual processes. That is, the implementation only sees a single thread and is not thread-safe. There are simple ways to do threading via async delegates though, if you really need to. ## Compiling + µWebSockets is 100% standard header-only C++17 - it compiles on any platform. However, it depends on µSockets in all cases, which is platform-specific C code that runs on Linux, Windows and macOS. There are a few compilation flags for µSockets (see its documentation), but common between µSockets and µWebSockets flags are as follows: -* LIBUS_NO_SSL - disable OpenSSL dependency/functionality for uSockets and uWebSockets builds -* UWS_NO_ZLIB - disable Zlib dependency/functionality for uWebSockets +- LIBUS_NO_SSL - disable OpenSSL dependency/functionality for uSockets and uWebSockets builds +- UWS_NO_ZLIB - disable Zlib dependency/functionality for uWebSockets You can use the Makefile on Linux and macOS. It is simple to use and builds the examples for you. `WITH_OPENSSL=1 make` builds all examples with SSL enabled. Examples will fail to listen if cert and key cannot be found, so make sure to specify a path that works for you. ## User manual ### uWS::App & uWS::SSLApp + You begin your journey by constructing an "App". Either an SSL-app or a regular TCP-only App. The uWS::SSLApp constructor takes a struct holding SSL options such as cert and key. Interfaces for both apps are identical, so let's call them both "App" from now on. Apps follow the builder pattern, member functions return the App so that you can chain calls. ### App.get, post, put, [...] and any routes + You attach behavior to "URL routes". A lambda is paired with a "method" (Http method that is) and a pattern (the URL matching pattern). Methods are many, but most common are probably get & post. They all have the same signature, let's look at one example: @@ -67,40 +72,44 @@ Data that you capture in a res follows RAII and is move-only so you can properly The "any" route will match any method. #### Pattern matching + Routes are matched in **order of specificity**, not by the order you register them: -* Highest priority - static routes, think "/hello/this/is/static". -* Middle priority - parameter routes, think "/candy/:kind", where value of :kind is retrieved by req.getParameter(0). -* Lowest priority - wildcard routes, think "/hello/*". +- Highest priority - static routes, think "/hello/this/is/static". +- Middle priority - parameter routes, think "/candy/:kind", where value of :kind is retrieved by req.getParameter(0). +- Lowest priority - wildcard routes, think "/hello/\*". In other words, the more specific a route is, the earlier it will match. This allows you to define wildcard routes that match a wide range of URLs and then "carve" out more specific behavior from that. "Any" routes, those who match any HTTP method, will match with lower priority than routes which specify their specific HTTP method (such as GET) if and only if the two routes otherwise are equally specific. #### Middlewares + A very commonly asked question is how to achieve something like middlewares. We don't support middlewares as something built into the router itself. Partly because routes cannot pass data to other routes, partly because the HttpRequest object being stack-allocated and only valid in one single callback invocation, but most importantly - you can **easily** achieve the same function-chaining that is middlewares by instead using simple high-order functions and functional programming. There are tons of examples of this under Discussions (since it is a commonly asked question). A middleware isn't really something that has to be built-in to the server library itself, it really is just **a regular function**. By passing functions to other functions you can build chains of behaviors in very elegant and efficient ways. Whether this library should keep a set of commonly used functions is another question - we might do that in the future and we might add an example of its usage but right now there is nothing like this provided. We aim to provide an easy to use server implementation that you can build things on. Not complete business logic puzzle pieces. #### Streaming data + You should never call res.end(huge buffer). res.end guarantees sending so backpressure will probably spike. Instead you should use res.tryEnd to stream huge data part by part. Use in combination with res.onWritable and res.onAborted callbacks. Tip: Check out the JavaScript project, it has many useful examples of async streaming of huge data. #### Corking + It is very important to understand the corking mechanism, as that is responsible for efficiently formatting, packing and sending data. Without corking your app will still work reliably, but can perform very bad and use excessive networking. In some cases the performance can be dreadful without proper corking. That's why your sockets will be corked by default in most simple cases, including all of the examples provided. However there are cases where default corking cannot happen automatically. -* Whenever your registered business logic (your callbacks) are called from the library, such as when receiving a message or when a socket opens, you'll be corked by default. Whatever you do with the socket inside of that callback will be efficient and properly corked. +- Whenever your registered business logic (your callbacks) are called from the library, such as when receiving a message or when a socket opens, you'll be corked by default. Whatever you do with the socket inside of that callback will be efficient and properly corked. -* If you have callbacks registered to some other library, say libhiredis, those callbacks will not be called with corked sockets (how could **we** know when to cork the socket if we don't control the third-party library!?). +- If you have callbacks registered to some other library, say libhiredis, those callbacks will not be called with corked sockets (how could **we** know when to cork the socket if we don't control the third-party library!?). -* Only one single socket can be corked at any point in time (isolated per thread, of course). It is efficient to cork-and-uncork. +- Only one single socket can be corked at any point in time (isolated per thread, of course). It is efficient to cork-and-uncork. -* Whenever your callback is a coroutine, such as the JavaScript async/await, automatic corking can only happen in the very first portion of the coroutine (consider await a separator which essentially cuts the coroutine into smaller segments). Only the first "segment" of the coroutine will be called from µWS, the following async segments will be called by the JavaScript runtime at a later point in time and will thus not be under our control with default corking enabled. +- Whenever your callback is a coroutine, such as the JavaScript async/await, automatic corking can only happen in the very first portion of the coroutine (consider await a separator which essentially cuts the coroutine into smaller segments). Only the first "segment" of the coroutine will be called from µWS, the following async segments will be called by the JavaScript runtime at a later point in time and will thus not be under our control with default corking enabled. -* Corking is important even for calls which seem to be "atomic" and only send one chunk. res->end, res->tryEnd, res->writeStatus, res->writeHeader will most likely send multiple chunks of data and is very important to properly cork. +- Corking is important even for calls which seem to be "atomic" and only send one chunk. res->end, res->tryEnd, res->writeStatus, res->writeHeader will most likely send multiple chunks of data and is very important to properly cork. You can make sure corking is enabled, even for cases where default corking would be enabled, by wrapping whatever sending function calls in a lambda like so: @@ -115,6 +124,7 @@ The above res->end call will actually call three separate send functions; res->w Keep this in mind, corking is by far the single most important performance trick to use. Even when streaming huge amounts of data it can be useful to cork. At least in the very tip of the response, as that holds the headers and status. ### The App.ws route + WebSocket "routes" are registered similarly, but not identically. Every websocket route has the same pattern and pattern matching as for Http, but instead of one single callback you have a whole set of them, here's an example: @@ -155,39 +165,47 @@ WebSocket routes specify a user data type that should be used to keep per-websoc which should belong to the websocket by putting the pointer and the user data in a std::map. That's wrong! Don't do that! #### Use the WebSocket.getUserData() feature + You should use the provided user data feature to store and attach any per-socket user data. Going from user data to WebSocket is possible if you make your user data hold a pointer to WebSocket, and hook things up in the WebSocket open handler. Your user data memory is valid while your WebSocket is. If you want to create something more elaborate you could have the user data hold a pointer to some dynamically allocated memory block that keeps a boolean whether the WebSocket is still valid or not. Sky is the limit here, you should never need any std::map for this. #### WebSockets are valid from open to close + All given WebSocket pointers are guaranteed to live from open event (where you got your WebSocket) until close event is called. So is the user data memory. One open event will always end in exactly one close event, they are 1-to-1 and will always be balanced no matter what. Use them to drive your RAII data types, they can be seen as constructor and destructor. Message events will never emit outside of open/close. Calling WebSocket.close or WebSocket.end will immediately call the close handler. #### Backpressure in websockets + Similarly to for Http, methods such as ws.send(...) can cause backpressure. Make sure to check ws.getBufferedAmount() before sending, and check the return value of ws.send before sending any more data. WebSockets do not have .onWritable, but instead make use of the .drain handler of the websocket route handler. Inside of .drain event you should check ws.getBufferedAmount(), it might have drained, or even increased. Most likely drained but don't assume that it has, .drain event is only a hint that it has changed. #### Ping/pongs "heartbeats" + The library will automatically send pings to clients according to the `idleTimeout` specified. If you set idleTimeout = 120 seconds a ping will go out a few seconds before this timeout unless the client has sent something to the server recently. If the client responds to the ping, the socket will stay open. When client fails to respond in time, the socket will be forcefully closed and the close event will trigger. On disconnect all resources are freed, including subscriptions to topics and any backpressure. You can easily let the browser reconnect using 3-lines-or-so of JavaScript if you want to. #### Backpressure + Sending on a WebSocket can build backpressure. WebSocket::send returns an enum of BACKPRESSURE, SUCCESS or DROPPED. When send returns BACKPRESSURE it means you should stop sending data until the drain event fires and WebSocket::getBufferedAmount() returns a reasonable amount of bytes. But in case you specified a maxBackpressure when creating the WebSocketContext, this limit will automatically be enforced. That means an attempt at sending a message which would result in too much backpressure will be canceled and send will return DROPPED. This means the message was dropped and will not be put in the queue. maxBackpressure is an essential setting when using pub/sub as a slow receiver otherwise could build up a lot of backpressure. By setting maxBackpressure the library will automatically manage an enforce a maximum allowed backpressure per socket for you. #### Threading + The library is single threaded. You cannot, absolutely not, mix threads. A socket created from an App on thread 1 cannot be used in any way from thread 2. The only function in the whole entire library which is thread-safe and can be used from any thread is Loop:defer. Loop::defer takes a function (such as a lambda with data) and defers the execution of said function until the specified loop's thread is ready to execute the function in a single-threaded fashion on correct thread. So in case you want to publish a message under a topic, or send on some other thread's sockets you can, but it requires a bit of indirection. You should aim for having as isolated apps and threads as possible. #### Settings + Compression (permessage-deflate) has three main modes; uWS::DISABLED, uWS::SHARED_COMPRESSOR and any of the uWS::DEDICATED_COMPRESSOR_xKB. Disabled and shared options require no memory, while dedicated compressor requires the amount of memory you selected. For instance, uWS::DEDICATED_COMPRESSOR_4KB adds an overhead of 4KB per WebSocket while uWS::DEDICATED_COMPRESSOR_256KB adds - you guessed it - 256KB! Compressing using shared means that every WebSocket message is an isolated compression stream, it does not have a sliding compression window, kept between multiple send calls like the dedicated variants do. You probably want shared compressor if dealing with larger JSON messages, or 4kb dedicated compressor if dealing with smaller JSON messages and if doing binary messaging you probably want to disable it completely. -* idleTimeout is roughly the amount of seconds that may pass between messages. Being idle for more than this, and the connection is severed. This means you should make your clients send small ping messages every now and then, to keep the connection alive. You can also make the server send ping messages but I would definitely put that labor on the client side. (outdated text - this is not entirely true anymore. The server will automatically send pings in case it needs to). +- idleTimeout is roughly the amount of seconds that may pass between messages. Being idle for more than this, and the connection is severed. This means you should make your clients send small ping messages every now and then, to keep the connection alive. You can also make the server send ping messages but I would definitely put that labor on the client side. (outdated text - this is not entirely true anymore. The server will automatically send pings in case it needs to). ### Listening on a port + Once you have defined your routes and their behavior, it is time to start listening for new connections. You do this by calling ```c++ @@ -199,6 +217,7 @@ App.listen(port, [](auto *listenSocket) { Canceling listening is done with the uSockets function call `us_listen_socket_close`. ### App.run and fallthrough + When you are done and want to enter the event loop, you call, once and only once, App.run. This will block the calling thread until "fallthrough". The event loop will block until no more async work is scheduled, just like for Node.js. @@ -231,6 +250,7 @@ If you want to, you can simply take the previous example, put it inside of a few Recent Node.js versions may scale using multiple threads, via the new Worker threads support. Scaling using that feature is identical to scaling using multiple threads in C++. ### Compression + We aren't as careful with resources as we used to be. Just look at, how many web developers represent time - it is not uncommon for web developers to send an entire textual representation of time as 30-something actual letters inside a JSON document with an actual textual key. This is just awful. We have had standardized, time-zone neutral representation of time in binary, efficient, 4-byte (or more commonly the 8 byte variant) representation since the 1970s. It's called unix timestamp and is an elegant and efficient way of representing time-zone neutral time down to the seconds. This is just an example of how we have regressed in our algorithmic thinking. Today it is common to use textual representations such as bloated JSON to represent data, even though most of that bloat is obvious repetitions and inefficient in nature. But we don't care because we have compression. True, even the most bloated source format can be compressed down to a small payload with few repetitions - however - this comes at TREMENDOUS cost. @@ -248,4 +268,5 @@ It is true that we can do more permessage-deflate messages/second than many othe So you might say - hey - that's too complex. Well build an SDK for your users then. Just wrap that "complex" protocol up in a JavaScript library that internally knows about this palette and exposes only simple-to-use functions for the end user. It's not that hard of a problem to solve. ##### What about TLS/SSL then? I still have to encrypt! + TLS is nothing like compression. With TLS 1.3 you're still looking at around 80% performance retention over non-TLS. This because TLS is block based and efficiently maps to modern CPUs. Modern CPUs also have hardware offloads for this. It's not that demanding to encrypt traffic using modern encryption standards. Compression is by far the most CPU-demanding thing you can do with your connection, and it requires TONS of per-socket memory. diff --git a/packages/bun-vscode/assets/bun.lock.json b/packages/bun-vscode/assets/bun.lock.json index 37b6588e2b..770df4c090 100644 --- a/packages/bun-vscode/assets/bun.lock.json +++ b/packages/bun-vscode/assets/bun.lock.json @@ -3,4 +3,4 @@ "title": "JSON schema for bun.lock files.", "allowTrailingCommas": true, "type": "object" -} \ No newline at end of file +} diff --git a/packages/bun-vscode/assets/vscode.css b/packages/bun-vscode/assets/vscode.css index 32bdcc5b27..028eaa0cc6 100644 --- a/packages/bun-vscode/assets/vscode.css +++ b/packages/bun-vscode/assets/vscode.css @@ -1,69 +1,129 @@ -.mtk1 { color: #cccccc; } -.mtk2 { color: #1f1f1f; } -.mtk3 { color: #d4d4d4; } -.mtk4 { color: #000080; } -.mtk5 { color: #6a9955; } -.mtk6 { color: #569cd6; } -.mtk7 { color: #b5cea8; } -.mtk8 { color: #646695; } -.mtk9 { color: #d7ba7d; } -.mtk10 { color: #9cdcfe; } -.mtk11 { color: #f44747; } -.mtk12 { color: #ce9178; } -.mtk13 { color: #6796e6; } -.mtk14 { color: #808080; } -.mtk15 { color: #d16969; } -.mtk16 { color: #dcdcaa; } -.mtk17 { color: #4ec9b0; } -.mtk18 { color: #c586c0; } -.mtk19 { color: #4fc1ff; } -.mtk20 { color: #c8c8c8; } -.mtk21 { color: #606060; } -.mtk22 { color: #ffffff; } -.mtk23 { color: #cd9731; } -.mtk24 { color: #b267e6; } -.mtki { font-style: italic; } -.mtkb { font-weight: bold; } -.mtku { text-decoration: underline; text-underline-position: under; } -.mtks { text-decoration: line-through; } -.mtks.mtku { text-decoration: underline line-through; text-underline-position: under; } +.mtk1 { + color: #cccccc; +} +.mtk2 { + color: #1f1f1f; +} +.mtk3 { + color: #d4d4d4; +} +.mtk4 { + color: #000080; +} +.mtk5 { + color: #6a9955; +} +.mtk6 { + color: #569cd6; +} +.mtk7 { + color: #b5cea8; +} +.mtk8 { + color: #646695; +} +.mtk9 { + color: #d7ba7d; +} +.mtk10 { + color: #9cdcfe; +} +.mtk11 { + color: #f44747; +} +.mtk12 { + color: #ce9178; +} +.mtk13 { + color: #6796e6; +} +.mtk14 { + color: #808080; +} +.mtk15 { + color: #d16969; +} +.mtk16 { + color: #dcdcaa; +} +.mtk17 { + color: #4ec9b0; +} +.mtk18 { + color: #c586c0; +} +.mtk19 { + color: #4fc1ff; +} +.mtk20 { + color: #c8c8c8; +} +.mtk21 { + color: #606060; +} +.mtk22 { + color: #ffffff; +} +.mtk23 { + color: #cd9731; +} +.mtk24 { + color: #b267e6; +} +.mtki { + font-style: italic; +} +.mtkb { + font-weight: bold; +} +.mtku { + text-decoration: underline; + text-underline-position: under; +} +.mtks { + text-decoration: line-through; +} +.mtks.mtku { + text-decoration: underline line-through; + text-underline-position: under; +} .bunlock { - display: flex; - flex-direction: row; + display: flex; + flex-direction: row; } .lines { - display: flex; - flex-direction: column; - width: 30px; - margin-right: 15px; - text-align: right; - opacity: 0.5; + display: flex; + flex-direction: column; + width: 30px; + margin-right: 15px; + text-align: right; + opacity: 0.5; - font-size: var(--vscode-editor-font-size); - font-weight: var(--vscode-editor-font-weight); - font-family: var(--vscode-editor-font-family); - background-color: var(--vscode-editor-background); + font-size: var(--vscode-editor-font-size); + font-weight: var(--vscode-editor-font-weight); + font-family: var(--vscode-editor-font-family); + background-color: var(--vscode-editor-background); } .lines > span { - margin-top: 1px; - margin-bottom: 1px; + margin-top: 1px; + margin-bottom: 1px; } code { - white-space: pre; + white-space: pre; - font-size: var(--vscode-editor-font-size); - font-weight: var(--vscode-editor-font-weight); - font-family: var(--vscode-editor-font-family); - background-color: var(--vscode-editor-background); + font-size: var(--vscode-editor-font-size); + font-weight: var(--vscode-editor-font-weight); + font-family: var(--vscode-editor-font-family); + background-color: var(--vscode-editor-background); } code > span { - display: inline-block; - width: 100%; - margin-top: 1px; - margin-bottom: 1px; + display: inline-block; + width: 100%; + margin-top: 1px; + margin-bottom: 1px; } diff --git a/packages/bun-vscode/example/bake-test/pages/index.tsx b/packages/bun-vscode/example/bake-test/pages/index.tsx index 2923ba7473..6c13856db7 100644 --- a/packages/bun-vscode/example/bake-test/pages/index.tsx +++ b/packages/bun-vscode/example/bake-test/pages/index.tsx @@ -1,17 +1,16 @@ "use client"; - import { useState } from "react"; function App() { - const [count, setCount] = useState(null); + const [count, setCount] = useState(null); - return ( - <> + return ( + <> {/* @ts-expect-error */} - - - ); + + + ); } -export default App; \ No newline at end of file +export default App; diff --git a/packages/bun-vscode/example/example.test.ts b/packages/bun-vscode/example/example.test.ts index 14eee8099c..c98480cdfa 100644 --- a/packages/bun-vscode/example/example.test.ts +++ b/packages/bun-vscode/example/example.test.ts @@ -32,5 +32,5 @@ describe("example", () => { test("can run with special chars :)", () => { // if this test runs, it's a success. // a failure is if it's either skipped or fails the runner - }) + }); }); diff --git a/packages/bun-vscode/package.json b/packages/bun-vscode/package.json index fdeb913a54..e18d4c4c83 100644 --- a/packages/bun-vscode/package.json +++ b/packages/bun-vscode/package.json @@ -379,4 +379,4 @@ "../bun-debug-adapter-protocol", "../bun-inspector-protocol" ] -} \ No newline at end of file +} diff --git a/packages/bun-vscode/src/features/debug.ts b/packages/bun-vscode/src/features/debug.ts index 242aed26e1..94ff64280b 100644 --- a/packages/bun-vscode/src/features/debug.ts +++ b/packages/bun-vscode/src/features/debug.ts @@ -67,7 +67,7 @@ export function registerDebugger(context: vscode.ExtensionContext, factory?: vsc ); if (getConfig("debugTerminal.enabled")) { - injectDebugTerminal2().then(context.subscriptions.push) + injectDebugTerminal2().then(context.subscriptions.push); } } @@ -136,15 +136,17 @@ async function injectDebugTerminal(terminal: vscode.Terminal): Promise { } async function injectDebugTerminal2() { - const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly') || vscode.extensions.getExtension('ms-vscode.js-debug'); + const jsDebugExt = + vscode.extensions.getExtension("ms-vscode.js-debug-nightly") || + vscode.extensions.getExtension("ms-vscode.js-debug"); if (!jsDebugExt) { - return vscode.window.onDidOpenTerminal(injectDebugTerminal) + return vscode.window.onDidOpenTerminal(injectDebugTerminal); } - await jsDebugExt.activate() - const jsDebug: import('@vscode/js-debug').IExports = jsDebugExt.exports; + await jsDebugExt.activate(); + const jsDebug: import("@vscode/js-debug").IExports = jsDebugExt.exports; if (!jsDebug) { - return vscode.window.onDidOpenTerminal(injectDebugTerminal) + return vscode.window.onDidOpenTerminal(injectDebugTerminal); } return jsDebug.registerDebugTerminalOptionsProvider({ @@ -331,7 +333,7 @@ class FileDebugSession extends DebugSession { } this.adapter.on("Adapter.reverseRequest", ({ command, arguments: args }) => - this.sendRequest(command, args, 5000, () => { }), + this.sendRequest(command, args, 5000, () => {}), ); adapters.set(url, this); diff --git a/packages/bun-vscode/src/features/diagnostics/diagnostics.ts b/packages/bun-vscode/src/features/diagnostics/diagnostics.ts index 5427fffafe..04ab340c46 100644 --- a/packages/bun-vscode/src/features/diagnostics/diagnostics.ts +++ b/packages/bun-vscode/src/features/diagnostics/diagnostics.ts @@ -10,8 +10,8 @@ import { UnixSignal, } from "../../../../bun-debug-adapter-protocol"; import type { JSC } from "../../../../bun-inspector-protocol"; -import { typedGlobalState } from "../../global-state"; import { getConfig } from "../../extension"; +import { typedGlobalState } from "../../global-state"; const output = vscode.window.createOutputChannel("Bun - Diagnostics"); diff --git a/packages/bun-vscode/src/features/lockfile/index.ts b/packages/bun-vscode/src/features/lockfile/index.ts index 7765a171d7..70810ab817 100644 --- a/packages/bun-vscode/src/features/lockfile/index.ts +++ b/packages/bun-vscode/src/features/lockfile/index.ts @@ -1,7 +1,7 @@ import { spawn } from "node:child_process"; import * as vscode from "vscode"; -import { styleLockfile } from "./lockfile.style"; import { getConfig } from "../../extension"; +import { styleLockfile } from "./lockfile.style"; export type BunLockfile = vscode.CustomDocument & { readonly preview: string; @@ -38,8 +38,8 @@ export class BunLockfileEditorProvider implements vscode.CustomReadonlyEditorPro function renderLockfile({ webview }: vscode.WebviewPanel, preview: string, extensionUri: vscode.Uri): void { if (!getConfig("bunlockb.enabled")) { - webview.html = "bun.bunlockb config option is disabled." - return + webview.html = "bun.bunlockb config option is disabled."; + return; } const styleVSCodeUri = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, "assets", "vscode.css")); diff --git a/packages/bun-vscode/src/features/tasks/package.json.ts b/packages/bun-vscode/src/features/tasks/package.json.ts index a6b83c249f..0944382b91 100644 --- a/packages/bun-vscode/src/features/tasks/package.json.ts +++ b/packages/bun-vscode/src/features/tasks/package.json.ts @@ -4,7 +4,6 @@ import * as vscode from "vscode"; import { debugCommand } from "../debug"; import { BunTask } from "./tasks"; -import { getConfig } from "../../extension"; /** * Parses tasks defined in the package.json. diff --git a/packages/bun-vscode/src/features/tests/index.ts b/packages/bun-vscode/src/features/tests/index.ts index 2b747566ca..341f91e360 100644 --- a/packages/bun-vscode/src/features/tests/index.ts +++ b/packages/bun-vscode/src/features/tests/index.ts @@ -204,7 +204,6 @@ export function registerTestRunner(context: vscode.ExtensionContext) { context.subscriptions.push(watchTestCommand); } - /** * Escape any special characters in the input string, so that regex-matching on it * will work as expected. diff --git a/packages/bun-vscode/src/vscode-js-debug.d.ts b/packages/bun-vscode/src/vscode-js-debug.d.ts index 475a60f8f7..52d50f5592 100644 --- a/packages/bun-vscode/src/vscode-js-debug.d.ts +++ b/packages/bun-vscode/src/vscode-js-debug.d.ts @@ -2,38 +2,38 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -declare module '@vscode/js-debug' { - import type * as vscode from 'vscode'; - - /** @see {IExports.registerDebugTerminalOptionsProvider} */ - export interface IDebugTerminalOptionsProvider { - /** - * Called when the user creates a JavaScript Debug Terminal. It's called - * with the options js-debug wants to use to create the terminal. It should - * modify and return the options to use in the terminal. - * - * In order to avoid conflicting with existing logic, participants should - * try to modify options in a additive way. For example prefer appending - * to rather than reading and overwriting `options.env.PATH`. - */ - provideTerminalOptions(options: vscode.TerminalOptions): vscode.ProviderResult; - } +declare module "@vscode/js-debug" { + import type * as vscode from "vscode"; + /** @see {IExports.registerDebugTerminalOptionsProvider} */ + export interface IDebugTerminalOptionsProvider { /** - * Defines the exports of the `js-debug` extension. Once you have this typings - * file, these can be acquired in your extension using the following code: + * Called when the user creates a JavaScript Debug Terminal. It's called + * with the options js-debug wants to use to create the terminal. It should + * modify and return the options to use in the terminal. * - * ``` - * const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly') - * || vscode.extensions.getExtension('ms-vscode.js-debug'); - * await jsDebugExt.activate() - * const jsDebug: import('@vscode/js-debug').IExports = jsDebug.exports; - * ``` + * In order to avoid conflicting with existing logic, participants should + * try to modify options in a additive way. For example prefer appending + * to rather than reading and overwriting `options.env.PATH`. */ - export interface IExports { - /** - * Registers a participant used when the user creates a JavaScript Debug Terminal. - */ - registerDebugTerminalOptionsProvider(provider: IDebugTerminalOptionsProvider): vscode.Disposable; - } -} \ No newline at end of file + provideTerminalOptions(options: vscode.TerminalOptions): vscode.ProviderResult; + } + + /** + * Defines the exports of the `js-debug` extension. Once you have this typings + * file, these can be acquired in your extension using the following code: + * + * ``` + * const jsDebugExt = vscode.extensions.getExtension('ms-vscode.js-debug-nightly') + * || vscode.extensions.getExtension('ms-vscode.js-debug'); + * await jsDebugExt.activate() + * const jsDebug: import('@vscode/js-debug').IExports = jsDebug.exports; + * ``` + */ + export interface IExports { + /** + * Registers a participant used when the user creates a JavaScript Debug Terminal. + */ + registerDebugTerminalOptionsProvider(provider: IDebugTerminalOptionsProvider): vscode.Disposable; + } +} diff --git a/packages/bun-wasm/index.ts b/packages/bun-wasm/index.ts index f07be12c50..a2cb77a726 100644 --- a/packages/bun-wasm/index.ts +++ b/packages/bun-wasm/index.ts @@ -77,10 +77,8 @@ const Wasi = { }, proc_exit() {}, - fd_seek(fd: number, offset_bigint: bigint, whence: unknown, newOffset: unknown) { - }, - fd_write(fd: unknown, iov: unknown, iovcnt: unknown, pnum: unknown) { - }, + fd_seek(fd: number, offset_bigint: bigint, whence: unknown, newOffset: unknown) {}, + fd_write(fd: unknown, iov: unknown, iovcnt: unknown, pnum: unknown) {}, }; const env = { diff --git a/packages/bun-wasm/test/node.mjs b/packages/bun-wasm/test/node.mjs index 9c2f503d40..e0e8dafac0 100644 --- a/packages/bun-wasm/test/node.mjs +++ b/packages/bun-wasm/test/node.mjs @@ -1,5 +1,5 @@ import { readFileSync } from "fs"; -import { init, getTests } from "../index.mjs"; +import { getTests, init } from "../index.mjs"; const filePath = process.argv[2]; if (!filePath) throw new Error("Usage: node node.mjs "); diff --git a/packages/bun-wasm/tsconfig.json b/packages/bun-wasm/tsconfig.json index 9b5b9eb0c3..c77b88cc32 100644 --- a/packages/bun-wasm/tsconfig.json +++ b/packages/bun-wasm/tsconfig.json @@ -13,11 +13,6 @@ "baseUrl": ".", "types": ["node"] }, - "include": [ - "./node_modules/peechy", - "./schema.d.ts", - "./index.ts", - "./schema.js" - ], + "include": ["./node_modules/peechy", "./schema.d.ts", "./index.ts", "./schema.js"], "exclude": [] } diff --git a/scripts/agent.mjs b/scripts/agent.mjs index ece3359cc7..14bf2cdd23 100755 --- a/scripts/agent.mjs +++ b/scripts/agent.mjs @@ -2,27 +2,27 @@ // An agent that starts buildkite-agent and runs others services. -import { join } from "node:path"; import { realpathSync } from "node:fs"; +import { join } from "node:path"; +import { parseArgs } from "node:util"; import { - isWindows, - getOs, - getArch, - getKernel, getAbi, getAbiVersion, - getDistro, - getDistroVersion, - getHostname, + getArch, getCloud, getCloudMetadataTag, - which, + getDistro, + getDistroVersion, getEnv, - writeFile, - spawnSafe, + getHostname, + getKernel, + getOs, + isWindows, mkdir, + spawnSafe, + which, + writeFile, } from "./utils.mjs"; -import { parseArgs } from "node:util"; /** * @param {"install" | "start"} action diff --git a/scripts/build.mjs b/scripts/build.mjs index 0b195674f8..1ad5bc577a 100755 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -1,7 +1,7 @@ #!/usr/bin/env node import { spawn as nodeSpawn } from "node:child_process"; -import { existsSync, readFileSync, mkdirSync, cpSync, chmodSync } from "node:fs"; +import { chmodSync, cpSync, existsSync, mkdirSync, readFileSync } from "node:fs"; import { basename, join, relative, resolve } from "node:path"; import { formatAnnotationToHtml, diff --git a/scripts/features.mjs b/scripts/features.mjs index e3f3d455c1..1f4e762732 100755 --- a/scripts/features.mjs +++ b/scripts/features.mjs @@ -1,7 +1,7 @@ // @bun // Used to generate a features.json file after building Bun. -import { writeFileSync } from "node:fs"; import { crash_handler } from "bun:internal-for-testing"; +import { writeFileSync } from "node:fs"; writeFileSync("./features.json", JSON.stringify(crash_handler.getFeatureData())); diff --git a/scripts/glob-sources.mjs b/scripts/glob-sources.mjs index 25ba49f40e..fa20fd28ad 100644 --- a/scripts/glob-sources.mjs +++ b/scripts/glob-sources.mjs @@ -1,5 +1,5 @@ -import { write, Glob, file } from "bun"; -import { join, resolve, relative } from "path"; +import { Glob, file, write } from "bun"; +import { join, relative, resolve } from "path"; import { normalize } from "path/posix"; const root = resolve(import.meta.dirname, ".."); diff --git a/scripts/google.mjs b/scripts/google.mjs index f5fb1daf55..95c197b119 100644 --- a/scripts/google.mjs +++ b/scripts/google.mjs @@ -1,4 +1,4 @@ -import { $, spawnSafe, which, getUsernameForDistro } from "./utils.mjs"; +import { $, getUsernameForDistro, spawnSafe, which } from "./utils.mjs"; export const google = { get cloud() { diff --git a/scripts/machine.mjs b/scripts/machine.mjs index fe7dd0cbbb..7dc549082a 100755 --- a/scripts/machine.mjs +++ b/scripts/machine.mjs @@ -1,48 +1,47 @@ #!/usr/bin/env node +import { existsSync, mkdtempSync, readdirSync } from "node:fs"; +import { basename, extname, join, relative, resolve } from "node:path"; +import { fileURLToPath } from "node:url"; import { inspect, parseArgs } from "node:util"; +import { docker } from "./docker.mjs"; +import { google } from "./google.mjs"; +import { orbstack } from "./orbstack.mjs"; +import { tart } from "./tart.mjs"; import { $, + copyFile, + curlSafe, + escapePowershell, getBootstrapVersion, getBuildNumber, + getGithubApiUrl, + getGithubUrl, getSecret, + getUsernameForDistro, + homedir, isCI, + isMacOS, + isWindows, + mkdir, + mkdtemp, parseArch, parseOs, readFile, + rm, + setupUserData, + sha256, spawn, spawnSafe, + spawnSsh, + spawnSshSafe, spawnSyncSafe, startGroup, - spawnSshSafe, - spawnSsh, tmpdir, waitForPort, which, - escapePowershell, - getGithubUrl, - getGithubApiUrl, - curlSafe, - mkdtemp, writeFile, - copyFile, - isMacOS, - mkdir, - rm, - homedir, - isWindows, - setupUserData, - sha256, - isPrivileged, - getUsernameForDistro, } from "./utils.mjs"; -import { basename, extname, join, relative, resolve } from "node:path"; -import { existsSync, mkdtempSync, readdirSync } from "node:fs"; -import { fileURLToPath } from "node:url"; -import { orbstack } from "./orbstack.mjs"; -import { docker } from "./docker.mjs"; -import { google } from "./google.mjs"; -import { tart } from "./tart.mjs"; const aws = { get name() { diff --git a/scripts/nav2readme.ts b/scripts/nav2readme.ts index 4beeabb107..58c936b15b 100644 --- a/scripts/nav2readme.ts +++ b/scripts/nav2readme.ts @@ -5,9 +5,9 @@ // bun ./scripts/nav2readme.ts // // -import nav from "../docs/nav"; import { readdirSync } from "fs"; import path from "path"; +import nav from "../docs/nav"; function getQuickLinks() { let md = ""; diff --git a/scripts/orbstack.mjs b/scripts/orbstack.mjs index 905c3a40a5..4d5e11fd8d 100644 --- a/scripts/orbstack.mjs +++ b/scripts/orbstack.mjs @@ -1,6 +1,6 @@ import { inspect } from "node:util"; -import { $, mkdtemp, rm, spawnSafe, writeFile, getUsernameForDistro, spawnSshSafe, setupUserData } from "./utils.mjs"; import { getUserData } from "./machine.mjs"; +import { $, getUsernameForDistro, mkdtemp, rm, setupUserData, spawnSafe, spawnSshSafe, writeFile } from "./utils.mjs"; /** * @link https://docs.orbstack.dev/ diff --git a/scripts/runner.node.mjs b/scripts/runner.node.mjs index fe46dce49d..3cad56a7b0 100755 --- a/scripts/runner.node.mjs +++ b/scripts/runner.node.mjs @@ -14,21 +14,21 @@ import { appendFileSync, existsSync, constants as fs, + linkSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, statSync, + symlinkSync, unlink, unlinkSync, writeFileSync, - linkSync, - symlinkSync, } from "node:fs"; import { readFile } from "node:fs/promises"; import { userInfo } from "node:os"; -import { basename, dirname, join, relative, sep, extname } from "node:path"; +import { basename, dirname, extname, join, relative, sep } from "node:path"; import { parseArgs } from "node:util"; import { getAbi, diff --git a/scripts/utils.mjs b/scripts/utils.mjs index 4440da7bc6..7f3e518124 100755 --- a/scripts/utils.mjs +++ b/scripts/utils.mjs @@ -15,7 +15,7 @@ import { writeFileSync, } from "node:fs"; import { connect } from "node:net"; -import { hostname, tmpdir as nodeTmpdir, homedir as nodeHomedir, userInfo, release } from "node:os"; +import { hostname, homedir as nodeHomedir, tmpdir as nodeTmpdir, release, userInfo } from "node:os"; import { dirname, join, relative, resolve } from "node:path"; import { normalize as normalizeWindows } from "node:path/win32";