Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@milkdown/exception

Package Overview
Dependencies
Maintainers
0
Versions
98
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 7.5.0 to 7.5.8

62

lib/index.es.js

@@ -9,18 +9,31 @@ 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 || {});

function l(e) {
return new t(n.docTypeError, `Doc type error, unsupported type: ${i(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?`);
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?`);
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.");
return new t(
n.ctxCallOutOfScope,
"Should not call a context out of the plugin."
);
}
function g(...e) {
const o = e.reduce((a, c) => {
if (!c)
return a;
const s = (r) => Array.isArray(r) ? r.map((m) => s(m)).join(", ") : r.toJSON ? i(r.toJSON()) : r.spec ? i(r.spec) : r.toString();
if (!c) return a;
const s = (r) => Array.isArray(r) ? r.map((m) => s(m)).join(", ") : r.toJSON ? i(
r.toJSON()
) : r.spec ? i(r.spec) : r.toString();
return `${a}, ${s(c)}`;

@@ -31,15 +44,30 @@ }, "Create prosemirror node from remark failed in parser");

function h() {
return new t(n.stackOverFlow, "Stack over flow, cannot pop on an empty stack.");
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)}.`);
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)}.`);
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.`);
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)}.`);
return new t(
n.expectDomTypeError,
`Expect to be a dom, but get: ${i(e)}.`
);
}

@@ -71,6 +99,12 @@ function y() {

function O() {
return new t(n.ctxNotBind, "Context not bind, please make sure the plugin has been initialized.");
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.");
return new t(
n.missingYjsDoc,
"Missing yjs doc, please make sure you have bind one."
);
}

@@ -77,0 +111,0 @@ export {

{
"name": "@milkdown/exception",
"type": "module",
"version": "7.5.0",
"version": "7.5.8",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": {

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

@@ -9,15 +10,27 @@ const stringify = (x: unknown): string => JSON.stringify(x, functionReplacer)

export function docTypeError(type: unknown) {
return new MilkdownError(ErrorCode.docTypeError, `Doc type error, unsupported type: ${stringify(type)}`)
return new MilkdownError(
ErrorCode.docTypeError,
`Doc type error, unsupported type: ${stringify(type)}`
)
}
export function contextNotFound(name: string) {
return new MilkdownError(ErrorCode.contextNotFound, `Context "${name}" not found, do you forget to inject it?`)
return new MilkdownError(
ErrorCode.contextNotFound,
`Context "${name}" not found, do you forget to inject it?`
)
}
export function timerNotFound(name: string) {
return new MilkdownError(ErrorCode.timerNotFound, `Timer "${name}" not found, do you forget to record it?`)
return new MilkdownError(
ErrorCode.timerNotFound,
`Timer "${name}" not found, do you forget to record it?`
)
}
export function ctxCallOutOfScope() {
return new MilkdownError(ErrorCode.ctxCallOutOfScope, 'Should not call a context out of the plugin.')
return new MilkdownError(
ErrorCode.ctxCallOutOfScope,
'Should not call a context out of the plugin.'
)
}

@@ -27,11 +40,12 @@

const message = args.reduce((msg, arg) => {
if (!arg)
return msg
if (!arg) return msg
const serialize = (x: unknown): string => {
if (Array.isArray(x))
return (x as unknown[]).map(y => serialize(y)).join(', ')
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())
return stringify(
(x as { toJSON: () => Record<string, unknown> }).toJSON()
)

@@ -50,19 +64,34 @@ if ((x as { spec: string }).spec)

export function stackOverFlow() {
return new MilkdownError(ErrorCode.stackOverFlow, 'Stack over flow, cannot pop on an empty stack.')
return new MilkdownError(
ErrorCode.stackOverFlow,
'Stack over flow, cannot pop on an empty stack.'
)
}
export function parserMatchError(node: unknown) {
return new MilkdownError(ErrorCode.parserMatchError, `Cannot match target parser for node: ${stringify(node)}.`)
return new MilkdownError(
ErrorCode.parserMatchError,
`Cannot match target parser for node: ${stringify(node)}.`
)
}
export function serializerMatchError(node: unknown) {
return new MilkdownError(ErrorCode.serializerMatchError, `Cannot match target serializer for node: ${stringify(node)}.`)
return new MilkdownError(
ErrorCode.serializerMatchError,
`Cannot match target serializer for node: ${stringify(node)}.`
)
}
export function getAtomFromSchemaFail(type: 'mark' | 'node', name: string) {
return new MilkdownError(ErrorCode.getAtomFromSchemaFail, `Cannot get ${type}: ${name} from schema.`)
return new MilkdownError(
ErrorCode.getAtomFromSchemaFail,
`Cannot get ${type}: ${name} from schema.`
)
}
export function expectDomTypeError(node: unknown) {
return new MilkdownError(ErrorCode.expectDomTypeError, `Expect to be a dom, but get: ${stringify(node)}.`)
return new MilkdownError(
ErrorCode.expectDomTypeError,
`Expect to be a dom, but get: ${stringify(node)}.`
)
}

@@ -73,3 +102,3 @@

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',
"You're trying to call a command before editor view initialized, make sure to get commandManager from ctx after editor view has been initialized"
)

@@ -81,3 +110,3 @@ }

ErrorCode.missingRootElement,
'Missing root element, milkdown cannot find root element of the editor.',
'Missing root element, milkdown cannot find root element of the editor.'
)

@@ -89,3 +118,3 @@ }

ErrorCode.missingNodeInSchema,
`Missing node in schema, milkdown cannot find "${name}" in schema.`,
`Missing node in schema, milkdown cannot find "${name}" in schema.`
)

@@ -97,3 +126,3 @@ }

ErrorCode.missingMarkInSchema,
`Missing mark in schema, milkdown cannot find "${name}" in schema.`,
`Missing mark in schema, milkdown cannot find "${name}" in schema.`
)

@@ -103,7 +132,13 @@ }

export function ctxNotBind() {
return new MilkdownError(ErrorCode.ctxNotBind, 'Context not bind, please make sure the plugin has been initialized.')
return new MilkdownError(
ErrorCode.ctxNotBind,
'Context not bind, please make sure the plugin has been initialized.'
)
}
export function missingYjsDoc() {
return new MilkdownError(ErrorCode.missingYjsDoc, 'Missing yjs doc, please make sure you have bind one.')
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

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