ivue 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +32 -32
- package/dist/index.umd.js +1 -1
- package/dist/src/ivue.d.ts +11 -6
- package/docs/docs/components/usage/classes/CustomMouse.ts +1 -1
- package/docs/package.json +1 -1
- package/package.json +1 -1
- package/src/ivue.ts +37 -22
package/dist/index.es.js
CHANGED
|
@@ -3,50 +3,50 @@ const d = /* @__PURE__ */ new Map();
|
|
|
3
3
|
function D(e) {
|
|
4
4
|
if (d.has(e))
|
|
5
5
|
return d.get(e);
|
|
6
|
-
const
|
|
6
|
+
const n = /* @__PURE__ */ new Map();
|
|
7
7
|
let t = e.prototype;
|
|
8
8
|
for (; t.constructor !== Object; )
|
|
9
9
|
Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([f, r]) => {
|
|
10
|
-
const i =
|
|
11
|
-
i !== r && (r != null && r.get || r != null && r.set) && (i != null && i.get && (r.get = i == null ? void 0 : i.get), i != null && i.set && (r.set = i == null ? void 0 : i.set),
|
|
10
|
+
const i = n.get(f);
|
|
11
|
+
i !== r && (r != null && r.get || r != null && r.set) && (i != null && i.get && (r.get = i == null ? void 0 : i.get), i != null && i.set && (r.set = i == null ? void 0 : i.set), n.set(f, r));
|
|
12
12
|
}), t = Object.getPrototypeOf(t);
|
|
13
|
-
return d.set(e,
|
|
13
|
+
return d.set(e, n), n;
|
|
14
14
|
}
|
|
15
|
-
function E(e, ...
|
|
15
|
+
function E(e, ...n) {
|
|
16
16
|
var i, O;
|
|
17
|
-
const t = D(e), f = t != null && t.size ? {} : null, r = v(new e(...
|
|
18
|
-
for (const [
|
|
19
|
-
((i = e == null ? void 0 : e.ivue) == null ? void 0 : i[
|
|
17
|
+
const t = D(e), f = t != null && t.size ? {} : null, r = v(new e(...n));
|
|
18
|
+
for (const [o, p] of t)
|
|
19
|
+
((i = e == null ? void 0 : e.ivue) == null ? void 0 : i[o]) !== !1 && Object.defineProperty(r, o, { get: p.get ? () => {
|
|
20
20
|
var u, g;
|
|
21
|
-
return
|
|
22
|
-
} : void 0, set: (O =
|
|
23
|
-
return Object.defineProperty(r, "toRefs", { get: () => function(
|
|
21
|
+
return o in f ? f[o] : f[o] = b({ get: (u = p.get) == null ? void 0 : u.bind(r), set: (g = p.set) == null ? void 0 : g.bind(r) });
|
|
22
|
+
} : void 0, set: (O = p.set) == null ? void 0 : O.bind(r), enumerable: !1 });
|
|
23
|
+
return Object.defineProperty(r, "toRefs", { get: () => function(o, p, u) {
|
|
24
24
|
return function(g) {
|
|
25
25
|
var h, j;
|
|
26
|
-
const
|
|
26
|
+
const l = {};
|
|
27
27
|
if (Array.isArray(g) && g.length)
|
|
28
28
|
for (let a = 0; a < g.length; a++) {
|
|
29
29
|
const s = g[a];
|
|
30
|
-
if (
|
|
30
|
+
if (p.has(s))
|
|
31
31
|
if (s in u)
|
|
32
|
-
|
|
32
|
+
l[s] = u[s];
|
|
33
33
|
else {
|
|
34
|
-
const c =
|
|
35
|
-
|
|
34
|
+
const c = p.get(s);
|
|
35
|
+
l[s] = u[s] = b({ get: (h = c == null ? void 0 : c.get) == null ? void 0 : h.bind(o), set: (j = c == null ? void 0 : c.set) == null ? void 0 : j.bind(o) });
|
|
36
36
|
}
|
|
37
37
|
else
|
|
38
|
-
typeof
|
|
38
|
+
typeof o[s] == "function" ? l[s] = o[s].bind(o) : l[s] = m(o, s);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
let a = new Set(C(
|
|
42
|
-
|
|
41
|
+
let a = new Set(C(o));
|
|
42
|
+
p.forEach((s, c) => {
|
|
43
43
|
var w, P;
|
|
44
|
-
|
|
44
|
+
l[c] = c in u ? u[c] : u[c] = b({ get: (w = s.get) == null ? void 0 : w.bind(o), set: (P = s.set) == null ? void 0 : P.bind(o) }), a == null || a.delete(c);
|
|
45
45
|
}), a.forEach((s) => {
|
|
46
|
-
typeof
|
|
46
|
+
typeof o[s] == "function" ? l[s] = o[s].bind(o) : l[s] = m(o, s);
|
|
47
47
|
}), a = null;
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return l;
|
|
50
50
|
};
|
|
51
51
|
}(r, t, f), enumerable: !1 }), "init" in r && r.init(), r;
|
|
52
52
|
}
|
|
@@ -54,26 +54,26 @@ const y = /* @__PURE__ */ new Map();
|
|
|
54
54
|
function C(e) {
|
|
55
55
|
if (y.has(e.constructor))
|
|
56
56
|
return y.get(e.constructor);
|
|
57
|
-
const
|
|
57
|
+
const n = e.constructor, t = /* @__PURE__ */ new Set();
|
|
58
58
|
do
|
|
59
59
|
Object.getOwnPropertyNames(e).forEach((f) => {
|
|
60
60
|
["caller", "callee", "arguments", "constructor"].includes(f) || t.add(f);
|
|
61
61
|
}), e = Object.getPrototypeOf(e);
|
|
62
62
|
while (e.constructor !== Object);
|
|
63
|
-
return y.set(
|
|
63
|
+
return y.set(n, t), t;
|
|
64
64
|
}
|
|
65
65
|
const S = A;
|
|
66
|
-
function x(e, ...
|
|
67
|
-
return M(e) ? E(e, ...
|
|
66
|
+
function x(e, ...n) {
|
|
67
|
+
return typeof e == "function" ? M(e) ? E(e, ...n).toRefs() : e(...n) : e;
|
|
68
68
|
}
|
|
69
69
|
function M(e) {
|
|
70
|
-
var
|
|
71
|
-
return typeof e == "function" && !!e.prototype && !((
|
|
70
|
+
var n;
|
|
71
|
+
return typeof e == "function" && !!e.prototype && !((n = Object.getOwnPropertyDescriptor(e, "prototype")) != null && n.writable);
|
|
72
72
|
}
|
|
73
|
-
function z(e,
|
|
74
|
-
for (const t in
|
|
75
|
-
typeof (e == null ? void 0 : e[t]) == "object" && (e == null ? void 0 : e[t]) !== null || M(e == null ? void 0 : e[t]) ?
|
|
76
|
-
return
|
|
73
|
+
function z(e, n) {
|
|
74
|
+
for (const t in n)
|
|
75
|
+
typeof (e == null ? void 0 : e[t]) == "object" && (e == null ? void 0 : e[t]) !== null || M(e == null ? void 0 : e[t]) ? n[t].default = () => e == null ? void 0 : e[t] : n[t].default = e == null ? void 0 : e[t];
|
|
76
|
+
return n;
|
|
77
77
|
}
|
|
78
78
|
export {
|
|
79
79
|
d as descriptorsMap,
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],u):u((i=typeof globalThis<"u"?globalThis:i||self).ivue={},i.Vue)})(this,function(i,u){"use strict";const y=new Map;function j(t){if(y.has(t))return y.get(t);const r=new Map;let e=t.prototype;for(;e.constructor!==Object;)Object.entries(Object.getOwnPropertyDescriptors(e)).forEach(([l,n])=>{const c=r.get(l);c!==n&&(n!=null&&n.get||n!=null&&n.set)&&(c!=null&&c.get&&(n.get=c==null?void 0:c.get),c!=null&&c.set&&(n.set=c==null?void 0:c.set),r.set(l,n))}),e=Object.getPrototypeOf(e);return y.set(t,r),r}function w(t,...r){var c,P;const e=j(t),l=e!=null&&e.size?{}:null,n=u.reactive(new t(...r));for(const[s,d]of e)((c=t==null?void 0:t.ivue)==null?void 0:c[s])!==!1&&Object.defineProperty(n,s,{get:d.get?()=>{var p,b;return s in l?l[s]:l[s]=u.computed({get:(p=d.get)==null?void 0:p.bind(n),set:(b=d.set)==null?void 0:b.bind(n)})}:void 0,set:(P=d.set)==null?void 0:P.bind(n),enumerable:!1});return Object.defineProperty(n,"toRefs",{get:()=>function(s,d,p){return function(b){var v,M;const g={};if(Array.isArray(b)&&b.length)for(let a=0;a<b.length;a++){const o=b[a];if(d.has(o))if(o in p)g[o]=p[o];else{const f=d.get(o);g[o]=p[o]=u.computed({get:(v=f==null?void 0:f.get)==null?void 0:v.bind(s),set:(M=f==null?void 0:f.set)==null?void 0:M.bind(s)})}else typeof s[o]=="function"?g[o]=s[o].bind(s):g[o]=u.toRef(s,o)}else{let a=new Set(m(s));d.forEach((o,f)=>{var A,D;g[f]=f in p?p[f]:p[f]=u.computed({get:(A=o.get)==null?void 0:A.bind(s),set:(D=o.set)==null?void 0:D.bind(s)}),a==null||a.delete(f)}),a.forEach(o=>{typeof s[o]=="function"?g[o]=s[o].bind(s):g[o]=u.toRef(s,o)}),a=null}return g}}(n,e,l),enumerable:!1}),"init"in n&&n.init(),n}const O=new Map;function m(t){if(O.has(t.constructor))return O.get(t.constructor);const r=t.constructor,e=new Set;do Object.getOwnPropertyNames(t).forEach(l=>{["caller","callee","arguments","constructor"].includes(l)||e.add(l)}),t=Object.getPrototypeOf(t);while(t.constructor!==Object);return O.set(r,e),e}const E=u.ref;function h(t){var r;return typeof t=="function"&&!!t.prototype&&!((r=Object.getOwnPropertyDescriptor(t,"prototype"))!=null&&r.writable)}i.descriptorsMap=y,i.getAllClassDescriptors=j,i.getAllClassProperties=m,i.iref=E,i.isClass=h,i.iuse=function(t,...r){return typeof t=="function"?h(t)?w(t,...r).toRefs():t(...r):t},i.ivue=w,i.propsMap=O,i.propsWithDefaults=function(t,r){for(const e in r)typeof(t==null?void 0:t[e])=="object"&&(t==null?void 0:t[e])!==null||h(t==null?void 0:t[e])?r[e].default=()=>t==null?void 0:t[e]:r[e].default=t==null?void 0:t[e];return r},Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/dist/src/ivue.d.ts
CHANGED
|
@@ -159,18 +159,23 @@ export declare function getAllClassProperties(obj: object): Set<string>;
|
|
|
159
159
|
* @param val T
|
|
160
160
|
* @returns {UnwrapRef<T>}
|
|
161
161
|
*/
|
|
162
|
-
export declare const iref: <T = any>(value
|
|
162
|
+
export declare const iref: <T = any>(value?: T | undefined) => T;
|
|
163
163
|
/**
|
|
164
|
-
*
|
|
164
|
+
* Three modes of operation:
|
|
165
165
|
* 1. `iuse(useComposable(arg, arg2, arg3, ...))` converts the return types of a Composable / Ref to pure raw type definition.
|
|
166
166
|
* Returns for all properties of an object an unwrapped raw type definition,
|
|
167
167
|
* unwraps direct Refs & ComputedRefs as well down to their raw types.
|
|
168
168
|
*
|
|
169
|
-
* 2. `iuse(
|
|
170
|
-
*
|
|
171
|
-
*
|
|
169
|
+
* 2. `iuse(useComposable, arg, arg2, arg3, ...)` for cleaner syntax for #1, it does exactly the same thing but
|
|
170
|
+
* here the TypeScript inference works for composable function arguments to assist you with intellisence,
|
|
171
|
+
* like they work for constructor arguments in the cause of `ivue()` core function,
|
|
172
|
+
* making the API cleaner to look at and make it compatible with how this function operates with classes, see #3.
|
|
173
|
+
*
|
|
174
|
+
* 3. `iuse(AnyClass, ...args)` If AnyClass is supplied and that class's arguments into `iuse(AnyClass, ...args)`,
|
|
175
|
+
* it returns an 'ivue(AnyClass, ...args).toRefs()` object for all properties but casts
|
|
176
|
+
* their types as raw (no-Ref) types to fit with reactive() structure of the ivue class context.
|
|
172
177
|
*/
|
|
173
|
-
export declare function iuse<T extends AnyClass | Object>(
|
|
178
|
+
export declare function iuse<T extends AnyClass | AnyFn | Object>(classFunctionObject?: T, ...args: T extends AnyClass ? InferredArgs<T> : T extends AnyFn ? Parameters<T extends (...args: any[]) => any ? T : any> : any): T extends AnyClass ? InstanceType<T> : T extends AnyFn ? UseComposable<T> : UnwrapComposableReturn<T>;
|
|
174
179
|
/**
|
|
175
180
|
* Vue props interface in defineComponent() style.
|
|
176
181
|
*/
|
package/docs/package.json
CHANGED
package/package.json
CHANGED
package/src/ivue.ts
CHANGED
|
@@ -57,8 +57,9 @@ export type UnwrapComposableReturn<T> = T extends Ref | DemiRef
|
|
|
57
57
|
/**
|
|
58
58
|
* Fully unwraps to bare value types any Vue 3 composable return definition type.
|
|
59
59
|
*/
|
|
60
|
-
export type UseComposable<T extends AnyFn> =
|
|
61
|
-
|
|
60
|
+
export type UseComposable<T extends AnyFn> = UnwrapComposableReturn<
|
|
61
|
+
ReturnType<T>
|
|
62
|
+
>;
|
|
62
63
|
|
|
63
64
|
/**
|
|
64
65
|
* Extracts object defined emit types by converting them to a plain interface
|
|
@@ -139,10 +140,7 @@ export type IFnParameter<
|
|
|
139
140
|
/**
|
|
140
141
|
* Get function arguments Parmeters<F> parameter by key K
|
|
141
142
|
*/
|
|
142
|
-
export type FnParameter<
|
|
143
|
-
F extends AnyFn,
|
|
144
|
-
K extends number
|
|
145
|
-
> = Parameters<F>[K];
|
|
143
|
+
export type FnParameter<F extends AnyFn, K extends number> = Parameters<F>[K];
|
|
146
144
|
|
|
147
145
|
/**
|
|
148
146
|
* Convert Union Type to Intersection Type.
|
|
@@ -322,28 +320,45 @@ export function getAllClassProperties(obj: object): Set<string> {
|
|
|
322
320
|
* @param val T
|
|
323
321
|
* @returns {UnwrapRef<T>}
|
|
324
322
|
*/
|
|
325
|
-
export const iref = ref as <T = any>(value
|
|
323
|
+
export const iref = ref as <T = any>(value?: T) => T;
|
|
326
324
|
|
|
327
325
|
/**
|
|
328
|
-
*
|
|
326
|
+
* Three modes of operation:
|
|
329
327
|
* 1. `iuse(useComposable(arg, arg2, arg3, ...))` converts the return types of a Composable / Ref to pure raw type definition.
|
|
330
328
|
* Returns for all properties of an object an unwrapped raw type definition,
|
|
331
329
|
* unwraps direct Refs & ComputedRefs as well down to their raw types.
|
|
332
330
|
*
|
|
333
|
-
* 2. `iuse(
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
)
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
:
|
|
331
|
+
* 2. `iuse(useComposable, arg, arg2, arg3, ...)` for cleaner syntax for #1, it does exactly the same thing but
|
|
332
|
+
* here the TypeScript inference works for composable function arguments to assist you with intellisence,
|
|
333
|
+
* like they work for constructor arguments in the cause of `ivue()` core function,
|
|
334
|
+
* making the API cleaner to look at and make it compatible with how this function operates with classes, see #3.
|
|
335
|
+
*
|
|
336
|
+
* 3. `iuse(AnyClass, ...args)` If AnyClass is supplied and that class's arguments into `iuse(AnyClass, ...args)`,
|
|
337
|
+
* it returns an 'ivue(AnyClass, ...args).toRefs()` object for all properties but casts
|
|
338
|
+
* their types as raw (no-Ref) types to fit with reactive() structure of the ivue class context.
|
|
339
|
+
*/
|
|
340
|
+
export function iuse<T extends AnyClass | AnyFn | Object>(
|
|
341
|
+
classFunctionObject?: T,
|
|
342
|
+
...args: T extends AnyClass
|
|
343
|
+
? InferredArgs<T>
|
|
344
|
+
: T extends AnyFn
|
|
345
|
+
? Parameters<T extends (...args: any[]) => any ? T : any>
|
|
346
|
+
: any
|
|
347
|
+
): T extends AnyClass
|
|
348
|
+
? InstanceType<T>
|
|
349
|
+
: T extends AnyFn
|
|
350
|
+
? UseComposable<T>
|
|
351
|
+
: UnwrapComposableReturn<T> {
|
|
352
|
+
return typeof classFunctionObject === 'function'
|
|
353
|
+
? isClass(classFunctionObject)
|
|
354
|
+
? ivue(
|
|
355
|
+
classFunctionObject as T extends AnyClass ? T : any,
|
|
356
|
+
...(args as InferredArgs<T extends AnyClass ? T : any>)
|
|
357
|
+
).toRefs()
|
|
358
|
+
: (classFunctionObject as AnyFn)(
|
|
359
|
+
...(args as Parameters<T extends AnyFn ? AnyFn : any>)
|
|
360
|
+
)
|
|
361
|
+
: (classFunctionObject as unknown as UnwrapComposableReturn<T>);
|
|
347
362
|
}
|
|
348
363
|
|
|
349
364
|
/**
|