diff --git a/.changeset/odd-ways-draw.md b/.changeset/odd-ways-draw.md new file mode 100644 index 0000000..ab521cb --- /dev/null +++ b/.changeset/odd-ways-draw.md @@ -0,0 +1,5 @@ +--- +'@antv/gpt-vis': minor +--- + +fix: ssr render err for map diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000..d17ebf5 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,8 @@ +{ + "mode": "exit", + "tag": "beta", + "initialVersions": { + "@antv/gpt-vis": "0.2.2" + }, + "changesets": ["odd-ways-draw"] +} diff --git a/.dumirc.ts b/.dumirc.ts index 740063a..43af4e7 100644 --- a/.dumirc.ts +++ b/.dumirc.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'dumi'; +import os from 'node:os'; export default defineConfig({ outputPath: 'docs-dist', @@ -13,6 +14,15 @@ Powered by AntV`, github: 'https://github.com/antvis/GPT-Vis', }, }, + // ssr: + // process.env.NODE_ENV === 'production' + // ? { + // builder: 'mako', + // } + // : false, + hash: true, + mfsu: false, + mako: ['Darwin', 'Linux'].includes(os.type()) ? {} : false, externals: { 'mapbox-gl': 'window.mapboxgl', 'maplibre-gl': 'window.maplibregl', diff --git a/.fatherrc.ts b/.fatherrc.ts index e983fef..0b9d896 100644 --- a/.fatherrc.ts +++ b/.fatherrc.ts @@ -17,7 +17,7 @@ export default defineConfig({ }, platform: 'browser', targets: { - chrome: 51, + chrome: 80, }, externals: { lodash: '_', diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 743318f..ccfe9d4 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -22,4 +22,4 @@ jobs: surge_token: ${{ secrets.SURGE_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }} dist: docs-dist - build: pn docs:build + build: pnpm docs:build diff --git a/.gitignore b/.gitignore index fc3ead2..5075a9a 100644 --- a/.gitignore +++ b/.gitignore @@ -78,4 +78,5 @@ jspm_packages/ # Build dist docs-dist +server .dumi diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c12449..8576f80 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/gpt-vis +## 0.3.0-beta.0 + +### Minor Changes + +- [`62d0c56`](https://github.com/antvis/GPT-Vis/commit/62d0c5644ed7a310de17f0accd71f4ca5d603a83) Thanks [@lvisei](https://github.com/lvisei)! - fix: ssr render err for map + ## 0.2.2 ### Patch Changes diff --git a/mako.config.json b/mako.config.json new file mode 100644 index 0000000..bf1f748 --- /dev/null +++ b/mako.config.json @@ -0,0 +1,9 @@ +{ + "optimization": { + "skipModules": false, + "concatenateModules": false + }, + "codeSplitting": { + "strategy": "auto" + } +} diff --git a/package.json b/package.json index 667b0d6..ac28c4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antv/gpt-vis", - "version": "0.2.2", + "version": "0.3.0-beta.0", "description": "Components for GPTs, generative AI, and LLM projects. Not only UI Components.", "keywords": [ "antv", @@ -23,6 +23,10 @@ "typings": "dist/esm/index.d.ts", "jsdelivr": "dist/umd/index.min.js", "unpkg": "dist/umd/index.min.js", + "browser": { + "./src/export-map.ts": "./src/export-map.browser.ts", + "./dist/esm/export-map.js": "./dist/esm/export-map.browser.js" + }, "files": [ "dist", "README.md", @@ -70,6 +74,7 @@ "@types/jest": "^29.5.14", "@types/lodash": "^4.17.13", "@types/react": "^18.0.0", + "@types/webpack-bundle-analyzer": "^4.7.0", "antd": "^5.0.0", "dumi": "^2.4.13", "eslint": "^9.14.0", diff --git a/src/export-map.browser.ts b/src/export-map.browser.ts new file mode 100644 index 0000000..a105ece --- /dev/null +++ b/src/export-map.browser.ts @@ -0,0 +1,5 @@ +// organize-imports-ignore +export { default as Map, type MapProps } from './Map'; +export { default as PinMap, type PinMapProps } from './PinMap'; +export { default as HeatMap, type HeatMapProps } from './HeatMap'; +export { default as PathMap, type PathMapProps } from './PathMap'; diff --git a/src/export-map.ts b/src/export-map.ts new file mode 100644 index 0000000..8da4e75 --- /dev/null +++ b/src/export-map.ts @@ -0,0 +1,18 @@ +// Map Components mock for use in environments without `document` / `window`, like ssr pre render +import type { FC } from 'react'; + +function MockMap() { + return null; +} + +import { type HeatMapProps } from './HeatMap'; +import { type MapProps } from './Map'; +import { type PathMapProps } from './PathMap'; +import { type PinMapProps } from './PinMap'; + +export const Map: FC = MockMap; +export const HeatMap: FC = MockMap; +export const PathMap: FC = MockMap; +export const PinMap: FC = MockMap; + +export type { HeatMapProps, MapProps, PathMapProps, PinMapProps }; diff --git a/src/export.ts b/src/export.ts index bacf3a0..f137f95 100644 --- a/src/export.ts +++ b/src/export.ts @@ -1,3 +1,4 @@ +// organize-imports-ignore import { ChartType } from './types'; /********** plot chart **********/ @@ -5,7 +6,6 @@ import { default as Area, type AreaProps } from './Area'; import { default as Bar, type BarProps } from './Bar'; import { default as Column, type ColumnProps } from './Column'; import { default as DualAxes, type DualAxesProps } from './DualAxes'; -import { default as HeatMap, type HeatMapProps } from './HeatMap'; import { default as Histogram, type HistogramProps } from './Histogram'; import { default as Line, type LineProps } from './Line'; import { default as Pie, type PieProps } from './Pie'; @@ -20,12 +20,18 @@ import { default as FlowDiagram, type FlowDiagramProps } from './FlowDiagram'; import { default as MindMap, type MindMapProps } from './MindMap'; import { default as NetworkGraph, type NetworkGraphProps } from './NetworkGraph'; export { default as IndentedTree, type IndentedTreeProps } from './IndentedTree'; -export { default as Map, type MapProps } from './Map'; export { default as OrganizationChart, type OrganizationChartProps } from './OrganizationChart'; /********** map chart **********/ -import { default as PathMap, type PathMapProps } from './PathMap'; -import { default as PinMap, type PinMapProps } from './PinMap'; +export { Map, type MapProps } from './export-map'; +import { + PinMap, + type PinMapProps, + HeatMap, + type HeatMapProps, + PathMap, + type PathMapProps, +} from './export-map'; /********** NTV **********/ export { VisText, type VisTextProps } from './Text'; @@ -77,10 +83,8 @@ export const DEFAULT_CHART_COMPONENTS: Record> = { [ChartType.Area]: Area, [ChartType.Scatter]: Scatter, [ChartType.PinMap]: PinMap, - [ChartType.PathMap]: PathMap, [ChartType.HeatMap]: HeatMap, [ChartType.MindMap]: MindMap, [ChartType.FlowDiagram]: FlowDiagram, [ChartType.NetworkGraph]: NetworkGraph, - [ChartType.FishboneDiagram]: FishboneDiagram, }; diff --git a/src/version.ts b/src/version.ts index 5af3ea9..a4e9946 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export default '0.2.2'; +export default '0.3.0-beta.0'; diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 4131afc..9f910a2 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -2,13 +2,5 @@ "extends": "./tsconfig.json", "compilerOptions": { "noEmit": true - }, - // paths intend to lint - "include": [ - "./*.?*.ts", - "src", - // test workspace lint - "__tests__" - ], - "exclude": ["node_modules", "dist"] + } } diff --git a/tsconfig.json b/tsconfig.json index a579fbc..0916abb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,5 +14,6 @@ "@antv/gpt-vis": ["./src/index.ts"] } }, + "include": ["./*.?*.ts", "src", "__tests__"], "exclude": ["node_modules", "dist"] }