browse 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CLAUDE.md ADDED
@@ -0,0 +1,111 @@
1
+ ---
2
+ description: Use Bun instead of Node.js, npm, pnpm, or vite.
3
+ globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ Default to using Bun instead of Node.js.
8
+
9
+ - Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10
+ - Use `bun test` instead of `jest` or `vitest`
11
+ - Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12
+ - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13
+ - Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14
+ - Bun automatically loads .env, so don't use dotenv.
15
+
16
+ ## APIs
17
+
18
+ - `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19
+ - `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20
+ - `Bun.redis` for Redis. Don't use `ioredis`.
21
+ - `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22
+ - `WebSocket` is built-in. Don't use `ws`.
23
+ - Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24
+ - Bun.$`ls` instead of execa.
25
+
26
+ ## Testing
27
+
28
+ Use `bun test` to run tests.
29
+
30
+ ```ts#index.test.ts
31
+ import { test, expect } from "bun:test";
32
+
33
+ test("hello world", () => {
34
+ expect(1).toBe(1);
35
+ });
36
+ ```
37
+
38
+ ## Frontend
39
+
40
+ Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41
+
42
+ Server:
43
+
44
+ ```ts#index.ts
45
+ import index from "./index.html"
46
+
47
+ Bun.serve({
48
+ routes: {
49
+ "/": index,
50
+ "/api/users/:id": {
51
+ GET: (req) => {
52
+ return new Response(JSON.stringify({ id: req.params.id }));
53
+ },
54
+ },
55
+ },
56
+ // optional websocket support
57
+ websocket: {
58
+ open: (ws) => {
59
+ ws.send("Hello, world!");
60
+ },
61
+ message: (ws, message) => {
62
+ ws.send(message);
63
+ },
64
+ close: (ws) => {
65
+ // handle close
66
+ }
67
+ },
68
+ development: {
69
+ hmr: true,
70
+ console: true,
71
+ }
72
+ })
73
+ ```
74
+
75
+ HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
76
+
77
+ ```html#index.html
78
+ <html>
79
+ <body>
80
+ <h1>Hello, world!</h1>
81
+ <script type="module" src="./frontend.tsx"></script>
82
+ </body>
83
+ </html>
84
+ ```
85
+
86
+ With the following `frontend.tsx`:
87
+
88
+ ```tsx#frontend.tsx
89
+ import React from "react";
90
+
91
+ // import .css files directly and it works
92
+ import './index.css';
93
+
94
+ import { createRoot } from "react-dom/client";
95
+
96
+ const root = createRoot(document.body);
97
+
98
+ export default function Frontend() {
99
+ return <h1>Hello, world!</h1>;
100
+ }
101
+
102
+ root.render(<Frontend />);
103
+ ```
104
+
105
+ Then, run index.ts
106
+
107
+ ```sh
108
+ bun --hot ./index.ts
109
+ ```
110
+
111
+ For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
package/README.md CHANGED
@@ -1,59 +1,15 @@
1
- [![view on npm](http://img.shields.io/npm/v/browse.svg)](https://www.npmjs.org/package/browse)
2
- [![npm module downloads](http://img.shields.io/npm/dt/browse.svg)](https://www.npmjs.org/package/browse)
3
- [![Dependency Status](https://david-dm.org/75lb/browse.svg)](https://david-dm.org/75lb/browse)
1
+ # browse-test
4
2
 
5
- browse
6
- ======
7
- Launch apps in full-screen mode from the Terminal. Currently Mac OS X only, patches welcome.
3
+ To install dependencies:
8
4
 
9
- Install
10
- -------
11
- Install [Node.js](http://nodejs.org), then run
12
-
13
- ```sh
14
- $ npm install -g browse
15
- ```
16
-
17
- Usage
18
- -----
19
- Six convenience commands are installed:
20
-
21
- ### Google Chrome Canary
22
- To launch Chrome Canary, run:
23
- ```sh
24
- $ ca <location>
25
- ```
26
-
27
- ### Google Chrome
28
- To launch Chrome, run:
29
- ```sh
30
- $ ch <location>
5
+ ```bash
6
+ bun install
31
7
  ```
32
8
 
33
- ### Firefox
34
- To launch Firefox, run:
35
- ```sh
36
- $ ff <location>
37
- ```
38
-
39
- ### Safari
40
- To launch Safari, run:
41
- ```sh
42
- $ sf <location>
43
- ```
9
+ To run:
44
10
 
45
- ### Launch anything in full-screen
46
- Run the command `ccf` (an applescript which sends the CMD+CTRL+f keystroke to the active application) following a regular `open` to switch it to full-screen mode:
47
- ```sh
48
- $ open -a Calendar && ccf
11
+ ```bash
12
+ bun run index.ts
49
13
  ```
50
14
 
51
- Should an app have an additional full-screen mode shortcutted by CMD+Shift+f (as Chrome does), use:
52
- ```sh
53
- $ open -a "Google Chrome" && csf
54
- ```
55
-
56
- **Tip**. If an app is slow to load, give it chance to load fully by inserting a pause before running the keyboard shortcut:
57
- ```sh
58
- $ ff http://www.rt.com && sleep 3 && csf
59
- ```
15
+ This project was created using `bun init` in bun v1.3.1. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/bun.lock ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "name": "browse-test",
6
+ "devDependencies": {
7
+ "@types/bun": "latest",
8
+ },
9
+ "peerDependencies": {
10
+ "typescript": "^5",
11
+ },
12
+ },
13
+ },
14
+ "packages": {
15
+ "@types/bun": ["@types/bun@1.3.9", "", { "dependencies": { "bun-types": "1.3.9" } }, "sha512-KQ571yULOdWJiMH+RIWIOZ7B2RXQGpL1YQrBtLIV3FqDcCu6FsbFUBwhdKUlCKUpS3PJDsHlJ1QKlpxoVR+xtw=="],
16
+
17
+ "@types/node": ["@types/node@25.2.3", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-m0jEgYlYz+mDJZ2+F4v8D1AyQb+QzsNqRuI7xg1VQX/KlKS0qT9r1Mo16yo5F/MtifXFgaofIFsdFMox2SxIbQ=="],
18
+
19
+ "bun-types": ["bun-types@1.3.9", "", { "dependencies": { "@types/node": "*" } }, "sha512-+UBWWOakIP4Tswh0Bt0QD0alpTY8cb5hvgiYeWCMet9YukHbzuruIEeXC2D7nMJPB12kbh8C7XJykSexEqGKJg=="],
20
+
21
+ "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
22
+
23
+ "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
24
+ }
25
+ }
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ console.log("Hello via Bun!");
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "browse",
3
- "version": "0.4.0",
4
- "description": "Terminal commands to launch your preferred browser (or any app) in full-screen mode",
5
- "repository": "https://github.com/75lb/browse",
6
- "author": "Lloyd Brookes",
7
- "bin": {
8
- "ca": "script/canary.sh",
9
- "ch": "script/chrome.sh",
10
- "ff": "script/firefox.sh",
11
- "ffd": "script/firefox-dev.sh",
12
- "sf": "script/safari.sh",
13
- "ccf": "script/cmd+ctrl+f.applescript",
14
- "csf": "script/cmd+shft+f.applescript"
3
+ "version": "0.5.0",
4
+ "module": "index.ts",
5
+ "type": "module",
6
+ "devDependencies": {
7
+ "@types/bun": "latest"
15
8
  },
16
- "license": "MIT"
9
+ "peerDependencies": {
10
+ "typescript": "^5"
11
+ }
17
12
  }
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext"],
5
+ "target": "ESNext",
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noImplicitOverride": true,
23
+
24
+ // Some stricter flags (disabled by default)
25
+ "noUnusedLocals": false,
26
+ "noUnusedParameters": false,
27
+ "noPropertyAccessFromIndexSignature": false
28
+ }
29
+ }
package/script/canary.sh DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- open -a "Google Chrome Canary" "$1"
package/script/chrome.sh DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- open -a "Google Chrome" "$1"
@@ -1,4 +0,0 @@
1
- #!/usr/bin/osascript
2
- tell application "System Events"
3
- keystroke "f" using {command down, control down}
4
- end tell
@@ -1,4 +0,0 @@
1
- #!/usr/bin/osascript
2
- tell application "System Events"
3
- keystroke "f" using {command down, shift down}
4
- end tell
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- open -a "FirefoxDeveloperEdition" "$1"
package/script/firefox.sh DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- open -a "Firefox" "$1"
@@ -1,2 +0,0 @@
1
- #!/usr/bin/osascript
2
- tell application "Safari" to activate
package/script/safari.sh DELETED
@@ -1,2 +0,0 @@
1
- #!/bin/bash
2
- open -a "Safari" "$1"