flashts 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ZMDev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ <div align="center">
2
+ <img src="./client/public/favicon.svg" alt="FlashTS" />
3
+ <h1>FlashTS</h1>
4
+ </div>
5
+
6
+ FlashTS is an ultra-fast, modern **JavaScript & TypeScript Playground** powered by [Bun](https://bun.sh/). It provides a professional IDE-like experience in the browser with instant execution, multi-file support, and automatic IntelliSense.
7
+
8
+ ## Features
9
+
10
+ - **Instant Execution**: Powered by Bun's high-performance runtime.
11
+ - **Multi-file Workspace**: Create complex projects with imports and modules.
12
+ - **Smart IntelliSense**: Automatic type injection for NPM packages via Monaco Editor.
13
+ - **Live NPM Manager**: Install and manage dependencies in real-time.
14
+ - **Safe Environment**: Session-based execution for isolated code running.
15
+
16
+ ## Tech Stack
17
+
18
+ ### Frontend (`/client`)
19
+
20
+ - **React 19 + Vite**: Modern, high-performance UI framework.
21
+ - **Monaco Editor**: The powerful editor behind VS Code, customized for FlashTS.
22
+ - **Tailwind CSS**: For a sleek, responsive, and maintainable design.
23
+ - **Lucide Icons**: Beautiful, consistent iconography.
24
+ - **React Resizable Panels**: Professional workspace layouts.
25
+
26
+ ### Backend (`/server`)
27
+
28
+ - **Bun**: The fast all-in-one JavaScript runtime (Bundler, Runner, Package Manager).
29
+ - **Hono**: Ultrafast web framework for the API layer.
30
+ - **TypeScript VFS**: In-memory type resolution for project files.
31
+
32
+ ## Getting Started
33
+
34
+ ### Prerequisites
35
+
36
+ - [Bun](https://bun.sh/) installed on your system.
37
+
38
+ ### Installation
39
+
40
+ 1. **Setup Server**:
41
+
42
+ ```bash
43
+ cd server
44
+ bun install
45
+ bun run index.ts
46
+ ```
47
+
48
+ 2. **Setup Client**:
49
+
50
+ ```bash
51
+ cd client
52
+ bun install
53
+ bun run dev
54
+ ```
55
+
56
+ 3. **Open FlashTS**:
57
+ Navigate to `http://localhost:5173` in your browser.
58
+
59
+ ## Technical Architecture
60
+
61
+ ### Execution Engine
62
+
63
+ When you click **Run**, the frontend bundles all your project files and sends them to the server. The server:
64
+
65
+ 1. Creates a unique, isolated session directory in `/tmp`.
66
+ 2. Writes all your files to disk.
67
+ 3. Spawns a Bun process to execute the active entry point.
68
+ 4. Streams the output (stdout/stderr) back to the client console.
69
+
70
+ ### Type Injection
71
+
72
+ FlashTS automatically fetches type definitions for any NPM package you install. The server parses the package's type tree and serves the `.d.ts` files to the frontend, which Monaco injects into its virtual filesystem. This ensures you always have perfect autocomplete.
73
+
74
+ ### Multi-file VFS
75
+
76
+ The editor maintains a **Double-Sync** strategy:
77
+
78
+ - Every file is a **Monaco Model** for active editing.
79
+ - Every file is also registered as an **Ambient ExtraLib**, allowing the TypeScript engine to resolve relative imports (e.g., `./utils.ts`) instantly across tabs.
80
+
81
+ ## License
82
+
83
+ Distributed under the **MIT License**.
84
+
85
+ ---
86
+
87
+ Built by ZMDev because all online options are payed, not open source or does not support npm modules correctly.
package/bin/cli.ts ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bun
2
+ import { Command } from "commander";
3
+ import { join } from "path";
4
+ import pc from "picocolors";
5
+ import localtunnel from "localtunnel";
6
+ import open from "open";
7
+
8
+ const program = new Command();
9
+
10
+ program
11
+ .name("flashts")
12
+ .description("FlashTS: High-performance TypeScript Playground CLI")
13
+ .version("1.0.0")
14
+ .option("-p, --port <number>", "Port to run the server on", "3000")
15
+ .option("-s, --share", "Generate a shareable public link")
16
+ .option("--no-open", "Do not open the browser automatically")
17
+ .action(async (options: { port: string; share: any; open: any; }) => {
18
+ const port = parseInt(options.port);
19
+ const rootDir = process.cwd();
20
+
21
+ console.log(`\n⚡ ${pc.bold(pc.cyan("FlashTS"))} ${pc.dim("v1.0.0")}`);
22
+ console.log(`${pc.green("➜")} Local: ${pc.cyan(`http://localhost:${port}`)}`);
23
+
24
+ // Start the server process
25
+ const serverPath = join(rootDir, "server", "index.ts");
26
+ const serverProc = Bun.spawn(["bun", "run", serverPath], {
27
+ env: { ...process.env, PORT: port.toString() },
28
+ stdout: "inherit",
29
+ stderr: "inherit",
30
+ });
31
+
32
+ if (options.share) {
33
+ try {
34
+ const tunnel = await localtunnel({ port });
35
+ const publicIp = await (await fetch("https://api.ipify.org")).text();
36
+
37
+ console.log(`${pc.green("➜")} Public: ${pc.magenta(tunnel.url)}`);
38
+ console.log(`${pc.yellow("➜")} Tunnel Password (IP): ${pc.bold(pc.white(publicIp))}`);
39
+ console.log(`${pc.dim(" (Use this IP if prompted by the tunnel landing page)")}\n`);
40
+
41
+ tunnel.on("close", () => {
42
+ console.log(pc.yellow("\nTunnel closed."));
43
+ });
44
+ } catch (err) {
45
+ console.error(pc.red("Failed to create shareable link:"), err);
46
+ }
47
+ }
48
+
49
+ if (options.open) {
50
+ setTimeout(() => {
51
+ open(`http://localhost:${port}`);
52
+ }, 1000);
53
+ }
54
+
55
+ // Keep process alive
56
+ process.on("SIGINT", () => {
57
+ console.log(pc.yellow("\nStopping FlashTS..."));
58
+ serverProc.kill();
59
+ process.exit(0);
60
+ });
61
+ });
62
+
63
+ program.parse();
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```