@rugal.tu/vuemodel3 1.3.1 → 1.3.3

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.
@@ -501,10 +501,9 @@ export class ApiStore extends FuncBase {
501
501
  FileStore: {},
502
502
  };
503
503
  #Func_ConvertTo_FormData = [];
504
- $ApiStore = {};
505
504
  constructor() {
506
505
  super();
507
- this.SetStore('api', this.$ApiStore);
506
+ this.SetStore('api', {});
508
507
  }
509
508
  get ApiDomain() {
510
509
  if (this.#ApiDomain == null)
@@ -526,6 +525,9 @@ export class ApiStore extends FuncBase {
526
525
  set Store(Store) {
527
526
  this.#Store = Store;
528
527
  }
528
+ get ApiStore() {
529
+ return this.GetStore('api');
530
+ }
529
531
  get FileStore() {
530
532
  return this.Store.FileStore;
531
533
  }
@@ -588,7 +590,7 @@ export class ApiStore extends FuncBase {
588
590
  ApiKey,
589
591
  ...ApiOption,
590
592
  };
591
- this.$ApiStore[ApiKey] = SetApi;
593
+ this.ApiStore[ApiKey] = SetApi;
592
594
  this.$EventTrigger(this.#EventName.AddApi, SetApi);
593
595
  }
594
596
  return this;
@@ -602,7 +604,7 @@ export class ApiStore extends FuncBase {
602
604
  return this;
603
605
  }
604
606
  $BaseApiCall(ApiKey, Option, IsFormRequest) {
605
- let Api = this.$ApiStore[ApiKey];
607
+ let Api = this.ApiStore[ApiKey];
606
608
  if (Api == null)
607
609
  this.$Throw(`Api setting not found of "${ApiKey}"`);
608
610
  let ParamQuery = Option?.Query ?? Api.Query;
@@ -740,8 +742,8 @@ export class ApiStore extends FuncBase {
740
742
  UpdateStore(StorePath, StoreData) {
741
743
  return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
742
744
  }
743
- ClearStore(StorePath) {
744
- return this.ClearStoreFrom(this.Store, StorePath);
745
+ ClearStore(StorePath, Option) {
746
+ return this.ClearStoreFrom(this.Store, StorePath, Option);
745
747
  }
746
748
  GetStoreFrom(SourceStore, StorePath, Option) {
747
749
  if (typeof Option == 'boolean')
@@ -781,7 +783,8 @@ export class ApiStore extends FuncBase {
781
783
  return this;
782
784
  }
783
785
  SetStoreFrom(SourceStore, StorePath, StoreData) {
784
- StorePath = this.ToJoin(StorePath);
786
+ if (StorePath != null)
787
+ StorePath = this.ToJoin(StorePath);
785
788
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
786
789
  IsDeepSet: false,
787
790
  });
@@ -792,7 +795,8 @@ export class ApiStore extends FuncBase {
792
795
  return this;
793
796
  }
794
797
  UpdateStoreFrom(SourceStore, StorePath, StoreData) {
795
- StorePath = this.ToJoin(StorePath);
798
+ if (StorePath != null)
799
+ StorePath = this.ToJoin(StorePath);
796
800
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
797
801
  IsDeepSet: true,
798
802
  });
@@ -802,24 +806,14 @@ export class ApiStore extends FuncBase {
802
806
  });
803
807
  return this;
804
808
  }
805
- ClearStoreFrom(SourceStore, StorePath) {
806
- let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
809
+ ClearStoreFrom(SourceStore, StorePath, Option) {
810
+ Option ??= {};
811
+ if (typeof Option === 'boolean')
812
+ Option = { DeepClear: Option };
813
+ let TargetStore = StorePath == null ? SourceStore : this.GetStoreFrom(SourceStore, StorePath);
807
814
  if (TargetStore == null)
808
815
  return this;
809
- let AllProperty = Object.getOwnPropertyNames(TargetStore);
810
- for (let Key of AllProperty) {
811
- if (Key.match(/^\$/g))
812
- continue;
813
- let Value = TargetStore[Key];
814
- if (typeof (Value) == 'function')
815
- continue;
816
- if (Array.isArray(Value)) {
817
- Value.splice(0, Value.length);
818
- ;
819
- continue;
820
- }
821
- TargetStore[Key] = null;
822
- }
816
+ this.$RCS_ClearStore(TargetStore, Option);
823
817
  return this;
824
818
  }
825
819
  $RCS_GetStore(StorePath, FindStore, Option) {
@@ -845,6 +839,10 @@ export class ApiStore extends FuncBase {
845
839
  $RCS_SetStore(StorePath, StoreData, FindStore, Option = {
846
840
  IsDeepSet: true,
847
841
  }) {
842
+ if (StorePath == null) {
843
+ this.$DeepSetObject(StoreData, FindStore);
844
+ return StoreData;
845
+ }
848
846
  StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
849
847
  if (StorePath.includes('.')) {
850
848
  let StorePaths = StorePath.split('.');
@@ -855,36 +853,64 @@ export class ApiStore extends FuncBase {
855
853
  let NextKey = StorePaths.join('.');
856
854
  return this.$RCS_SetStore(NextKey, StoreData, NextStore, Option);
857
855
  }
858
- let IsAwaysSet = !Option.IsDeepSet ||
856
+ let IsAwaysSet = StoreData == null ||
857
+ !Option.IsDeepSet ||
859
858
  FindStore[StorePath] == null ||
860
- StoreData == null || typeof StoreData != 'object';
859
+ typeof StoreData != 'object';
861
860
  if (IsAwaysSet) {
862
861
  FindStore[StorePath] = StoreData;
863
862
  return StoreData;
864
863
  }
865
- this.$DeepSetObject(StorePath, StoreData, FindStore);
866
- return StoreData;
864
+ return this.$RCS_SetStore(null, StoreData, FindStore[StorePath]);
867
865
  }
868
- $DeepSetObject(StorePath, SetData, FindStore) {
866
+ $RCS_ClearStore(TargetStore, Option) {
867
+ if (typeof TargetStore != 'object')
868
+ return;
869
+ if (Array.isArray(TargetStore)) {
870
+ TargetStore.length = 0;
871
+ return;
872
+ }
873
+ let AllProperty = Object.getOwnPropertyNames(TargetStore);
874
+ for (let Key of AllProperty) {
875
+ if (Key.match(/^\$/g))
876
+ continue;
877
+ if (typeof TargetStore[Key] === 'function')
878
+ continue;
879
+ else if (Option.DeepClear && typeof TargetStore[Key] === 'object')
880
+ this.$RCS_ClearStore(TargetStore[Key], Option);
881
+ else
882
+ TargetStore[Key] = null;
883
+ }
884
+ }
885
+ $DeepSetObject(SetData, FindStore) {
869
886
  if (SetData == null) {
870
- FindStore[StorePath] = SetData;
887
+ this.ClearStoreFrom(FindStore);
871
888
  return;
872
889
  }
873
- if (!Array.isArray(SetData)) {
874
- this.ForEachObject(SetData, (Key, Value) => {
875
- if (Array.isArray(Value) || typeof Value == 'object') {
876
- this.$DeepSetObject(Key, Value, FindStore[StorePath]);
877
- return;
878
- }
879
- if (FindStore[StorePath] == null)
880
- FindStore[StorePath] = {};
881
- FindStore[StorePath][Key] = Value;
882
- });
890
+ if (Array.isArray(SetData)) {
891
+ if (!Array.isArray(FindStore))
892
+ return;
893
+ FindStore.length = 0;
894
+ FindStore.push.apply(FindStore, SetData);
883
895
  return;
884
896
  }
885
- if (!Array.isArray(FindStore[StorePath]))
886
- FindStore[StorePath] = [];
887
- FindStore[StorePath] = SetData.slice();
897
+ this.ForEachObject(SetData, (Key, Value) => {
898
+ let IsGoNext = false;
899
+ if (Array.isArray(Value)) {
900
+ if (FindStore[Key] == null || !Array.isArray(FindStore[Key]))
901
+ FindStore[Key] = [];
902
+ IsGoNext = true;
903
+ }
904
+ else if (typeof Value == 'object') {
905
+ if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
906
+ FindStore[Key] = {};
907
+ IsGoNext = true;
908
+ }
909
+ if (IsGoNext)
910
+ this.$DeepSetObject(Value, FindStore[Key]);
911
+ else
912
+ FindStore[Key] = Value;
913
+ });
888
914
  }
889
915
  AddFileStore(FileStoreKey, Option) {
890
916
  Option ??= {};
@@ -517,10 +517,9 @@
517
517
  FileStore: {},
518
518
  };
519
519
  #Func_ConvertTo_FormData = [];
520
- $ApiStore = {};
521
520
  constructor() {
522
521
  super();
523
- this.SetStore('api', this.$ApiStore);
522
+ this.SetStore('api', {});
524
523
  }
525
524
  get ApiDomain() {
526
525
  if (this.#ApiDomain == null)
@@ -542,6 +541,9 @@
542
541
  set Store(Store) {
543
542
  this.#Store = Store;
544
543
  }
544
+ get ApiStore() {
545
+ return this.GetStore('api');
546
+ }
545
547
  get FileStore() {
546
548
  return this.Store.FileStore;
547
549
  }
@@ -604,7 +606,7 @@
604
606
  ApiKey,
605
607
  ...ApiOption,
606
608
  };
607
- this.$ApiStore[ApiKey] = SetApi;
609
+ this.ApiStore[ApiKey] = SetApi;
608
610
  this.$EventTrigger(this.#EventName.AddApi, SetApi);
609
611
  }
610
612
  return this;
@@ -618,7 +620,7 @@
618
620
  return this;
619
621
  }
620
622
  $BaseApiCall(ApiKey, Option, IsFormRequest) {
621
- let Api = this.$ApiStore[ApiKey];
623
+ let Api = this.ApiStore[ApiKey];
622
624
  if (Api == null)
623
625
  this.$Throw(`Api setting not found of "${ApiKey}"`);
624
626
  let ParamQuery = Option?.Query ?? Api.Query;
@@ -756,8 +758,8 @@
756
758
  UpdateStore(StorePath, StoreData) {
757
759
  return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
758
760
  }
759
- ClearStore(StorePath) {
760
- return this.ClearStoreFrom(this.Store, StorePath);
761
+ ClearStore(StorePath, Option) {
762
+ return this.ClearStoreFrom(this.Store, StorePath, Option);
761
763
  }
762
764
  GetStoreFrom(SourceStore, StorePath, Option) {
763
765
  if (typeof Option == 'boolean')
@@ -797,7 +799,8 @@
797
799
  return this;
798
800
  }
799
801
  SetStoreFrom(SourceStore, StorePath, StoreData) {
800
- StorePath = this.ToJoin(StorePath);
802
+ if (StorePath != null)
803
+ StorePath = this.ToJoin(StorePath);
801
804
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
802
805
  IsDeepSet: false,
803
806
  });
@@ -808,7 +811,8 @@
808
811
  return this;
809
812
  }
810
813
  UpdateStoreFrom(SourceStore, StorePath, StoreData) {
811
- StorePath = this.ToJoin(StorePath);
814
+ if (StorePath != null)
815
+ StorePath = this.ToJoin(StorePath);
812
816
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
813
817
  IsDeepSet: true,
814
818
  });
@@ -818,24 +822,14 @@
818
822
  });
819
823
  return this;
820
824
  }
821
- ClearStoreFrom(SourceStore, StorePath) {
822
- let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
825
+ ClearStoreFrom(SourceStore, StorePath, Option) {
826
+ Option ??= {};
827
+ if (typeof Option === 'boolean')
828
+ Option = { DeepClear: Option };
829
+ let TargetStore = StorePath == null ? SourceStore : this.GetStoreFrom(SourceStore, StorePath);
823
830
  if (TargetStore == null)
824
831
  return this;
825
- let AllProperty = Object.getOwnPropertyNames(TargetStore);
826
- for (let Key of AllProperty) {
827
- if (Key.match(/^\$/g))
828
- continue;
829
- let Value = TargetStore[Key];
830
- if (typeof (Value) == 'function')
831
- continue;
832
- if (Array.isArray(Value)) {
833
- Value.splice(0, Value.length);
834
- ;
835
- continue;
836
- }
837
- TargetStore[Key] = null;
838
- }
832
+ this.$RCS_ClearStore(TargetStore, Option);
839
833
  return this;
840
834
  }
841
835
  $RCS_GetStore(StorePath, FindStore, Option) {
@@ -861,6 +855,10 @@
861
855
  $RCS_SetStore(StorePath, StoreData, FindStore, Option = {
862
856
  IsDeepSet: true,
863
857
  }) {
858
+ if (StorePath == null) {
859
+ this.$DeepSetObject(StoreData, FindStore);
860
+ return StoreData;
861
+ }
864
862
  StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
865
863
  if (StorePath.includes('.')) {
866
864
  let StorePaths = StorePath.split('.');
@@ -871,36 +869,64 @@
871
869
  let NextKey = StorePaths.join('.');
872
870
  return this.$RCS_SetStore(NextKey, StoreData, NextStore, Option);
873
871
  }
874
- let IsAwaysSet = !Option.IsDeepSet ||
872
+ let IsAwaysSet = StoreData == null ||
873
+ !Option.IsDeepSet ||
875
874
  FindStore[StorePath] == null ||
876
- StoreData == null || typeof StoreData != 'object';
875
+ typeof StoreData != 'object';
877
876
  if (IsAwaysSet) {
878
877
  FindStore[StorePath] = StoreData;
879
878
  return StoreData;
880
879
  }
881
- this.$DeepSetObject(StorePath, StoreData, FindStore);
882
- return StoreData;
880
+ return this.$RCS_SetStore(null, StoreData, FindStore[StorePath]);
883
881
  }
884
- $DeepSetObject(StorePath, SetData, FindStore) {
882
+ $RCS_ClearStore(TargetStore, Option) {
883
+ if (typeof TargetStore != 'object')
884
+ return;
885
+ if (Array.isArray(TargetStore)) {
886
+ TargetStore.length = 0;
887
+ return;
888
+ }
889
+ let AllProperty = Object.getOwnPropertyNames(TargetStore);
890
+ for (let Key of AllProperty) {
891
+ if (Key.match(/^\$/g))
892
+ continue;
893
+ if (typeof TargetStore[Key] === 'function')
894
+ continue;
895
+ else if (Option.DeepClear && typeof TargetStore[Key] === 'object')
896
+ this.$RCS_ClearStore(TargetStore[Key], Option);
897
+ else
898
+ TargetStore[Key] = null;
899
+ }
900
+ }
901
+ $DeepSetObject(SetData, FindStore) {
885
902
  if (SetData == null) {
886
- FindStore[StorePath] = SetData;
903
+ this.ClearStoreFrom(FindStore);
887
904
  return;
888
905
  }
889
- if (!Array.isArray(SetData)) {
890
- this.ForEachObject(SetData, (Key, Value) => {
891
- if (Array.isArray(Value) || typeof Value == 'object') {
892
- this.$DeepSetObject(Key, Value, FindStore[StorePath]);
893
- return;
894
- }
895
- if (FindStore[StorePath] == null)
896
- FindStore[StorePath] = {};
897
- FindStore[StorePath][Key] = Value;
898
- });
906
+ if (Array.isArray(SetData)) {
907
+ if (!Array.isArray(FindStore))
908
+ return;
909
+ FindStore.length = 0;
910
+ FindStore.push.apply(FindStore, SetData);
899
911
  return;
900
912
  }
901
- if (!Array.isArray(FindStore[StorePath]))
902
- FindStore[StorePath] = [];
903
- FindStore[StorePath] = SetData.slice();
913
+ this.ForEachObject(SetData, (Key, Value) => {
914
+ let IsGoNext = false;
915
+ if (Array.isArray(Value)) {
916
+ if (FindStore[Key] == null || !Array.isArray(FindStore[Key]))
917
+ FindStore[Key] = [];
918
+ IsGoNext = true;
919
+ }
920
+ else if (typeof Value == 'object') {
921
+ if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
922
+ FindStore[Key] = {};
923
+ IsGoNext = true;
924
+ }
925
+ if (IsGoNext)
926
+ this.$DeepSetObject(Value, FindStore[Key]);
927
+ else
928
+ FindStore[Key] = Value;
929
+ });
904
930
  }
905
931
  AddFileStore(FileStoreKey, Option) {
906
932
  Option ??= {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rugal.tu/vuemodel3",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/VueModel.d.ts CHANGED
@@ -152,6 +152,9 @@ type GetStoreOption<TStore = any> = {
152
152
  DefaultValue?: TStore;
153
153
  Clone?: boolean;
154
154
  };
155
+ type ClearStoreOption = {
156
+ DeepClear?: boolean;
157
+ };
155
158
  type EventArg_AddApi = ApiStoreValue;
156
159
  type EventArg_UpdateStore = {
157
160
  Path: string;
@@ -169,7 +172,6 @@ type AddFileStoreOption = {
169
172
  };
170
173
  export declare class ApiStore extends FuncBase {
171
174
  #private;
172
- protected $ApiStore: Record<string, ApiStoreValue>;
173
175
  constructor();
174
176
  get ApiDomain(): string;
175
177
  set ApiDomain(ApiDomain: string);
@@ -183,6 +185,7 @@ export declare class ApiStore extends FuncBase {
183
185
  };
184
186
  get Store(): StoreType;
185
187
  protected set Store(Store: StoreType);
188
+ get ApiStore(): any;
186
189
  get FileStore(): FileStoreType;
187
190
  WithAccessToken(AccessToken: string): this;
188
191
  WithRefreshToken(RefreshToken: string): this;
@@ -212,12 +215,12 @@ export declare class ApiStore extends FuncBase {
212
215
  AddStore<TStore = any>(StorePath: PathType, StoreData?: TStore): this;
213
216
  SetStore<TStore = any>(StorePath: PathType, StoreData: TStore): this;
214
217
  UpdateStore<TStore = any>(StorePath: PathType, StoreData: TStore): this;
215
- ClearStore(StorePath: PathType): this;
218
+ ClearStore(StorePath: PathType, Option?: boolean | ClearStoreOption): this;
216
219
  GetStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, Option?: GetStoreOption<TStore> | boolean): TStore;
217
220
  AddStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, StoreData?: TStore): this;
218
221
  SetStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, StoreData: TStore): this;
219
222
  UpdateStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, StoreData: TStore): this;
220
- ClearStoreFrom(SourceStore: any, StorePath: PathType): this;
223
+ ClearStoreFrom(SourceStore: any, StorePath?: PathType, Option?: boolean | ClearStoreOption): this;
221
224
  protected $RCS_GetStore(StorePath: string, FindStore: any, Option: {
222
225
  CreateIfNull: boolean;
223
226
  DefaultValue: object;
@@ -225,7 +228,8 @@ export declare class ApiStore extends FuncBase {
225
228
  protected $RCS_SetStore(StorePath: string, StoreData: any, FindStore: any, Option?: {
226
229
  IsDeepSet: boolean;
227
230
  }): any;
228
- protected $DeepSetObject(StorePath: string, SetData: Record<string, any>, FindStore: any): void;
231
+ protected $RCS_ClearStore(TargetStore: any, Option: ClearStoreOption): void;
232
+ protected $DeepSetObject(SetData: Record<string, any>, FindStore: any): void;
229
233
  AddFileStore(FileStoreKey: string, Option?: AddFileStoreOption): this;
230
234
  Files(FileStoreKey: string, WhereFunc?: (FileArg: FileItem) => boolean): File[];
231
235
  File(FileStoreKey: string, WhereFunc?: (FileArg: FileItem) => boolean): File;
package/src/VueModel.ts CHANGED
@@ -631,6 +631,9 @@ type GetStoreOption<TStore = any> = {
631
631
  DefaultValue?: TStore,
632
632
  Clone?: boolean,
633
633
  };
634
+ type ClearStoreOption = {
635
+ DeepClear?: boolean,
636
+ }
634
637
 
635
638
  type EventArg_AddApi = ApiStoreValue;
636
639
  type EventArg_UpdateStore = {
@@ -675,13 +678,9 @@ export class ApiStore extends FuncBase {
675
678
  };
676
679
  #Func_ConvertTo_FormData: ((ConvertData: object, Form: FormData) => FormData | Record<string, any>)[] = [];
677
680
  //#endregion
678
-
679
- //#region Protected Property
680
- protected $ApiStore: Record<string, ApiStoreValue> = {};
681
- //#endregion
682
681
  constructor() {
683
682
  super();
684
- this.SetStore('api', this.$ApiStore);
683
+ this.SetStore('api', {});
685
684
  }
686
685
 
687
686
  //#region Get/Set Property
@@ -705,6 +704,10 @@ export class ApiStore extends FuncBase {
705
704
  protected set Store(Store: StoreType) {
706
705
  this.#Store = Store;
707
706
  }
707
+ get ApiStore() {
708
+ return this.GetStore('api');
709
+ }
710
+
708
711
  get FileStore(): FileStoreType {
709
712
  return this.Store.FileStore;
710
713
  }
@@ -778,7 +781,7 @@ export class ApiStore extends FuncBase {
778
781
  ApiKey,
779
782
  ...ApiOption,
780
783
  };
781
- this.$ApiStore[ApiKey] = SetApi;
784
+ this.ApiStore[ApiKey] = SetApi;
782
785
  this.$EventTrigger(this.#EventName.AddApi, SetApi);
783
786
  }
784
787
  return this;
@@ -793,7 +796,7 @@ export class ApiStore extends FuncBase {
793
796
  }
794
797
  protected $BaseApiCall(ApiKey: string, Option: ApiCallOption, IsFormRequest: boolean) {
795
798
 
796
- let Api = this.$ApiStore[ApiKey];
799
+ let Api = this.ApiStore[ApiKey];
797
800
  if (Api == null)
798
801
  this.$Throw(`Api setting not found of "${ApiKey}"`);
799
802
 
@@ -957,8 +960,8 @@ export class ApiStore extends FuncBase {
957
960
  public UpdateStore<TStore = any>(StorePath: PathType, StoreData: TStore) {
958
961
  return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
959
962
  }
960
- public ClearStore(StorePath: PathType) {
961
- return this.ClearStoreFrom(this.Store, StorePath);
963
+ public ClearStore(StorePath: PathType, Option?: boolean | ClearStoreOption) {
964
+ return this.ClearStoreFrom(this.Store, StorePath, Option);
962
965
  }
963
966
 
964
967
  public GetStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, Option?: GetStoreOption<TStore> | boolean): TStore {
@@ -1005,44 +1008,41 @@ export class ApiStore extends FuncBase {
1005
1008
  return this;
1006
1009
  }
1007
1010
  public SetStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, StoreData: TStore) {
1008
- StorePath = this.ToJoin(StorePath);
1009
- this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
1011
+ if (StorePath != null)
1012
+ StorePath = this.ToJoin(StorePath);
1013
+
1014
+ this.$RCS_SetStore(StorePath as string, StoreData, SourceStore, {
1010
1015
  IsDeepSet: false,
1011
1016
  });
1012
1017
  this.$EventTrigger<EventArg_SetStore>(this.#EventName.SetStore, {
1013
- Path: StorePath,
1018
+ Path: StorePath as string,
1014
1019
  Data: StoreData,
1015
1020
  });
1016
1021
  return this;
1017
1022
  }
1018
1023
  public UpdateStoreFrom<TStore = any>(SourceStore: any, StorePath: PathType, StoreData: TStore) {
1019
- StorePath = this.ToJoin(StorePath);
1020
- this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
1024
+ if (StorePath != null)
1025
+ StorePath = this.ToJoin(StorePath);
1026
+
1027
+ this.$RCS_SetStore(StorePath as string, StoreData, SourceStore, {
1021
1028
  IsDeepSet: true,
1022
1029
  });
1023
1030
  this.$EventTrigger<EventArg_UpdateStore>(this.#EventName.UpdateStore, {
1024
- Path: StorePath,
1031
+ Path: StorePath as string,
1025
1032
  Data: StoreData,
1026
1033
  });
1027
1034
  return this;
1028
1035
  }
1029
- public ClearStoreFrom(SourceStore: any, StorePath: PathType) {
1030
- let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
1036
+ public ClearStoreFrom(SourceStore: any, StorePath?: PathType, Option?: boolean | ClearStoreOption) {
1037
+ Option ??= {};
1038
+ if (typeof Option === 'boolean')
1039
+ Option = { DeepClear: Option };
1040
+
1041
+ let TargetStore = StorePath == null ? SourceStore : this.GetStoreFrom(SourceStore, StorePath);
1031
1042
  if (TargetStore == null)
1032
1043
  return this;
1033
- let AllProperty = Object.getOwnPropertyNames(TargetStore);
1034
- for (let Key of AllProperty) {
1035
- if (Key.match(/^\$/g))
1036
- continue;
1037
- let Value = TargetStore[Key];
1038
- if (typeof (Value) == 'function')
1039
- continue;
1040
- if (Array.isArray(Value)) {
1041
- Value.splice(0, Value.length);;
1042
- continue;
1043
- }
1044
- TargetStore[Key] = null;
1045
- }
1044
+
1045
+ this.$RCS_ClearStore(TargetStore, Option);
1046
1046
  return this;
1047
1047
  }
1048
1048
  //#endregion
@@ -1077,6 +1077,11 @@ export class ApiStore extends FuncBase {
1077
1077
  protected $RCS_SetStore(StorePath: string, StoreData: any, FindStore: any, Option = {
1078
1078
  IsDeepSet: true,
1079
1079
  }): any {
1080
+ if (StorePath == null) {
1081
+ this.$DeepSetObject(StoreData, FindStore);
1082
+ return StoreData;
1083
+ }
1084
+
1080
1085
  StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
1081
1086
  if (StorePath.includes('.')) {
1082
1087
  let StorePaths = StorePath.split('.');
@@ -1089,39 +1094,72 @@ export class ApiStore extends FuncBase {
1089
1094
  return this.$RCS_SetStore(NextKey, StoreData, NextStore, Option);
1090
1095
  }
1091
1096
 
1092
- let IsAwaysSet = !Option.IsDeepSet ||
1097
+ let IsAwaysSet =
1098
+ StoreData == null ||
1099
+ !Option.IsDeepSet ||
1093
1100
  FindStore[StorePath] == null ||
1094
- StoreData == null || typeof StoreData != 'object';
1101
+ typeof StoreData != 'object';
1102
+
1095
1103
  if (IsAwaysSet) {
1096
1104
  FindStore[StorePath] = StoreData;
1097
1105
  return StoreData;
1098
1106
  }
1099
1107
 
1100
- this.$DeepSetObject(StorePath, StoreData, FindStore);
1101
- return StoreData;
1108
+ return this.$RCS_SetStore(null, StoreData, FindStore[StorePath])
1102
1109
  }
1103
- protected $DeepSetObject(StorePath: string, SetData: Record<string, any>, FindStore: any) {
1110
+ protected $RCS_ClearStore(TargetStore: any, Option: ClearStoreOption) {
1111
+ if (typeof TargetStore != 'object')
1112
+ return;
1113
+
1114
+ if (Array.isArray(TargetStore)) {
1115
+ TargetStore.length = 0;
1116
+ return;
1117
+ }
1118
+
1119
+ let AllProperty = Object.getOwnPropertyNames(TargetStore);
1120
+ for (let Key of AllProperty) {
1121
+ if (Key.match(/^\$/g))
1122
+ continue;
1123
+
1124
+ if (typeof TargetStore[Key] === 'function')
1125
+ continue;
1126
+ else if (Option.DeepClear && typeof TargetStore[Key] === 'object')
1127
+ this.$RCS_ClearStore(TargetStore[Key], Option);
1128
+ else
1129
+ TargetStore[Key] = null;
1130
+ }
1131
+ }
1132
+ protected $DeepSetObject(SetData: Record<string, any>, FindStore: any) {
1104
1133
  if (SetData == null) {
1105
- FindStore[StorePath] = SetData;
1134
+ this.ClearStoreFrom(FindStore);
1106
1135
  return;
1107
1136
  }
1108
1137
 
1109
- if (!Array.isArray(SetData)) {
1110
- this.ForEachObject(SetData, (Key, Value) => {
1111
- if (Array.isArray(Value) || typeof Value == 'object') {
1112
- this.$DeepSetObject(Key, Value, FindStore[StorePath]);
1113
- return;
1114
- }
1115
- if (FindStore[StorePath] == null)
1116
- FindStore[StorePath] = {};
1117
- FindStore[StorePath][Key] = Value;
1118
- });
1138
+ if (Array.isArray(SetData)) {
1139
+ if (!Array.isArray(FindStore))
1140
+ return;
1141
+ FindStore.length = 0;
1142
+ FindStore.push.apply(FindStore, SetData);
1119
1143
  return;
1120
1144
  }
1121
- if (!Array.isArray(FindStore[StorePath]))
1122
- FindStore[StorePath] = [];
1123
1145
 
1124
- FindStore[StorePath] = SetData.slice();
1146
+ this.ForEachObject(SetData, (Key, Value) => {
1147
+ let IsGoNext = false;
1148
+ if (Array.isArray(Value)) {
1149
+ if (FindStore[Key] == null || !Array.isArray(FindStore[Key]))
1150
+ FindStore[Key] = [];
1151
+ IsGoNext = true;
1152
+ }
1153
+ else if (typeof Value == 'object') {
1154
+ if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
1155
+ FindStore[Key] = {};
1156
+ IsGoNext = true;
1157
+ }
1158
+ if (IsGoNext)
1159
+ this.$DeepSetObject(Value, FindStore[Key]);
1160
+ else
1161
+ FindStore[Key] = Value;
1162
+ });
1125
1163
  }
1126
1164
  //#endregion
1127
1165
 
@@ -2150,6 +2188,7 @@ export class VueModel extends VueCommand {
2150
2188
  }
2151
2189
 
2152
2190
  const Model = new VueModel();
2191
+
2153
2192
  (window as any).Model = Model;
2154
2193
  export {
2155
2194
  Model,