taon 19.0.28 → 19.0.29

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.
@@ -761,6 +761,95 @@ let CURRENT_HOST_BACKEND_PORT;
761
761
  //#region @browser
762
762
  CURRENT_HOST_BACKEND_PORT = new InjectionToken('CURRENT_HOST_BACKEND_PORT');
763
763
 
764
+ const inject = (entity) => {
765
+ return new Proxy({}, {
766
+ get: (_, propName) => {
767
+ if (propName === 'hasOwnProperty') {
768
+ return () => false;
769
+ }
770
+ const ctor = entity();
771
+ const contextFromClass = ctor[Symbols.ctxInClassOrClassObj];
772
+ const resultContext = contextFromClass;
773
+ if (resultContext) {
774
+ let instance = resultContext.inject(ctor, {
775
+ parentInstanceThatWillGetInjectedStuff: this,
776
+ });
777
+ // console.log('instance', instance);
778
+ if (propName === 'getOriginalPrototype') {
779
+ return () => Object.getPrototypeOf(instance);
780
+ }
781
+ if (propName === 'getOriginalConstructor') {
782
+ return () => instance.constructor;
783
+ }
784
+ const methods = ctor[Symbols.classMethodsNames] || [];
785
+ const isMethods = methods.includes(propName);
786
+ const methodOrProperty = isMethods
787
+ ? instance[propName].bind(instance)
788
+ : instance[propName];
789
+ // console.log(
790
+ // `methodOrProperty from proxy ${propName?.toString()} = isMethods:${isMethods}`,
791
+ // methods,
792
+ // );
793
+ return methodOrProperty;
794
+ }
795
+ },
796
+ });
797
+ };
798
+ // export const injectController = inject;
799
+ // export type SubscriptionEvent<T> = {
800
+ // name: keyof T;
801
+ // data: any;
802
+ // };
803
+ /**
804
+ * TODO
805
+ */
806
+ // export const injectEntityEvents = <T>(
807
+ // subscriberClassResolveFn: () => new (...args: any[]) => T,
808
+ // eventName?: keyof Omit<EntitySubscriberInterface,'listenTo'> ,
809
+ // ): Observable<SubscriptionEvent<T>> => {
810
+ // const eventsSrc = new Subject<SubscriptionEvent<T>>();
811
+ // const obs = eventsSrc.asObservable();
812
+ // let isFirstSubscription = true;
813
+ // const proxyObservable = new Proxy(obs, {
814
+ // get(target, prop, receiver) {
815
+ // if (prop === 'subscribe') {
816
+ // return (...args: any[]) => {
817
+ // if (isFirstSubscription) {
818
+ // isFirstSubscription = false;
819
+ // const subscriberClassFN: typeof BaseClass =
820
+ // subscriberClassResolveFn() as any;
821
+ // const ctx = subscriberClassFN[
822
+ // Symbols.ctxInClassOrClassObj
823
+ // ] as EndpointContext;
824
+ // if (!ctx) {
825
+ // throw new Error(
826
+ // `You are trying to inject class without context. Use context like this:
827
+ // class MyClassSubscriber extends BaseSubscriber {
828
+ // ${eventName as any}() {
829
+ // \/\/ your code here
830
+ // }
831
+ // }
832
+ // Taon.injectSubscriberEvents( MyContext.getInstance(()=> MyClassSubscriber), '${eventName as any}' )
833
+ // `,
834
+ // );
835
+ // }
836
+ // const subscriberInstance = ctx.getInstanceBy(subscriberClassFN);
837
+ // // subscriberInstance TODO @LAST subscriber event from instance
838
+ // // const entity = subscriberClassFN.prototype.listenTo();
839
+ // console.log('First subscription, you can access arguments here:', {
840
+ // subscriberClassFN,
841
+ // eventName,
842
+ // });
843
+ // }
844
+ // return target.subscribe(...args);
845
+ // };
846
+ // }
847
+ // return Reflect.get(target, prop, receiver);
848
+ // },
849
+ // });
850
+ // return proxyObservable as Observable<SubscriptionEvent<T>>;
851
+ // };
852
+
764
853
  /**
765
854
  * TODO prevent calling methods when not initialized
766
855
  * with init(ctx)
@@ -772,7 +861,9 @@ class BaseAngularsService {
772
861
  //#region @browser
773
862
  this.currentContext = inject$1(TAON_CONTEXT);
774
863
  //#region @browser
775
- this.CURRENT_HOST_BACKEND_PORT = inject$1(CURRENT_HOST_BACKEND_PORT);
864
+ this.CURRENT_HOST_BACKEND_PORT = inject$1(CURRENT_HOST_BACKEND_PORT, {
865
+ optional: true,
866
+ });
776
867
  // #endregion
777
868
  }
778
869
  /**
@@ -783,6 +874,13 @@ class BaseAngularsService {
783
874
  get host() {
784
875
  return `http://localhost:${this.CURRENT_HOST_BACKEND_PORT}`;
785
876
  }
877
+ injectController(ctor) {
878
+ let currentContext;
879
+ //#region @browser
880
+ currentContext = this.currentContext;
881
+ //#endregion
882
+ return inject(() => currentContext.getClass(ctor));
883
+ }
786
884
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: BaseAngularsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
787
885
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: BaseAngularsService }); }
788
886
  }
@@ -4197,7 +4295,7 @@ class EndpointContext {
4197
4295
  const orgMethods = target.prototype[methodConfig.methodName];
4198
4296
  //#region handle electron ipc request
4199
4297
  if (Helpers.isElectron) {
4200
- const { ipcRenderer } = await import('electron');
4298
+ const ipcRenderer = window.require('electron').ipcRenderer;
4201
4299
  target.prototype[methodConfig.methodName] = function (...args) {
4202
4300
  const received = new Promise(async (resolve, reject) => {
4203
4301
  const headers = {};
@@ -6299,95 +6397,6 @@ var Http;
6299
6397
  })(Param = Http.Param || (Http.Param = {}));
6300
6398
  })(Http || (Http = {}));
6301
6399
 
6302
- const inject = (entity) => {
6303
- return new Proxy({}, {
6304
- get: (_, propName) => {
6305
- if (propName === 'hasOwnProperty') {
6306
- return () => false;
6307
- }
6308
- const ctor = entity();
6309
- const contextFromClass = ctor[Symbols.ctxInClassOrClassObj];
6310
- const resultContext = contextFromClass;
6311
- if (resultContext) {
6312
- let instance = resultContext.inject(ctor, {
6313
- parentInstanceThatWillGetInjectedStuff: this,
6314
- });
6315
- // console.log('instance', instance);
6316
- if (propName === 'getOriginalPrototype') {
6317
- return () => Object.getPrototypeOf(instance);
6318
- }
6319
- if (propName === 'getOriginalConstructor') {
6320
- return () => instance.constructor;
6321
- }
6322
- const methods = ctor[Symbols.classMethodsNames] || [];
6323
- const isMethods = methods.includes(propName);
6324
- const methodOrProperty = isMethods
6325
- ? instance[propName].bind(instance)
6326
- : instance[propName];
6327
- // console.log(
6328
- // `methodOrProperty from proxy ${propName?.toString()} = isMethods:${isMethods}`,
6329
- // methods,
6330
- // );
6331
- return methodOrProperty;
6332
- }
6333
- },
6334
- });
6335
- };
6336
- // export const injectController = inject;
6337
- // export type SubscriptionEvent<T> = {
6338
- // name: keyof T;
6339
- // data: any;
6340
- // };
6341
- /**
6342
- * TODO
6343
- */
6344
- // export const injectEntityEvents = <T>(
6345
- // subscriberClassResolveFn: () => new (...args: any[]) => T,
6346
- // eventName?: keyof Omit<EntitySubscriberInterface,'listenTo'> ,
6347
- // ): Observable<SubscriptionEvent<T>> => {
6348
- // const eventsSrc = new Subject<SubscriptionEvent<T>>();
6349
- // const obs = eventsSrc.asObservable();
6350
- // let isFirstSubscription = true;
6351
- // const proxyObservable = new Proxy(obs, {
6352
- // get(target, prop, receiver) {
6353
- // if (prop === 'subscribe') {
6354
- // return (...args: any[]) => {
6355
- // if (isFirstSubscription) {
6356
- // isFirstSubscription = false;
6357
- // const subscriberClassFN: typeof BaseClass =
6358
- // subscriberClassResolveFn() as any;
6359
- // const ctx = subscriberClassFN[
6360
- // Symbols.ctxInClassOrClassObj
6361
- // ] as EndpointContext;
6362
- // if (!ctx) {
6363
- // throw new Error(
6364
- // `You are trying to inject class without context. Use context like this:
6365
- // class MyClassSubscriber extends BaseSubscriber {
6366
- // ${eventName as any}() {
6367
- // \/\/ your code here
6368
- // }
6369
- // }
6370
- // Taon.injectSubscriberEvents( MyContext.getInstance(()=> MyClassSubscriber), '${eventName as any}' )
6371
- // `,
6372
- // );
6373
- // }
6374
- // const subscriberInstance = ctx.getInstanceBy(subscriberClassFN);
6375
- // // subscriberInstance TODO @LAST subscriber event from instance
6376
- // // const entity = subscriberClassFN.prototype.listenTo();
6377
- // console.log('First subscription, you can access arguments here:', {
6378
- // subscriberClassFN,
6379
- // eventName,
6380
- // });
6381
- // }
6382
- // return target.subscribe(...args);
6383
- // };
6384
- // }
6385
- // return Reflect.get(target, prop, receiver);
6386
- // },
6387
- // });
6388
- // return proxyObservable as Observable<SubscriptionEvent<T>>;
6389
- // };
6390
-
6391
6400
  // TODO export all things
6392
6401
  var Taon;
6393
6402
  (function (Taon) {