phecda-core 3.0.1 → 3.0.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/dist/index.d.mts CHANGED
@@ -120,4 +120,18 @@ declare const activeInstance: Record<string, any>;
120
120
  declare function setInject(key: string, value: any): Record<string, any>;
121
121
  declare function getInject(key: string): any;
122
122
 
123
- export { type AbConstruct, Assign, Bind, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, type Handler, If, Ignore, Init, Inject, type InjectData, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, Rule, SHARE_KEY, Storage, type StorageParam, Tag, To, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, classToPlain, get, getBind, getExposeKey, getHandler, getInject, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnState, getOwnStateKey, getPhecdaFromTarget, getShareState, getState, getStateKey, getTag, init, invokeHandler, isAsyncFunc, isPhecda, plainToClass, set, setExposeKey, setHandler, setIgnoreKey, setInject, setPropertyState, setState, setStateKey, snapShot, transformInstance, transformInstanceAsync, transformProperty, transformPropertyAsync };
123
+ declare abstract class Base {
124
+ private readonly __UNMOUNT_SYMBOL__;
125
+ private readonly __PROMISE_SYMBOL__;
126
+ abstract emitter: any;
127
+ constructor();
128
+ get tag(): PropertyKey;
129
+ then(cb: () => void, reject?: (e: any) => void): Promise<void>;
130
+ on<Key extends keyof Events>(type: Key, handler: (arg: Events[Key]) => void): void;
131
+ emit<Key extends keyof Events>(type: Key, param: Events[Key]): void;
132
+ off<Key extends keyof Events>(type: Key, handler?: (arg: Events[Key]) => void): void;
133
+ protected onUnmount(cb: () => void): void;
134
+ private _unmount;
135
+ }
136
+
137
+ export { type AbConstruct, Assign, Base, Bind, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, type Handler, If, Ignore, Init, Inject, type InjectData, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, Rule, SHARE_KEY, Storage, type StorageParam, Tag, To, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, classToPlain, get, getBind, getExposeKey, getHandler, getInject, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnState, getOwnStateKey, getPhecdaFromTarget, getShareState, getState, getStateKey, getTag, init, invokeHandler, isAsyncFunc, isPhecda, plainToClass, set, setExposeKey, setHandler, setIgnoreKey, setInject, setPropertyState, setState, setStateKey, snapShot, transformInstance, transformInstanceAsync, transformProperty, transformPropertyAsync };
package/dist/index.d.ts CHANGED
@@ -120,4 +120,18 @@ declare const activeInstance: Record<string, any>;
120
120
  declare function setInject(key: string, value: any): Record<string, any>;
121
121
  declare function getInject(key: string): any;
122
122
 
123
- export { type AbConstruct, Assign, Bind, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, type Handler, If, Ignore, Init, Inject, type InjectData, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, Rule, SHARE_KEY, Storage, type StorageParam, Tag, To, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, classToPlain, get, getBind, getExposeKey, getHandler, getInject, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnState, getOwnStateKey, getPhecdaFromTarget, getShareState, getState, getStateKey, getTag, init, invokeHandler, isAsyncFunc, isPhecda, plainToClass, set, setExposeKey, setHandler, setIgnoreKey, setInject, setPropertyState, setState, setStateKey, snapShot, transformInstance, transformInstanceAsync, transformProperty, transformPropertyAsync };
123
+ declare abstract class Base {
124
+ private readonly __UNMOUNT_SYMBOL__;
125
+ private readonly __PROMISE_SYMBOL__;
126
+ abstract emitter: any;
127
+ constructor();
128
+ get tag(): PropertyKey;
129
+ then(cb: () => void, reject?: (e: any) => void): Promise<void>;
130
+ on<Key extends keyof Events>(type: Key, handler: (arg: Events[Key]) => void): void;
131
+ emit<Key extends keyof Events>(type: Key, param: Events[Key]): void;
132
+ off<Key extends keyof Events>(type: Key, handler?: (arg: Events[Key]) => void): void;
133
+ protected onUnmount(cb: () => void): void;
134
+ private _unmount;
135
+ }
136
+
137
+ export { type AbConstruct, Assign, Base, Bind, type ClassValue, Clear, type Construct, DataMap, Effect, Empty, Err, type Events, Expose, Global, type Handler, If, Ignore, Init, Inject, type InjectData, Isolate, type NameSpace, PHECDA_KEY, type Phecda, Pipeline, Provide, Rule, SHARE_KEY, Storage, type StorageParam, Tag, To, Unique, Unmount, Watcher, type WatcherParam, activeInstance, addDecoToClass, classToPlain, get, getBind, getExposeKey, getHandler, getInject, getOwnExposeKey, getOwnHandler, getOwnIgnoreKey, getOwnState, getOwnStateKey, getPhecdaFromTarget, getShareState, getState, getStateKey, getTag, init, invokeHandler, isAsyncFunc, isPhecda, plainToClass, set, setExposeKey, setHandler, setIgnoreKey, setInject, setPropertyState, setState, setStateKey, snapShot, transformInstance, transformInstanceAsync, transformProperty, transformPropertyAsync };
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
24
  Assign: () => Assign,
25
+ Base: () => Base,
25
26
  Bind: () => Bind,
26
27
  Clear: () => Clear,
27
28
  DataMap: () => DataMap,
@@ -687,9 +688,60 @@ function If(value, ...decorators) {
687
688
  };
688
689
  }
689
690
  __name(If, "If");
691
+
692
+ // src/base.ts
693
+ function _ts_decorate(decorators, target, key, desc) {
694
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
695
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
696
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
697
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
698
+ }
699
+ __name(_ts_decorate, "_ts_decorate");
700
+ function _ts_metadata(k, v) {
701
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
702
+ }
703
+ __name(_ts_metadata, "_ts_metadata");
704
+ var Base = class {
705
+ static {
706
+ __name(this, "Base");
707
+ }
708
+ __UNMOUNT_SYMBOL__ = [];
709
+ __PROMISE_SYMBOL__;
710
+ constructor() {
711
+ }
712
+ get tag() {
713
+ return getTag(this);
714
+ }
715
+ then(cb, reject) {
716
+ return this.__PROMISE_SYMBOL__.then(cb, reject);
717
+ }
718
+ on(type, handler) {
719
+ this.emitter.on(type, handler);
720
+ this.onUnmount(() => this.emitter.off(type, handler));
721
+ }
722
+ emit(type, param) {
723
+ this.emitter.emit(type, param);
724
+ }
725
+ off(type, handler) {
726
+ this.emitter.off(type, handler);
727
+ }
728
+ onUnmount(cb) {
729
+ this.__UNMOUNT_SYMBOL__.push(cb);
730
+ }
731
+ _unmount() {
732
+ return Promise.all(this.__UNMOUNT_SYMBOL__.map((fn) => fn()));
733
+ }
734
+ };
735
+ _ts_decorate([
736
+ Unmount,
737
+ _ts_metadata("design:type", Function),
738
+ _ts_metadata("design:paramtypes", []),
739
+ _ts_metadata("design:returntype", void 0)
740
+ ], Base.prototype, "_unmount", null);
690
741
  // Annotate the CommonJS export names for ESM import in node:
691
742
  0 && (module.exports = {
692
743
  Assign,
744
+ Base,
693
745
  Bind,
694
746
  Clear,
695
747
  DataMap,
package/dist/index.mjs CHANGED
@@ -603,8 +603,59 @@ function If(value, ...decorators) {
603
603
  };
604
604
  }
605
605
  __name(If, "If");
606
+
607
+ // src/base.ts
608
+ function _ts_decorate(decorators, target, key, desc) {
609
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
610
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
611
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
612
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
613
+ }
614
+ __name(_ts_decorate, "_ts_decorate");
615
+ function _ts_metadata(k, v) {
616
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
617
+ }
618
+ __name(_ts_metadata, "_ts_metadata");
619
+ var Base = class {
620
+ static {
621
+ __name(this, "Base");
622
+ }
623
+ __UNMOUNT_SYMBOL__ = [];
624
+ __PROMISE_SYMBOL__;
625
+ constructor() {
626
+ }
627
+ get tag() {
628
+ return getTag(this);
629
+ }
630
+ then(cb, reject) {
631
+ return this.__PROMISE_SYMBOL__.then(cb, reject);
632
+ }
633
+ on(type, handler) {
634
+ this.emitter.on(type, handler);
635
+ this.onUnmount(() => this.emitter.off(type, handler));
636
+ }
637
+ emit(type, param) {
638
+ this.emitter.emit(type, param);
639
+ }
640
+ off(type, handler) {
641
+ this.emitter.off(type, handler);
642
+ }
643
+ onUnmount(cb) {
644
+ this.__UNMOUNT_SYMBOL__.push(cb);
645
+ }
646
+ _unmount() {
647
+ return Promise.all(this.__UNMOUNT_SYMBOL__.map((fn) => fn()));
648
+ }
649
+ };
650
+ _ts_decorate([
651
+ Unmount,
652
+ _ts_metadata("design:type", Function),
653
+ _ts_metadata("design:paramtypes", []),
654
+ _ts_metadata("design:returntype", void 0)
655
+ ], Base.prototype, "_unmount", null);
606
656
  export {
607
657
  Assign,
658
+ Base,
608
659
  Bind,
609
660
  Clear,
610
661
  DataMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-core",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "provide base function and abstract limit to other phecda module ",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",