New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@milkdown/exception

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/exception - npm Package Compare versions

Comparing version 6.5.2 to 6.5.3

2

lib/error.d.ts

@@ -1,2 +0,2 @@

import { ErrorCode } from './code';
import type { ErrorCode } from './code';
export declare class MilkdownError extends Error {

@@ -3,0 +3,0 @@ code: string;

{
"name": "@milkdown/exception",
"version": "6.5.2",
"type": "module",
"version": "6.5.3",
"license": "MIT",
"sideEffects": false,
"main": "./lib/index.es.js",
"types": "./lib/index.d.ts",
"sideEffects": false,
"license": "MIT",
"files": [

@@ -10,0 +10,0 @@ "lib",

/* Copyright 2021, Milkdown by Mirone. */
export const enum ErrorCode {
docTypeError = 'docTypeError',
contextNotFound = 'contextNotFound',
timerNotFound = 'timerNotFound',
ctxCallOutOfScope = 'ctxCallOutOfScope',
createNodeInParserFail = 'createNodeInParserFail',
stackOverFlow = 'stackOverFlow',
parserMatchError = 'parserMatchError',
serializerMatchError = 'serializerMatchError',
getAtomFromSchemaFail = 'getAtomFromSchemaFail',
expectDomTypeError = 'expectDomTypeError',
callCommandBeforeEditorView = 'callCommandBeforeEditorView',
themeMustInstalled = 'themeMustInstalled',
missingRootElement = 'missingRootElement',
missingNodeInSchema = 'missingNodeInSchema',
missingMarkInSchema = 'missingMarkInSchema',
docTypeError = 'docTypeError',
contextNotFound = 'contextNotFound',
timerNotFound = 'timerNotFound',
ctxCallOutOfScope = 'ctxCallOutOfScope',
createNodeInParserFail = 'createNodeInParserFail',
stackOverFlow = 'stackOverFlow',
parserMatchError = 'parserMatchError',
serializerMatchError = 'serializerMatchError',
getAtomFromSchemaFail = 'getAtomFromSchemaFail',
expectDomTypeError = 'expectDomTypeError',
callCommandBeforeEditorView = 'callCommandBeforeEditorView',
themeMustInstalled = 'themeMustInstalled',
missingRootElement = 'missingRootElement',
missingNodeInSchema = 'missingNodeInSchema',
missingMarkInSchema = 'missingMarkInSchema',
// theme
missingIcon = 'missingIcon',
// theme
missingIcon = 'missingIcon',
// vue
vueRendererCallOutOfScope = 'vueRendererCallOutOfScope',
// vue
vueRendererCallOutOfScope = 'vueRendererCallOutOfScope',
// collab plugin
ctxNotBind = 'ctxNotBind',
missingYjsDoc = 'missingYjsDoc',
// collab plugin
ctxNotBind = 'ctxNotBind',
missingYjsDoc = 'missingYjsDoc',
// menu plugin
repeatCallsToMenuWrapperInit = 'repeatCallsToMenuWrapperInit',
missingMenuWrapper = 'missingMenuWrapper',
// menu plugin
repeatCallsToMenuWrapperInit = 'repeatCallsToMenuWrapperInit',
missingMenuWrapper = 'missingMenuWrapper',
}
/* Copyright 2021, Milkdown by Mirone. */
import { ErrorCode } from './code';
import type { ErrorCode } from './code'
export class MilkdownError extends Error {
public code: string;
constructor(code: ErrorCode, message: string) {
super(message);
this.name = 'MilkdownError';
this.code = code;
}
public code: string
constructor(code: ErrorCode, message: string) {
super(message)
this.name = 'MilkdownError'
this.code = code
}
}
/* Copyright 2021, Milkdown by Mirone. */
import { ErrorCode } from './code';
import { MilkdownError } from './error';
import { ErrorCode } from './code'
import { MilkdownError } from './error'
const functionReplacer = (_: string, value: unknown) => (typeof value === 'function' ? '[Function]' : value);
const functionReplacer = (_: string, value: unknown) => (typeof value === 'function' ? '[Function]' : value)
const stringify = (x: unknown): string => JSON.stringify(x, functionReplacer);
const stringify = (x: unknown): string => JSON.stringify(x, functionReplacer)
export const docTypeError = (type: unknown) =>
new MilkdownError(ErrorCode.docTypeError, `Doc type error, unsupported type: ${stringify(type)}`);
new MilkdownError(ErrorCode.docTypeError, `Doc type error, unsupported type: ${stringify(type)}`)
export const contextNotFound = (name: string) =>
new MilkdownError(ErrorCode.contextNotFound, `Context "${name}" not found, do you forget to inject it?`);
new MilkdownError(ErrorCode.contextNotFound, `Context "${name}" not found, do you forget to inject it?`)
export const timerNotFound = (name: string) =>
new MilkdownError(ErrorCode.timerNotFound, `Timer "${name}" not found, do you forget to record it?`);
new MilkdownError(ErrorCode.timerNotFound, `Timer "${name}" not found, do you forget to record it?`)
export const ctxCallOutOfScope = () =>
new MilkdownError(ErrorCode.ctxCallOutOfScope, 'Should not call a context out of the plugin.');
new MilkdownError(ErrorCode.ctxCallOutOfScope, 'Should not call a context out of the plugin.')
export const createNodeInParserFail = (...args: unknown[]) => {
const message = args.reduce((msg, arg) => {
if (!arg) {
return msg;
}
const serialize = (x: unknown): string => {
if (Array.isArray(x)) {
return (x as unknown[]).map((y) => serialize(y)).join(', ');
}
if ((x as { toJSON(): Record<string, unknown> }).toJSON) {
return stringify((x as { toJSON(): Record<string, unknown> }).toJSON());
}
const message = args.reduce((msg, arg) => {
if (!arg)
return msg
if ((x as { spec: string }).spec) {
return stringify((x as { spec: string }).spec);
}
const serialize = (x: unknown): string => {
if (Array.isArray(x))
return (x as unknown[]).map(y => serialize(y)).join(', ')
return (x as { toString(): string }).toString();
};
return `${msg}, ${serialize(arg)}`;
}, 'Create prosemirror node from remark failed in parser') as string;
if ((x as { toJSON(): Record<string, unknown> }).toJSON)
return stringify((x as { toJSON(): Record<string, unknown> }).toJSON())
return new MilkdownError(ErrorCode.createNodeInParserFail, message);
};
if ((x as { spec: string }).spec)
return stringify((x as { spec: string }).spec)
return (x as { toString(): string }).toString()
}
return `${msg}, ${serialize(arg)}`
}, 'Create prosemirror node from remark failed in parser') as string
return new MilkdownError(ErrorCode.createNodeInParserFail, message)
}
export const stackOverFlow = () =>
new MilkdownError(ErrorCode.stackOverFlow, 'Stack over flow, cannot pop on an empty stack.');
new MilkdownError(ErrorCode.stackOverFlow, 'Stack over flow, cannot pop on an empty stack.')
export const parserMatchError = (node: unknown) =>
new MilkdownError(ErrorCode.parserMatchError, `Cannot match target parser for node: ${stringify(node)}.`);
new MilkdownError(ErrorCode.parserMatchError, `Cannot match target parser for node: ${stringify(node)}.`)
export const serializerMatchError = (node: unknown) =>
new MilkdownError(ErrorCode.serializerMatchError, `Cannot match target serializer for node: ${stringify(node)}.`);
new MilkdownError(ErrorCode.serializerMatchError, `Cannot match target serializer for node: ${stringify(node)}.`)
export const getAtomFromSchemaFail = (type: 'mark' | 'node', name: string) =>
new MilkdownError(ErrorCode.getAtomFromSchemaFail, `Cannot get ${type}: ${name} from schema.`);
new MilkdownError(ErrorCode.getAtomFromSchemaFail, `Cannot get ${type}: ${name} from schema.`)
export const expectDomTypeError = (node: unknown) =>
new MilkdownError(ErrorCode.expectDomTypeError, `Expect to be a dom, but get: ${stringify(node)}.`);
new MilkdownError(ErrorCode.expectDomTypeError, `Expect to be a dom, but get: ${stringify(node)}.`)
export const callCommandBeforeEditorView = () =>
new MilkdownError(
ErrorCode.callCommandBeforeEditorView,
`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`,
);
new MilkdownError(
ErrorCode.callCommandBeforeEditorView,
'You\'re trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized',
)
export const themeMustInstalled = () =>
new MilkdownError(
ErrorCode.themeMustInstalled,
new MilkdownError(
ErrorCode.themeMustInstalled,
`It seems that no theme found in editor, please make sure you have use theme in front of all plugins.
If you prefer to use an empty theme, you can use \`themeFactory({})\`.`,
);
)
export const missingRootElement = () =>
new MilkdownError(
ErrorCode.missingRootElement,
'Missing root element, milkdown cannot find root element of the editor.',
);
new MilkdownError(
ErrorCode.missingRootElement,
'Missing root element, milkdown cannot find root element of the editor.',
)
export const missingNodeInSchema = (name: string) =>
new MilkdownError(
ErrorCode.missingNodeInSchema,
new MilkdownError(
ErrorCode.missingNodeInSchema,
`Missing node in schema, milkdown cannot find "${name}" in schema.`,
);
)
export const missingMarkInSchema = (name: string) =>
new MilkdownError(
ErrorCode.missingMarkInSchema,
new MilkdownError(
ErrorCode.missingMarkInSchema,
`Missing mark in schema, milkdown cannot find "${name}" in schema.`,
);
)
export const missingIcon = (name: string) =>
new MilkdownError(ErrorCode.missingIcon, `Missing icon in theme, milkdown cannot find icon "${name}" in theme.`);
new MilkdownError(ErrorCode.missingIcon, `Missing icon in theme, milkdown cannot find icon "${name}" in theme.`)
export const ctxNotBind = () =>
new MilkdownError(ErrorCode.ctxNotBind, 'Context not bind, please make sure the plugin has been initialized.');
new MilkdownError(ErrorCode.ctxNotBind, 'Context not bind, please make sure the plugin has been initialized.')
export const missingYjsDoc = () =>
new MilkdownError(ErrorCode.missingYjsDoc, 'Missing yjs doc, please make sure you have bind one.');
new MilkdownError(ErrorCode.missingYjsDoc, 'Missing yjs doc, please make sure you have bind one.')
export const vueRendererCallOutOfScope = () =>
new MilkdownError(ErrorCode.vueRendererCallOutOfScope, 'Should not call vue renderer before it has been created.');
new MilkdownError(ErrorCode.vueRendererCallOutOfScope, 'Should not call vue renderer before it has been created.')
export const missingMenuWrapper = () =>
new MilkdownError(ErrorCode.missingMenuWrapper, 'Missing menu wrapper, should init menu wrapper first.');
new MilkdownError(ErrorCode.missingMenuWrapper, 'Missing menu wrapper, should init menu wrapper first.')
export const repeatCallsToMenuWrapperInit = () =>
new MilkdownError(ErrorCode.repeatCallsToMenuWrapperInit, 'Repeated calls to menu wrapper initialization');
new MilkdownError(ErrorCode.repeatCallsToMenuWrapperInit, 'Repeated calls to menu wrapper initialization')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc