@rugal.tu/vuemodel3 1.3.0 → 1.3.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.
@@ -740,8 +740,8 @@ export class ApiStore extends FuncBase {
740
740
  UpdateStore(StorePath, StoreData) {
741
741
  return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
742
742
  }
743
- ClearStore(StorePath) {
744
- return this.ClearStoreFrom(this.Store, StorePath);
743
+ ClearStore(StorePath, Option) {
744
+ return this.ClearStoreFrom(this.Store, StorePath, Option);
745
745
  }
746
746
  GetStoreFrom(SourceStore, StorePath, Option) {
747
747
  if (typeof Option == 'boolean')
@@ -781,7 +781,8 @@ export class ApiStore extends FuncBase {
781
781
  return this;
782
782
  }
783
783
  SetStoreFrom(SourceStore, StorePath, StoreData) {
784
- StorePath = this.ToJoin(StorePath);
784
+ if (StorePath != null)
785
+ StorePath = this.ToJoin(StorePath);
785
786
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
786
787
  IsDeepSet: false,
787
788
  });
@@ -792,7 +793,8 @@ export class ApiStore extends FuncBase {
792
793
  return this;
793
794
  }
794
795
  UpdateStoreFrom(SourceStore, StorePath, StoreData) {
795
- StorePath = this.ToJoin(StorePath);
796
+ if (StorePath != null)
797
+ StorePath = this.ToJoin(StorePath);
796
798
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
797
799
  IsDeepSet: true,
798
800
  });
@@ -802,24 +804,14 @@ export class ApiStore extends FuncBase {
802
804
  });
803
805
  return this;
804
806
  }
805
- ClearStoreFrom(SourceStore, StorePath) {
806
- let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
807
+ ClearStoreFrom(SourceStore, StorePath, Option) {
808
+ Option ??= {};
809
+ if (typeof Option === 'boolean')
810
+ Option = { DeepClear: Option };
811
+ let TargetStore = StorePath == null ? SourceStore : this.GetStoreFrom(SourceStore, StorePath);
807
812
  if (TargetStore == null)
808
813
  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
- }
814
+ this.$RCS_ClearStore(TargetStore, Option);
823
815
  return this;
824
816
  }
825
817
  $RCS_GetStore(StorePath, FindStore, Option) {
@@ -845,6 +837,10 @@ export class ApiStore extends FuncBase {
845
837
  $RCS_SetStore(StorePath, StoreData, FindStore, Option = {
846
838
  IsDeepSet: true,
847
839
  }) {
840
+ if (StorePath == null) {
841
+ this.$DeepSetObject(StoreData, FindStore);
842
+ return StoreData;
843
+ }
848
844
  StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
849
845
  if (StorePath.includes('.')) {
850
846
  let StorePaths = StorePath.split('.');
@@ -855,36 +851,64 @@ export class ApiStore extends FuncBase {
855
851
  let NextKey = StorePaths.join('.');
856
852
  return this.$RCS_SetStore(NextKey, StoreData, NextStore, Option);
857
853
  }
858
- let IsAwaysSet = !Option.IsDeepSet ||
854
+ let IsAwaysSet = StoreData == null ||
855
+ !Option.IsDeepSet ||
859
856
  FindStore[StorePath] == null ||
860
- StoreData == null || typeof StoreData != 'object';
857
+ typeof StoreData != 'object';
861
858
  if (IsAwaysSet) {
862
859
  FindStore[StorePath] = StoreData;
863
860
  return StoreData;
864
861
  }
865
- this.$DeepSetObject(StorePath, StoreData, FindStore);
866
- return StoreData;
862
+ return this.$RCS_SetStore(null, StoreData, FindStore[StorePath]);
863
+ }
864
+ $RCS_ClearStore(TargetStore, Option) {
865
+ if (typeof TargetStore != 'object')
866
+ return;
867
+ if (Array.isArray(TargetStore)) {
868
+ TargetStore.length = 0;
869
+ return;
870
+ }
871
+ let AllProperty = Object.getOwnPropertyNames(TargetStore);
872
+ for (let Key of AllProperty) {
873
+ if (Key.match(/^\$/g))
874
+ continue;
875
+ if (typeof TargetStore[Key] === 'function')
876
+ continue;
877
+ else if (Option.DeepClear && typeof TargetStore[Key] === 'object')
878
+ this.$RCS_ClearStore(TargetStore[Key], Option);
879
+ else
880
+ TargetStore[Key] = null;
881
+ }
867
882
  }
868
- $DeepSetObject(StorePath, SetData, FindStore) {
883
+ $DeepSetObject(SetData, FindStore) {
869
884
  if (SetData == null) {
870
- FindStore[StorePath] = SetData;
885
+ this.ClearStoreFrom(FindStore);
871
886
  return;
872
887
  }
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
- });
888
+ if (Array.isArray(SetData)) {
889
+ if (!Array.isArray(FindStore))
890
+ return;
891
+ FindStore.length = 0;
892
+ FindStore.push.apply(FindStore, SetData);
883
893
  return;
884
894
  }
885
- if (!Array.isArray(FindStore[StorePath]))
886
- FindStore[StorePath] = [];
887
- FindStore[StorePath] = SetData.slice();
895
+ this.ForEachObject(SetData, (Key, Value) => {
896
+ let IsGoNext = false;
897
+ if (Array.isArray(Value)) {
898
+ if (FindStore[Key] == null || !Array.isArray(FindStore[Key]))
899
+ FindStore[Key] = [];
900
+ IsGoNext = true;
901
+ }
902
+ else if (typeof Value == 'object') {
903
+ if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
904
+ FindStore[Key] = {};
905
+ IsGoNext = true;
906
+ }
907
+ if (IsGoNext)
908
+ this.$DeepSetObject(Value, FindStore[Key]);
909
+ else
910
+ FindStore[Key] = Value;
911
+ });
888
912
  }
889
913
  AddFileStore(FileStoreKey, Option) {
890
914
  Option ??= {};
@@ -1343,7 +1367,7 @@ export class VueCommand extends VueStore {
1343
1367
  },
1344
1368
  'using': (Info, Option) => {
1345
1369
  if (typeof (Info.StoreValue) === 'function') {
1346
- Info.StoreValue(Info.DomPaths);
1370
+ Info.StoreValue(Info.DomPaths, Info.Nodes);
1347
1371
  }
1348
1372
  }
1349
1373
  };
@@ -756,8 +756,8 @@
756
756
  UpdateStore(StorePath, StoreData) {
757
757
  return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
758
758
  }
759
- ClearStore(StorePath) {
760
- return this.ClearStoreFrom(this.Store, StorePath);
759
+ ClearStore(StorePath, Option) {
760
+ return this.ClearStoreFrom(this.Store, StorePath, Option);
761
761
  }
762
762
  GetStoreFrom(SourceStore, StorePath, Option) {
763
763
  if (typeof Option == 'boolean')
@@ -797,7 +797,8 @@
797
797
  return this;
798
798
  }
799
799
  SetStoreFrom(SourceStore, StorePath, StoreData) {
800
- StorePath = this.ToJoin(StorePath);
800
+ if (StorePath != null)
801
+ StorePath = this.ToJoin(StorePath);
801
802
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
802
803
  IsDeepSet: false,
803
804
  });
@@ -808,7 +809,8 @@
808
809
  return this;
809
810
  }
810
811
  UpdateStoreFrom(SourceStore, StorePath, StoreData) {
811
- StorePath = this.ToJoin(StorePath);
812
+ if (StorePath != null)
813
+ StorePath = this.ToJoin(StorePath);
812
814
  this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
813
815
  IsDeepSet: true,
814
816
  });
@@ -818,24 +820,14 @@
818
820
  });
819
821
  return this;
820
822
  }
821
- ClearStoreFrom(SourceStore, StorePath) {
822
- let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
823
+ ClearStoreFrom(SourceStore, StorePath, Option) {
824
+ Option ??= {};
825
+ if (typeof Option === 'boolean')
826
+ Option = { DeepClear: Option };
827
+ let TargetStore = StorePath == null ? SourceStore : this.GetStoreFrom(SourceStore, StorePath);
823
828
  if (TargetStore == null)
824
829
  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
- }
830
+ this.$RCS_ClearStore(TargetStore, Option);
839
831
  return this;
840
832
  }
841
833
  $RCS_GetStore(StorePath, FindStore, Option) {
@@ -861,6 +853,10 @@
861
853
  $RCS_SetStore(StorePath, StoreData, FindStore, Option = {
862
854
  IsDeepSet: true,
863
855
  }) {
856
+ if (StorePath == null) {
857
+ this.$DeepSetObject(StoreData, FindStore);
858
+ return StoreData;
859
+ }
864
860
  StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
865
861
  if (StorePath.includes('.')) {
866
862
  let StorePaths = StorePath.split('.');
@@ -871,36 +867,64 @@
871
867
  let NextKey = StorePaths.join('.');
872
868
  return this.$RCS_SetStore(NextKey, StoreData, NextStore, Option);
873
869
  }
874
- let IsAwaysSet = !Option.IsDeepSet ||
870
+ let IsAwaysSet = StoreData == null ||
871
+ !Option.IsDeepSet ||
875
872
  FindStore[StorePath] == null ||
876
- StoreData == null || typeof StoreData != 'object';
873
+ typeof StoreData != 'object';
877
874
  if (IsAwaysSet) {
878
875
  FindStore[StorePath] = StoreData;
879
876
  return StoreData;
880
877
  }
881
- this.$DeepSetObject(StorePath, StoreData, FindStore);
882
- return StoreData;
878
+ return this.$RCS_SetStore(null, StoreData, FindStore[StorePath]);
879
+ }
880
+ $RCS_ClearStore(TargetStore, Option) {
881
+ if (typeof TargetStore != 'object')
882
+ return;
883
+ if (Array.isArray(TargetStore)) {
884
+ TargetStore.length = 0;
885
+ return;
886
+ }
887
+ let AllProperty = Object.getOwnPropertyNames(TargetStore);
888
+ for (let Key of AllProperty) {
889
+ if (Key.match(/^\$/g))
890
+ continue;
891
+ if (typeof TargetStore[Key] === 'function')
892
+ continue;
893
+ else if (Option.DeepClear && typeof TargetStore[Key] === 'object')
894
+ this.$RCS_ClearStore(TargetStore[Key], Option);
895
+ else
896
+ TargetStore[Key] = null;
897
+ }
883
898
  }
884
- $DeepSetObject(StorePath, SetData, FindStore) {
899
+ $DeepSetObject(SetData, FindStore) {
885
900
  if (SetData == null) {
886
- FindStore[StorePath] = SetData;
901
+ this.ClearStoreFrom(FindStore);
887
902
  return;
888
903
  }
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
- });
904
+ if (Array.isArray(SetData)) {
905
+ if (!Array.isArray(FindStore))
906
+ return;
907
+ FindStore.length = 0;
908
+ FindStore.push.apply(FindStore, SetData);
899
909
  return;
900
910
  }
901
- if (!Array.isArray(FindStore[StorePath]))
902
- FindStore[StorePath] = [];
903
- FindStore[StorePath] = SetData.slice();
911
+ this.ForEachObject(SetData, (Key, Value) => {
912
+ let IsGoNext = false;
913
+ if (Array.isArray(Value)) {
914
+ if (FindStore[Key] == null || !Array.isArray(FindStore[Key]))
915
+ FindStore[Key] = [];
916
+ IsGoNext = true;
917
+ }
918
+ else if (typeof Value == 'object') {
919
+ if (FindStore[Key] == null || typeof FindStore[Key] != 'object')
920
+ FindStore[Key] = {};
921
+ IsGoNext = true;
922
+ }
923
+ if (IsGoNext)
924
+ this.$DeepSetObject(Value, FindStore[Key]);
925
+ else
926
+ FindStore[Key] = Value;
927
+ });
904
928
  }
905
929
  AddFileStore(FileStoreKey, Option) {
906
930
  Option ??= {};
@@ -1361,7 +1385,7 @@
1361
1385
  },
1362
1386
  'using': (Info, Option) => {
1363
1387
  if (typeof (Info.StoreValue) === 'function') {
1364
- Info.StoreValue(Info.DomPaths);
1388
+ Info.StoreValue(Info.DomPaths, Info.Nodes);
1365
1389
  }
1366
1390
  }
1367
1391
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rugal.tu/vuemodel3",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
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;
@@ -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;
@@ -263,6 +267,7 @@ export declare class VueStore extends ApiStore {
263
267
  ForceUpdate(): this;
264
268
  Refs(RefName: PathType): any;
265
269
  }
270
+ type UsingFunctionType = ((Paths: PathType, Node?: QueryNode[]) => void);
266
271
  type CommandOption = {
267
272
  CommandKey?: string;
268
273
  Target: PathType | Function;
@@ -285,7 +290,7 @@ type TreeSetType = {
285
290
  'v-on-mounted'?: '' | PathType | Function | TreeSetOption;
286
291
  'v-on-unmounted'?: '' | PathType | Function | TreeSetOption;
287
292
  'watch'?: '' | WatchCallback;
288
- 'using'?: '' | ((Paths: PathType) => void);
293
+ 'using'?: '' | UsingFunctionType;
289
294
  [VModelCmd: `v-model:${string}`]: '' | PathType | TreeSetOption;
290
295
  [VForCmd: `v-for(${string})`]: '' | PathType | Function | TreeSetOption;
291
296
  [VBindCmd: `v-bind:${string}`]: '' | PathType | Function | TreeSetOption;
@@ -295,7 +300,7 @@ type TreeSetType = {
295
300
  [VOnMountedCmd: `v-on-mounted(${string})`]: '' | PathType | Function | TreeSetOption;
296
301
  [VOnUnMountedCmd: `v-on-unmounted(${string})`]: '' | PathType | Function | TreeSetOption;
297
302
  [FuncCmd: `func:${string}`]: '' | Function;
298
- [DomName: `:${string}`]: '' | ((Paths: PathType) => void) | TreeSetType;
303
+ [DomName: `:${string}`]: '' | UsingFunctionType | TreeSetType;
299
304
  };
300
305
  type TreeSetOption = CommandOption;
301
306
  type AddCommandOption = PathType | Function | CommandOption;
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 = {
@@ -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
 
@@ -1393,6 +1431,7 @@ export class VueStore extends ApiStore {
1393
1431
  }
1394
1432
 
1395
1433
  //#region VueCommand Data Type
1434
+ type UsingFunctionType = ((Paths: PathType, Node?: QueryNode[]) => void);
1396
1435
  type CommandOption = {
1397
1436
  CommandKey?: string,
1398
1437
  Target: PathType | Function,
@@ -1417,7 +1456,7 @@ type TreeSetType = {
1417
1456
  'v-on-unmounted'?: '' | PathType | Function | TreeSetOption,
1418
1457
 
1419
1458
  'watch'?: '' | WatchCallback,
1420
- 'using'?: '' | ((Paths: PathType) => void),
1459
+ 'using'?: '' | UsingFunctionType,
1421
1460
 
1422
1461
  [VModelCmd: `v-model:${string}`]: '' | PathType | TreeSetOption,
1423
1462
  [VForCmd: `v-for(${string})`]: '' | PathType | Function | TreeSetOption,
@@ -1428,7 +1467,7 @@ type TreeSetType = {
1428
1467
  [VOnMountedCmd: `v-on-mounted(${string})`]: '' | PathType | Function | TreeSetOption,
1429
1468
  [VOnUnMountedCmd: `v-on-unmounted(${string})`]: '' | PathType | Function | TreeSetOption,
1430
1469
  [FuncCmd: `func:${string}`]: '' | Function,
1431
- [DomName: `:${string}`]: '' | ((Paths: PathType) => void) | TreeSetType,
1470
+ [DomName: `:${string}`]: '' | UsingFunctionType | TreeSetType,
1432
1471
  };
1433
1472
  type TreeSetOption = CommandOption;
1434
1473
  type AddCommandOption = PathType | Function | CommandOption;
@@ -1724,7 +1763,7 @@ export class VueCommand extends VueStore {
1724
1763
  },
1725
1764
  'using': (Info, Option) => {
1726
1765
  if (typeof (Info.StoreValue) === 'function') {
1727
- Info.StoreValue(Info.DomPaths);
1766
+ Info.StoreValue(Info.DomPaths, Info.Nodes);
1728
1767
  }
1729
1768
  }
1730
1769
  }
@@ -2149,6 +2188,7 @@ export class VueModel extends VueCommand {
2149
2188
  }
2150
2189
 
2151
2190
  const Model = new VueModel();
2191
+
2152
2192
  (window as any).Model = Model;
2153
2193
  export {
2154
2194
  Model,