phecda-core 4.0.1 → 4.1.0-alpha.0

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.d.mts CHANGED
@@ -89,6 +89,8 @@ declare function invokeUnmount(instance: any): Promise<PromiseSettledResult<any>
89
89
  declare function If(value: Boolean, ...decorators: (ClassDecorator[]) | (PropertyDecorator[]) | (ParameterDecorator[])): (...args: any[]) => void;
90
90
  declare function getMergedMeta(target: any, property?: PropertyKey, index?: number, merger?: (prev: any, cur: any) => any): any;
91
91
  declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
92
+ declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
93
+ declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
92
94
 
93
95
  declare const DataMap: InjectData;
94
96
  declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
@@ -111,4 +113,4 @@ declare abstract class Base {
111
113
  private _unmount;
112
114
  }
113
115
 
114
- 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, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, set, setInject, setMeta, wait };
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 };
package/dist/index.d.ts CHANGED
@@ -89,6 +89,8 @@ declare function invokeUnmount(instance: any): Promise<PromiseSettledResult<any>
89
89
  declare function If(value: Boolean, ...decorators: (ClassDecorator[]) | (PropertyDecorator[]) | (ParameterDecorator[])): (...args: any[]) => void;
90
90
  declare function getMergedMeta(target: any, property?: PropertyKey, index?: number, merger?: (prev: any, cur: any) => any): any;
91
91
  declare function wait(...instances: InstanceType<Construct>[]): Promise<any[]>;
92
+ declare function objectToClass<Obj extends Record<string, any>>(obj: Obj): new () => Obj;
93
+ declare function functionToClass<Func extends (...args: any) => object>(fn: Func): new (...args: Parameters<Func>) => ReturnType<Func>;
92
94
 
93
95
  declare const DataMap: InjectData;
94
96
  declare function Provide<K extends keyof InjectData>(key: K, value: InjectData[K]): void;
@@ -111,4 +113,4 @@ declare abstract class Base {
111
113
  private _unmount;
112
114
  }
113
115
 
114
- 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, get, getInject, getMergedMeta, getMeta, getMetaKey, getMetaParams, getOwnMeta, getOwnMetaKey, getOwnMetaParams, getPhecdaFromTarget, getTag, init, invoke, invokeInit, invokeUnmount, isAsyncFunc, isPhecda, set, setInject, setMeta, wait };
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 };
package/dist/index.js CHANGED
@@ -54,6 +54,7 @@ __export(src_exports, {
54
54
  Watcher: () => Watcher,
55
55
  activeInstance: () => activeInstance,
56
56
  addDecoToClass: () => addDecoToClass,
57
+ functionToClass: () => functionToClass,
57
58
  get: () => get,
58
59
  getInject: () => getInject,
59
60
  getMergedMeta: () => getMergedMeta,
@@ -71,6 +72,7 @@ __export(src_exports, {
71
72
  invokeUnmount: () => invokeUnmount,
72
73
  isAsyncFunc: () => isAsyncFunc,
73
74
  isPhecda: () => isPhecda,
75
+ objectToClass: () => objectToClass,
74
76
  set: () => set,
75
77
  setInject: () => setInject,
76
78
  setMeta: () => setMeta,
@@ -308,6 +310,20 @@ function defaultMerger(prev, cur) {
308
310
  function wait(...instances) {
309
311
  return Promise.all(instances.map((i) => i.__PROMISE_SYMBOL__));
310
312
  }
313
+ function objectToClass(obj) {
314
+ return class {
315
+ constructor() {
316
+ Object.assign(this, obj);
317
+ }
318
+ };
319
+ }
320
+ function functionToClass(fn) {
321
+ return class {
322
+ constructor(...args) {
323
+ Object.setPrototypeOf(this, fn(...args));
324
+ }
325
+ };
326
+ }
311
327
 
312
328
  // src/di.ts
313
329
  var DataMap = {};
@@ -506,6 +522,7 @@ Base = __decorateClass([
506
522
  Watcher,
507
523
  activeInstance,
508
524
  addDecoToClass,
525
+ functionToClass,
509
526
  get,
510
527
  getInject,
511
528
  getMergedMeta,
@@ -523,6 +540,7 @@ Base = __decorateClass([
523
540
  invokeUnmount,
524
541
  isAsyncFunc,
525
542
  isPhecda,
543
+ objectToClass,
526
544
  set,
527
545
  setInject,
528
546
  setMeta,
package/dist/index.mjs CHANGED
@@ -239,6 +239,20 @@ function defaultMerger(prev, cur) {
239
239
  function wait(...instances) {
240
240
  return Promise.all(instances.map((i) => i.__PROMISE_SYMBOL__));
241
241
  }
242
+ function objectToClass(obj) {
243
+ return class {
244
+ constructor() {
245
+ Object.assign(this, obj);
246
+ }
247
+ };
248
+ }
249
+ function functionToClass(fn) {
250
+ return class {
251
+ constructor(...args) {
252
+ Object.setPrototypeOf(this, fn(...args));
253
+ }
254
+ };
255
+ }
242
256
 
243
257
  // src/di.ts
244
258
  var DataMap = {};
@@ -436,6 +450,7 @@ export {
436
450
  Watcher,
437
451
  activeInstance,
438
452
  addDecoToClass,
453
+ functionToClass,
439
454
  get,
440
455
  getInject,
441
456
  getMergedMeta,
@@ -453,6 +468,7 @@ export {
453
468
  invokeUnmount,
454
469
  isAsyncFunc,
455
470
  isPhecda,
471
+ objectToClass,
456
472
  set,
457
473
  setInject,
458
474
  setMeta,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "4.0.1",
3
+ "version": "4.1.0-alpha.0",
4
4
  "description": "provide base function and abstract limit to other phecda module ",
5
5
  "author": "fgsreally",
6
6
  "license": "MIT",