feat(core): add missing styles warning
This commit is contained in:
@@ -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}`,
|
||||
|
||||
@@ -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__ || '')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user