visualifyjs 2.5.3-2.dev → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/.claude/mem/TIMELINE.md +36 -0
  2. package/.claude/mem/notes/2026-02-11-3d-visualization-docs-fix-external-script-solution.md +24 -0
  3. package/.claude/mem/notes/2026-02-11-3d-visualization-docs-fix-session-summary.md +43 -0
  4. package/.claude/mem/notes/2026-02-11-cli-fix-editor-command-alias.md +26 -0
  5. package/.claude/mem/notes/2026-02-11-phase-3-developer-experience-completed.md +51 -0
  6. package/.claude/mem/notes/2026-02-11-phase-4-web-workers-implementation-complete.md +59 -0
  7. package/.claude/mem/notes/2026-02-11-visualify-phase-2-3d-visualization-complete.md +50 -0
  8. package/.claude/mem/notes/2026-02-11-visualify-phase-2-committed-ready-for-phase-3.md +33 -0
  9. package/.claude/mem/notes/2026-02-11-visualify-phase-3-complete-developer-experience.md +52 -0
  10. package/.claude/mem/notes/2026-02-11-visualify-repository-cleanup-complete.md +28 -0
  11. package/.claude/mem/notes/2026-02-18-codebase-cleanup-docsify-plugin-documentation.md +37 -0
  12. package/.claude/mem/notes/2026-02-19-css-grid-layout-fix-displaycontents-on-vcontroller.md +18 -0
  13. package/.claude/mem/notes/2026-02-19-docsify-plugin-fixes-latex-and-visualify-code-bloc.md +26 -0
  14. package/.claude/mem/notes/2026-02-19-page-mode-docs-update-decisions.md +23 -0
  15. package/.claude/mem/notes/2026-02-19-react-context-infinite-re-render-loop-fix-pattern.md +31 -0
  16. package/.claude/mem/notes/2026-02-19-version-300-bump-and-build-fixes.md +32 -0
  17. package/.claude/mem/notes/2026-02-19-visualify-build-deployment-architecture-bug-fixes.md +25 -0
  18. package/.claude/mem/notes/2026-02-19-visualify-dist-iife-self-contained-build-config.md +30 -0
  19. package/.claude/mem/notes/2026-02-19-visualify-infinite-loop-i18n-fixes.md +31 -0
  20. package/.claude/mem/notes/2026-02-19-visualify-v3-bundle-splitting-docs-restructuring.md +32 -0
  21. package/.claude/mem/notes/2026-02-20-bundle-externalization-final-architecture.md +29 -0
  22. package/.claude/mem/notes/2026-02-20-chromium-page-fix-unstable-keys-and-double-event-b.md +27 -0
  23. package/.claude/mem/notes/2026-02-20-console-cleanup-bundle-optimization-commit.md +20 -0
  24. package/.claude/mem/notes/2026-02-20-dotbio-dot-plot-fix-useeffect-dependency.md +21 -0
  25. package/.claude/mem/notes/2026-02-20-public-folder-cleanup-and-readme-rewrite.md +25 -0
  26. package/.claude/mem/notes/2026-02-20-v300-release-and-beta-channel-strategy.md +29 -0
  27. package/.claude/mem/notes/2026-02-20-visium-background-image-unknown-legend-fix.md +19 -0
  28. package/.claude/mem/notes/2026-02-20-visualify-cdn-loader-bundle-externalization.md +34 -0
  29. package/.claude/mem/sessions/session-2026-02-20-031524.md +54 -0
  30. package/.claude/settings.local.json +21 -0
  31. package/.github/workflows/static.yml.bak +51 -51
  32. package/.sisyphus/boulder.json +65 -0
  33. package/.sisyphus/plans/phase-4-advanced-optimizations.md +217 -0
  34. package/LICENSE +674 -674
  35. package/README.md +94 -59
  36. package/config-overrides.js +31 -31
  37. package/dist/stats.html +4949 -0
  38. package/dist/visualify-3d.esm.js +1 -0
  39. package/dist/visualify-3d.js +1 -0
  40. package/dist/visualify-core.esm.js +1 -0
  41. package/dist/visualify-core.js +1 -0
  42. package/dist/visualify-docs.esm.js +1 -0
  43. package/dist/visualify-docs.js +1 -0
  44. package/dist/visualify-loader.js +1 -0
  45. package/dist/visualify-pages.esm.js +1 -0
  46. package/dist/visualify-pages.js +1 -0
  47. package/dist/visualify-portal.esm.js +1 -0
  48. package/dist/visualify-portal.js +1 -0
  49. package/dist/visualify-shared.js +26571 -0
  50. package/dist/visualify.js +1 -188
  51. package/docs/CHANGELOG.md +148 -0
  52. package/docs/cli/commands.md +513 -0
  53. package/docs/configuration/visualify-json.md +474 -0
  54. package/docs/docs/3d-visualization.md +374 -0
  55. package/docs/docs/CLI.md +303 -34
  56. package/docs/docs/README.md +65 -65
  57. package/docs/docs/Rechart/bar.md +190 -190
  58. package/docs/docs/Rechart/funnel.md +241 -241
  59. package/docs/docs/Rechart/line.md +355 -355
  60. package/docs/docs/Rechart/pie.md +225 -225
  61. package/docs/docs/Rechart/radar.md +253 -253
  62. package/docs/docs/Rechart/scatter.md +298 -298
  63. package/docs/docs/_404.md +51 -51
  64. package/docs/docs/_coverpage.md +11 -11
  65. package/docs/docs/_sidebar.md +54 -44
  66. package/docs/docs/components/dotBio.md +87 -34
  67. package/docs/docs/components/echart.md +171 -82
  68. package/docs/docs/components/html.md +61 -34
  69. package/docs/docs/components/macaron.md +156 -145
  70. package/docs/docs/components/markdown.md +42 -0
  71. package/docs/docs/components/more.md +183 -142
  72. package/docs/docs/components/plotly.md +132 -62
  73. package/docs/docs/components/scatterL.md +171 -70
  74. package/docs/docs/components/visium.md +112 -57
  75. package/docs/docs/configuration.md +121 -121
  76. package/docs/docs/deploy.md +31 -31
  77. package/docs/docs/docsify-plugin.md +655 -0
  78. package/docs/docs/hmr.md +165 -0
  79. package/docs/docs/i18n.md +332 -0
  80. package/docs/docs/log.md +30 -9
  81. package/docs/docs/more-pages.md +23 -23
  82. package/docs/docs/quickstart.md +148 -124
  83. package/docs/docs/rechart-attributes.md +74 -74
  84. package/docs/docs/rechart-basic-usage.md +160 -162
  85. package/docs/docs/theme.md +5 -5
  86. package/docs/docs/typescript.md +306 -0
  87. package/docs/docs/visual-editor.md +359 -0
  88. package/docs/index.html +85 -71
  89. package/docs/manifest.json +23 -23
  90. package/docs/migration/v3-migration.md +392 -0
  91. package/docs/static/css/fluff-stuff.css +169 -169
  92. package/docs/static/css/font-awesome.min.css +4 -4
  93. package/docs/static/css/visualify.css +6 -25
  94. package/docs/static/js/3d-viz-examples.js +181 -0
  95. package/docs/static/js/configuration.js +630 -448
  96. package/docs/static/js/visualify.js +1 -188
  97. package/package.json +106 -84
  98. package/rollup.config.mjs +766 -76
  99. package/src/_css/404.css +115 -115
  100. package/src/_css/App.css +37 -37
  101. package/src/_css/autoSuggestion.css +26 -26
  102. package/src/_css/circular-progress.css +32 -32
  103. package/src/_css/index.css +36 -36
  104. package/src/_css/modern.css +350 -25
  105. package/src/_media/corner.svg +8 -8
  106. package/src/_media/download.svg +3 -3
  107. package/src/_media/logo.svg +14 -14
  108. package/src/_test/App.test.js +15 -15
  109. package/src/_utils/reportWebVitals.js +13 -13
  110. package/src/a11y/README.md +177 -0
  111. package/src/a11y/aria-labels.js +339 -0
  112. package/src/a11y/color-contrast.js +535 -0
  113. package/src/a11y/index.js +197 -0
  114. package/src/a11y/keyboard-nav.js +523 -0
  115. package/src/a11y/styles.css +165 -0
  116. package/src/cli/commands/dev.js +214 -0
  117. package/src/cli/commands/docs.js +521 -0
  118. package/src/cli/commands/edit.js +379 -0
  119. package/src/cli/commands/init.js +213 -0
  120. package/src/cli/commands/portal.js +236 -0
  121. package/src/cli/dev-server.js +530 -0
  122. package/src/cli/hmr.js +456 -0
  123. package/src/cli/index.js +180 -0
  124. package/src/cli/utils/config.js +207 -0
  125. package/src/cli/utils/logger.js +241 -0
  126. package/src/config/defaults.ts +122 -0
  127. package/src/config/index.ts +72 -0
  128. package/src/config/loader.ts +478 -0
  129. package/src/config/schema.ts +227 -0
  130. package/src/config/validator.ts +337 -0
  131. package/src/core/appContext.js +34 -27
  132. package/src/core/components/Bar.js +383 -0
  133. package/src/core/components/Bar3D.js +473 -0
  134. package/src/core/components/LargeDatasetChart.js +296 -0
  135. package/src/core/components/Line3D.js +310 -0
  136. package/src/core/components/Scatter.js +392 -188
  137. package/src/core/components/Scatter3D.js +455 -0
  138. package/src/core/components/ScatterBio.js +601 -572
  139. package/src/core/components/Surface3D.js +326 -0
  140. package/src/core/components/ThreeCustom.js +648 -0
  141. package/src/core/components/ThreeScene.js +459 -0
  142. package/src/core/components/VisiumPlot.js +191 -165
  143. package/src/core/components/browser.js +42 -42
  144. package/src/core/components/dotplot.js +413 -413
  145. package/src/core/components/html.js +29 -29
  146. package/src/core/components/list.js +178 -178
  147. package/src/core/components/macaron.js +206 -201
  148. package/src/core/components/markdown.js +56 -56
  149. package/src/core/components/parser.scatterBio.js +582 -587
  150. package/src/core/components/ratio.js +82 -80
  151. package/src/core/components/scatterL.js +206 -173
  152. package/src/core/components/searchbar.js +156 -131
  153. package/src/core/components/selection.js +310 -193
  154. package/src/core/components/timeline.js +236 -281
  155. package/src/core/components/visium.js +114 -97
  156. package/src/core/data-processor.js +413 -0
  157. package/src/core/fetch/condfetch.js +82 -82
  158. package/src/core/fetch/fetch.js +92 -92
  159. package/src/core/fetch/json.js +29 -29
  160. package/src/core/fetch/vfetch.js +42 -42
  161. package/src/core/hmr-client.js +724 -0
  162. package/src/core/liveEditor.js +44 -44
  163. package/src/core/modules/codeEditorWithPreview.js +104 -104
  164. package/src/core/modules/echarts/common.js +20 -20
  165. package/src/core/modules/echarts/gl.js +228 -0
  166. package/src/core/modules/echarts/presetHandler.js +41 -41
  167. package/src/core/modules/echarts/presets/esodev.chromium.js +172 -172
  168. package/src/core/modules/echarts/presets/esodev.codex.js +130 -130
  169. package/src/core/modules/echarts/presets/esodev.visium.js +123 -123
  170. package/src/core/modules/echarts/presets/mmtrbc.js +186 -186
  171. package/src/core/modules/echarts.js +70 -71
  172. package/src/core/modules/echartsUtils.js +43 -43
  173. package/src/core/modules/echartswitcher.js +227 -152
  174. package/src/core/modules/replotly/presetHandler.js +24 -24
  175. package/src/core/modules/replotly/presets/minimum.js +18 -18
  176. package/src/core/modules/replotly/presets/mmtrbc.dot.js +114 -114
  177. package/src/core/modules/replotly/presets/mmtrbc.violin.js +100 -100
  178. package/src/core/modules/replotly.js +74 -71
  179. package/src/core/modules/threejs/Camera.js +373 -0
  180. package/src/core/modules/threejs/Lighting.js +459 -0
  181. package/src/core/modules/threejs/Renderer.js +364 -0
  182. package/src/core/modules/threejs/Scene.js +266 -0
  183. package/src/core/modules/threejs/index.js +155 -0
  184. package/src/core/pages/404.js +50 -50
  185. package/src/core/pages/error.js +27 -27
  186. package/src/core/pages/jsonPage.js +62 -62
  187. package/src/core/pages/loading.js +44 -44
  188. package/src/core/parser/echart.data.js +204 -183
  189. package/src/core/parser/echart.features.js +125 -125
  190. package/src/core/parser/echart.general.js +147 -147
  191. package/src/core/parser/echart.hilbert.js +57 -57
  192. package/src/core/parser/echart.parser.js +210 -210
  193. package/src/core/parser/echart.series.js +67 -67
  194. package/src/core/parser/echart.types.js +76 -76
  195. package/src/core/parser/plotly.config.js +10 -10
  196. package/src/core/parser/plotly.data.js +132 -132
  197. package/src/core/parser/plotly.layout.js +9 -9
  198. package/src/core/parser/plotly.violin.js +18 -18
  199. package/src/core/recharts.js +361 -62
  200. package/src/core/router/alias.js +49 -49
  201. package/src/core/router/jsonRouter.js +31 -31
  202. package/src/core/themes/modern.js +32 -32
  203. package/src/core/themes/themeSelector.js +33 -33
  204. package/src/core/visualify.js +213 -47
  205. package/src/core/widgets/circularProgress.js +23 -23
  206. package/src/core/widgets/controller.js +116 -83
  207. package/src/core/widgets/errorBoundary.js +36 -36
  208. package/src/core/widgets/footer.js +185 -177
  209. package/src/core/widgets/header.js +238 -234
  210. package/src/core/widgets/layout/Grid.js +31 -31
  211. package/src/core/widgets/layout.js +36 -36
  212. package/src/core/widgets/mapping.js +56 -42
  213. package/src/core/workers/data-worker.js +349 -0
  214. package/src/core/workers/worker-pool.js +396 -0
  215. package/src/docsify/bundle.js +215 -0
  216. package/src/docsify/markdown.js +271 -0
  217. package/src/docsify/plugin.js +268 -0
  218. package/src/editor/README.md +172 -0
  219. package/src/editor/components/ChartBuilder.jsx +341 -0
  220. package/src/editor/components/ChartTypeSidebar.jsx +91 -0
  221. package/src/editor/components/Editor.jsx +367 -0
  222. package/src/editor/components/Preview.jsx +446 -0
  223. package/src/editor/components/PropertyPanel.jsx +468 -0
  224. package/src/editor/components/StatusBar.jsx +85 -0
  225. package/src/editor/context/EditorContext.js +248 -0
  226. package/src/editor/hooks/useDebounce.js +32 -0
  227. package/src/editor/index.js +315 -0
  228. package/src/editor/styles/editor.css +637 -0
  229. package/src/editor/utils/chartValidator.js +263 -0
  230. package/src/entries/charts3d.js +70 -0
  231. package/src/entries/core.js +78 -0
  232. package/src/entries/docs.js +154 -0
  233. package/src/entries/pages.js +93 -0
  234. package/src/entries/portal.js +204 -0
  235. package/src/entries/shared.js +50 -0
  236. package/src/i18n/formatters.js +455 -0
  237. package/src/i18n/index.js +169 -0
  238. package/src/i18n/locales/ar.json +137 -0
  239. package/src/i18n/locales/de.json +137 -0
  240. package/src/i18n/locales/en.json +137 -0
  241. package/src/i18n/locales/es.json +137 -0
  242. package/src/i18n/locales/he.json +137 -0
  243. package/src/i18n/locales/zh.json +137 -0
  244. package/src/i18n/rtl.css +183 -0
  245. package/src/index.js +82 -62
  246. package/src/loader.js +103 -0
  247. package/src/setupTests.js +5 -5
  248. package/tsconfig.json +51 -0
  249. package/types/charts.d.ts +569 -0
  250. package/types/components.d.ts +441 -0
  251. package/types/config.d.ts +199 -0
  252. package/types/index.d.ts +353 -0
package/rollup.config.mjs CHANGED
@@ -1,76 +1,766 @@
1
- /*
2
- * @Author : Lihao leolihao@arizona.edu
3
- * @Date : 2023-12-01 12:51:04
4
- * @FilePath : /visualifyjs/rollup.config.mjs
5
- * @Description :
6
- * Copyright (c) 2023 by Lihao (leolihao@arizona.edu), All Rights Reserved.
7
- */
8
- // rollup.config.js
9
- import resolve from '@rollup/plugin-node-resolve';
10
- import commonjs from '@rollup/plugin-commonjs';
11
- import babel from '@rollup/plugin-babel';
12
- import replace from '@rollup/plugin-replace';
13
- import terser from '@rollup/plugin-terser';
14
- import json from '@rollup/plugin-json';
15
- import postcss from 'rollup-plugin-postcss';
16
- import nodePolyfills from 'rollup-plugin-polyfill-node';
17
- import image from '@rollup/plugin-image';
18
- import inlineReactSvg from 'babel-plugin-inline-react-svg';
19
- import url from '@rollup/plugin-url';
20
-
21
- //import css from 'rollup-plugin-css-only';
22
-
23
- function onwarn(warning, warn) {
24
- if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
25
- return;
26
- }
27
- warn(warning);
28
- }
29
-
30
- export default {
31
- input: 'src/index.js',
32
- output: [{
33
- dir: 'dist/',
34
- format: 'esm',
35
- entryFileNames: 'visualify.js',
36
- inlineDynamicImports: true,
37
- sourcemap: false,
38
- },
39
- {
40
- dir: 'docs/static/js',
41
- format: 'esm',
42
- entryFileNames: 'visualify.js',
43
- inlineDynamicImports: true,
44
- sourcemap: false,
45
- },
46
- ],
47
- plugins: [
48
- replace({
49
- preventAssignment: true,
50
- 'process.env.NODE_ENV': JSON.stringify('production'),
51
- }),
52
- resolve({ browser: true }),
53
- babel({
54
- exclude: 'node_modules/**',
55
- babelHelpers: 'bundled',
56
- presets: ['@babel/preset-env', '@babel/preset-react'],
57
- plugins: [inlineReactSvg],
58
- }),
59
- postcss({
60
- extensions: ['.css'],
61
- inject: true,
62
- minimize: true,
63
- }),
64
- url({
65
- include: ['**/*.svg'], // Only SVG files
66
- limit: 0, // 0 bytes
67
- emitFiles: true,
68
- }),
69
- commonjs(),
70
- terser(),
71
- json(),
72
- nodePolyfills(),
73
- image(),
74
- ],
75
- onwarn,
76
- };
1
+ /**
2
+ * Visualify.js Rollup Configuration
3
+ * @description Multi-mode build system with on-demand chunk splitting
4
+ *
5
+ * Build Outputs:
6
+ * - dist/visualify-docs.js (UMD) - Docsify plugin bundle
7
+ * - dist/visualify-docs.esm.js (ESM) - Docsify plugin ESM
8
+ * - dist/visualify-portal.js (UMD) - Full portal bundle
9
+ * - dist/visualify-portal.esm.js (ESM) - Full portal ESM
10
+ * - dist/visualify-shared.js - Shared components chunk
11
+ * - dist/visualify.js - Legacy single-file build
12
+ * - dist/visualify-core.js (UMD/ESM) - Core 2D charts only
13
+ * - dist/visualify-3d.js (UMD/ESM) - 3D visualization chunk
14
+ * - dist/visualify-pages.js (UMD/ESM) - Page mode components
15
+ * - dist/stats.html - Bundle analysis visualization
16
+ */
17
+
18
+ import resolve from '@rollup/plugin-node-resolve';
19
+ import commonjs from '@rollup/plugin-commonjs';
20
+ import babel from '@rollup/plugin-babel';
21
+ import replace from '@rollup/plugin-replace';
22
+ import terser from '@rollup/plugin-terser';
23
+ import json from '@rollup/plugin-json';
24
+ import postcss from 'rollup-plugin-postcss';
25
+ import nodePolyfills from 'rollup-plugin-polyfill-node';
26
+ import image from '@rollup/plugin-image';
27
+ import inlineReactSvg from 'babel-plugin-inline-react-svg';
28
+ import url from '@rollup/plugin-url';
29
+ import { visualizer } from 'rollup-plugin-visualizer';
30
+
31
+ // =============================================================================
32
+ // Configuration Constants
33
+ // =============================================================================
34
+
35
+ /** Bundle size thresholds for warnings (in KB) */
36
+ const SIZE_THRESHOLDS = {
37
+ docs: 500, // Docs bundle should be lightweight
38
+ portal: 2000, // Portal bundle can be larger
39
+ shared: 1000, // Shared chunk threshold
40
+ threejs: 3000, // 3D libs are large - separate threshold
41
+ core: 300, // Core 2D charts - should be small
42
+ charts3d: 200, // 3D chunk (excluding external 3D libs)
43
+ pages: 500, // Page mode components
44
+ };
45
+
46
+ /** Version from package.json */
47
+ const PACKAGE_VERSION = process.env.npm_package_version || 'dev';
48
+
49
+ /** Sourcemaps only in development (npm run rollup:dev) */
50
+ const SOURCEMAP = process.env.NODE_ENV === 'development';
51
+
52
+ /** External dependencies that should not be bundled */
53
+ const EXTERNAL_DEPS = [
54
+ 'react',
55
+ 'react-dom',
56
+ 'react-dom/client',
57
+ 'react/jsx-runtime',
58
+ 'echarts',
59
+ 'echarts-for-react',
60
+ 'echarts-gl',
61
+ 'react-plotly.js',
62
+ 'plotly.js',
63
+ 'react-router-dom',
64
+ 'react-bootstrap',
65
+ 'bootstrap',
66
+ 'axios',
67
+ 'lodash',
68
+ 'dompurify',
69
+ 'react-markdown',
70
+ 'remark',
71
+ 'remark-html',
72
+ 'react-select',
73
+ 'react-ace',
74
+ 'ace-builds',
75
+ 'hilbert',
76
+ 'three',
77
+ '@react-three/fiber',
78
+ '@react-three/drei',
79
+ ];
80
+
81
+ /** Peer dependencies (always external) */
82
+ const PEER_DEPS = ['react', 'react-dom'];
83
+
84
+ /** Common UMD globals mapping */
85
+ const COMMON_GLOBALS = {
86
+ react: 'React',
87
+ 'react-dom': 'ReactDOM',
88
+ 'react-dom/client': 'ReactDOM',
89
+ echarts: 'echarts',
90
+ 'echarts-for-react': 'ReactEcharts',
91
+ 'echarts-gl': 'echartsGL',
92
+ lodash: '_',
93
+ hilbert: 'hilbert',
94
+ 'react-ace': 'AceEditor',
95
+ three: 'THREE',
96
+ '@react-three/fiber': 'ReactThreeFiber',
97
+ '@react-three/drei': 'ReactThreeDrei',
98
+ 'react-bootstrap': 'reactBootstrap',
99
+ 'react-router-dom': 'reactRouterDom',
100
+ dompurify: 'DOMPurify',
101
+ axios: 'axios',
102
+ 'remark-html': 'remarkHtml',
103
+ 'react-select': 'Select',
104
+ 'react-plotly.js': 'Plotly',
105
+ };
106
+
107
+ // =============================================================================
108
+ // Plugin Configurations
109
+ // =============================================================================
110
+
111
+ /**
112
+ * Create common plugins shared across all builds
113
+ * @param {Object} options - Plugin options
114
+ * @returns {Array} Array of Rollup plugins
115
+ */
116
+ /**
117
+ * Custom plugin to resolve extensionless imports in node_modules
118
+ * (e.g., echarts-gl imports zrender/lib/animation/requestAnimationFrame without .js)
119
+ */
120
+ /**
121
+ * Fix implicit global assignments in legacy CommonJS modules that break strict mode
122
+ * (e.g., hilbert/hilbert3d.js uses bare `debug = false; log = function(...){}`)
123
+ */
124
+ /**
125
+ * Post-process IIFE output to use safe global references (typeof + window)
126
+ * instead of bare variable references that throw ReferenceError when missing.
127
+ * Transforms the IIFE closing: }(echarts,Plotly,...);
128
+ * Into: }(typeof echarts!=="undefined"?echarts:void 0,...);
129
+ */
130
+ function safeExternalGlobals() {
131
+ const globalNames = ['echarts', 'echartsGL', 'Plotly'];
132
+ return {
133
+ name: 'safe-external-globals',
134
+ renderChunk(code) {
135
+ // Only target the IIFE closing pattern at end of file: }(global1,global2,...);
136
+ const iifeClosingRegex = /\}\(([^)]+)\);?\s*$/;
137
+ const match = code.match(iifeClosingRegex);
138
+ if (!match) return null;
139
+
140
+ const args = match[1];
141
+ const safeArgs = args.split(',').map(arg => {
142
+ const trimmed = arg.trim();
143
+ if (globalNames.includes(trimmed)) {
144
+ return `typeof ${trimmed}!=="undefined"?${trimmed}:void 0`;
145
+ }
146
+ return trimmed;
147
+ }).join(',');
148
+
149
+ if (safeArgs === args) return null;
150
+
151
+ const modified = code.slice(0, match.index) + `}(${safeArgs});`;
152
+ return { code: modified, map: null };
153
+ },
154
+ };
155
+ }
156
+
157
+ function fixImplicitGlobals() {
158
+ return {
159
+ name: 'fix-implicit-globals',
160
+ transform(code, id) {
161
+ if (id.includes('hilbert') && id.endsWith('.js')) {
162
+ // Prepend var declarations for bare globals
163
+ if (code.includes('debug = false') || code.includes('log = function')) {
164
+ return 'var debug, log;\n' + code;
165
+ }
166
+ }
167
+ return null;
168
+ },
169
+ };
170
+ }
171
+
172
+ function resolveExtensionless() {
173
+ return {
174
+ name: 'resolve-extensionless',
175
+ async resolveId(source, importer) {
176
+ if (!importer || !importer.includes('node_modules')) return null;
177
+ if (source.startsWith('.') || source.startsWith('/')) return null;
178
+ // Only handle bare module paths that look like deep imports
179
+ if (!source.includes('/lib/') && !source.includes('/src/')) return null;
180
+
181
+ const { resolve } = await import('path');
182
+ const { existsSync } = await import('fs');
183
+ const baseDir = importer.substring(0, importer.lastIndexOf('node_modules') + 'node_modules'.length);
184
+ const fullPath = resolve(baseDir, source);
185
+
186
+ // Try adding .js extension
187
+ if (!existsSync(fullPath) && existsSync(fullPath + '.js')) {
188
+ return fullPath + '.js';
189
+ }
190
+ return null;
191
+ },
192
+ };
193
+ }
194
+
195
+ function createCommonPlugins(options = {}) {
196
+ const { isProduction = true } = options;
197
+
198
+ return [
199
+ // Resolve extensionless deep imports in node_modules
200
+ resolveExtensionless(),
201
+
202
+ // Replace environment variables
203
+ replace({
204
+ preventAssignment: true,
205
+ 'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
206
+ 'process.env.VISUALIFY_VERSION': JSON.stringify(PACKAGE_VERSION),
207
+ }),
208
+
209
+ // Resolve node_modules dependencies
210
+ resolve({
211
+ browser: true,
212
+ preferBuiltins: false,
213
+ extensions: ['.mjs', '.js', '.jsx', '.json', '.node', '.ts'],
214
+ }),
215
+
216
+ // Handle JSON imports
217
+ json(),
218
+
219
+ // Process CSS and inject
220
+ postcss({
221
+ extensions: ['.css'],
222
+ inject: true,
223
+ minimize: isProduction,
224
+ }),
225
+
226
+ // Handle image imports
227
+ image(),
228
+
229
+ // URL handling for assets
230
+ url({
231
+ include: ['**/*.svg', '**/*.png', '**/*.jpg', '**/*.gif'],
232
+ limit: 0,
233
+ emitFiles: true,
234
+ }),
235
+
236
+ // Babel transpilation
237
+ babel({
238
+ exclude: 'node_modules/**',
239
+ babelHelpers: 'bundled',
240
+ presets: ['@babel/preset-env', '@babel/preset-react'],
241
+ plugins: [inlineReactSvg],
242
+ }),
243
+
244
+ // Fix implicit globals in legacy CJS modules (must run before commonjs)
245
+ fixImplicitGlobals(),
246
+
247
+ // CommonJS support
248
+ commonjs({
249
+ include: 'node_modules/**',
250
+ }),
251
+
252
+ // Node polyfills for browser
253
+ nodePolyfills(),
254
+ ];
255
+ }
256
+
257
+ /**
258
+ * Create production plugins (minification)
259
+ * @returns {Array} Production plugins
260
+ */
261
+ function createProductionPlugins() {
262
+ return [
263
+ // Minification with terser
264
+ terser({
265
+ compress: {
266
+ drop_console: false, // Keep console for debugging
267
+ drop_debugger: true,
268
+ pure_funcs: ['console.log'], // Remove console.log in production
269
+ },
270
+ mangle: true,
271
+ format: {
272
+ comments: false,
273
+ },
274
+ }),
275
+ ];
276
+ }
277
+
278
+ /**
279
+ * Create bundle analyzer plugin
280
+ * @param {string} filename - Output filename for stats
281
+ * @returns {Object} Visualizer plugin
282
+ */
283
+ function createVisualizerPlugin(filename = 'stats.html') {
284
+ return visualizer({
285
+ filename: `dist/${filename}`,
286
+ title: 'Visualify Bundle Analysis',
287
+ template: 'treemap', // treemap, sunburst, or network
288
+ sourcemap: SOURCEMAP,
289
+ gzipSize: true,
290
+ brotliSize: true,
291
+ });
292
+ }
293
+
294
+ // =============================================================================
295
+ // Warning Handler
296
+ // =============================================================================
297
+
298
+ /**
299
+ * Custom warning handler to filter noise and highlight important issues
300
+ * @param {Object} warning - Rollup warning object
301
+ * @param {Function} warn - Default warn function
302
+ */
303
+ function onwarn(warning, warn) {
304
+ // Ignore module level directives (use client, etc.)
305
+ if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
306
+ return;
307
+ }
308
+
309
+ // Ignore circular dependency warnings from node_modules
310
+ if (warning.code === 'CIRCULAR_DEPENDENCY' && warning.ids?.some(id => id.includes('node_modules'))) {
311
+ return;
312
+ }
313
+
314
+ // Ignore eval warnings (some dependencies use eval)
315
+ if (warning.code === 'EVAL') {
316
+ return;
317
+ }
318
+
319
+ // Log bundle size warnings
320
+ if (warning.code === 'PLUGIN_WARNING' && warning.message?.includes('bundle size')) {
321
+ console.warn(`⚠️ Bundle Size Warning: ${warning.message}`);
322
+ }
323
+
324
+ // Warn about 3D library dynamic imports
325
+ if (warning.code === 'UNRESOLVED_IMPORT') {
326
+ const threeJsLibs = ['three', '@react-three/fiber', '@react-three/drei', 'echarts-gl'];
327
+ if (threeJsLibs.some(lib => warning.source?.includes(lib))) {
328
+ console.warn(`⚠️ 3D Library Import: ${warning.source} - Ensure it's available at runtime`);
329
+ return;
330
+ }
331
+ }
332
+
333
+ // Handle dynamic import warnings for 3D chunks
334
+ if (warning.code === 'DYNAMIC_IMPORT_FAILED') {
335
+ console.warn(`⚠️ Dynamic Import Warning: ${warning.message}`);
336
+ return;
337
+ }
338
+
339
+ warn(warning);
340
+ }
341
+
342
+ // =============================================================================
343
+ // Build Configurations
344
+ // =============================================================================
345
+
346
+ /**
347
+ * Docs entry configuration
348
+ * Lightweight bundle for Docsify plugin usage
349
+ */
350
+ const docsConfig = {
351
+ input: 'src/entries/docs.js',
352
+ output: [
353
+ {
354
+ file: 'dist/visualify-docs.js',
355
+ format: 'umd',
356
+ name: 'VisualifyDocs',
357
+ globals: {
358
+ react: 'React',
359
+ 'react-dom': 'ReactDOM',
360
+ 'react-dom/client': 'ReactDOM',
361
+ 'echarts-for-react': 'ReactEcharts',
362
+ lodash: '_',
363
+ hilbert: 'hilbert',
364
+ 'react-ace': 'AceEditor',
365
+ three: 'THREE',
366
+ 'echarts-gl': 'echartsGL',
367
+ },
368
+ exports: 'named',
369
+ sourcemap: SOURCEMAP,
370
+ inlineDynamicImports: true,
371
+ // Preserve dynamic imports for 3D lazy loading
372
+ // Dynamic import() statements will be preserved for runtime loading
373
+ // Banner with version info
374
+ banner: `/*! VisualifyDocs v${PACKAGE_VERSION} | Docsify Plugin Bundle */`,
375
+ },
376
+ {
377
+ file: 'dist/visualify-docs.esm.js',
378
+ format: 'esm',
379
+ sourcemap: SOURCEMAP,
380
+ inlineDynamicImports: true,
381
+ banner: `/*! VisualifyDocs v${PACKAGE_VERSION} | Docsify Plugin ESM */`,
382
+ // Preserve dynamic imports for 3D lazy loading
383
+ // This allows Three.js to be loaded only when needed
384
+ },
385
+ ],
386
+ external: EXTERNAL_DEPS,
387
+ plugins: [
388
+ ...createCommonPlugins({ isProduction: true }),
389
+ ...createProductionPlugins(),
390
+ ],
391
+ onwarn,
392
+ };
393
+
394
+ /**
395
+ * Portal entry configuration
396
+ * Full application bundle for data portals
397
+ */
398
+ const portalConfig = {
399
+ input: 'src/entries/portal.js',
400
+ output: [
401
+ {
402
+ file: 'dist/visualify-portal.js',
403
+ format: 'umd',
404
+ name: 'Visualify',
405
+ globals: {
406
+ react: 'React',
407
+ 'react-dom': 'ReactDOM',
408
+ 'react-dom/client': 'ReactDOM',
409
+ echarts: 'echarts',
410
+ 'echarts-for-react': 'ReactEcharts',
411
+ lodash: '_',
412
+ hilbert: 'hilbert',
413
+ 'react-ace': 'AceEditor',
414
+ 'react-bootstrap': 'reactBootstrap',
415
+ 'react-router-dom': 'reactRouterDom',
416
+ dompurify: 'DOMPurify',
417
+ axios: 'axios',
418
+ 'remark-html': 'remarkHtml',
419
+ 'react-select': 'Select',
420
+ 'react-plotly.js': 'Plotly',
421
+ three: 'THREE',
422
+ 'echarts-gl': 'echartsGL',
423
+ '@react-three/fiber': 'ReactThreeFiber',
424
+ '@react-three/drei': 'ReactThreeDrei',
425
+ },
426
+ exports: 'named',
427
+ sourcemap: SOURCEMAP,
428
+ inlineDynamicImports: true,
429
+ // Preserve dynamic imports for 3D lazy loading
430
+ // Dynamic import() statements will be preserved for runtime loading
431
+ banner: `/*! Visualify v${PACKAGE_VERSION} | Portal Bundle */`,
432
+ },
433
+ {
434
+ file: 'dist/visualify-portal.esm.js',
435
+ format: 'esm',
436
+ sourcemap: SOURCEMAP,
437
+ inlineDynamicImports: true,
438
+ banner: `/*! Visualify v${PACKAGE_VERSION} | Portal ESM */`,
439
+ // Preserve dynamic imports for 3D lazy loading
440
+ // Three.js and ECharts GL will be loaded on demand
441
+ },
442
+ ],
443
+ external: EXTERNAL_DEPS,
444
+ plugins: [
445
+ ...createCommonPlugins({ isProduction: true }),
446
+ ...createProductionPlugins(),
447
+ ],
448
+ onwarn,
449
+ };
450
+
451
+ /**
452
+ * Shared chunk configuration
453
+ * Code-splitting for components used by both docs and portal
454
+ */
455
+ const sharedConfig = {
456
+ input: 'src/entries/shared.js',
457
+ output: [
458
+ {
459
+ file: 'dist/visualify-shared.js',
460
+ format: 'esm',
461
+ sourcemap: SOURCEMAP,
462
+ banner: `/*! Visualify v${PACKAGE_VERSION} | Shared Components */`,
463
+ },
464
+ ],
465
+ external: EXTERNAL_DEPS,
466
+ plugins: createCommonPlugins({ isProduction: true }),
467
+ onwarn,
468
+ };
469
+
470
+ /**
471
+ * Legacy single-file build — IIFE for direct <script> tag usage
472
+ * Externalizes heavy libraries (echarts, plotly, three) to keep bundle under 4MB.
473
+ * IMPORTANT: CDN <script> tags for echarts/plotly MUST load before this bundle.
474
+ * Use dist/visualify-loader.js for automatic CDN loading.
475
+ */
476
+ const legacyConfig = {
477
+ input: 'src/index.js',
478
+ output: {
479
+ file: 'dist/visualify.js',
480
+ format: 'iife',
481
+ name: 'Visualify',
482
+ sourcemap: SOURCEMAP,
483
+ inlineDynamicImports: true,
484
+ banner: `/*! Visualify v${PACKAGE_VERSION} | Legacy Build (requires echarts + plotly CDN) */`,
485
+ globals: {
486
+ 'echarts': 'echarts',
487
+ 'echarts-gl': 'echartsGL',
488
+ 'plotly.js': 'Plotly',
489
+ 'plotly.js/dist/plotly': 'Plotly',
490
+ },
491
+ },
492
+ // Externalize heavy visualization libraries — MUST be loaded via CDN first
493
+ external: (id) => {
494
+ if (['echarts', 'echarts-gl'].includes(id)) return true;
495
+ if (id.startsWith('plotly.js')) return true;
496
+ return false;
497
+ },
498
+ plugins: [
499
+ ...createCommonPlugins({ isProduction: true }),
500
+ terser({
501
+ compress: {
502
+ drop_console: false,
503
+ drop_debugger: true,
504
+ keep_classnames: true,
505
+ keep_fnames: true,
506
+ },
507
+ mangle: {
508
+ keep_classnames: true,
509
+ keep_fnames: true,
510
+ },
511
+ format: {
512
+ comments: false,
513
+ },
514
+ }),
515
+ ],
516
+ onwarn,
517
+ };
518
+
519
+ /**
520
+ * Docs static bundle - Used by the documentation site
521
+ * Same externalization as legacy — docs/index.html has CDN scripts
522
+ */
523
+ const docsStaticConfig = {
524
+ input: 'src/index.js',
525
+ output: {
526
+ file: 'docs/static/js/visualify.js',
527
+ format: 'iife',
528
+ name: 'Visualify',
529
+ sourcemap: false,
530
+ inlineDynamicImports: true,
531
+ banner: `/*! Visualify v${PACKAGE_VERSION} | Docs Static Bundle (requires echarts + plotly CDN) */`,
532
+ globals: {
533
+ 'echarts': 'echarts',
534
+ 'echarts-gl': 'echartsGL',
535
+ 'plotly.js': 'Plotly',
536
+ 'plotly.js/dist/plotly': 'Plotly',
537
+ },
538
+ },
539
+ external: (id) => {
540
+ if (['echarts', 'echarts-gl'].includes(id)) return true;
541
+ if (id.startsWith('plotly.js')) return true;
542
+ return false;
543
+ },
544
+ plugins: [
545
+ ...createCommonPlugins({ isProduction: true }),
546
+ terser({
547
+ compress: {
548
+ drop_console: false,
549
+ drop_debugger: true,
550
+ keep_classnames: true,
551
+ keep_fnames: true,
552
+ },
553
+ mangle: {
554
+ keep_classnames: true,
555
+ keep_fnames: true,
556
+ },
557
+ format: {
558
+ comments: false,
559
+ },
560
+ }),
561
+ ],
562
+ onwarn,
563
+ };
564
+
565
+ // =============================================================================
566
+ // On-Demand Chunk Configurations (v3 Bundle Splitting)
567
+ // =============================================================================
568
+
569
+ /**
570
+ * Core 2D Charts chunk
571
+ * Lightweight bundle with only core charting capabilities
572
+ */
573
+ const coreConfig = {
574
+ input: 'src/entries/core.js',
575
+ output: [
576
+ {
577
+ file: 'dist/visualify-core.js',
578
+ format: 'umd',
579
+ name: 'VisualifyCore',
580
+ globals: COMMON_GLOBALS,
581
+ exports: 'named',
582
+ sourcemap: SOURCEMAP,
583
+ inlineDynamicImports: true,
584
+ banner: `/*! VisualifyCore v${PACKAGE_VERSION} | Core 2D Charts */`,
585
+ },
586
+ {
587
+ file: 'dist/visualify-core.esm.js',
588
+ format: 'esm',
589
+ sourcemap: SOURCEMAP,
590
+ inlineDynamicImports: true,
591
+ banner: `/*! VisualifyCore v${PACKAGE_VERSION} | Core 2D Charts ESM */`,
592
+ },
593
+ ],
594
+ external: EXTERNAL_DEPS,
595
+ plugins: [
596
+ ...createCommonPlugins({ isProduction: true }),
597
+ ...createProductionPlugins(),
598
+ ],
599
+ onwarn,
600
+ };
601
+
602
+ /**
603
+ * 3D Charts chunk
604
+ * Loaded on demand when 3D chart types are used
605
+ * External: three, echarts-gl, @react-three/*
606
+ */
607
+ const charts3dConfig = {
608
+ input: 'src/entries/charts3d.js',
609
+ output: [
610
+ {
611
+ file: 'dist/visualify-3d.js',
612
+ format: 'umd',
613
+ name: 'Visualify3D',
614
+ globals: COMMON_GLOBALS,
615
+ exports: 'named',
616
+ sourcemap: SOURCEMAP,
617
+ inlineDynamicImports: true,
618
+ banner: `/*! Visualify3D v${PACKAGE_VERSION} | 3D Charts Chunk */`,
619
+ },
620
+ {
621
+ file: 'dist/visualify-3d.esm.js',
622
+ format: 'esm',
623
+ sourcemap: SOURCEMAP,
624
+ inlineDynamicImports: true,
625
+ banner: `/*! Visualify3D v${PACKAGE_VERSION} | 3D Charts ESM */`,
626
+ },
627
+ ],
628
+ external: EXTERNAL_DEPS,
629
+ plugins: [
630
+ ...createCommonPlugins({ isProduction: true }),
631
+ ...createProductionPlugins(),
632
+ ],
633
+ onwarn,
634
+ };
635
+
636
+ /**
637
+ * Page Mode chunk
638
+ * Loaded on demand for full portal/application usage
639
+ */
640
+ const pagesConfig = {
641
+ input: 'src/entries/pages.js',
642
+ output: [
643
+ {
644
+ file: 'dist/visualify-pages.js',
645
+ format: 'umd',
646
+ name: 'VisualifyPages',
647
+ globals: COMMON_GLOBALS,
648
+ exports: 'named',
649
+ sourcemap: SOURCEMAP,
650
+ inlineDynamicImports: true,
651
+ banner: `/*! VisualifyPages v${PACKAGE_VERSION} | Page Mode Chunk */`,
652
+ },
653
+ {
654
+ file: 'dist/visualify-pages.esm.js',
655
+ format: 'esm',
656
+ sourcemap: SOURCEMAP,
657
+ inlineDynamicImports: true,
658
+ banner: `/*! VisualifyPages v${PACKAGE_VERSION} | Page Mode ESM */`,
659
+ },
660
+ ],
661
+ external: EXTERNAL_DEPS,
662
+ plugins: [
663
+ ...createCommonPlugins({ isProduction: true }),
664
+ ...createProductionPlugins(),
665
+ ],
666
+ onwarn,
667
+ };
668
+
669
+ /**
670
+ * CDN Loader — tiny bootstrap script that auto-loads CDN deps then visualify.js
671
+ * Users include just one <script> tag instead of multiple CDN + visualify tags
672
+ */
673
+ const loaderConfig = {
674
+ input: 'src/loader.js',
675
+ output: {
676
+ file: 'dist/visualify-loader.js',
677
+ format: 'iife',
678
+ banner: `/*! Visualify Loader v${PACKAGE_VERSION} | Auto-loads CDN deps + visualify.js */`,
679
+ },
680
+ plugins: [
681
+ terser({
682
+ compress: { drop_console: false, drop_debugger: true },
683
+ format: { comments: false },
684
+ }),
685
+ ],
686
+ onwarn,
687
+ };
688
+
689
+ // =============================================================================
690
+ // Development Configuration (when NODE_ENV=development)
691
+ // =============================================================================
692
+
693
+ const isDevelopment = process.env.NODE_ENV === 'development';
694
+
695
+ if (isDevelopment) {
696
+ // Add visualizer in development builds
697
+ docsConfig.plugins.push(createVisualizerPlugin('stats-docs.html'));
698
+ portalConfig.plugins.push(createVisualizerPlugin('stats-portal.html'));
699
+ portalConfig.plugins.push(createVisualizerPlugin('stats.html'));
700
+ }
701
+
702
+ // =============================================================================
703
+ // Export Configuration Array
704
+ // =============================================================================
705
+
706
+ /**
707
+ * Export all build configurations
708
+ * Rollup will build each configuration in parallel
709
+ */
710
+ export default [
711
+ // Primary dual-mode builds
712
+ docsConfig,
713
+ portalConfig,
714
+
715
+ // Shared components chunk
716
+ sharedConfig,
717
+
718
+ // Legacy compatibility build
719
+ legacyConfig,
720
+
721
+ // Docs static bundle (self-contained)
722
+ docsStaticConfig,
723
+
724
+ // On-demand chunks (v3 bundle splitting)
725
+ coreConfig,
726
+ charts3dConfig,
727
+ pagesConfig,
728
+
729
+ // CDN loader (tiny bootstrap)
730
+ loaderConfig,
731
+ ];
732
+
733
+ // =============================================================================
734
+ // Build Output Summary (logged during build)
735
+ // =============================================================================
736
+
737
+ console.log(`
738
+ ╔══════════════════════════════════════════════════════════════╗
739
+ ║ Visualify.js Build System v${PACKAGE_VERSION.padEnd(16)}║
740
+ ╠══════════════════════════════════════════════════════════════╣
741
+ ║ Build Targets: ║
742
+ ║ • visualify-docs.js - Docsify UMD bundle ║
743
+ ║ • visualify-docs.esm.js - Docsify ESM bundle ║
744
+ ║ • visualify-portal.js - Portal UMD bundle ║
745
+ ║ • visualify-portal.esm.js- Portal ESM bundle ║
746
+ ║ • visualify-shared.js - Shared components ║
747
+ ║ • visualify.js - Legacy build (backward compat) ║
748
+ ║ • stats.html - Bundle analysis ║
749
+ ╠══════════════════════════════════════════════════════════════╣
750
+ ║ On-Demand Chunks (v3): ║
751
+ ║ • visualify-core.js - Core 2D charts only ║
752
+ ║ • visualify-3d.js - 3D visualization chunk ║
753
+ ║ • visualify-pages.js - Page mode components ║
754
+ ╠══════════════════════════════════════════════════════════════╣
755
+ ║ Size Thresholds: ║
756
+ ║ • Docs: ${String(SIZE_THRESHOLDS.docs).padStart(4)} KB │ Core: ${String(SIZE_THRESHOLDS.core).padStart(4)} KB ║
757
+ ║ • Portal: ${String(SIZE_THRESHOLDS.portal).padStart(4)} KB │ 3D: ${String(SIZE_THRESHOLDS.charts3d).padStart(4)} KB ║
758
+ ║ • Shared: ${String(SIZE_THRESHOLDS.shared).padStart(4)} KB │ Pages: ${String(SIZE_THRESHOLDS.pages).padStart(4)} KB ║
759
+ ╠══════════════════════════════════════════════════════════════╣
760
+ ║ 3D Dependencies (External): ║
761
+ ║ • three - Three.js core library ║
762
+ ║ • @react-three/fiber - React renderer for Three.js ║
763
+ ║ • @react-three/drei - Useful helpers for R3F ║
764
+ ║ • echarts-gl - ECharts GL extension ║
765
+ ╚══════════════════════════════════════════════════════════════╝
766
+ `);