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

@milkdown/transformer

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@milkdown/transformer - npm Package Compare versions

Comparing version 6.5.0 to 6.5.2

352

lib/index.es.js

@@ -1,14 +0,16 @@

var J = (e, t, s) => {
var A = Object.defineProperty;
var C = (e, t, r) => t in e ? A(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
var i = (e, t, r) => (C(e, typeof t != "symbol" ? t + "" : t, r), r), U = (e, t, r) => {
if (!t.has(e))
throw TypeError("Cannot " + s);
throw TypeError("Cannot " + r);
};
var h = (e, t, s) => {
var u = (e, t, r) => {
if (t.has(e))
throw TypeError("Cannot add the same private member more than once");
t instanceof WeakSet ? t.add(e) : t.set(e, s);
t instanceof WeakSet ? t.add(e) : t.set(e, r);
};
var a = (e, t, s) => (J(e, t, "access private method"), s);
import { stackOverFlow as v, createNodeInParserFail as A, parserMatchError as C, serializerMatchError as U } from "@milkdown/exception";
import { Mark as $ } from "@milkdown/prose/model";
const w = () => {
var h = (e, t, r) => (U(e, t, "access private method"), r);
import { stackOverFlow as $, createNodeInParserFail as q, parserMatchError as x, serializerMatchError as B } from "@milkdown/exception";
import { Mark as w } from "@milkdown/prose/model";
const E = () => {
const e = (o) => o.elements.length, t = (o) => o.elements[e(o) - 1];

@@ -19,4 +21,4 @@ return {

push: (o) => (c) => {
var i;
(i = t(o)) == null || i.push(c);
var a;
(a = t(o)) == null || a.push(c);
},

@@ -29,56 +31,56 @@ open: (o) => (c) => {

if (!c)
throw v();
throw $();
return c;
}
};
}, q = (e, t, ...s) => {
e.content.push(t, ...s);
}, x = (e) => e.content.pop(), B = (e, t, s) => {
const n = {
}, G = (e, t, ...r) => {
e.content.push(t, ...r);
}, H = (e) => e.content.pop(), K = (e, t, r) => {
const s = {
type: e,
content: t,
attrs: s,
push: (...r) => q(n, ...r),
pop: () => x(n)
attrs: r,
push: (...n) => G(s, ...n),
pop: () => H(s)
};
return n;
}, { size: G, push: H, top: K, open: L, close: Q } = w(), S = (e) => e.isText, V = (e, t, s) => {
if (S(t) && S(s) && $.sameSet(t.marks, s.marks))
return e.text(t.text + s.text, t.marks);
}, W = (e) => (t, s) => L(e)(B(t, [], s)), E = (e) => (t, s, n) => {
const r = t.createAndFill(s, n, e.marks);
return s;
}, { size: L, push: Q, top: V, open: W, close: X } = E(), v = (e) => e.isText, Y = (e, t, r) => {
if (v(t) && v(r) && w.sameSet(t.marks, r.marks))
return e.text(t.text + r.text, t.marks);
}, Z = (e) => (t, r) => W(e)(K(t, [], r)), T = (e) => (t, r, s) => {
const n = t.createAndFill(r, s, e.marks);
if (!n)
throw q(t, r, s);
return Q(e)(n), n;
}, b = (e) => () => {
e.marks = w.none;
const t = X(e);
return T(e)(t.type, t.attrs, t.content);
}, _ = (e) => (t, r) => {
const s = t.create(r);
e.marks = s.addToSet(e.marks);
}, tt = (e) => (t) => {
e.marks = t.removeFromSet(e.marks);
}, et = (e) => (t) => {
const r = V(e);
if (!r)
throw A(t, s, n);
return H(e)(r), r;
}, T = (e) => () => {
e.marks = $.none;
const t = Q(e);
return E(e)(t.type, t.attrs, t.content);
}, X = (e) => (t, s) => {
const n = t.create(s);
e.marks = n.addToSet(e.marks);
}, Y = (e) => (t) => {
e.marks = t.removeFromSet(e.marks);
}, Z = (e) => (t) => {
const s = K(e);
if (!s)
throw v();
const n = s.pop(), r = e.schema.text(t, e.marks);
if (!n) {
s.push(r);
throw $();
const s = r.pop(), n = e.schema.text(t, e.marks);
if (!s) {
r.push(n);
return;
}
const o = V(e.schema, n, r);
const o = Y(e.schema, s, n);
if (o) {
s.push(o);
r.push(o);
return;
}
s.push(n, r);
}, _ = (e) => () => {
r.push(s, n);
}, rt = (e) => () => {
let t;
do
t = T(e)();
while (G(e));
t = b(e)();
while (L(e));
return t;
}, tt = (e) => {
}, st = (e) => {
const t = {

@@ -90,86 +92,96 @@ marks: [],

return {
build: _(t),
openMark: X(t),
closeMark: Y(t),
addText: Z(t),
openNode: W(t),
addNode: E(t),
closeNode: T(t)
build: rt(t),
openMark: _(t),
closeMark: tt(t),
addText: et(t),
openNode: Z(t),
addNode: T(t),
closeNode: b(t)
};
};
var k, b, m, P;
class et {
constructor(t, s, n) {
h(this, k);
h(this, m);
this.stack = t, this.schema = s, this.specMap = n, this.run = (r, o) => {
const c = r.runSync(r.parse(o), o);
return this.next(c), this;
}, this.next = (r = []) => ([r].flat().forEach((o) => a(this, m, P).call(this, o)), this), this.toDoc = () => this.stack.build(), this.injectRoot = (r, o, c) => (this.stack.openNode(o, c), this.next(r.children), this), this.addText = (r = "") => (this.stack.addText(r), this), this.addNode = (...r) => (this.stack.addNode(...r), this), this.openNode = (...r) => (this.stack.openNode(...r), this), this.closeNode = (...r) => (this.stack.closeNode(...r), this), this.openMark = (...r) => (this.stack.openMark(...r), this), this.closeMark = (...r) => (this.stack.closeMark(...r), this);
var m, P, f, z;
class nt {
constructor(t, r, s) {
u(this, m);
u(this, f);
i(this, "run", (t, r) => {
const s = t.runSync(t.parse(r), r);
return this.next(s), this;
});
i(this, "next", (t = []) => ([t].flat().forEach((r) => h(this, f, z).call(this, r)), this));
i(this, "toDoc", () => this.stack.build());
i(this, "injectRoot", (t, r, s) => (this.stack.openNode(r, s), this.next(t.children), this));
i(this, "addText", (t = "") => (this.stack.addText(t), this));
i(this, "addNode", (...t) => (this.stack.addNode(...t), this));
i(this, "openNode", (...t) => (this.stack.openNode(...t), this));
i(this, "closeNode", (...t) => (this.stack.closeNode(...t), this));
i(this, "openMark", (...t) => (this.stack.openMark(...t), this));
i(this, "closeMark", (...t) => (this.stack.closeMark(...t), this));
this.stack = t, this.schema = r, this.specMap = s;
}
}
k = new WeakSet(), b = function(t) {
const s = Object.values(this.specMap).find((n) => n.match(t));
if (!s)
throw C(t);
return s;
}, m = new WeakSet(), P = function(t) {
const { key: s, runner: n, is: r } = a(this, k, b).call(this, t), o = this.schema[r === "node" ? "nodes" : "marks"][s];
n(this, t, o);
m = new WeakSet(), P = function(t) {
const r = Object.values(this.specMap).find((s) => s.match(t));
if (!r)
throw x(t);
return r;
}, f = new WeakSet(), z = function(t) {
const { key: r, runner: s, is: n } = h(this, m, P).call(this, t), o = this.schema[n === "node" ? "nodes" : "marks"][r];
s(this, t, o);
};
const yt = (e, t, s) => {
const n = new et(tt(e), e, t);
return (r) => (n.run(s, r), n.toDoc());
}, st = (e, t, ...s) => {
e.children || (e.children = []), e.children.push(t, ...s);
}, rt = (e) => {
const vt = (e, t, r) => {
const s = new nt(st(e), e, t);
return (n) => (s.run(r, n), s.toDoc());
}, ot = (e, t, ...r) => {
e.children || (e.children = []), e.children.push(t, ...r);
}, ct = (e) => {
var t;
return (t = e.children) == null ? void 0 : t.pop();
}, z = (e, t, s, n = {}) => {
const r = {
}, O = (e, t, r, s = {}) => {
const n = {
type: e,
children: t,
props: n,
value: s,
push: (...o) => st(r, ...o),
pop: () => rt(r)
props: s,
value: r,
push: (...o) => ot(n, ...o),
pop: () => ct(n)
};
return r;
}, { size: nt, push: ot, open: ct, close: it } = w(), at = (e, t) => {
return n;
}, { size: it, push: at, open: ht, close: ut } = E(), pt = (e, t) => {
var c;
if (e.type === t || ((c = e.children) == null ? void 0 : c.length) !== 1)
return e;
const s = (i) => {
var p;
if (i.type === t)
return i;
if (((p = i.children) == null ? void 0 : p.length) !== 1)
const r = (a) => {
var d;
if (a.type === t)
return a;
if (((d = a.children) == null ? void 0 : d.length) !== 1)
return null;
const [u] = i.children;
return u ? s(u) : null;
}, n = s(e);
if (!n)
const [p] = a.children;
return p ? r(p) : null;
}, s = r(e);
if (!s)
return e;
const r = n.children ? [...n.children] : void 0, o = { ...e, children: r };
return o.children = r, n.children = [o], n;
}, O = (e) => {
const n = s.children ? [...s.children] : void 0, o = { ...e, children: n };
return o.children = n, s.children = [o], s;
}, F = (e) => {
const { children: t } = e;
return t && (e.children = t.reduce((s, n, r) => {
if (r === 0)
return [n];
const o = s[s.length - 1];
if (o && o.isMark && n.isMark) {
n = at(n, o.type);
const { children: c, ...i } = n, { children: u, ...p } = o;
if (n.type === o.type && c && u && JSON.stringify(i) === JSON.stringify(p)) {
const D = {
...p,
children: [...u, ...c]
return t && (e.children = t.reduce((r, s, n) => {
if (n === 0)
return [s];
const o = r[r.length - 1];
if (o && o.isMark && s.isMark) {
s = pt(s, o.type);
const { children: c, ...a } = s, { children: p, ...d } = o;
if (s.type === o.type && c && p && JSON.stringify(a) === JSON.stringify(d)) {
const J = {
...d,
children: [...p, ...c]
};
return s.slice(0, -1).concat(O(D));
return r.slice(0, -1).concat(F(J));
}
}
return s.concat(n);
return r.concat(s);
}, [])), e;
}, ht = (e) => {
}, dt = (e) => {
const t = {

@@ -180,17 +192,17 @@ ...e.props,

return e.children && (t.children = e.children), e.value && (t.value = e.value), t;
}, F = (e) => (t, s, n) => ct(e)(z(t, [], s, n)), I = (e) => (t, s, n, r) => {
const o = z(t, s, n, r), c = O(ht(o));
return ot(e)(c), c;
}, g = (e) => () => {
const t = it(e);
return I(e)(t.type, t.children, t.value, t.props);
}, ut = (e) => (t, s, n, r) => {
t.isInSet(e.marks) || (e.marks = t.addToSet(e.marks), F(e)(s, n, { ...r, isMark: !0 }));
}, pt = (e) => (t) => t.isInSet(e.marks) ? (e.marks = t.type.removeFromSet(e.marks), g(e)()) : null, dt = (e) => () => {
}, I = (e) => (t, r, s) => ht(e)(O(t, [], r, s)), j = (e) => (t, r, s, n) => {
const o = O(t, r, s, n), c = F(dt(o));
return at(e)(c), c;
}, S = (e) => () => {
const t = ut(e);
return j(e)(t.type, t.children, t.value, t.props);
}, lt = (e) => (t, r, s, n) => {
t.isInSet(e.marks) || (e.marks = t.addToSet(e.marks), I(e)(r, s, { ...n, isMark: !0 }));
}, kt = (e) => (t) => t.isInSet(e.marks) ? (e.marks = t.type.removeFromSet(e.marks), S(e)()) : null, mt = (e) => () => {
let t = null;
do
t = g(e)();
while (nt(e));
t = S(e)();
while (it(e));
return t;
}, lt = () => {
}, ft = () => {
const e = {

@@ -201,20 +213,26 @@ marks: [],

return {
build: dt(e),
openMark: ut(e),
closeMark: pt(e),
openNode: F(e),
addNode: I(e),
closeNode: g(e)
build: mt(e),
openMark: lt(e),
closeMark: kt(e),
openNode: I(e),
addNode: j(e),
closeNode: S(e)
};
}, kt = (e) => Object.prototype.hasOwnProperty.call(e, "size");
var d, M, f, j, N, R, l, y;
class mt {
constructor(t, s, n) {
h(this, d);
h(this, f);
h(this, N);
h(this, l);
this.stack = t, this.schema = s, this.specMap = n, this.toString = (r) => r.stringify(this.stack.build()), this.next = (r) => kt(r) ? (r.forEach((o) => {
a(this, l, y).call(this, o);
}), this) : (a(this, l, y).call(this, r), this), this.addNode = (...r) => (this.stack.addNode(...r), this), this.openNode = (...r) => (this.stack.openNode(...r), this), this.closeNode = (...r) => (this.stack.closeNode(...r), this), this.withMark = (...r) => (this.stack.openMark(...r), this);
}, Nt = (e) => Object.prototype.hasOwnProperty.call(e, "size");
var l, y, N, R, M, D, k, g;
class Mt {
constructor(t, r, s) {
u(this, l);
u(this, N);
u(this, M);
u(this, k);
i(this, "toString", (t) => t.stringify(this.stack.build()));
i(this, "next", (t) => Nt(t) ? (t.forEach((r) => {
h(this, k, g).call(this, r);
}), this) : (h(this, k, g).call(this, t), this));
i(this, "addNode", (...t) => (this.stack.addNode(...t), this));
i(this, "openNode", (...t) => (this.stack.openNode(...t), this));
i(this, "closeNode", (...t) => (this.stack.closeNode(...t), this));
i(this, "withMark", (...t) => (this.stack.openMark(...t), this));
this.stack = t, this.schema = r, this.specMap = s;
}

@@ -225,32 +243,32 @@ run(t) {

}
d = new WeakSet(), M = function(t) {
const s = Object.entries(this.specMap).map(([n, r]) => ({
key: n,
...r
})).find((n) => n.match(t));
if (!s)
throw U(t.type);
return s;
}, f = new WeakSet(), j = function(t) {
const { runner: s } = a(this, d, M).call(this, t);
s(this, t);
}, N = new WeakSet(), R = function(t, s) {
const { runner: n } = a(this, d, M).call(this, t);
return n(this, t, s);
}, l = new WeakSet(), y = function(t) {
const { marks: s } = t, n = (c) => {
var i;
return (i = c.type.spec.priority) != null ? i : 50;
l = new WeakSet(), y = function(t) {
const r = Object.entries(this.specMap).map(([s, n]) => ({
key: s,
...n
})).find((s) => s.match(t));
if (!r)
throw B(t.type);
return r;
}, N = new WeakSet(), R = function(t) {
const { runner: r } = h(this, l, y).call(this, t);
r(this, t);
}, M = new WeakSet(), D = function(t, r) {
const { runner: s } = h(this, l, y).call(this, t);
return s(this, t, r);
}, k = new WeakSet(), g = function(t) {
const { marks: r } = t, s = (c) => {
var a;
return (a = c.type.spec.priority) != null ? a : 50;
};
[...s].sort((c, i) => n(c) - n(i)).every((c) => !a(this, N, R).call(this, c, t)) && a(this, f, j).call(this, t), s.forEach((c) => this.stack.closeMark(c));
[...r].sort((c, a) => s(c) - s(a)).every((c) => !h(this, M, D).call(this, c, t)) && h(this, N, R).call(this, t), r.forEach((c) => this.stack.closeMark(c));
};
const gt = (e, t, s) => (n) => {
const r = new mt(lt(), e, t);
return r.run(n), r.toString(s);
const $t = (e, t, r) => (s) => {
const n = new Mt(ft(), e, t);
return n.run(s), n.toString(r);
};
export {
yt as createParser,
gt as createSerializer,
w as getStackUtil
vt as createParser,
$t as createSerializer,
E as getStackUtil
};
//# sourceMappingURL=index.es.js.map
{
"name": "@milkdown/transformer",
"version": "6.5.0",
"version": "6.5.2",
"type": "module",

@@ -20,3 +20,3 @@ "main": "./lib/index.es.js",

"devDependencies": {
"@milkdown/prose": "6.5.0"
"@milkdown/prose": "6.5.2"
},

@@ -27,3 +27,3 @@ "peerDependencies": {

"dependencies": {
"@milkdown/exception": "6.5.0",
"@milkdown/exception": "6.5.2",
"@types/mdast": "^3.0.10",

@@ -30,0 +30,0 @@ "@types/unist": "^2.0.6",

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