mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 18:38:11 +03:00
a8810e19f2
- Improve visualization UI APIs: - Isolate visualizations within a Vue Custom Element to prevent any unintended interaction between GUI and visualization CSS/JS. - New visualization-menus API: Visualizations no longer create toolbars using the GUI's components; a simpler JS interface moves the responsibility for appearance of controls to the GUI. - Simplify visualization configuration interface. Properties that should not be exposed to visualizations have been removed. Visualizations no longer need logic implementing fullscreen mode; the `size` property reflects the current renderable area. - Visualizations no longer use a `VisualizationContainer`; the visualization simply renders its content at its root. - Viz dropdowns: Buttons always show arrows (fixes #10809) - Fullscreen mode: Fix rendering size of scatter plot and other visualizations - JSON visualization interactivity: Fix intermittent incorrectly non-interactive state - Viz toolbars: Fix squished-looking rightmost button. Other API changes: - `Interaction` no longer includes `GraphNavigator` with pointer events.
111 lines
3.8 KiB
TypeScript
111 lines
3.8 KiB
TypeScript
/// <reference types="histoire" />
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import { getDefines, readEnvironmentFromFile } from 'enso-common/src/appConfig'
|
|
import * as tailwindConfig from 'enso-dashboard/tailwind.config'
|
|
import { fileURLToPath } from 'node:url'
|
|
import postcssNesting from 'postcss-nesting'
|
|
import tailwindcss from 'tailwindcss'
|
|
import tailwindcssNesting from 'tailwindcss/nesting'
|
|
import { defineConfig, type Plugin } from 'vite'
|
|
import VueDevTools from 'vite-plugin-vue-devtools'
|
|
import wasm from 'vite-plugin-wasm'
|
|
|
|
const dynHostnameWsUrl = (port: number) => JSON.stringify(`ws://__HOSTNAME__:${port}`)
|
|
const projectManagerUrl = dynHostnameWsUrl(process.env.E2E === 'true' ? 30536 : 30535)
|
|
const IS_CLOUD_BUILD = process.env.CLOUD_BUILD === 'true'
|
|
const YDOC_SERVER_URL =
|
|
process.env.ENSO_POLYGLOT_YDOC_SERVER ? JSON.stringify(process.env.ENSO_POLYGLOT_YDOC_SERVER)
|
|
: process.env.NODE_ENV === 'development' ? dynHostnameWsUrl(5976)
|
|
: undefined
|
|
|
|
await readEnvironmentFromFile()
|
|
|
|
const entrypoint = process.env.E2E === 'true' ? './src/e2e-entrypoint.ts' : './src/entrypoint.ts'
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
root: fileURLToPath(new URL('.', import.meta.url)),
|
|
cacheDir: fileURLToPath(new URL('../../node_modules/.cache/vite', import.meta.url)),
|
|
publicDir: fileURLToPath(new URL('./public', import.meta.url)),
|
|
envDir: fileURLToPath(new URL('.', import.meta.url)),
|
|
plugins: [
|
|
wasm(),
|
|
...(process.env.NODE_ENV === 'development' ? [await VueDevTools()] : []),
|
|
vue({
|
|
customElement: ['**/components/visualizations/**', '**/components/shared/**'],
|
|
template: {
|
|
compilerOptions: {
|
|
isCustomElement: (tag) => tag.startsWith('enso-'),
|
|
},
|
|
},
|
|
}),
|
|
react({
|
|
include: fileURLToPath(new URL('../dashboard/**/*.tsx', import.meta.url)),
|
|
babel: { plugins: ['@babel/plugin-syntax-import-attributes'] },
|
|
}),
|
|
...(process.env.NODE_ENV === 'development' ? [await projectManagerShim()] : []),
|
|
],
|
|
optimizeDeps: {
|
|
entries: fileURLToPath(new URL('./index.html', import.meta.url)),
|
|
},
|
|
server: {
|
|
headers: {
|
|
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
'Cross-Origin-Resource-Policy': 'same-origin',
|
|
},
|
|
...(process.env.GUI_HOSTNAME ? { host: process.env.GUI_HOSTNAME } : {}),
|
|
},
|
|
resolve: {
|
|
conditions: ['source'],
|
|
alias: {
|
|
'/src/entrypoint.ts': fileURLToPath(new URL(entrypoint, import.meta.url)),
|
|
shared: fileURLToPath(new URL('./shared', import.meta.url)),
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
define: {
|
|
...getDefines(),
|
|
IS_CLOUD_BUILD: JSON.stringify(IS_CLOUD_BUILD),
|
|
PROJECT_MANAGER_URL: projectManagerUrl,
|
|
YDOC_SERVER_URL: YDOC_SERVER_URL,
|
|
'import.meta.vitest': false,
|
|
// Single hardcoded usage of `global` in aws-amplify.
|
|
'global.TYPED_ARRAY_SUPPORT': true,
|
|
},
|
|
esbuild: {
|
|
dropLabels: process.env.NODE_ENV === 'development' ? [] : ['DEV'],
|
|
supported: {
|
|
'top-level-await': true,
|
|
},
|
|
},
|
|
assetsInclude: ['**/*.yaml', '**/*.svg'],
|
|
css: {
|
|
postcss: {
|
|
plugins: [
|
|
tailwindcssNesting(postcssNesting()),
|
|
tailwindcss({
|
|
...tailwindConfig.default,
|
|
content: tailwindConfig.default.content.map((glob: string) =>
|
|
glob.replace(/^[.][/]/, fileURLToPath(new URL('../dashboard/', import.meta.url))),
|
|
),
|
|
}),
|
|
],
|
|
},
|
|
},
|
|
build: {
|
|
// dashboard chunk size is larger than the default warning limit
|
|
chunkSizeWarningLimit: 700,
|
|
},
|
|
})
|
|
async function projectManagerShim(): Promise<Plugin> {
|
|
const module = await import('./project-manager-shim-middleware')
|
|
return {
|
|
name: 'project-manager-shim',
|
|
configureServer(server) {
|
|
server.middlewares.use(module.default)
|
|
},
|
|
}
|
|
}
|