From fed5ce3ad79411360cfab721d33f1744ee1f4958 Mon Sep 17 00:00:00 2001 From: zizifn <1803942+zizifn@users.noreply.github.com> Date: Mon, 2 Jan 2023 03:16:57 +0800 Subject: [PATCH] add edge ui common project --- apps/cf-page/postcss.config.js | 15 ++ apps/cf-page/src/styles.css | 3 + apps/cf-page/tailwind.config.js | 17 ++ apps/deno-vless/src/app/app.spec.tsx | 17 -- .../{index.fcec86ee.js => index.65634f6c.js} | 2 +- apps/deno-vless/src/client/index.html | 2 +- apps/deno-vless/src/index.tsx | 5 +- apps/deno-vless/tailwind.config.js | 1 + babel.config.json | 3 + libs/edge-ui/.eslintrc.json | 18 ++ libs/edge-ui/README.md | 7 + libs/edge-ui/postcss.config.js | 15 ++ libs/edge-ui/project.json | 23 ++ libs/edge-ui/src/index.ts | 1 + .../src/app => libs/edge-ui/src/lib}/app.tsx | 6 +- libs/edge-ui/tailwind.config.js | 17 ++ libs/edge-ui/tsconfig.json | 20 ++ libs/edge-ui/tsconfig.lib.json | 22 ++ libs/edge-ui/tsconfig.spec.json | 19 ++ libs/edge-ui/vite.config.ts | 26 +++ nx.json | 2 +- package-lock.json | 203 +++++++++++++----- package.json | 3 + tsconfig.base.json | 1 + 24 files changed, 373 insertions(+), 75 deletions(-) create mode 100644 apps/cf-page/postcss.config.js create mode 100644 apps/cf-page/tailwind.config.js delete mode 100644 apps/deno-vless/src/app/app.spec.tsx rename apps/deno-vless/src/client/assets/{index.fcec86ee.js => index.65634f6c.js} (98%) create mode 100644 babel.config.json create mode 100644 libs/edge-ui/.eslintrc.json create mode 100644 libs/edge-ui/README.md create mode 100644 libs/edge-ui/postcss.config.js create mode 100644 libs/edge-ui/project.json create mode 100644 libs/edge-ui/src/index.ts rename {apps/deno-vless/src/app => libs/edge-ui/src/lib}/app.tsx (99%) create mode 100644 libs/edge-ui/tailwind.config.js create mode 100644 libs/edge-ui/tsconfig.json create mode 100644 libs/edge-ui/tsconfig.lib.json create mode 100644 libs/edge-ui/tsconfig.spec.json create mode 100644 libs/edge-ui/vite.config.ts diff --git a/apps/cf-page/postcss.config.js b/apps/cf-page/postcss.config.js new file mode 100644 index 0000000..c72626d --- /dev/null +++ b/apps/cf-page/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/cf-page/src/styles.css b/apps/cf-page/src/styles.css index 90d4ee0..f477788 100644 --- a/apps/cf-page/src/styles.css +++ b/apps/cf-page/src/styles.css @@ -1 +1,4 @@ +@tailwind components; +@tailwind base; +@tailwind utilities; /* You can add global styles to this file, and also import other style files */ diff --git a/apps/cf-page/tailwind.config.js b/apps/cf-page/tailwind.config.js new file mode 100644 index 0000000..d00839f --- /dev/null +++ b/apps/cf-page/tailwind.config.js @@ -0,0 +1,17 @@ +const { createGlobPatternsForDependencies } = require('@nrwl/react/tailwind'); +const { join } = require('path'); + +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + join( + __dirname, + '{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}' + ), + ...createGlobPatternsForDependencies(__dirname), + ], + theme: { + extend: {}, + }, + plugins: [], +}; diff --git a/apps/deno-vless/src/app/app.spec.tsx b/apps/deno-vless/src/app/app.spec.tsx deleted file mode 100644 index 5afc2a2..0000000 --- a/apps/deno-vless/src/app/app.spec.tsx +++ /dev/null @@ -1,17 +0,0 @@ -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/client/assets/index.fcec86ee.js b/apps/deno-vless/src/client/assets/index.65634f6c.js similarity index 98% rename from apps/deno-vless/src/client/assets/index.fcec86ee.js rename to apps/deno-vless/src/client/assets/index.65634f6c.js index c38a5a1..66dc822 100644 --- a/apps/deno-vless/src/client/assets/index.fcec86ee.js +++ b/apps/deno-vless/src/client/assets/index.65634f6c.js @@ -47,4 +47,4 @@ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var b0 The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+o+`. `);const i=dh(t,n,l),u=bl.getSymbolSize(t),s=new th(u);return uh(s,t),sh(s),ah(s,t),Do(s,n,0),t>=7&&ch(s,t),fh(s,i),isNaN(r)&&(r=Mi.getBestMask(s,Do.bind(null,s,n))),Mi.applyMask(r,s),Do(s,n,r),{modules:s,version:t,errorCorrectionLevel:n,maskPattern:r,segments:l}}Ef.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Io.M,l,o;return typeof n<"u"&&(r=Io.from(n.errorCorrectionLevel,Io.M),l=_l.from(n.version),o=Mi.from(n.maskPattern),n.toSJISFunc&&bl.setToSJISFunction(n.toSJISFunc)),hh(t,l,r,o)};var If={},Bu={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(o){return[o,o]}))),r.length===6&&r.push("F","F");const l=parseInt(r.join(""),16);return{r:l>>24&255,g:l>>16&255,b:l>>8&255,a:l&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const l=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,o=r.width&&r.width>=21?r.width:void 0,i=r.scale||4;return{width:o,scale:o?4:i,margin:l,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,l){return l.width&&l.width>=r+l.margin*2?l.width/(r+l.margin*2):l.scale},e.getImageWidth=function(r,l){const o=e.getScale(r,l);return Math.floor((r+l.margin*2)*o)},e.qrToImageData=function(r,l,o){const i=l.modules.size,u=l.modules.data,s=e.getScale(i,o),a=Math.floor((i+o.margin*2)*s),p=o.margin*s,g=[o.color.light,o.color.dark];for(let h=0;h=p&&y>=p&&h"u"&&(!i||!i.getContext)&&(s=i,i=void 0),i||(a=r()),s=t.getOptions(s);const p=t.getImageWidth(o.modules.size,s),g=a.getContext("2d"),h=g.createImageData(p,p);return t.qrToImageData(h.data,o,s),n(g,a,p),g.putImageData(h,0,0),a},e.renderToDataURL=function(o,i,u){let s=u;typeof s>"u"&&(!i||!i.getContext)&&(s=i,i=void 0),s||(s={});const a=e.render(o,i,s),p=s.type||"image/png",g=s.rendererOpts||{};return a.toDataURL(p,g.quality)}})(If);var Bf={};const mh=Bu;function Js(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function Ao(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function gh(e,t,n){let r="",l=0,o=!1,i=0;for(let u=0;u0&&s>0&&e[u-1]||(r+=o?Ao("M",s+n,.5+a+n):Ao("m",l,0),l=0,o=!1),s+1':"",a="',p='viewBox="0 0 '+u+" "+u+'"',h=''+s+a+` -`;return typeof r=="function"&&r(null,h),h};const vh=z0,Ii=Ef,Df=If,yh=Bf;function Du(e,t,n,r,l){const o=[].slice.call(arguments,1),i=o.length,u=typeof o[i-1]=="function";if(!u&&!vh())throw new Error("Callback required as last argument");if(u){if(i<2)throw new Error("Too few arguments provided");i===2?(l=n,n=t,t=r=void 0):i===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(n=t,t=r=void 0):i===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(s,a){try{const p=Ii.create(n,r);s(e(p,t,r))}catch(p){a(p)}})}try{const s=Ii.create(n,r);l(null,e(s,t,r))}catch(s){l(s)}}yr.create=Ii.create;yr.toCanvas=Du.bind(null,Df.render);yr.toDataURL=Du.bind(null,Df.renderToDataURL);yr.toString=Du.bind(null,function(e,t,n){return yh.render(e,n)});const wh=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Sh(e){return typeof e=="string"&&wh.test(e)}function Eh(){const[e,t]=T.exports.useState(""),[n,r]=T.exports.useState(!1);function l(o){t(o),r(!0)}return T.exports.useEffect(()=>{if(n){console.log("useEffect---setShow");const o=setTimeout(()=>{r(!1)},1500);return()=>{clearTimeout(o)}}},[n]),ce(zu,{children:[ce("div",{className:"flex flex-col items-center h-screen",children:[R(_h,{}),ce("div",{className:"flex flex-col h-full ite",children:[R(Ch,{text:e}),R(Nh,{handleShare:l}),R(xh,{handleShare:l})]})]}),R(kh,{show:n,setShow:r})]})}function kh({show:e,setShow:t}){return R(zu,{children:R("div",{"aria-live":"assertive",className:"fixed inset-0 flex items-end px-4 py-6 pointer-events-none sm:items-start sm:p-6",children:R("div",{className:"flex flex-col items-center w-full space-y-4 sm:items-end",children:R(N0,{show:e,as:T.exports.Fragment,enter:"transform ease-out duration-300 transition",enterFrom:"translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2",enterTo:"translate-y-0 opacity-100 sm:translate-x-0",leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:R("div",{className:"w-full max-w-sm overflow-hidden bg-white rounded-lg shadow-lg pointer-events-auto ring-1 ring-black ring-opacity-5",children:R("div",{className:"p-4",children:ce("div",{className:"flex items-start",children:[R("div",{className:"flex-shrink-0",children:R(Sf,{className:"w-6 h-6 text-red-700","aria-hidden":"true"})}),ce("div",{className:"ml-3 w-0 flex-1 pt-0.5",children:[R("p",{className:"text-sm font-medium text-gray-900",children:"\u5206\u4EAB\u6210\u529F\uFF01"}),R("p",{className:"mt-1 text-sm text-red-500",children:"\u8BF7\u4E0D\u8981\u968F\u610F\u6CC4\u9732\u5206\u4EAB\u94FE\u63A5\uFF01\uFF01"})]}),R("div",{className:"flex flex-shrink-0 ml-4",children:ce("button",{type:"button",className:"inline-flex text-gray-400 bg-white rounded-md hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>{t(!1)},children:[R("span",{className:"sr-only",children:"Close"}),R(R0,{className:"w-5 h-5","aria-hidden":"true"})]})})]})})})})})})})}function Ch({text:e}){const[t,n]=T.exports.useState(""),[r,l]=T.exports.useState(!1);T.exports.useEffect(()=>{(async()=>{if(e){const i=await yr.toDataURL(e);n(i)}})()},[e]);async function o(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>{l(!1)},1500)}return ce("div",{className:"flex flex-col border border-blue-300 overflow-hidden w-[420px] h-[420px] justify-start items-center",children:[R("img",{src:t,width:"350",height:"350",alt:"\u4E8C\u7EF4\u7801",className:"border-spacing-1"}),ce("div",{className:"flex flex-grow w-full bg-gray-200",children:[R("span",{className:"flex-grow",children:e}),ce("div",{className:"w-6 h-6 ml-auto",children:[R("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",onClick:o,className:`w-6 h-6 hover:cursor-pointer hover:border hover:border-indigo-500 ${r?"hidden":"block"}`,children:R("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5A3.375 3.375 0 006.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0015 2.25h-1.5a2.251 2.251 0 00-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 00-9-9z"})}),R("svg",{"aria-hidden":"true",height:"16",viewBox:"0 0 16 16",version:"1.1",className:`w-6 h-6 hover:border hover:border-indigo-500 ${r?"block bg-green-300":"hidden"}`,children:R("path",{fillRule:"evenodd",d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]})]})]})}function xh({handleShare:e}){const[t,n]=T.exports.useState("");return ce("div",{className:"mt-4",children:[R("label",{htmlFor:"comment",className:"block text-sm font-medium text-gray-700",children:"\u968F\u610F\u8981\u5206\u4EAB\u7684\u5185\u5BB9"}),R("div",{className:"mt-1",children:R("textarea",{rows:4,name:"comment",id:"comment",className:"block w-full border border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm",value:t,onChange:r=>n(r.target.value)})}),R("div",{className:"flex justify-end mt-2",children:R("button",{onClick:()=>e(t),type:"submit",className:"inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-transparent rounded-md shadow-sm hover:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:"\u5206\u4EAB"})})]})}function Nh({handleShare:e}){function t(){return window.location.href}function n(){const r=new URL(window.location.href);return`vless://${r.pathname.split("/").find(Sh)}@${r.hostname}:443?encryption=none&security=tls&type=ws#deno-vless`}return ce("span",{className:"inline-flex self-center mt-4 rounded-md shadow-sm isolate",children:[R("button",{onClick:()=>e(t()),type:"button",className:"relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:border-indigo-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",children:"\u5206\u4EAB\u672C\u9875"}),R("button",{onClick:()=>e(n()),type:"button",className:"relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",children:"\u5206\u4EAB V2ray"})]})}function _h(){return R("div",{className:"flex justify-center w-full p-4 rounded-md bg-red-50",children:ce("div",{className:"flex",children:[R("div",{className:"flex-shrink-0",children:R(Sf,{className:"w-5 h-5 text-red-700","aria-hidden":"true"})}),ce("div",{className:"ml-3",children:[R("h3",{className:"text-sm font-medium text-red-700",children:"\u6CE8\u610F\uFF01\uFF01"}),R("div",{className:"mt-2 text-sm text-red-700",children:R("p",{children:"\u6CC4\u9732\u672C\u9875\u9762\u5C31\u7B49\u4E8E\u6CC4\u9732\u4F60\u7684\u8BBE\u7F6E\u3002"})})]})]})})}const Ph=uf(document.getElementById("root"));Ph.render(R(T.exports.StrictMode,{children:R(Eh,{})})); +`;return typeof r=="function"&&r(null,h),h};const vh=z0,Ii=Ef,Df=If,yh=Bf;function Du(e,t,n,r,l){const o=[].slice.call(arguments,1),i=o.length,u=typeof o[i-1]=="function";if(!u&&!vh())throw new Error("Callback required as last argument");if(u){if(i<2)throw new Error("Too few arguments provided");i===2?(l=n,n=t,t=r=void 0):i===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(i<1)throw new Error("Too few arguments provided");return i===1?(n=t,t=r=void 0):i===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(s,a){try{const p=Ii.create(n,r);s(e(p,t,r))}catch(p){a(p)}})}try{const s=Ii.create(n,r);l(null,e(s,t,r))}catch(s){l(s)}}yr.create=Ii.create;yr.toCanvas=Du.bind(null,Df.render);yr.toDataURL=Du.bind(null,Df.renderToDataURL);yr.toString=Du.bind(null,function(e,t,n){return yh.render(e,n)});const wh=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Sh(e){return typeof e=="string"&&wh.test(e)}function Eh(){const[e,t]=T.exports.useState(""),[n,r]=T.exports.useState(!1);function l(o){t(o),r(!0)}return T.exports.useEffect(()=>{if(n){console.log("useEffect---setShow");const o=setTimeout(()=>{r(!1)},1500);return()=>{clearTimeout(o)}}},[n]),ce(zu,{children:[ce("div",{className:"flex flex-col items-center h-screen",children:[R(_h,{}),ce("div",{className:"flex flex-col h-full ite",children:[R(Ch,{text:e}),R(Nh,{handleShare:l}),R(xh,{handleShare:l})]})]}),R(kh,{show:n,setShow:r})]})}function kh({show:e,setShow:t}){return R(zu,{children:R("div",{"aria-live":"assertive",className:"fixed inset-0 flex items-end px-4 py-6 pointer-events-none sm:items-start sm:p-6",children:R("div",{className:"flex flex-col items-center w-full space-y-4 sm:items-end",children:R(N0,{show:e,as:T.exports.Fragment,enter:"transform ease-out duration-300 transition",enterFrom:"translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2",enterTo:"translate-y-0 opacity-100 sm:translate-x-0",leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:R("div",{className:"w-full max-w-sm overflow-hidden bg-white rounded-lg shadow-lg pointer-events-auto ring-1 ring-black ring-opacity-5",children:R("div",{className:"p-4",children:ce("div",{className:"flex items-start",children:[R("div",{className:"flex-shrink-0",children:R(Sf,{className:"w-6 h-6 text-red-700","aria-hidden":"true"})}),ce("div",{className:"ml-3 w-0 flex-1 pt-0.5",children:[R("p",{className:"text-sm font-medium text-gray-900",children:"\u5206\u4EAB\u6210\u529F\uFF01"}),R("p",{className:"mt-1 text-sm text-red-500",children:"\u8BF7\u4E0D\u8981\u968F\u610F\u6CC4\u9732\u5206\u4EAB\u94FE\u63A5\uFF01\uFF01"})]}),R("div",{className:"flex flex-shrink-0 ml-4",children:ce("button",{type:"button",className:"inline-flex text-gray-400 bg-white rounded-md hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",onClick:()=>{t(!1)},children:[R("span",{className:"sr-only",children:"Close"}),R(R0,{className:"w-5 h-5","aria-hidden":"true"})]})})]})})})})})})})}function Ch({text:e}){const[t,n]=T.exports.useState(""),[r,l]=T.exports.useState(!1);T.exports.useEffect(()=>{(async()=>{if(e){const i=await yr.toDataURL(e);n(i)}})()},[e]);async function o(){await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>{l(!1)},1500)}return ce("div",{className:"flex flex-col border border-blue-300 overflow-hidden w-[420px] h-[420px] justify-start items-center",children:[R("img",{src:t,width:"350",height:"350",alt:"\u4E8C\u7EF4\u7801",className:"border-spacing-1"}),ce("div",{className:"flex flex-grow w-full bg-gray-200",children:[R("span",{className:"flex-grow",children:e}),ce("div",{className:"w-6 h-6 ml-auto",children:[R("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",onClick:o,className:`w-6 h-6 hover:cursor-pointer hover:border hover:border-indigo-500 ${r?"hidden":"block"}`,children:R("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.25 7.5V6.108c0-1.135.845-2.098 1.976-2.192.373-.03.748-.057 1.123-.08M15.75 18H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08M15.75 18.75v-1.875a3.375 3.375 0 00-3.375-3.375h-1.5a1.125 1.125 0 01-1.125-1.125v-1.5A3.375 3.375 0 006.375 7.5H5.25m11.9-3.664A2.251 2.251 0 0015 2.25h-1.5a2.251 2.251 0 00-2.15 1.586m5.8 0c.065.21.1.433.1.664v.75h-6V4.5c0-.231.035-.454.1-.664M6.75 7.5H4.875c-.621 0-1.125.504-1.125 1.125v12c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V16.5a9 9 0 00-9-9z"})}),R("svg",{"aria-hidden":"true",height:"16",viewBox:"0 0 16 16",version:"1.1",className:`w-6 h-6 hover:border hover:border-indigo-500 ${r?"block bg-green-300":"hidden"}`,children:R("path",{fillRule:"evenodd",d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"})})]})]})]})}function xh({handleShare:e}){const[t,n]=T.exports.useState("");return ce("div",{className:"mt-4",children:[R("label",{htmlFor:"comment",className:"block text-sm font-medium text-gray-700",children:"\u968F\u610F\u8981\u5206\u4EAB\u7684\u5185\u5BB9."}),R("div",{className:"mt-1",children:R("textarea",{rows:4,name:"comment",id:"comment",className:"block w-full border border-gray-300 rounded-md shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm",value:t,onChange:r=>n(r.target.value)})}),R("div",{className:"flex justify-end mt-2",children:R("button",{onClick:()=>e(t),type:"submit",className:"inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-transparent rounded-md shadow-sm hover:border-indigo-500 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2",children:"\u5206\u4EAB"})})]})}function Nh({handleShare:e}){function t(){return window.location.href}function n(){const r=new URL(window.location.href);return`vless://${r.pathname.split("/").find(Sh)}@${r.hostname}:443?encryption=none&security=tls&type=ws#deno-vless`}return ce("span",{className:"inline-flex self-center mt-4 rounded-md shadow-sm isolate",children:[R("button",{onClick:()=>e(t()),type:"button",className:"relative inline-flex items-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-l-md hover:border-indigo-500 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",children:"\u5206\u4EAB\u672C\u9875"}),R("button",{onClick:()=>e(n()),type:"button",className:"relative inline-flex items-center px-4 py-2 -ml-px text-sm font-medium text-gray-700 bg-white border border-gray-300 hover:bg-gray-50 focus:z-10 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500",children:"\u5206\u4EAB V2ray"})]})}function _h(){return R("div",{className:"flex justify-center w-full p-4 rounded-md bg-red-50",children:ce("div",{className:"flex",children:[R("div",{className:"flex-shrink-0",children:R(Sf,{className:"w-5 h-5 text-red-700","aria-hidden":"true"})}),ce("div",{className:"ml-3",children:[R("h3",{className:"text-sm font-medium text-red-700",children:"\u6CE8\u610F\uFF01\uFF01"}),R("div",{className:"mt-2 text-sm text-red-700",children:R("p",{children:"\u6CC4\u9732\u672C\u9875\u9762\u5C31\u7B49\u4E8E\u6CC4\u9732\u4F60\u7684\u8BBE\u7F6E\u3002"})})]})]})})}const Ph=uf(document.getElementById("root"));Ph.render(R(T.exports.StrictMode,{children:R(Eh,{})})); diff --git a/apps/deno-vless/src/client/index.html b/apps/deno-vless/src/client/index.html index 41c1704..897820f 100644 --- a/apps/deno-vless/src/client/index.html +++ b/apps/deno-vless/src/client/index.html @@ -8,7 +8,7 @@ - + diff --git a/apps/deno-vless/src/index.tsx b/apps/deno-vless/src/index.tsx index ce704bc..89c46d7 100644 --- a/apps/deno-vless/src/index.tsx +++ b/apps/deno-vless/src/index.tsx @@ -1,6 +1,7 @@ import { StrictMode } from 'react'; import * as ReactDOM from 'react-dom/client'; -import App from './app/app'; +// import App from './app/app'; +import { EdgeApp } from 'edge-ui'; import './styles.css'; const root = ReactDOM.createRoot( @@ -8,6 +9,6 @@ const root = ReactDOM.createRoot( ); root.render( - + ); diff --git a/apps/deno-vless/tailwind.config.js b/apps/deno-vless/tailwind.config.js index d00839f..d0c1802 100644 --- a/apps/deno-vless/tailwind.config.js +++ b/apps/deno-vless/tailwind.config.js @@ -9,6 +9,7 @@ module.exports = { '{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}' ), ...createGlobPatternsForDependencies(__dirname), + 'libs/edge-ui/src/lib/*.tsx', ], theme: { extend: {}, diff --git a/babel.config.json b/babel.config.json new file mode 100644 index 0000000..065aee7 --- /dev/null +++ b/babel.config.json @@ -0,0 +1,3 @@ +{ + "babelrcRoots": ["*"] +} diff --git a/libs/edge-ui/.eslintrc.json b/libs/edge-ui/.eslintrc.json new file mode 100644 index 0000000..734ddac --- /dev/null +++ b/libs/edge-ui/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/edge-ui/README.md b/libs/edge-ui/README.md new file mode 100644 index 0000000..4994342 --- /dev/null +++ b/libs/edge-ui/README.md @@ -0,0 +1,7 @@ +# edge-ui + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test edge-ui` to execute the unit tests via [Vitest](https://vitest.dev/). diff --git a/libs/edge-ui/postcss.config.js b/libs/edge-ui/postcss.config.js new file mode 100644 index 0000000..c72626d --- /dev/null +++ b/libs/edge-ui/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/libs/edge-ui/project.json b/libs/edge-ui/project.json new file mode 100644 index 0000000..8e464aa --- /dev/null +++ b/libs/edge-ui/project.json @@ -0,0 +1,23 @@ +{ + "name": "edge-ui", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/edge-ui/src", + "projectType": "library", + "tags": [], + "targets": { + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/edge-ui/**/*.{ts,tsx,js,jsx}"] + } + }, + "test": { + "executor": "@nrwl/vite:test", + "outputs": ["{projectRoot}/coverage"], + "options": { + "passWithNoTests": true + } + } + } +} diff --git a/libs/edge-ui/src/index.ts b/libs/edge-ui/src/index.ts new file mode 100644 index 0000000..eb924fc --- /dev/null +++ b/libs/edge-ui/src/index.ts @@ -0,0 +1 @@ +export * from './lib/app'; diff --git a/apps/deno-vless/src/app/app.tsx b/libs/edge-ui/src/lib/app.tsx similarity index 99% rename from apps/deno-vless/src/app/app.tsx rename to libs/edge-ui/src/lib/app.tsx index fede66b..8ed42a4 100644 --- a/apps/deno-vless/src/app/app.tsx +++ b/libs/edge-ui/src/lib/app.tsx @@ -4,7 +4,7 @@ import { ExclamationTriangleIcon, XMarkIcon } from '@heroicons/react/20/solid'; import QRCode from 'qrcode'; import { Fragment, useEffect, useState } from 'react'; import { validate as uuidValidate } from 'uuid'; -export function App() { +export function EdgeApp() { const [text, setText] = useState(''); const [show, setShow] = useState(false); function handleShare(text: string) { @@ -183,7 +183,7 @@ function ShareAnything({ htmlFor="comment" className="block text-sm font-medium text-gray-700" > - 随意要分享的内容 + 随意要分享的内容.