phecda-core 4.1.0-alpha.0 → 4.1.0-alpha.2
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/README.md +3 -3
- package/dist/a.ts +17 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +26 -4
- package/dist/index.mjs +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
# phecda-core
|
|
2
|
-
provide base function and abstract limit to other phecda module
|
|
3
|
-
|
|
1
|
+
# phecda-core
|
|
2
|
+
provide base function and abstract limit to other phecda module
|
|
3
|
+
|
package/dist/a.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function Pick<T extends object, K extends keyof T>(obj: T, ...args: K[]): Pick<T, K> {
|
|
2
|
+
const result = {} as Pick<T, K>
|
|
3
|
+
for (const key of args) {
|
|
4
|
+
if (obj.hasOwnProperty(key)) {
|
|
5
|
+
result[key] = obj[key]
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return result
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const a = {
|
|
12
|
+
b: 1,
|
|
13
|
+
c: 1
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const x = Pick(a, 'b', 'c')
|
package/dist/index.d.mts
CHANGED
|
@@ -91,6 +91,7 @@ declare function getMergedMeta(target: any, property?: PropertyKey, index?: numb
|
|
|
91
91
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
92
92
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
93
93
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
94
|
+
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
94
95
|
|
|
95
96
|
declare const DataMap: InjectData;
|
|
96
97
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
|
@@ -113,4 +114,4 @@ declare abstract class Base {
|
|
|
113
114
|
private _unmount;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, set, setInject, setMeta, wait };
|
|
117
|
+
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, set, setInject, setMeta, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,6 +91,7 @@ declare function getMergedMeta(target: any, property?: PropertyKey, index?: numb
|
|
|
91
91
|
declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
|
|
92
92
|
declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
|
|
93
93
|
declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
|
|
94
|
+
declare function omit<Class extends Construct, Key extends keyof InstanceType<Class>>(classFn: Class, ...properties: Key[]): Construct<Omit<InstanceType<Class>, Key>>;
|
|
94
95
|
|
|
95
96
|
declare const DataMap: InjectData;
|
|
96
97
|
declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
|
|
@@ -113,4 +114,4 @@ declare abstract class Base {
|
|
|
113
114
|
private _unmount;
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, set, setInject, setMeta, wait };
|
|
117
|
+
export { type AbConstruct, Assign, Base, CLEAR_KEY, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, If, Init, Inject, type InjectData, Injectable, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, SHARE_KEY, Storage, type StorageParam, Tag, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, functionToClass, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, objectToClass, omit, set, setInject, setMeta, wait };
|
package/dist/index.js
CHANGED
|
@@ -26,8 +26,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// src/index.ts
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
31
|
Assign: () => Assign,
|
|
32
32
|
Base: () => Base,
|
|
33
33
|
CLEAR_KEY: () => CLEAR_KEY,
|
|
@@ -73,12 +73,13 @@ __export(src_exports, {
|
|
|
73
73
|
isAsyncFunc: () => isAsyncFunc,
|
|
74
74
|
isPhecda: () => isPhecda,
|
|
75
75
|
objectToClass: () => objectToClass,
|
|
76
|
+
omit: () => omit,
|
|
76
77
|
set: () => set,
|
|
77
78
|
setInject: () => setInject,
|
|
78
79
|
setMeta: () => setMeta,
|
|
79
80
|
wait: () => wait
|
|
80
81
|
});
|
|
81
|
-
module.exports = __toCommonJS(
|
|
82
|
+
module.exports = __toCommonJS(index_exports);
|
|
82
83
|
|
|
83
84
|
// src/core.ts
|
|
84
85
|
var SHARE_KEY = Symbol("phecda[share]");
|
|
@@ -255,7 +256,12 @@ function invoke(instance, key, ...params) {
|
|
|
255
256
|
const metaKeys = getMetaKey(instance);
|
|
256
257
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
257
258
|
return getMeta(instance, k);
|
|
258
|
-
}).flat().filter((item) => typeof item[key] === "function").map((item) => item[key](instance, ...params)))
|
|
259
|
+
}).flat().filter((item) => typeof item[key] === "function").map((item) => item[key](instance, ...params))).then((res) => {
|
|
260
|
+
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
261
|
+
console.error(item.reason);
|
|
262
|
+
});
|
|
263
|
+
return res;
|
|
264
|
+
});
|
|
259
265
|
}
|
|
260
266
|
function invokeInit(instance) {
|
|
261
267
|
return instance.__PROMISE_SYMBOL__ = invoke(instance, "init");
|
|
@@ -324,6 +330,21 @@ function functionToClass(fn) {
|
|
|
324
330
|
}
|
|
325
331
|
};
|
|
326
332
|
}
|
|
333
|
+
function omit(classFn, ...properties) {
|
|
334
|
+
const newClass = class extends classFn {
|
|
335
|
+
constructor(...args) {
|
|
336
|
+
super(...args);
|
|
337
|
+
properties.forEach((k) => {
|
|
338
|
+
delete this[k];
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
getMetaKey(classFn).forEach((k) => {
|
|
343
|
+
if (properties.includes(k))
|
|
344
|
+
addDecoToClass(newClass, k, Clear);
|
|
345
|
+
});
|
|
346
|
+
return newClass;
|
|
347
|
+
}
|
|
327
348
|
|
|
328
349
|
// src/di.ts
|
|
329
350
|
var DataMap = {};
|
|
@@ -541,6 +562,7 @@ Base = __decorateClass([
|
|
|
541
562
|
isAsyncFunc,
|
|
542
563
|
isPhecda,
|
|
543
564
|
objectToClass,
|
|
565
|
+
omit,
|
|
544
566
|
set,
|
|
545
567
|
setInject,
|
|
546
568
|
setMeta,
|
package/dist/index.mjs
CHANGED
|
@@ -184,7 +184,12 @@ function invoke(instance, key, ...params) {
|
|
|
184
184
|
const metaKeys = getMetaKey(instance);
|
|
185
185
|
return Promise.allSettled(metaKeys.map((k) => {
|
|
186
186
|
return getMeta(instance, k);
|
|
187
|
-
}).flat().filter((item) => typeof item[key] === "function").map((item) => item[key](instance, ...params)))
|
|
187
|
+
}).flat().filter((item) => typeof item[key] === "function").map((item) => item[key](instance, ...params))).then((res) => {
|
|
188
|
+
res.filter((item) => item.status === "rejected").forEach((item) => {
|
|
189
|
+
console.error(item.reason);
|
|
190
|
+
});
|
|
191
|
+
return res;
|
|
192
|
+
});
|
|
188
193
|
}
|
|
189
194
|
function invokeInit(instance) {
|
|
190
195
|
return instance.__PROMISE_SYMBOL__ = invoke(instance, "init");
|
|
@@ -253,6 +258,21 @@ function functionToClass(fn) {
|
|
|
253
258
|
}
|
|
254
259
|
};
|
|
255
260
|
}
|
|
261
|
+
function omit(classFn, ...properties) {
|
|
262
|
+
const newClass = class extends classFn {
|
|
263
|
+
constructor(...args) {
|
|
264
|
+
super(...args);
|
|
265
|
+
properties.forEach((k) => {
|
|
266
|
+
delete this[k];
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
getMetaKey(classFn).forEach((k) => {
|
|
271
|
+
if (properties.includes(k))
|
|
272
|
+
addDecoToClass(newClass, k, Clear);
|
|
273
|
+
});
|
|
274
|
+
return newClass;
|
|
275
|
+
}
|
|
256
276
|
|
|
257
277
|
// src/di.ts
|
|
258
278
|
var DataMap = {};
|
|
@@ -469,6 +489,7 @@ export {
|
|
|
469
489
|
isAsyncFunc,
|
|
470
490
|
isPhecda,
|
|
471
491
|
objectToClass,
|
|
492
|
+
omit,
|
|
472
493
|
set,
|
|
473
494
|
setInject,
|
|
474
495
|
setMeta,
|