Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to umi4 and React 18 #379

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
registry=https://registry.npmmirror.com
# pnpm
auto-install-peers=true
git-checks=false
git-checks=false
# public-hoist-pattern[]=*
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ currently being supported with security updates.
| pnpm | 7.x |
| antd | 4.x |
| react | 17.x |
| umi | 3.x |
| umi | 4.x |
| father | 2.x |
| webpack | 5.x |

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"react": "17",
"react-dom": "17.x",
"stream-browserify": "^3.0.0",
"umi": "3.x"
"@umijs/max": "4.x"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useContext } from '@antv/gi-sdk';
import { createUuid } from '@antv/gi-sdk/lib/process/common';
import { useContext, utils } from '@antv/gi-sdk';
import * as React from 'react';
import { useImmer } from 'use-immer';
import { CheckCircleFilled, PictureOutlined } from '@ant-design/icons';
Expand Down Expand Up @@ -87,8 +86,8 @@ const TemplateModal: React.FC<TemplateModalProps> = props => {
updateState(draft => {
draft.configuring = undefined;
draft.graphData = {
id: createUuid(),
name: createUuid(),
id: utils.createUuid(),
name: utils.createUuid(),
nodes,
edges: [
{
Expand Down Expand Up @@ -123,8 +122,8 @@ const TemplateModal: React.FC<TemplateModalProps> = props => {
updateState(draft => {
draft.configuring = undefined;
draft.graphData = {
id: createUuid(),
name: createUuid(),
id: utils.createUuid(),
name: utils.createUuid(),
nodes,
edges,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { GILayoutConfig, IGIAC } from '@antv/gi-sdk';
import { Icon, extra, useContext, utils } from '@antv/gi-sdk';
import { LayoutConfig } from '@antv/gi-sdk/lib/typing';
import type { LayoutConfig } from '@antv/gi-sdk';
import { Card, Popover, Radio, Space } from 'antd';
import React, { useEffect, useMemo } from 'react';

Expand Down
3 changes: 1 addition & 2 deletions packages/gi-sdk/src/GISDK.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { GraphInsightContext } from './context';
import getComponents from './hooks/useComponents';
import './index.less';
import * as utils from './process';
import { createUuid } from './process/common';
import { registerLayouts, registerShapes } from './register';
import type { GIComponentConfig, GIGraphData, Props, State } from './typing';

Expand Down Expand Up @@ -337,7 +336,7 @@ const GISDK = (props: Props) => {
// @ts-ignore
draft.history = (draft.history || []).concat([
{
id: createUuid(),
id: utils.createUuid(),
timestamp: time,
...param,
},
Expand Down
1 change: 1 addition & 0 deletions packages/gi-sdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type {
GraphSchemaData,
ISourceDataMap,
ServiceObject,
LayoutConfig,
} from './typing';
export { extra, template, useContext, utils, version };

Expand Down
1 change: 1 addition & 0 deletions packages/gi-sdk/src/process/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export {
mergeObjectByRule,
time,
uniqueElementsBy,
createUuid,
} from './common';
export { filterByRules } from './filterByRules';
export { findAllPath, getNeighbors } from './findAllPath';
Expand Down
91 changes: 57 additions & 34 deletions packages/gi-site/.umirc.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from 'umi';
import GI_SDK from '@antv/gi-sdk/package.json';
import GI_THEME_ANTD from '@antv/gi-theme-antd/package.json';

import deps_externals from './scripts/deps_externals.json';
export const G6_VERSION = '4.8.14';
export const GRAPHIN_VERSION = '2.7.16';
Expand All @@ -26,23 +26,22 @@ export const externalScripts = deps_externals.map(c => {
return { src: c.url };
});
console.log('externals', externals, BUILD_MODE);
const BASE_CONFIG = {
links: [
{
href: 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*7svFR6wkPMoAAAAAAAAAAAAADmJ7AQ/original',
rel: 'shortcut icon',
},
],
};
const EXTRA_CONFIG = isDev
? {
externals: {
react: 'React',
'react-dom': 'ReactDOM',
antd: 'antd',
// '@antv/g6': 'G6',
// '@antv/graphin': 'Graphin',
},
scripts: [
'https://gw.alipayobjects.com/os/lib/react/17.0.2/umd/react.production.min.js',
'https://gw.alipayobjects.com/os/lib/react-dom/17.0.2/umd/react-dom.production.min.js',
'https://gw.alipayobjects.com/os/lib/antd/4.24.8/dist/antd.min.js',
// 'https://gw.alipayobjects.com/os/lib/antv/g6/4.8.8/dist/g6.min.js',
// // 'https://gw.alipayobjects.com/os/lib/antv/graphin/2.7.13/dist/graphin.min.js',
// 'http://localhost:5501/graphin.min.js',
],
scripts: ['https://gw.alipayobjects.com/os/lib/antd/4.24.8/dist/antd.min.js'],
links: [],
}
: {
Expand All @@ -58,31 +57,49 @@ const EXTRA_CONFIG = isDev
};

export default {
// base: '/',
base: '/',
title: 'AntV Insight 让数据栩栩如生',
metas: [
{
name: 'keywords',
content: 'AntV Insight 数据可视化平台 图可视化 地理可视化 分析应用低代码构建',
},
{
name: 'description',
content:
'AntV Insight 是蚂蚁集团 AntV 团队推出的一款数据分析产品,用户可以在线完成视觉映射,分析洞察工作,也可以一键导出SDK,二次开发,集成部署',
},
],
externals: EXTRA_CONFIG.externals,
scripts: EXTRA_CONFIG.scripts,
links: [...BASE_CONFIG.links, ...EXTRA_CONFIG.links],
styles: ['body {background: var(--background-color); color: var(--text-color)}'],
headScripts: [
'https://www.googletagmanager.com/gtag/js?id=G-9Z6Z0NTLFB',
"window.dataLayer = window.dataLayer || [];function gtag() {dataLayer.push(arguments);}gtag('js', new Date());gtag('config', 'G-9Z6Z0NTLFB');",
"window.TracertCmdCache = window.TracertCmdCache || [];var t = window.Tracert || {_isRenderInit: !0,call: function () {window.TracertCmdCache.push(arguments);},},f = ['call','start','config','logPv','info','err','click','expo','pageName','pageState','time','timeEnd','parse','checkExpo','stringify','report','set','before'];for (let i = 0; i < f.length; i++) {(function (fn) {t[fn] = function () {var a = [],l = arguments.length;for (var j = 0; j < l; j++) {a.push(arguments[j]);}a.unshift(fn);window.TracertCmdCache.push(a);};})(f[i]);}window.Tracert = t;window._to = window._to || {};function filterLog(logType) {return function (opts) {return !!window.GI_USER_INFO?.outUserNo;};}window.Tracert.call('before', 'logPv', filterLog('PageMonitor'));window.Tracert.call('before', 'expo', filterLog('expo'));window.Tracert.call('before', 'click', filterLog('click'));",
'https://ur.alipay.com/tracert_a3220.js',
'https://gw.alipayobjects.com/os/lib/react/18.2.0/umd/react.production.min.js',
'https://gw.alipayobjects.com/os/lib/react-dom/18.2.0/umd/react-dom.production.min.js',
],
publicPath: BUILD_MODE === 'docker' ? '/public/' : '/',
hash: true,
favicon: 'https://gw.alipayobjects.com/zos/bmw-prod/b9a0f537-3768-445d-aa39-ff49de82124a.svg',
favicons: ['https://gw.alipayobjects.com/zos/bmw-prod/b9a0f537-3768-445d-aa39-ff49de82124a.svg'],
history: {
type: 'hash',
type: 'browser',
},
alias: {
'@': './src',
},
nodeModulesTransform: {
type: 'none',
},
routes: [
{ exact: true, path: '/', redirect: '/home' },
{ exact: true, path: '', redirect: '/home' },
{ exact: true, path: '/workspace/:projectId', component: 'Analysis' },
{ exact: true, path: '/share/:shareId', component: 'Share' },
{ exact: true, path: '/tabs/:type', component: 'Tab' },
{
path: '/',
component: '@/layouts/index',
component: '@/layouts/Main',
routes: [
{ exact: true, path: '/workspace', component: 'Workspace' },
{ exact: true, path: '/services', component: 'ServerCenter' },
{ exact: true, path: '/home', component: 'Home' },
{
path: '/dataset',
Expand Down Expand Up @@ -182,25 +199,31 @@ export default {
},
],
},
{ component: '404' },
{ exact: true, path: '/services', component: 'ServerCenter' },
{ exact: true, path: '/workspace', component: 'Workspace' },
],
},
{ component: '404' },
],
...EXTRA_CONFIG,

request: {
dataField: '',
},
// ...EXTRA_CONFIG,
analyze: {
analyzerMode: 'server',
analyzerPort: 8888,
openAnalyzer: true,
// generate stats file while ANALYZE_DUMP exist
generateStatsFile: false,
statsFilename: 'stats.json',
logLevel: 'info',
defaultSizes: 'parsed', // stat // gzip
},
mfsu: false,
// monorepoRedirect: {
// srcDir: ['.', 'src'],
// exclude: [/^(?!@alipay|@antv).*/],
// },
// analyze: {
// analyzerMode: 'server',
// analyzerPort: 8888,
// openAnalyzer: true,
// // generate stats file while ANALYZE_DUMP exist
// generateStatsFile: false,
// statsFilename: 'stats.json',
// logLevel: 'info',
// defaultSizes: 'parsed', // stat // gzip
// },
chainWebpack(memo, { type }) {
memo.module
.rule('mjs$')
Expand Down
21 changes: 11 additions & 10 deletions packages/gi-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
],
"main": "dist/app.js",
"scripts": {
"analyse": "ANALYZE=1 NODE_OPTIONS=--max_old_space_size=4096 umi build",
"build": "node --experimental-json-modules scripts/pre-build.mjs && NODE_OPTIONS=--max_old_space_size=4096 umi build",
"build:docker": "node scripts/link.mjs && cd ../../ && npm run build:all:umd && cd packages/gi-site/ && BUILD_MODE=docker node scripts/pre-build.mjs && node scripts/copy-assets.mjs && BUILD_MODE=docker NODE_OPTIONS=--max_old_space_size=4096 umi build",
"analyse": "ANALYZE=1 NODE_OPTIONS=--max_old_space_size=4096 max build",
"build": "node --experimental-json-modules scripts/pre-build.mjs && NODE_OPTIONS=--max_old_space_size=4096 max build",
"build:docker": "node scripts/link.mjs && cd ../../ && npm run build:all:umd && cd packages/gi-site/ && BUILD_MODE=docker node scripts/pre-build.mjs && node scripts/copy-assets.mjs && BUILD_MODE=docker NODE_OPTIONS=--max_old_space_size=4096 max build",
"deploy": "node ./scripts/deploy.js",
"start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--max_old_space_size=4096 cross-env PORT=8000 umi dev",
"start": "node --experimental-json-modules scripts/link.mjs && node scripts/pre-build.mjs && cross-env NODE_OPTIONS=--max_old_space_size=4096 cross-env PORT=8000 max dev",
"link": "node scripts/link.mjs",
"unlink": "cross-env UNLINK=true node scripts/link.mjs",
"eject": "cross-env EJECT=true node scripts/link.mjs"

},
"dependencies": {
"@ant-design/charts": "^1.0.21",
Expand All @@ -41,12 +40,15 @@
"@antv/gi-common-components": "workspace:*",
"@antv/gi-sdk": "workspace:*",
"@antv/gi-theme-antd": "workspace:*",
"@antv/s2-react": "^1.41.0",
"@antv/s2": "^1.48.0",
"@antv/util": "^3.3.2",
"@faker-js/faker": "latest",
"@fast-csv/format": "latest",
"@types/classnames": "^2.2.9",
"@types/node": "^7.0.12",
"@types/systemjs": "latest",
"@umijs/preset-react": "^1.8.12",
"@umijs/max": "^4.0.0",
"ahooks": "^2.10.9",
"classnames": "^2.2.6",
"d3-scale": "^4.0.0",
Expand All @@ -62,10 +64,9 @@
"node-fetch": "^3.3.0",
"react-color": "^2.19.3",
"react-monaco-editor": "^0.48.0",
"react-router-dom": "^5.1.1",
"swr": "^1.2.2",
"systemjs": "^6.11.0",
"umi": "^3.5.18",
"umi": "^4.0.0",
"umi-request": "^1.3.9",
"use-immer": "^0.7.0",
"xlsx2js": "^1.3.8"
Expand All @@ -79,8 +80,8 @@
"peerDependencies": {
"@antv/graphin": "^2.7.15",
"antd": "4.x",
"react": "17.x",
"react-dom": "17.x"
"react": "18.x",
"react-dom": "18.x"
},
"publishConfig": {
"access": "public"
Expand Down
12 changes: 0 additions & 12 deletions packages/gi-site/scripts/pre-build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ const depsPackage = [
global: 'localforage',
name: 'localforage',
},
{
url: 'https://gw.alipayobjects.com/os/lib/react/17.0.2/umd/react.production.min.js',
version: '17.0.2',
global: 'React',
name: 'react',
},
{
url: 'https://gw.alipayobjects.com/os/lib/react-dom/17.0.2/umd/react-dom.production.min.js',
name: 'react-dom',
version: '17.0.2',
global: 'ReactDOM',
},
{
url: 'https://gw.alipayobjects.com/os/lib/lodash/4.17.21/lodash.min.js',
name: 'lodash',
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-site/src/components/DataSource/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { useImmer } from 'use-immer';
import { getSearchParams } from '../../components/utils';
import { getSearchParams } from '../utils';
import Detail from './Detail';
import './index.less';
import SideList from './List';
Expand Down
3 changes: 1 addition & 2 deletions packages/gi-site/src/components/Empty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Button, Empty } from 'antd';
import * as React from 'react';
import { useHistory } from 'react-router-dom';
import { history } from 'umi';
interface EmptyDemoProps {
url: string;
title: string;
}

const EmptyDemo: React.FunctionComponent<EmptyDemoProps> = props => {
const { url, title } = props;
const history = useHistory();

return (
<Empty
Expand Down
4 changes: 2 additions & 2 deletions packages/gi-site/src/components/Navbar/ExportSdk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const SdkContent = () => {
data: { transData: data },
},
deps: {
react: '17.x',
'react-dom': '17.x',
react: '18.x',
'react-dom': '18.x',
localforage: '1.10.0',
antd: ANTD_VERSION,
'@antv/gi-theme-antd': GI_THEME_ANTD_VERSION,
Expand Down
2 changes: 1 addition & 1 deletion packages/gi-site/src/components/Navbar/Links.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { Link } from 'react-router-dom';
import { Link } from 'umi';
interface LinksProps {
active: string;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/gi-site/src/components/Navbar/SaveWorkbook.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { history } from 'umi';
import { SaveOutlined } from '@ant-design/icons';
import { Graph } from '@antv/graphin';
import { Button, notification, Tooltip } from 'antd';
import * as React from 'react';
import { useHistory } from 'react-router-dom';
import { useContext } from '../../pages/Analysis/hooks/useContext';
import * as ProjectServices from '../../services/project';
import type { IProject } from '../../services/typing';
Expand All @@ -23,7 +23,6 @@ const getCover = async (graph: Graph) => {

const SaveWorkbook: React.FunctionComponent<SaveWorkbookProps> = props => {
const { workbookId } = props;
const history = useHistory();
const { context, updateContext } = useContext();
const { config, activeAssetsKeys, name, graphRef } = context;
const handleSave = async () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/gi-site/src/components/Navbar/SiteNav.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { useHistory } from 'react-router-dom';
import { history } from 'umi';
import DataModeCard from '../DataModeCard';
import Github from './Github';
import Links from './Links';
Expand Down Expand Up @@ -28,7 +28,6 @@ const styles = {

const SiteNav: React.FunctionComponent<WorkbookBarProps> = props => {
const { active } = props;
const history = useHistory();

return (
<header style={styles.container} className="gi-navbar-container">
Expand Down
Loading