Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@libeilong/mobx

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libeilong/mobx - npm Package Compare versions

Comparing version
0.4.7
to
0.4.8
+69
-64
dist/index.js

@@ -1,10 +0,10 @@

import { extendObservable as O, makeObservable as d, observable as r, action as f, computed as y } from "mobx";
import v from "react";
function j(t, e) {
import { extendObservable as F, makeObservable as f, observable as r, action as u, computed as M } from "mobx";
import L from "react";
function S(t, e) {
const i = {}, s = Object.keys(e);
for (const o of s)
o in t ? t[o] = e[o] : i[o] = e[o];
Object.keys(i).length > 0 && O(t, i);
Object.keys(i).length > 0 && F(t, i);
}
function k(t = {}) {
function C(t = {}) {
return (e) => {

@@ -17,10 +17,10 @@ e.prototype._modelOptions = {

}
function F(t) {
function T(t) {
return typeof t == "function" ? t.prototype._modelOptions || {} : t && typeof t == "object" ? t._modelOptions || {} : {};
}
function N(t) {
return !t || typeof t != "object" && typeof t != "function" ? void 0 : F(t).primaryKey;
function D(t) {
return !t || typeof t != "object" && typeof t != "function" ? void 0 : T(t).primaryKey;
}
var m = /* @__PURE__ */ ((t) => (t.OneToMany = "OneToMany", t.ManyToOne = "ManyToOne", t.OneToOne = "OneToOne", t.ManyToMany = "ManyToMany", t))(m || {});
function g(t, e) {
function d(t, e) {
return function(i, s) {

@@ -33,34 +33,37 @@ i.constructor._relations || (i.constructor._relations = {}), i.constructor._relations[s] = {

}
function S(t) {
return g("OneToMany", t);
}
function D(t) {
return g("ManyToOne", t);
}
function E(t) {
return g("OneToOne", t);
return d("OneToMany", t);
}
function R(t) {
return g("ManyToMany", t);
return d("ManyToOne", t);
}
function L(t) {
function _(t) {
return d("OneToOne", t);
}
function A(t) {
return d("ManyToMany", t);
}
function w(t) {
return typeof t == "function" ? t._relations || {} : t.constructor._relations || {};
}
function _(t, e) {
const i = L(t), s = {}, o = Object.keys(e);
function x(t) {
return typeof t == "function" && t.length === 0 ? t() : t;
}
function P(t, e) {
const i = w(t), s = {}, o = Object.keys(e);
for (const n of o) {
const l = i[n];
if (l) {
const { primaryKey: h, createInstance: u } = F(l.modelClass);
if (!h) continue;
if ([m.ManyToMany, m.OneToMany].includes(l.type)) {
const g = i[n];
if (g) {
const p = x(g.modelClass), { primaryKey: l, createInstance: c } = T(p);
if (!l) continue;
if ([m.ManyToMany, m.OneToMany].includes(g.type)) {
if (!Array.isArray(e[n]))
throw new Error(`Expected an array for relation ${n.toString()}, but got ${typeof e[n]}`);
const c = e[n].map((a) => {
const p = typeof a == "object" ? a : { [h]: a }, M = t[n]?.find((b) => b[h] === p[h]);
return M || (u ? u(p) : new l.modelClass(p));
const h = e[n].map((a) => {
const y = typeof a == "object" ? a : { [l]: a }, O = t[n]?.find((v) => v[l] === y[l]);
return O || (c ? c(y) : new p(y));
});
n in t ? t[n] = c : s[n] = c;
n in t ? t[n] = h : s[n] = h;
} else {
const c = typeof e[n] == "object" ? e[n] : { [h]: e[n] }, a = u ? u(c) : new l.modelClass(c);
const h = typeof e[n] == "object" ? e[n] : { [l]: e[n] }, a = c ? c(h) : new p(h);
n in t ? t[n] = a : s[n] = a;

@@ -71,5 +74,5 @@ }

}
return Object.keys(s).length > 0 && O(t, s), t;
return Object.keys(s).length > 0 && F(t, s), t;
}
class A {
class z {
initCount = 60;

@@ -79,3 +82,3 @@ defaultText = "获取验证码";

constructor(e = {}) {
this.initCount = e.initCount ?? 60, this.defaultText = e.defaultText ?? "获取验证码", this.countTemplate = e.countTemplate ?? "{{count}}s", this.count = this.initCount, d(this, {
this.initCount = e.initCount ?? 60, this.defaultText = e.defaultText ?? "获取验证码", this.countTemplate = e.countTemplate ?? "{{count}}s", this.count = this.initCount, f(this, {
count: r,

@@ -101,4 +104,4 @@ isRunning: r

}
class w {
createElement = (e, i) => v.createElement(
class j {
createElement = (e, i) => L.createElement(
"div",

@@ -121,5 +124,5 @@ {

}
class T {
constructor(e = new w()) {
this.adapter = e, d(this, {
class b {
constructor(e = new j()) {
this.adapter = e, f(this, {
list: r,

@@ -130,7 +133,7 @@ hasMore: r,

err: r,
notData: y,
state: y,
stateWidget: y,
fetch: f,
reset: f
notData: M,
state: M,
stateWidget: M,
fetch: u,
reset: u
});

@@ -147,3 +150,3 @@ }

paging = {
pageNumber: T.startPageNumber,
pageNumber: b.startPageNumber,
pageSize: 10,

@@ -192,5 +195,5 @@ total: 0

}
class P {
class K {
constructor() {
d(this, {
f(this, {
loading: r,

@@ -218,5 +221,5 @@ result: r,

}
class z {
class I {
constructor() {
d(this, {
f(this, {
list: r,

@@ -226,4 +229,4 @@ loading: r,

total: r,
fetch: f,
reset: f
fetch: u,
reset: u
});

@@ -261,16 +264,18 @@ }

export {
w as BaseFooterListAdapter,
A as CountDownStore,
T as ListStore,
R as ManyToMany,
D as ManyToOne,
k as Model,
S as OneToMany,
E as OneToOne,
P as ResultStore,
z as TableListStore,
j as assignMobx,
_ as assignModel,
F as getModelOptions,
N as getPrimaryKey
j as BaseFooterListAdapter,
z as CountDownStore,
b as ListStore,
A as ManyToMany,
R as ManyToOne,
C as Model,
E as OneToMany,
_ as OneToOne,
K as ResultStore,
I as TableListStore,
S as assignMobx,
P as assignModel,
T as getModelOptions,
D as getPrimaryKey,
w as getRelations,
x as resolveModelClass
};
export { assignModel } from './assignModel';
export { Model, getModelOptions, getPrimaryKey } from './Model';
export { OneToMany, ManyToMany, ManyToOne, OneToOne } from './Relations';
export { OneToMany, ManyToMany, ManyToOne, OneToOne, resolveModelClass, getRelations } from './Relations';

@@ -9,8 +9,12 @@ export declare enum RelationType {

type: RelationType;
modelClass: any;
modelClass: any | (() => any);
}
export declare function OneToMany<T extends new () => any>(modelClass: T): (target: any, propertyKey: string | symbol) => void;
export declare function ManyToOne<T extends new () => any>(modelClass: T): (target: any, propertyKey: string | symbol) => void;
export declare function OneToOne<T extends new () => any>(modelClass: T): (target: any, propertyKey: string | symbol) => void;
export declare function ManyToMany<T extends new () => any>(modelClass: T): (target: any, propertyKey: string | symbol) => void;
export declare function OneToMany<T extends new () => any>(modelClass: T | (() => T)): (target: any, propertyKey: string | symbol) => void;
export declare function ManyToOne<T extends new () => any>(modelClass: T | (() => T)): (target: any, propertyKey: string | symbol) => void;
export declare function OneToOne<T extends new () => any>(modelClass: T | (() => T)): (target: any, propertyKey: string | symbol) => void;
export declare function ManyToMany<T extends new () => any>(modelClass: T | (() => T)): (target: any, propertyKey: string | symbol) => void;
export declare function getRelations(target: any): Record<string, RelationMetadata>;
/**
* 解析模型类,支持直接类引用和函数形式
*/
export declare function resolveModelClass(modelClass: any | (() => any)): any;
{
"name": "@libeilong/mobx",
"version": "0.4.7",
"version": "0.4.8",
"type": "module",

@@ -5,0 +5,0 @@ "files": [