replace cra to next.js

This commit is contained in:
exromany 2021-07-07 12:56:46 +03:00
parent b372642d2e
commit bd3d80ec6a
21 changed files with 794 additions and 4685 deletions

View File

@ -5,7 +5,8 @@
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
"exports": {
".": "./dist/lib/"
".": "./dist/lib",
"./styles.css": "./dist/lib/styles.css"
},
"license": "Apache-2.0",
"publishConfig": {

View File

@ -1 +1,2 @@
target
.next

View File

@ -1,57 +0,0 @@
const CracoLessPlugin = require('craco-less');
const CracoAlias = require('craco-alias');
const CracoBabelLoader = require('craco-babel-loader');
const path = require('path');
const fs = require('fs');
//console.log('qualified', pnp.resolveRequest('@babel/preset-typescript'), path.resolve(__dirname, '/') + 'src/');
// Handle relative paths to sibling packages
const appDirectory = fs.realpathSync(process.cwd());
const resolvePackage = relativePath => path.resolve(appDirectory, relativePath);
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
paths.appBuild = webpackConfig.output.path = path.resolve(
'./../../build/web',
);
return webpackConfig;
},
},
plugins: [
/*{
plugin: CracoBabelLoader,
options: {
includes: [
// No "unexpected token" error importing components from these lerna siblings:
resolvePackage('../packages'),
],
},
},*/
/*{
plugin: CracoAlias,
options: {
source: 'tsconfig',
// baseUrl SHOULD be specified
// plugin does not take it from tsconfig
baseUrl: '../../',
// tsConfigPath should point to the file where "baseUrl" and "paths" are specified
tsConfigPath: '../../tsconfig.json',
},
},*/
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {
'@primary-color': '#768BF9',
'@text-color': 'rgba(255, 255, 255)'
},
javascriptEnabled: true,
},
},
},
},
],
};

3
js/packages/web/next-env.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

View File

@ -0,0 +1,21 @@
const withLess = require('next-with-less');
module.exports = withLess({
async rewrites() {
return [
{
source: '/:any*',
destination: '/',
},
];
},
lessLoaderOptions: {
lessOptions: {
modifyVars: {
'@primary-color': '#768BF9',
'@text-color': 'rgba(255, 255, 255)',
},
javascriptEnabled: true,
},
},
});

View File

@ -5,7 +5,6 @@
"@ant-design/icons": "^4.4.0",
"@babel/preset-typescript": "^7.12.13",
"@cloudflare/stream-react": "^1.1.0",
"@craco/craco": "^5.7.0",
"@oyster/common": "0.0.1",
"@project-serum/serum": "^0.13.34",
"@project-serum/sol-wallet-adapter": "^0.2.0",
@ -26,24 +25,26 @@
"buffer-layout": "^1.2.0",
"canvas-confetti": "^1.4.0",
"eventemitter3": "^4.0.7",
"less": "^4.1.1",
"less-loader": "^10.0.1",
"lodash": "^4.17.20",
"next": "^11.0.1",
"next-with-less": "^1.0.0",
"react": "16.13.1",
"react-content-loader": "^6.0.3",
"react-dom": "16.13.1",
"react-intersection-observer": "^8.32.0",
"react-masonry-css": "^1.0.16",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-virtualized": "^9.22.3",
"three": "^0.128.0",
"use-wallet": "^0.8.1"
},
"scripts": {
"prestart": "npm-link-shared ../common/node_modules/ . react",
"start": "craco start --verbose",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",
"start": "next dev",
"build": "next build",
"test": "jest",
"deploy:ar": "arweave deploy-dir ../../build/web --key-file ",
"deploy": "gh-pages -d ../../build/web --repo https://github.com/metaplex-foundation/metaplex",
"format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\""
@ -82,9 +83,6 @@
"@types/testing-library__react": "^10.2.0",
"@types/three": "^0.128.0",
"arweave-deploy": "^1.9.1",
"craco-alias": "^2.1.1",
"craco-babel-loader": "^0.1.4",
"craco-less": "^1.17.0",
"gh-pages": "^3.1.0",
"npm-link-shared": "0.5.6",
"prettier": "^2.1.2",

View File

@ -1,101 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="loadforge-site-verification" content="2056680d2883a8b910880d53b9cb2ebf16e7b8f91e169cceddce62c4c4ef8fe6240748c08c2e3769e554e12dafcd5bfc62028638e6524a0efd7d729efd762d42" />
<link rel="apple-touch-icon" sizes="57x57" href="%PUBLIC_URL%/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="%PUBLIC_URL%/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="%PUBLIC_URL%/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="%PUBLIC_URL%/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="%PUBLIC_URL%/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="%PUBLIC_URL%/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="%PUBLIC_URL%/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="%PUBLIC_URL%/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="%PUBLIC_URL%/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="%PUBLIC_URL%/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="%PUBLIC_URL%/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="%PUBLIC_URL%/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="%PUBLIC_URL%/favicon-16x16.png">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Metaplex NFT Marketplace" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Metaplex NFT Marketplace</title>
<style type="text/css">
html {
overflow-y: scroll;
width: 100vw;
overflow-x: hidden;
}
#root {
height: 100%;
font-family: 'Graphik Web', sans-serif;
}
#root::before {
content: "";
position: absolute;
top: 0;
left: 0;
min-width: 100%;
min-height: 100%;
filter: grayscale(100%);
background-repeat: no-repeat;
background-size: cover;
}
.App {
position: relative;
height: 100%;
text-align: center;
min-width: 100%;
display: flex;
flex-direction: column;
background-color: black;
color: white;
}
</style>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
crossorigin="anonymous" />
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<script>
(function () {
var s = document.createElement("script");
s.src = "https://stackpile.io/stack_162299.js"; s.async = true;
var e = document.getElementsByTagName("script")[0]; e.parentNode.insertBefore(s, e);
})();
</script>
</body>
</html>

View File

@ -1,4 +1,4 @@
@import "_colors";
@import '../../_colors.less';
.App-Bar {
padding: 0px;
@ -29,7 +29,7 @@
align-items: center;
text-align: center;
color: #FFFFFF;
color: #ffffff;
padding: 10px 14px 10px 6px;
margin-bottom: 0px;
@ -69,5 +69,3 @@
}
}
}

View File

@ -1,18 +0,0 @@
import './wdyr';
import './styles.less';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root'),
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();

View File

@ -0,0 +1,16 @@
import type { AppProps } from 'next/app';
import Head from 'next/head';
import '../styles.less';
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Metaplex NFT Marketplace</title>
</Head>
{typeof window === 'undefined' ? null : <Component {...pageProps} />}
</>
);
}

View File

@ -0,0 +1,76 @@
import Document, {
Html,
Head,
Main,
NextScript,
DocumentContext,
} from 'next/document';
export default class MetaplexDocument extends Document {
static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}
render() {
return (
<Html lang="en">
<Head>
<meta charSet="utf-8" />
<meta
name="loadforge-site-verification"
content="2056680d2883a8b910880d53b9cb2ebf16e7b8f91e169cceddce62c4c4ef8fe6240748c08c2e3769e554e12dafcd5bfc62028638e6524a0efd7d729efd762d42"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="96x96"
href="/favicon-96x96.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/favicon-16x16.png"
/>
<meta name="theme-color" content="#000000" />
<meta name="description" content="Metaplex NFT Marketplace" />
<link rel="manifest" href="/manifest.json" />
<link
rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css"
integrity="sha512-+4zCK9k+qNFUR5X+cKL9EIR+ZOhtIloNl9GIKS57V1MyNsYpYcUrUeQc9vNfzsWfV28IaLL3i96P9sdNyeRssA=="
crossOrigin="anonymous"
/>
</Head>
<body>
<Main />
<NextScript />
<script
async
src="https://platform.twitter.com/widgets.js"
charSet="utf-8"
/>
<script
type="text/javascript"
dangerouslySetInnerHTML={{
__html: `
(function () {
var s = document.createElement("script");
s.src = "https://stackpile.io/stack_162299.js"; s.async = true;
var e = document.getElementsByTagName("script")[0]; e.parentNode.insertBefore(s, e);
})();
`,
}}
/>
</body>
</Html>
);
}
}

View File

@ -0,0 +1,22 @@
import { useState, useEffect } from 'react';
import dynamic from 'next/dynamic';
const CreateReactAppEntryPoint = dynamic(() => import('../App'), {
ssr: false,
});
function App() {
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
if (!isMounted) {
return null;
}
return <CreateReactAppEntryPoint />;
}
export default App;

View File

@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@ -1,146 +0,0 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
),
);
type Config = {
onSuccess?: (registration: ServiceWorkerRegistration) => void;
onUpdate?: (registration: ServiceWorkerRegistration) => void;
};
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA',
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl: string, config?: Config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker === null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl: string, config?: Config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType !== null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.',
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(registration => {
registration.unregister();
})
.catch(error => {
console.error(error.message);
});
}
}

View File

@ -1,7 +1,7 @@
@import './fonts.less';
@import './App.less';
@import '~@oyster/common/dist/lib/styles.css';
@import '@oyster/common/styles.css';
@import './views/home/index.less';
@import './views/styles.less';

View File

@ -50,7 +50,7 @@ import {
SafetyDepositDraft,
} from '../../actions/createAuctionManager';
import BN from 'bn.js';
import { ZERO } from '@oyster/common/dist/lib/constants';
import { constants } from '@oyster/common';
import { DateTimePicker } from '../../components/DateTimePicker';
import { AmountLabel } from '../../components/AmountLabel';
import { useMeta } from '../../contexts';
@ -59,6 +59,7 @@ import { PlusCircleOutlined } from '@ant-design/icons';
const { Option } = Select;
const { Step } = Steps;
const { ZERO } = constants;
export enum AuctionCategory {
Limited,

View File

@ -1,5 +1,4 @@
@import '_colors';
@import '../../_colors.less';
section.ant-layout {
width: 100%;
@ -52,7 +51,8 @@ a:active {
background-clip: padding-box;
}
.my-masonry-grid_column > div { /* change div to reference your elements you put in <Masonry> */
.my-masonry-grid_column > div {
/* change div to reference your elements you put in <Masonry> */
margin-bottom: 30px;
}

View File

@ -1,8 +0,0 @@
import React from 'react';
if (process.env.NODE_ENV === 'development') {
// const whyDidYouRender = require('@welldone-software/why-did-you-render');
// whyDidYouRender(React, {
// trackAllPureComponents: true,
// });
}

View File

@ -19,12 +19,15 @@
"isolatedModules": true,
"downlevelIteration": true,
"noEmit": true,
"jsx": "react-jsx",
"jsx": "preserve",
"typeRoots": [
"../../types"
]
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}

File diff suppressed because it is too large Load Diff