@rugal.tu/vuemodel3 1.5.8 → 1.5.10
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/VueModel.esm.js +92 -6
- package/dist/VueModel.esm.min.js +1 -1
- package/dist/VueModel.esm.min.js.map +2 -2
- package/package.json +1 -1
- package/src/VueModel.d.ts +8 -6
- package/src/VueModel.ts +36 -15
- package/dist/VueModel.umd.js +0 -1984
- package/dist/VueModel.umd.min.js +0 -2
- package/dist/VueModel.umd.min.js.map +0 -7
- package/src/esm/VueModel.js +0 -1963
- package/src/esm/VueModel.js.map +0 -1
- package/src/umd/VueModel.js +0 -1984
- package/src/umd/VueModel.js.map +0 -1
package/dist/VueModel.esm.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
//#endregion
|
|
2
|
+
//#region FuncBase
|
|
1
3
|
export class FuncBase {
|
|
4
|
+
//#region Protected Property
|
|
2
5
|
$NavigateToFunc;
|
|
3
6
|
$DefaultDateJoinChar;
|
|
7
|
+
//#endregion
|
|
4
8
|
constructor() {
|
|
5
9
|
this.$NavigateToFunc = null;
|
|
6
10
|
this.WithDateTextJoinChar('/');
|
|
7
11
|
}
|
|
12
|
+
//#region Public With Method
|
|
8
13
|
WithNavigateTo(NavigateToFunc) {
|
|
9
14
|
this.$NavigateToFunc = NavigateToFunc;
|
|
10
15
|
return this;
|
|
@@ -13,6 +18,8 @@ export class FuncBase {
|
|
|
13
18
|
this.$DefaultDateJoinChar = JoinChar;
|
|
14
19
|
return this;
|
|
15
20
|
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region Public Method
|
|
16
23
|
GenerateId() {
|
|
17
24
|
let NewId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => {
|
|
18
25
|
let RandomValue = crypto.getRandomValues(new Uint8Array(1))[0] & 15;
|
|
@@ -149,6 +156,8 @@ export class FuncBase {
|
|
|
149
156
|
};
|
|
150
157
|
return Result;
|
|
151
158
|
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region Process
|
|
152
161
|
ConvertTo_UrlQuery(Param) {
|
|
153
162
|
if (typeof Param === 'string')
|
|
154
163
|
return Param;
|
|
@@ -199,6 +208,8 @@ export class FuncBase {
|
|
|
199
208
|
}
|
|
200
209
|
return false;
|
|
201
210
|
}
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region Console And Throw
|
|
202
213
|
$Throw(Message) {
|
|
203
214
|
throw new Error(Message);
|
|
204
215
|
}
|
|
@@ -212,6 +223,7 @@ export class QueryNode extends FuncBase {
|
|
|
212
223
|
DomName = null;
|
|
213
224
|
Parent = null;
|
|
214
225
|
Children = [];
|
|
226
|
+
//DomChildren:
|
|
215
227
|
ElementDeep = 0;
|
|
216
228
|
NodeDeep = 0;
|
|
217
229
|
constructor(Dom) {
|
|
@@ -220,9 +232,11 @@ export class QueryNode extends FuncBase {
|
|
|
220
232
|
this.NodeId = this.GenerateIdReplace('');
|
|
221
233
|
}
|
|
222
234
|
Query(DomName, Option) {
|
|
235
|
+
Option ??= { Mode: 'Multi' };
|
|
223
236
|
return this.$RCS_QueryChildrens(this, DomName, Option);
|
|
224
237
|
}
|
|
225
238
|
QueryCss(Selector, Option) {
|
|
239
|
+
Option ??= { Mode: 'Multi' };
|
|
226
240
|
return this.$RCS_QueryCssChildrens(this, Selector, Option);
|
|
227
241
|
}
|
|
228
242
|
Selector(Selector) {
|
|
@@ -242,6 +256,20 @@ export class QueryNode extends FuncBase {
|
|
|
242
256
|
if (Array.isArray(DomName)) {
|
|
243
257
|
let Names = [...DomName];
|
|
244
258
|
let FirstName = Names.shift();
|
|
259
|
+
const pathRegex = FirstName.match(/^(?<key>[^:]+):(?<name>.+)$/);
|
|
260
|
+
if (pathRegex) {
|
|
261
|
+
const key = pathRegex.groups.key;
|
|
262
|
+
const name = pathRegex.groups.name;
|
|
263
|
+
switch (key) {
|
|
264
|
+
case 'tag':
|
|
265
|
+
//TargetNode.Dom.
|
|
266
|
+
//Todo:
|
|
267
|
+
break;
|
|
268
|
+
default:
|
|
269
|
+
FirstName = name;
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
245
273
|
if (NodeItem.DomName == FirstName) {
|
|
246
274
|
if (Names.length == 1)
|
|
247
275
|
Names = Names[0];
|
|
@@ -530,7 +558,9 @@ export class FileItem {
|
|
|
530
558
|
};
|
|
531
559
|
}
|
|
532
560
|
}
|
|
561
|
+
//#endregion
|
|
533
562
|
export class ApiStore extends FuncBase {
|
|
563
|
+
//#region Private Property
|
|
534
564
|
#ApiDomain = null;
|
|
535
565
|
#RootRoute = null;
|
|
536
566
|
#AccessToken = null;
|
|
@@ -553,10 +583,12 @@ export class ApiStore extends FuncBase {
|
|
|
553
583
|
FileStore: {},
|
|
554
584
|
};
|
|
555
585
|
#Func_ConvertTo_FormData = [];
|
|
586
|
+
//#endregion
|
|
556
587
|
constructor() {
|
|
557
588
|
super();
|
|
558
589
|
this.SetStore('api', {});
|
|
559
590
|
}
|
|
591
|
+
//#region Get/Set Property
|
|
560
592
|
get ApiDomain() {
|
|
561
593
|
if (this.#ApiDomain == null)
|
|
562
594
|
return null;
|
|
@@ -583,6 +615,8 @@ export class ApiStore extends FuncBase {
|
|
|
583
615
|
get FileStore() {
|
|
584
616
|
return this.Store.FileStore;
|
|
585
617
|
}
|
|
618
|
+
//#endregion
|
|
619
|
+
//#region Public With Method
|
|
586
620
|
WithAccessToken(AccessToken) {
|
|
587
621
|
this.#AccessToken = AccessToken;
|
|
588
622
|
return this;
|
|
@@ -619,6 +653,8 @@ export class ApiStore extends FuncBase {
|
|
|
619
653
|
this.#ExportSuccessStore = ExportSuccessStoreFunc;
|
|
620
654
|
return this;
|
|
621
655
|
}
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region ConvertTo Method
|
|
622
658
|
WithConvertTo_FormParam(ConvertToFunc) {
|
|
623
659
|
this.#Func_ConvertTo_FormData.push(ConvertToFunc);
|
|
624
660
|
return this;
|
|
@@ -635,6 +671,8 @@ export class ApiStore extends FuncBase {
|
|
|
635
671
|
ApiDomainUrl = `${ApiDomainUrl}?${this.ConvertTo_UrlQuery(Param)}`;
|
|
636
672
|
return ApiDomainUrl;
|
|
637
673
|
}
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region Api Method
|
|
638
676
|
AddApi(AddApi) {
|
|
639
677
|
for (let ApiKey in AddApi) {
|
|
640
678
|
let ApiOption = AddApi[ApiKey];
|
|
@@ -747,6 +785,8 @@ export class ApiStore extends FuncBase {
|
|
|
747
785
|
}
|
|
748
786
|
return FetchRequest;
|
|
749
787
|
}
|
|
788
|
+
//#endregion
|
|
789
|
+
//#region Api Sub/Pub Method
|
|
750
790
|
AddSubApi(ApiKey, Option) {
|
|
751
791
|
if (typeof Option === 'function')
|
|
752
792
|
Option = {
|
|
@@ -778,6 +818,8 @@ export class ApiStore extends FuncBase {
|
|
|
778
818
|
}
|
|
779
819
|
return this;
|
|
780
820
|
}
|
|
821
|
+
//#endregion
|
|
822
|
+
//#region Default Use Method
|
|
781
823
|
UseFormJsonBody(JsonBodyKey = 'Body') {
|
|
782
824
|
this.WithConvertTo_FormParam((FormDataBody, Form) => {
|
|
783
825
|
let ConvertParam = {};
|
|
@@ -786,6 +828,8 @@ export class ApiStore extends FuncBase {
|
|
|
786
828
|
});
|
|
787
829
|
return this;
|
|
788
830
|
}
|
|
831
|
+
//#endregion
|
|
832
|
+
//#region Public Event Add
|
|
789
833
|
EventAdd_AddApi(EventFunc) {
|
|
790
834
|
this.$EventAdd(this.#EventName.AddApi, EventFunc);
|
|
791
835
|
return this;
|
|
@@ -802,6 +846,8 @@ export class ApiStore extends FuncBase {
|
|
|
802
846
|
this.$EventAdd(this.#EventName.SetStore, EventFunc);
|
|
803
847
|
return this;
|
|
804
848
|
}
|
|
849
|
+
//#endregion
|
|
850
|
+
//#region Protected Event Process
|
|
805
851
|
$EventAdd(EventName, OnFunc) {
|
|
806
852
|
if (EventName in this.#OnEventFunc == false)
|
|
807
853
|
this.#OnEventFunc[EventName] = [];
|
|
@@ -814,6 +860,9 @@ export class ApiStore extends FuncBase {
|
|
|
814
860
|
for (let Item of EventFuncs)
|
|
815
861
|
Item(EventArg);
|
|
816
862
|
}
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region Store Control
|
|
865
|
+
//#region Public Data Store Contorl
|
|
817
866
|
GetStore(StorePath, Option) {
|
|
818
867
|
return this.GetStoreFrom(this.Store, StorePath, Option);
|
|
819
868
|
}
|
|
@@ -900,6 +949,8 @@ export class ApiStore extends FuncBase {
|
|
|
900
949
|
this.$RCS_ClearStore(TargetStore, Option);
|
|
901
950
|
return this;
|
|
902
951
|
}
|
|
952
|
+
//#endregion
|
|
953
|
+
//#region Protected Data Store Process
|
|
903
954
|
$RCS_GetStore(StorePath, FindStore, Option) {
|
|
904
955
|
if (FindStore == null)
|
|
905
956
|
return null;
|
|
@@ -996,6 +1047,8 @@ export class ApiStore extends FuncBase {
|
|
|
996
1047
|
FindStore[Key] = Value;
|
|
997
1048
|
});
|
|
998
1049
|
}
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region File Store
|
|
999
1052
|
AddFileStore(FileStoreKey, Option) {
|
|
1000
1053
|
Option ??= {};
|
|
1001
1054
|
if (this.FileStore[FileStoreKey] == null) {
|
|
@@ -1077,6 +1130,9 @@ export class ApiStore extends FuncBase {
|
|
|
1077
1130
|
}
|
|
1078
1131
|
return this;
|
|
1079
1132
|
}
|
|
1133
|
+
//#endregion
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region Protected Process
|
|
1080
1136
|
$ProcessApiReturn(ApiResponse) {
|
|
1081
1137
|
let GetContentType = ApiResponse.headers.get("content-type");
|
|
1082
1138
|
if (GetContentType.includes('application/json')) {
|
|
@@ -1087,11 +1143,15 @@ export class ApiStore extends FuncBase {
|
|
|
1087
1143
|
}
|
|
1088
1144
|
return new Promise(reslove => { reslove(ApiResponse); });
|
|
1089
1145
|
}
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region Override Method
|
|
1090
1148
|
NavigateToRoot() {
|
|
1091
1149
|
let RootUrl = this.#RootRoute ?? '/';
|
|
1092
1150
|
super.$BaseNavigateTo(RootUrl);
|
|
1093
1151
|
return this;
|
|
1094
1152
|
}
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region Protected ConvertTo
|
|
1095
1155
|
$ConvertTo_FormData(ConvertFormData, Form) {
|
|
1096
1156
|
Form ??= new FormData();
|
|
1097
1157
|
if (ConvertFormData == null)
|
|
@@ -1157,6 +1217,7 @@ export class VueStore extends ApiStore {
|
|
|
1157
1217
|
super();
|
|
1158
1218
|
this.#Setup();
|
|
1159
1219
|
}
|
|
1220
|
+
//#region Private Setup
|
|
1160
1221
|
#Setup() {
|
|
1161
1222
|
this
|
|
1162
1223
|
.EventAdd_AddApi(Arg => {
|
|
@@ -1176,6 +1237,8 @@ export class VueStore extends ApiStore {
|
|
|
1176
1237
|
this.UpdateStore([this.$CoreStore, 'IsMounted'], true);
|
|
1177
1238
|
});
|
|
1178
1239
|
}
|
|
1240
|
+
//#endregion
|
|
1241
|
+
//#region Get/Set Property
|
|
1179
1242
|
get Store() {
|
|
1180
1243
|
if (this.$VueProxy != null)
|
|
1181
1244
|
return this.$VueProxy;
|
|
@@ -1184,6 +1247,8 @@ export class VueStore extends ApiStore {
|
|
|
1184
1247
|
set Store(Store) {
|
|
1185
1248
|
super.Store = Store;
|
|
1186
1249
|
}
|
|
1250
|
+
//#endregion
|
|
1251
|
+
//#region Public With Method
|
|
1187
1252
|
WithVueOption(VueOption = {}) {
|
|
1188
1253
|
this.$VueOption = this.DeepObjectExtend(this.$VueOption, VueOption);
|
|
1189
1254
|
return this;
|
|
@@ -1209,6 +1274,8 @@ export class VueStore extends ApiStore {
|
|
|
1209
1274
|
});
|
|
1210
1275
|
return this;
|
|
1211
1276
|
}
|
|
1277
|
+
//#endregion
|
|
1278
|
+
//#region Public Method
|
|
1212
1279
|
ForceUpdate() {
|
|
1213
1280
|
this.$VueProxy?.$forceUpdate();
|
|
1214
1281
|
return this;
|
|
@@ -1219,6 +1286,7 @@ export class VueStore extends ApiStore {
|
|
|
1219
1286
|
return this.$VueProxy.$refs[Model.ToJoin(RefName)];
|
|
1220
1287
|
}
|
|
1221
1288
|
}
|
|
1289
|
+
//#endregion
|
|
1222
1290
|
export class VueCommand extends VueStore {
|
|
1223
1291
|
$IsInited = false;
|
|
1224
1292
|
$CommandMap;
|
|
@@ -1227,11 +1295,14 @@ export class VueCommand extends VueStore {
|
|
|
1227
1295
|
super();
|
|
1228
1296
|
this.$SetupCommandMap();
|
|
1229
1297
|
}
|
|
1298
|
+
//#region With Method
|
|
1230
1299
|
WithQueryDomName(QueryDomName) {
|
|
1231
1300
|
this.$QueryDomName = QueryDomName;
|
|
1232
1301
|
Queryer.WithDomName(this.$QueryDomName);
|
|
1233
1302
|
return this;
|
|
1234
1303
|
}
|
|
1304
|
+
//#endregion
|
|
1305
|
+
//#region Path Command
|
|
1235
1306
|
AddV_Text(DomName, Option) {
|
|
1236
1307
|
let SetOption = this.$ConvertCommandOption(DomName, Option);
|
|
1237
1308
|
if (typeof SetOption.Target != 'function') {
|
|
@@ -1260,6 +1331,8 @@ export class VueCommand extends VueStore {
|
|
|
1260
1331
|
this.$AddCommand(DomName, `v-slot`, SetOption);
|
|
1261
1332
|
return this;
|
|
1262
1333
|
}
|
|
1334
|
+
//#endregion
|
|
1335
|
+
//#region Path/Function Command
|
|
1263
1336
|
AddV_For(DomName, Option, ForKey) {
|
|
1264
1337
|
let SetOption = this.$ConvertCommandOption(DomName, Option);
|
|
1265
1338
|
if (ForKey) {
|
|
@@ -1313,6 +1386,8 @@ export class VueCommand extends VueStore {
|
|
|
1313
1386
|
this.$AddCommand(DomName, `v-on`, SetOption);
|
|
1314
1387
|
return this;
|
|
1315
1388
|
}
|
|
1389
|
+
//#endregion
|
|
1390
|
+
//#region Customer Command
|
|
1316
1391
|
Watch(WatchPath, Callback, Option = {}) {
|
|
1317
1392
|
let Handle;
|
|
1318
1393
|
if (typeof WatchPath == 'function')
|
|
@@ -1680,6 +1755,8 @@ export class VueCommand extends VueStore {
|
|
|
1680
1755
|
}
|
|
1681
1756
|
};
|
|
1682
1757
|
}
|
|
1758
|
+
//#endregion
|
|
1759
|
+
//#region Property Method
|
|
1683
1760
|
AddV_Property(PropertyPath, Option) {
|
|
1684
1761
|
return this.AddV_PropertyFrom(this.Store, PropertyPath, Option);
|
|
1685
1762
|
}
|
|
@@ -1755,6 +1832,8 @@ export class VueCommand extends VueStore {
|
|
|
1755
1832
|
SetProperty[PropertyKey] = OriginalValue;
|
|
1756
1833
|
return SetProperty;
|
|
1757
1834
|
}
|
|
1835
|
+
//#endregion
|
|
1836
|
+
//#region Protected Process
|
|
1758
1837
|
$ConvertCommandOption(DomName, Option, Args) {
|
|
1759
1838
|
let Result;
|
|
1760
1839
|
if (Option == null || Option == '.') {
|
|
@@ -1832,15 +1911,17 @@ export class VueCommand extends VueStore {
|
|
|
1832
1911
|
}
|
|
1833
1912
|
Dom.setAttribute(AttrName, AttrValue);
|
|
1834
1913
|
}
|
|
1914
|
+
//#region Function Control
|
|
1835
1915
|
$RandomFuncName(BaseFuncName) {
|
|
1836
1916
|
return `${BaseFuncName}${this.GenerateIdReplace('')}`.replace(/[-:.]/g, '_');
|
|
1837
1917
|
}
|
|
1838
|
-
$GenerateEventFunction(
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1918
|
+
$GenerateEventFunction(domName, eventFunc, command) {
|
|
1919
|
+
const funcName = this.$RandomFuncName(`${command}_`);
|
|
1920
|
+
domName = this.Paths(domName);
|
|
1921
|
+
const fullFuncPath = ['event', ...domName, funcName]
|
|
1922
|
+
.filter(item => item != null && item != '');
|
|
1923
|
+
this.AddV_Function(fullFuncPath, eventFunc);
|
|
1924
|
+
return this.ToJoin(fullFuncPath);
|
|
1844
1925
|
}
|
|
1845
1926
|
}
|
|
1846
1927
|
export class VueModel extends VueCommand {
|
|
@@ -1855,6 +1936,7 @@ export class VueModel extends VueCommand {
|
|
|
1855
1936
|
this.WithVueWarn(false);
|
|
1856
1937
|
this.WithLifeCycleDirective();
|
|
1857
1938
|
}
|
|
1939
|
+
//#region With Method
|
|
1858
1940
|
WithMountId(MountId) {
|
|
1859
1941
|
this.$MountId = MountId;
|
|
1860
1942
|
return this;
|
|
@@ -1893,6 +1975,8 @@ export class VueModel extends VueCommand {
|
|
|
1893
1975
|
}
|
|
1894
1976
|
});
|
|
1895
1977
|
}
|
|
1978
|
+
//#endregion
|
|
1979
|
+
//#region Public Method
|
|
1896
1980
|
Init() {
|
|
1897
1981
|
if (this.$IsInited)
|
|
1898
1982
|
return this;
|
|
@@ -1926,6 +2010,8 @@ export class VueModel extends VueCommand {
|
|
|
1926
2010
|
this.$VueApp.directive;
|
|
1927
2011
|
return this;
|
|
1928
2012
|
}
|
|
2013
|
+
//#endregion
|
|
2014
|
+
//#region Customer Vue Command
|
|
1929
2015
|
AddV_OnMounted(DomName, Option, Args) {
|
|
1930
2016
|
let SetOption = this.$ConvertCommandOption(DomName, Option);
|
|
1931
2017
|
if (Args) {
|
package/dist/VueModel.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export class FuncBase{$NavigateToFunc;$DefaultDateJoinChar;constructor(){this.$NavigateToFunc=null;this.WithDateTextJoinChar("/")}WithNavigateTo(n){return this.$NavigateToFunc=n,this}WithDateTextJoinChar(n){return this.$DefaultDateJoinChar=n,this}GenerateId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=crypto.getRandomValues(new Uint8Array(1))[0]&15,i=n==="x"?t:t&3|8;return i.toString(16)})}GenerateIdReplace(n){return this.GenerateId().replaceAll("-",n)}GenerateUrl(n,t=null){let i=this.Paths(n);(i==null||i.length==0||i[0].length==0)&&this.$Throw("Url can not be null or empty");i=i.map(n=>n.replace(/\/+$/g,"").replace(/^\/+/g,"/"));let r=this.ToJoin(i,"/");return(r==null||r=="")&&(r="/"),t!=null&&(t=this.ConvertTo_UrlQuery(t),r+=`?${t}`),r}$BaseNavigateTo(n){this.$NavigateToFunc?this.$NavigateToFunc(n):window.location.href=n}NavigateToRoot(){return this.$BaseNavigateTo("/"),this}NavigateTo(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateTo(i),this}$BaseNavigateBlank(n){let t=document.createElement("a");t.href=n;t.target="_blank";t.rel="noopener noreferrer";t.click()}NavigateBlank(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateBlank(i),this}ForEachObject(n,t){for(let i of Object.getOwnPropertyNames(n))if(!i.match(/^$/g)){let r=n[i];t!=null&&t.call(this,i,r)}}DeepObjectExtend(n,t,i=10){if(i==0)return{...n,...t};let r=Object.keys(t);for(let u=0;u<r.length;u++){let f=r[u];if(f in n)if(typeof t[f]!="object")n[f]=t[f];else{let r={...this.DeepObjectExtend(n[f],t[f],i-1)};n[f]=r}else n[f]=t[f]}return n}ToDateInfo(n){n??=new Date;return this.$CreateDateInfo(n)}ToDateText(n,t){n=this.$CreateDateInfo(n);t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd`;let i=t.Format;return i=i.replaceAll("yyyy",n.Year.toString().padStart(4,"0")),i=i.replaceAll("MM",n.Month.toString().padStart(2,"0")),i=i.replaceAll("dd",n.Day.toString().padStart(2,"0")),t.Format=i,i}ToDateTimeText(n,t){t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd HH:mm:ss`;t={...t};n=this.$CreateDateInfo(n);this.ToDateText(n,t);let i=t.Format;return i=i.replaceAll("HH",n.Hour.toString().padStart(2,"0")),i=i.replaceAll("mm",n.Minute.toString().padStart(2,"0")),i.replaceAll("ss",n.Second.toString().padStart(2,"0"))}$CreateDateInfo(n){if(n??=new Date,typeof n=="string"&&(n=new Date(n)),n instanceof Date==!1)return n;return{Date:n,Year:n.getFullYear(),Month:n.getMonth()+1,Day:n.getDate(),Hour:n.getHours(),Minute:n.getMinutes(),Second:n.getSeconds()}}ConvertTo_UrlQuery(n){if(typeof n=="string")return n;let t=[];this.ForEachObject(n,(n,i)=>{t.push(`${n}=${i}`)});return t.join("&")}ClearUrl(n){return n.replace(/^\/+|\/+$/g,"")}ToJoin(n,t="."){let i=this.Paths(n);return i.join(t)}Paths(...n){if(!Array.isArray(n))return[n];let t=[];for(let i of n)if(i!=null){if(!Array.isArray(i)){t.push(i);continue}i.length!=0&&t.push(...this.Paths(...i))}return t}IsPathType(n){if(Array.isArray(n)){for(let t of n){let n=this.IsPathType(t);if(!n)return!1}return!0}return typeof n=="string"?!0:!1}$Throw(n){throw new Error(n);}$Error(n){console.error(n)}}export class QueryNode extends FuncBase{NodeId;Dom;DomName=null;Parent=null;Children=[];ElementDeep=0;NodeDeep=0;constructor(n){super();this.Dom=n;this.NodeId=this.GenerateIdReplace("")}Query(n,t){return this.$RCS_QueryChildrens(this,n,t)}QueryCss(n,t){return this.$RCS_QueryCssChildrens(this,n,t)}Selector(n){return this.Dom.querySelector(n)}SelectorAll(n){return this.Dom.querySelectorAll(n)}$RCS_QueryChildrens(n,t,i){if(t==null)return null;t=this.Paths(t);t.length==1&&(t=t[0]);let r=[];for(let u of n.Children){if(Array.isArray(t)){let n=[...t],f=n.shift();if(u.DomName==f){n.length==1&&(n=n[0]);let t=this.$RCS_QueryChildrens(u,n,i);if(t!=null){r.push(...t);continue}}}else if(u.DomName==t&&(r.push(u),i.Mode=="Multi"))continue;let n=this.$RCS_QueryChildrens(u,t,i);n!=null&&r.push(...n)}return r}$RCS_QueryCssChildrens(n,t,i){let r=[];for(let u of n.Children)if(!u.Dom.matches(t)||(r.push(u),i.Mode!="Multi")){let n=this.$RCS_QueryCssChildrens(u,t,i);n!=null&&r.push(...n)}return r}}export class DomQueryer{$Root=null;$RootNode=null;$Nodes=[];$QueryDomName=null;IsInited=false;WithRoot(n){return this.$Root=document.querySelector(n),this}WithDomName(n){return this.$QueryDomName=n,this}Init(n=false){return this.IsInited&&!n?this:(this.$Root??=document.body,this.$RootNode=new QueryNode(this.$Root),this.$RCS_Visit(this.$Root,this.$RootNode,0),this.$Nodes=this.$Nodes.sort((n,t)=>n.NodeDeep-t.NodeDeep),this.IsInited=!0,this)}Query(n,t){return Queryer.IsInited||Queryer.Init(),t==null?t={Mode:"Multi"}:t instanceof QueryNode&&(t={Mode:"Multi",TargetNode:t}),t.TargetNode==null&&(t.TargetNode=this.$RootNode),t.TargetNode.Query(n,t)}QueryCss(n,t){return Queryer.IsInited||Queryer.Init(),t==null?t={Mode:"Multi"}:t instanceof QueryNode&&(t={Mode:"Multi",TargetNode:t}),t.TargetNode==null&&(t.TargetNode=this.$RootNode),t.TargetNode.QueryCss(n,t)}Using(n,t,i){let r=this.Query(n,{Mode:"Multi",TargetNode:i});return r!=null&&r.length>0&&t({QueryNodes:r}),this}$RCS_Visit(n,t,i){let u=this.$AddNode(n,t,i);u??=t;let r=n.children;if(n instanceof HTMLTemplateElement&&(r=n.content.children),r!=null&&r.length!=0)for(let n=0;n<r.length;n++){let t=r[n];t instanceof HTMLElement&&this.$RCS_Visit(t,u,i+1)}}$AddNode(n,t,i){if(this.$QueryDomName!=null&&!n.matches(`[${this.$QueryDomName}]`))return null;let u=n.getAttribute(this.$QueryDomName),r=new QueryNode(n);return r.DomName=u,r.ElementDeep=i,this.$Nodes.push(r),t!=null&&(r.Parent=t,r.NodeDeep=t.NodeDeep+1,t.Children.push(r)),r}}export var Queryer=new DomQueryer;export class FileItem{OnChangeBase64;OnChangeBuffer;$Store;constructor(n,i="none"){n==null?this.$Store=t({}):(this.$Store=t({FileId:(new FuncBase).GenerateId(),File:n,ConvertType:i,Base64:null,Buffer:null,IsLoaded:!1,IsLoading:!0,Error:null}),this.$ConvertFile())}get FileId(){return this.$Store.FileId}set FileId(n){this.$Store.FileId=n}get File(){return this.$Store.File}set File(n){this.$Store.File=n}get ConvertType(){return this.$Store.ConvertType}set ConvertType(n){this.$Store.ConvertType=n}get Base64(){return this.$Store.Base64}set Base64(n){this.$Store.Base64=n;this.OnChangeBase64?.call(this,this.$Store.Base64)}get Buffer(){return this.$Store.Buffer}set Buffer(n){this.$Store.Buffer=n;this.OnChangeBuffer?.call(this,this.$Store.Buffer)}get InnerStore(){return this.$Store}get IsLoaded(){return this.$Store.IsLoaded}get IsLoading(){return this.$Store.IsLoading}get Error(){return this.$Store.Error}Clear(){this.$Store.Base64=null;this.$Store.Buffer=null;this.$Store.File=null}From(n){this.$Store=n.InnerStore}CheckLoadAsync(){return new Promise((n,t)=>{try{if(this.$Store.IsLoaded||!this.$Store.IsLoading)return n(this.$Store.IsLoaded);const r=setTimeout(()=>{i&&clearInterval(i),this.$Store.Error="timeout",console.error("WaitLoadAsync: timeout"),t(!1)},6e4),i=setInterval(()=>{(this.$Store.IsLoaded||!this.$Store.IsLoading)&&(clearInterval(i),clearTimeout(r),n(this.$Store.IsLoaded))},100)}catch(i){this.$Store.Error=i;console.error(i);t(!1)}})}$ConvertFile(){if(this.ConvertType!=null){let n=[];n=Array.isArray(this.ConvertType)?this.ConvertType:[this.ConvertType];for(let t=0;t<n.length;t++){let i=n[t];switch(i){case"base64":this.$Store.IsLoading=!0;this.$ConvertBase64();break;case"buffer":this.$Store.IsLoading=!0;this.$ConvertBuffer();break;default:this.$Store.IsLoaded=!0}}}}$ConvertBase64(n=false){if(this.File==null||this.Base64!=null&&n==!1)return this;let t=new FileReader;return t.readAsDataURL(this.File),t.onload=()=>{this.Base64=t.result,this.$Store.IsLoaded=!0,this.$Store.IsLoading=!1},this}$ConvertBuffer(){let n=new FileReader;n.readAsArrayBuffer(this.File);n.onload=()=>{this.Buffer=n.result,this.$Store.IsLoaded=!0,this.$Store.IsLoading=!1}}}export class ApiStore extends FuncBase{#ApiDomain=null;#RootRoute=null;#AccessToken=null;#RefreshToken=null;#HeaderFuncs=[];#OnEventFunc={};#OnEventName={ApiStore:{AddApi:"AddApi",UpdateStore:"UpdateStore",AddStore:"AddStore",SetStore:"SetStore"}};#OnSuccess;#OnError;#OnComplete;#ExportSuccessStore;#Store={FileStore:{}};#Func_ConvertTo_FormData=[];constructor(){super();this.SetStore("api",{})}get ApiDomain(){return this.#ApiDomain==null?null:this.ClearUrl(this.#ApiDomain)}set ApiDomain(n){this.#ApiDomain=this.ClearUrl(n)}get OnEventName(){return this.#OnEventName}get #EventName(){return this.OnEventName.ApiStore}get Store(){return this.#Store}set Store(n){this.#Store=n}get ApiStore(){return this.GetStore("api")}get FileStore(){return this.Store.FileStore}WithAccessToken(n){return this.#AccessToken=n,this}WithRefreshToken(n){return this.#RefreshToken=n,this}WithApiDomain(n){return this.ApiDomain=n,this}WithRootRoute(n){return this.#RootRoute=n,this}WithHeader(n){return this.#HeaderFuncs.push(n),this}WithOnSuccess(n){return this.#OnSuccess=n,this}WithOnError(n){return this.#OnError=n,this}WithOnComplete(n){return this.#OnComplete=n,this}WithExportSuccessStore(n){return this.#ExportSuccessStore=n,this}WithConvertTo_FormParam(n){return this.#Func_ConvertTo_FormData.push(n),this}ClearConvertTo_FormParam(){return this.#Func_ConvertTo_FormData=[],this}ConvertTo_ApiUrl(n,t=null){let i=n;return this.ApiDomain==null||i.includes("http")||(i=`${this.ApiDomain}/${this.ClearUrl(i)}`),t!=null&&(i=`${i}?${this.ConvertTo_UrlQuery(t)}`),i}AddApi(n){for(let t in n){let r=n[t],i={ApiKey:t,...r};this.AddStoreFrom(this.ApiStore,t,{});this.UpdateStoreFrom(this.ApiStore,t,i);this.$EventTrigger(this.#EventName.AddApi,i)}return this}ApiCall(n,t=null){return this.$BaseApiCall(n,t,!1),this}ApiCall_Form(n,t=null){return this.$BaseApiCall(n,t,!0),this}$BaseApiCall(n,t,i){let r=this.ApiStore[n];r==null&&this.$Throw(`Api setting not found of "${n}"`);let u=t?.Query??r.Query,f=t?.Body??r.Body,e=t?.File??r.File;typeof u=="function"&&(u=u());typeof f=="function"&&(f=f());typeof e=="function"&&(e=e());let s=t?.IsUpdateStore??r.IsUpdateStore??!0,h=this.ConvertTo_ApiUrl(r.Url,u),o=this.$GenerateFetchRequest(r,f,e,i);this.PubApi(n,"IsCalling",!0);r.OnCalling?.call(this,o);t?.OnCalling?.call(this,o);fetch(h,o).then(async i=>{if(!i.ok)throw i;let u=await this.$ProcessApiReturn(i);if(s){r.Export!=!1&&(typeof r.Export=="function"?u=r.Export?.call(this,u,i):this.#ExportSuccessStore!=null&&(u=this.#ExportSuccessStore?.call(this,u,i)));let n=r.ApiKey;this.UpdateStore(n,u)}return this.PubApi(n,"IsSuccess",!0),this.PubApi(n,"IsError",!1),r.OnSuccess?.call(this,u,i),t?.OnSuccess?.call(this,u,i),this.#OnSuccess?.call(this,u,i),{ConvertResult:u,ApiResponse:i}}).catch(i=>{this.PubApi(n,"IsError",!0),this.PubApi(n,"IsSuccess",!1),this.$Error(i.message),r.OnError?.call(this,i),t?.OnError?.call(this,i),this.#OnError?.call(this,i)}).then(i=>{this.PubApi(n,"IsCalling",!1),this.PubApi(n,"IsComplete",!0),i instanceof Object?(r.OnComplete?.call(this,i.ConvertResult,i.ApiResponse),t?.OnComplete?.call(this,i.ConvertResult,i.ApiResponse),this.#OnComplete?.call(this,i.ConvertResult,i.ApiResponse)):(r.OnComplete?.call(this),t?.OnComplete?.call(this),this.#OnComplete?.call(this,null,null))})}$GenerateFetchRequest(n,t,i,r){let u=new Headers;if(u.set("Authorization",`Bearer ${this.#AccessToken}`),this.#HeaderFuncs.length>0)for(let n of this.#HeaderFuncs)n(u);let f={method:n.Method,headers:u};if(r){let n=this.$ConvertTo_FormData(t,new FormData);n=this.$ConvertTo_FormFile(i,n);f.body=n;f.method="POST"}else u.set("content-type","application/json"),n.Method!="GET"&&(f.body=JSON.stringify(t??{}));return f}AddSubApi(n,t){typeof t=="function"&&(t={NotifyEvent:t});let r={...t};this.AddStoreFrom(this.ApiStore,n,{});let i=this.ApiStore[n];return i.$sub??=[],i.$sub.push(r),this}PubApi(n,t,i){let r=this.ApiStore[n];if(r[t]=i,r.$sub==null||!Array.isArray(r.$sub))return this;for(let n of r.$sub){let i=n;(i.PropertyName==null||i.PropertyName==t)&&i.NotifyEvent({PropertyName:t,ApiStore:r,Value:r[t]})}return this}UseFormJsonBody(n="Body"){return this.WithConvertTo_FormParam(t=>{let i={};return i[n]=JSON.stringify(t),i}),this}EventAdd_AddApi(n){return this.$EventAdd(this.#EventName.AddApi,n),this}EventAdd_UpdateStore(n){return this.$EventAdd(this.#EventName.UpdateStore,n),this}EventAdd_AddStore(n){return this.$EventAdd(this.#EventName.AddStore,n),this}EventAdd_SetStore(n){return this.$EventAdd(this.#EventName.SetStore,n),this}$EventAdd(n,t){n in this.#OnEventFunc==!1&&(this.#OnEventFunc[n]=[]);this.#OnEventFunc[n].push(t)}$EventTrigger(n,t){let i=this.#OnEventFunc[n];if(i!=null)for(let n of i)n(t)}GetStore(n,t){return this.GetStoreFrom(this.Store,n,t)}AddStore(n,t=null){return this.AddStoreFrom(this.Store,n,t)}SetStore(n,t){return this.SetStoreFrom(this.Store,n,t)}UpdateStore(n,t){return this.UpdateStoreFrom(this.Store,n,t)}ClearStore(n,t){return this.ClearStoreFrom(this.Store,n,t)}GetStoreFrom(n,t,i){typeof i=="boolean"&&(i={Clone:i});i??={};i.Clone??=!1;i.CreateIfNull??=!1;i.DefaultValue==null&&(i.DefaultValue={});t=this.ToJoin(t);let r=this.$RCS_GetStore(t,n,{CreateIfNull:i.CreateIfNull,DefaultValue:i.DefaultValue});if(i.Clone){let n={},t=Object.getOwnPropertyNames(r);for(let i of t)i.match(/^\$/g)||(n[i]=r[i]);return n}return r}AddStoreFrom(n,t,i=null){return(t=this.ToJoin(t),this.GetStoreFrom(n,t)!=null)?this:(this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.AddStore,{Path:t,Data:i}),this)}SetStoreFrom(n,t,i){return t!=null&&(t=this.ToJoin(t)),this.$RCS_SetStore(t,i,n,{IsDeepSet:!1}),this.$EventTrigger(this.#EventName.SetStore,{Path:t,Data:i}),this}UpdateStoreFrom(n,t,i){return t!=null&&(t=this.ToJoin(t)),this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.UpdateStore,{Path:t,Data:i}),this}ClearStoreFrom(n,t,i){i??={};typeof i=="boolean"&&(i={DeepClear:i});let r=t==null?n:this.GetStoreFrom(n,t);return r==null?this:(this.$RCS_ClearStore(r,i),this)}$RCS_GetStore(n,t,i){if(t==null)return null;n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,"");let r=n.split("."),u=r.shift();t[u]==null&&i.CreateIfNull&&(t[u]=Array.isArray(i.DefaultValue)?[...i.DefaultValue]:typeof i.DefaultValue=="object"?{...i.DefaultValue}:i.DefaultValue);let f=t[u];if(r.length==0)return f;let e=r.join(".");return this.$RCS_GetStore(e,f,i)}$RCS_SetStore(n,t,i,r={IsDeepSet:true}){if(n==null)return this.$DeepSetObject(t,i),t;if(n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,""),n.includes(".")){let f=n.split("."),u=f.shift();i[u]==null&&(i[u]={});let e=i[u],o=f.join(".");return this.$RCS_SetStore(o,t,e,r)}let u=t==null||!r.IsDeepSet||i[n]==null||typeof t!="object";return u?(i[n]=t,t):this.$RCS_SetStore(null,t,i[n])}$RCS_ClearStore(n,t){if(typeof n=="object"){if(Array.isArray(n)){n.length=0;return}let i=Object.getOwnPropertyNames(n);for(let r of i)if(!r.match(/^\$/g))if(typeof n[r]=="function")continue;else t.DeepClear&&typeof n[r]=="object"?this.$RCS_ClearStore(n[r],t):n[r]=null}}$DeepSetObject(n,t){if(n==null){this.ClearStoreFrom(t);return}if(Array.isArray(n)){if(!Array.isArray(t))return;t.length=0;n.forEach(n=>t.push(n));return}this.ForEachObject(n,(n,i)=>{let r=!1;Array.isArray(i)?(t[n]!=null&&Array.isArray(t[n])||(t[n]=[]),r=!0):i!=null&&typeof i=="object"&&((t[n]==null||typeof t[n]!="object")&&(t[n]={}),r=!0);r?this.$DeepSetObject(i,t[n]):t[n]=i})}AddFileStore(n,t){return t??={},this.FileStore[n]==null&&(this.FileStore[n]=t.Multi==!0?[]:new FileItem),this}Files(n,t=null){let i=this.FileStore[n];if(i==null)return[];Array.isArray(i)||(i=[i]);t!=null&&(i=i.filter(n=>t(n)));return i.map(n=>n.File)}File(n,t=null){let i=this.Files(n,t);return i==null||i.length==0?null:i[0]}AddFile(n,t,i="none"){if(t!=null){this.AddFileStore(n);let r=this.FileStore[n];return Array.isArray(t)?Array.isArray(r)?t.forEach(t=>this.AddFile(n,t)):this.AddFile(n,t[0]):(t instanceof FileItem==!1&&(t=new FileItem(t,i)),Array.isArray(r)?r.push(t):r.From(t)),this}}RemoveFile(n,t){let i=this.FileStore[n];if(i==null)return this;if(Array.isArray(t))t.forEach(t=>this.RemoveFile(n,t));else if(Array.isArray(i)){let n=i.findIndex(n=>n.FileId==t);n>=0&&i.splice(n,1)}else i.Clear();return this}ClearFile(n){let t=this.FileStore[n];return t==null?this:(Array.isArray(t)?t.splice(0,t.length):t.Clear(),this)}$ProcessApiReturn(n){let t=n.headers.get("content-type");return t.includes("application/json")?n.json():t.includes("text")?n.text():new Promise(t=>{t(n)})}NavigateToRoot(){let n=this.#RootRoute??"/";return super.$BaseNavigateTo(n),this}$ConvertTo_FormData(n,t){return(t??=new FormData,n==null)?t:(this.#Func_ConvertTo_FormData.forEach(i=>{n=i(n,t)}),n instanceof FormData)?n:(this.ForEachObject(n,(n,i)=>{t.append(n,i)}),t)}$ConvertTo_FormFile(n,t){if(t??=new FormData,n==null)return t;if(Array.isArray(n)||n instanceof File||n instanceof FileItem)return this.$AppendFileToFormData("Files",t,n),t;let i=Object.keys(n);for(let r=0;r<i.length;r++){let u=i[r],f=n[u];this.$AppendFileToFormData(u,t,f)}return t}$AppendFileToFormData(n,t,i){if(Array.isArray(i))for(let r=0;r<i.length;r++)this.$AppendFileToFormData(n,t,i[r]);else i instanceof File?t.append(n,i):t.append(n,i.File);return t}}import{createApp as r,reactive as t,nextTick as u}from"vue";import{watch as i}from"vue";export class VueStore extends ApiStore{$VueProxy=null;$VueOption={methods:{},components:{},computed:{}};$VueApp=null;$VueUse=[];$CoreStore="app";$MountedFuncs=[];$Directive=[];constructor(){super();this.#Setup()}#Setup(){this.EventAdd_AddApi(n=>{this.AddStore(n.ApiKey)}).EventAdd_UpdateStore(()=>{this.ForceUpdate()}).EventAdd_AddStore(()=>{this.ForceUpdate()}).EventAdd_SetStore(()=>{this.ForceUpdate()}).AddStore(this.$CoreStore,{}).WithMounted(()=>{this.UpdateStore([this.$CoreStore,"IsMounted"],!0)})}get Store(){return this.$VueProxy!=null?this.$VueProxy:super.Store}set Store(n){super.Store=n}WithVueOption(n={}){return this.$VueOption=this.DeepObjectExtend(this.$VueOption,n),this}WithMounted(n=()=>{}){return this.$MountedFuncs.push(n),this}WithComponent(n={}){return this.$VueOption.components=this.DeepObjectExtend(this.$VueOption.components,n),this}WithVueUse(...n){for(let t of n)this.$VueUse.push(t);return this}WithDirective(n,t){return this.$Directive.push({Name:n,Directive:t}),this}ForceUpdate(){return this.$VueProxy?.$forceUpdate(),this}Refs(t){return this.$VueProxy?this.$VueProxy.$refs[n.ToJoin(t)]:null}}export class VueCommand extends VueStore{$IsInited=false;$CommandMap;$QueryDomName=null;constructor(){super();this.$SetupCommandMap()}WithQueryDomName(n){return this.$QueryDomName=n,Queryer.WithDomName(this.$QueryDomName),this}AddV_Text(t,i){let r=this.$ConvertCommandOption(t,i);if(typeof r.Target!="function"){let t=n.ToJoin(r.Target);/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/.test(t)&&n.AddStore(r.Target)}return r.FuncAction=!0,this.$AddCommand(t,"v-text",r),this}AddV_Model(n,t,i){let r=this.$ConvertCommandOption(t);return i??={},i.DefaultValue??=null,r.CommandKey=i.ModelValue,this.AddStore(t,i.DefaultValue),this.$AddCommand(n,"v-model",r),this}AddV_Slot(n,t,i){let r=this.$ConvertCommandOption(n,i);return t!=null&&(r.CommandKey=t),this.$AddCommand(n,`v-slot`,r),this}AddV_For(t,i,r){let u=this.$ConvertCommandOption(t,i);r&&(r=this.ToJoin(r),/^\(/.test(r)||(r=`(${r}`),/\)$/.test(r)||(r+=")"),u.TargetHead=`${r} in `);let f=n.ToJoin(u.Target);return/\b(in|of)\b/.test(f)||(u.TargetHead??="(item, index) in "),u.FuncAction=!0,this.$AddCommand(t,"v-for",u),this}AddV_If(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-if",i),this}AddV_ElseIf(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-else-if",i),this}AddV_Else(n){let t=this.$ConvertCommandOption(n);return t.Target="",this.$AddCommand(n,"v-else",t),this}AddV_Show(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-show",i),this}AddV_Bind(n,t,i,r){let u=this.$ConvertCommandOption(n,i,r);return u.CommandKey=t,this.$AddCommand(n,"v-bind",u),this}AddV_On(n,t,i,r){let u=this.$ConvertCommandOption(n,i,r);return u.CommandKey=t,this.$AddCommand(n,`v-on`,u),this}Watch(t,r,u={}){let f;return typeof t=="function"?f=i(t,r,u):(n.AddStore(t),f=i(()=>n.GetStore(t),r,u)),f}AddV_Watch(t,i,r={}){return n.WithMounted(()=>{this.Watch(t,i,r)}),this}AddV_Function(t,i){return this.$IsInited&&!Array.isArray(t)?this.$VueOption.methods[t]=i:n.UpdateStore(t,i),this}AddV_OnChange(n,t,i){return this.AddV_On(n,"change",t,i),this}AddV_Click(n,t,i){let r=this.$ConvertCommandOption(n,t,i);return this.AddV_On(n,"click",r),this}AddV_FilePicker(t,i){let r=null,f=null,o="none",u=!1,e,s;return typeof i=="string"?r=i:(r=i.Store,o=i.ConvertType,u=i.Multiple,e=i.OnSuccess,f=Array.isArray(i.Accept)?i.Accept.join(" "):i.Accept),this.AddFileStore(r,{Multi:u}),this.AddV_Click(t,()=>{let t=document.createElement("input");t.type="file";f!=null&&(t.accept=f);u!=null&&(t.multiple=u);t.onchange=async()=>{if(t.files!=null&&t.files.length!=0){const u=t.files,i=[];for(let t=0;t<u.length;t++){let e=u[t];this.AddFile(r,e,o);let f=n.FileStore[r];Array.isArray(f)||(f=[f]);i.push(...f)}if(e){let n=!0;for(const t of i)if(t instanceof FileItem&&!await t.CheckLoadAsync()){s&&s(t);n=!1;break}n&&e(i)}}};t.click()}),this}AddV_Tree(t,i,r){let e=[],u,f=t instanceof QueryNode;f&&(u=t);let o=f?[]:this.Paths(t);this.$ParseTreeSet(o,i,e);for(let t of e){let e=this.$CommandMap[t.Command];if(e==null){n.$Error(`${t.Command} command is not allowed, path: ${this.ToJoin(t.DomPaths)}`);continue}if(t.StoreValue!=""&&(t.StoreValue!=null||e.AcceptNull==!0)&&(t.StoreValue!="."||e.AcceptSelf==!0)){let o=t.Command=="using",s={Mode:"Multi"};if(f&&(o=!0,s.TargetNode=u),r?.UseDeepQuery&&(o=!0,s.Mode="DeepMulti"),o){let n=[u];t.DomPaths.length>0&&(n=Queryer.Query(t.DomPaths,s));t.Nodes=n}let h=o?t.Nodes:t.DomPaths,i;if(typeof t.StoreValue=="function")i={Target:t.StoreValue,FuncArgs:t.Args};else if(typeof t.StoreValue=="string"||Array.isArray(t.StoreValue))t.StoreValue=="."?i=this.Paths(t.TreePaths,t.DomName):t.StoreValue!=null&&t.StoreValue!=""&&(i=t.StoreValue);else if(i={Target:t.StoreValue?.TargetFunc,FuncArgs:t.StoreValue?.Args},t.StoreValue?.Args!=null){let i=t.StoreValue.Args;t.Args=t.Args==null?n.ToJoin(i,", "):n.ToJoin([t.Args,i],", ")}e.Execute(t,{TargetDom:h,TargetValue:i})}}return this}$ParseTreeSet(n,t,i){const u=/^:(?<next>.+)$/,r=Object.keys(t);for(let f=0;f<r.length;f++){const e=r[f],o=t[e],s=[...n],h=[...n],v=h.pop(),c=e.match(u);if(c){const t=c.groups.next;typeof o=="function"?i.push({Command:"using",StoreValue:o,TreePaths:[...s],DomPaths:[...s,t],DomName:t}):this.$ParseTreeSet([...n,t],o,i);continue}const l=(n,t,i)=>{if(!n.includes(t)||!n.includes(i))return null;const r=n.indexOf(t),u=n.lastIndexOf(i),f=n.slice(r+1,u).trim();return f?.trim()},y=n=>{let i=null,r=null;n.includes("(")&&(i=n.indexOf("("));n.includes("<")&&(r=n.indexOf("<"));let t=null;if(i==null&&r==null)t=n;else if(i==null||r==null){let u=i??r;t=n.slice(0,u)}else{let u=Math.min(i,r);t=n.slice(0,u)}let u=t,f=null;if(t.includes(":")){let n=u.indexOf(":");u=t.slice(0,n);f=t.slice(n+1)}return{Command:u?.trim(),CommandKey:f?.trim()}},p=l(e,"(",")"),w=l(e,"<",">"),a=y(e);i.push({Command:a?.Command,CommandKey:a?.CommandKey,ForKey:w,Args:p,StoreValue:o,TreePaths:h,DomPaths:s,DomName:v});continue}}$SetupCommandMap(){this.$CommandMap={"v-text":{Execute:(t,i)=>{n.AddV_Text(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-model":{Execute:(t,i)=>{if(typeof i.TargetValue=="function"){n.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Model(i.TargetDom,i.TargetValue,{ModelValue:t.CommandKey})},AcceptSelf:!0},"v-for":{Execute:(t,i)=>{n.AddV_For(i.TargetDom,i.TargetValue,t.ForKey)},AcceptSelf:!0},"v-show":{Execute:(t,i)=>{n.AddV_Show(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-if":{Execute:(t,i)=>{n.AddV_If(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-else-if":{Execute:(t,i)=>{n.AddV_ElseIf(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-else":{Execute:(t,i)=>{n.AddV_Else(i.TargetDom)},AcceptNull:!0},"v-bind":{Execute:(t,i)=>{n.AddV_Bind(i.TargetDom,t.CommandKey,i.TargetValue,t.Args)}},"v-on":{Execute:(t,i)=>{n.AddV_On(i.TargetDom,t.CommandKey,i.TargetValue,t.Args)}},"v-slot":{Execute:(t,i)=>{n.AddV_Slot(i.TargetDom,t.CommandKey,i.TargetValue)}},"v-on-mounted":{Execute:(t,i)=>{n.AddV_OnMounted(i.TargetDom,i.TargetValue,t.Args)}},"v-on-unmounted":{Execute:(t,i)=>{n.AddV_OnUnMounted(i.TargetDom,i.TargetValue,t.Args)}},"v-on-ready":{Execute:(t,i)=>{n.AddV_OnReady(i.TargetDom,i.TargetValue,t.Args)}},watch:{Execute:t=>{let i=[t.DomPaths];if(t.CommandKey&&i.push(t.CommandKey.split(":")),i=n.Paths(i),typeof t.StoreValue=="function")n.AddV_Watch(i,t.StoreValue);else{let r=t.StoreValue;n.AddV_Watch(i,r?.CallBack,r?.Option)}}},func:{Execute:t=>{if(typeof t.StoreValue!="function"){n.$Error(`func command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Function(n.Paths(...t.DomPaths,t.CommandKey??"func"),t.StoreValue)}},using:{Execute:n=>{if(typeof n.StoreValue=="function"){const t=n.Nodes,i=t!=null?t[0]:null;n.StoreValue(n.DomPaths,i,t)}}},store:{Execute:t=>{n.UpdateStore(t.DomPaths,t.StoreValue)}}}}AddV_Property(n,t){return this.AddV_PropertyFrom(this.Store,n,t)}AddV_PropertyFrom(n,t,i){if(t!=null){let r=n;t=this.ToJoin(t);let u=t;if(t.includes(".")){let i=t.split(".");u=i.pop();let f=i.join(".");r=this.GetStoreFrom(n,f,{CreateIfNull:!0})}let f=this.$BaseAddProperty(r,u,i);if(i.Bind){Array.isArray(i.Bind)||(i.Bind=[i.Bind]);for(let n of i.Bind)n!=null&&this.AddV_Property(n,{Target:t});f.Bind=i.Bind}return this}}$BaseAddProperty(n,t,i){let f=this,u={get(){return i.get?i.get():this.$get(t)},set(n){if(i.set){i.set(n);return}this.$set(t,n)}};i.get&&(u.get=i.get);i.set!=null&&(u.set=i.set);let e=n[t],r=Object.defineProperty(n,t,u);return r.$properties??={},r.$properties[t]={...i},r.$get??=n=>{let t=r.$properties[n];return t?.Target==null?t[`$${n}`]:f.GetStore(t.Target)},r.$set??=(n,t)=>{let i=r.$properties[n];i?.Target?f.SetStore(i.Target,t):i[`$${n}`]=t},i.Value!=null?r[t]=i.Value:e!=null&&(r[t]=e),r}$ConvertCommandOption(n,t,i){let r;if(t==null||t==".")if(this.IsPathType(n))r={Target:n};else{let t=n,i=t.map(n=>n.DomName);r={Target:i}}else r=typeof t=="string"||typeof t=="function"||Array.isArray(t)?{Target:t}:t;return i&&(r.FuncArgs=i),r.FuncAction??=!1,r.FuncArgs&&(r.FuncAction=!0),r}$AddCommand(n,t,i){if(n!=null){Array.isArray(n)||(n=[n]);let f=n[0]instanceof QueryNode,u;u=f?n:Queryer.Query(n);let r=i.Target;if(typeof r=="function"){let u=[];if(u=f?n.at(-1).DomName:n,r=this.$GenerateEventFunction(u,r,t),i.FuncArgs){let n=this.ToJoin(i.FuncArgs,",");r+=`(${n})`}else i.FuncAction&&(r+=`()`)}else r=this.ToJoin(r);i.TargetHead&&(r=i.TargetHead+r);i.TargetTail&&(r+=i.TargetTail);i.CommandKey&&(t+=`:${i.CommandKey}`);for(let n=0;n<u.length;n++){let i=u[n],f=i.Dom;this.$SetAttribute(f,t,r)}}}$SetAttribute(n,t,i){if(n==null){let n=`Dom Element is null. ${i}`;console.warn(n);return}n.setAttribute(t,i)}$RandomFuncName(n){return`${n}${this.GenerateIdReplace("")}`.replace(/[-:.]/g,"_")}$GenerateEventFunction(n,t,i){let u=this.$RandomFuncName(`${i}_`);n=this.Paths(n);let r=["event",...n,u];return this.AddV_Function(r,t),this.ToJoin(r)}}export class VueModel extends VueCommand{$NativeWarn;$IsEnableVueWarn;$MountId=null;Id;constructor(){super();this.Id=this.GenerateId();this.$MountId="app";this.WithVueWarn(!1);this.WithLifeCycleDirective()}WithMountId(n){return this.$MountId=n,this}WithVueWarn(n){return this.$IsEnableVueWarn=n,this.$NativeWarn=console.warn,console.warn=(...n)=>{n!=null&&n.length!=0&&(n[0].toLowerCase().includes("[vue warn]")&&this.$IsEnableVueWarn==!1||this.$NativeWarn(n))},this}WithLifeCycleDirective(){this.WithDirective("on-mounted",{mounted(n,t,i){typeof t.value=="function"&&t.value(n,i)}});this.WithDirective("on-unmounted",{unmounted(n,t,i){typeof t.value=="function"&&t.value(n,i)}});this.WithDirective("on-ready",{mounted(n,t,i){typeof t.value=="function"&&u(()=>t.value(n,i))}})}Init(){if(this.$IsInited)return this;this.Store=t(this.Store);let n=this.Store,i=this.$MountedFuncs;this.$VueApp=r({...this.$VueOption,data(){return n},mounted:()=>{for(let n of i)n()}});for(let n of this.$VueUse)this.$VueApp.use(n);for(let n of this.$Directive)this.$VueApp.directive(n.Name,n.Directive);return this.$VueProxy=this.$VueApp.mount(`#${this.$MountId}`),this.$IsInited=!0,this}Using(n=()=>{}){return n(),this}UsingVueApp(n){return n?.call(this,this.$VueApp),this.$VueApp.directive,this}AddV_OnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-mounted`,r),this}AddV_OnUnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-unmounted`,r),this}AddV_OnReady(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-ready`,r),this}}const n=new VueModel;window.Model=n;export{n as Model};
|
|
1
|
+
export class FuncBase{$NavigateToFunc;$DefaultDateJoinChar;constructor(){this.$NavigateToFunc=null;this.WithDateTextJoinChar("/")}WithNavigateTo(n){return this.$NavigateToFunc=n,this}WithDateTextJoinChar(n){return this.$DefaultDateJoinChar=n,this}GenerateId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=crypto.getRandomValues(new Uint8Array(1))[0]&15,i=n==="x"?t:t&3|8;return i.toString(16)})}GenerateIdReplace(n){return this.GenerateId().replaceAll("-",n)}GenerateUrl(n,t=null){let i=this.Paths(n);(i==null||i.length==0||i[0].length==0)&&this.$Throw("Url can not be null or empty");i=i.map(n=>n.replace(/\/+$/g,"").replace(/^\/+/g,"/"));let r=this.ToJoin(i,"/");return(r==null||r=="")&&(r="/"),t!=null&&(t=this.ConvertTo_UrlQuery(t),r+=`?${t}`),r}$BaseNavigateTo(n){this.$NavigateToFunc?this.$NavigateToFunc(n):window.location.href=n}NavigateToRoot(){return this.$BaseNavigateTo("/"),this}NavigateTo(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateTo(i),this}$BaseNavigateBlank(n){let t=document.createElement("a");t.href=n;t.target="_blank";t.rel="noopener noreferrer";t.click()}NavigateBlank(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateBlank(i),this}ForEachObject(n,t){for(let i of Object.getOwnPropertyNames(n))if(!i.match(/^$/g)){let r=n[i];t!=null&&t.call(this,i,r)}}DeepObjectExtend(n,t,i=10){if(i==0)return{...n,...t};let r=Object.keys(t);for(let u=0;u<r.length;u++){let f=r[u];if(f in n)if(typeof t[f]!="object")n[f]=t[f];else{let r={...this.DeepObjectExtend(n[f],t[f],i-1)};n[f]=r}else n[f]=t[f]}return n}ToDateInfo(n){n??=new Date;return this.$CreateDateInfo(n)}ToDateText(n,t){n=this.$CreateDateInfo(n);t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd`;let i=t.Format;return i=i.replaceAll("yyyy",n.Year.toString().padStart(4,"0")),i=i.replaceAll("MM",n.Month.toString().padStart(2,"0")),i=i.replaceAll("dd",n.Day.toString().padStart(2,"0")),t.Format=i,i}ToDateTimeText(n,t){t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd HH:mm:ss`;t={...t};n=this.$CreateDateInfo(n);this.ToDateText(n,t);let i=t.Format;return i=i.replaceAll("HH",n.Hour.toString().padStart(2,"0")),i=i.replaceAll("mm",n.Minute.toString().padStart(2,"0")),i.replaceAll("ss",n.Second.toString().padStart(2,"0"))}$CreateDateInfo(n){if(n??=new Date,typeof n=="string"&&(n=new Date(n)),n instanceof Date==!1)return n;return{Date:n,Year:n.getFullYear(),Month:n.getMonth()+1,Day:n.getDate(),Hour:n.getHours(),Minute:n.getMinutes(),Second:n.getSeconds()}}ConvertTo_UrlQuery(n){if(typeof n=="string")return n;let t=[];this.ForEachObject(n,(n,i)=>{t.push(`${n}=${i}`)});return t.join("&")}ClearUrl(n){return n.replace(/^\/+|\/+$/g,"")}ToJoin(n,t="."){let i=this.Paths(n);return i.join(t)}Paths(...n){if(!Array.isArray(n))return[n];let t=[];for(let i of n)if(i!=null){if(!Array.isArray(i)){t.push(i);continue}i.length!=0&&t.push(...this.Paths(...i))}return t}IsPathType(n){if(Array.isArray(n)){for(let t of n){let n=this.IsPathType(t);if(!n)return!1}return!0}return typeof n=="string"?!0:!1}$Throw(n){throw new Error(n);}$Error(n){console.error(n)}}export class QueryNode extends FuncBase{NodeId;Dom;DomName=null;Parent=null;Children=[];ElementDeep=0;NodeDeep=0;constructor(n){super();this.Dom=n;this.NodeId=this.GenerateIdReplace("")}Query(n,t){return t??={Mode:"Multi"},this.$RCS_QueryChildrens(this,n,t)}QueryCss(n,t){return t??={Mode:"Multi"},this.$RCS_QueryCssChildrens(this,n,t)}Selector(n){return this.Dom.querySelector(n)}SelectorAll(n){return this.Dom.querySelectorAll(n)}$RCS_QueryChildrens(n,t,i){if(t==null)return null;t=this.Paths(t);t.length==1&&(t=t[0]);let r=[];for(let u of n.Children){if(Array.isArray(t)){let n=[...t],f=n.shift();const e=f.match(/^(?<key>[^:]+):(?<name>.+)$/);if(e){const n=e.groups.key,t=e.groups.name;switch(n){case"tag":break;default:f=t}}if(u.DomName==f){n.length==1&&(n=n[0]);let t=this.$RCS_QueryChildrens(u,n,i);if(t!=null){r.push(...t);continue}}}else if(u.DomName==t&&(r.push(u),i.Mode=="Multi"))continue;let n=this.$RCS_QueryChildrens(u,t,i);n!=null&&r.push(...n)}return r}$RCS_QueryCssChildrens(n,t,i){let r=[];for(let u of n.Children)if(!u.Dom.matches(t)||(r.push(u),i.Mode!="Multi")){let n=this.$RCS_QueryCssChildrens(u,t,i);n!=null&&r.push(...n)}return r}}export class DomQueryer{$Root=null;$RootNode=null;$Nodes=[];$QueryDomName=null;IsInited=false;WithRoot(n){return this.$Root=document.querySelector(n),this}WithDomName(n){return this.$QueryDomName=n,this}Init(n=false){return this.IsInited&&!n?this:(this.$Root??=document.body,this.$RootNode=new QueryNode(this.$Root),this.$RCS_Visit(this.$Root,this.$RootNode,0),this.$Nodes=this.$Nodes.sort((n,t)=>n.NodeDeep-t.NodeDeep),this.IsInited=!0,this)}Query(n,t){return Queryer.IsInited||Queryer.Init(),t==null?t={Mode:"Multi"}:t instanceof QueryNode&&(t={Mode:"Multi",TargetNode:t}),t.TargetNode==null&&(t.TargetNode=this.$RootNode),t.TargetNode.Query(n,t)}QueryCss(n,t){return Queryer.IsInited||Queryer.Init(),t==null?t={Mode:"Multi"}:t instanceof QueryNode&&(t={Mode:"Multi",TargetNode:t}),t.TargetNode==null&&(t.TargetNode=this.$RootNode),t.TargetNode.QueryCss(n,t)}Using(n,t,i){let r=this.Query(n,{Mode:"Multi",TargetNode:i});return r!=null&&r.length>0&&t({QueryNodes:r}),this}$RCS_Visit(n,t,i){let u=this.$AddNode(n,t,i);u??=t;let r=n.children;if(n instanceof HTMLTemplateElement&&(r=n.content.children),r!=null&&r.length!=0)for(let n=0;n<r.length;n++){let t=r[n];t instanceof HTMLElement&&this.$RCS_Visit(t,u,i+1)}}$AddNode(n,t,i){if(this.$QueryDomName!=null&&!n.matches(`[${this.$QueryDomName}]`))return null;let u=n.getAttribute(this.$QueryDomName),r=new QueryNode(n);return r.DomName=u,r.ElementDeep=i,this.$Nodes.push(r),t!=null&&(r.Parent=t,r.NodeDeep=t.NodeDeep+1,t.Children.push(r)),r}}export var Queryer=new DomQueryer;export class FileItem{OnChangeBase64;OnChangeBuffer;$Store;constructor(n,i="none"){n==null?this.$Store=t({}):(this.$Store=t({FileId:(new FuncBase).GenerateId(),File:n,ConvertType:i,Base64:null,Buffer:null,IsLoaded:!1,IsLoading:!0,Error:null}),this.$ConvertFile())}get FileId(){return this.$Store.FileId}set FileId(n){this.$Store.FileId=n}get File(){return this.$Store.File}set File(n){this.$Store.File=n}get ConvertType(){return this.$Store.ConvertType}set ConvertType(n){this.$Store.ConvertType=n}get Base64(){return this.$Store.Base64}set Base64(n){this.$Store.Base64=n;this.OnChangeBase64?.call(this,this.$Store.Base64)}get Buffer(){return this.$Store.Buffer}set Buffer(n){this.$Store.Buffer=n;this.OnChangeBuffer?.call(this,this.$Store.Buffer)}get InnerStore(){return this.$Store}get IsLoaded(){return this.$Store.IsLoaded}get IsLoading(){return this.$Store.IsLoading}get Error(){return this.$Store.Error}Clear(){this.$Store.Base64=null;this.$Store.Buffer=null;this.$Store.File=null}From(n){this.$Store=n.InnerStore}CheckLoadAsync(){return new Promise((n,t)=>{try{if(this.$Store.IsLoaded||!this.$Store.IsLoading)return n(this.$Store.IsLoaded);const r=setTimeout(()=>{i&&clearInterval(i),this.$Store.Error="timeout",console.error("WaitLoadAsync: timeout"),t(!1)},6e4),i=setInterval(()=>{(this.$Store.IsLoaded||!this.$Store.IsLoading)&&(clearInterval(i),clearTimeout(r),n(this.$Store.IsLoaded))},100)}catch(i){this.$Store.Error=i;console.error(i);t(!1)}})}$ConvertFile(){if(this.ConvertType!=null){let n=[];n=Array.isArray(this.ConvertType)?this.ConvertType:[this.ConvertType];for(let t=0;t<n.length;t++){let i=n[t];switch(i){case"base64":this.$Store.IsLoading=!0;this.$ConvertBase64();break;case"buffer":this.$Store.IsLoading=!0;this.$ConvertBuffer();break;default:this.$Store.IsLoaded=!0}}}}$ConvertBase64(n=false){if(this.File==null||this.Base64!=null&&n==!1)return this;let t=new FileReader;return t.readAsDataURL(this.File),t.onload=()=>{this.Base64=t.result,this.$Store.IsLoaded=!0,this.$Store.IsLoading=!1},this}$ConvertBuffer(){let n=new FileReader;n.readAsArrayBuffer(this.File);n.onload=()=>{this.Buffer=n.result,this.$Store.IsLoaded=!0,this.$Store.IsLoading=!1}}}export class ApiStore extends FuncBase{#ApiDomain=null;#RootRoute=null;#AccessToken=null;#RefreshToken=null;#HeaderFuncs=[];#OnEventFunc={};#OnEventName={ApiStore:{AddApi:"AddApi",UpdateStore:"UpdateStore",AddStore:"AddStore",SetStore:"SetStore"}};#OnSuccess;#OnError;#OnComplete;#ExportSuccessStore;#Store={FileStore:{}};#Func_ConvertTo_FormData=[];constructor(){super();this.SetStore("api",{})}get ApiDomain(){return this.#ApiDomain==null?null:this.ClearUrl(this.#ApiDomain)}set ApiDomain(n){this.#ApiDomain=this.ClearUrl(n)}get OnEventName(){return this.#OnEventName}get #EventName(){return this.OnEventName.ApiStore}get Store(){return this.#Store}set Store(n){this.#Store=n}get ApiStore(){return this.GetStore("api")}get FileStore(){return this.Store.FileStore}WithAccessToken(n){return this.#AccessToken=n,this}WithRefreshToken(n){return this.#RefreshToken=n,this}WithApiDomain(n){return this.ApiDomain=n,this}WithRootRoute(n){return this.#RootRoute=n,this}WithHeader(n){return this.#HeaderFuncs.push(n),this}WithOnSuccess(n){return this.#OnSuccess=n,this}WithOnError(n){return this.#OnError=n,this}WithOnComplete(n){return this.#OnComplete=n,this}WithExportSuccessStore(n){return this.#ExportSuccessStore=n,this}WithConvertTo_FormParam(n){return this.#Func_ConvertTo_FormData.push(n),this}ClearConvertTo_FormParam(){return this.#Func_ConvertTo_FormData=[],this}ConvertTo_ApiUrl(n,t=null){let i=n;return this.ApiDomain==null||i.includes("http")||(i=`${this.ApiDomain}/${this.ClearUrl(i)}`),t!=null&&(i=`${i}?${this.ConvertTo_UrlQuery(t)}`),i}AddApi(n){for(let t in n){let r=n[t],i={ApiKey:t,...r};this.AddStoreFrom(this.ApiStore,t,{});this.UpdateStoreFrom(this.ApiStore,t,i);this.$EventTrigger(this.#EventName.AddApi,i)}return this}ApiCall(n,t=null){return this.$BaseApiCall(n,t,!1),this}ApiCall_Form(n,t=null){return this.$BaseApiCall(n,t,!0),this}$BaseApiCall(n,t,i){let r=this.ApiStore[n];r==null&&this.$Throw(`Api setting not found of "${n}"`);let u=t?.Query??r.Query,f=t?.Body??r.Body,e=t?.File??r.File;typeof u=="function"&&(u=u());typeof f=="function"&&(f=f());typeof e=="function"&&(e=e());let s=t?.IsUpdateStore??r.IsUpdateStore??!0,h=this.ConvertTo_ApiUrl(r.Url,u),o=this.$GenerateFetchRequest(r,f,e,i);this.PubApi(n,"IsCalling",!0);r.OnCalling?.call(this,o);t?.OnCalling?.call(this,o);fetch(h,o).then(async i=>{if(!i.ok)throw i;let u=await this.$ProcessApiReturn(i);if(s){r.Export!=!1&&(typeof r.Export=="function"?u=r.Export?.call(this,u,i):this.#ExportSuccessStore!=null&&(u=this.#ExportSuccessStore?.call(this,u,i)));let n=r.ApiKey;this.UpdateStore(n,u)}return this.PubApi(n,"IsSuccess",!0),this.PubApi(n,"IsError",!1),r.OnSuccess?.call(this,u,i),t?.OnSuccess?.call(this,u,i),this.#OnSuccess?.call(this,u,i),{ConvertResult:u,ApiResponse:i}}).catch(i=>{this.PubApi(n,"IsError",!0),this.PubApi(n,"IsSuccess",!1),this.$Error(i.message),r.OnError?.call(this,i),t?.OnError?.call(this,i),this.#OnError?.call(this,i)}).then(i=>{this.PubApi(n,"IsCalling",!1),this.PubApi(n,"IsComplete",!0),i instanceof Object?(r.OnComplete?.call(this,i.ConvertResult,i.ApiResponse),t?.OnComplete?.call(this,i.ConvertResult,i.ApiResponse),this.#OnComplete?.call(this,i.ConvertResult,i.ApiResponse)):(r.OnComplete?.call(this),t?.OnComplete?.call(this),this.#OnComplete?.call(this,null,null))})}$GenerateFetchRequest(n,t,i,r){let u=new Headers;if(u.set("Authorization",`Bearer ${this.#AccessToken}`),this.#HeaderFuncs.length>0)for(let n of this.#HeaderFuncs)n(u);let f={method:n.Method,headers:u};if(r){let n=this.$ConvertTo_FormData(t,new FormData);n=this.$ConvertTo_FormFile(i,n);f.body=n;f.method="POST"}else u.set("content-type","application/json"),n.Method!="GET"&&(f.body=JSON.stringify(t??{}));return f}AddSubApi(n,t){typeof t=="function"&&(t={NotifyEvent:t});let r={...t};this.AddStoreFrom(this.ApiStore,n,{});let i=this.ApiStore[n];return i.$sub??=[],i.$sub.push(r),this}PubApi(n,t,i){let r=this.ApiStore[n];if(r[t]=i,r.$sub==null||!Array.isArray(r.$sub))return this;for(let n of r.$sub){let i=n;(i.PropertyName==null||i.PropertyName==t)&&i.NotifyEvent({PropertyName:t,ApiStore:r,Value:r[t]})}return this}UseFormJsonBody(n="Body"){return this.WithConvertTo_FormParam(t=>{let i={};return i[n]=JSON.stringify(t),i}),this}EventAdd_AddApi(n){return this.$EventAdd(this.#EventName.AddApi,n),this}EventAdd_UpdateStore(n){return this.$EventAdd(this.#EventName.UpdateStore,n),this}EventAdd_AddStore(n){return this.$EventAdd(this.#EventName.AddStore,n),this}EventAdd_SetStore(n){return this.$EventAdd(this.#EventName.SetStore,n),this}$EventAdd(n,t){n in this.#OnEventFunc==!1&&(this.#OnEventFunc[n]=[]);this.#OnEventFunc[n].push(t)}$EventTrigger(n,t){let i=this.#OnEventFunc[n];if(i!=null)for(let n of i)n(t)}GetStore(n,t){return this.GetStoreFrom(this.Store,n,t)}AddStore(n,t=null){return this.AddStoreFrom(this.Store,n,t)}SetStore(n,t){return this.SetStoreFrom(this.Store,n,t)}UpdateStore(n,t){return this.UpdateStoreFrom(this.Store,n,t)}ClearStore(n,t){return this.ClearStoreFrom(this.Store,n,t)}GetStoreFrom(n,t,i){typeof i=="boolean"&&(i={Clone:i});i??={};i.Clone??=!1;i.CreateIfNull??=!1;i.DefaultValue==null&&(i.DefaultValue={});t=this.ToJoin(t);let r=this.$RCS_GetStore(t,n,{CreateIfNull:i.CreateIfNull,DefaultValue:i.DefaultValue});if(i.Clone){let n={},t=Object.getOwnPropertyNames(r);for(let i of t)i.match(/^\$/g)||(n[i]=r[i]);return n}return r}AddStoreFrom(n,t,i=null){return(t=this.ToJoin(t),this.GetStoreFrom(n,t)!=null)?this:(this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.AddStore,{Path:t,Data:i}),this)}SetStoreFrom(n,t,i){return t!=null&&(t=this.ToJoin(t)),this.$RCS_SetStore(t,i,n,{IsDeepSet:!1}),this.$EventTrigger(this.#EventName.SetStore,{Path:t,Data:i}),this}UpdateStoreFrom(n,t,i){return t!=null&&(t=this.ToJoin(t)),this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.UpdateStore,{Path:t,Data:i}),this}ClearStoreFrom(n,t,i){i??={};typeof i=="boolean"&&(i={DeepClear:i});let r=t==null?n:this.GetStoreFrom(n,t);return r==null?this:(this.$RCS_ClearStore(r,i),this)}$RCS_GetStore(n,t,i){if(t==null)return null;n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,"");let r=n.split("."),u=r.shift();t[u]==null&&i.CreateIfNull&&(t[u]=Array.isArray(i.DefaultValue)?[...i.DefaultValue]:typeof i.DefaultValue=="object"?{...i.DefaultValue}:i.DefaultValue);let f=t[u];if(r.length==0)return f;let e=r.join(".");return this.$RCS_GetStore(e,f,i)}$RCS_SetStore(n,t,i,r={IsDeepSet:true}){if(n==null)return this.$DeepSetObject(t,i),t;if(n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,""),n.includes(".")){let f=n.split("."),u=f.shift();i[u]==null&&(i[u]={});let e=i[u],o=f.join(".");return this.$RCS_SetStore(o,t,e,r)}let u=t==null||!r.IsDeepSet||i[n]==null||typeof t!="object";return u?(i[n]=t,t):this.$RCS_SetStore(null,t,i[n])}$RCS_ClearStore(n,t){if(typeof n=="object"){if(Array.isArray(n)){n.length=0;return}let i=Object.getOwnPropertyNames(n);for(let r of i)if(!r.match(/^\$/g))if(typeof n[r]=="function")continue;else t.DeepClear&&typeof n[r]=="object"?this.$RCS_ClearStore(n[r],t):n[r]=null}}$DeepSetObject(n,t){if(n==null){this.ClearStoreFrom(t);return}if(Array.isArray(n)){if(!Array.isArray(t))return;t.length=0;n.forEach(n=>t.push(n));return}this.ForEachObject(n,(n,i)=>{let r=!1;Array.isArray(i)?(t[n]!=null&&Array.isArray(t[n])||(t[n]=[]),r=!0):i!=null&&typeof i=="object"&&((t[n]==null||typeof t[n]!="object")&&(t[n]={}),r=!0);r?this.$DeepSetObject(i,t[n]):t[n]=i})}AddFileStore(n,t){return t??={},this.FileStore[n]==null&&(this.FileStore[n]=t.Multi==!0?[]:new FileItem),this}Files(n,t=null){let i=this.FileStore[n];if(i==null)return[];Array.isArray(i)||(i=[i]);t!=null&&(i=i.filter(n=>t(n)));return i.map(n=>n.File)}File(n,t=null){let i=this.Files(n,t);return i==null||i.length==0?null:i[0]}AddFile(n,t,i="none"){if(t!=null){this.AddFileStore(n);let r=this.FileStore[n];return Array.isArray(t)?Array.isArray(r)?t.forEach(t=>this.AddFile(n,t)):this.AddFile(n,t[0]):(t instanceof FileItem==!1&&(t=new FileItem(t,i)),Array.isArray(r)?r.push(t):r.From(t)),this}}RemoveFile(n,t){let i=this.FileStore[n];if(i==null)return this;if(Array.isArray(t))t.forEach(t=>this.RemoveFile(n,t));else if(Array.isArray(i)){let n=i.findIndex(n=>n.FileId==t);n>=0&&i.splice(n,1)}else i.Clear();return this}ClearFile(n){let t=this.FileStore[n];return t==null?this:(Array.isArray(t)?t.splice(0,t.length):t.Clear(),this)}$ProcessApiReturn(n){let t=n.headers.get("content-type");return t.includes("application/json")?n.json():t.includes("text")?n.text():new Promise(t=>{t(n)})}NavigateToRoot(){let n=this.#RootRoute??"/";return super.$BaseNavigateTo(n),this}$ConvertTo_FormData(n,t){return(t??=new FormData,n==null)?t:(this.#Func_ConvertTo_FormData.forEach(i=>{n=i(n,t)}),n instanceof FormData)?n:(this.ForEachObject(n,(n,i)=>{t.append(n,i)}),t)}$ConvertTo_FormFile(n,t){if(t??=new FormData,n==null)return t;if(Array.isArray(n)||n instanceof File||n instanceof FileItem)return this.$AppendFileToFormData("Files",t,n),t;let i=Object.keys(n);for(let r=0;r<i.length;r++){let u=i[r],f=n[u];this.$AppendFileToFormData(u,t,f)}return t}$AppendFileToFormData(n,t,i){if(Array.isArray(i))for(let r=0;r<i.length;r++)this.$AppendFileToFormData(n,t,i[r]);else i instanceof File?t.append(n,i):t.append(n,i.File);return t}}import{createApp as r,reactive as t,nextTick as u}from"vue";import{watch as i}from"vue";export class VueStore extends ApiStore{$VueProxy=null;$VueOption={methods:{},components:{},computed:{}};$VueApp=null;$VueUse=[];$CoreStore="app";$MountedFuncs=[];$Directive=[];constructor(){super();this.#Setup()}#Setup(){this.EventAdd_AddApi(n=>{this.AddStore(n.ApiKey)}).EventAdd_UpdateStore(()=>{this.ForceUpdate()}).EventAdd_AddStore(()=>{this.ForceUpdate()}).EventAdd_SetStore(()=>{this.ForceUpdate()}).AddStore(this.$CoreStore,{}).WithMounted(()=>{this.UpdateStore([this.$CoreStore,"IsMounted"],!0)})}get Store(){return this.$VueProxy!=null?this.$VueProxy:super.Store}set Store(n){super.Store=n}WithVueOption(n={}){return this.$VueOption=this.DeepObjectExtend(this.$VueOption,n),this}WithMounted(n=()=>{}){return this.$MountedFuncs.push(n),this}WithComponent(n={}){return this.$VueOption.components=this.DeepObjectExtend(this.$VueOption.components,n),this}WithVueUse(...n){for(let t of n)this.$VueUse.push(t);return this}WithDirective(n,t){return this.$Directive.push({Name:n,Directive:t}),this}ForceUpdate(){return this.$VueProxy?.$forceUpdate(),this}Refs(t){return this.$VueProxy?this.$VueProxy.$refs[n.ToJoin(t)]:null}}export class VueCommand extends VueStore{$IsInited=false;$CommandMap;$QueryDomName=null;constructor(){super();this.$SetupCommandMap()}WithQueryDomName(n){return this.$QueryDomName=n,Queryer.WithDomName(this.$QueryDomName),this}AddV_Text(t,i){let r=this.$ConvertCommandOption(t,i);if(typeof r.Target!="function"){let t=n.ToJoin(r.Target);/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*)*$/.test(t)&&n.AddStore(r.Target)}return r.FuncAction=!0,this.$AddCommand(t,"v-text",r),this}AddV_Model(n,t,i){let r=this.$ConvertCommandOption(t);return i??={},i.DefaultValue??=null,r.CommandKey=i.ModelValue,this.AddStore(t,i.DefaultValue),this.$AddCommand(n,"v-model",r),this}AddV_Slot(n,t,i){let r=this.$ConvertCommandOption(n,i);return t!=null&&(r.CommandKey=t),this.$AddCommand(n,`v-slot`,r),this}AddV_For(t,i,r){let u=this.$ConvertCommandOption(t,i);r&&(r=this.ToJoin(r),/^\(/.test(r)||(r=`(${r}`),/\)$/.test(r)||(r+=")"),u.TargetHead=`${r} in `);let f=n.ToJoin(u.Target);return/\b(in|of)\b/.test(f)||(u.TargetHead??="(item, index) in "),u.FuncAction=!0,this.$AddCommand(t,"v-for",u),this}AddV_If(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-if",i),this}AddV_ElseIf(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-else-if",i),this}AddV_Else(n){let t=this.$ConvertCommandOption(n);return t.Target="",this.$AddCommand(n,"v-else",t),this}AddV_Show(n,t){let i=this.$ConvertCommandOption(n,t);return i.FuncAction=!0,this.$AddCommand(n,"v-show",i),this}AddV_Bind(n,t,i,r){let u=this.$ConvertCommandOption(n,i,r);return u.CommandKey=t,this.$AddCommand(n,"v-bind",u),this}AddV_On(n,t,i,r){let u=this.$ConvertCommandOption(n,i,r);return u.CommandKey=t,this.$AddCommand(n,`v-on`,u),this}Watch(t,r,u={}){let f;return typeof t=="function"?f=i(t,r,u):(n.AddStore(t),f=i(()=>n.GetStore(t),r,u)),f}AddV_Watch(t,i,r={}){return n.WithMounted(()=>{this.Watch(t,i,r)}),this}AddV_Function(t,i){return this.$IsInited&&!Array.isArray(t)?this.$VueOption.methods[t]=i:n.UpdateStore(t,i),this}AddV_OnChange(n,t,i){return this.AddV_On(n,"change",t,i),this}AddV_Click(n,t,i){let r=this.$ConvertCommandOption(n,t,i);return this.AddV_On(n,"click",r),this}AddV_FilePicker(t,i){let r=null,f=null,o="none",u=!1,e,s;return typeof i=="string"?r=i:(r=i.Store,o=i.ConvertType,u=i.Multiple,e=i.OnSuccess,f=Array.isArray(i.Accept)?i.Accept.join(" "):i.Accept),this.AddFileStore(r,{Multi:u}),this.AddV_Click(t,()=>{let t=document.createElement("input");t.type="file";f!=null&&(t.accept=f);u!=null&&(t.multiple=u);t.onchange=async()=>{if(t.files!=null&&t.files.length!=0){const u=t.files,i=[];for(let t=0;t<u.length;t++){let e=u[t];this.AddFile(r,e,o);let f=n.FileStore[r];Array.isArray(f)||(f=[f]);i.push(...f)}if(e){let n=!0;for(const t of i)if(t instanceof FileItem&&!await t.CheckLoadAsync()){s&&s(t);n=!1;break}n&&e(i)}}};t.click()}),this}AddV_Tree(t,i,r){let e=[],u,f=t instanceof QueryNode;f&&(u=t);let o=f?[]:this.Paths(t);this.$ParseTreeSet(o,i,e);for(let t of e){let e=this.$CommandMap[t.Command];if(e==null){n.$Error(`${t.Command} command is not allowed, path: ${this.ToJoin(t.DomPaths)}`);continue}if(t.StoreValue!=""&&(t.StoreValue!=null||e.AcceptNull==!0)&&(t.StoreValue!="."||e.AcceptSelf==!0)){let o=t.Command=="using",s={Mode:"Multi"};if(f&&(o=!0,s.TargetNode=u),r?.UseDeepQuery&&(o=!0,s.Mode="DeepMulti"),o){let n=[u];t.DomPaths.length>0&&(n=Queryer.Query(t.DomPaths,s));t.Nodes=n}let h=o?t.Nodes:t.DomPaths,i;if(typeof t.StoreValue=="function")i={Target:t.StoreValue,FuncArgs:t.Args};else if(typeof t.StoreValue=="string"||Array.isArray(t.StoreValue))t.StoreValue=="."?i=this.Paths(t.TreePaths,t.DomName):t.StoreValue!=null&&t.StoreValue!=""&&(i=t.StoreValue);else if(i={Target:t.StoreValue?.TargetFunc,FuncArgs:t.StoreValue?.Args},t.StoreValue?.Args!=null){let i=t.StoreValue.Args;t.Args=t.Args==null?n.ToJoin(i,", "):n.ToJoin([t.Args,i],", ")}e.Execute(t,{TargetDom:h,TargetValue:i})}}return this}$ParseTreeSet(n,t,i){const u=/^:(?<next>.+)$/,r=Object.keys(t);for(let f=0;f<r.length;f++){const e=r[f],o=t[e],s=[...n],h=[...n],v=h.pop(),c=e.match(u);if(c){const t=c.groups.next;typeof o=="function"?i.push({Command:"using",StoreValue:o,TreePaths:[...s],DomPaths:[...s,t],DomName:t}):this.$ParseTreeSet([...n,t],o,i);continue}const l=(n,t,i)=>{if(!n.includes(t)||!n.includes(i))return null;const r=n.indexOf(t),u=n.lastIndexOf(i),f=n.slice(r+1,u).trim();return f?.trim()},y=n=>{let i=null,r=null;n.includes("(")&&(i=n.indexOf("("));n.includes("<")&&(r=n.indexOf("<"));let t=null;if(i==null&&r==null)t=n;else if(i==null||r==null){let u=i??r;t=n.slice(0,u)}else{let u=Math.min(i,r);t=n.slice(0,u)}let u=t,f=null;if(t.includes(":")){let n=u.indexOf(":");u=t.slice(0,n);f=t.slice(n+1)}return{Command:u?.trim(),CommandKey:f?.trim()}},p=l(e,"(",")"),w=l(e,"<",">"),a=y(e);i.push({Command:a?.Command,CommandKey:a?.CommandKey,ForKey:w,Args:p,StoreValue:o,TreePaths:h,DomPaths:s,DomName:v});continue}}$SetupCommandMap(){this.$CommandMap={"v-text":{Execute:(t,i)=>{n.AddV_Text(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-model":{Execute:(t,i)=>{if(typeof i.TargetValue=="function"){n.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Model(i.TargetDom,i.TargetValue,{ModelValue:t.CommandKey})},AcceptSelf:!0},"v-for":{Execute:(t,i)=>{n.AddV_For(i.TargetDom,i.TargetValue,t.ForKey)},AcceptSelf:!0},"v-show":{Execute:(t,i)=>{n.AddV_Show(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-if":{Execute:(t,i)=>{n.AddV_If(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-else-if":{Execute:(t,i)=>{n.AddV_ElseIf(i.TargetDom,i.TargetValue)},AcceptSelf:!0},"v-else":{Execute:(t,i)=>{n.AddV_Else(i.TargetDom)},AcceptNull:!0},"v-bind":{Execute:(t,i)=>{n.AddV_Bind(i.TargetDom,t.CommandKey,i.TargetValue,t.Args)}},"v-on":{Execute:(t,i)=>{n.AddV_On(i.TargetDom,t.CommandKey,i.TargetValue,t.Args)}},"v-slot":{Execute:(t,i)=>{n.AddV_Slot(i.TargetDom,t.CommandKey,i.TargetValue)}},"v-on-mounted":{Execute:(t,i)=>{n.AddV_OnMounted(i.TargetDom,i.TargetValue,t.Args)}},"v-on-unmounted":{Execute:(t,i)=>{n.AddV_OnUnMounted(i.TargetDom,i.TargetValue,t.Args)}},"v-on-ready":{Execute:(t,i)=>{n.AddV_OnReady(i.TargetDom,i.TargetValue,t.Args)}},watch:{Execute:t=>{let i=[t.DomPaths];if(t.CommandKey&&i.push(t.CommandKey.split(":")),i=n.Paths(i),typeof t.StoreValue=="function")n.AddV_Watch(i,t.StoreValue);else{let r=t.StoreValue;n.AddV_Watch(i,r?.CallBack,r?.Option)}}},func:{Execute:t=>{if(typeof t.StoreValue!="function"){n.$Error(`func command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Function(n.Paths(...t.DomPaths,t.CommandKey??"func"),t.StoreValue)}},using:{Execute:n=>{if(typeof n.StoreValue=="function"){const t=n.Nodes,i=t!=null?t[0]:null;n.StoreValue(n.DomPaths,i,t)}}},store:{Execute:t=>{n.UpdateStore(t.DomPaths,t.StoreValue)}}}}AddV_Property(n,t){return this.AddV_PropertyFrom(this.Store,n,t)}AddV_PropertyFrom(n,t,i){if(t!=null){let r=n;t=this.ToJoin(t);let u=t;if(t.includes(".")){let i=t.split(".");u=i.pop();let f=i.join(".");r=this.GetStoreFrom(n,f,{CreateIfNull:!0})}let f=this.$BaseAddProperty(r,u,i);if(i.Bind){Array.isArray(i.Bind)||(i.Bind=[i.Bind]);for(let n of i.Bind)n!=null&&this.AddV_Property(n,{Target:t});f.Bind=i.Bind}return this}}$BaseAddProperty(n,t,i){let f=this,u={get(){return i.get?i.get():this.$get(t)},set(n){if(i.set){i.set(n);return}this.$set(t,n)}};i.get&&(u.get=i.get);i.set!=null&&(u.set=i.set);let e=n[t],r=Object.defineProperty(n,t,u);return r.$properties??={},r.$properties[t]={...i},r.$get??=n=>{let t=r.$properties[n];return t?.Target==null?t[`$${n}`]:f.GetStore(t.Target)},r.$set??=(n,t)=>{let i=r.$properties[n];i?.Target?f.SetStore(i.Target,t):i[`$${n}`]=t},i.Value!=null?r[t]=i.Value:e!=null&&(r[t]=e),r}$ConvertCommandOption(n,t,i){let r;if(t==null||t==".")if(this.IsPathType(n))r={Target:n};else{let t=n,i=t.map(n=>n.DomName);r={Target:i}}else r=typeof t=="string"||typeof t=="function"||Array.isArray(t)?{Target:t}:t;return i&&(r.FuncArgs=i),r.FuncAction??=!1,r.FuncArgs&&(r.FuncAction=!0),r}$AddCommand(n,t,i){if(n!=null){Array.isArray(n)||(n=[n]);let f=n[0]instanceof QueryNode,u;u=f?n:Queryer.Query(n);let r=i.Target;if(typeof r=="function"){let u=[];if(u=f?n.at(-1).DomName:n,r=this.$GenerateEventFunction(u,r,t),i.FuncArgs){let n=this.ToJoin(i.FuncArgs,",");r+=`(${n})`}else i.FuncAction&&(r+=`()`)}else r=this.ToJoin(r);i.TargetHead&&(r=i.TargetHead+r);i.TargetTail&&(r+=i.TargetTail);i.CommandKey&&(t+=`:${i.CommandKey}`);for(let n=0;n<u.length;n++){let i=u[n],f=i.Dom;this.$SetAttribute(f,t,r)}}}$SetAttribute(n,t,i){if(n==null){let n=`Dom Element is null. ${i}`;console.warn(n);return}n.setAttribute(t,i)}$RandomFuncName(n){return`${n}${this.GenerateIdReplace("")}`.replace(/[-:.]/g,"_")}$GenerateEventFunction(n,t,i){const u=this.$RandomFuncName(`${i}_`);n=this.Paths(n);const r=["event",...n,u].filter(n=>n!=null&&n!="");return this.AddV_Function(r,t),this.ToJoin(r)}}export class VueModel extends VueCommand{$NativeWarn;$IsEnableVueWarn;$MountId=null;Id;constructor(){super();this.Id=this.GenerateId();this.$MountId="app";this.WithVueWarn(!1);this.WithLifeCycleDirective()}WithMountId(n){return this.$MountId=n,this}WithVueWarn(n){return this.$IsEnableVueWarn=n,this.$NativeWarn=console.warn,console.warn=(...n)=>{n!=null&&n.length!=0&&(n[0].toLowerCase().includes("[vue warn]")&&this.$IsEnableVueWarn==!1||this.$NativeWarn(n))},this}WithLifeCycleDirective(){this.WithDirective("on-mounted",{mounted(n,t,i){typeof t.value=="function"&&t.value(n,i)}});this.WithDirective("on-unmounted",{unmounted(n,t,i){typeof t.value=="function"&&t.value(n,i)}});this.WithDirective("on-ready",{mounted(n,t,i){typeof t.value=="function"&&u(()=>t.value(n,i))}})}Init(){if(this.$IsInited)return this;this.Store=t(this.Store);let n=this.Store,i=this.$MountedFuncs;this.$VueApp=r({...this.$VueOption,data(){return n},mounted:()=>{for(let n of i)n()}});for(let n of this.$VueUse)this.$VueApp.use(n);for(let n of this.$Directive)this.$VueApp.directive(n.Name,n.Directive);return this.$VueProxy=this.$VueApp.mount(`#${this.$MountId}`),this.$IsInited=!0,this}Using(n=()=>{}){return n(),this}UsingVueApp(n){return n?.call(this,this.$VueApp),this.$VueApp.directive,this}AddV_OnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-mounted`,r),this}AddV_OnUnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-unmounted`,r),this}AddV_OnReady(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-ready`,r),this}}const n=new VueModel;window.Model=n;export{n as Model};
|
|
2
2
|
//# sourceMappingURL=VueModel.esm.min.js.map
|