@milkdown/ctx
Advanced tools
Comparing version 6.3.2 to 6.4.0
@@ -1,97 +0,109 @@ | ||
var y = (t, n, i) => { | ||
if (!n.has(t)) | ||
var S = (e, s, i) => { | ||
if (!s.has(e)) | ||
throw TypeError("Cannot " + i); | ||
}; | ||
var u = (t, n, i) => (y(t, n, "read from private field"), i ? i.call(t) : n.get(t)), h = (t, n, i) => { | ||
if (n.has(t)) | ||
var o = (e, s, i) => (S(e, s, "read from private field"), i ? i.call(e) : s.get(e)), h = (e, s, i) => { | ||
if (s.has(e)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
n instanceof WeakSet ? n.add(t) : n.set(t, i); | ||
}, l = (t, n, i, e) => (y(t, n, "write to private field"), e ? e.call(t, i) : n.set(t, i), i); | ||
import { contextNotFound as C, ctxCallOutOfScope as S, timerNotFound as E } from "@milkdown/exception"; | ||
s instanceof WeakSet ? s.add(e) : s.set(e, i); | ||
}, a = (e, s, i, t) => (S(e, s, "write to private field"), t ? t.call(e, i) : s.set(e, i), i); | ||
import { contextNotFound as E, ctxCallOutOfScope as T, timerNotFound as M } from "@milkdown/exception"; | ||
const N = () => { | ||
const t = /* @__PURE__ */ new Map(); | ||
const e = /* @__PURE__ */ new Map(); | ||
return { getSlice: (i) => { | ||
const e = typeof i == "string" ? [...t.values()].find((s) => s.name === i) : t.get(i.id); | ||
if (!e) { | ||
const s = typeof i == "string" ? i : i.sliceName; | ||
throw C(s); | ||
const t = typeof i == "string" ? [...e.values()].find((n) => n.name === i) : e.get(i.id); | ||
if (!t) { | ||
const n = typeof i == "string" ? i : i.sliceName; | ||
throw E(n); | ||
} | ||
return e; | ||
}, sliceMap: t }; | ||
}, T = (t) => Array.isArray(t) ? [...t] : typeof t == "object" ? { ...t } : t, P = (t, n) => { | ||
const i = Symbol("Context"), e = (s, c = T(t)) => { | ||
let o = c; | ||
const a = { | ||
name: n, | ||
return t; | ||
}, sliceMap: e }; | ||
}, P = (e) => Array.isArray(e) ? [...e] : typeof e == "object" ? { ...e } : e, j = (e, s) => { | ||
const i = Symbol("Context"), t = (n, d = P(e)) => { | ||
let r = d; | ||
const m = { | ||
name: s, | ||
id: i, | ||
set: (r) => { | ||
o = r; | ||
set: (c) => { | ||
r = c; | ||
}, | ||
get: () => o, | ||
update: (r) => { | ||
o = r(o); | ||
get: () => r, | ||
update: (c) => { | ||
r = c(r); | ||
} | ||
}; | ||
return s.set(i, a), a; | ||
return n.set(i, m), m; | ||
}; | ||
return e.sliceName = n, e.id = i, e._typeInfo = () => { | ||
throw S(); | ||
}, e; | ||
return t.sliceName = s, t.id = i, t._typeInfo = () => { | ||
throw T(); | ||
}, t; | ||
}; | ||
var d, m; | ||
class k { | ||
constructor(n, i) { | ||
h(this, d, void 0); | ||
h(this, m, void 0); | ||
this.use = (e) => u(this, d).getSlice(e), this.get = (e) => this.use(e).get(), this.set = (e, s) => this.use(e).set(s), this.update = (e, s) => this.use(e).update(s), this.timing = (e) => u(this, m).get(e), this.wait = (e) => this.timing(e)(), this.done = (e) => this.timing(e).done(), this.waitTimers = async (e) => { | ||
await Promise.all(this.get(e).map((s) => this.wait(s))); | ||
}, l(this, d, n), l(this, m, i); | ||
} | ||
} | ||
d = new WeakMap(), m = new WeakMap(); | ||
var g, p; | ||
class x { | ||
constructor(n, i) { | ||
constructor(s, i) { | ||
h(this, g, void 0); | ||
h(this, p, void 0); | ||
this.inject = (e, s) => (e(u(this, g).sliceMap, s), this), this.record = (e) => (e(u(this, p).store), this), l(this, g, n), l(this, p, i); | ||
this.use = (t) => o(this, g).getSlice(t), this.get = (t) => this.use(t).get(), this.set = (t, n) => this.use(t).set(n), this.update = (t, n) => this.use(t).update(n), this.timing = (t) => o(this, p).get(t), this.wait = (t) => this.timing(t)(), this.done = (t) => this.timing(t).done(), this.waitTimers = async (t) => { | ||
await Promise.all(this.get(t).map((n) => this.wait(n))); | ||
}, a(this, g, s), a(this, p, i); | ||
} | ||
} | ||
g = new WeakMap(), p = new WeakMap(); | ||
const L = () => { | ||
const t = /* @__PURE__ */ new Map(); | ||
var u, l; | ||
class L { | ||
constructor(s, i) { | ||
h(this, u, void 0); | ||
h(this, l, void 0); | ||
this.inject = (t, n) => (t(o(this, u).sliceMap, n), this), this.record = (t) => (t(o(this, l).store), this), this.use = (t) => o(this, u).getSlice(t), this.get = (t) => this.use(t).get(), this.set = (t, n) => this.use(t).set(n), this.update = (t, n) => this.use(t).update(n), this.timing = (t) => o(this, l).get(t), this.wait = (t) => this.timing(t)(), this.done = (t) => this.timing(t).done(), this.waitTimers = async (t) => { | ||
await Promise.all(this.get(t).map((n) => this.wait(n))); | ||
}, a(this, u, s), a(this, l, i); | ||
} | ||
} | ||
u = new WeakMap(), l = new WeakMap(); | ||
var w, f; | ||
class A { | ||
constructor(s, i) { | ||
h(this, w, void 0); | ||
h(this, f, void 0); | ||
this.inject = (t, n) => (t(o(this, w).sliceMap, n), this), this.record = (t) => (t(o(this, f).store), this), a(this, w, s), a(this, f, i); | ||
} | ||
} | ||
w = new WeakMap(), f = new WeakMap(); | ||
const F = () => { | ||
const e = /* @__PURE__ */ new Map(); | ||
return { | ||
store: t, | ||
store: e, | ||
get: (i) => { | ||
const e = t.get(i.id); | ||
if (!e) | ||
throw E(i.name); | ||
return e; | ||
const t = e.get(i.id); | ||
if (!t) | ||
throw M(i.name); | ||
return t; | ||
} | ||
}; | ||
}, j = (t, n = 3e3) => { | ||
const i = Symbol("Timer"), e = (s) => { | ||
let c = null, o; | ||
const a = Symbol(t), r = () => c != null ? c : c = new Promise((f, v) => { | ||
o = (w) => { | ||
w instanceof CustomEvent && w.detail.id === a && (removeEventListener(t, o), w.stopImmediatePropagation(), f()); | ||
}, I = (e, s = 3e3) => { | ||
const i = Symbol("Timer"), t = (n) => { | ||
let d = null, r; | ||
const m = Symbol(e), c = () => d != null ? d : d = new Promise((y, C) => { | ||
r = (v) => { | ||
v instanceof CustomEvent && v.detail.id === m && (removeEventListener(e, r), v.stopImmediatePropagation(), y()); | ||
}, setTimeout(() => { | ||
v(`Timing ${t} timeout.`), removeEventListener(t, o); | ||
}, n), addEventListener(t, o); | ||
C(`Timing ${e} timeout.`), removeEventListener(e, r); | ||
}, s), addEventListener(e, r); | ||
}); | ||
return r.done = () => { | ||
const f = new CustomEvent(t, { detail: { id: a } }); | ||
dispatchEvent(f); | ||
}, s.set(i, r), r; | ||
return c.done = () => { | ||
const y = new CustomEvent(e, { detail: { id: m } }); | ||
dispatchEvent(y); | ||
}, n.set(i, c), c; | ||
}; | ||
return e.id = i, e; | ||
return t.id = i, t; | ||
}; | ||
export { | ||
k as Ctx, | ||
x as Pre, | ||
L as createClock, | ||
x as Ctx, | ||
L as Env, | ||
A as Pre, | ||
F as createClock, | ||
N as createContainer, | ||
P as createSlice, | ||
j as createTimer | ||
j as createSlice, | ||
I as createTimer | ||
}; | ||
//# sourceMappingURL=index.es.js.map |
export * from './ctx'; | ||
export * from './env'; | ||
export * from './pre'; | ||
export * from './types'; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "@milkdown/ctx", | ||
"version": "6.3.2", | ||
"version": "6.4.0", | ||
"type": "module", | ||
@@ -23,3 +23,3 @@ "main": "./lib/index.es.js", | ||
"dependencies": { | ||
"@milkdown/exception": "6.3.2", | ||
"@milkdown/exception": "6.4.0", | ||
"tslib": "^2.4.0" | ||
@@ -26,0 +26,0 @@ }, |
/* Copyright 2021, Milkdown by Mirone. */ | ||
export * from './ctx'; | ||
export * from './env'; | ||
export * from './pre'; | ||
export * from './types'; |
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
51037
49
844
+ Added@milkdown/exception@6.4.0(transitive)
- Removed@milkdown/exception@6.3.2(transitive)
Updated@milkdown/exception@6.4.0