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

@cn-ui/reactive

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cn-ui/reactive - npm Package Compare versions

Comparing version 2.2.4 to 2.3.0

554

./dist/index.js

@@ -1,189 +0,233 @@

var R = Object.defineProperty, B = Object.defineProperties;
var F = Object.getOwnPropertyDescriptors;
var I = Object.getOwnPropertySymbols;
var J = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r) => {
for (var t in r || (r = {}))
J.call(r, t) && T(e, t, r[t]);
if (I)
for (var t of I(r))
N.call(r, t) && T(e, t, r[t]);
return e;
}, A = (e, r) => B(e, F(r));
var S = (e, r, t) => new Promise((n, o) => {
var c = (s) => {
var M = Object.defineProperty, R = Object.defineProperties;
var B = Object.getOwnPropertyDescriptors;
var T = Object.getOwnPropertySymbols;
var J = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
var P = (t, r, e) => r in t ? M(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, d = (t, r) => {
for (var e in r || (r = {}))
J.call(r, e) && P(t, e, r[e]);
if (T)
for (var e of T(r))
q.call(r, e) && P(t, e, r[e]);
return t;
}, v = (t, r) => R(t, B(r));
var S = (t, r, e) => new Promise((n, s) => {
var o = (c) => {
try {
u(t.next(s));
} catch (l) {
o(l);
a(e.next(c));
} catch (i) {
s(i);
}
}, a = (s) => {
}, u = (c) => {
try {
u(t.throw(s));
} catch (l) {
o(l);
a(e.throw(c));
} catch (i) {
s(i);
}
}, u = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(c, a);
u((t = t.apply(e, r)).next());
}, a = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(o, u);
a((e = e.apply(t, r)).next());
});
import { createEffect as x, on as q, createSignal as H, untrack as _, createMemo as M, batch as O, onCleanup as $ } from "solid-js";
import { debounce as D, throttle as z } from "lodash-es";
const g = (e, r, t = null) => {
import { createEffect as p, on as H, createSignal as _, untrack as $, createMemo as L, batch as k, onCleanup as z } from "solid-js";
import { debounce as N, throttle as C } from "lodash-es";
const A = (t, r, e = null) => {
let n = !0;
return C(
(o) => n ? (n = !1, null) : e(o),
return G(
(s) => n ? (n = !1, null) : t(s),
r,
t
e
);
}, ee = g, C = (e, r, t = null) => {
let n = t;
return x(
q(r, () => (n = e(n), n))
}, ne = A, G = (t, r, e = null) => {
let n = e;
return p(
H(r, () => (n = t(n), n))
);
}, d = Symbol("AtomTypeSymbol"), te = (e) => e[d], f = (e, r) => {
const [t, n] = H(e, r);
}, m = Symbol("AtomTypeSymbol"), se = (t) => t[m], f = (t, r) => {
const [e, n] = _(t, r);
return Object.assign(
(...o) => o.length === 0 ? t() : n(...o),
{ reflux: K, [d]: "atom" }
(...s) => s.length === 0 ? e() : n(...s),
{ reflux: K, [m]: "atom" }
);
}, K = function(e, r, t) {
const n = this, o = f(e, t);
return g(() => {
n(() => r(o()));
}, [o]), o[d] = "reflux", o;
}, k = (e, {
}, K = function(t, r, e) {
const n = this, s = f(t, e);
return A(() => {
n(() => r(s()));
}, [s]), s[m] = "reflux", s;
}, y = (t, {
immediately: r = !0,
initValue: t = null
initValue: e = null
} = {}) => {
const n = f(r ? _(() => e(t)) : t);
return x((o) => {
n(() => e(o));
}, t), n[d] = "reflect", n;
}, U = (e, {
const n = f(r ? $(() => t(e)) : e);
return p((s) => {
n(() => t(s));
}, e), n[m] = "reflect", n;
}, U = (t, {
immediately: r = !0,
initValue: t = null
} = {}) => M((n) => {
const o = e(n);
return r ? o : (r = !0, t);
}, t), W = (e, {
initValue: e = null
} = {}) => L((n) => {
const s = t(n);
return r ? s : (r = !0, e);
}, e), V = (t, {
initValue: r = null,
immediately: t = !0,
immediately: e = !0,
deps: n,
refetch: o = {},
tap: c = (u) => {
refetch: s = {},
tap: o = (a) => {
},
ignoreError: a = !1
ignoreError: u = !1
} = {}) => {
const u = f(r), s = f(!1), l = f(!1), i = M(() => !s() && !l());
const a = f(r), c = f(!1), i = f(!1), l = L(() => !c() && !i());
let h = Promise.resolve(!1);
const v = (...Se) => S(void 0, [...Se], function* ({ warn: b = !0, cancelCallback: p } = o) {
i() || (p ? p(h) : b && console.warn(
const E = (...be) => S(void 0, [...be], function* ({ warn: x = !0, cancelCallback: I } = s) {
l() || (I ? I(h) : x && console.warn(
"Resource Atom: some fetch has been covered; Recommend to add a cancelCallback to some Hook"
)), s(!0);
const E = e().then((m) => (O(() => {
u(() => m), s(!1), l(!1);
}), E === h && c(m), !0)).catch((m) => (O(() => {
l(m), s(!1);
}), a || console.error(m), m));
return h = E, E;
)), c(!0);
const O = t().then((g) => (k(() => {
a(() => g), c(!1), i(!1);
}), O === h && o(g), !0)).catch((g) => (k(() => {
i(g), c(!1);
}), u || console.error(g), g));
return h = O, O;
});
return t && v(), n && n.length && g(() => v(o), n), Object.assign(u, {
error: l,
loading: s,
mutate(b) {
u(() => b);
return e && E(), n && n.length && A(() => E(s), n), Object.assign(a, {
error: i,
loading: c,
mutate(x) {
a(() => x);
},
isReady: i,
refetch: v,
isReady: l,
refetch: E,
promise: () => h,
[d]: "resource"
[m]: "resource"
});
};
let L = () => {
let D = () => {
};
const re = (e) => {
e && (L = e);
}, G = function(e, r = L) {
let t = !1;
const oe = (t) => {
t && (D = t);
}, W = function(t, r = D) {
let e = !1;
return function(...n) {
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, n)).then((o) => (t = !1, o)), t);
return e ? (r && r(), e) : (e = Promise.resolve(t.apply(this, n)).then((s) => (e = !1, s)), e);
};
}, ne = G;
function P(e) {
return typeof e == "function" ? w(e) ? e : k(e()) : f(e);
}, ce = W;
function j(t) {
return typeof t == "function" ? w(t) ? t : y(t()) : f(t);
}
function w(e) {
return typeof e[d] == "string";
function w(t) {
return typeof t[m] == "string";
}
const se = (e) => e().map((r, t) => k(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({
value: e(),
"on:input": (r) => e(() => r.target.value)
}), ce = (e, r, t) => {
var c, a, u;
const n = (c = t == null ? void 0 : t.parse) != null ? c : (s) => JSON.parse(s), o = (a = t == null ? void 0 : t.stringify) != null ? a : (s) => JSON.stringify(s);
if ((u = t == null ? void 0 : t.immediately) == null || u) {
const s = localStorage.getItem(r);
s && e(n(s));
const ue = (t) => t().map((r, e) => y(() => t()[e])), Q = (t, r) => new Promise((e) => setTimeout(() => e(r), t)), ae = (t, { valueName: r = "value" }) => ({
value: t(),
"on:input": (e) => t(() => e.target.value)
}), ie = (t, r, e) => {
var o, u, a;
const n = (o = e == null ? void 0 : e.parse) != null ? o : (c) => JSON.parse(c), s = (u = e == null ? void 0 : e.stringify) != null ? u : (c) => JSON.stringify(c);
if ((a = e == null ? void 0 : e.immediately) == null || a) {
const c = localStorage.getItem(r);
c && t(n(c));
}
return g(() => {
localStorage.setItem(r, o(e()));
}, [e]), e;
}, ae = (e) => [...Array(e).keys()];
function j(e, r) {
const t = w(e) ? e : f(e, r), n = (c, a, u) => {
const s = c.findIndex((l) => l === a);
if (s >= 0) {
const l = [...c];
return u(l, s), l;
return A(() => {
localStorage.setItem(r, s(t()));
}, [t]), t;
}, le = (t) => [...Array(t).keys()], X = (t, r) => Object.fromEntries(r.map((e) => [e, function(...n) {
return t((s) => {
const o = [...s];
return o[e](...n), o;
}), this;
}])), Y = (t, r) => Object.fromEntries(r.map((e) => [e, function(...n) {
return y(() => t()[e](...n));
}])), F = (t, r, e = !1) => Object.fromEntries(r.map((n) => [n, function(...s) {
return b(y(e ? () => [...t()][n](...s) : () => t()[n](...s)));
}]));
function b(t, r) {
const e = w(t) ? t : f(t, r), n = (o, u, a) => {
const c = o.findIndex((i) => i === u);
if (c >= 0) {
const i = [...o];
return a(i, c), i;
} else
return console.warn("Can't find array atom Item: ", a), c;
};
return Object.assign(t, A(y({}, {
replace(c, a) {
return t((u) => n(u, c, (s, l) => {
s[l] = a;
return console.warn("Can't find array atom Item: ", u), o;
}, s = d(d(d(d({
replace(o, u) {
return e((a) => n(a, o, (c, i) => {
c[i] = u;
})), this;
},
replaceAll(c, a) {
return t((u) => {
const s = [];
u.forEach((i, h) => i === c && s.push(h));
const l = [...u];
return s.forEach((i) => l[i] = a), l;
replaceAll(o, u) {
return e((a) => {
const c = [];
a.forEach((l, h) => l === o && c.push(h));
const i = [...a];
return c.forEach((l) => i[l] = u), i;
}), this;
},
remove(c) {
return t((a) => n(a, c, (u, s) => {
u.splice(s, 1);
remove(o) {
return e((u) => n(u, o, (a, c) => {
a.splice(c, 1);
})), this;
},
removeAll(c) {
return t((a) => a.filter((u) => u !== c)), this;
removeAll(o) {
return e((u) => u.filter((a) => a !== o)), this;
},
insert(c, a, u = "before") {
return t((s) => n(s, a, (l, i) => {
l.splice(u === "before" ? i : i + 1, 0, c);
insert(o, u, a = "before") {
return e((c) => n(c, u, (i, l) => {
i.splice(a === "before" ? l : l + 1, 0, o);
})), this;
},
move(c, a, u) {
return this.remove(c), this.insert(c, a, u), this;
move(o, u, a) {
return this.remove(o), this.insert(o, u, a), this;
},
switch(c, a) {
return t((u) => {
const s = [...u], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === a);
if (l === -1 || i === -1)
switch(o, u) {
return e((a) => {
const c = [...a], i = e().findIndex((h) => h === o), l = e().findIndex((h) => h === u);
if (i === -1 || l === -1)
throw new Error("ArrayAtom: Please check the Items you want to switch ");
return s[l] = a, s[i] = c, s;
return c[i] = u, c[l] = o, c;
}), this;
},
toggle(o) {
return e((u) => {
const a = u.indexOf(o);
return a === -1 ? [...u, o] : [...u.splice(a, 1)];
}), this;
},
forEach(o, u) {
p(() => e().forEach(o));
}
}), { [d]: "array" }));
}, X(e, ["push", "pop", "shift", "unshift"])), Y(
e,
[
"join",
"indexOf",
"lastIndexOf",
"every",
"some",
"reduce",
"reduceRight"
]
)), F(
e,
[
"slice",
"map",
"filter"
]
)), F(
e,
[
"reverse",
"sort",
"splice"
],
!0
));
return Object.assign(e, v(d({}, s), { [m]: "array" }));
}
function ue(e, r) {
const t = w(e) ? e : f(e, { equals: !1 }), n = w(e) ? e() : e;
return t[d] = "object", Object.assign(
t,
function fe(t, r) {
const e = w(t) ? t : f(t, { equals: !1 }), n = w(t) ? t() : t;
return e[m] = "object", Object.assign(
e,
Object.fromEntries(
Object.keys(n).reduce((o, c) => {
const a = t.reflux(t()[c], (u) => A(y({}, t()), { [c]: u }));
return o.push([c, a]), o;
Object.keys(n).reduce((s, o) => {
const u = e.reflux(e()[o], (a) => v(d({}, e()), { [o]: a }));
return s.push([o, u]), s;
}, [])

@@ -193,153 +237,153 @@ )

}
function le(e, r = 150) {
let t = e();
const n = f(t);
return g(
D(() => {
const o = e();
o !== void 0 && n(() => o);
function he(t, r = 150) {
let e = t();
const n = f(e);
return A(
N(() => {
const s = t();
s !== void 0 && n(() => s);
}, r),
[e]
[t]
), n;
}
function ie(e, r = 150, t) {
let n = e();
const o = f(n);
return g(
z(
function de(t, r = 150, e) {
let n = t();
const s = f(n);
return A(
C(
() => {
const c = e();
c !== void 0 && o(() => c);
const o = t();
o !== void 0 && s(() => o);
},
r,
t
e
),
[e]
), o;
[t]
), s;
}
const fe = () => {
const e = /* @__PURE__ */ new Map();
const me = () => {
const t = /* @__PURE__ */ new Map();
return {
register(r, t) {
if (e.has(r))
register(r, e) {
if (t.has(r))
throw new Error("Blackboard has a same app named " + r.toString());
return e.set(r, t);
return t.set(r, e);
},
getApp(r) {
if (!e.has(r))
if (!t.has(r))
throw new Error(`Blackboard app ${r.toString()} isn't init yet`);
return e.get(r);
return t.get(r);
},
delete(r) {
if (!e.has(r))
if (!t.has(r))
throw new Error(`Blackboard app ${r.toString()} isn't init yet`);
e.delete(r);
t.delete(r);
},
check(r) {
return e.has(r);
return t.has(r);
},
destroy() {
e.clear();
t.clear();
}
};
}, V = (e, r = {}) => {
var u, s;
r.debounceTime = (u = r.debounceTime) != null ? u : 100;
const t = f((s = r.initIndex) != null ? s : 0), n = f(10), o = W(() => e(t(), n), r), c = D(() => o.refetch(), r.debounceTime), a = (i) => {
if (i < 0 || i >= n())
}, Z = (t, r = {}) => {
var a, c;
r.debounceTime = (a = r.debounceTime) != null ? a : 100;
const e = f((c = r.initIndex) != null ? c : 0), n = f(10), s = V(() => t(e(), n), r), o = N(() => s.refetch(), r.debounceTime), u = (l) => {
if (l < 0 || l >= n())
return !1;
{
t(i);
e(l);
//! 页码改变如果迅速的话,那应该不进行请求,而是直接忽略
return c();
return o();
}
};
return {
currentIndex: t,
currentPage: U(() => t() + 1),
currentIndex: e,
currentPage: U(() => e() + 1),
maxPage: n,
prev() {
return a(t() - 1);
return u(e() - 1);
},
next() {
return a(t() + 1);
return u(e() + 1);
},
waitForDone() {
return S(this, null, function* () {
return Q(r.debounceTime + 10).then(o.promise);
return Q(r.debounceTime + 10).then(s.promise);
});
},
refetch: c,
goto: a,
currentData: o
refetch: o,
goto: u,
currentData: s
};
}, he = (e, r) => {
const t = f([], { equals: !1 }), n = V((...o) => S(void 0, null, function* () {
const c = yield e(...o);
return t((a) => (a[o[0]] = c, a)), c;
}, ge = (t, r) => {
const e = f([], { equals: !1 }), n = Z((...s) => S(void 0, null, function* () {
const o = yield t(...s);
return e((u) => (u[s[0]] = o, u)), o;
}), r);
return A(y({}, n), {
resetStack(o = !0) {
O(() => {
t([]), n.currentIndex(0), o && n.currentData.refetch();
return v(d({}, n), {
resetStack(s = !0) {
k(() => {
e([]), n.currentIndex(0), s && n.currentData.refetch();
});
},
dataSlices: t
dataSlices: e
});
}, de = function(e = {}) {
var a, u;
const r = j(P((a = e.activeIds) != null ? a : [])), t = P((u = e.multi) != null ? u : !0), n = f(new Set(r()));
x(() => {
!t() && r((s) => s.slice(0, 1)), n(() => new Set(r()));
}, ye = function(t = {}) {
var u, a;
const r = b(j((u = t.activeIds) != null ? u : [])), e = j((a = t.multi) != null ? a : !0), n = f(new Set(r()));
p(() => {
!e() && r((c) => c.slice(0, 1)), n(() => new Set(r()));
});
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (s, l) => {
l === void 0 && (l = !n().has(s)), l === !0 && !n().has(s) ? r((i) => t() ? [...i, s] : [s]) : l === !1 && r.removeAll(s);
const s = f(/* @__PURE__ */ new Set(), { equals: !1 }), o = (c, i) => {
i === void 0 && (i = !n().has(c)), i === !0 && !n().has(c) ? r((l) => e() ? [...l, c] : [c]) : i === !1 && r.removeAll(c);
};
return {
changeSelected: c,
register(s, l = !1) {
o((i) => (i.add(s), i)), c(s, l);
changeSelected: o,
register(c, i = !1) {
s((l) => (l.add(c), l)), o(c, i);
},
deregister(s) {
r.removeAll(s), o((l) => (l.delete(s), l));
deregister(c) {
r.removeAll(c), s((i) => (i.delete(c), i));
},
allRegistered: o,
allRegistered: s,
activeIds: n,
isSelected: (s) => n().has(s)
isSelected: (c) => n().has(c)
};
}, me = (e, r, t, {
on: n = (c) => c.addEventListener,
off: o = (c) => c.removeEventListener
}, Ae = (t, r, e, {
on: n = (o) => o.addEventListener,
off: s = (o) => o.removeEventListener
} = {}) => {
n(e).call(e, r, t), $(() => {
o(e).call(e, r, t);
n(t).call(t, r, e), z(() => {
s(t).call(t, r, e);
});
}, ge = (e) => {
const r = (t, n, o) => {
const c = o != null ? o : new n();
return Object.entries(t()).forEach(([a, u]) => {
c.set(a, u.toString());
}), c;
}, ve = (t) => {
const r = (e, n, s) => {
const o = s != null ? s : new n();
return Object.entries(e()).forEach(([u, a]) => {
o.set(u, a.toString());
}), o;
};
return {
toKeysAtom() {
return k(() => j(Object.keys(e)));
return y(() => b(Object.keys(t)));
},
toEntries() {
return Object.entries(e());
return Object.entries(t());
},
toFromData(t) {
return r(e, FormData, t);
toFromData(e) {
return r(t, FormData, e);
},
toSearchParams(t) {
return r(e, URLSearchParams, t);
toSearchParams(e) {
return r(t, URLSearchParams, e);
},
toHeaders(t) {
return r(e, Headers, t);
toHeaders(e) {
return r(t, Headers, e);
},
toMap(t) {
return r(e, Map, t);
toMap(e) {
return r(t, Map, e);
},
toJSON() {
return JSON.stringify(e());
return JSON.stringify(t());
}

@@ -349,32 +393,32 @@ };

export {
j as ArrayAtom,
se as AtomToArray,
d as AtomTypeSymbol,
le as DebounceAtom,
ge as EntriesTransform,
ue as ObjectAtom,
ie as ThrottleAtom,
oe as VModel,
me as addListener,
G as asyncLock,
b as ArrayAtom,
ue as AtomToArray,
m as AtomTypeSymbol,
he as DebounceAtom,
ve as EntriesTransform,
fe as ObjectAtom,
de as ThrottleAtom,
ae as VModel,
Ae as addListener,
W as asyncLock,
f as atom,
P as atomization,
fe as createBlackBoard,
ee as createIgnoreFirst,
ae as genArray,
te as getAtomType,
j as atomization,
me as createBlackBoard,
ne as createIgnoreFirst,
le as genArray,
se as getAtomType,
w as isAtom,
ce as localSync,
k as reflect,
ie as localSync,
y as reflect,
U as reflectMemo,
W as resource,
re as setAsyncLockDefaultRefuse,
V as resource,
oe as setAsyncLockDefaultRefuse,
Q as sleep,
C as useEffect,
g as useEffectWithoutFirst,
V as usePagination,
he as usePaginationStack,
de as useSelect,
ne as useSingleAsync
G as useEffect,
A as useEffectWithoutFirst,
Z as usePagination,
ge as usePaginationStack,
ye as useSelect,
ce as useSingleAsync
};
//# sourceMappingURL=index.js.map

@@ -1,5 +0,32 @@

import type { SignalOptions } from 'solid-js';
import { SignalOptions } from 'solid-js';
import { Atom } from './atom';
import type { InferArray } from '../typeUtils';
export interface ArrayAtomExtends<T> {
export interface BaseArrayAtomHandle<T> {
push(...items: T[]): this;
pop(): this;
shift(): this;
unshift(...items: T[]): this;
join(separator?: string): Atom<string>;
indexOf(searchElement: T, fromIndex?: number): Atom<number>;
lastIndexOf(searchElement: T, fromIndex?: number): Atom<number>;
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
every<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): this is ArrayAtomType<S[]>;
every(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): Atom<boolean>;
some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): Atom<boolean>;
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Atom<T>;
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): Atom<T>;
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Atom<U>;
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Atom<T>;
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): Atom<T>;
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Atom<U>;
reverse(): ArrayAtomType<T[]>;
slice(start?: number, end?: number): ArrayAtomType<T[]>;
sort(compareFn?: (a: T, b: T) => number): ArrayAtomType<T[]>;
splice(start: number, deleteCount?: number): ArrayAtomType<T[]>;
splice(start: number, deleteCount: number, ...items: T[]): ArrayAtomType<T[]>;
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): ArrayAtomType<U[]>;
filter<S extends T>(predicate: (value: T, index: number, array: T[]) => value is S, thisArg?: any): ArrayAtomType<S[]>;
filter(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): ArrayAtomType<T[]>;
}
export interface ArrayAtomExtends<T> extends BaseArrayAtomHandle<T> {
replace(oldItem: T, newItem: T): this;

@@ -12,2 +39,3 @@ replaceAll(oldItem: T, newItem: T): this;

switch(thisItem: T, nearByItem: T): this;
toggle(thisItem: T): this;
}

@@ -14,0 +42,0 @@ export interface ArrayAtomType<Arr extends any[]> extends Atom<Arr>, ArrayAtomExtends<InferArray<Arr>> {

@@ -1,189 +0,233 @@

var R = Object.defineProperty, B = Object.defineProperties;
var F = Object.getOwnPropertyDescriptors;
var I = Object.getOwnPropertySymbols;
var J = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
var T = (e, r, t) => r in e ? R(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, y = (e, r) => {
for (var t in r || (r = {}))
J.call(r, t) && T(e, t, r[t]);
if (I)
for (var t of I(r))
N.call(r, t) && T(e, t, r[t]);
return e;
}, A = (e, r) => B(e, F(r));
var S = (e, r, t) => new Promise((n, o) => {
var c = (s) => {
var M = Object.defineProperty, R = Object.defineProperties;
var B = Object.getOwnPropertyDescriptors;
var T = Object.getOwnPropertySymbols;
var J = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
var P = (t, r, e) => r in t ? M(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e, d = (t, r) => {
for (var e in r || (r = {}))
J.call(r, e) && P(t, e, r[e]);
if (T)
for (var e of T(r))
q.call(r, e) && P(t, e, r[e]);
return t;
}, v = (t, r) => R(t, B(r));
var S = (t, r, e) => new Promise((n, s) => {
var o = (c) => {
try {
u(t.next(s));
} catch (l) {
o(l);
a(e.next(c));
} catch (i) {
s(i);
}
}, a = (s) => {
}, u = (c) => {
try {
u(t.throw(s));
} catch (l) {
o(l);
a(e.throw(c));
} catch (i) {
s(i);
}
}, u = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(c, a);
u((t = t.apply(e, r)).next());
}, a = (c) => c.done ? n(c.value) : Promise.resolve(c.value).then(o, u);
a((e = e.apply(t, r)).next());
});
import { createEffect as x, on as q, createSignal as H, untrack as _, createMemo as M, batch as O, onCleanup as $ } from "solid-js";
import { debounce as D, throttle as z } from "lodash-es";
const g = (e, r, t = null) => {
import { createEffect as p, on as H, createSignal as _, untrack as $, createMemo as L, batch as k, onCleanup as z } from "solid-js";
import { debounce as N, throttle as C } from "lodash-es";
const A = (t, r, e = null) => {
let n = !0;
return C(
(o) => n ? (n = !1, null) : e(o),
return G(
(s) => n ? (n = !1, null) : t(s),
r,
t
e
);
}, ee = g, C = (e, r, t = null) => {
let n = t;
return x(
q(r, () => (n = e(n), n))
}, ne = A, G = (t, r, e = null) => {
let n = e;
return p(
H(r, () => (n = t(n), n))
);
}, d = Symbol("AtomTypeSymbol"), te = (e) => e[d], f = (e, r) => {
const [t, n] = H(e, r);
}, m = Symbol("AtomTypeSymbol"), se = (t) => t[m], f = (t, r) => {
const [e, n] = _(t, r);
return Object.assign(
(...o) => o.length === 0 ? t() : n(...o),
{ reflux: K, [d]: "atom" }
(...s) => s.length === 0 ? e() : n(...s),
{ reflux: K, [m]: "atom" }
);
}, K = function(e, r, t) {
const n = this, o = f(e, t);
return g(() => {
n(() => r(o()));
}, [o]), o[d] = "reflux", o;
}, k = (e, {
}, K = function(t, r, e) {
const n = this, s = f(t, e);
return A(() => {
n(() => r(s()));
}, [s]), s[m] = "reflux", s;
}, y = (t, {
immediately: r = !0,
initValue: t = null
initValue: e = null
} = {}) => {
const n = f(r ? _(() => e(t)) : t);
return x((o) => {
n(() => e(o));
}, t), n[d] = "reflect", n;
}, U = (e, {
const n = f(r ? $(() => t(e)) : e);
return p((s) => {
n(() => t(s));
}, e), n[m] = "reflect", n;
}, U = (t, {
immediately: r = !0,
initValue: t = null
} = {}) => M((n) => {
const o = e(n);
return r ? o : (r = !0, t);
}, t), W = (e, {
initValue: e = null
} = {}) => L((n) => {
const s = t(n);
return r ? s : (r = !0, e);
}, e), V = (t, {
initValue: r = null,
immediately: t = !0,
immediately: e = !0,
deps: n,
refetch: o = {},
tap: c = (u) => {
refetch: s = {},
tap: o = (a) => {
},
ignoreError: a = !1
ignoreError: u = !1
} = {}) => {
const u = f(r), s = f(!1), l = f(!1), i = M(() => !s() && !l());
const a = f(r), c = f(!1), i = f(!1), l = L(() => !c() && !i());
let h = Promise.resolve(!1);
const v = (...Se) => S(void 0, [...Se], function* ({ warn: b = !0, cancelCallback: p } = o) {
i() || (p ? p(h) : b && console.warn(
const E = (...be) => S(void 0, [...be], function* ({ warn: x = !0, cancelCallback: I } = s) {
l() || (I ? I(h) : x && console.warn(
"Resource Atom: some fetch has been covered; Recommend to add a cancelCallback to some Hook"
)), s(!0);
const E = e().then((m) => (O(() => {
u(() => m), s(!1), l(!1);
}), E === h && c(m), !0)).catch((m) => (O(() => {
l(m), s(!1);
}), a || console.error(m), m));
return h = E, E;
)), c(!0);
const O = t().then((g) => (k(() => {
a(() => g), c(!1), i(!1);
}), O === h && o(g), !0)).catch((g) => (k(() => {
i(g), c(!1);
}), u || console.error(g), g));
return h = O, O;
});
return t && v(), n && n.length && g(() => v(o), n), Object.assign(u, {
error: l,
loading: s,
mutate(b) {
u(() => b);
return e && E(), n && n.length && A(() => E(s), n), Object.assign(a, {
error: i,
loading: c,
mutate(x) {
a(() => x);
},
isReady: i,
refetch: v,
isReady: l,
refetch: E,
promise: () => h,
[d]: "resource"
[m]: "resource"
});
};
let L = () => {
let D = () => {
};
const re = (e) => {
e && (L = e);
}, G = function(e, r = L) {
let t = !1;
const oe = (t) => {
t && (D = t);
}, W = function(t, r = D) {
let e = !1;
return function(...n) {
return t ? (r && r(), t) : (t = Promise.resolve(e.apply(this, n)).then((o) => (t = !1, o)), t);
return e ? (r && r(), e) : (e = Promise.resolve(t.apply(this, n)).then((s) => (e = !1, s)), e);
};
}, ne = G;
function P(e) {
return typeof e == "function" ? w(e) ? e : k(e()) : f(e);
}, ce = W;
function j(t) {
return typeof t == "function" ? w(t) ? t : y(t()) : f(t);
}
function w(e) {
return typeof e[d] == "string";
function w(t) {
return typeof t[m] == "string";
}
const se = (e) => e().map((r, t) => k(() => e()[t])), Q = (e, r) => new Promise((t) => setTimeout(() => t(r), e)), oe = (e) => ({
value: e(),
"on:input": (r) => e(() => r.target.value)
}), ce = (e, r, t) => {
var c, a, u;
const n = (c = t == null ? void 0 : t.parse) != null ? c : (s) => JSON.parse(s), o = (a = t == null ? void 0 : t.stringify) != null ? a : (s) => JSON.stringify(s);
if ((u = t == null ? void 0 : t.immediately) == null || u) {
const s = localStorage.getItem(r);
s && e(n(s));
const ue = (t) => t().map((r, e) => y(() => t()[e])), Q = (t, r) => new Promise((e) => setTimeout(() => e(r), t)), ae = (t, { valueName: r = "value" }) => ({
value: t(),
"on:input": (e) => t(() => e.target.value)
}), ie = (t, r, e) => {
var o, u, a;
const n = (o = e == null ? void 0 : e.parse) != null ? o : (c) => JSON.parse(c), s = (u = e == null ? void 0 : e.stringify) != null ? u : (c) => JSON.stringify(c);
if ((a = e == null ? void 0 : e.immediately) == null || a) {
const c = localStorage.getItem(r);
c && t(n(c));
}
return g(() => {
localStorage.setItem(r, o(e()));
}, [e]), e;
}, ae = (e) => [...Array(e).keys()];
function j(e, r) {
const t = w(e) ? e : f(e, r), n = (c, a, u) => {
const s = c.findIndex((l) => l === a);
if (s >= 0) {
const l = [...c];
return u(l, s), l;
return A(() => {
localStorage.setItem(r, s(t()));
}, [t]), t;
}, le = (t) => [...Array(t).keys()], X = (t, r) => Object.fromEntries(r.map((e) => [e, function(...n) {
return t((s) => {
const o = [...s];
return o[e](...n), o;
}), this;
}])), Y = (t, r) => Object.fromEntries(r.map((e) => [e, function(...n) {
return y(() => t()[e](...n));
}])), F = (t, r, e = !1) => Object.fromEntries(r.map((n) => [n, function(...s) {
return b(y(e ? () => [...t()][n](...s) : () => t()[n](...s)));
}]));
function b(t, r) {
const e = w(t) ? t : f(t, r), n = (o, u, a) => {
const c = o.findIndex((i) => i === u);
if (c >= 0) {
const i = [...o];
return a(i, c), i;
} else
return console.warn("Can't find array atom Item: ", a), c;
};
return Object.assign(t, A(y({}, {
replace(c, a) {
return t((u) => n(u, c, (s, l) => {
s[l] = a;
return console.warn("Can't find array atom Item: ", u), o;
}, s = d(d(d(d({
replace(o, u) {
return e((a) => n(a, o, (c, i) => {
c[i] = u;
})), this;
},
replaceAll(c, a) {
return t((u) => {
const s = [];
u.forEach((i, h) => i === c && s.push(h));
const l = [...u];
return s.forEach((i) => l[i] = a), l;
replaceAll(o, u) {
return e((a) => {
const c = [];
a.forEach((l, h) => l === o && c.push(h));
const i = [...a];
return c.forEach((l) => i[l] = u), i;
}), this;
},
remove(c) {
return t((a) => n(a, c, (u, s) => {
u.splice(s, 1);
remove(o) {
return e((u) => n(u, o, (a, c) => {
a.splice(c, 1);
})), this;
},
removeAll(c) {
return t((a) => a.filter((u) => u !== c)), this;
removeAll(o) {
return e((u) => u.filter((a) => a !== o)), this;
},
insert(c, a, u = "before") {
return t((s) => n(s, a, (l, i) => {
l.splice(u === "before" ? i : i + 1, 0, c);
insert(o, u, a = "before") {
return e((c) => n(c, u, (i, l) => {
i.splice(a === "before" ? l : l + 1, 0, o);
})), this;
},
move(c, a, u) {
return this.remove(c), this.insert(c, a, u), this;
move(o, u, a) {
return this.remove(o), this.insert(o, u, a), this;
},
switch(c, a) {
return t((u) => {
const s = [...u], l = t().findIndex((h) => h === c), i = t().findIndex((h) => h === a);
if (l === -1 || i === -1)
switch(o, u) {
return e((a) => {
const c = [...a], i = e().findIndex((h) => h === o), l = e().findIndex((h) => h === u);
if (i === -1 || l === -1)
throw new Error("ArrayAtom: Please check the Items you want to switch ");
return s[l] = a, s[i] = c, s;
return c[i] = u, c[l] = o, c;
}), this;
},
toggle(o) {
return e((u) => {
const a = u.indexOf(o);
return a === -1 ? [...u, o] : [...u.splice(a, 1)];
}), this;
},
forEach(o, u) {
p(() => e().forEach(o));
}
}), { [d]: "array" }));
}, X(e, ["push", "pop", "shift", "unshift"])), Y(
e,
[
"join",
"indexOf",
"lastIndexOf",
"every",
"some",
"reduce",
"reduceRight"
]
)), F(
e,
[
"slice",
"map",
"filter"
]
)), F(
e,
[
"reverse",
"sort",
"splice"
],
!0
));
return Object.assign(e, v(d({}, s), { [m]: "array" }));
}
function ue(e, r) {
const t = w(e) ? e : f(e, { equals: !1 }), n = w(e) ? e() : e;
return t[d] = "object", Object.assign(
t,
function fe(t, r) {
const e = w(t) ? t : f(t, { equals: !1 }), n = w(t) ? t() : t;
return e[m] = "object", Object.assign(
e,
Object.fromEntries(
Object.keys(n).reduce((o, c) => {
const a = t.reflux(t()[c], (u) => A(y({}, t()), { [c]: u }));
return o.push([c, a]), o;
Object.keys(n).reduce((s, o) => {
const u = e.reflux(e()[o], (a) => v(d({}, e()), { [o]: a }));
return s.push([o, u]), s;
}, [])

@@ -193,153 +237,153 @@ )

}
function le(e, r = 150) {
let t = e();
const n = f(t);
return g(
D(() => {
const o = e();
o !== void 0 && n(() => o);
function he(t, r = 150) {
let e = t();
const n = f(e);
return A(
N(() => {
const s = t();
s !== void 0 && n(() => s);
}, r),
[e]
[t]
), n;
}
function ie(e, r = 150, t) {
let n = e();
const o = f(n);
return g(
z(
function de(t, r = 150, e) {
let n = t();
const s = f(n);
return A(
C(
() => {
const c = e();
c !== void 0 && o(() => c);
const o = t();
o !== void 0 && s(() => o);
},
r,
t
e
),
[e]
), o;
[t]
), s;
}
const fe = () => {
const e = /* @__PURE__ */ new Map();
const me = () => {
const t = /* @__PURE__ */ new Map();
return {
register(r, t) {
if (e.has(r))
register(r, e) {
if (t.has(r))
throw new Error("Blackboard has a same app named " + r.toString());
return e.set(r, t);
return t.set(r, e);
},
getApp(r) {
if (!e.has(r))
if (!t.has(r))
throw new Error(`Blackboard app ${r.toString()} isn't init yet`);
return e.get(r);
return t.get(r);
},
delete(r) {
if (!e.has(r))
if (!t.has(r))
throw new Error(`Blackboard app ${r.toString()} isn't init yet`);
e.delete(r);
t.delete(r);
},
check(r) {
return e.has(r);
return t.has(r);
},
destroy() {
e.clear();
t.clear();
}
};
}, V = (e, r = {}) => {
var u, s;
r.debounceTime = (u = r.debounceTime) != null ? u : 100;
const t = f((s = r.initIndex) != null ? s : 0), n = f(10), o = W(() => e(t(), n), r), c = D(() => o.refetch(), r.debounceTime), a = (i) => {
if (i < 0 || i >= n())
}, Z = (t, r = {}) => {
var a, c;
r.debounceTime = (a = r.debounceTime) != null ? a : 100;
const e = f((c = r.initIndex) != null ? c : 0), n = f(10), s = V(() => t(e(), n), r), o = N(() => s.refetch(), r.debounceTime), u = (l) => {
if (l < 0 || l >= n())
return !1;
{
t(i);
e(l);
//! 页码改变如果迅速的话,那应该不进行请求,而是直接忽略
return c();
return o();
}
};
return {
currentIndex: t,
currentPage: U(() => t() + 1),
currentIndex: e,
currentPage: U(() => e() + 1),
maxPage: n,
prev() {
return a(t() - 1);
return u(e() - 1);
},
next() {
return a(t() + 1);
return u(e() + 1);
},
waitForDone() {
return S(this, null, function* () {
return Q(r.debounceTime + 10).then(o.promise);
return Q(r.debounceTime + 10).then(s.promise);
});
},
refetch: c,
goto: a,
currentData: o
refetch: o,
goto: u,
currentData: s
};
}, he = (e, r) => {
const t = f([], { equals: !1 }), n = V((...o) => S(void 0, null, function* () {
const c = yield e(...o);
return t((a) => (a[o[0]] = c, a)), c;
}, ge = (t, r) => {
const e = f([], { equals: !1 }), n = Z((...s) => S(void 0, null, function* () {
const o = yield t(...s);
return e((u) => (u[s[0]] = o, u)), o;
}), r);
return A(y({}, n), {
resetStack(o = !0) {
O(() => {
t([]), n.currentIndex(0), o && n.currentData.refetch();
return v(d({}, n), {
resetStack(s = !0) {
k(() => {
e([]), n.currentIndex(0), s && n.currentData.refetch();
});
},
dataSlices: t
dataSlices: e
});
}, de = function(e = {}) {
var a, u;
const r = j(P((a = e.activeIds) != null ? a : [])), t = P((u = e.multi) != null ? u : !0), n = f(new Set(r()));
x(() => {
!t() && r((s) => s.slice(0, 1)), n(() => new Set(r()));
}, ye = function(t = {}) {
var u, a;
const r = b(j((u = t.activeIds) != null ? u : [])), e = j((a = t.multi) != null ? a : !0), n = f(new Set(r()));
p(() => {
!e() && r((c) => c.slice(0, 1)), n(() => new Set(r()));
});
const o = f(/* @__PURE__ */ new Set(), { equals: !1 }), c = (s, l) => {
l === void 0 && (l = !n().has(s)), l === !0 && !n().has(s) ? r((i) => t() ? [...i, s] : [s]) : l === !1 && r.removeAll(s);
const s = f(/* @__PURE__ */ new Set(), { equals: !1 }), o = (c, i) => {
i === void 0 && (i = !n().has(c)), i === !0 && !n().has(c) ? r((l) => e() ? [...l, c] : [c]) : i === !1 && r.removeAll(c);
};
return {
changeSelected: c,
register(s, l = !1) {
o((i) => (i.add(s), i)), c(s, l);
changeSelected: o,
register(c, i = !1) {
s((l) => (l.add(c), l)), o(c, i);
},
deregister(s) {
r.removeAll(s), o((l) => (l.delete(s), l));
deregister(c) {
r.removeAll(c), s((i) => (i.delete(c), i));
},
allRegistered: o,
allRegistered: s,
activeIds: n,
isSelected: (s) => n().has(s)
isSelected: (c) => n().has(c)
};
}, me = (e, r, t, {
on: n = (c) => c.addEventListener,
off: o = (c) => c.removeEventListener
}, Ae = (t, r, e, {
on: n = (o) => o.addEventListener,
off: s = (o) => o.removeEventListener
} = {}) => {
n(e).call(e, r, t), $(() => {
o(e).call(e, r, t);
n(t).call(t, r, e), z(() => {
s(t).call(t, r, e);
});
}, ge = (e) => {
const r = (t, n, o) => {
const c = o != null ? o : new n();
return Object.entries(t()).forEach(([a, u]) => {
c.set(a, u.toString());
}), c;
}, ve = (t) => {
const r = (e, n, s) => {
const o = s != null ? s : new n();
return Object.entries(e()).forEach(([u, a]) => {
o.set(u, a.toString());
}), o;
};
return {
toKeysAtom() {
return k(() => j(Object.keys(e)));
return y(() => b(Object.keys(t)));
},
toEntries() {
return Object.entries(e());
return Object.entries(t());
},
toFromData(t) {
return r(e, FormData, t);
toFromData(e) {
return r(t, FormData, e);
},
toSearchParams(t) {
return r(e, URLSearchParams, t);
toSearchParams(e) {
return r(t, URLSearchParams, e);
},
toHeaders(t) {
return r(e, Headers, t);
toHeaders(e) {
return r(t, Headers, e);
},
toMap(t) {
return r(e, Map, t);
toMap(e) {
return r(t, Map, e);
},
toJSON() {
return JSON.stringify(e());
return JSON.stringify(t());
}

@@ -349,32 +393,32 @@ };

export {
j as ArrayAtom,
se as AtomToArray,
d as AtomTypeSymbol,
le as DebounceAtom,
ge as EntriesTransform,
ue as ObjectAtom,
ie as ThrottleAtom,
oe as VModel,
me as addListener,
G as asyncLock,
b as ArrayAtom,
ue as AtomToArray,
m as AtomTypeSymbol,
he as DebounceAtom,
ve as EntriesTransform,
fe as ObjectAtom,
de as ThrottleAtom,
ae as VModel,
Ae as addListener,
W as asyncLock,
f as atom,
P as atomization,
fe as createBlackBoard,
ee as createIgnoreFirst,
ae as genArray,
te as getAtomType,
j as atomization,
me as createBlackBoard,
ne as createIgnoreFirst,
le as genArray,
se as getAtomType,
w as isAtom,
ce as localSync,
k as reflect,
ie as localSync,
y as reflect,
U as reflectMemo,
W as resource,
re as setAsyncLockDefaultRefuse,
V as resource,
oe as setAsyncLockDefaultRefuse,
Q as sleep,
C as useEffect,
g as useEffectWithoutFirst,
V as usePagination,
he as usePaginationStack,
de as useSelect,
ne as useSingleAsync
G as useEffect,
A as useEffectWithoutFirst,
Z as usePagination,
ge as usePaginationStack,
ye as useSelect,
ce as useSingleAsync
};
//# sourceMappingURL=index.js.map

@@ -8,5 +8,7 @@ import type { Atom } from "../atom";

*/
export declare const VModel: <T>(atom: Atom<T>) => {
export declare const VModel: <T>(atom: Atom<T>, { valueName }: {
valueName?: string | undefined;
}) => {
value: T;
'on:input': (e: any) => any;
};
{
"name": "@cn-ui/reactive",
"version": "2.2.4",
"version": "2.3.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

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