@milkdown/exception
Advanced tools
Comparing version 7.3.1 to 7.3.2
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 missingRootElement: () => MilkdownError; | ||
export declare const missingNodeInSchema: (name: string) => MilkdownError; | ||
export declare const missingMarkInSchema: (name: string) => MilkdownError; | ||
export declare const ctxNotBind: () => MilkdownError; | ||
export declare const missingYjsDoc: () => MilkdownError; | ||
export declare function docTypeError(type: unknown): MilkdownError; | ||
export declare function contextNotFound(name: string): MilkdownError; | ||
export declare function timerNotFound(name: string): MilkdownError; | ||
export declare function ctxCallOutOfScope(): MilkdownError; | ||
export declare function createNodeInParserFail(...args: unknown[]): MilkdownError; | ||
export declare function stackOverFlow(): MilkdownError; | ||
export declare function parserMatchError(node: unknown): MilkdownError; | ||
export declare function serializerMatchError(node: unknown): MilkdownError; | ||
export declare function getAtomFromSchemaFail(type: 'mark' | 'node', name: string): MilkdownError; | ||
export declare function expectDomTypeError(node: unknown): MilkdownError; | ||
export declare function callCommandBeforeEditorView(): MilkdownError; | ||
export declare function missingRootElement(): MilkdownError; | ||
export declare function missingNodeInSchema(name: string): MilkdownError; | ||
export declare function missingMarkInSchema(name: string): MilkdownError; | ||
export declare function ctxNotBind(): MilkdownError; | ||
export declare function missingYjsDoc(): MilkdownError; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,3 @@ | ||
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.missingRootElement = "missingRootElement", e.missingNodeInSchema = "missingNodeInSchema", e.missingMarkInSchema = "missingMarkInSchema", e.ctxNotBind = "ctxNotBind", e.missingYjsDoc = "missingYjsDoc", e))(t || {}); | ||
class n extends Error { | ||
var n = /* @__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.missingRootElement = "missingRootElement", e.missingNodeInSchema = "missingNodeInSchema", e.missingMarkInSchema = "missingMarkInSchema", e.ctxNotBind = "ctxNotBind", e.missingYjsDoc = "missingYjsDoc", e))(n || {}); | ||
class t extends Error { | ||
constructor(o, a) { | ||
@@ -7,3 +7,16 @@ super(a), this.name = "MilkdownError", this.code = o; | ||
} | ||
const l = (e, o) => typeof o == "function" ? "[Function]" : o, i = (e) => JSON.stringify(e, l), d = (e) => new n(t.docTypeError, `Doc type error, unsupported type: ${i(e)}`), p = (e) => new n(t.contextNotFound, `Context "${e}" not found, do you forget to inject it?`), u = (e) => new n(t.timerNotFound, `Timer "${e}" not found, do you forget to record it?`), g = () => new n(t.ctxCallOutOfScope, "Should not call a context out of the plugin."), h = (...e) => { | ||
const u = (e, o) => typeof o == "function" ? "[Function]" : o, i = (e) => JSON.stringify(e, u); | ||
function l(e) { | ||
return new t(n.docTypeError, `Doc type error, unsupported type: ${i(e)}`); | ||
} | ||
function d(e) { | ||
return new t(n.contextNotFound, `Context "${e}" not found, do you forget to inject it?`); | ||
} | ||
function f(e) { | ||
return new t(n.timerNotFound, `Timer "${e}" not found, do you forget to record it?`); | ||
} | ||
function p() { | ||
return new t(n.ctxCallOutOfScope, "Should not call a context out of the plugin."); | ||
} | ||
function g(...e) { | ||
const o = e.reduce((a, c) => { | ||
@@ -15,23 +28,56 @@ if (!c) | ||
}, "Create prosemirror node from remark failed in parser"); | ||
return new n(t.createNodeInParserFail, o); | ||
}, f = () => 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: ${i(e)}.`), F = (e) => new n(t.serializerMatchError, `Cannot match target serializer for node: ${i(e)}.`), N = (e, o) => new n(t.getAtomFromSchemaFail, `Cannot get ${e}: ${o} from schema.`), S = (e) => new n(t.expectDomTypeError, `Expect to be a dom, but get: ${i(e)}.`), y = () => 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" | ||
), k = () => new n( | ||
t.missingRootElement, | ||
"Missing root element, milkdown cannot find root element of the editor." | ||
), M = (e) => new n( | ||
t.missingNodeInSchema, | ||
`Missing node in schema, milkdown cannot find "${e}" in schema.` | ||
), x = (e) => new n( | ||
t.missingMarkInSchema, | ||
`Missing mark in schema, milkdown cannot find "${e}" in schema.` | ||
), O = () => new n(t.ctxNotBind, "Context not bind, please make sure the plugin has been initialized."), E = () => new n(t.missingYjsDoc, "Missing yjs doc, please make sure you have bind one."); | ||
return new t(n.createNodeInParserFail, o); | ||
} | ||
function h() { | ||
return new t(n.stackOverFlow, "Stack over flow, cannot pop on an empty stack."); | ||
} | ||
function w(e) { | ||
return new t(n.parserMatchError, `Cannot match target parser for node: ${i(e)}.`); | ||
} | ||
function F(e) { | ||
return new t(n.serializerMatchError, `Cannot match target serializer for node: ${i(e)}.`); | ||
} | ||
function N(e, o) { | ||
return new t(n.getAtomFromSchemaFail, `Cannot get ${e}: ${o} from schema.`); | ||
} | ||
function S(e) { | ||
return new t(n.expectDomTypeError, `Expect to be a dom, but get: ${i(e)}.`); | ||
} | ||
function y() { | ||
return new t( | ||
n.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" | ||
); | ||
} | ||
function k() { | ||
return new t( | ||
n.missingRootElement, | ||
"Missing root element, milkdown cannot find root element of the editor." | ||
); | ||
} | ||
function M(e) { | ||
return new t( | ||
n.missingNodeInSchema, | ||
`Missing node in schema, milkdown cannot find "${e}" in schema.` | ||
); | ||
} | ||
function x(e) { | ||
return new t( | ||
n.missingMarkInSchema, | ||
`Missing mark in schema, milkdown cannot find "${e}" in schema.` | ||
); | ||
} | ||
function O() { | ||
return new t(n.ctxNotBind, "Context not bind, please make sure the plugin has been initialized."); | ||
} | ||
function E() { | ||
return new t(n.missingYjsDoc, "Missing yjs doc, please make sure you have bind one."); | ||
} | ||
export { | ||
y as callCommandBeforeEditorView, | ||
p as contextNotFound, | ||
h as createNodeInParserFail, | ||
g as ctxCallOutOfScope, | ||
d as contextNotFound, | ||
g as createNodeInParserFail, | ||
p as ctxCallOutOfScope, | ||
O as ctxNotBind, | ||
d as docTypeError, | ||
l as docTypeError, | ||
S as expectDomTypeError, | ||
@@ -45,5 +91,5 @@ N as getAtomFromSchemaFail, | ||
F as serializerMatchError, | ||
f as stackOverFlow, | ||
u as timerNotFound | ||
h as stackOverFlow, | ||
f as timerNotFound | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
{ | ||
"name": "@milkdown/exception", | ||
"type": "module", | ||
"version": "7.3.1", | ||
"version": "7.3.2", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -9,15 +9,19 @@ /* Copyright 2021, Milkdown by Mirone. */ | ||
export const docTypeError = (type: unknown) => | ||
new MilkdownError(ErrorCode.docTypeError, `Doc type error, unsupported type: ${stringify(type)}`) | ||
export function docTypeError(type: unknown) { | ||
return 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?`) | ||
export function contextNotFound(name: string) { | ||
return 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?`) | ||
export function timerNotFound(name: string) { | ||
return 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.') | ||
export function ctxCallOutOfScope() { | ||
return new MilkdownError(ErrorCode.ctxCallOutOfScope, 'Should not call a context out of the plugin.') | ||
} | ||
export const createNodeInParserFail = (...args: unknown[]) => { | ||
export function createNodeInParserFail(...args: unknown[]) { | ||
const message = args.reduce((msg, arg) => { | ||
@@ -45,45 +49,56 @@ if (!arg) | ||
export const stackOverFlow = () => | ||
new MilkdownError(ErrorCode.stackOverFlow, 'Stack over flow, cannot pop on an empty stack.') | ||
export function stackOverFlow() { | ||
return 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)}.`) | ||
export function parserMatchError(node: unknown) { | ||
return 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)}.`) | ||
export function serializerMatchError(node: unknown) { | ||
return 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.`) | ||
export function getAtomFromSchemaFail(type: 'mark' | 'node', name: string) { | ||
return 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)}.`) | ||
export function expectDomTypeError(node: unknown) { | ||
return new MilkdownError(ErrorCode.expectDomTypeError, `Expect to be a dom, but get: ${stringify(node)}.`) | ||
} | ||
export const callCommandBeforeEditorView = () => | ||
new MilkdownError( | ||
export function callCommandBeforeEditorView() { | ||
return 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 missingRootElement = () => | ||
new MilkdownError( | ||
export function missingRootElement() { | ||
return new MilkdownError( | ||
ErrorCode.missingRootElement, | ||
'Missing root element, milkdown cannot find root element of the editor.', | ||
) | ||
} | ||
export const missingNodeInSchema = (name: string) => | ||
new MilkdownError( | ||
export function missingNodeInSchema(name: string) { | ||
return new MilkdownError( | ||
ErrorCode.missingNodeInSchema, | ||
`Missing node in schema, milkdown cannot find "${name}" in schema.`, | ||
) | ||
} | ||
export const missingMarkInSchema = (name: string) => | ||
new MilkdownError( | ||
export function missingMarkInSchema(name: string) { | ||
return new MilkdownError( | ||
ErrorCode.missingMarkInSchema, | ||
`Missing mark in schema, milkdown cannot find "${name}" in schema.`, | ||
) | ||
} | ||
export const ctxNotBind = () => | ||
new MilkdownError(ErrorCode.ctxNotBind, 'Context not bind, please make sure the plugin has been initialized.') | ||
export function ctxNotBind() { | ||
return 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 function missingYjsDoc() { | ||
return new MilkdownError(ErrorCode.missingYjsDoc, 'Missing yjs doc, please make sure you have bind one.') | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22028
243