@milkdown/exception
Advanced tools
Comparing version 6.2.0 to 6.3.0
@@ -1,13 +0,21 @@ | ||
export declare const docTypeError: (type: unknown) => Error; | ||
export declare const contextNotFound: (name: string) => Error; | ||
export declare const timerNotFound: () => Error; | ||
export declare const ctxCallOutOfScope: () => Error; | ||
export declare const createNodeInParserFail: (...args: unknown[]) => Error; | ||
export declare const stackOverFlow: () => Error; | ||
export declare const parserMatchError: (node: unknown) => Error; | ||
export declare const serializerMatchError: (node: unknown) => Error; | ||
export declare const getAtomFromSchemaFail: (type: 'mark' | 'node', name: string) => Error; | ||
export declare const expectDomTypeError: (node: unknown) => Error; | ||
export declare const callCommandBeforeEditorView: () => Error; | ||
export declare const themeMustInstalled: () => Error; | ||
import { MilkdownError } from './error'; | ||
export declare const docTypeError: (type: unknown) => MilkdownError; | ||
export declare const contextNotFound: (name: string) => MilkdownError; | ||
export declare const timerNotFound: (name: string) => MilkdownError; | ||
export declare const ctxCallOutOfScope: () => MilkdownError; | ||
export declare const createNodeInParserFail: (...args: unknown[]) => MilkdownError; | ||
export declare const stackOverFlow: () => MilkdownError; | ||
export declare const parserMatchError: (node: unknown) => MilkdownError; | ||
export declare const serializerMatchError: (node: unknown) => MilkdownError; | ||
export declare const getAtomFromSchemaFail: (type: 'mark' | 'node', name: string) => MilkdownError; | ||
export declare const expectDomTypeError: (node: unknown) => MilkdownError; | ||
export declare const callCommandBeforeEditorView: () => MilkdownError; | ||
export declare const themeMustInstalled: () => MilkdownError; | ||
export declare const missingRootElement: () => MilkdownError; | ||
export declare const missingNodeInSchema: (name: string) => MilkdownError; | ||
export declare const missingMarkInSchema: (name: string) => MilkdownError; | ||
export declare const missingIcon: (name: string) => MilkdownError; | ||
export declare const ctxNotBind: () => MilkdownError; | ||
export declare const missingYjsDoc: () => MilkdownError; | ||
export declare const vueRendererCallOutOfScope: () => MilkdownError; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,37 +0,37 @@ | ||
const functionReplacer = (_, value) => typeof value === "function" ? "[Function]" : value; | ||
const stringify = (x) => JSON.stringify(x, functionReplacer); | ||
const docTypeError = (type) => new Error(`Doc type error, unsupported type: ${stringify(type)}`); | ||
const contextNotFound = (name) => new Error(`Context "${name}" not found, do you forget to inject it?`); | ||
const timerNotFound = () => new Error("Timer not found, do you forget to record it?"); | ||
const ctxCallOutOfScope = () => new Error("Should not call a context out of the plugin."); | ||
const createNodeInParserFail = (...args) => { | ||
const message = args.reduce((msg, arg) => { | ||
if (!arg) { | ||
return msg; | ||
} | ||
const serialize = (x) => { | ||
if (Array.isArray(x)) { | ||
return x.map((y) => serialize(y)).join(", "); | ||
} | ||
if (x.toJSON) { | ||
return stringify(x.toJSON()); | ||
} | ||
if (x.spec) { | ||
return stringify(x.spec); | ||
} | ||
return x.toString(); | ||
}; | ||
return `${msg}, ${serialize(arg)}`; | ||
var t = /* @__PURE__ */ ((e) => (e.docTypeError = "docTypeError", e.contextNotFound = "contextNotFound", e.timerNotFound = "timerNotFound", e.ctxCallOutOfScope = "ctxCallOutOfScope", e.createNodeInParserFail = "createNodeInParserFail", e.stackOverFlow = "stackOverFlow", e.parserMatchError = "parserMatchError", e.serializerMatchError = "serializerMatchError", e.getAtomFromSchemaFail = "getAtomFromSchemaFail", e.expectDomTypeError = "expectDomTypeError", e.callCommandBeforeEditorView = "callCommandBeforeEditorView", e.themeMustInstalled = "themeMustInstalled", e.missingRootElement = "missingRootElement", e.missingNodeInSchema = "missingNodeInSchema", e.missingMarkInSchema = "missingMarkInSchema", e.missingIcon = "missingIcon", e.ctxNotBind = "ctxNotBind", e.missingYjsDoc = "missingYjsDoc", e.vueRendererCallOutOfScope = "vueRendererCallOutOfScope", e))(t || {}); | ||
class n extends Error { | ||
constructor(o, s) { | ||
super(s), this.name = "MilkdownError", this.code = o; | ||
} | ||
} | ||
const l = (e, o) => typeof o == "function" ? "[Function]" : o, r = (e) => JSON.stringify(e, l), d = (e) => new n(t.docTypeError, `Doc type error, unsupported type: ${r(e)}`), u = (e) => new n(t.contextNotFound, `Context "${e}" not found, do you forget to inject it?`), h = (e) => new n(t.timerNotFound, `Timer "${e}" not found, do you forget to record it?`), p = () => new n(t.ctxCallOutOfScope, "Should not call a context out of the plugin."), f = (...e) => { | ||
const o = e.reduce((s, a) => { | ||
if (!a) | ||
return s; | ||
const c = (i) => Array.isArray(i) ? i.map((m) => c(m)).join(", ") : i.toJSON ? r(i.toJSON()) : i.spec ? r(i.spec) : i.toString(); | ||
return `${s}, ${c(a)}`; | ||
}, "Create prosemirror node from remark failed in parser"); | ||
return new Error(message); | ||
return new n(t.createNodeInParserFail, o); | ||
}, g = () => new n(t.stackOverFlow, "Stack over flow, cannot pop on an empty stack."), w = (e) => new n(t.parserMatchError, `Cannot match target parser for node: ${r(e)}.`), S = (e) => new n(t.serializerMatchError, `Cannot match target serializer for node: ${r(e)}.`), y = (e, o) => new n(t.getAtomFromSchemaFail, `Cannot get ${e}: ${o} from schema.`), F = (e) => new n(t.expectDomTypeError, `Expect to be a dom, but get: ${r(e)}.`), M = () => new n(t.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"), N = () => new n(t.themeMustInstalled, "It seems that no theme found in editor, please make sure you have use theme in front of all plugins.\nIf you prefer to use an empty theme, you can use `themeFactory({})`."), O = () => new n(t.missingRootElement, "Missing root element, milkdown cannot find root element of the editor."), k = (e) => new n(t.missingNodeInSchema, `Missing node in schema, milkdown cannot find "${e}" in schema.`), I = (e) => new n(t.missingMarkInSchema, `Missing mark in schema, milkdown cannot find "${e}" in schema.`), x = (e) => new n(t.missingIcon, `Missing icon in theme, milkdown cannot find icon "${e}" in theme.`), v = () => new n(t.ctxNotBind, "Context not bind, please make sure the plugin has been initialized."), $ = () => new n(t.missingYjsDoc, "Missing yjs doc, please make sure you have bind one."), E = () => new n(t.vueRendererCallOutOfScope, "Should not call vue renderer before it has been created."); | ||
export { | ||
M as callCommandBeforeEditorView, | ||
u as contextNotFound, | ||
f as createNodeInParserFail, | ||
p as ctxCallOutOfScope, | ||
v as ctxNotBind, | ||
d as docTypeError, | ||
F as expectDomTypeError, | ||
y as getAtomFromSchemaFail, | ||
x as missingIcon, | ||
I as missingMarkInSchema, | ||
k as missingNodeInSchema, | ||
O as missingRootElement, | ||
$ as missingYjsDoc, | ||
w as parserMatchError, | ||
S as serializerMatchError, | ||
g as stackOverFlow, | ||
N as themeMustInstalled, | ||
h as timerNotFound, | ||
E as vueRendererCallOutOfScope | ||
}; | ||
const stackOverFlow = () => new Error("Stack over flow, cannot pop on an empty stack."); | ||
const parserMatchError = (node) => new Error(`Cannot match target parser for node: ${stringify(node)}.`); | ||
const serializerMatchError = (node) => new Error(`Cannot match target serializer for node: ${stringify(node)}.`); | ||
const getAtomFromSchemaFail = (type, name) => new Error(`Cannot get ${type}: ${name} from schema.`); | ||
const expectDomTypeError = (node) => new Error(`Expect to be a dom, but get: ${stringify(node)}.`); | ||
const callCommandBeforeEditorView = () => new Error(`You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized`); | ||
const themeMustInstalled = () => new Error(`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 { callCommandBeforeEditorView, contextNotFound, createNodeInParserFail, ctxCallOutOfScope, docTypeError, expectDomTypeError, getAtomFromSchemaFail, parserMatchError, serializerMatchError, stackOverFlow, themeMustInstalled, timerNotFound }; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "@milkdown/exception", | ||
"version": "6.2.0", | ||
"version": "6.3.0", | ||
"type": "module", | ||
@@ -14,3 +14,3 @@ "main": "./lib/index.es.js", | ||
"dependencies": { | ||
"tslib": "^2.3.1" | ||
"tslib": "^2.4.0" | ||
}, | ||
@@ -17,0 +17,0 @@ "nx": { |
/* Copyright 2021, Milkdown by Mirone. */ | ||
import { ErrorCode } from './code'; | ||
import { MilkdownError } from './error'; | ||
@@ -7,9 +9,13 @@ const functionReplacer = (_: string, value: unknown) => (typeof value === 'function' ? '[Function]' : value); | ||
export const docTypeError = (type: unknown) => new Error(`Doc type error, unsupported type: ${stringify(type)}`); | ||
export const docTypeError = (type: unknown) => | ||
new MilkdownError(ErrorCode.docTypeError, `Doc type error, unsupported type: ${stringify(type)}`); | ||
export const contextNotFound = (name: string) => new Error(`Context "${name}" not found, do you forget to inject it?`); | ||
export const contextNotFound = (name: string) => | ||
new MilkdownError(ErrorCode.contextNotFound, `Context "${name}" not found, do you forget to inject it?`); | ||
export const timerNotFound = () => new Error('Timer not found, do you forget to record it?'); | ||
export const timerNotFound = (name: string) => | ||
new MilkdownError(ErrorCode.timerNotFound, `Timer "${name}" not found, do you forget to record it?`); | ||
export const ctxCallOutOfScope = () => new Error('Should not call a context out of the plugin.'); | ||
export const ctxCallOutOfScope = () => | ||
new MilkdownError(ErrorCode.ctxCallOutOfScope, 'Should not call a context out of the plugin.'); | ||
@@ -38,20 +44,23 @@ export const createNodeInParserFail = (...args: unknown[]) => { | ||
return new Error(message); | ||
return new MilkdownError(ErrorCode.createNodeInParserFail, message); | ||
}; | ||
export const stackOverFlow = () => new Error('Stack over flow, cannot pop on an empty stack.'); | ||
export const stackOverFlow = () => | ||
new MilkdownError(ErrorCode.stackOverFlow, 'Stack over flow, cannot pop on an empty stack.'); | ||
export const parserMatchError = (node: unknown) => | ||
new Error(`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 Error(`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 Error(`Cannot get ${type}: ${name} from schema.`); | ||
new MilkdownError(ErrorCode.getAtomFromSchemaFail, `Cannot get ${type}: ${name} from schema.`); | ||
export const expectDomTypeError = (node: unknown) => new Error(`Expect to be a dom, but get: ${stringify(node)}.`); | ||
export const expectDomTypeError = (node: unknown) => | ||
new MilkdownError(ErrorCode.expectDomTypeError, `Expect to be a dom, but get: ${stringify(node)}.`); | ||
export const callCommandBeforeEditorView = () => | ||
new Error( | ||
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`, | ||
@@ -61,5 +70,36 @@ ); | ||
export const themeMustInstalled = () => | ||
new Error( | ||
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.', | ||
); | ||
export const missingNodeInSchema = (name: string) => | ||
new MilkdownError( | ||
ErrorCode.missingNodeInSchema, | ||
`Missing node in schema, milkdown cannot find "${name}" in schema.`, | ||
); | ||
export const missingMarkInSchema = (name: string) => | ||
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.`); | ||
export const ctxNotBind = () => | ||
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.'); | ||
export const vueRendererCallOutOfScope = () => | ||
new MilkdownError(ErrorCode.vueRendererCallOutOfScope, 'Should not call vue renderer before it has been created.'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23927
14
205
1
Updatedtslib@^2.4.0