visualifyjs 2.5.3 → 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.
- package/.claude/mem/TIMELINE.md +36 -0
- package/.claude/mem/notes/2026-02-11-3d-visualization-docs-fix-external-script-solution.md +24 -0
- package/.claude/mem/notes/2026-02-11-3d-visualization-docs-fix-session-summary.md +43 -0
- package/.claude/mem/notes/2026-02-11-cli-fix-editor-command-alias.md +26 -0
- package/.claude/mem/notes/2026-02-11-phase-3-developer-experience-completed.md +51 -0
- package/.claude/mem/notes/2026-02-11-phase-4-web-workers-implementation-complete.md +59 -0
- package/.claude/mem/notes/2026-02-11-visualify-phase-2-3d-visualization-complete.md +50 -0
- package/.claude/mem/notes/2026-02-11-visualify-phase-2-committed-ready-for-phase-3.md +33 -0
- package/.claude/mem/notes/2026-02-11-visualify-phase-3-complete-developer-experience.md +52 -0
- package/.claude/mem/notes/2026-02-11-visualify-repository-cleanup-complete.md +28 -0
- package/.claude/mem/notes/2026-02-18-codebase-cleanup-docsify-plugin-documentation.md +37 -0
- package/.claude/mem/notes/2026-02-19-css-grid-layout-fix-displaycontents-on-vcontroller.md +18 -0
- package/.claude/mem/notes/2026-02-19-docsify-plugin-fixes-latex-and-visualify-code-bloc.md +26 -0
- package/.claude/mem/notes/2026-02-19-page-mode-docs-update-decisions.md +23 -0
- package/.claude/mem/notes/2026-02-19-react-context-infinite-re-render-loop-fix-pattern.md +31 -0
- package/.claude/mem/notes/2026-02-19-version-300-bump-and-build-fixes.md +32 -0
- package/.claude/mem/notes/2026-02-19-visualify-build-deployment-architecture-bug-fixes.md +25 -0
- package/.claude/mem/notes/2026-02-19-visualify-dist-iife-self-contained-build-config.md +30 -0
- package/.claude/mem/notes/2026-02-19-visualify-infinite-loop-i18n-fixes.md +31 -0
- package/.claude/mem/notes/2026-02-19-visualify-v3-bundle-splitting-docs-restructuring.md +32 -0
- package/.claude/mem/notes/2026-02-20-bundle-externalization-final-architecture.md +29 -0
- package/.claude/mem/notes/2026-02-20-chromium-page-fix-unstable-keys-and-double-event-b.md +27 -0
- package/.claude/mem/notes/2026-02-20-console-cleanup-bundle-optimization-commit.md +20 -0
- package/.claude/mem/notes/2026-02-20-dotbio-dot-plot-fix-useeffect-dependency.md +21 -0
- package/.claude/mem/notes/2026-02-20-public-folder-cleanup-and-readme-rewrite.md +25 -0
- package/.claude/mem/notes/2026-02-20-v300-release-and-beta-channel-strategy.md +29 -0
- package/.claude/mem/notes/2026-02-20-visium-background-image-unknown-legend-fix.md +19 -0
- package/.claude/mem/notes/2026-02-20-visualify-cdn-loader-bundle-externalization.md +34 -0
- package/.claude/mem/sessions/session-2026-02-20-031524.md +54 -0
- package/.claude/settings.local.json +21 -0
- package/.github/workflows/static.yml.bak +51 -51
- package/.sisyphus/boulder.json +65 -0
- package/.sisyphus/plans/phase-4-advanced-optimizations.md +217 -0
- package/LICENSE +674 -674
- package/README.md +94 -59
- package/config-overrides.js +31 -31
- package/dist/stats.html +4949 -0
- package/dist/visualify-3d.esm.js +1 -0
- package/dist/visualify-3d.js +1 -0
- package/dist/visualify-core.esm.js +1 -0
- package/dist/visualify-core.js +1 -0
- package/dist/visualify-docs.esm.js +1 -0
- package/dist/visualify-docs.js +1 -0
- package/dist/visualify-loader.js +1 -0
- package/dist/visualify-pages.esm.js +1 -0
- package/dist/visualify-pages.js +1 -0
- package/dist/visualify-portal.esm.js +1 -0
- package/dist/visualify-portal.js +1 -0
- package/dist/visualify-shared.js +26571 -0
- package/dist/visualify.js +1 -188
- package/docs/CHANGELOG.md +148 -0
- package/docs/cli/commands.md +513 -0
- package/docs/configuration/visualify-json.md +474 -0
- package/docs/docs/3d-visualization.md +374 -0
- package/docs/docs/CLI.md +303 -34
- package/docs/docs/README.md +65 -65
- package/docs/docs/Rechart/bar.md +190 -190
- package/docs/docs/Rechart/funnel.md +241 -193
- package/docs/docs/Rechart/line.md +355 -355
- package/docs/docs/Rechart/pie.md +225 -225
- package/docs/docs/Rechart/radar.md +253 -253
- package/docs/docs/Rechart/scatter.md +298 -0
- package/docs/docs/_404.md +51 -51
- package/docs/docs/_coverpage.md +11 -11
- package/docs/docs/_sidebar.md +54 -43
- package/docs/docs/components/dotBio.md +87 -34
- package/docs/docs/components/echart.md +171 -82
- package/docs/docs/components/html.md +61 -34
- package/docs/docs/components/macaron.md +156 -145
- package/docs/docs/components/markdown.md +42 -0
- package/docs/docs/components/more.md +183 -142
- package/docs/docs/components/plotly.md +132 -62
- package/docs/docs/components/scatterL.md +171 -70
- package/docs/docs/components/visium.md +112 -57
- package/docs/docs/configuration.md +121 -123
- package/docs/docs/deploy.md +31 -31
- package/docs/docs/docsify-plugin.md +655 -0
- package/docs/docs/hmr.md +165 -0
- package/docs/docs/i18n.md +332 -0
- package/docs/docs/log.md +30 -1
- package/docs/docs/more-pages.md +23 -23
- package/docs/docs/quickstart.md +148 -119
- package/docs/docs/rechart-attributes.md +74 -74
- package/docs/docs/rechart-basic-usage.md +160 -162
- package/docs/docs/theme.md +5 -5
- package/docs/docs/typescript.md +306 -0
- package/docs/docs/visual-editor.md +359 -0
- package/docs/index.html +85 -71
- package/docs/manifest.json +23 -23
- package/docs/migration/v3-migration.md +392 -0
- package/docs/static/css/fluff-stuff.css +169 -169
- package/docs/static/css/font-awesome.min.css +4 -4
- package/docs/static/css/visualify.css +6 -25
- package/docs/static/js/3d-viz-examples.js +181 -0
- package/docs/static/js/configuration.js +630 -448
- package/docs/static/js/visualify.js +1 -188
- package/package.json +106 -84
- package/rollup.config.mjs +766 -76
- package/src/_css/404.css +115 -115
- package/src/_css/App.css +37 -37
- package/src/_css/autoSuggestion.css +26 -26
- package/src/_css/circular-progress.css +32 -32
- package/src/_css/index.css +36 -36
- package/src/_css/modern.css +350 -25
- package/src/_media/corner.svg +8 -8
- package/src/_media/download.svg +3 -3
- package/src/_media/logo.svg +14 -14
- package/src/_test/App.test.js +15 -15
- package/src/_utils/reportWebVitals.js +13 -13
- package/src/a11y/README.md +177 -0
- package/src/a11y/aria-labels.js +339 -0
- package/src/a11y/color-contrast.js +535 -0
- package/src/a11y/index.js +197 -0
- package/src/a11y/keyboard-nav.js +523 -0
- package/src/a11y/styles.css +165 -0
- package/src/cli/commands/dev.js +214 -0
- package/src/cli/commands/docs.js +521 -0
- package/src/cli/commands/edit.js +379 -0
- package/src/cli/commands/init.js +213 -0
- package/src/cli/commands/portal.js +236 -0
- package/src/cli/dev-server.js +530 -0
- package/src/cli/hmr.js +456 -0
- package/src/cli/index.js +180 -0
- package/src/cli/utils/config.js +207 -0
- package/src/cli/utils/logger.js +241 -0
- package/src/config/defaults.ts +122 -0
- package/src/config/index.ts +72 -0
- package/src/config/loader.ts +478 -0
- package/src/config/schema.ts +227 -0
- package/src/config/validator.ts +337 -0
- package/src/core/appContext.js +34 -27
- package/src/core/components/Bar.js +383 -0
- package/src/core/components/Bar3D.js +473 -0
- package/src/core/components/LargeDatasetChart.js +296 -0
- package/src/core/components/Line3D.js +310 -0
- package/src/core/components/Scatter.js +392 -188
- package/src/core/components/Scatter3D.js +455 -0
- package/src/core/components/ScatterBio.js +601 -572
- package/src/core/components/Surface3D.js +326 -0
- package/src/core/components/ThreeCustom.js +648 -0
- package/src/core/components/ThreeScene.js +459 -0
- package/src/core/components/VisiumPlot.js +191 -165
- package/src/core/components/browser.js +42 -42
- package/src/core/components/dotplot.js +413 -413
- package/src/core/components/html.js +29 -29
- package/src/core/components/list.js +178 -178
- package/src/core/components/macaron.js +206 -201
- package/src/core/components/markdown.js +56 -56
- package/src/core/components/parser.scatterBio.js +582 -579
- package/src/core/components/ratio.js +82 -80
- package/src/core/components/scatterL.js +206 -173
- package/src/core/components/searchbar.js +156 -131
- package/src/core/components/selection.js +310 -193
- package/src/core/components/timeline.js +236 -281
- package/src/core/components/visium.js +114 -97
- package/src/core/data-processor.js +413 -0
- package/src/core/fetch/condfetch.js +82 -82
- package/src/core/fetch/fetch.js +92 -92
- package/src/core/fetch/json.js +29 -29
- package/src/core/fetch/vfetch.js +42 -42
- package/src/core/hmr-client.js +724 -0
- package/src/core/liveEditor.js +44 -44
- package/src/core/modules/codeEditorWithPreview.js +104 -104
- package/src/core/modules/echarts/common.js +20 -20
- package/src/core/modules/echarts/gl.js +228 -0
- package/src/core/modules/echarts/presetHandler.js +41 -41
- package/src/core/modules/echarts/presets/esodev.chromium.js +172 -172
- package/src/core/modules/echarts/presets/esodev.codex.js +130 -130
- package/src/core/modules/echarts/presets/esodev.visium.js +123 -123
- package/src/core/modules/echarts/presets/mmtrbc.js +186 -186
- package/src/core/modules/echarts.js +70 -71
- package/src/core/modules/echartsUtils.js +43 -43
- package/src/core/modules/echartswitcher.js +227 -152
- package/src/core/modules/replotly/presetHandler.js +24 -24
- package/src/core/modules/replotly/presets/minimum.js +18 -18
- package/src/core/modules/replotly/presets/mmtrbc.dot.js +114 -114
- package/src/core/modules/replotly/presets/mmtrbc.violin.js +100 -100
- package/src/core/modules/replotly.js +74 -71
- package/src/core/modules/threejs/Camera.js +373 -0
- package/src/core/modules/threejs/Lighting.js +459 -0
- package/src/core/modules/threejs/Renderer.js +364 -0
- package/src/core/modules/threejs/Scene.js +266 -0
- package/src/core/modules/threejs/index.js +155 -0
- package/src/core/pages/404.js +50 -50
- package/src/core/pages/error.js +27 -27
- package/src/core/pages/jsonPage.js +62 -62
- package/src/core/pages/loading.js +44 -44
- package/src/core/parser/echart.data.js +204 -183
- package/src/core/parser/echart.features.js +125 -125
- package/src/core/parser/echart.general.js +147 -143
- package/src/core/parser/echart.hilbert.js +57 -57
- package/src/core/parser/echart.parser.js +210 -210
- package/src/core/parser/echart.series.js +67 -67
- package/src/core/parser/echart.types.js +76 -76
- package/src/core/parser/plotly.config.js +10 -10
- package/src/core/parser/plotly.data.js +132 -132
- package/src/core/parser/plotly.layout.js +9 -9
- package/src/core/parser/plotly.violin.js +18 -18
- package/src/core/recharts.js +361 -62
- package/src/core/router/alias.js +49 -49
- package/src/core/router/jsonRouter.js +31 -31
- package/src/core/themes/modern.js +32 -32
- package/src/core/themes/themeSelector.js +33 -33
- package/src/core/visualify.js +213 -47
- package/src/core/widgets/circularProgress.js +23 -23
- package/src/core/widgets/controller.js +116 -83
- package/src/core/widgets/errorBoundary.js +36 -36
- package/src/core/widgets/footer.js +185 -177
- package/src/core/widgets/header.js +238 -234
- package/src/core/widgets/layout/Grid.js +31 -31
- package/src/core/widgets/layout.js +36 -36
- package/src/core/widgets/mapping.js +56 -42
- package/src/core/workers/data-worker.js +349 -0
- package/src/core/workers/worker-pool.js +396 -0
- package/src/docsify/bundle.js +215 -0
- package/src/docsify/markdown.js +271 -0
- package/src/docsify/plugin.js +268 -0
- package/src/editor/README.md +172 -0
- package/src/editor/components/ChartBuilder.jsx +341 -0
- package/src/editor/components/ChartTypeSidebar.jsx +91 -0
- package/src/editor/components/Editor.jsx +367 -0
- package/src/editor/components/Preview.jsx +446 -0
- package/src/editor/components/PropertyPanel.jsx +468 -0
- package/src/editor/components/StatusBar.jsx +85 -0
- package/src/editor/context/EditorContext.js +248 -0
- package/src/editor/hooks/useDebounce.js +32 -0
- package/src/editor/index.js +315 -0
- package/src/editor/styles/editor.css +637 -0
- package/src/editor/utils/chartValidator.js +263 -0
- package/src/entries/charts3d.js +70 -0
- package/src/entries/core.js +78 -0
- package/src/entries/docs.js +154 -0
- package/src/entries/pages.js +93 -0
- package/src/entries/portal.js +204 -0
- package/src/entries/shared.js +50 -0
- package/src/i18n/formatters.js +455 -0
- package/src/i18n/index.js +169 -0
- package/src/i18n/locales/ar.json +137 -0
- package/src/i18n/locales/de.json +137 -0
- package/src/i18n/locales/en.json +137 -0
- package/src/i18n/locales/es.json +137 -0
- package/src/i18n/locales/he.json +137 -0
- package/src/i18n/locales/zh.json +137 -0
- package/src/i18n/rtl.css +183 -0
- package/src/index.js +82 -62
- package/src/loader.js +103 -0
- package/src/setupTests.js +5 -5
- package/tsconfig.json +51 -0
- package/types/charts.d.ts +569 -0
- package/types/components.d.ts +441 -0
- package/types/config.d.ts +199 -0
- package/types/index.d.ts +353 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Configuration utilities for Visualify CLI
|
|
3
|
+
* @module cli/utils/config
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require('fs').promises;
|
|
7
|
+
const path = require('path');
|
|
8
|
+
const logger = require('./logger');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Configuration file names to search for
|
|
12
|
+
* @readonly
|
|
13
|
+
* @type {string[]}
|
|
14
|
+
*/
|
|
15
|
+
const CONFIG_FILES = ['visualify.json', '.visualify.json'];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Default configuration values
|
|
19
|
+
* @readonly
|
|
20
|
+
* @type {Object}
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_CONFIG = {
|
|
23
|
+
mode: 'auto',
|
|
24
|
+
port: 3000,
|
|
25
|
+
host: 'localhost',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Check if a file exists
|
|
30
|
+
* @param {string} filePath - Path to check
|
|
31
|
+
* @returns {Promise<boolean>} Whether the file exists
|
|
32
|
+
*/
|
|
33
|
+
async function fileExists(filePath) {
|
|
34
|
+
try {
|
|
35
|
+
await fs.access(filePath);
|
|
36
|
+
return true;
|
|
37
|
+
} catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Find the configuration file in the current directory
|
|
44
|
+
* @returns {Promise<string|null>} Path to config file or null
|
|
45
|
+
*/
|
|
46
|
+
async function findConfigFile() {
|
|
47
|
+
const cwd = process.cwd();
|
|
48
|
+
|
|
49
|
+
for (const configFile of CONFIG_FILES) {
|
|
50
|
+
const configPath = path.join(cwd, configFile);
|
|
51
|
+
if (await fileExists(configPath)) {
|
|
52
|
+
logger.debug(`Found config file: ${configPath}`);
|
|
53
|
+
return configPath;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
logger.debug('No config file found');
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Load and parse the configuration file
|
|
63
|
+
* @param {string} [configPath] - Path to config file (optional)
|
|
64
|
+
* @returns {Promise<Object>} Merged configuration object
|
|
65
|
+
*/
|
|
66
|
+
async function loadConfig(configPath) {
|
|
67
|
+
const targetPath = configPath || (await findConfigFile());
|
|
68
|
+
|
|
69
|
+
if (!targetPath) {
|
|
70
|
+
logger.debug('Using default configuration');
|
|
71
|
+
return { ...DEFAULT_CONFIG };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const content = await fs.readFile(targetPath, 'utf-8');
|
|
76
|
+
const parsed = JSON.parse(content);
|
|
77
|
+
logger.debug(`Loaded config from ${targetPath}`);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
...DEFAULT_CONFIG,
|
|
81
|
+
...parsed,
|
|
82
|
+
};
|
|
83
|
+
} catch (err) {
|
|
84
|
+
if (err instanceof SyntaxError) {
|
|
85
|
+
logger.error(`Invalid JSON in config file: ${targetPath}`);
|
|
86
|
+
throw new Error(`Failed to parse config file: ${err.message}`);
|
|
87
|
+
}
|
|
88
|
+
logger.error(`Failed to read config file: ${targetPath}`);
|
|
89
|
+
throw err;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Detect the project mode based on file structure
|
|
95
|
+
* @returns {Promise<string>} Detected mode ('docs' or 'portal')
|
|
96
|
+
*/
|
|
97
|
+
async function detectMode() {
|
|
98
|
+
const cwd = process.cwd();
|
|
99
|
+
logger.debug('Detecting mode from file structure...');
|
|
100
|
+
|
|
101
|
+
// Check for docs directory with markdown files
|
|
102
|
+
const docsPath = path.join(cwd, 'docs');
|
|
103
|
+
if (await fileExists(docsPath)) {
|
|
104
|
+
try {
|
|
105
|
+
const files = await fs.readdir(docsPath);
|
|
106
|
+
const hasMarkdown = files.some(
|
|
107
|
+
(file) => file.endsWith('.md') || file.endsWith('.mdx')
|
|
108
|
+
);
|
|
109
|
+
if (hasMarkdown) {
|
|
110
|
+
logger.debug('Found docs directory with markdown files');
|
|
111
|
+
return 'docs';
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
logger.debug('Error reading docs directory:', err.message);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Check for portal indicators
|
|
119
|
+
const portalIndicators = [
|
|
120
|
+
'src/pages',
|
|
121
|
+
'src/routes',
|
|
122
|
+
'visualify.config.js',
|
|
123
|
+
'src/App.jsx',
|
|
124
|
+
'src/App.tsx',
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
for (const indicator of portalIndicators) {
|
|
128
|
+
const indicatorPath = path.join(cwd, indicator);
|
|
129
|
+
if (await fileExists(indicatorPath)) {
|
|
130
|
+
logger.debug(`Found portal indicator: ${indicator}`);
|
|
131
|
+
return 'portal';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Default to docs if we can't determine
|
|
136
|
+
logger.debug('Could not detect mode, defaulting to docs');
|
|
137
|
+
logger.warn('Could not auto-detect project mode, defaulting to docs');
|
|
138
|
+
logger.tip('Create a visualify.json file to specify mode explicitly');
|
|
139
|
+
return 'docs';
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Get the configured mode from config or auto-detect
|
|
144
|
+
* @returns {Promise<string>} The mode to use
|
|
145
|
+
*/
|
|
146
|
+
async function getMode() {
|
|
147
|
+
const config = await loadConfig();
|
|
148
|
+
|
|
149
|
+
if (config.mode && config.mode !== 'auto') {
|
|
150
|
+
logger.debug(`Using configured mode: ${config.mode}`);
|
|
151
|
+
return config.mode;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return detectMode();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Save configuration to file
|
|
159
|
+
* @param {Object} config - Configuration object to save
|
|
160
|
+
* @param {string} [configPath] - Path to save to (defaults to visualify.json)
|
|
161
|
+
* @returns {Promise<void>}
|
|
162
|
+
*/
|
|
163
|
+
async function saveConfig(config, configPath = 'visualify.json') {
|
|
164
|
+
try {
|
|
165
|
+
const content = JSON.stringify(config, null, 2);
|
|
166
|
+
await fs.writeFile(configPath, content, 'utf-8');
|
|
167
|
+
logger.debug(`Saved config to ${configPath}`);
|
|
168
|
+
} catch (err) {
|
|
169
|
+
logger.error(`Failed to save config to ${configPath}:`, err.message);
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Validate configuration object
|
|
176
|
+
* @param {Object} config - Configuration to validate
|
|
177
|
+
* @returns {Object} Validation result with isValid and errors
|
|
178
|
+
*/
|
|
179
|
+
function validateConfig(config) {
|
|
180
|
+
const errors = [];
|
|
181
|
+
const validModes = ['auto', 'docs', 'portal'];
|
|
182
|
+
|
|
183
|
+
if (config.mode && !validModes.includes(config.mode)) {
|
|
184
|
+
errors.push(`Invalid mode: "${config.mode}". Must be one of: ${validModes.join(', ')}`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (config.port && (typeof config.port !== 'number' || config.port < 1 || config.port > 65535)) {
|
|
188
|
+
errors.push('Invalid port: must be a number between 1 and 65535');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
isValid: errors.length === 0,
|
|
193
|
+
errors,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
module.exports = {
|
|
198
|
+
CONFIG_FILES,
|
|
199
|
+
DEFAULT_CONFIG,
|
|
200
|
+
fileExists,
|
|
201
|
+
findConfigFile,
|
|
202
|
+
loadConfig,
|
|
203
|
+
detectMode,
|
|
204
|
+
getMode,
|
|
205
|
+
saveConfig,
|
|
206
|
+
validateConfig,
|
|
207
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Colored logging utility for Visualify CLI with i18n support
|
|
3
|
+
* @module cli/utils/logger
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const chalk = require('chalk');
|
|
7
|
+
|
|
8
|
+
// Simple i18n for CLI (Node.js compatible)
|
|
9
|
+
let currentLocale = 'en';
|
|
10
|
+
const translations = {};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Load translations for a locale
|
|
14
|
+
* @param {string} locale - Locale code
|
|
15
|
+
* @param {Object} messages - Translation messages
|
|
16
|
+
*/
|
|
17
|
+
function loadTranslations(locale, messages) {
|
|
18
|
+
translations[locale] = { ...translations[locale], ...messages };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Set the current locale for CLI messages
|
|
23
|
+
* @param {string} locale - Locale code
|
|
24
|
+
*/
|
|
25
|
+
function setLocale(locale) {
|
|
26
|
+
currentLocale = locale;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the current locale
|
|
31
|
+
* @returns {string} Current locale code
|
|
32
|
+
*/
|
|
33
|
+
function getLocale() {
|
|
34
|
+
return currentLocale;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Translate a key with optional interpolation
|
|
39
|
+
* @param {string} key - Translation key
|
|
40
|
+
* @param {Object} params - Interpolation parameters
|
|
41
|
+
* @returns {string} Translated string
|
|
42
|
+
*/
|
|
43
|
+
function t(key, params = {}) {
|
|
44
|
+
const messages = translations[currentLocale] || translations['en'] || {};
|
|
45
|
+
let message = key.split('.').reduce((obj, k) => obj?.[k], messages) || key;
|
|
46
|
+
|
|
47
|
+
// Simple interpolation: {key} -> value
|
|
48
|
+
Object.keys(params).forEach((param) => {
|
|
49
|
+
message = message.replace(new RegExp(`{${param}}`, 'g'), params[param]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return message;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Load default English translations
|
|
56
|
+
loadTranslations('en', {
|
|
57
|
+
cli: {
|
|
58
|
+
debug: 'debug',
|
|
59
|
+
info: 'info',
|
|
60
|
+
warn: 'warn',
|
|
61
|
+
error: 'error',
|
|
62
|
+
success: 'success',
|
|
63
|
+
tip: 'tip',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
loadTranslations('zh', {
|
|
68
|
+
cli: {
|
|
69
|
+
debug: '调试',
|
|
70
|
+
info: '信息',
|
|
71
|
+
warn: '警告',
|
|
72
|
+
error: '错误',
|
|
73
|
+
success: '成功',
|
|
74
|
+
tip: '提示',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
loadTranslations('es', {
|
|
79
|
+
cli: {
|
|
80
|
+
debug: 'depurar',
|
|
81
|
+
info: 'info',
|
|
82
|
+
warn: 'advertencia',
|
|
83
|
+
error: 'error',
|
|
84
|
+
success: 'éxito',
|
|
85
|
+
tip: 'consejo',
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
loadTranslations('de', {
|
|
90
|
+
cli: {
|
|
91
|
+
debug: 'debug',
|
|
92
|
+
info: 'info',
|
|
93
|
+
warn: 'warnung',
|
|
94
|
+
error: 'fehler',
|
|
95
|
+
success: 'erfolg',
|
|
96
|
+
tip: 'tipp',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Log level constants
|
|
102
|
+
* @readonly
|
|
103
|
+
* @enum {number}
|
|
104
|
+
*/
|
|
105
|
+
const LOG_LEVELS = {
|
|
106
|
+
DEBUG: 0,
|
|
107
|
+
INFO: 1,
|
|
108
|
+
WARN: 2,
|
|
109
|
+
ERROR: 3,
|
|
110
|
+
SUCCESS: 4,
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Current log level (can be overridden by --verbose flag)
|
|
115
|
+
* @type {number}
|
|
116
|
+
*/
|
|
117
|
+
let currentLogLevel = LOG_LEVELS.INFO;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Set the minimum log level for output
|
|
121
|
+
* @param {number} level - The log level to set
|
|
122
|
+
*/
|
|
123
|
+
function setLogLevel(level) {
|
|
124
|
+
currentLogLevel = level;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Enable verbose/debug mode
|
|
129
|
+
*/
|
|
130
|
+
function enableVerbose() {
|
|
131
|
+
currentLogLevel = LOG_LEVELS.DEBUG;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Check if a message should be logged based on current level
|
|
136
|
+
* @param {number} level - The level of the message
|
|
137
|
+
* @returns {boolean} Whether the message should be logged
|
|
138
|
+
*/
|
|
139
|
+
function shouldLog(level) {
|
|
140
|
+
return level >= currentLogLevel;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Print a debug message (gray)
|
|
145
|
+
* @param {...any} args - Messages to log
|
|
146
|
+
*/
|
|
147
|
+
function debug(...args) {
|
|
148
|
+
if (!shouldLog(LOG_LEVELS.DEBUG)) return;
|
|
149
|
+
console.log(chalk.gray(`[${t('cli.debug')}]`), ...args);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Print an info message (cyan)
|
|
154
|
+
* @param {...any} args - Messages to log
|
|
155
|
+
*/
|
|
156
|
+
function info(...args) {
|
|
157
|
+
if (!shouldLog(LOG_LEVELS.INFO)) return;
|
|
158
|
+
console.log(chalk.cyan(`[${t('cli.info')}]`), ...args);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Print a warning message (yellow)
|
|
163
|
+
* @param {...any} args - Messages to log
|
|
164
|
+
*/
|
|
165
|
+
function warn(...args) {
|
|
166
|
+
if (!shouldLog(LOG_LEVELS.WARN)) return;
|
|
167
|
+
console.warn(chalk.yellow(`[${t('cli.warn')}]`), ...args);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Print an error message (red)
|
|
172
|
+
* @param {...any} args - Messages to log
|
|
173
|
+
*/
|
|
174
|
+
function error(...args) {
|
|
175
|
+
if (!shouldLog(LOG_LEVELS.ERROR)) return;
|
|
176
|
+
console.error(chalk.red(`[${t('cli.error')}]`), ...args);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Print a success message (green)
|
|
181
|
+
* @param {...any} args - Messages to log
|
|
182
|
+
*/
|
|
183
|
+
function success(...args) {
|
|
184
|
+
if (!shouldLog(LOG_LEVELS.SUCCESS)) return;
|
|
185
|
+
console.log(chalk.green(`[${t('cli.success')}]`), ...args);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Print a newline
|
|
190
|
+
*/
|
|
191
|
+
function newline() {
|
|
192
|
+
console.log();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Print a section header (bold white)
|
|
197
|
+
* @param {string} title - The section title
|
|
198
|
+
*/
|
|
199
|
+
function header(title) {
|
|
200
|
+
console.log(chalk.bold.white(`\n${title}\n`));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Print a command example (dim)
|
|
205
|
+
* @param {string} command - The command to display
|
|
206
|
+
* @param {string} [description] - Optional description
|
|
207
|
+
*/
|
|
208
|
+
function example(command, description) {
|
|
209
|
+
if (description) {
|
|
210
|
+
console.log(chalk.dim(` $ ${command}`), chalk.gray(`- ${description}`));
|
|
211
|
+
} else {
|
|
212
|
+
console.log(chalk.dim(` $ ${command}`));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Print a tip/suggestion (magenta)
|
|
218
|
+
* @param {string} message - The tip message
|
|
219
|
+
*/
|
|
220
|
+
function tip(message) {
|
|
221
|
+
console.log(chalk.magenta(`[${t('cli.tip')}]`), message);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
module.exports = {
|
|
225
|
+
LOG_LEVELS,
|
|
226
|
+
setLogLevel,
|
|
227
|
+
enableVerbose,
|
|
228
|
+
debug,
|
|
229
|
+
info,
|
|
230
|
+
warn,
|
|
231
|
+
error,
|
|
232
|
+
success,
|
|
233
|
+
newline,
|
|
234
|
+
header,
|
|
235
|
+
example,
|
|
236
|
+
tip,
|
|
237
|
+
setLocale,
|
|
238
|
+
getLocale,
|
|
239
|
+
loadTranslations,
|
|
240
|
+
t,
|
|
241
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default configuration values for Visualify.js
|
|
3
|
+
* @module defaults
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { VisualifyConfig } from '../../types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Complete default configuration object for Visualify.js
|
|
10
|
+
* These values are used when not specified in visualify.json or overrides
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import defaults from './defaults';
|
|
15
|
+
*
|
|
16
|
+
* const config = {
|
|
17
|
+
* ...defaults,
|
|
18
|
+
* mode: 'portal' // Override specific values
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
const defaults: VisualifyConfig = {
|
|
23
|
+
/**
|
|
24
|
+
* Schema version - must match the expected version for compatibility
|
|
25
|
+
*/
|
|
26
|
+
version: '3.0.0',
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Application mode - determines how Visualify operates
|
|
30
|
+
* - 'docs': Documentation mode with markdown rendering
|
|
31
|
+
* - 'portal': Full portal mode with navigation
|
|
32
|
+
* - 'hybrid': Combined docs and portal
|
|
33
|
+
* - 'auto': Automatically detect based on content
|
|
34
|
+
*/
|
|
35
|
+
mode: 'auto',
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Documentation configuration
|
|
39
|
+
*/
|
|
40
|
+
docs: {
|
|
41
|
+
/**
|
|
42
|
+
* Base path for documentation files
|
|
43
|
+
*/
|
|
44
|
+
basePath: './docs',
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Documentation theme
|
|
48
|
+
*/
|
|
49
|
+
theme: 'vue',
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* List of plugin modules to load
|
|
53
|
+
*/
|
|
54
|
+
plugins: [],
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Portal configuration
|
|
59
|
+
*/
|
|
60
|
+
portal: {
|
|
61
|
+
/**
|
|
62
|
+
* Homepage configuration file
|
|
63
|
+
*/
|
|
64
|
+
homepage: 'home.json',
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Portal theme
|
|
68
|
+
*/
|
|
69
|
+
theme: 'modern',
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Data sources for the portal
|
|
73
|
+
*/
|
|
74
|
+
dataSources: [],
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Visualization configuration
|
|
79
|
+
*/
|
|
80
|
+
visualization: {
|
|
81
|
+
/**
|
|
82
|
+
* Default charting library
|
|
83
|
+
* - 'echarts': Apache ECharts (default)
|
|
84
|
+
* - 'plotly': Plotly.js
|
|
85
|
+
*/
|
|
86
|
+
defaultLibrary: 'echarts',
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Enable 3D visualization capabilities
|
|
90
|
+
*/
|
|
91
|
+
enable3D: false,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Use Web Workers for rendering (improves performance)
|
|
95
|
+
*/
|
|
96
|
+
webWorkers: false,
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Internationalization (i18n) configuration
|
|
101
|
+
*/
|
|
102
|
+
i18n: {
|
|
103
|
+
/**
|
|
104
|
+
* Locale setting
|
|
105
|
+
* - 'auto': Automatically detect from browser
|
|
106
|
+
* - 'en', 'zh', 'es', 'de', 'ar', 'he': Specific language
|
|
107
|
+
*/
|
|
108
|
+
locale: 'auto',
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Fallback locale when translation is missing
|
|
112
|
+
*/
|
|
113
|
+
fallbackLocale: 'en',
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Enable RTL (Right-to-Left) layout support
|
|
117
|
+
*/
|
|
118
|
+
enableRTL: true,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default defaults;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visualify.js Configuration System
|
|
3
|
+
*
|
|
4
|
+
* This module provides configuration management for Visualify.js applications.
|
|
5
|
+
* It supports loading from files, environment variables, and CLI arguments with
|
|
6
|
+
* proper validation using JSON Schema.
|
|
7
|
+
*
|
|
8
|
+
* @module config
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { loadConfig, validateConfig, defaults } from './config';
|
|
12
|
+
*
|
|
13
|
+
* // Load and validate configuration
|
|
14
|
+
* const config = await loadConfig(process.cwd(), cliArgs);
|
|
15
|
+
*
|
|
16
|
+
* // Validate custom configuration
|
|
17
|
+
* const result = validateConfig(myConfig);
|
|
18
|
+
* if (!result.valid) {
|
|
19
|
+
* console.error(result.errors);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Export defaults
|
|
25
|
+
export { default as defaults } from './defaults';
|
|
26
|
+
|
|
27
|
+
// Export schema
|
|
28
|
+
export { default as schema } from './schema';
|
|
29
|
+
export type { SchemaType } from './schema';
|
|
30
|
+
|
|
31
|
+
// Export validation functions
|
|
32
|
+
export {
|
|
33
|
+
validateConfig,
|
|
34
|
+
validateProperty,
|
|
35
|
+
isVersionCompatible,
|
|
36
|
+
isValidConfig,
|
|
37
|
+
ERROR_TEMPLATES,
|
|
38
|
+
SUGGESTED_FIXES,
|
|
39
|
+
} from './validator';
|
|
40
|
+
|
|
41
|
+
// Export loading functions and constants
|
|
42
|
+
export {
|
|
43
|
+
loadConfig,
|
|
44
|
+
watchConfig,
|
|
45
|
+
findConfigFile,
|
|
46
|
+
loadConfigFile,
|
|
47
|
+
loadEnvironmentConfig,
|
|
48
|
+
clearCache,
|
|
49
|
+
getCacheStats,
|
|
50
|
+
deepMerge,
|
|
51
|
+
ConfigLoadError,
|
|
52
|
+
CONFIG_FILES,
|
|
53
|
+
ENV_PREFIX,
|
|
54
|
+
} from './loader';
|
|
55
|
+
|
|
56
|
+
// Re-export types
|
|
57
|
+
export type {
|
|
58
|
+
VisualifyConfig,
|
|
59
|
+
DocsConfig,
|
|
60
|
+
PortalConfig,
|
|
61
|
+
VisualizationConfig,
|
|
62
|
+
DataSource,
|
|
63
|
+
AppMode,
|
|
64
|
+
ChartLibrary,
|
|
65
|
+
DataSourceType,
|
|
66
|
+
LoadConfigOptions,
|
|
67
|
+
ConfigCacheEntry,
|
|
68
|
+
CacheStats,
|
|
69
|
+
ConfigWatcher,
|
|
70
|
+
ConfigReloadCallback,
|
|
71
|
+
PartialConfig,
|
|
72
|
+
} from '../../types';
|