From 999eaa1f72340b433f048b8e3e8ae7073abb283f Mon Sep 17 00:00:00 2001 From: Joseph Izang Date: Mon, 13 Mar 2023 23:30:02 +0100 Subject: [PATCH] add docviewer plugin to show generated documentation --- apps/docviewer/project.json | 59 ++++++++++++++++ apps/docviewer/src/app/App.tsx | 11 +++ apps/docviewer/src/favicon.ico | Bin 0 -> 3150 bytes apps/docviewer/src/index.html | 14 ++++ apps/docviewer/src/main.tsx | 10 +++ apps/docviewer/tsconfig.app.json | 23 +++++++ apps/docviewer/tsconfig.json | 16 +++++ apps/docviewer/webpack.config.js | 85 ++++++++++++++++++++++++ apps/remixdocgen/src/app/AppContext.tsx | 20 ------ apps/remixdocgen/src/app/routes.tsx | 24 ------- 10 files changed, 218 insertions(+), 44 deletions(-) create mode 100644 apps/docviewer/project.json create mode 100644 apps/docviewer/src/app/App.tsx create mode 100644 apps/docviewer/src/favicon.ico create mode 100644 apps/docviewer/src/index.html create mode 100644 apps/docviewer/src/main.tsx create mode 100644 apps/docviewer/tsconfig.app.json create mode 100644 apps/docviewer/tsconfig.json create mode 100644 apps/docviewer/webpack.config.js delete mode 100644 apps/remixdocgen/src/app/AppContext.tsx delete mode 100644 apps/remixdocgen/src/app/routes.tsx diff --git a/apps/docviewer/project.json b/apps/docviewer/project.json new file mode 100644 index 0000000000..58fc9f5675 --- /dev/null +++ b/apps/docviewer/project.json @@ -0,0 +1,59 @@ +{ + "name": "docviewer", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "apps/docviewer/src", + "projectType": "application", + "implicitDependencies": [ + ], + "targets": { + "build": { + "executor": "@nrwl/webpack:webpack", + "outputs": ["{options.outputPath}"], + "defaultConfiguration": "development", + "options": { + "compiler": "babel", + "outputPath": "dist/apps/docviewer", + "index": "apps/docviewer/src/index.html", + "baseHref": "/", + "main": "apps/docviewer/src/main.tsx", + "tsConfig": "apps/docviewer/tsconfig.app.json", + "assets": [ + "apps/docviewer/src/favicon.ico" + ], + "styles": [], + "scripts": [], + "webpackConfig": "apps/docviewer/webpack.config.js" + }, + "configurations": { + "development": { + }, + "production": { + "fileReplacements": [ + { + "replace": "apps/docviewer/src/environments/environment.ts", + "with": "apps/docviewer/src/environments/environment.prod.ts" + } + ] + } + } + }, + "serve": { + "executor": "@nrwl/webpack:dev-server", + "defaultConfiguration": "development", + "options": { + "buildTarget": "docviewer:build", + "hmr": true + }, + "configurations": { + "development": { + "buildTarget": "docviewer:build:development", + "port": 7003 + }, + "production": { + "buildTarget": "docviewer:build:production" + } + } + } + }, + "tags": [] +} diff --git a/apps/docviewer/src/app/App.tsx b/apps/docviewer/src/app/App.tsx new file mode 100644 index 0000000000..c99255bc0f --- /dev/null +++ b/apps/docviewer/src/app/App.tsx @@ -0,0 +1,11 @@ + +export default function App() { + return ( + <> +

Documentation Viewer

+

+ Show documentation of compiled contracts. +

+ + ) +} \ No newline at end of file diff --git a/apps/docviewer/src/favicon.ico b/apps/docviewer/src/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..bcd5dfd67cd0361b78123e95c2dd96031f27f743 GIT binary patch literal 3150 zcmaKtc{Ei0AIGn;MZ^<@lHD*OV;K7~W1q3jSjJcqNywTkMOhP*k~Oj?GO|6{m(*C2 zC7JA+hN%%Bp7T4;J@?%2_x=5zbI<2~->=X60stMr0B~{wzpi9D0MG|# zyuANt7z6;uz%?PEfAnimLl^)6h5ARwGXemG2>?hqQv-I^Gpyh$JH}Ag92}3{$a#z& zd`il2Sb#$U&e&4#^4R|GTgk!Qs+x*PCL{2+`uB5mqtnqLaaw`*H2oqJ?XF(zUACc2 zSibBrdQzcidqv*TK}rpEv1ie&;Famq2IK5%4c}1Jt2b1x_{y1C!?EU)@`_F)yN*NK z)(u03@%g%uDawwXGAMm%EnP9FgoucUedioDwL~{6RVO@A-Q$+pwVRR%WYR>{K3E&Q zzqzT!EEZ$_NHGYM6&PK#CGUV$pTWsiI5#~m>htoJ!vbc0=gm3H8sz8KzIiVN5xdCT z%;}`UH2Pc8))1VS-unh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@;nhA>PE%s99&;z{8>VFgf{u!(-B-x7Of6ueme+ScryL`h(^qKE)DtieWY>-7 zgB)VJESQS4*1LU(2&@pgLvSt{(((C?K_V(rQk``i&5}ZPG;G^FiPlZ$7|-vEmMWlU z5lQ%iK2nu=h2wd_7>gK@vX=*AG+u~rQP$NwPC`ZA?4nh{3tui1x@bT6-;Rk3yDQ>d z?3qRD#+PeV7#FAa>s`Xwxsx_oRFcN$StW2=CW`=qObsT?SD^#^jM1Yk}PSPxJ zG@-_mnNU_)vM|iLRSI>UMp|hatyS}17R{10IuL0TLlupt>9dRs_SPQbv7BLYyC#qv16E-y@XZ= z-!p7I%#r-BVi$nQq3&ssRc_IC%R6$tA&^s_l46880~Wst3@>(|EO<}T4~ci~#!=e; zD)B>o%1+$ksURD1p7I-<3ehlFyVkqrySf&gg>Bp0Z9?JaG|gyTZ{Cb8SdvAWVmFX7v2ohs!OCc!Udk zUITUpmZ33rKLI#(&lDj}cKA#dpL4Fil=$5pu_wi1XJR!llw` zSItPBDEdMHk2>c7#%lBxZHHvtVUOZ$}v?=?AT~9!Jcqa@IJGuMg(s^7r>pcTrd)pS`{5Cu8WPey` z9)!!OUUY@L%9Q+bZa*S5`3f_|lFCPN6kdp_M2>{le8;cn^XUsPa+TUk47qd6)IBR% zk*&Ip?!Ge_gmmdj)BX}P_5o@VI2*wbZ^>UhFju}0gQZh!pP%4XT9{@w;G#b3XK8sN zF(7i$Jv(IM$8Akys9dhP^^~H2(7BfJp}yDW1#@!CL-!mGcSCnJ599WK9MV@yo_u$v MDeX2GIKR{Qf5okjU;qFB literal 0 HcmV?d00001 diff --git a/apps/docviewer/src/index.html b/apps/docviewer/src/index.html new file mode 100644 index 0000000000..7fd033d57e --- /dev/null +++ b/apps/docviewer/src/index.html @@ -0,0 +1,14 @@ + + + + + Doc Viewer + + + + + + +
+ + diff --git a/apps/docviewer/src/main.tsx b/apps/docviewer/src/main.tsx new file mode 100644 index 0000000000..7b8dd49ee6 --- /dev/null +++ b/apps/docviewer/src/main.tsx @@ -0,0 +1,10 @@ +import React from 'react' +import ReactDOM from 'react-dom' +import App from './app/App' + +ReactDOM.render( + + + , + document.getElementById("root") +); diff --git a/apps/docviewer/tsconfig.app.json b/apps/docviewer/tsconfig.app.json new file mode 100644 index 0000000000..af84f21cfc --- /dev/null +++ b/apps/docviewer/tsconfig.app.json @@ -0,0 +1,23 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["node"] + }, + "files": [ + "../../node_modules/@nrwl/react/typings/cssmodule.d.ts", + "../../node_modules/@nrwl/react/typings/image.d.ts" + ], + "exclude": [ + "jest.config.ts", + "**/*.spec.ts", + "**/*.test.ts", + "**/*.spec.tsx", + "**/*.test.tsx", + "**/*.spec.js", + "**/*.test.js", + "**/*.spec.jsx", + "**/*.test.jsx" + ], + "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"] +} diff --git a/apps/docviewer/tsconfig.json b/apps/docviewer/tsconfig.json new file mode 100644 index 0000000000..5aab5e7911 --- /dev/null +++ b/apps/docviewer/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "jsx": "react-jsx", + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.app.json" + } + ] +} diff --git a/apps/docviewer/webpack.config.js b/apps/docviewer/webpack.config.js new file mode 100644 index 0000000000..3cd446f615 --- /dev/null +++ b/apps/docviewer/webpack.config.js @@ -0,0 +1,85 @@ +const { composePlugins, withNx } = require('@nrwl/webpack') +const { withReact } = require('@nrwl/react') +const webpack = require('webpack') +const TerserPlugin = require("terser-webpack-plugin") +const CssMinimizerPlugin = require("css-minimizer-webpack-plugin") + +// Nx plugins for webpack. +module.exports = composePlugins(withNx(), withReact(), (config) => { + // Update the webpack config as needed here. + // e.g. `config.plugins.push(new MyPlugin())` + + // add fallback for node modules + config.resolve.fallback = { + ...config.resolve.fallback, + "crypto": require.resolve("crypto-browserify"), + "stream": require.resolve("stream-browserify"), + "path": require.resolve("path-browserify"), + "http": require.resolve("stream-http"), + "https": require.resolve("https-browserify"), + "constants": require.resolve("constants-browserify"), + "os": false, //require.resolve("os-browserify/browser"), + "timers": false, // require.resolve("timers-browserify"), + "zlib": require.resolve("browserify-zlib"), + "fs": false, + "module": false, + "tls": false, + "net": false, + "readline": false, + "child_process": false, + "buffer": require.resolve("buffer/"), + "vm": require.resolve('vm-browserify'), + } + + // add externals + config.externals = { + ...config.externals, + solc: 'solc', + } + + // add public path + config.output.publicPath = '/' + + + + // add copy & provide plugin + config.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + url: ['url', 'URL'], + process: 'process/browser', + }), + new webpack.DefinePlugin({ + + }), + ) + + // souce-map loader + config.module.rules.push({ + test: /\.js$/, + use: ["source-map-loader"], + enforce: "pre" + }) + + config.ignoreWarnings = [/Failed to parse source map/] // ignore source-map-loader warnings + + + // set minimizer + config.optimization.minimizer = [ + new TerserPlugin({ + parallel: true, + terserOptions: { + ecma: 2015, + compress: false, + mangle: false, + format: { + comments: false, + }, + }, + extractComments: false, + }), + new CssMinimizerPlugin(), + ]; + + return config; +}); diff --git a/apps/remixdocgen/src/app/AppContext.tsx b/apps/remixdocgen/src/app/AppContext.tsx deleted file mode 100644 index 612ac7af9a..0000000000 --- a/apps/remixdocgen/src/app/AppContext.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; -import { PluginClient } from "@remixproject/plugin"; -import { PluginApi, Api } from "@remixproject/plugin-utils"; -import { IRemixApi } from "@remixproject/plugin-api"; - -import { ContractName, Documentation, PublishedSite } from "../types"; - -export const AppContext = React.createContext({ - clientInstance: {} as PluginApi> & - PluginClient>, - contracts: new Map(), - setContracts: (contracts: Map) => { - console.log("Calling Set Contract Names"); - }, - sites: [], - setSites: (sites: PublishedSite[]) => { - console.log("Calling Set Sites"); - }, - themeType: "dark", -}); diff --git a/apps/remixdocgen/src/app/routes.tsx b/apps/remixdocgen/src/app/routes.tsx deleted file mode 100644 index b16eae3a9e..0000000000 --- a/apps/remixdocgen/src/app/routes.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React from "react"; -import { - BrowserRouter as Router, - Route, - RouteProps, -} from "react-router-dom"; - - - -interface Props extends RouteProps { - component: any; // TODO: new (props: any) => React.Component - from: string; -} - -const CustomRoute = ({ component: Component, ...rest }: Props) => { - return ( - <> - ); -}; - -export const Routes = () => ( - - -);