feat(core): add missing styles warning

This commit is contained in:
braks
2024-05-28 19:18:23 +02:00
committed by Braks
parent 9eb5769e0c
commit 8a8c8f50bf
4 changed files with 28 additions and 1 deletions
+3
View File
@@ -1,4 +1,5 @@
export enum ErrorCode {
MISSING_STYLES = 'MISSING_STYLES',
MISSING_VIEWPORT_DIMENSIONS = 'MISSING_VIEWPORT_DIMENSIONS',
NODE_INVALID = 'NODE_INVALID',
NODE_NOT_FOUND = 'NODE_NOT_FOUND',
@@ -16,6 +17,8 @@ export enum ErrorCode {
}
const messages = {
[ErrorCode.MISSING_STYLES]: () =>
`It seems that you haven't loaded the necessary styles. Please import '@vue-flow/core/dist/style.css' to ensure that the graph is rendered correctly`,
[ErrorCode.MISSING_VIEWPORT_DIMENSIONS]: () => 'The Vue Flow parent container needs a width and a height to render the graph',
[ErrorCode.NODE_INVALID]: (id?: string) => `Node is invalid\nNode: ${id}`,
[ErrorCode.NODE_NOT_FOUND]: (id: string | null) => `Node not found\nNode: ${id}`,
+5 -1
View File
@@ -1,7 +1,11 @@
const productionEnvs = ['production', 'prod']
export function warn(message: string, ...args: any[]) {
if (!productionEnvs.includes(__ENV__ || '')) {
if (isDev()) {
console.warn(`[Vue Flow]: ${message}`, ...args)
}
}
export function isDev() {
return !productionEnvs.includes(__ENV__ || '')
}