diff --git a/.vscode/settings.json b/.vscode/settings.json index f81fdd1..daae9f3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,9 @@ { "deno.codeLens.implementations": true, "deno.codeLens.references": true, - "deno.enablePaths": ["apps/deno-bypass", "apps/deno-vless"] + "deno.enablePaths": [ + "apps/deno-bypass", + "apps/deno-vless/src/deno", + "apps/deno-vless/src/main.ts" + ] } diff --git a/apps/deno-vless/.eslintrc.json b/apps/deno-vless/.eslintrc.json index 9d9c0db..734ddac 100644 --- a/apps/deno-vless/.eslintrc.json +++ b/apps/deno-vless/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": ["../../.eslintrc.json"], + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], "ignorePatterns": ["!**/*"], "overrides": [ { diff --git a/apps/deno-vless/index.html b/apps/deno-vless/index.html new file mode 100644 index 0000000..3d0e77e --- /dev/null +++ b/apps/deno-vless/index.html @@ -0,0 +1,18 @@ + + + + + + Edge Tunnel VLESS Deno + + + + + + + +
+ + + + \ No newline at end of file diff --git a/apps/deno-vless/jest.config.ts b/apps/deno-vless/jest.config.ts deleted file mode 100644 index 82e0cdd..0000000 --- a/apps/deno-vless/jest.config.ts +++ /dev/null @@ -1,16 +0,0 @@ -/* eslint-disable */ -export default { - displayName: 'deno-vless', - preset: '../../jest.preset.js', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - }, - }, - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': 'ts-jest', - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../coverage/apps/deno-vless', -}; diff --git a/apps/deno-vless/postcss.config.js b/apps/deno-vless/postcss.config.js new file mode 100644 index 0000000..c72626d --- /dev/null +++ b/apps/deno-vless/postcss.config.js @@ -0,0 +1,15 @@ +const { join } = require('path'); + +// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build +// option from your application's configuration (i.e. project.json). +// +// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries + +module.exports = { + plugins: { + tailwindcss: { + config: join(__dirname, 'tailwind.config.js'), + }, + autoprefixer: {}, + }, +}; diff --git a/apps/deno-vless/project.json b/apps/deno-vless/project.json index 580e4a3..3e0b08d 100644 --- a/apps/deno-vless/project.json +++ b/apps/deno-vless/project.json @@ -4,16 +4,53 @@ "sourceRoot": "apps/deno-vless/src", "projectType": "application", "targets": { - "run": { - "executor": "nx:run-commands", + "build": { + "executor": "@nrwl/vite:build", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "production", "options": { - "command": "deno run --allow-net --allow-env --allow-write apps/deno-vless/src/main.ts " + "outputPath": "apps/deno-vless/src/client" + }, + "configurations": { + "development": {}, + "production": {} } }, "serve": { + "executor": "@nrwl/vite:dev-server", + "defaultConfiguration": "development", + "options": { + "buildTarget": "deno-vless:build" + }, + "configurations": { + "development": { + "buildTarget": "deno-vless:build:development", + "hmr": true + }, + "production": { + "buildTarget": "deno-vless:build:production", + "hmr": false + } + } + }, + "serve-deno": { "executor": "nx:run-commands", "options": { - "command": "deno run --allow-net --allow-write --allow-env --watch apps/deno-vless/src/main.ts " + "command": "deno run --allow-net --allow-read --allow-write --allow-env --watch apps/deno-vless/src/main.ts" + } + }, + "test": { + "executor": "@nrwl/vite:test", + "outputs": ["{projectRoot}/coverage"], + "options": { + "passWithNoTests": true + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["apps/deno-vless/**/*.{ts,tsx,js,jsx}"] } } }, diff --git a/apps/deno-vless/public/favicon.ico b/apps/deno-vless/public/favicon.ico new file mode 100644 index 0000000..317ebcb Binary files /dev/null and b/apps/deno-vless/public/favicon.ico differ diff --git a/apps/deno-vless/src/app/.gitkeep b/apps/deno-vless/src/app/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/apps/deno-vless/src/app/app.spec.tsx b/apps/deno-vless/src/app/app.spec.tsx new file mode 100644 index 0000000..5afc2a2 --- /dev/null +++ b/apps/deno-vless/src/app/app.spec.tsx @@ -0,0 +1,17 @@ +import { render } from '@testing-library/react'; + +import App from './app'; + +describe('App', () => { + it('should render successfully', () => { + const { baseElement } = render(); + + expect(baseElement).toBeTruthy(); + }); + + it('should have a greeting as the title', () => { + const { getByText } = render(); + + expect(getByText(/Welcome test-app/gi)).toBeTruthy(); + }); +}); diff --git a/apps/deno-vless/src/app/app.tsx b/apps/deno-vless/src/app/app.tsx new file mode 100644 index 0000000..885204d --- /dev/null +++ b/apps/deno-vless/src/app/app.tsx @@ -0,0 +1,175 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { ExclamationTriangleIcon } from '@heroicons/react/20/solid'; +import QRCode from 'qrcode'; +import { useEffect, useState } from 'react'; +import { validate as uuidValidate } from 'uuid'; +export function App() { + const [text, setText] = useState(''); + function handleShare(text: string) { + setText(text); + } + return ( +
+ +
+ + + +
+
+ ); +} + +function ClipboardCopy(text: string) {} +function QRcodeImg({ text }: { text: string }) { + const [codeImg, setcodeImg] = useState(''); + const [copy, setCopy] = useState(false); + useEffect(() => { + (async () => { + if (text) { + const dataURL = await QRCode.toDataURL(text); + setcodeImg(dataURL); + } + })(); + }, [text]); + + async function copyText() { + await navigator.clipboard.writeText(text); + setCopy(true); + setTimeout(() => { + setCopy(false); + }, 1500); + } + + return ( +
+ code +
+ {text} +
+ + + + +
+
+
+ ); +} +function Anything({ handleShare }: { handleShare: (text: string) => void }) { + const [text, setText] = useState(''); + return ( +
+ +
+