@dooboostore/simple-web-component 1.0.24 → 1.0.26
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/README.md +162 -33
- package/dist/cjs/decorators/addEventListener.js +1 -1
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +148 -0
- package/dist/cjs/decorators/applyAttribute.js.map +7 -0
- package/dist/cjs/decorators/applyClass.js +164 -0
- package/dist/cjs/decorators/applyClass.js.map +7 -0
- package/dist/cjs/decorators/applyNode.js +87 -194
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/{style.js → applyStyle.js} +50 -60
- package/dist/cjs/decorators/applyStyle.js.map +7 -0
- package/dist/cjs/decorators/attribute.js +10 -16
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +1 -1
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +14 -23
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +5 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -3
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +9 -9
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +1 -1
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +19 -4
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +2 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/utils/Utils.js +1 -1
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +1 -1
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +129 -0
- package/dist/esm/decorators/applyAttribute.js.map +7 -0
- package/dist/esm/decorators/applyClass.js +145 -0
- package/dist/esm/decorators/applyClass.js.map +7 -0
- package/dist/esm/decorators/applyNode.js +87 -194
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/{style.js → applyStyle.js} +47 -57
- package/dist/esm/decorators/applyStyle.js.map +7 -0
- package/dist/esm/decorators/attribute.js +10 -16
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +1 -1
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +14 -23
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +5 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +3 -3
- package/dist/esm/decorators/index.js.map +1 -1
- package/dist/esm/decorators/lifecycles.js +9 -9
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +1 -1
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +19 -4
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +2 -0
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/utils/Utils.js +1 -1
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +2853 -574
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +22 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -0
- package/dist/types/decorators/applyClass.d.ts +65 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -0
- package/dist/types/decorators/applyNode.d.ts +15 -123
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +21 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -0
- package/dist/types/decorators/attribute.d.ts +10 -19
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +3 -3
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +7 -0
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +2853 -574
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +2 -2
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +147 -0
- package/src/decorators/applyClass.ts +158 -0
- package/src/decorators/applyNode.ts +112 -330
- package/src/decorators/applyStyle.ts +128 -0
- package/src/decorators/attribute.ts +21 -55
- package/src/decorators/changedAttributeHost.ts +1 -1
- package/src/decorators/elementDefine.ts +18 -39
- package/src/decorators/emitCustomEvent.ts +6 -3
- package/src/decorators/index.ts +3 -3
- package/src/decorators/lifecycles.ts +9 -11
- package/src/decorators/query.ts +1 -1
- package/src/decorators/queryAll.ts +1 -1
- package/src/elements/SwcAppEngine.ts +32 -4
- package/src/elements/SwcAppMixin.ts +2 -0
- package/src/utils/Utils.ts +2 -1
- package/dist/cjs/decorators/classList.js +0 -177
- package/dist/cjs/decorators/classList.js.map +0 -7
- package/dist/cjs/decorators/setAttribute.js +0 -111
- package/dist/cjs/decorators/setAttribute.js.map +0 -7
- package/dist/cjs/decorators/style.js.map +0 -7
- package/dist/esm/decorators/classList.js +0 -158
- package/dist/esm/decorators/classList.js.map +0 -7
- package/dist/esm/decorators/setAttribute.js +0 -92
- package/dist/esm/decorators/setAttribute.js.map +0 -7
- package/dist/esm/decorators/style.js.map +0 -7
- package/dist/types/decorators/classList.d.ts +0 -71
- package/dist/types/decorators/classList.d.ts.map +0 -1
- package/dist/types/decorators/setAttribute.d.ts +0 -23
- package/dist/types/decorators/setAttribute.d.ts.map +0 -1
- package/dist/types/decorators/style.d.ts +0 -58
- package/dist/types/decorators/style.d.ts.map +0 -1
- package/src/decorators/classList.ts +0 -234
- package/src/decorators/setAttribute.ts +0 -114
- package/src/decorators/style.ts +0 -185
|
@@ -303,8 +303,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
303
303
|
keys.push(key);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
for (var
|
|
307
|
-
var key = parentKeys_1[
|
|
306
|
+
for (var _a4 = 0, parentKeys_1 = parentKeys; _a4 < parentKeys_1.length; _a4++) {
|
|
307
|
+
var key = parentKeys_1[_a4];
|
|
308
308
|
var hasKey = set.has(key);
|
|
309
309
|
if (!hasKey) {
|
|
310
310
|
set.add(key);
|
|
@@ -1120,10 +1120,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1120
1120
|
__export(bundle_entry_exports, {
|
|
1121
1121
|
ADD_EVENT_LISTENER_METADATA_KEY: () => ADD_EVENT_LISTENER_METADATA_KEY,
|
|
1122
1122
|
APPLY_NODE_METADATA_KEY: () => APPLY_NODE_METADATA_KEY,
|
|
1123
|
+
ATTRIBUTE_APPLY_METADATA_KEY: () => ATTRIBUTE_APPLY_METADATA_KEY,
|
|
1123
1124
|
ATTRIBUTE_CHANGED_WILDCARD: () => ATTRIBUTE_CHANGED_WILDCARD,
|
|
1124
|
-
|
|
1125
|
+
ATTRIBUTE_FIELD_METADATA_KEY: () => ATTRIBUTE_FIELD_METADATA_KEY,
|
|
1125
1126
|
BROWSER_GLOBALS: () => BROWSER_GLOBALS,
|
|
1126
|
-
|
|
1127
|
+
CLASS_METADATA_KEY: () => CLASS_METADATA_KEY,
|
|
1127
1128
|
DOM_EVENT_NAMES: () => DOM_EVENT_NAMES,
|
|
1128
1129
|
ELEMENT_CONFIG_KEY: () => ELEMENT_CONFIG_KEY,
|
|
1129
1130
|
EMIT_CUSTOM_EVENT_METADATA_KEY: () => EMIT_CUSTOM_EVENT_METADATA_KEY,
|
|
@@ -1141,12 +1142,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1141
1142
|
ON_CONSTRUCTOR_METADATA_KEY: () => ON_CONSTRUCTOR_METADATA_KEY,
|
|
1142
1143
|
QUERY_ALL_METADATA_KEY: () => QUERY_ALL_METADATA_KEY,
|
|
1143
1144
|
QUERY_METADATA_KEY: () => QUERY_METADATA_KEY,
|
|
1144
|
-
SET_ATTRIBUTE_METADATA_KEY: () => SET_ATTRIBUTE_METADATA_KEY,
|
|
1145
1145
|
STYLE_METADATA_KEY: () => STYLE_METADATA_KEY,
|
|
1146
1146
|
SWC_NOT_FOUND: () => SWC_NOT_FOUND,
|
|
1147
1147
|
SwcUtils: () => SwcUtils,
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
addClass: () => addClass,
|
|
1149
|
+
addClassHost: () => addClassHost,
|
|
1150
1150
|
addEventListener: () => addEventListener,
|
|
1151
1151
|
addEventListenerHost: () => addEventListenerHost,
|
|
1152
1152
|
allAppHost: () => allAppHost,
|
|
@@ -1157,26 +1157,18 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1157
1157
|
allLastHost: () => allLastHost,
|
|
1158
1158
|
allParentHost: () => allParentHost,
|
|
1159
1159
|
appHost: () => appHost,
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
applyBeforeBeginNode: () => applyBeforeBeginNode,
|
|
1165
|
-
applyBeforeBeginNodeHost: () => applyBeforeBeginNodeHost,
|
|
1166
|
-
applyBeforeEndNode: () => applyBeforeEndNode,
|
|
1167
|
-
applyBeforeEndNodeHost: () => applyBeforeEndNodeHost,
|
|
1160
|
+
applyAttribute: () => applyAttribute,
|
|
1161
|
+
applyAttributeHost: () => applyAttributeHost,
|
|
1162
|
+
applyClass: () => applyClass,
|
|
1163
|
+
applyClassHost: () => applyClassHost,
|
|
1168
1164
|
applyInnerHtmlNode: () => applyInnerHtmlNode,
|
|
1169
1165
|
applyInnerHtmlNodeHost: () => applyInnerHtmlNodeHost,
|
|
1170
|
-
applyInnerTextNode: () => applyInnerTextNode,
|
|
1171
|
-
applyInnerTextNodeHost: () => applyInnerTextNodeHost,
|
|
1172
1166
|
applyNode: () => applyNode,
|
|
1173
1167
|
applyNodeHost: () => applyNodeHost,
|
|
1174
|
-
applyRemoveNode: () => applyRemoveNode,
|
|
1175
|
-
applyRemoveNodeHost: () => applyRemoveNodeHost,
|
|
1176
1168
|
applyReplaceChildrenNode: () => applyReplaceChildrenNode,
|
|
1177
1169
|
applyReplaceChildrenNodeHost: () => applyReplaceChildrenNodeHost,
|
|
1178
|
-
|
|
1179
|
-
|
|
1170
|
+
applyStyle: () => applyStyle,
|
|
1171
|
+
applyStyleHost: () => applyStyleHost,
|
|
1180
1172
|
attribute: () => attribute,
|
|
1181
1173
|
attributeHost: () => attributeHost,
|
|
1182
1174
|
changedAttributeHost: () => changedAttributeHost,
|
|
@@ -1187,11 +1179,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1187
1179
|
emitCustomEventHost: () => emitCustomEventHost,
|
|
1188
1180
|
ensureInit: () => ensureInit2,
|
|
1189
1181
|
findAllApplyNodeMetadata: () => findAllApplyNodeMetadata,
|
|
1182
|
+
findAllAttributeApplyMetadata: () => findAllAttributeApplyMetadata,
|
|
1190
1183
|
findAllAttributeChangedMetadata: () => findAllAttributeChangedMetadata,
|
|
1191
1184
|
findAllAttributeMetadata: () => findAllAttributeMetadata,
|
|
1192
|
-
|
|
1185
|
+
findAllClassMetadata: () => findAllClassMetadata,
|
|
1193
1186
|
findAllLifecycleMetadata: () => findAllLifecycleMetadata,
|
|
1194
|
-
findAllSetAttributeMetadata: () => findAllSetAttributeMetadata,
|
|
1195
1187
|
findAllStyleMetadata: () => findAllStyleMetadata,
|
|
1196
1188
|
firstAppHost: () => firstAppHost,
|
|
1197
1189
|
firstHost: () => firstHost,
|
|
@@ -1202,7 +1194,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1202
1194
|
getOnConnectedInnerHtmlMetadata: () => getOnConnectedInnerHtmlMetadata,
|
|
1203
1195
|
getQueryAllMetadata: () => getQueryAllMetadata,
|
|
1204
1196
|
getQueryMetadata: () => getQueryMetadata,
|
|
1205
|
-
getSetAttributeMetadata: () => getSetAttributeMetadata,
|
|
1206
1197
|
host: () => host,
|
|
1207
1198
|
htmlAElement: () => htmlAElement,
|
|
1208
1199
|
htmlArticleElement: () => htmlArticleElement,
|
|
@@ -1234,29 +1225,33 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1234
1225
|
queryAll: () => queryAll,
|
|
1235
1226
|
queryAllHost: () => queryAllHost,
|
|
1236
1227
|
queryHost: () => queryHost,
|
|
1237
|
-
|
|
1238
|
-
|
|
1228
|
+
removeAttribute: () => removeAttribute,
|
|
1229
|
+
removeAttributeHost: () => removeAttributeHost,
|
|
1230
|
+
removeClass: () => removeClass,
|
|
1231
|
+
removeClassHost: () => removeClassHost,
|
|
1239
1232
|
removeStyle: () => removeStyle,
|
|
1240
1233
|
removeStyleHost: () => removeStyleHost,
|
|
1241
1234
|
resolveTargetEls: () => resolveTargetEls,
|
|
1242
1235
|
setAttribute: () => setAttribute,
|
|
1243
1236
|
setAttributeHost: () => setAttributeHost,
|
|
1244
|
-
|
|
1245
|
-
|
|
1237
|
+
setClass: () => setClass,
|
|
1238
|
+
setClassHost: () => setClassHost,
|
|
1246
1239
|
setStyle: () => setStyle,
|
|
1247
1240
|
setStyleHost: () => setStyleHost,
|
|
1248
1241
|
textNode: () => textNode,
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1242
|
+
toggleClass: () => toggleClass,
|
|
1243
|
+
toggleClassHost: () => toggleClassHost,
|
|
1244
|
+
updateAttribute: () => updateAttribute,
|
|
1245
|
+
updateAttributeHost: () => updateAttributeHost,
|
|
1246
|
+
updateClass: () => updateClass,
|
|
1247
|
+
updateClassHost: () => updateClassHost,
|
|
1253
1248
|
updateStyle: () => updateStyle,
|
|
1254
1249
|
updateStyleHost: () => updateStyleHost
|
|
1255
1250
|
});
|
|
1256
|
-
var
|
|
1251
|
+
var import_reflect_metadata3 = __toESM(require_Reflect(), 1);
|
|
1257
1252
|
|
|
1258
1253
|
// src/index.ts
|
|
1259
|
-
var
|
|
1254
|
+
var import_reflect_metadata2 = __toESM(require_Reflect(), 1);
|
|
1260
1255
|
|
|
1261
1256
|
// ../core/dist/esm/valid/ValidUtils.js
|
|
1262
1257
|
var ValidUtils;
|
|
@@ -4932,6 +4927,107 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
4932
4927
|
}
|
|
4933
4928
|
};
|
|
4934
4929
|
|
|
4930
|
+
// ../core/dist/esm/message/Subject.js
|
|
4931
|
+
var Subject = class extends Observable {
|
|
4932
|
+
constructor() {
|
|
4933
|
+
super((subscriber) => {
|
|
4934
|
+
return this._subscribeToSubject(subscriber);
|
|
4935
|
+
});
|
|
4936
|
+
this._observers = /* @__PURE__ */ new Set();
|
|
4937
|
+
this._isStopped = false;
|
|
4938
|
+
this._hasError = false;
|
|
4939
|
+
}
|
|
4940
|
+
_subscribeToSubject(subscriber) {
|
|
4941
|
+
const partialObserver = {
|
|
4942
|
+
next: subscriber.next.bind(subscriber),
|
|
4943
|
+
error: subscriber.error.bind(subscriber),
|
|
4944
|
+
complete: subscriber.complete.bind(subscriber)
|
|
4945
|
+
};
|
|
4946
|
+
if (this._isStopped) {
|
|
4947
|
+
if (this._hasError) {
|
|
4948
|
+
partialObserver.error?.(this._error);
|
|
4949
|
+
} else {
|
|
4950
|
+
partialObserver.complete?.();
|
|
4951
|
+
}
|
|
4952
|
+
return Subscription.EMPTY;
|
|
4953
|
+
}
|
|
4954
|
+
this._observers.add(partialObserver);
|
|
4955
|
+
return new Subscription(() => {
|
|
4956
|
+
this._observers.delete(partialObserver);
|
|
4957
|
+
});
|
|
4958
|
+
}
|
|
4959
|
+
next(data) {
|
|
4960
|
+
if (this._isStopped) {
|
|
4961
|
+
return;
|
|
4962
|
+
}
|
|
4963
|
+
this._observers.forEach((observer) => {
|
|
4964
|
+
observer.next?.(data);
|
|
4965
|
+
});
|
|
4966
|
+
}
|
|
4967
|
+
error(err) {
|
|
4968
|
+
if (this._isStopped) {
|
|
4969
|
+
return;
|
|
4970
|
+
}
|
|
4971
|
+
this._hasError = true;
|
|
4972
|
+
this._error = err;
|
|
4973
|
+
this._isStopped = true;
|
|
4974
|
+
this._observers.forEach((observer) => observer.error?.(err));
|
|
4975
|
+
this._observers.clear();
|
|
4976
|
+
}
|
|
4977
|
+
complete() {
|
|
4978
|
+
if (this._isStopped) {
|
|
4979
|
+
return;
|
|
4980
|
+
}
|
|
4981
|
+
this._isStopped = true;
|
|
4982
|
+
this._observers.forEach((observer) => observer.complete?.());
|
|
4983
|
+
this._observers.clear();
|
|
4984
|
+
}
|
|
4985
|
+
asObservable() {
|
|
4986
|
+
return new Observable((subscriber) => {
|
|
4987
|
+
return this._subscribeToSubject(subscriber);
|
|
4988
|
+
});
|
|
4989
|
+
}
|
|
4990
|
+
};
|
|
4991
|
+
|
|
4992
|
+
// ../core/dist/esm/message/ReplaySubject.js
|
|
4993
|
+
var ReplaySubject = class extends Subject {
|
|
4994
|
+
// Removed: private _error: E | undefined;
|
|
4995
|
+
// Removed: private _isStopped = false;
|
|
4996
|
+
constructor(bufferSize = Infinity) {
|
|
4997
|
+
super();
|
|
4998
|
+
this.bufferSize = bufferSize;
|
|
4999
|
+
this._buffer = [];
|
|
5000
|
+
}
|
|
5001
|
+
next(data) {
|
|
5002
|
+
if (this._isStopped) {
|
|
5003
|
+
return;
|
|
5004
|
+
}
|
|
5005
|
+
this._buffer.push(data);
|
|
5006
|
+
if (this._buffer.length > this.bufferSize) {
|
|
5007
|
+
this._buffer.shift();
|
|
5008
|
+
}
|
|
5009
|
+
super.next(data);
|
|
5010
|
+
}
|
|
5011
|
+
error(err) {
|
|
5012
|
+
super.error(err);
|
|
5013
|
+
}
|
|
5014
|
+
complete() {
|
|
5015
|
+
super.complete();
|
|
5016
|
+
}
|
|
5017
|
+
_subscribeToSubject(subscriber) {
|
|
5018
|
+
this._buffer.forEach((value) => subscriber.next(value));
|
|
5019
|
+
if (this._isStopped) {
|
|
5020
|
+
if (this._hasError) {
|
|
5021
|
+
subscriber.error(this._error);
|
|
5022
|
+
} else {
|
|
5023
|
+
subscriber.complete();
|
|
5024
|
+
}
|
|
5025
|
+
return Subscription.EMPTY;
|
|
5026
|
+
}
|
|
5027
|
+
return super._subscribeToSubject(subscriber);
|
|
5028
|
+
}
|
|
5029
|
+
};
|
|
5030
|
+
|
|
4935
5031
|
// ../core/dist/esm/message/AutoCloseSubscription.js
|
|
4936
5032
|
var AutoCloseSubscription = class extends Subscription {
|
|
4937
5033
|
constructor(userUnsubscribe) {
|
|
@@ -5266,6 +5362,284 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5266
5362
|
})(Result = Promises2.Result || (Promises2.Result = {}));
|
|
5267
5363
|
})(Promises || (Promises = {}));
|
|
5268
5364
|
|
|
5365
|
+
// ../core/dist/esm/fetch/Fetcher.js
|
|
5366
|
+
var Fetcher = class {
|
|
5367
|
+
createPipe(config) {
|
|
5368
|
+
return {};
|
|
5369
|
+
}
|
|
5370
|
+
fetch(config) {
|
|
5371
|
+
return new Promise((resolve, reject) => {
|
|
5372
|
+
const pipe = this.createPipe(config);
|
|
5373
|
+
Promise.resolve().then(() => {
|
|
5374
|
+
this.before(config, pipe);
|
|
5375
|
+
config?.before?.();
|
|
5376
|
+
}).then(() => {
|
|
5377
|
+
return this.execute(config);
|
|
5378
|
+
}).then((data) => {
|
|
5379
|
+
const hasError = config.config?.hasErrorChecker?.(data);
|
|
5380
|
+
if (hasError) {
|
|
5381
|
+
throw hasError;
|
|
5382
|
+
}
|
|
5383
|
+
pipe.responseData = data;
|
|
5384
|
+
this.afterSuccess(config, pipe);
|
|
5385
|
+
config?.afterSuccess?.();
|
|
5386
|
+
const gdata = config?.transform ? config.transform(data) : data;
|
|
5387
|
+
this.afterSuccessTransform(config, pipe);
|
|
5388
|
+
resolve(gdata);
|
|
5389
|
+
}).catch(async (e) => {
|
|
5390
|
+
this.error(config, pipe, e);
|
|
5391
|
+
config?.error?.();
|
|
5392
|
+
if (config?.errorTransform) {
|
|
5393
|
+
e = await config.errorTransform(e);
|
|
5394
|
+
}
|
|
5395
|
+
e = await this.errorTransform(e);
|
|
5396
|
+
reject(e);
|
|
5397
|
+
}).finally(() => {
|
|
5398
|
+
this.finally(config, pipe);
|
|
5399
|
+
config?.finally?.();
|
|
5400
|
+
});
|
|
5401
|
+
});
|
|
5402
|
+
}
|
|
5403
|
+
};
|
|
5404
|
+
|
|
5405
|
+
// ../core/dist/esm/fetch/HttpFetcher.js
|
|
5406
|
+
var HttpResponseError = class extends Error {
|
|
5407
|
+
};
|
|
5408
|
+
var HttpFetcher = class extends Fetcher {
|
|
5409
|
+
get(config) {
|
|
5410
|
+
config.config ?? (config.config = {});
|
|
5411
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5412
|
+
config.config.fetch.method = "GET";
|
|
5413
|
+
return this.fetch(config);
|
|
5414
|
+
}
|
|
5415
|
+
post(config) {
|
|
5416
|
+
config.config ?? (config.config = {});
|
|
5417
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5418
|
+
config.config.fetch.method = "POST";
|
|
5419
|
+
return this.fetch(config);
|
|
5420
|
+
}
|
|
5421
|
+
patch(config) {
|
|
5422
|
+
config.config ?? (config.config = {});
|
|
5423
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5424
|
+
config.config.fetch.method = "PATCH";
|
|
5425
|
+
return this.fetch(config);
|
|
5426
|
+
}
|
|
5427
|
+
put(config) {
|
|
5428
|
+
config.config ?? (config.config = {});
|
|
5429
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5430
|
+
config.config.fetch.method = "PUT";
|
|
5431
|
+
return this.fetch(config);
|
|
5432
|
+
}
|
|
5433
|
+
head(config) {
|
|
5434
|
+
config.config ?? (config.config = {});
|
|
5435
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5436
|
+
config.config.fetch.method = "HEAD";
|
|
5437
|
+
return this.fetch(config);
|
|
5438
|
+
}
|
|
5439
|
+
delete(config) {
|
|
5440
|
+
config.config ?? (config.config = {});
|
|
5441
|
+
config.config.fetch = config.config?.fetch ?? {};
|
|
5442
|
+
config.config.fetch.method = "DELETE";
|
|
5443
|
+
return this.fetch(config);
|
|
5444
|
+
}
|
|
5445
|
+
async beforeProxyFetch(config) {
|
|
5446
|
+
return config;
|
|
5447
|
+
}
|
|
5448
|
+
async afterProxyFetch(config) {
|
|
5449
|
+
return config.response;
|
|
5450
|
+
}
|
|
5451
|
+
afterSuccess(config, pipe) {
|
|
5452
|
+
}
|
|
5453
|
+
afterSuccessTransform(config, pipe) {
|
|
5454
|
+
}
|
|
5455
|
+
before(config, pipe) {
|
|
5456
|
+
}
|
|
5457
|
+
error(config, pipe, e) {
|
|
5458
|
+
}
|
|
5459
|
+
finally(config, pipe) {
|
|
5460
|
+
}
|
|
5461
|
+
beforeFetch(fetch2) {
|
|
5462
|
+
}
|
|
5463
|
+
afterFetch(fetch2, response) {
|
|
5464
|
+
}
|
|
5465
|
+
// protected async errorTransform(e: any): Promise<HttpResponseError<any>> {
|
|
5466
|
+
async errorTransform(e) {
|
|
5467
|
+
const httpResponseError = new HttpResponseError();
|
|
5468
|
+
httpResponseError.error = e;
|
|
5469
|
+
if (e instanceof Response) {
|
|
5470
|
+
httpResponseError.response = e;
|
|
5471
|
+
try {
|
|
5472
|
+
httpResponseError.body = await e.clone().text();
|
|
5473
|
+
httpResponseError.message = e.statusText;
|
|
5474
|
+
} catch (e2) {
|
|
5475
|
+
httpResponseError.body = e2;
|
|
5476
|
+
httpResponseError.message = e2.message;
|
|
5477
|
+
}
|
|
5478
|
+
} else {
|
|
5479
|
+
httpResponseError.body = e;
|
|
5480
|
+
httpResponseError.message = e.message;
|
|
5481
|
+
}
|
|
5482
|
+
return httpResponseError;
|
|
5483
|
+
}
|
|
5484
|
+
async execute(fetcherRequest) {
|
|
5485
|
+
let target = fetcherRequest.target;
|
|
5486
|
+
let config = fetcherRequest.config;
|
|
5487
|
+
if (!(target instanceof URL) && typeof target !== "string") {
|
|
5488
|
+
const searchParams = ConvertUtils.toURLSearchParams(target.searchParams ?? {});
|
|
5489
|
+
try {
|
|
5490
|
+
const url = typeof target.url === "string" ? new URL(target.url) : target.url;
|
|
5491
|
+
searchParams.forEach((value, key) => {
|
|
5492
|
+
url.searchParams.append(key, value);
|
|
5493
|
+
});
|
|
5494
|
+
target = url;
|
|
5495
|
+
} catch (e) {
|
|
5496
|
+
if (typeof target.url === "string") {
|
|
5497
|
+
const searchParamString = searchParams.toString();
|
|
5498
|
+
target = target.url + (searchParamString ? "?" + searchParamString : "");
|
|
5499
|
+
} else {
|
|
5500
|
+
target = "";
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5504
|
+
const beforeProxyData = { requestInfo: target, init: config?.fetch };
|
|
5505
|
+
let beforeData = config?.beforeProxyFetch ? await config?.beforeProxyFetch(config) : beforeProxyData.requestInfo;
|
|
5506
|
+
beforeData = config?.skipGlobalBeforeProxyFetch ? beforeProxyData : await this.beforeProxyFetch(beforeProxyData);
|
|
5507
|
+
target = beforeData.requestInfo;
|
|
5508
|
+
if (beforeData.init) {
|
|
5509
|
+
config ?? (config = {});
|
|
5510
|
+
config.fetch = beforeData.init;
|
|
5511
|
+
}
|
|
5512
|
+
let abortedTimeout;
|
|
5513
|
+
if (config?.fetch && "timeout" in config.fetch) {
|
|
5514
|
+
const abortController = new AbortController();
|
|
5515
|
+
abortedTimeout = setTimeout(() => {
|
|
5516
|
+
if (config?.fetch?.signal) {
|
|
5517
|
+
const inputSignal = config.fetch.signal;
|
|
5518
|
+
const listener = () => {
|
|
5519
|
+
if (!abortController.signal.aborted) {
|
|
5520
|
+
abortController.abort();
|
|
5521
|
+
}
|
|
5522
|
+
inputSignal.removeEventListener("abort", listener);
|
|
5523
|
+
};
|
|
5524
|
+
inputSignal.addEventListener("abort", listener);
|
|
5525
|
+
}
|
|
5526
|
+
if (!abortController.signal.aborted) {
|
|
5527
|
+
abortController.abort();
|
|
5528
|
+
}
|
|
5529
|
+
}, config.fetch.timeout);
|
|
5530
|
+
config.fetch.signal = abortController.signal;
|
|
5531
|
+
}
|
|
5532
|
+
this.beforeFetch({ target, requestInit: config?.fetch });
|
|
5533
|
+
return (config.fetcher ?? fetch)(target, config?.fetch).then(async (it) => {
|
|
5534
|
+
this.afterFetch({ target, requestInit: config?.fetch }, it);
|
|
5535
|
+
const afterProxyData = {
|
|
5536
|
+
fetch: { target, requestInit: config.fetch },
|
|
5537
|
+
config: beforeData,
|
|
5538
|
+
response: it
|
|
5539
|
+
};
|
|
5540
|
+
it = config?.afterProxyFetch ? await config.afterProxyFetch(afterProxyData) : it;
|
|
5541
|
+
it = config?.skipGlobalAfterProxyFetch ? it : await this.afterProxyFetch(afterProxyData);
|
|
5542
|
+
config?.fetchResponseAfterCallBack?.(it, config);
|
|
5543
|
+
if (!config?.allowedResponseNotOk && !it.ok) {
|
|
5544
|
+
throw it;
|
|
5545
|
+
}
|
|
5546
|
+
const data = config?.hasResponseErrorChecker?.(it, config);
|
|
5547
|
+
if (data) {
|
|
5548
|
+
throw data;
|
|
5549
|
+
}
|
|
5550
|
+
return it;
|
|
5551
|
+
}).finally(() => {
|
|
5552
|
+
if (abortedTimeout) {
|
|
5553
|
+
clearTimeout(abortedTimeout);
|
|
5554
|
+
}
|
|
5555
|
+
});
|
|
5556
|
+
}
|
|
5557
|
+
};
|
|
5558
|
+
|
|
5559
|
+
// ../core/dist/esm/fetch/HttpJsonFetcher.js
|
|
5560
|
+
var HttpJsonFetcher = class extends HttpFetcher {
|
|
5561
|
+
updateJsonFetchConfigAndData(config) {
|
|
5562
|
+
var _a4, _b2;
|
|
5563
|
+
const headers = {
|
|
5564
|
+
"Content-Type": "application/json",
|
|
5565
|
+
Accept: "application/json, text/plain, */*"
|
|
5566
|
+
};
|
|
5567
|
+
config.config ?? (config.config = {});
|
|
5568
|
+
(_a4 = config.config).fetch ?? (_a4.fetch = {});
|
|
5569
|
+
(_b2 = config.config.fetch).headers ?? (_b2.headers = {});
|
|
5570
|
+
config.config.fetch.headers = { ...headers, ...config.config.fetch?.headers };
|
|
5571
|
+
if (config.config?.fetch?.body && typeof config.config?.fetch?.body !== "string") {
|
|
5572
|
+
config.config.fetch.body = JSON.stringify(config.config.fetch.body);
|
|
5573
|
+
}
|
|
5574
|
+
return config;
|
|
5575
|
+
}
|
|
5576
|
+
get(config) {
|
|
5577
|
+
return super.get(config);
|
|
5578
|
+
}
|
|
5579
|
+
delete(config) {
|
|
5580
|
+
return super.delete(config);
|
|
5581
|
+
}
|
|
5582
|
+
post(config) {
|
|
5583
|
+
return super.post(config);
|
|
5584
|
+
}
|
|
5585
|
+
patch(config) {
|
|
5586
|
+
return super.patch(config);
|
|
5587
|
+
}
|
|
5588
|
+
put(config) {
|
|
5589
|
+
return super.put(config);
|
|
5590
|
+
}
|
|
5591
|
+
head(config) {
|
|
5592
|
+
return super.head(config);
|
|
5593
|
+
}
|
|
5594
|
+
postJson(config) {
|
|
5595
|
+
return super.post(this.updateJsonFetchConfigAndData(config));
|
|
5596
|
+
}
|
|
5597
|
+
patchJson(config) {
|
|
5598
|
+
return super.patch(this.updateJsonFetchConfigAndData(config));
|
|
5599
|
+
}
|
|
5600
|
+
putJson(config) {
|
|
5601
|
+
return super.put(this.updateJsonFetchConfigAndData(config));
|
|
5602
|
+
}
|
|
5603
|
+
async errorTransform(e) {
|
|
5604
|
+
const httpResponseError = new HttpResponseError();
|
|
5605
|
+
httpResponseError.error = e;
|
|
5606
|
+
if (e instanceof Response) {
|
|
5607
|
+
httpResponseError.response = e;
|
|
5608
|
+
try {
|
|
5609
|
+
httpResponseError.body = await e.clone().json();
|
|
5610
|
+
httpResponseError.message = e.statusText;
|
|
5611
|
+
} catch (parseError) {
|
|
5612
|
+
httpResponseError.body = parseError;
|
|
5613
|
+
httpResponseError.message = parseError.message;
|
|
5614
|
+
}
|
|
5615
|
+
} else {
|
|
5616
|
+
httpResponseError.body = e;
|
|
5617
|
+
httpResponseError.message = e.message;
|
|
5618
|
+
}
|
|
5619
|
+
return httpResponseError;
|
|
5620
|
+
}
|
|
5621
|
+
// protected execute(target: HttpFetcherTarget, config?: HttpJsonFetcherConfig<C, any>): Promise<any> {
|
|
5622
|
+
execute(fetcherRequest) {
|
|
5623
|
+
return super.execute(fetcherRequest).then((response) => {
|
|
5624
|
+
const config = fetcherRequest.config;
|
|
5625
|
+
const transform = config?.responseTransform ?? (config?.bypassTransform ? "response" : config?.transformText ? "text" : void 0);
|
|
5626
|
+
if (transform === "response") {
|
|
5627
|
+
return response;
|
|
5628
|
+
} else if (transform === "text") {
|
|
5629
|
+
return response?.text();
|
|
5630
|
+
} else if (typeof transform === "function") {
|
|
5631
|
+
return transform(response);
|
|
5632
|
+
} else {
|
|
5633
|
+
return response?.text().then((it) => {
|
|
5634
|
+
if ((it ?? "").length > 0) {
|
|
5635
|
+
return JSON.parse(it);
|
|
5636
|
+
}
|
|
5637
|
+
});
|
|
5638
|
+
}
|
|
5639
|
+
});
|
|
5640
|
+
}
|
|
5641
|
+
};
|
|
5642
|
+
|
|
5269
5643
|
// ../core/dist/esm/entity/object/obj/RenderDrawObj.js
|
|
5270
5644
|
var RenderDrawObj = class extends Obj {
|
|
5271
5645
|
render(draw, config) {
|
|
@@ -5859,7 +6233,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5859
6233
|
})(Expression || (Expression = {}));
|
|
5860
6234
|
|
|
5861
6235
|
// src/decorators/addEventListener.ts
|
|
5862
|
-
var ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:add-event-listener");
|
|
6236
|
+
var ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:add-event-listener");
|
|
5863
6237
|
function addEventListener(selectorOrTarget, type, options = {}) {
|
|
5864
6238
|
return (targetObj, propertyKey, descriptor) => {
|
|
5865
6239
|
const constructor = targetObj.constructor;
|
|
@@ -5880,15 +6254,15 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5880
6254
|
}
|
|
5881
6255
|
|
|
5882
6256
|
// src/decorators/lifecycles.ts
|
|
5883
|
-
var ON_CONSTRUCTOR_METADATA_KEY = Symbol("simple-web-component:on-constructor");
|
|
5884
|
-
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-connected");
|
|
5885
|
-
var ON_AFTER_CONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-connected");
|
|
5886
|
-
var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-before-disconnected");
|
|
5887
|
-
var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol("simple-web-component:on-after-disconnected");
|
|
5888
|
-
var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-before-adopted");
|
|
5889
|
-
var ON_AFTER_ADOPTED_METADATA_KEY = Symbol("simple-web-component:on-after-adopted");
|
|
5890
|
-
var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol("simple-web-component:on-add-event-listener");
|
|
5891
|
-
var INNER_HTML_METADATA_KEY = Symbol("simple-web-component:inner-html");
|
|
6257
|
+
var ON_CONSTRUCTOR_METADATA_KEY = Symbol.for("simple-web-component:on-constructor");
|
|
6258
|
+
var ON_BEFORE_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-connected");
|
|
6259
|
+
var ON_AFTER_CONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-connected");
|
|
6260
|
+
var ON_BEFORE_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-disconnected");
|
|
6261
|
+
var ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-disconnected");
|
|
6262
|
+
var ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-before-adopted");
|
|
6263
|
+
var ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for("simple-web-component:on-after-adopted");
|
|
6264
|
+
var ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for("simple-web-component:on-add-event-listener");
|
|
6265
|
+
var INNER_HTML_METADATA_KEY = Symbol.for("simple-web-component:inner-html");
|
|
5892
6266
|
var ATTRIBUTE_CHANGED_WILDCARD = "*";
|
|
5893
6267
|
function createLifecycleDecorator(metadataKey) {
|
|
5894
6268
|
return (target, propertyKey) => {
|
|
@@ -5939,7 +6313,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5939
6313
|
};
|
|
5940
6314
|
|
|
5941
6315
|
// src/decorators/attribute.ts
|
|
5942
|
-
var
|
|
6316
|
+
var ATTRIBUTE_FIELD_METADATA_KEY = Symbol.for("simple-web-component:attribute-field");
|
|
5943
6317
|
var convertValue = (val, type) => {
|
|
5944
6318
|
if (val === null || val === void 0) return val;
|
|
5945
6319
|
if (type === Number) return Number(val);
|
|
@@ -5997,15 +6371,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
5997
6371
|
const constructor = target.constructor;
|
|
5998
6372
|
const privateKey = Symbol(String(propertyKey));
|
|
5999
6373
|
const designType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
6000
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6374
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_FIELD_METADATA_KEY, constructor);
|
|
6001
6375
|
if (!metaList) {
|
|
6002
6376
|
metaList = [];
|
|
6003
|
-
ReflectUtils.defineMetadata(
|
|
6377
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_FIELD_METADATA_KEY, metaList, constructor);
|
|
6004
6378
|
}
|
|
6005
6379
|
metaList.push({ propertyKey, selector, options, privateKey });
|
|
6006
6380
|
const applySetAttribute = (inst, targets, attrName, nv) => {
|
|
6007
6381
|
targets.forEach((it) => {
|
|
6008
|
-
console.log("----->", it);
|
|
6009
6382
|
if (it && typeof it.setAttribute === "function") {
|
|
6010
6383
|
if (nv === null) {
|
|
6011
6384
|
it.removeAttribute(attrName);
|
|
@@ -6023,7 +6396,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6023
6396
|
const conf = getElementConfig(this);
|
|
6024
6397
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6025
6398
|
const targetType = options.type || designType;
|
|
6026
|
-
console.log("type-->", propertyKey, targetType);
|
|
6027
6399
|
if (this.__swc_syncing_init || options.connectedInitialize && !this.__swc_connected) {
|
|
6028
6400
|
return convertValue(this[privateKey], targetType);
|
|
6029
6401
|
}
|
|
@@ -6039,7 +6411,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6039
6411
|
return convertValue(this[privateKey], targetType);
|
|
6040
6412
|
},
|
|
6041
6413
|
set(nv) {
|
|
6042
|
-
const targetType = options.type || designType;
|
|
6043
6414
|
const attrName = options.name || String(propertyKey);
|
|
6044
6415
|
const conf = getElementConfig(this);
|
|
6045
6416
|
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
@@ -6064,13 +6435,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6064
6435
|
});
|
|
6065
6436
|
};
|
|
6066
6437
|
}
|
|
6067
|
-
var findAllAttributeMetadata = (target) => {
|
|
6068
|
-
return ReflectUtils.findAllMetadata(ATTRIBUTE_METADATA_KEY, target).flat();
|
|
6069
|
-
};
|
|
6070
6438
|
function attributeHost(targetOrAttrOrOptions, propertyKeyOrOptions) {
|
|
6071
6439
|
if (propertyKeyOrOptions !== void 0 && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol")) {
|
|
6072
|
-
|
|
6073
|
-
return attribute(":host", { name: fieldName })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
6440
|
+
return attribute(":host", { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
6074
6441
|
}
|
|
6075
6442
|
if (typeof targetOrAttrOrOptions === "string") {
|
|
6076
6443
|
const attrName = targetOrAttrOrOptions;
|
|
@@ -6079,19 +6446,20 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6079
6446
|
} else if (typeof targetOrAttrOrOptions === "object") {
|
|
6080
6447
|
const options = targetOrAttrOrOptions;
|
|
6081
6448
|
return (target, propertyKey) => {
|
|
6082
|
-
|
|
6083
|
-
return attribute(":host", { ...options, name: fieldName })(target, propertyKey);
|
|
6449
|
+
return attribute(":host", { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
6084
6450
|
};
|
|
6085
6451
|
} else {
|
|
6086
6452
|
return (target, propertyKey) => {
|
|
6087
|
-
|
|
6088
|
-
return attribute(":host", { name: fieldName })(target, propertyKey);
|
|
6453
|
+
return attribute(":host", { name: String(propertyKey) })(target, propertyKey);
|
|
6089
6454
|
};
|
|
6090
6455
|
}
|
|
6091
6456
|
}
|
|
6457
|
+
var findAllAttributeMetadata = (target) => {
|
|
6458
|
+
return ReflectUtils.findAllMetadata(ATTRIBUTE_FIELD_METADATA_KEY, target).flat();
|
|
6459
|
+
};
|
|
6092
6460
|
|
|
6093
6461
|
// src/decorators/changedAttributeHost.ts
|
|
6094
|
-
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol("simple-web-component:on-attribute-changed");
|
|
6462
|
+
var ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for("simple-web-component:on-attribute-changed");
|
|
6095
6463
|
function changedAttributeHost(attributeName) {
|
|
6096
6464
|
return (target, propertyKey) => {
|
|
6097
6465
|
const constructor = target.constructor;
|
|
@@ -6117,102 +6485,43 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6117
6485
|
return ReflectUtils.findAllMapMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, target);
|
|
6118
6486
|
};
|
|
6119
6487
|
|
|
6120
|
-
// src/decorators/setAttribute.ts
|
|
6121
|
-
var SET_ATTRIBUTE_METADATA_KEY = Symbol("simple-web-component:set-attribute");
|
|
6122
|
-
function setAttribute(selector, name, options = {}) {
|
|
6123
|
-
return (target, propertyKey, descriptor) => {
|
|
6124
|
-
const constructor = target.constructor;
|
|
6125
|
-
let metaList = ReflectUtils.getOwnMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
|
|
6126
|
-
if (!metaList) {
|
|
6127
|
-
metaList = /* @__PURE__ */ new Map();
|
|
6128
|
-
ReflectUtils.defineMetadata(SET_ATTRIBUTE_METADATA_KEY, metaList, constructor);
|
|
6129
|
-
}
|
|
6130
|
-
metaList.set(propertyKey, { propertyKey, selector, name, options });
|
|
6131
|
-
const original = descriptor.value;
|
|
6132
|
-
descriptor.value = async function(...args) {
|
|
6133
|
-
ensureInit2(this);
|
|
6134
|
-
const res = await original.apply(this, args);
|
|
6135
|
-
if (res !== void 0) {
|
|
6136
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
6137
|
-
const conf = getElementConfig(this);
|
|
6138
|
-
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6139
|
-
const targetEls = [];
|
|
6140
|
-
const r = options.root || "auto";
|
|
6141
|
-
const applyRoot = (t) => {
|
|
6142
|
-
if (!t) return;
|
|
6143
|
-
if (r === "auto") {
|
|
6144
|
-
targetEls.push(t);
|
|
6145
|
-
} else {
|
|
6146
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6147
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) targetEls.push(t.shadowRoot);
|
|
6148
|
-
}
|
|
6149
|
-
};
|
|
6150
|
-
if (selector === ":window") targetEls.push(currentWin);
|
|
6151
|
-
else if (selector === ":document") targetEls.push(currentWin.document);
|
|
6152
|
-
else if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6153
|
-
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
6154
|
-
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
6155
|
-
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
6156
|
-
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
6157
|
-
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6158
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6159
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6160
|
-
else if (selector === ":host" || !selector) applyRoot(this);
|
|
6161
|
-
else {
|
|
6162
|
-
const roots = [];
|
|
6163
|
-
if (r === "shadow") {
|
|
6164
|
-
if (this.shadowRoot) roots.push(this.shadowRoot);
|
|
6165
|
-
} else if (r === "light") {
|
|
6166
|
-
roots.push(this);
|
|
6167
|
-
} else if (r === "all") {
|
|
6168
|
-
roots.push(this);
|
|
6169
|
-
if (this.shadowRoot) roots.push(this.shadowRoot);
|
|
6170
|
-
} else {
|
|
6171
|
-
roots.push(this.shadowRoot || this);
|
|
6172
|
-
}
|
|
6173
|
-
roots.forEach((root) => targetEls.push(...root.querySelectorAll(selector)));
|
|
6174
|
-
}
|
|
6175
|
-
targetEls.forEach((targetEl) => {
|
|
6176
|
-
if (!targetEl || typeof targetEl.setAttribute !== "function") return;
|
|
6177
|
-
if (res === null) targetEl.removeAttribute(name);
|
|
6178
|
-
else targetEl.setAttribute(name, String(res));
|
|
6179
|
-
});
|
|
6180
|
-
}
|
|
6181
|
-
return res;
|
|
6182
|
-
};
|
|
6183
|
-
};
|
|
6184
|
-
}
|
|
6185
|
-
var getSetAttributeMetadata = (target) => {
|
|
6186
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
6187
|
-
return ReflectUtils.getMetadata(SET_ATTRIBUTE_METADATA_KEY, constructor);
|
|
6188
|
-
};
|
|
6189
|
-
var findAllSetAttributeMetadata = (target) => {
|
|
6190
|
-
const result = /* @__PURE__ */ new Map();
|
|
6191
|
-
const maps = ReflectUtils.findAllMetadata(SET_ATTRIBUTE_METADATA_KEY, target);
|
|
6192
|
-
maps.forEach((map) => {
|
|
6193
|
-
if (map instanceof Map) {
|
|
6194
|
-
map.forEach((v, k) => result.set(k, v));
|
|
6195
|
-
}
|
|
6196
|
-
});
|
|
6197
|
-
return result;
|
|
6198
|
-
};
|
|
6199
|
-
function setAttributeHost(name, options) {
|
|
6200
|
-
return setAttribute(":host", name, options);
|
|
6201
|
-
}
|
|
6202
|
-
|
|
6203
6488
|
// src/decorators/applyNode.ts
|
|
6204
|
-
var APPLY_NODE_METADATA_KEY = Symbol("simple-web-component:apply-node");
|
|
6489
|
+
var APPLY_NODE_METADATA_KEY = Symbol.for("simple-web-component:apply-node");
|
|
6205
6490
|
var normalizeNodes = (res, doc) => {
|
|
6206
6491
|
const items = Array.isArray(res) ? res : [res];
|
|
6207
6492
|
return items.map((it) => {
|
|
6208
|
-
if (it instanceof Node)
|
|
6209
|
-
return it;
|
|
6493
|
+
if (it instanceof Node) return it;
|
|
6210
6494
|
return doc.createTextNode(it !== void 0 && it !== null ? String(it) : "");
|
|
6211
6495
|
});
|
|
6212
6496
|
};
|
|
6497
|
+
var applyToDom = (targetEl, res, pos, doc) => {
|
|
6498
|
+
if (!targetEl) return;
|
|
6499
|
+
if (pos === "innerHtml") {
|
|
6500
|
+
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
6501
|
+
return;
|
|
6502
|
+
}
|
|
6503
|
+
if (pos === "innerText") {
|
|
6504
|
+
if (targetEl.innerText !== void 0) {
|
|
6505
|
+
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
6506
|
+
}
|
|
6507
|
+
return;
|
|
6508
|
+
}
|
|
6509
|
+
const isShadowRoot = targetEl instanceof ShadowRoot;
|
|
6510
|
+
const nodes = normalizeNodes(res, doc);
|
|
6511
|
+
if (pos === "replace") {
|
|
6512
|
+
if (!isShadowRoot) targetEl.replaceWith(...nodes);
|
|
6513
|
+
} else if (pos === "replaceChildren") {
|
|
6514
|
+
targetEl.replaceChildren(...nodes);
|
|
6515
|
+
} else {
|
|
6516
|
+
if (pos === "beforeEnd") targetEl.append(...nodes);
|
|
6517
|
+
else if (pos === "afterBegin") targetEl.prepend(...nodes);
|
|
6518
|
+
else if (pos === "beforeBegin" && !isShadowRoot) targetEl.before(...nodes);
|
|
6519
|
+
else if (pos === "afterEnd" && !isShadowRoot) targetEl.after(...nodes);
|
|
6520
|
+
}
|
|
6521
|
+
};
|
|
6213
6522
|
function applyNode(selector, options = { position: "beforeEnd" }) {
|
|
6214
|
-
return (
|
|
6215
|
-
const constructor =
|
|
6523
|
+
return (targetObj, propertyKey, descriptor) => {
|
|
6524
|
+
const constructor = targetObj.constructor;
|
|
6216
6525
|
let metaList = ReflectUtils.getOwnMetadata(APPLY_NODE_METADATA_KEY, constructor);
|
|
6217
6526
|
if (!metaList) {
|
|
6218
6527
|
metaList = /* @__PURE__ */ new Map();
|
|
@@ -6220,94 +6529,58 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6220
6529
|
}
|
|
6221
6530
|
metaList.set(propertyKey, { propertyKey, selector, options });
|
|
6222
6531
|
const original = descriptor.value;
|
|
6223
|
-
descriptor.value =
|
|
6532
|
+
descriptor.value = function(...args) {
|
|
6224
6533
|
ensureInit2(this);
|
|
6225
|
-
const
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
const pos = options.position || "beforeEnd";
|
|
6534
|
+
const conf = getElementConfig(this);
|
|
6535
|
+
const currentWin = this._resolveWindow?.(conf) || (typeof window !== "undefined" ? window : void 0);
|
|
6536
|
+
const currentDoc = currentWin.document;
|
|
6537
|
+
const hostSet = SwcUtils.getHelperAndHostSet(currentWin, this);
|
|
6538
|
+
const getTarget = () => {
|
|
6231
6539
|
const r = options.root || "auto";
|
|
6232
6540
|
const applyRoot = (t) => {
|
|
6233
|
-
if (!t
|
|
6234
|
-
|
|
6235
|
-
if (r === "
|
|
6236
|
-
|
|
6237
|
-
if (r === "
|
|
6238
|
-
return t.shadowRoot;
|
|
6239
|
-
if (r === "light")
|
|
6240
|
-
return t;
|
|
6241
|
-
if (r === "all")
|
|
6242
|
-
return t.shadowRoot || t;
|
|
6541
|
+
if (!t) return t;
|
|
6542
|
+
if (r === "auto") return t.shadowRoot || t;
|
|
6543
|
+
if (r === "shadow") return t.shadowRoot;
|
|
6544
|
+
if (r === "light") return t;
|
|
6545
|
+
if (r === "all") return t.shadowRoot || t;
|
|
6243
6546
|
return t;
|
|
6244
6547
|
};
|
|
6245
|
-
|
|
6246
|
-
if (
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
}
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
} else if (selector === ":parentHost") {
|
|
6267
|
-
targetEl = applyRoot(hostSet.$parentHost);
|
|
6268
|
-
} else if (selector === ":appHost") {
|
|
6269
|
-
targetEl = applyRoot(hostSet.$appHost);
|
|
6270
|
-
} else if (selector === ":firstHost") {
|
|
6271
|
-
targetEl = applyRoot(hostSet.$firstHost);
|
|
6272
|
-
} else if (selector === ":lastHost") {
|
|
6273
|
-
targetEl = applyRoot(hostSet.$lastHost);
|
|
6274
|
-
} else if (selector === ":firstAppHost") {
|
|
6275
|
-
targetEl = applyRoot(hostSet.$firstHost);
|
|
6276
|
-
} else if (selector === ":lastAppHost") {
|
|
6277
|
-
targetEl = applyRoot(hostSet.$lastAppHost);
|
|
6278
|
-
} else {
|
|
6279
|
-
const targetRoot = applyRoot(this);
|
|
6280
|
-
targetEl = targetRoot ? targetRoot.querySelector(selector) : null;
|
|
6281
|
-
}
|
|
6282
|
-
if (targetEl) {
|
|
6283
|
-
const isShadowRoot = targetEl instanceof ShadowRoot;
|
|
6284
|
-
const nodes = normalizeNodes(res, currentDoc);
|
|
6285
|
-
if (pos === "replace") {
|
|
6286
|
-
if (!isShadowRoot) {
|
|
6287
|
-
targetEl.replaceWith(...nodes);
|
|
6288
|
-
}
|
|
6289
|
-
} else if (pos === "replaceChildren") {
|
|
6290
|
-
targetEl.replaceChildren(...nodes);
|
|
6291
|
-
} else if (pos === "innerHtml") {
|
|
6292
|
-
targetEl.innerHTML = res !== void 0 && res !== null ? String(res) : "";
|
|
6293
|
-
} else if (pos === "innerText") {
|
|
6294
|
-
if (targetEl.innerText !== void 0) {
|
|
6295
|
-
targetEl.innerText = res !== void 0 && res !== null ? String(res) : "";
|
|
6296
|
-
}
|
|
6297
|
-
} else {
|
|
6298
|
-
if (pos === "beforeEnd")
|
|
6299
|
-
targetEl.append(...nodes);
|
|
6300
|
-
else if (pos === "afterBegin")
|
|
6301
|
-
targetEl.prepend(...nodes);
|
|
6302
|
-
else if (pos === "beforeBegin" && !isShadowRoot)
|
|
6303
|
-
targetEl.before(...nodes);
|
|
6304
|
-
else if (pos === "afterEnd" && !isShadowRoot)
|
|
6305
|
-
targetEl.after(...nodes);
|
|
6306
|
-
}
|
|
6307
|
-
}
|
|
6548
|
+
if (selector === ":host") return applyRoot(this);
|
|
6549
|
+
if (selector === ":parentHost") return applyRoot(hostSet.$parentHost);
|
|
6550
|
+
if (selector === ":appHost") return applyRoot(hostSet.$appHost);
|
|
6551
|
+
if (selector === ":firstHost") return applyRoot(hostSet.$firstHost);
|
|
6552
|
+
if (selector === ":lastHost") return applyRoot(hostSet.$lastHost);
|
|
6553
|
+
const targetRoot = applyRoot(this);
|
|
6554
|
+
return targetRoot ? targetRoot.querySelector(selector) : null;
|
|
6555
|
+
};
|
|
6556
|
+
const targetEl = getTarget();
|
|
6557
|
+
const res = original.apply(this, args);
|
|
6558
|
+
const runApply = (target, val) => {
|
|
6559
|
+
const pos = options.position || "beforeEnd";
|
|
6560
|
+
const defaultFilter = (t, v) => {
|
|
6561
|
+
if (v instanceof Node) return !t.contains(v);
|
|
6562
|
+
if (pos === "innerHtml" && typeof v === "string") return t.innerHTML !== v;
|
|
6563
|
+
if (pos === "replaceChildren" && v instanceof Node) return !t.contains(v);
|
|
6564
|
+
return true;
|
|
6565
|
+
};
|
|
6566
|
+
const activeFilter = options.filter || defaultFilter;
|
|
6567
|
+
if (activeFilter(target, val, hostSet)) {
|
|
6568
|
+
applyToDom(target, val, pos, currentDoc);
|
|
6308
6569
|
}
|
|
6570
|
+
};
|
|
6571
|
+
if (res instanceof Promise) {
|
|
6572
|
+
if (targetEl && options.loading) {
|
|
6573
|
+
const loadingRes = options.loading.call(this, hostSet);
|
|
6574
|
+
applyToDom(targetEl, loadingRes, options.position || "beforeEnd", currentDoc);
|
|
6575
|
+
}
|
|
6576
|
+
return res.then((finalRes) => {
|
|
6577
|
+
if (finalRes !== void 0 && targetEl) runApply(targetEl, finalRes);
|
|
6578
|
+
return finalRes;
|
|
6579
|
+
});
|
|
6580
|
+
} else {
|
|
6581
|
+
if (res !== void 0 && targetEl) runApply(targetEl, res);
|
|
6582
|
+
return res;
|
|
6309
6583
|
}
|
|
6310
|
-
return res;
|
|
6311
6584
|
};
|
|
6312
6585
|
};
|
|
6313
6586
|
}
|
|
@@ -6322,110 +6595,29 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6322
6595
|
return result;
|
|
6323
6596
|
};
|
|
6324
6597
|
function applyNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
}
|
|
6329
|
-
if (typeof targetOrOptions === "object" && targetOrOptions !== null) {
|
|
6330
|
-
const options = targetOrOptions;
|
|
6331
|
-
return applyNode(":host", { ...options, position: options.position || "beforeEnd" });
|
|
6332
|
-
} else {
|
|
6333
|
-
return applyNode(":host", { position: "beforeEnd" });
|
|
6334
|
-
}
|
|
6335
|
-
}
|
|
6336
|
-
function applyBeforeBeginNode(selector, options) {
|
|
6337
|
-
return applyNode(selector, { ...options, position: "beforeBegin" });
|
|
6338
|
-
}
|
|
6339
|
-
function applyAfterBeginNode(selector, options) {
|
|
6340
|
-
return applyNode(selector, { ...options, position: "afterBegin" });
|
|
6598
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "beforeEnd" })(targetOrOptions, propertyKey, descriptor);
|
|
6599
|
+
const opt = targetOrOptions || {};
|
|
6600
|
+
return applyNode(":host", { position: "beforeEnd", ...opt });
|
|
6341
6601
|
}
|
|
6342
|
-
function
|
|
6343
|
-
return applyNode(
|
|
6602
|
+
function applyReplaceChildrenNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6603
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "replaceChildren" })(targetOrOptions, propertyKey, descriptor);
|
|
6604
|
+
const opt = targetOrOptions || {};
|
|
6605
|
+
return applyNode(":host", { position: "replaceChildren", ...opt });
|
|
6344
6606
|
}
|
|
6345
|
-
function
|
|
6346
|
-
return applyNode(
|
|
6607
|
+
function applyInnerHtmlNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6608
|
+
if (propertyKey !== void 0) return applyNode(":host", { position: "innerHtml" })(targetOrOptions, propertyKey, descriptor);
|
|
6609
|
+
const opt = targetOrOptions || {};
|
|
6610
|
+
return applyNode(":host", { position: "innerHtml", ...opt });
|
|
6347
6611
|
}
|
|
6348
|
-
function
|
|
6349
|
-
return applyNode(selector, { ...options, position: "replace" });
|
|
6350
|
-
}
|
|
6351
|
-
function applyReplaceChildrenNode(selector, options) {
|
|
6612
|
+
function applyReplaceChildrenNode(selector, options = {}) {
|
|
6352
6613
|
return applyNode(selector, { ...options, position: "replaceChildren" });
|
|
6353
6614
|
}
|
|
6354
|
-
function applyInnerHtmlNode(selector, options) {
|
|
6615
|
+
function applyInnerHtmlNode(selector, options = {}) {
|
|
6355
6616
|
return applyNode(selector, { ...options, position: "innerHtml" });
|
|
6356
6617
|
}
|
|
6357
|
-
function applyInnerTextNode(selector, options) {
|
|
6358
|
-
return applyNode(selector, { ...options, position: "innerText" });
|
|
6359
|
-
}
|
|
6360
|
-
function applyRemoveNode(selector, options) {
|
|
6361
|
-
return applyNode(selector, { ...options, position: "remove" });
|
|
6362
|
-
}
|
|
6363
|
-
function applyBeforeBeginNodeHost(targetOrOptions, propertyKey, descriptor) {
|
|
6364
|
-
if (propertyKey !== void 0) {
|
|
6365
|
-
const decorator = applyNode(":host", { position: "beforeBegin" });
|
|
6366
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6367
|
-
}
|
|
6368
|
-
return applyNode(":host", { ...targetOrOptions || {}, position: "beforeBegin" });
|
|
6369
|
-
}
|
|
6370
|
-
function applyAfterBeginNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6371
|
-
if (propertyKey !== void 0) {
|
|
6372
|
-
const decorator = applyNode(":host", { position: "afterBegin" });
|
|
6373
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6374
|
-
}
|
|
6375
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "afterBegin" });
|
|
6376
|
-
}
|
|
6377
|
-
function applyBeforeEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6378
|
-
if (propertyKey !== void 0) {
|
|
6379
|
-
const decorator = applyNode(":host", { position: "beforeEnd" });
|
|
6380
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6381
|
-
}
|
|
6382
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "beforeEnd" });
|
|
6383
|
-
}
|
|
6384
|
-
function applyAfterEndNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6385
|
-
if (propertyKey !== void 0) {
|
|
6386
|
-
const decorator = applyNode(":host", { position: "afterEnd" });
|
|
6387
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6388
|
-
}
|
|
6389
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "afterEnd" });
|
|
6390
|
-
}
|
|
6391
|
-
function applyReplaceNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6392
|
-
if (propertyKey !== void 0) {
|
|
6393
|
-
const decorator = applyNode(":host", { position: "replace" });
|
|
6394
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6395
|
-
}
|
|
6396
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "replace" });
|
|
6397
|
-
}
|
|
6398
|
-
function applyReplaceChildrenNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6399
|
-
if (propertyKey !== void 0) {
|
|
6400
|
-
const decorator = applyNode(":host", { position: "replaceChildren" });
|
|
6401
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6402
|
-
}
|
|
6403
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "replaceChildren" });
|
|
6404
|
-
}
|
|
6405
|
-
function applyInnerHtmlNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6406
|
-
if (propertyKey !== void 0) {
|
|
6407
|
-
const decorator = applyNode(":host", { position: "innerHtml" });
|
|
6408
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6409
|
-
}
|
|
6410
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "innerHtml" });
|
|
6411
|
-
}
|
|
6412
|
-
function applyInnerTextNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6413
|
-
if (propertyKey !== void 0) {
|
|
6414
|
-
const decorator = applyNode(":host", { position: "innerText" });
|
|
6415
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6416
|
-
}
|
|
6417
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "innerText" });
|
|
6418
|
-
}
|
|
6419
|
-
function applyRemoveNodeHost(optionsOrTarget, propertyKey, descriptor) {
|
|
6420
|
-
if (propertyKey !== void 0) {
|
|
6421
|
-
const decorator = applyNode(":host", { position: "remove" });
|
|
6422
|
-
return decorator(optionsOrTarget, propertyKey, descriptor);
|
|
6423
|
-
}
|
|
6424
|
-
return applyNode(":host", { ...optionsOrTarget || {}, position: "remove" });
|
|
6425
|
-
}
|
|
6426
6618
|
|
|
6427
6619
|
// src/decorators/query.ts
|
|
6428
|
-
var QUERY_METADATA_KEY = Symbol("simple-web-component:query");
|
|
6620
|
+
var QUERY_METADATA_KEY = Symbol.for("simple-web-component:query");
|
|
6429
6621
|
function query(selectorOrTarget, options = {}) {
|
|
6430
6622
|
return (targetObj, propertyKey, descriptor) => {
|
|
6431
6623
|
if (descriptor !== void 0) {
|
|
@@ -6596,7 +6788,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6596
6788
|
}
|
|
6597
6789
|
|
|
6598
6790
|
// src/decorators/queryAll.ts
|
|
6599
|
-
var QUERY_ALL_METADATA_KEY = Symbol("simple-web-component:query-all");
|
|
6791
|
+
var QUERY_ALL_METADATA_KEY = Symbol.for("simple-web-component:query-all");
|
|
6600
6792
|
function queryAll(selectorOrTarget, options = {}) {
|
|
6601
6793
|
return (targetObj, propertyKey, descriptor) => {
|
|
6602
6794
|
if (descriptor !== void 0) {
|
|
@@ -6763,35 +6955,38 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6763
6955
|
}
|
|
6764
6956
|
}
|
|
6765
6957
|
|
|
6766
|
-
// src/decorators/
|
|
6767
|
-
var
|
|
6768
|
-
function
|
|
6769
|
-
return (selector, options = {}) => {
|
|
6958
|
+
// src/decorators/applyClass.ts
|
|
6959
|
+
var CLASS_METADATA_KEY = Symbol.for("simple-web-component:class");
|
|
6960
|
+
function createClassDecorator(action) {
|
|
6961
|
+
return (selector, classMapOrOptions, options = {}) => {
|
|
6770
6962
|
return (target, propertyKey, descriptor) => {
|
|
6771
6963
|
const constructor = target.constructor;
|
|
6772
|
-
let metaList = ReflectUtils.getOwnMetadata(
|
|
6964
|
+
let metaList = ReflectUtils.getOwnMetadata(CLASS_METADATA_KEY, constructor);
|
|
6773
6965
|
if (!metaList) {
|
|
6774
6966
|
metaList = /* @__PURE__ */ new Map();
|
|
6775
|
-
ReflectUtils.defineMetadata(
|
|
6967
|
+
ReflectUtils.defineMetadata(CLASS_METADATA_KEY, metaList, constructor);
|
|
6776
6968
|
}
|
|
6777
|
-
|
|
6969
|
+
let classMap = void 0;
|
|
6970
|
+
let finalOptions = options;
|
|
6971
|
+
if (typeof classMapOrOptions === "string" || typeof classMapOrOptions === "object" && classMapOrOptions !== null && !("root" in classMapOrOptions)) {
|
|
6972
|
+
classMap = classMapOrOptions;
|
|
6973
|
+
} else if (typeof classMapOrOptions === "object" && classMapOrOptions !== null && "root" in classMapOrOptions) {
|
|
6974
|
+
finalOptions = classMapOrOptions;
|
|
6975
|
+
}
|
|
6976
|
+
metaList.set(propertyKey, { propertyKey, selector, action, options: finalOptions });
|
|
6778
6977
|
const original = descriptor.value;
|
|
6779
6978
|
descriptor.value = async function(...args) {
|
|
6780
6979
|
ensureInit2(this);
|
|
6781
6980
|
const res = await original.apply(this, args);
|
|
6782
6981
|
if (res !== void 0) {
|
|
6783
|
-
const
|
|
6784
|
-
const
|
|
6982
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
6983
|
+
const host2 = this;
|
|
6984
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6985
|
+
const r = finalOptions.root || "auto";
|
|
6785
6986
|
const targetEls = [];
|
|
6786
6987
|
const applyRoot = (t) => {
|
|
6787
|
-
if (!t || !(t instanceof HTMLElement)) return;
|
|
6788
|
-
|
|
6789
|
-
targetEls.push(t);
|
|
6790
|
-
} else {
|
|
6791
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6792
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
6793
|
-
}
|
|
6794
|
-
}
|
|
6988
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
6989
|
+
targetEls.push(t);
|
|
6795
6990
|
};
|
|
6796
6991
|
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6797
6992
|
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
@@ -6801,102 +6996,84 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6801
6996
|
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6802
6997
|
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6803
6998
|
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6804
|
-
else if (selector === ":host" || !selector) applyRoot(
|
|
6999
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6805
7000
|
else {
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
} else if (r === "light") {
|
|
6810
|
-
const found = this.querySelectorAll(selector);
|
|
6811
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6812
|
-
} else if (r === "all") {
|
|
6813
|
-
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
6814
|
-
const lFound = this.querySelectorAll(selector);
|
|
6815
|
-
if (sFound) targetEls.push(...Array.from(sFound));
|
|
6816
|
-
if (lFound) targetEls.push(...Array.from(lFound));
|
|
6817
|
-
} else {
|
|
6818
|
-
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
7001
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
7002
|
+
if (targetRoot) {
|
|
7003
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6819
7004
|
if (found) targetEls.push(...Array.from(found));
|
|
6820
7005
|
}
|
|
6821
7006
|
}
|
|
6822
7007
|
targetEls.forEach((targetEl) => {
|
|
7008
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
6823
7009
|
if (action === "set") {
|
|
6824
7010
|
let classes = "";
|
|
6825
|
-
if (typeof
|
|
6826
|
-
classes =
|
|
7011
|
+
if (classMap && typeof classMap === "string") {
|
|
7012
|
+
classes = resolvedRes ? classMap : "";
|
|
7013
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7014
|
+
classes = Object.entries(resolvedRes).filter(([_, force]) => typeof force === "function" ? force(targetEl, hostSet) : !!force).map(([cls]) => cls).join(" ");
|
|
6827
7015
|
} else {
|
|
6828
|
-
classes = Array.isArray(
|
|
7016
|
+
classes = Array.isArray(resolvedRes) ? resolvedRes.join(" ") : String(resolvedRes);
|
|
6829
7017
|
}
|
|
6830
7018
|
targetEl.className = classes;
|
|
6831
|
-
} else if (action === "update") {
|
|
6832
|
-
if (typeof
|
|
6833
|
-
|
|
6834
|
-
|
|
7019
|
+
} else if (action === "update" || action === "toggle") {
|
|
7020
|
+
if (classMap && typeof classMap === "string") {
|
|
7021
|
+
targetEl.classList.toggle(classMap, !!resolvedRes);
|
|
7022
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7023
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
7024
|
+
const isActive = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
7025
|
+
targetEl.classList.toggle(cls, isActive);
|
|
6835
7026
|
});
|
|
6836
|
-
} else
|
|
6837
|
-
const classes = Array.isArray(
|
|
6838
|
-
targetEl.classList.add(...classes);
|
|
7027
|
+
} else {
|
|
7028
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
7029
|
+
if (action === "update") targetEl.classList.add(...classes);
|
|
7030
|
+
else classes.forEach((c) => targetEl.classList.toggle(c));
|
|
7031
|
+
}
|
|
7032
|
+
} else if (action === "add" || action === "remove") {
|
|
7033
|
+
if (classMap && typeof classMap === "string" && !!resolvedRes) {
|
|
7034
|
+
if (action === "add") targetEl.classList.add(classMap);
|
|
7035
|
+
else targetEl.classList.remove(classMap);
|
|
7036
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7037
|
+
Object.entries(resolvedRes).forEach(([cls, force]) => {
|
|
7038
|
+
const shouldExecute = typeof force === "function" ? force(targetEl, hostSet) : !!force;
|
|
7039
|
+
if (shouldExecute) {
|
|
7040
|
+
if (action === "add") targetEl.classList.add(cls);
|
|
7041
|
+
else targetEl.classList.remove(cls);
|
|
7042
|
+
}
|
|
7043
|
+
});
|
|
7044
|
+
} else {
|
|
7045
|
+
const classes = Array.isArray(resolvedRes) ? resolvedRes.map(String) : [String(resolvedRes)];
|
|
7046
|
+
if (action === "add") targetEl.classList.add(...classes);
|
|
7047
|
+
else targetEl.classList.remove(...classes);
|
|
6839
7048
|
}
|
|
6840
|
-
} else if (action === "add") {
|
|
6841
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6842
|
-
targetEl.classList.add(...classes);
|
|
6843
|
-
} else if (action === "remove") {
|
|
6844
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6845
|
-
targetEl.classList.remove(...classes);
|
|
6846
|
-
} else if (action === "toggle") {
|
|
6847
|
-
const classes = Array.isArray(res) ? res.map(String) : [String(res)];
|
|
6848
|
-
classes.forEach((c) => targetEl.classList.toggle(c));
|
|
6849
7049
|
}
|
|
6850
7050
|
});
|
|
6851
7051
|
}
|
|
6852
7052
|
return res;
|
|
6853
7053
|
};
|
|
7054
|
+
return descriptor;
|
|
6854
7055
|
};
|
|
6855
7056
|
};
|
|
6856
7057
|
}
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
var addClassList = (selector, options = {}) => createClassListDecorator("add")(selector, options);
|
|
6860
|
-
var removeClassList = (selector, options = {}) => createClassListDecorator("remove")(selector, options);
|
|
6861
|
-
var toggleClassList = (selector, options = {}) => createClassListDecorator("toggle")(selector, options);
|
|
6862
|
-
function setClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6863
|
-
if (propertyKey !== void 0) {
|
|
6864
|
-
const decorator = createClassListDecorator("set")(":host", {});
|
|
6865
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6866
|
-
}
|
|
6867
|
-
return createClassListDecorator("set")(":host", targetOrOptions || {});
|
|
7058
|
+
function applyClass(selector, action = "update", options = {}) {
|
|
7059
|
+
return createClassDecorator(action)(selector, options);
|
|
6868
7060
|
}
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
7061
|
+
var setClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("set")(selector, classMapOrOptions, options);
|
|
7062
|
+
var updateClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("update")(selector, classMapOrOptions, options);
|
|
7063
|
+
var addClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("add")(selector, classMapOrOptions, options);
|
|
7064
|
+
var removeClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("remove")(selector, classMapOrOptions, options);
|
|
7065
|
+
var toggleClass = (selector, classMapOrOptions, options = {}) => createClassDecorator("toggle")(selector, classMapOrOptions, options);
|
|
7066
|
+
function applyClassHost(action = "update", options = {}) {
|
|
7067
|
+
return createClassDecorator(action)(":host", options);
|
|
6875
7068
|
}
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
}
|
|
6883
|
-
function removeClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6884
|
-
if (propertyKey !== void 0) {
|
|
6885
|
-
const decorator = createClassListDecorator("remove")(":host", {});
|
|
6886
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6887
|
-
}
|
|
6888
|
-
return createClassListDecorator("remove")(":host", targetOrOptions || {});
|
|
6889
|
-
}
|
|
6890
|
-
function toggleClassListHost(targetOrOptions, propertyKey, descriptor) {
|
|
6891
|
-
if (propertyKey !== void 0) {
|
|
6892
|
-
const decorator = createClassListDecorator("toggle")(":host", {});
|
|
6893
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6894
|
-
}
|
|
6895
|
-
return createClassListDecorator("toggle")(":host", targetOrOptions || {});
|
|
6896
|
-
}
|
|
6897
|
-
var findAllClassListMetadata = (target) => {
|
|
7069
|
+
var setClassHost = (classMapOrOptions, options = {}) => createClassDecorator("set")(":host", classMapOrOptions, options);
|
|
7070
|
+
var updateClassHost = (classMapOrOptions, options = {}) => createClassDecorator("update")(":host", classMapOrOptions, options);
|
|
7071
|
+
var addClassHost = (classMapOrOptions, options = {}) => createClassDecorator("add")(":host", classMapOrOptions, options);
|
|
7072
|
+
var removeClassHost = (classMapOrOptions, options = {}) => createClassDecorator("remove")(":host", classMapOrOptions, options);
|
|
7073
|
+
var toggleClassHost = (classMapOrOptions, options = {}) => createClassDecorator("toggle")(":host", classMapOrOptions, options);
|
|
7074
|
+
var findAllClassMetadata = (target) => {
|
|
6898
7075
|
const result = /* @__PURE__ */ new Map();
|
|
6899
|
-
const maps = ReflectUtils.findAllMetadata(
|
|
7076
|
+
const maps = ReflectUtils.findAllMetadata(CLASS_METADATA_KEY, target);
|
|
6900
7077
|
maps.forEach((map) => {
|
|
6901
7078
|
if (map instanceof Map) {
|
|
6902
7079
|
map.forEach((v, k) => result.set(k, v));
|
|
@@ -6905,8 +7082,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6905
7082
|
return result;
|
|
6906
7083
|
};
|
|
6907
7084
|
|
|
6908
|
-
// src/decorators/
|
|
6909
|
-
var STYLE_METADATA_KEY = Symbol("simple-web-component:style");
|
|
7085
|
+
// src/decorators/applyStyle.ts
|
|
7086
|
+
var STYLE_METADATA_KEY = Symbol.for("simple-web-component:style");
|
|
6910
7087
|
function createStyleDecorator(action) {
|
|
6911
7088
|
return (selector, options = {}) => {
|
|
6912
7089
|
return (target, propertyKey, descriptor) => {
|
|
@@ -6922,18 +7099,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6922
7099
|
ensureInit2(this);
|
|
6923
7100
|
const res = await original.apply(this, args);
|
|
6924
7101
|
if (res !== void 0) {
|
|
7102
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
7103
|
+
const host2 = this;
|
|
7104
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
6925
7105
|
const r = options.root || "auto";
|
|
6926
|
-
const hostSet = SwcUtils.getHostSet(this);
|
|
6927
7106
|
const targetEls = [];
|
|
6928
7107
|
const applyRoot = (t) => {
|
|
6929
|
-
if (!t || !(t instanceof HTMLElement)) return;
|
|
6930
|
-
|
|
6931
|
-
targetEls.push(t);
|
|
6932
|
-
} else {
|
|
6933
|
-
if (r === "light" || r === "all") targetEls.push(t);
|
|
6934
|
-
if ((r === "shadow" || r === "all") && t.shadowRoot) {
|
|
6935
|
-
}
|
|
6936
|
-
}
|
|
7108
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
7109
|
+
targetEls.push(t);
|
|
6937
7110
|
};
|
|
6938
7111
|
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
6939
7112
|
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
@@ -6943,71 +7116,63 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6943
7116
|
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
6944
7117
|
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
6945
7118
|
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
6946
|
-
else if (selector === ":host" || !selector) applyRoot(
|
|
7119
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
6947
7120
|
else {
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
} else if (r === "light") {
|
|
6952
|
-
const found = this.querySelectorAll(selector);
|
|
6953
|
-
if (found) targetEls.push(...Array.from(found));
|
|
6954
|
-
} else if (r === "all") {
|
|
6955
|
-
const sFound = this.shadowRoot?.querySelectorAll(selector);
|
|
6956
|
-
const lFound = this.querySelectorAll(selector);
|
|
6957
|
-
if (sFound) targetEls.push(...Array.from(sFound));
|
|
6958
|
-
if (lFound) targetEls.push(...Array.from(lFound));
|
|
6959
|
-
} else {
|
|
6960
|
-
const found = (this.shadowRoot || this).querySelectorAll(selector);
|
|
7121
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
7122
|
+
if (targetRoot) {
|
|
7123
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
6961
7124
|
if (found) targetEls.push(...Array.from(found));
|
|
6962
7125
|
}
|
|
6963
7126
|
}
|
|
6964
7127
|
targetEls.forEach((targetEl) => {
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
if (
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
7128
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
7129
|
+
if (action === "set" || action === "update") {
|
|
7130
|
+
if (action === "set") targetEl.style.cssText = "";
|
|
7131
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7132
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
7133
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
7134
|
+
if (finalVal === null || finalVal === void 0) {
|
|
7135
|
+
targetEl.style.removeProperty(prop);
|
|
7136
|
+
} else {
|
|
7137
|
+
targetEl.style[prop] = String(finalVal);
|
|
7138
|
+
}
|
|
7139
|
+
});
|
|
7140
|
+
} else if (typeof resolvedRes === "string") {
|
|
7141
|
+
targetEl.style.cssText = resolvedRes;
|
|
6975
7142
|
}
|
|
6976
7143
|
} else if (action === "remove") {
|
|
6977
|
-
|
|
6978
|
-
|
|
7144
|
+
if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7145
|
+
Object.entries(resolvedRes).forEach(([prop, val]) => {
|
|
7146
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
7147
|
+
if (shouldRemove) {
|
|
7148
|
+
targetEl.style.removeProperty(prop);
|
|
7149
|
+
}
|
|
7150
|
+
});
|
|
7151
|
+
} else {
|
|
7152
|
+
const props = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
7153
|
+
props.forEach((p) => targetEl.style.removeProperty(String(p)));
|
|
7154
|
+
}
|
|
6979
7155
|
}
|
|
6980
7156
|
});
|
|
6981
7157
|
}
|
|
6982
7158
|
return res;
|
|
6983
7159
|
};
|
|
7160
|
+
return descriptor;
|
|
6984
7161
|
};
|
|
6985
7162
|
};
|
|
6986
7163
|
}
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
if (propertyKey !== void 0) {
|
|
6990
|
-
const decorator = createStyleDecorator("set")(":host", {});
|
|
6991
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
6992
|
-
}
|
|
6993
|
-
return createStyleDecorator("set")(":host", targetOrOptions || {});
|
|
7164
|
+
function applyStyle(selector, action = "update", options = {}) {
|
|
7165
|
+
return createStyleDecorator(action)(selector, options);
|
|
6994
7166
|
}
|
|
7167
|
+
var setStyle = (selector, options = {}) => createStyleDecorator("set")(selector, options);
|
|
6995
7168
|
var updateStyle = (selector, options = {}) => createStyleDecorator("update")(selector, options);
|
|
6996
|
-
function updateStyleHost(targetOrOptions, propertyKey, descriptor) {
|
|
6997
|
-
if (propertyKey !== void 0) {
|
|
6998
|
-
const decorator = createStyleDecorator("update")(":host", {});
|
|
6999
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
7000
|
-
}
|
|
7001
|
-
return createStyleDecorator("update")(":host", targetOrOptions || {});
|
|
7002
|
-
}
|
|
7003
7169
|
var removeStyle = (selector, options = {}) => createStyleDecorator("remove")(selector, options);
|
|
7004
|
-
function
|
|
7005
|
-
|
|
7006
|
-
const decorator = createStyleDecorator("remove")(":host", {});
|
|
7007
|
-
return decorator(targetOrOptions, propertyKey, descriptor);
|
|
7008
|
-
}
|
|
7009
|
-
return createStyleDecorator("remove")(":host", targetOrOptions || {});
|
|
7170
|
+
function applyStyleHost(action = "update", options = {}) {
|
|
7171
|
+
return createStyleDecorator(action)(":host", options);
|
|
7010
7172
|
}
|
|
7173
|
+
var setStyleHost = (options = {}) => createStyleDecorator("set")(":host", options);
|
|
7174
|
+
var updateStyleHost = (options = {}) => createStyleDecorator("update")(":host", options);
|
|
7175
|
+
var removeStyleHost = (options = {}) => createStyleDecorator("remove")(":host", options);
|
|
7011
7176
|
var findAllStyleMetadata = (target) => {
|
|
7012
7177
|
const result = /* @__PURE__ */ new Map();
|
|
7013
7178
|
const maps = ReflectUtils.findAllMetadata(STYLE_METADATA_KEY, target);
|
|
@@ -7019,8 +7184,123 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7019
7184
|
return result;
|
|
7020
7185
|
};
|
|
7021
7186
|
|
|
7187
|
+
// src/decorators/applyAttribute.ts
|
|
7188
|
+
var ATTRIBUTE_APPLY_METADATA_KEY = Symbol.for("simple-web-component:attribute-apply");
|
|
7189
|
+
function createAttributeDecorator(action) {
|
|
7190
|
+
return (selector, nameOrOptions, options = {}) => {
|
|
7191
|
+
return (target, propertyKey, descriptor) => {
|
|
7192
|
+
const constructor = target.constructor;
|
|
7193
|
+
let metaList = ReflectUtils.getOwnMetadata(ATTRIBUTE_APPLY_METADATA_KEY, constructor);
|
|
7194
|
+
if (!metaList) {
|
|
7195
|
+
metaList = /* @__PURE__ */ new Map();
|
|
7196
|
+
ReflectUtils.defineMetadata(ATTRIBUTE_APPLY_METADATA_KEY, metaList, constructor);
|
|
7197
|
+
}
|
|
7198
|
+
let attributeName = typeof nameOrOptions === "string" ? nameOrOptions : void 0;
|
|
7199
|
+
let finalOptions = options;
|
|
7200
|
+
if (typeof nameOrOptions === "object" && nameOrOptions !== null) {
|
|
7201
|
+
finalOptions = nameOrOptions;
|
|
7202
|
+
}
|
|
7203
|
+
metaList.set(propertyKey, {
|
|
7204
|
+
propertyKey,
|
|
7205
|
+
selector,
|
|
7206
|
+
action,
|
|
7207
|
+
options: { ...finalOptions, name: attributeName }
|
|
7208
|
+
});
|
|
7209
|
+
const original = descriptor.value;
|
|
7210
|
+
descriptor.value = async function(...args) {
|
|
7211
|
+
ensureInit2(this);
|
|
7212
|
+
const res = await original.apply(this, args);
|
|
7213
|
+
if (res !== void 0) {
|
|
7214
|
+
const win = this.ownerDocument?.defaultView || window;
|
|
7215
|
+
const host2 = this;
|
|
7216
|
+
const hostSet = { ...SwcUtils.getHelperAndHostSet(win, host2), $this: this };
|
|
7217
|
+
const r = finalOptions.root || "auto";
|
|
7218
|
+
const targetEls = [];
|
|
7219
|
+
const applyRoot = (t) => {
|
|
7220
|
+
if (!t || !(t instanceof win.HTMLElement)) return;
|
|
7221
|
+
targetEls.push(t);
|
|
7222
|
+
};
|
|
7223
|
+
if (selector === ":parentHost") applyRoot(hostSet.$parentHost);
|
|
7224
|
+
else if (selector === ":appHost") applyRoot(hostSet.$appHost);
|
|
7225
|
+
else if (selector === ":firstHost") applyRoot(hostSet.$firstHost);
|
|
7226
|
+
else if (selector === ":lastHost") applyRoot(hostSet.$lastHost);
|
|
7227
|
+
else if (selector === ":firstAppHost") applyRoot(hostSet.$firstAppHost);
|
|
7228
|
+
else if (selector === ":lastAppHost") applyRoot(hostSet.$lastAppHost);
|
|
7229
|
+
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRoot);
|
|
7230
|
+
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRoot);
|
|
7231
|
+
else if (selector === ":host" || !selector) applyRoot(host2);
|
|
7232
|
+
else {
|
|
7233
|
+
const targetRoot = r === "auto" ? host2.shadowRoot || host2 : r === "shadow" ? host2.shadowRoot : host2;
|
|
7234
|
+
if (targetRoot) {
|
|
7235
|
+
const found = targetRoot.querySelectorAll(selector);
|
|
7236
|
+
if (found) targetEls.push(...Array.from(found));
|
|
7237
|
+
}
|
|
7238
|
+
}
|
|
7239
|
+
targetEls.forEach((targetEl) => {
|
|
7240
|
+
const resolvedRes = typeof res === "function" ? res(targetEl, hostSet) : res;
|
|
7241
|
+
if (action === "set" || action === "update") {
|
|
7242
|
+
if (attributeName) {
|
|
7243
|
+
if (resolvedRes === null || resolvedRes === void 0 || resolvedRes === false) {
|
|
7244
|
+
targetEl.removeAttribute(attributeName);
|
|
7245
|
+
} else {
|
|
7246
|
+
targetEl.setAttribute(attributeName, resolvedRes === true ? "" : String(resolvedRes));
|
|
7247
|
+
}
|
|
7248
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7249
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
7250
|
+
const finalVal = typeof val === "function" ? val(targetEl, hostSet) : val;
|
|
7251
|
+
if (finalVal === null || finalVal === void 0 || finalVal === false) {
|
|
7252
|
+
targetEl.removeAttribute(attr);
|
|
7253
|
+
} else {
|
|
7254
|
+
targetEl.setAttribute(attr, finalVal === true ? "" : String(finalVal));
|
|
7255
|
+
}
|
|
7256
|
+
});
|
|
7257
|
+
}
|
|
7258
|
+
} else if (action === "remove") {
|
|
7259
|
+
if (attributeName) {
|
|
7260
|
+
targetEl.removeAttribute(attributeName);
|
|
7261
|
+
} else if (typeof resolvedRes === "object" && resolvedRes !== null && !Array.isArray(resolvedRes)) {
|
|
7262
|
+
Object.entries(resolvedRes).forEach(([attr, val]) => {
|
|
7263
|
+
const shouldRemove = typeof val === "function" ? val(targetEl, hostSet) : !!val;
|
|
7264
|
+
if (shouldRemove) targetEl.removeAttribute(attr);
|
|
7265
|
+
});
|
|
7266
|
+
} else {
|
|
7267
|
+
const attrs = Array.isArray(resolvedRes) ? resolvedRes : [resolvedRes];
|
|
7268
|
+
attrs.forEach((a) => targetEl.removeAttribute(String(a)));
|
|
7269
|
+
}
|
|
7270
|
+
}
|
|
7271
|
+
});
|
|
7272
|
+
}
|
|
7273
|
+
return res;
|
|
7274
|
+
};
|
|
7275
|
+
return descriptor;
|
|
7276
|
+
};
|
|
7277
|
+
};
|
|
7278
|
+
}
|
|
7279
|
+
function applyAttribute(selector, action = "update", options = {}) {
|
|
7280
|
+
return createAttributeDecorator(action)(selector, options);
|
|
7281
|
+
}
|
|
7282
|
+
var setAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("set")(selector, nameOrOptions, options);
|
|
7283
|
+
var updateAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("update")(selector, nameOrOptions, options);
|
|
7284
|
+
var removeAttribute = (selector, nameOrOptions, options = {}) => createAttributeDecorator("remove")(selector, nameOrOptions, options);
|
|
7285
|
+
function applyAttributeHost(action = "update", options = {}) {
|
|
7286
|
+
return createAttributeDecorator(action)(":host", options);
|
|
7287
|
+
}
|
|
7288
|
+
var setAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("set")(":host", nameOrOptions, options);
|
|
7289
|
+
var updateAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("update")(":host", nameOrOptions, options);
|
|
7290
|
+
var removeAttributeHost = (nameOrOptions, options = {}) => createAttributeDecorator("remove")(":host", nameOrOptions, options);
|
|
7291
|
+
var findAllAttributeApplyMetadata = (target) => {
|
|
7292
|
+
const result = /* @__PURE__ */ new Map();
|
|
7293
|
+
const maps = ReflectUtils.findAllMetadata(ATTRIBUTE_APPLY_METADATA_KEY, target);
|
|
7294
|
+
maps.forEach((map) => {
|
|
7295
|
+
if (map instanceof Map) {
|
|
7296
|
+
map.forEach((v, k) => result.set(k, v));
|
|
7297
|
+
}
|
|
7298
|
+
});
|
|
7299
|
+
return result;
|
|
7300
|
+
};
|
|
7301
|
+
|
|
7022
7302
|
// src/utils/Utils.ts
|
|
7023
|
-
var SWC_NOT_FOUND = Symbol("
|
|
7303
|
+
var SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
|
|
7024
7304
|
var htmlFragment = (html, doc) => {
|
|
7025
7305
|
const d = doc || (typeof document !== "undefined" ? document : void 0);
|
|
7026
7306
|
if (!d) throw new Error("Document is not available");
|
|
@@ -7257,7 +7537,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7257
7537
|
})(SwcUtils || (SwcUtils = {}));
|
|
7258
7538
|
|
|
7259
7539
|
// src/decorators/emitCustomEvent.ts
|
|
7260
|
-
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol("simple-web-component:emit-custom-event");
|
|
7540
|
+
var EMIT_CUSTOM_EVENT_METADATA_KEY = Symbol.for("simple-web-component:emit-custom-event");
|
|
7261
7541
|
function emitCustomEvent(selectorOrTarget, type, options = {}) {
|
|
7262
7542
|
return (targetObj, propertyKey, descriptor) => {
|
|
7263
7543
|
const constructor = targetObj.constructor;
|
|
@@ -7326,7 +7606,10 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7326
7606
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
7327
7607
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
7328
7608
|
};
|
|
7329
|
-
function emitCustomEventHost(type, options) {
|
|
7609
|
+
function emitCustomEventHost(type, options = {}) {
|
|
7610
|
+
if (!options.attributeName) {
|
|
7611
|
+
options.attributeName = `on-emit-${type}`;
|
|
7612
|
+
}
|
|
7330
7613
|
return emitCustomEvent(":host", type, options);
|
|
7331
7614
|
}
|
|
7332
7615
|
|
|
@@ -7418,7 +7701,46 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7418
7701
|
return this.containers.find(predicate);
|
|
7419
7702
|
}
|
|
7420
7703
|
};
|
|
7704
|
+
var isTargetSymbol = (config) => {
|
|
7705
|
+
return "symbol" in config && config.symbol !== void 0;
|
|
7706
|
+
};
|
|
7707
|
+
var isTargetType = (config) => {
|
|
7708
|
+
return "type" in config && config.type !== void 0;
|
|
7709
|
+
};
|
|
7710
|
+
var isTargetScheme = (config) => {
|
|
7711
|
+
return "scheme" in config && config.scheme !== void 0;
|
|
7712
|
+
};
|
|
7713
|
+
var isTargetFactory = (config) => {
|
|
7714
|
+
return "factory" in config && typeof config.factory === "function" && !("symbol" in config) && !("type" in config) && !("scheme" in config);
|
|
7715
|
+
};
|
|
7421
7716
|
var InjectMetadataKey = Symbol("Inject");
|
|
7717
|
+
var injectProcess = (config, target, propertyKey, parameterIndex) => {
|
|
7718
|
+
if (propertyKey && typeof target === "object") {
|
|
7719
|
+
const otarget = target;
|
|
7720
|
+
target = target.constructor;
|
|
7721
|
+
const saves = Reflect.getOwnMetadata(InjectMetadataKey, target, propertyKey) || [];
|
|
7722
|
+
const type = ReflectUtils.getParameterTypes(otarget, propertyKey)[parameterIndex];
|
|
7723
|
+
saves.push({ index: parameterIndex, config, propertyKey, type });
|
|
7724
|
+
ReflectUtils.defineMetadata(InjectMetadataKey, saves, target, propertyKey);
|
|
7725
|
+
} else if (!propertyKey || typeof target === "function") {
|
|
7726
|
+
const existingInjectdParameters = ReflectUtils.getMetadata(InjectMetadataKey, target) || [];
|
|
7727
|
+
const type = ReflectUtils.getParameterTypes(target)[parameterIndex];
|
|
7728
|
+
existingInjectdParameters.push({ index: parameterIndex, config, type });
|
|
7729
|
+
ReflectUtils.defineMetadata(InjectMetadataKey, existingInjectdParameters, target);
|
|
7730
|
+
}
|
|
7731
|
+
};
|
|
7732
|
+
function Inject(configOrTarget, propertyKey, parameterIndex) {
|
|
7733
|
+
if (propertyKey && parameterIndex !== void 0) {
|
|
7734
|
+
injectProcess({}, configOrTarget, propertyKey, parameterIndex);
|
|
7735
|
+
} else {
|
|
7736
|
+
return (target, propertyKey2, parameterIndex2) => {
|
|
7737
|
+
injectProcess(configOrTarget, target, propertyKey2, parameterIndex2);
|
|
7738
|
+
};
|
|
7739
|
+
}
|
|
7740
|
+
}
|
|
7741
|
+
var getInject = (target, propertyKey) => {
|
|
7742
|
+
return ReflectUtils.findMetadata(InjectMetadataKey, target, propertyKey) ?? [];
|
|
7743
|
+
};
|
|
7422
7744
|
|
|
7423
7745
|
// src/types.ts
|
|
7424
7746
|
var InjectSituationType = /* @__PURE__ */ ((InjectSituationType2) => {
|
|
@@ -7436,7 +7758,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7436
7758
|
})(InjectSituationType || {});
|
|
7437
7759
|
|
|
7438
7760
|
// src/decorators/elementDefine.ts
|
|
7439
|
-
var ELEMENT_CONFIG_KEY = Symbol("simple-web-component:element-config");
|
|
7761
|
+
var ELEMENT_CONFIG_KEY = Symbol.for("simple-web-component:element-config");
|
|
7440
7762
|
var getElementConfig = (target) => {
|
|
7441
7763
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
7442
7764
|
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
@@ -7551,7 +7873,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7551
7873
|
const oldHandler = handlers.get(attrName);
|
|
7552
7874
|
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
7553
7875
|
const handler = async (event) => {
|
|
7554
|
-
console.log("execute handler", event);
|
|
7555
7876
|
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7556
7877
|
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7557
7878
|
const conf = getElementConfig(this);
|
|
@@ -7572,7 +7893,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7572
7893
|
};
|
|
7573
7894
|
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event) {
|
|
7574
7895
|
ensureInit2(this);
|
|
7575
|
-
console.log("execute handler2", event);
|
|
7576
7896
|
const parent = SwcUtils.findNearestSwcHost(el);
|
|
7577
7897
|
const hostSet = SwcUtils.getHostSet(parent || el);
|
|
7578
7898
|
const conf = getElementConfig(this);
|
|
@@ -7612,12 +7932,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7612
7932
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
7613
7933
|
const emitHostCustomEventList = emitCustomEventList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7614
7934
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
7615
|
-
const addHostEventListenerList = addEventListenerList.filter((meta) => meta.selector === ":host" || meta.selector === "");
|
|
7616
7935
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
7617
7936
|
const attributeList = findAllAttributeMetadata(constructor);
|
|
7937
|
+
const applyAttributeMap = findAllAttributeApplyMetadata(constructor);
|
|
7618
7938
|
const swcLifecycleAttributes = ["swc-on-constructor", "swc-on-connected", "swc-on-disconnected", "swc-on-before-connected", "swc-on-after-connected", "swc-on-before-disconnected", "swc-on-after-disconnected", "swc-on-before-adopted", "swc-on-after-adopted", "swc-on-attribute-changed"];
|
|
7619
7939
|
const swcOnEvents = DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
7620
|
-
const
|
|
7940
|
+
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
7941
|
+
const attributeListNames = attributeList.map((it) => it.options.name || String(it.propertyKey));
|
|
7942
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
7943
|
+
...metadata.observedAttributes ?? [],
|
|
7944
|
+
...attrChangeMap.keys(),
|
|
7945
|
+
...attributeApplyNames,
|
|
7946
|
+
...attributeListNames,
|
|
7947
|
+
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
7948
|
+
...swcLifecycleAttributes,
|
|
7949
|
+
...swcOnEvents
|
|
7950
|
+
])];
|
|
7621
7951
|
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
7622
7952
|
const proto = constructor.prototype;
|
|
7623
7953
|
setupPrototype(proto);
|
|
@@ -7636,7 +7966,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7636
7966
|
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
7637
7967
|
}
|
|
7638
7968
|
attributeList.forEach((meta) => {
|
|
7639
|
-
const attrName = meta.options.name || String(meta.propertyKey);
|
|
7640
7969
|
if (meta.options.connectedInitialize === true) {
|
|
7641
7970
|
this.__swc_syncing_init = true;
|
|
7642
7971
|
try {
|
|
@@ -7776,22 +8105,6 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7776
8105
|
}
|
|
7777
8106
|
});
|
|
7778
8107
|
});
|
|
7779
|
-
addHostEventListenerList.forEach((meta) => {
|
|
7780
|
-
const { type, options } = meta;
|
|
7781
|
-
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
7782
|
-
const handler = async (event) => {
|
|
7783
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
7784
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
7785
|
-
if (options.preventDefault) event.preventDefault();
|
|
7786
|
-
const currentHostSet = SwcUtils.getHostSet(this);
|
|
7787
|
-
const args = { event, ...currentHostSet, $el: this, $root: this.getRootNode() };
|
|
7788
|
-
await this[meta.propertyKey](event, currentHostSet, args);
|
|
7789
|
-
};
|
|
7790
|
-
this.addEventListener(type, handler, opts);
|
|
7791
|
-
if (options.removeOnDisconnected === true) {
|
|
7792
|
-
this._boundListeners.push({ target: this, type, handler, options: opts });
|
|
7793
|
-
}
|
|
7794
|
-
});
|
|
7795
8108
|
if (originalConnected) originalConnected.apply(this);
|
|
7796
8109
|
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
7797
8110
|
if (aMethods) {
|
|
@@ -7869,100 +8182,1680 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7869
8182
|
return constructor;
|
|
7870
8183
|
};
|
|
7871
8184
|
|
|
8185
|
+
// ../simple-boot/dist/esm/throwable/SimError.js
|
|
8186
|
+
var SimError = class {
|
|
8187
|
+
constructor(message, name, stack) {
|
|
8188
|
+
this.message = message;
|
|
8189
|
+
this.name = name;
|
|
8190
|
+
this.stack = stack;
|
|
8191
|
+
}
|
|
8192
|
+
};
|
|
8193
|
+
|
|
8194
|
+
// ../simple-boot/dist/esm/throwable/SimNoSuch.js
|
|
8195
|
+
var SimNoSuch = class extends SimError {
|
|
8196
|
+
constructor(message, name, stack) {
|
|
8197
|
+
super(message, name, stack);
|
|
8198
|
+
}
|
|
8199
|
+
};
|
|
8200
|
+
|
|
7872
8201
|
// ../simple-boot/dist/esm/decorators/SimDecorator.js
|
|
8202
|
+
var Lifecycle = /* @__PURE__ */ ((Lifecycle2) => {
|
|
8203
|
+
Lifecycle2["Singleton"] = "Singleton";
|
|
8204
|
+
Lifecycle2["Transient"] = "Transient";
|
|
8205
|
+
return Lifecycle2;
|
|
8206
|
+
})(Lifecycle || {});
|
|
8207
|
+
var sims = /* @__PURE__ */ new Map();
|
|
8208
|
+
var containers = /* @__PURE__ */ new Set();
|
|
7873
8209
|
var SimMetadataKey = Symbol("Sim");
|
|
8210
|
+
var isNotNullObjetInstance = (target) => target != null && target !== void 0 && typeof target === "object";
|
|
8211
|
+
var simProcess = (config, inputTarget) => {
|
|
8212
|
+
const target = (() => {
|
|
8213
|
+
if (typeof inputTarget === "object") {
|
|
8214
|
+
return config.scope === "Singleton" ? inputTarget : ValidUtils.isPlainObject(inputTarget) ? { ...inputTarget } : inputTarget;
|
|
8215
|
+
}
|
|
8216
|
+
if (ValidUtils.isArrowFunction(inputTarget)) {
|
|
8217
|
+
return () => inputTarget();
|
|
8218
|
+
}
|
|
8219
|
+
return inputTarget;
|
|
8220
|
+
})();
|
|
8221
|
+
let targetType;
|
|
8222
|
+
if (isNotNullObjetInstance(target)) {
|
|
8223
|
+
targetType = target.constructor;
|
|
8224
|
+
} else {
|
|
8225
|
+
targetType = target;
|
|
8226
|
+
}
|
|
8227
|
+
config.scope = config?.scope ?? "Singleton";
|
|
8228
|
+
ReflectUtils.defineMetadata(SimMetadataKey, config, targetType);
|
|
8229
|
+
const adding = (targetKey, target2 = targetKey) => {
|
|
8230
|
+
const items = sims.get(targetKey) ?? /* @__PURE__ */ new Set();
|
|
8231
|
+
items.add(target2);
|
|
8232
|
+
sims.set(targetKey, items);
|
|
8233
|
+
};
|
|
8234
|
+
if (Array.isArray(config?.type)) {
|
|
8235
|
+
config?.type.forEach((it) => {
|
|
8236
|
+
adding(it, target);
|
|
8237
|
+
});
|
|
8238
|
+
} else if (config.type) {
|
|
8239
|
+
adding(config?.type, target);
|
|
8240
|
+
} else {
|
|
8241
|
+
adding(target);
|
|
8242
|
+
}
|
|
8243
|
+
};
|
|
8244
|
+
function Sim(configOrTarget) {
|
|
8245
|
+
if (typeof configOrTarget === "function") {
|
|
8246
|
+
simProcess({}, configOrTarget);
|
|
8247
|
+
} else {
|
|
8248
|
+
return (target) => {
|
|
8249
|
+
simProcess(configOrTarget, target);
|
|
8250
|
+
};
|
|
8251
|
+
}
|
|
8252
|
+
}
|
|
8253
|
+
var getSim = (target) => {
|
|
8254
|
+
if (target != null && target !== void 0 && typeof target === "object") {
|
|
8255
|
+
target = Object.getPrototypeOf(target).constructor;
|
|
8256
|
+
}
|
|
8257
|
+
try {
|
|
8258
|
+
return ReflectUtils.getMetadata(SimMetadataKey, target);
|
|
8259
|
+
} catch (e) {
|
|
8260
|
+
}
|
|
8261
|
+
};
|
|
7874
8262
|
var PostConstructMetadataKey = Symbol("PostConstruct");
|
|
8263
|
+
var getPostConstructs = (target) => {
|
|
8264
|
+
return ReflectUtils.getMetadata(PostConstructMetadataKey, target) ?? [];
|
|
8265
|
+
};
|
|
8266
|
+
|
|
8267
|
+
// ../simple-boot/dist/esm/simstance/SimAtomic.js
|
|
8268
|
+
var SimAtomic = class {
|
|
8269
|
+
constructor(type, simstanceManager, config) {
|
|
8270
|
+
this.type = type;
|
|
8271
|
+
this.simstanceManager = simstanceManager;
|
|
8272
|
+
this.config = config;
|
|
8273
|
+
this.value = type.value;
|
|
8274
|
+
}
|
|
8275
|
+
getConfig(key = SimMetadataKey) {
|
|
8276
|
+
return ReflectUtils.getMetadata(key, this.type.originalType);
|
|
8277
|
+
}
|
|
8278
|
+
getConfigs() {
|
|
8279
|
+
return ReflectUtils.getMetadatas(this.type.originalType);
|
|
8280
|
+
}
|
|
8281
|
+
getValue(config) {
|
|
8282
|
+
if (config?.refresh) {
|
|
8283
|
+
this.value = void 0;
|
|
8284
|
+
}
|
|
8285
|
+
if (!this.value) {
|
|
8286
|
+
if (typeof this.type.targetKeyType === "symbol") {
|
|
8287
|
+
this.value = this.simstanceManager.findFirstSim(this.type.targetKeyType)?.getValue();
|
|
8288
|
+
} else {
|
|
8289
|
+
this.value = this.simstanceManager.getOrNewSim({ target: this.type.targetKeyType, originTypeTarget: this.type.originalType, newInstanceCarrier: config?.newInstanceCarrier });
|
|
8290
|
+
}
|
|
8291
|
+
}
|
|
8292
|
+
return this.value;
|
|
8293
|
+
}
|
|
8294
|
+
};
|
|
8295
|
+
|
|
8296
|
+
// ../simple-boot/dist/esm/SimOption.js
|
|
8297
|
+
var SimOption = class {
|
|
8298
|
+
constructor({ rootRouter, container, cache, advice = [], excludeProxys, proxy, using } = {}) {
|
|
8299
|
+
this.rootRouter = rootRouter;
|
|
8300
|
+
this.container = container;
|
|
8301
|
+
this.advice = advice;
|
|
8302
|
+
this.excludeProxys = excludeProxys;
|
|
8303
|
+
this.proxy = proxy;
|
|
8304
|
+
this.using = using;
|
|
8305
|
+
this.cache = cache;
|
|
8306
|
+
}
|
|
8307
|
+
addAdvicce(advice) {
|
|
8308
|
+
this.advice ?? (this.advice = []);
|
|
8309
|
+
this.advice.push(advice);
|
|
8310
|
+
}
|
|
8311
|
+
setAdvice(...advice) {
|
|
8312
|
+
this.advice = advice;
|
|
8313
|
+
return this;
|
|
8314
|
+
}
|
|
8315
|
+
};
|
|
8316
|
+
|
|
8317
|
+
// ../simple-boot/dist/esm/decorators/MetaDataAtomic.js
|
|
8318
|
+
var MetaDataAtomic = class {
|
|
8319
|
+
constructor(target, metaData) {
|
|
8320
|
+
this.target = target;
|
|
8321
|
+
this.metaData = metaData;
|
|
8322
|
+
}
|
|
8323
|
+
};
|
|
8324
|
+
var MetaDataPropertyAtomic = class extends MetaDataAtomic {
|
|
8325
|
+
constructor(target, metaData, property, parameter) {
|
|
8326
|
+
super(target, metaData);
|
|
8327
|
+
this.property = property;
|
|
8328
|
+
this.parameter = parameter;
|
|
8329
|
+
}
|
|
8330
|
+
call(...parameter) {
|
|
8331
|
+
return this.target[this.property](...parameter);
|
|
8332
|
+
}
|
|
8333
|
+
};
|
|
7875
8334
|
|
|
7876
8335
|
// ../simple-boot/dist/esm/decorators/aop/AOPDecorator.js
|
|
7877
8336
|
var AfterMetadataKey = Symbol("After");
|
|
7878
8337
|
var BeforeMetadataKey = Symbol("Before");
|
|
7879
8338
|
var AroundMetadataKey = Symbol("Around");
|
|
8339
|
+
var getAfter = (target, propertyKey) => {
|
|
8340
|
+
return ReflectUtils.getMetadata(AfterMetadataKey, target, propertyKey);
|
|
8341
|
+
};
|
|
8342
|
+
var getAfters = (target) => {
|
|
8343
|
+
return ObjectUtils.allProtoTypeName(target).map((it) => new MetaDataPropertyAtomic(target, getAfter(target, it), it)).filter((it) => it.metaData !== void 0) || [];
|
|
8344
|
+
};
|
|
8345
|
+
var getProtoAfters = (target, propertyKey, type) => {
|
|
8346
|
+
return getAfters(target).filter((it) => propertyKey === it.metaData?.property && type === it.metaData.type?.prototype) || [];
|
|
8347
|
+
};
|
|
8348
|
+
var getBefore = (target, propertyKey) => {
|
|
8349
|
+
return ReflectUtils.getMetadata(BeforeMetadataKey, target, propertyKey);
|
|
8350
|
+
};
|
|
8351
|
+
var getBefores = (target) => {
|
|
8352
|
+
return ObjectUtils.allProtoTypeName(target).map((it) => new MetaDataPropertyAtomic(target, getBefore(target, it), it)).filter((it) => it.metaData !== void 0) || [];
|
|
8353
|
+
};
|
|
8354
|
+
var getProtoBefores = (target, propertyKey, type) => {
|
|
8355
|
+
return getBefores(target).filter((it) => propertyKey === it.metaData?.property && type === it.metaData.type?.prototype) || [];
|
|
8356
|
+
};
|
|
7880
8357
|
|
|
7881
8358
|
// ../simple-boot/dist/esm/decorators/exception/ExceptionDecorator.js
|
|
8359
|
+
var ExceptionHandlerSituationType = /* @__PURE__ */ ((ExceptionHandlerSituationType2) => {
|
|
8360
|
+
ExceptionHandlerSituationType2["ERROR_OBJECT"] = "SIMPLE_BOOT_CORE://ExceptionHandler/ERROR_OBJECT";
|
|
8361
|
+
ExceptionHandlerSituationType2["PARAMETER"] = "SIMPLE_BOOT_CORE://ExceptionHandler/PARAMETER";
|
|
8362
|
+
return ExceptionHandlerSituationType2;
|
|
8363
|
+
})(ExceptionHandlerSituationType || {});
|
|
7882
8364
|
var ExceptionHandlerMetadataKey = Symbol("ExceptionHandler");
|
|
8365
|
+
var getExceptionHandlers = (target) => {
|
|
8366
|
+
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
8367
|
+
target = target.constructor;
|
|
8368
|
+
}
|
|
8369
|
+
return ReflectUtils.getMetadata(ExceptionHandlerMetadataKey, target);
|
|
8370
|
+
};
|
|
8371
|
+
var targetExceptionHandlers = (target, error) => {
|
|
8372
|
+
const exceptionHandlers = getExceptionHandlers(target);
|
|
8373
|
+
const emptyTargets = exceptionHandlers?.filter((it) => it.config.type === void 0);
|
|
8374
|
+
const targets = exceptionHandlers?.filter((it) => ObjectUtils.isPrototypeOfTarget(it.config.type, error));
|
|
8375
|
+
const targetSorts = targets?.sort((a, b) => {
|
|
8376
|
+
const aPrototypeOfDepth = ObjectUtils.prototypeOfDepth(error, a.config.type);
|
|
8377
|
+
const bPrototypeOfDepth = ObjectUtils.prototypeOfDepth(error, b.config.type);
|
|
8378
|
+
return aPrototypeOfDepth.length - bPrototypeOfDepth.length;
|
|
8379
|
+
});
|
|
8380
|
+
return (targetSorts ?? []).concat(...emptyTargets ?? []);
|
|
8381
|
+
};
|
|
8382
|
+
var targetExceptionHandler = (target, error, excludeMethods = []) => {
|
|
8383
|
+
let exceptionHandlers = targetExceptionHandlers(target, error);
|
|
8384
|
+
exceptionHandlers = exceptionHandlers?.filter((it) => !excludeMethods.includes(it.method));
|
|
8385
|
+
if (exceptionHandlers && exceptionHandlers.length > 0) {
|
|
8386
|
+
return exceptionHandlers[0];
|
|
8387
|
+
} else {
|
|
8388
|
+
return void 0;
|
|
8389
|
+
}
|
|
8390
|
+
};
|
|
7883
8391
|
|
|
7884
|
-
// ../simple-boot/dist/esm/
|
|
7885
|
-
var
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
RouterAction2.isHasActivate = (obj) => {
|
|
7904
|
-
return typeof obj?.hasActivate === "function";
|
|
7905
|
-
};
|
|
7906
|
-
})(RouterAction || (RouterAction = {}));
|
|
7907
|
-
|
|
7908
|
-
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
7909
|
-
var CanvasUtils;
|
|
7910
|
-
((CanvasUtils2) => {
|
|
7911
|
-
let Context2D;
|
|
7912
|
-
((Context2D2) => {
|
|
7913
|
-
Context2D2.resetTransform = (context) => {
|
|
7914
|
-
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
7915
|
-
};
|
|
7916
|
-
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
7917
|
-
CanvasUtils2.fontSize = (ctx, config) => {
|
|
7918
|
-
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
7919
|
-
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
7920
|
-
return 0;
|
|
8392
|
+
// ../simple-boot/dist/esm/proxy/SimProxyHandler.js
|
|
8393
|
+
var SimProxyHandler = class {
|
|
8394
|
+
constructor(simpleApplication, simstanceManager, simOption) {
|
|
8395
|
+
this.simpleApplication = simpleApplication;
|
|
8396
|
+
this.simstanceManager = simstanceManager;
|
|
8397
|
+
this.simOption = simOption;
|
|
8398
|
+
}
|
|
8399
|
+
// 잘받게 해놨네 ㅋㅋ simstanceManager
|
|
8400
|
+
get(target, name) {
|
|
8401
|
+
if (name === "_SimpleBoot_application") {
|
|
8402
|
+
return this.simpleApplication;
|
|
8403
|
+
} else if (name === "_SimpleBoot_simstanceManager") {
|
|
8404
|
+
return this.simstanceManager;
|
|
8405
|
+
} else if (name === "_SimpleBoot_simOption") {
|
|
8406
|
+
return this.simOption;
|
|
8407
|
+
} else if (name === "_SimpleBoot_origin") {
|
|
8408
|
+
return target;
|
|
8409
|
+
} else {
|
|
8410
|
+
return target[name];
|
|
7921
8411
|
}
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
8412
|
+
}
|
|
8413
|
+
set(obj, prop, value, receiver) {
|
|
8414
|
+
value = this.simstanceManager?.proxy(value);
|
|
8415
|
+
obj[prop] = value;
|
|
8416
|
+
return true;
|
|
8417
|
+
}
|
|
8418
|
+
apply(target, thisArg, argumentsList) {
|
|
8419
|
+
let r;
|
|
8420
|
+
try {
|
|
8421
|
+
this.aopBefore(thisArg, target);
|
|
8422
|
+
try {
|
|
8423
|
+
r = Reflect.apply(target, thisArg, argumentsList);
|
|
8424
|
+
} catch (e) {
|
|
8425
|
+
throw e;
|
|
8426
|
+
} finally {
|
|
8427
|
+
this.aopAfter(thisArg, target);
|
|
8428
|
+
}
|
|
8429
|
+
} catch (e) {
|
|
8430
|
+
console.error(e);
|
|
8431
|
+
const inHandlers = this.getExceptionHandler(e, thisArg, target);
|
|
8432
|
+
if (inHandlers.length > 0 && inHandlers[0]) {
|
|
8433
|
+
const inHandler = inHandlers[0];
|
|
8434
|
+
this.executeExceptionHandler(e, inHandler, argumentsList);
|
|
8435
|
+
} else {
|
|
8436
|
+
throw e;
|
|
8437
|
+
}
|
|
7925
8438
|
}
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
8439
|
+
return r;
|
|
8440
|
+
}
|
|
8441
|
+
executeExceptionHandler(e, inHandler, argumentsList) {
|
|
8442
|
+
const otherStorage = /* @__PURE__ */ new Map();
|
|
8443
|
+
otherStorage.set(e.constructor, e);
|
|
8444
|
+
const situationErrorTypeContainer = new SituationTypeContainer({
|
|
8445
|
+
situationType: ExceptionHandlerSituationType.ERROR_OBJECT,
|
|
8446
|
+
data: e
|
|
8447
|
+
});
|
|
8448
|
+
const situationParameterTypeContainer = new SituationTypeContainer({
|
|
8449
|
+
situationType: ExceptionHandlerSituationType.PARAMETER,
|
|
8450
|
+
data: argumentsList
|
|
8451
|
+
});
|
|
8452
|
+
otherStorage.set(SituationTypeContainers, new SituationTypeContainers([situationErrorTypeContainer, situationParameterTypeContainer]));
|
|
8453
|
+
argumentsList?.forEach((it) => {
|
|
8454
|
+
otherStorage.set(it.constructor, it);
|
|
8455
|
+
});
|
|
8456
|
+
try {
|
|
8457
|
+
this.simstanceManager.executeBindParameterSim(
|
|
8458
|
+
{
|
|
8459
|
+
target: inHandler.thisArg,
|
|
8460
|
+
targetKey: inHandler.config.propertyKey
|
|
8461
|
+
},
|
|
8462
|
+
otherStorage
|
|
8463
|
+
);
|
|
8464
|
+
} catch (es) {
|
|
8465
|
+
e = es;
|
|
7930
8466
|
}
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
let iteration = 0;
|
|
7936
|
-
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
7937
|
-
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
7938
|
-
if (midSize === 0) break;
|
|
7939
|
-
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
7940
|
-
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
7941
|
-
if (maxLineWidth <= maxWidth) {
|
|
7942
|
-
bestSizeForWidth = midSize;
|
|
7943
|
-
minSizeForWidth = midSize + 1;
|
|
7944
|
-
} else {
|
|
7945
|
-
maxSizeForWidth = midSize - 1;
|
|
8467
|
+
if (inHandler.config.config.throw) {
|
|
8468
|
+
const exceptionHandler = this.getExceptionHandler(e, inHandler.thisArg, inHandler.config.method);
|
|
8469
|
+
if ((exceptionHandler?.length ?? 0) > 0) {
|
|
8470
|
+
this.executeExceptionHandler(e, exceptionHandler[0], argumentsList);
|
|
7946
8471
|
}
|
|
7947
|
-
iteration++;
|
|
7948
8472
|
}
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
if (
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
|
|
8473
|
+
}
|
|
8474
|
+
getExceptionHandler(e, thisArg, target) {
|
|
8475
|
+
const globalConfigSets = this.simOption.advice.map((it) => this.simstanceManager?.getOrNewSim({ target: it })).filter((it) => it).map((it) => {
|
|
8476
|
+
return { thisArg: it, config: targetExceptionHandler(it, e, [target]) };
|
|
8477
|
+
}) ?? [];
|
|
8478
|
+
const thisConfigSet = { thisArg, config: targetExceptionHandler(thisArg, e, [target]) };
|
|
8479
|
+
const inHandlers = [thisConfigSet, ...globalConfigSets].filter((it) => it && it.config);
|
|
8480
|
+
return inHandlers;
|
|
8481
|
+
}
|
|
8482
|
+
aopBefore(obj, protoType) {
|
|
8483
|
+
const propertyName = ObjectUtils.prototypeName(obj, protoType);
|
|
8484
|
+
if (propertyName && obj) {
|
|
8485
|
+
getProtoBefores(obj, propertyName).forEach((it) => {
|
|
8486
|
+
it.call(obj, protoType, propertyName);
|
|
8487
|
+
});
|
|
8488
|
+
for (let i = 0; i < this.simOption.advice.length; i++) {
|
|
8489
|
+
const sim = this.simstanceManager?.getOrNewSim({ target: this.simOption.advice[i] });
|
|
8490
|
+
const protoBefores = getProtoBefores(sim, propertyName, Object.getPrototypeOf(obj));
|
|
8491
|
+
protoBefores.forEach((it) => {
|
|
8492
|
+
it.call(obj, protoType, propertyName);
|
|
8493
|
+
});
|
|
8494
|
+
}
|
|
8495
|
+
}
|
|
8496
|
+
}
|
|
8497
|
+
aopAfter(obj, protoType) {
|
|
8498
|
+
const propertyName = ObjectUtils.prototypeName(obj, protoType);
|
|
8499
|
+
if (propertyName) {
|
|
8500
|
+
getProtoAfters(obj, propertyName).forEach((it) => {
|
|
8501
|
+
it.call(obj, protoType, propertyName);
|
|
8502
|
+
});
|
|
8503
|
+
for (let i = 0; i < this.simOption.advice.length; i++) {
|
|
8504
|
+
const sim = this.simstanceManager?.getOrNewSim({ target: this.simOption.advice[i] });
|
|
8505
|
+
const protoBefores = getProtoAfters(sim, propertyName, Object.getPrototypeOf(obj));
|
|
8506
|
+
protoBefores.forEach((it) => {
|
|
8507
|
+
it.call(obj, protoType, propertyName);
|
|
8508
|
+
});
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
}
|
|
8512
|
+
has(target, key) {
|
|
8513
|
+
if (key === "_SimpleBoot_isProxy") {
|
|
8514
|
+
return true;
|
|
8515
|
+
}
|
|
8516
|
+
return key in target;
|
|
8517
|
+
}
|
|
8518
|
+
};
|
|
8519
|
+
|
|
8520
|
+
// ../simple-boot/dist/esm/lifecycle/OnSimCreate.js
|
|
8521
|
+
var isOnSimCreate = (obj) => {
|
|
8522
|
+
return typeof obj?.onSimCreate === "function";
|
|
8523
|
+
};
|
|
8524
|
+
|
|
8525
|
+
// ../simple-boot/dist/esm/lifecycle/OnSimCreateCompleted.js
|
|
8526
|
+
var isOnSimCreateProxyCompleted = (obj) => {
|
|
8527
|
+
return typeof obj?.onSimCreateProxyCompleted === "function";
|
|
8528
|
+
};
|
|
8529
|
+
|
|
8530
|
+
// ../simple-boot/dist/esm/decorators/SimNoProxy.js
|
|
8531
|
+
var SimNoProxyKey = Symbol("Sim:NoProxy");
|
|
8532
|
+
var getSimNoProxy = (target, propertyKey) => {
|
|
8533
|
+
try {
|
|
8534
|
+
if (propertyKey === void 0) {
|
|
8535
|
+
return Reflect.getMetadata(SimNoProxyKey, target);
|
|
8536
|
+
}
|
|
8537
|
+
return Reflect.getMetadata(SimNoProxyKey, target, propertyKey);
|
|
8538
|
+
} catch (e) {
|
|
8539
|
+
return void 0;
|
|
8540
|
+
}
|
|
8541
|
+
};
|
|
8542
|
+
var isSimNoProxy = (target, propertyKey) => {
|
|
8543
|
+
if (target === null || target === void 0) {
|
|
8544
|
+
return false;
|
|
8545
|
+
}
|
|
8546
|
+
return getSimNoProxy(target, propertyKey) === true;
|
|
8547
|
+
};
|
|
8548
|
+
|
|
8549
|
+
// ../simple-boot/dist/esm/simstance/SimstanceManager.js
|
|
8550
|
+
var SimstanceManager = class _SimstanceManager {
|
|
8551
|
+
// private otherInstanceSim?: Map<ConstructorType<any> | Function, any>;
|
|
8552
|
+
constructor(simpleApplication, option) {
|
|
8553
|
+
this.simpleApplication = simpleApplication;
|
|
8554
|
+
this.option = option;
|
|
8555
|
+
this._storage = /* @__PURE__ */ new Map();
|
|
8556
|
+
this.name = "simstanceManager-" + RandomUtils.uuid4();
|
|
8557
|
+
this.setStoreSet(SimpleApplication, this.simpleApplication);
|
|
8558
|
+
this.setStoreSet(_SimstanceManager, this);
|
|
8559
|
+
this.setStoreSet(option.constructor, option);
|
|
8560
|
+
this.setStoreSet(SimOption, option);
|
|
8561
|
+
this.simProxyHandler = new SimProxyHandler(this.simpleApplication, this, option);
|
|
8562
|
+
}
|
|
8563
|
+
get storage() {
|
|
8564
|
+
return this._storage;
|
|
8565
|
+
}
|
|
8566
|
+
getSimAtomics() {
|
|
8567
|
+
const r = [];
|
|
8568
|
+
Array.from(this.storage.entries()).forEach(([targetKeyType, targetMap]) => {
|
|
8569
|
+
r.push(
|
|
8570
|
+
...Array.from(Array.from(targetMap.keys())).map(
|
|
8571
|
+
(sit) => new SimAtomic(
|
|
8572
|
+
{
|
|
8573
|
+
targetKeyType,
|
|
8574
|
+
originalType: sit
|
|
8575
|
+
},
|
|
8576
|
+
this
|
|
8577
|
+
)
|
|
8578
|
+
)
|
|
8579
|
+
);
|
|
8580
|
+
});
|
|
8581
|
+
return r;
|
|
8582
|
+
}
|
|
8583
|
+
getSimConfig(schemeOrSymbol) {
|
|
8584
|
+
const newVar = this.getSimAtomics().filter((it) => {
|
|
8585
|
+
const config = it?.getConfig();
|
|
8586
|
+
const symbols = ConvertUtils.flatArray(config?.symbol);
|
|
8587
|
+
const schemes = ConvertUtils.flatArray(config?.scheme);
|
|
8588
|
+
if (typeof schemeOrSymbol === "symbol") {
|
|
8589
|
+
return schemeOrSymbol && it && symbols.includes(schemeOrSymbol);
|
|
8590
|
+
} else if (typeof schemeOrSymbol === "string") {
|
|
8591
|
+
return schemeOrSymbol && it && schemes.includes(schemeOrSymbol);
|
|
8592
|
+
} else {
|
|
8593
|
+
return false;
|
|
8594
|
+
}
|
|
8595
|
+
}) || [];
|
|
8596
|
+
return newVar;
|
|
8597
|
+
}
|
|
8598
|
+
findSims(data) {
|
|
8599
|
+
let r = [];
|
|
8600
|
+
if (data) {
|
|
8601
|
+
const simAtomics = this.getSimAtomics();
|
|
8602
|
+
r = simAtomics.filter((it) => {
|
|
8603
|
+
let b = false;
|
|
8604
|
+
const config = it.getConfig();
|
|
8605
|
+
const symbols = ConvertUtils.flatArray(config?.symbol).filter(ValidUtils.isDefined);
|
|
8606
|
+
const schemes = ConvertUtils.flatArray(config?.scheme).filter(ValidUtils.isDefined);
|
|
8607
|
+
if (typeof data === "symbol") {
|
|
8608
|
+
b = symbols.includes(data);
|
|
8609
|
+
} else {
|
|
8610
|
+
const { scheme, type } = data;
|
|
8611
|
+
b = (scheme ? schemes.includes(scheme) : true) && (type ? it.type.targetKeyType === type : true);
|
|
8612
|
+
}
|
|
8613
|
+
return b;
|
|
8614
|
+
});
|
|
8615
|
+
}
|
|
8616
|
+
return r;
|
|
8617
|
+
}
|
|
8618
|
+
findFirstSim(data) {
|
|
8619
|
+
if (typeof data === "symbol") {
|
|
8620
|
+
return this.findSims(data)[0];
|
|
8621
|
+
} else {
|
|
8622
|
+
return this.findSims(data)[0];
|
|
8623
|
+
}
|
|
8624
|
+
}
|
|
8625
|
+
findLastSim(data) {
|
|
8626
|
+
if (typeof data === "symbol") {
|
|
8627
|
+
return this.findSims(data).reverse()[0];
|
|
8628
|
+
} else {
|
|
8629
|
+
return this.findSims(data).reverse()[0];
|
|
8630
|
+
}
|
|
8631
|
+
}
|
|
8632
|
+
flatStoreSets() {
|
|
8633
|
+
return new Map(
|
|
8634
|
+
Array.from(this.storage.values()).map((it) => Array.from(it.entries())).flat()
|
|
8635
|
+
);
|
|
8636
|
+
}
|
|
8637
|
+
getStoreSets(targetKey) {
|
|
8638
|
+
const map = this.storage.get(targetKey);
|
|
8639
|
+
const datas = (Array.from(map?.entries?.() ?? []) ?? []).reverse();
|
|
8640
|
+
return datas.map((it) => ({ type: it[0], instance: it[1] }));
|
|
8641
|
+
}
|
|
8642
|
+
getStoreSet(targetKey, target) {
|
|
8643
|
+
const sets = this.getStoreSets(targetKey);
|
|
8644
|
+
let find = sets.find((it) => it.type === target);
|
|
8645
|
+
if (!find && (!target || target === targetKey)) {
|
|
8646
|
+
find = sets.find((it) => it.instance);
|
|
8647
|
+
}
|
|
8648
|
+
if (!find?.instance) {
|
|
8649
|
+
const type = target ?? targetKey;
|
|
8650
|
+
if (typeof type === "object") {
|
|
8651
|
+
const find2 = this.storage.get(type);
|
|
8652
|
+
if (find2) {
|
|
8653
|
+
return { type, instance: type };
|
|
8654
|
+
}
|
|
8655
|
+
}
|
|
8656
|
+
const flatStoreSets = this.flatStoreSets();
|
|
8657
|
+
const data = flatStoreSets.get(type);
|
|
8658
|
+
if (data) {
|
|
8659
|
+
this.setStoreSet(targetKey, data, type);
|
|
8660
|
+
}
|
|
8661
|
+
return { type, instance: data };
|
|
8662
|
+
} else {
|
|
8663
|
+
return find;
|
|
8664
|
+
}
|
|
8665
|
+
}
|
|
8666
|
+
getStoreInstance(targetKey, target) {
|
|
8667
|
+
return this.getStoreSet(targetKey, target)?.instance;
|
|
8668
|
+
}
|
|
8669
|
+
getOrNewSim({ target, originTypeTarget = target, newInstanceCarrier }) {
|
|
8670
|
+
if (target) {
|
|
8671
|
+
const registed = this.getStoreSet(target, originTypeTarget);
|
|
8672
|
+
if (registed?.type && !registed?.instance) {
|
|
8673
|
+
return this.resolve({
|
|
8674
|
+
targetKey: target,
|
|
8675
|
+
target: originTypeTarget,
|
|
8676
|
+
newInstanceCarrier
|
|
8677
|
+
});
|
|
8678
|
+
}
|
|
8679
|
+
return registed?.instance;
|
|
8680
|
+
}
|
|
8681
|
+
}
|
|
8682
|
+
setStoreSet(targetKey, obj, target = targetKey) {
|
|
8683
|
+
const itemMap = this.storage.get(targetKey) ?? /* @__PURE__ */ new Map();
|
|
8684
|
+
itemMap.set(target, obj);
|
|
8685
|
+
this.storage.set(targetKey, itemMap);
|
|
8686
|
+
}
|
|
8687
|
+
registerStore(targetKey, regTyps) {
|
|
8688
|
+
const itemMap = this.storage.get(targetKey) ?? /* @__PURE__ */ new Map();
|
|
8689
|
+
regTyps.forEach((it) => {
|
|
8690
|
+
const { type, value } = typeof it === "object" ? { type: it.constructor, value: it } : { type: it, value: void 0 };
|
|
8691
|
+
if (!itemMap.has(type) || value !== void 0 && itemMap.get(type) === void 0) {
|
|
8692
|
+
itemMap.set(type, value);
|
|
8693
|
+
}
|
|
8694
|
+
});
|
|
8695
|
+
this.storage.set(targetKey, itemMap);
|
|
8696
|
+
}
|
|
8697
|
+
// 진입점
|
|
8698
|
+
resolve({ target, targetKey, newInstanceCarrier = { newInstances: [], depth: 0 } }) {
|
|
8699
|
+
const registed = this.getStoreSet(targetKey, target);
|
|
8700
|
+
if (registed?.instance) {
|
|
8701
|
+
return registed.instance;
|
|
8702
|
+
}
|
|
8703
|
+
if (this.storage.has(targetKey) && void 0 === registed?.instance) {
|
|
8704
|
+
newInstanceCarrier.depth++;
|
|
8705
|
+
const newSim = this.newSim({
|
|
8706
|
+
target: registed?.type ?? targetKey,
|
|
8707
|
+
newInstanceCarrier,
|
|
8708
|
+
simCreateAfter: (data) => {
|
|
8709
|
+
if (getSim(registed?.type ?? target ?? targetKey)?.scope === Lifecycle.Singleton) {
|
|
8710
|
+
this.setStoreSet(targetKey, data, target);
|
|
8711
|
+
}
|
|
8712
|
+
}
|
|
8713
|
+
});
|
|
8714
|
+
newInstanceCarrier.depth--;
|
|
8715
|
+
if (newInstanceCarrier.depth === 0) {
|
|
8716
|
+
newInstanceCarrier.newInstances.forEach((it) => {
|
|
8717
|
+
this.callBindPostConstruct(it);
|
|
8718
|
+
});
|
|
8719
|
+
}
|
|
8720
|
+
if (isOnSimCreate(newSim)) {
|
|
8721
|
+
newSim.onSimCreate();
|
|
8722
|
+
}
|
|
8723
|
+
return newSim;
|
|
8724
|
+
}
|
|
8725
|
+
const simNoSuch = new SimNoSuch("SimNoSuch: no simple instance(resolve) name:" + targetKey?.prototype?.constructor?.name + "," + targetKey);
|
|
8726
|
+
console.error(simNoSuch);
|
|
8727
|
+
throw simNoSuch;
|
|
8728
|
+
}
|
|
8729
|
+
newSim({ target, simCreateAfter, otherStorage, newInstanceCarrier }) {
|
|
8730
|
+
const parameters = this.getParameterSim({
|
|
8731
|
+
target,
|
|
8732
|
+
otherStorage,
|
|
8733
|
+
newInstanceCarrier
|
|
8734
|
+
});
|
|
8735
|
+
const r = ValidUtils.isFunction(target) && !target.prototype ? target(...parameters) : new target(...parameters);
|
|
8736
|
+
let p = this.proxy(r);
|
|
8737
|
+
const config = getSim(target);
|
|
8738
|
+
if (config?.proxy) {
|
|
8739
|
+
const proxys = (Array.isArray(config.proxy) ? config.proxy : [config.proxy]).filter(ValidUtils.isDefined);
|
|
8740
|
+
proxys.forEach((it) => {
|
|
8741
|
+
if (typeof it === "object") {
|
|
8742
|
+
p = new Proxy(p, it);
|
|
8743
|
+
} else {
|
|
8744
|
+
const simConfig = getSim(it);
|
|
8745
|
+
p = new Proxy(p, simConfig ? this.getOrNewSim({ target: it }) : this.newSim({ target: it }));
|
|
8746
|
+
}
|
|
8747
|
+
});
|
|
8748
|
+
}
|
|
8749
|
+
newInstanceCarrier?.newInstances.push(p);
|
|
8750
|
+
simCreateAfter?.(p);
|
|
8751
|
+
if (isOnSimCreateProxyCompleted(p)) {
|
|
8752
|
+
p.onSimCreateProxyCompleted(p);
|
|
8753
|
+
}
|
|
8754
|
+
return p;
|
|
8755
|
+
}
|
|
8756
|
+
callBindPostConstruct(obj) {
|
|
8757
|
+
const postConstruct = getPostConstructs(obj);
|
|
8758
|
+
postConstruct.forEach((it) => {
|
|
8759
|
+
obj[it.property](...this.getParameterSim({ target: obj, targetKey: it.property }));
|
|
8760
|
+
});
|
|
8761
|
+
}
|
|
8762
|
+
async executeBindParameterSimPromise({ target, targetKey, firstCheckMaker, parameterCount, inputParameters }, otherStorage) {
|
|
8763
|
+
const binds = this.getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, parameterCount, inputParameters });
|
|
8764
|
+
if (typeof target === "object" && targetKey) {
|
|
8765
|
+
const targetMethod = target[targetKey];
|
|
8766
|
+
return targetMethod?.bind(target)?.(...binds);
|
|
8767
|
+
} else if (typeof target === "function" && !targetKey) {
|
|
8768
|
+
return new target(...binds);
|
|
8769
|
+
}
|
|
8770
|
+
}
|
|
8771
|
+
executeBindParameterSim({ target, targetKey, firstCheckMaker, parameterCount, inputParameters }, otherStorage) {
|
|
8772
|
+
const binds = this.getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, parameterCount, inputParameters });
|
|
8773
|
+
if (typeof target === "object" && targetKey) {
|
|
8774
|
+
const targetMethod = target[targetKey];
|
|
8775
|
+
return targetMethod?.bind(target)?.(...binds);
|
|
8776
|
+
} else if (typeof target === "function" && !targetKey) {
|
|
8777
|
+
return new target(...binds);
|
|
8778
|
+
}
|
|
8779
|
+
}
|
|
8780
|
+
getParameterSim({ target, targetKey, firstCheckMaker, otherStorage, newInstanceCarrier, parameterCount, inputParameters = [] }) {
|
|
8781
|
+
const paramTypes = ReflectUtils.getParameterTypes(target, targetKey) || [];
|
|
8782
|
+
let injections = [];
|
|
8783
|
+
const injects = getInject(target, targetKey);
|
|
8784
|
+
const loopCount = Math.max(paramTypes.length, parameterCount ?? 0);
|
|
8785
|
+
const loopArray = new Array(loopCount).fill(void 0);
|
|
8786
|
+
injections = loopArray.map((_, idx) => {
|
|
8787
|
+
const token = paramTypes[idx];
|
|
8788
|
+
const saveInject = injects?.find((it) => it.index === idx);
|
|
8789
|
+
for (const f of firstCheckMaker ?? []) {
|
|
8790
|
+
const firstCheckObj = f({ target, targetKey }, token, idx, saveInject);
|
|
8791
|
+
if (void 0 !== firstCheckObj) {
|
|
8792
|
+
return firstCheckObj;
|
|
8793
|
+
}
|
|
8794
|
+
}
|
|
8795
|
+
if (saveInject) {
|
|
8796
|
+
const inject = saveInject.config;
|
|
8797
|
+
let obj = otherStorage?.get(token);
|
|
8798
|
+
if (token === Array && (isTargetType(inject) || isTargetScheme(inject) || isTargetSymbol(inject))) {
|
|
8799
|
+
const p = [];
|
|
8800
|
+
if (isTargetType(inject) && inject.type) {
|
|
8801
|
+
p.push(
|
|
8802
|
+
...this.getStoreSets(inject.type).map(
|
|
8803
|
+
(it) => this.resolve({
|
|
8804
|
+
targetKey: inject.type,
|
|
8805
|
+
target: it.type,
|
|
8806
|
+
newInstanceCarrier
|
|
8807
|
+
})
|
|
8808
|
+
).reverse()
|
|
8809
|
+
);
|
|
8810
|
+
}
|
|
8811
|
+
if (isTargetSymbol(inject)) {
|
|
8812
|
+
p.push(...this.getSimConfig(inject.symbol).map((it) => it.getValue({ newInstanceCarrier })));
|
|
8813
|
+
}
|
|
8814
|
+
if (isTargetScheme(inject)) {
|
|
8815
|
+
p.push(...this.getSimConfig(inject.scheme).map((it) => it.getValue({ newInstanceCarrier })));
|
|
8816
|
+
}
|
|
8817
|
+
return p;
|
|
8818
|
+
}
|
|
8819
|
+
if (inject.situationType && otherStorage) {
|
|
8820
|
+
const situations = otherStorage.get(SituationTypeContainers);
|
|
8821
|
+
const situation = otherStorage.get(SituationTypeContainer);
|
|
8822
|
+
if (inject.situationType === situation?.situationType) {
|
|
8823
|
+
obj = situation.data;
|
|
8824
|
+
} else if (situations && situations.length > 0) {
|
|
8825
|
+
const find = situations.find((a) => {
|
|
8826
|
+
if (a.index !== void 0) {
|
|
8827
|
+
return a.situationType === inject.situationType && a.index === idx;
|
|
8828
|
+
} else {
|
|
8829
|
+
return a.situationType === inject.situationType;
|
|
8830
|
+
}
|
|
8831
|
+
});
|
|
8832
|
+
if (find) {
|
|
8833
|
+
obj = find.data;
|
|
8834
|
+
}
|
|
8835
|
+
}
|
|
8836
|
+
}
|
|
8837
|
+
if (!obj) {
|
|
8838
|
+
const currentInstance = typeof target === "object" ? target : void 0;
|
|
8839
|
+
if (isTargetFactory(inject)) {
|
|
8840
|
+
obj = inject.factory({
|
|
8841
|
+
instance: currentInstance,
|
|
8842
|
+
methodName: String(targetKey),
|
|
8843
|
+
parameter: inputParameters,
|
|
8844
|
+
application: this.simpleApplication
|
|
8845
|
+
});
|
|
8846
|
+
} else {
|
|
8847
|
+
let findLastSim;
|
|
8848
|
+
if (isTargetSymbol(inject)) {
|
|
8849
|
+
findLastSim = this.findLastSim(inject.symbol);
|
|
8850
|
+
} else if (isTargetType(inject) || isTargetScheme(inject)) {
|
|
8851
|
+
findLastSim = this.findLastSim(inject);
|
|
8852
|
+
}
|
|
8853
|
+
try {
|
|
8854
|
+
obj = findLastSim ? this.resolve({
|
|
8855
|
+
targetKey: findLastSim?.type.targetKeyType ?? token,
|
|
8856
|
+
newInstanceCarrier
|
|
8857
|
+
}) : this.resolve({
|
|
8858
|
+
targetKey: token,
|
|
8859
|
+
newInstanceCarrier
|
|
8860
|
+
});
|
|
8861
|
+
if (inject.factory && obj) {
|
|
8862
|
+
if (typeof inject.factory === "function") {
|
|
8863
|
+
obj = inject.factory({
|
|
8864
|
+
instance: currentInstance,
|
|
8865
|
+
methodName: String(targetKey),
|
|
8866
|
+
parameter: inputParameters,
|
|
8867
|
+
application: this.simpleApplication,
|
|
8868
|
+
injectInstance: obj
|
|
8869
|
+
});
|
|
8870
|
+
}
|
|
8871
|
+
}
|
|
8872
|
+
} catch (e) {
|
|
8873
|
+
if (inject.optional) {
|
|
8874
|
+
return void 0;
|
|
8875
|
+
} else {
|
|
8876
|
+
throw e;
|
|
8877
|
+
}
|
|
8878
|
+
}
|
|
8879
|
+
}
|
|
8880
|
+
}
|
|
8881
|
+
if (inject.proxy && obj) {
|
|
8882
|
+
if (ValidUtils.isConstructor(inject.proxy)) {
|
|
8883
|
+
const handler = getSim(inject.proxy) ? this.getOrNewSim({ target: inject.proxy }) : new inject.proxy();
|
|
8884
|
+
if (handler) {
|
|
8885
|
+
obj = new Proxy(obj, handler);
|
|
8886
|
+
}
|
|
8887
|
+
} else if (typeof inject.proxy === "function") {
|
|
8888
|
+
const handler = inject.proxy({
|
|
8889
|
+
application: this.simpleApplication,
|
|
8890
|
+
instance: obj
|
|
8891
|
+
});
|
|
8892
|
+
if (handler) {
|
|
8893
|
+
obj = new Proxy(obj, handler);
|
|
8894
|
+
}
|
|
8895
|
+
}
|
|
8896
|
+
}
|
|
8897
|
+
return obj;
|
|
8898
|
+
} else {
|
|
8899
|
+
return otherStorage?.get(token) ?? (token ? this.resolve({ targetKey: token, newInstanceCarrier }) : void 0);
|
|
8900
|
+
}
|
|
8901
|
+
});
|
|
8902
|
+
return injections;
|
|
8903
|
+
}
|
|
8904
|
+
proxy(target) {
|
|
8905
|
+
try {
|
|
8906
|
+
const noProxy = isSimNoProxy(target);
|
|
8907
|
+
const isExcludeProxy = this.option.excludeProxys?.some((it) => target instanceof it);
|
|
8908
|
+
if (!noProxy && !isExcludeProxy && target !== null && getSim(target) && typeof target === "object" && !("_SimpleBoot_isProxy" in target)) {
|
|
8909
|
+
for (const key in target) {
|
|
8910
|
+
if (!isSimNoProxy(target, key)) {
|
|
8911
|
+
target[key] = this.proxy(target[key]);
|
|
8912
|
+
}
|
|
8913
|
+
}
|
|
8914
|
+
const protoTypeName = ObjectUtils.ownPropertyNames(target);
|
|
8915
|
+
protoTypeName.filter((it) => typeof target[it] === "function").filter((it) => !isSimNoProxy(target, it)).filter((it) => !("_SimpleBoot_isProxy" in target[it])).forEach((it) => {
|
|
8916
|
+
target[it] = new Proxy(target[it], this.simProxyHandler);
|
|
8917
|
+
});
|
|
8918
|
+
if (this.simProxyHandler) {
|
|
8919
|
+
target = new Proxy(target, this.simProxyHandler);
|
|
8920
|
+
}
|
|
8921
|
+
}
|
|
8922
|
+
if (this.option.proxy) {
|
|
8923
|
+
target = this.option.proxy.onAfterProxy(target);
|
|
8924
|
+
}
|
|
8925
|
+
return target;
|
|
8926
|
+
} catch (e) {
|
|
8927
|
+
console.log("sim proxy error");
|
|
8928
|
+
throw e;
|
|
8929
|
+
}
|
|
8930
|
+
}
|
|
8931
|
+
run(otherInstanceSim = /* @__PURE__ */ new Map()) {
|
|
8932
|
+
for (const [k, v] of Array.from(otherInstanceSim.entries())) {
|
|
8933
|
+
if (typeof k === "symbol") {
|
|
8934
|
+
simProcess({ symbol: k }, v);
|
|
8935
|
+
} else if (typeof k === "object") {
|
|
8936
|
+
simProcess(k, v);
|
|
8937
|
+
} else {
|
|
8938
|
+
simProcess({ type: k }, v);
|
|
8939
|
+
}
|
|
8940
|
+
}
|
|
8941
|
+
const myContainers = ConvertUtils.flatArray(this.option.container).filter(ValidUtils.isDefined);
|
|
8942
|
+
Array.from(sims.entries()).forEach(([type, value]) => {
|
|
8943
|
+
const targetContainers = ConvertUtils.flatArray(getSim(type)?.container).filter(ValidUtils.isDefined);
|
|
8944
|
+
let isInclude = false;
|
|
8945
|
+
if (myContainers.length <= 0 && targetContainers.length <= 0) {
|
|
8946
|
+
isInclude = true;
|
|
8947
|
+
} else if (targetContainers.length <= 0) {
|
|
8948
|
+
isInclude = true;
|
|
8949
|
+
} else {
|
|
8950
|
+
isInclude = myContainers.some((it) => targetContainers.includes(it));
|
|
8951
|
+
}
|
|
8952
|
+
this.registerStore(type, value);
|
|
8953
|
+
});
|
|
8954
|
+
this.callBindPostConstruct(this);
|
|
8955
|
+
this.getSimAtomics().forEach((it) => {
|
|
8956
|
+
if (it.getConfig()?.autoCreate) {
|
|
8957
|
+
it.getValue();
|
|
8958
|
+
}
|
|
8959
|
+
});
|
|
8960
|
+
}
|
|
8961
|
+
};
|
|
8962
|
+
|
|
8963
|
+
// ../simple-boot/dist/esm/intent/Intent.js
|
|
8964
|
+
var Intent = class {
|
|
8965
|
+
constructor(uri, data, event) {
|
|
8966
|
+
this.uri = uri;
|
|
8967
|
+
this.data = data;
|
|
8968
|
+
this.event = event;
|
|
8969
|
+
this.sessionData = /* @__PURE__ */ new Map();
|
|
8970
|
+
if (typeof uri === "string") {
|
|
8971
|
+
const match = uri.match(/^Symbol\.for\((.+)\):\/(.*)$/);
|
|
8972
|
+
if (match) {
|
|
8973
|
+
const symbol = Symbol.for(match[1]);
|
|
8974
|
+
this.uri = {
|
|
8975
|
+
symbol,
|
|
8976
|
+
uri: match[2]
|
|
8977
|
+
};
|
|
8978
|
+
}
|
|
8979
|
+
}
|
|
8980
|
+
}
|
|
8981
|
+
get symbols() {
|
|
8982
|
+
if (typeof this.uri === "object") {
|
|
8983
|
+
return Array.isArray(this.uri.symbol) ? this.uri.symbol : [this.uri.symbol];
|
|
8984
|
+
}
|
|
8985
|
+
return void 0;
|
|
8986
|
+
}
|
|
8987
|
+
get scheme() {
|
|
8988
|
+
if (typeof this.uri === "string") {
|
|
8989
|
+
const parts = this.uri.split("://");
|
|
8990
|
+
if (parts.length > 1) {
|
|
8991
|
+
return parts[0];
|
|
8992
|
+
}
|
|
8993
|
+
return void 0;
|
|
8994
|
+
} else {
|
|
8995
|
+
return void 0;
|
|
8996
|
+
}
|
|
8997
|
+
}
|
|
8998
|
+
get paths() {
|
|
8999
|
+
return this.pathname.split("/") ?? [];
|
|
9000
|
+
}
|
|
9001
|
+
get fullPath() {
|
|
9002
|
+
const uri = typeof this.uri === "string" ? this.uri : this.uri.uri;
|
|
9003
|
+
const paths = uri.split("://");
|
|
9004
|
+
return paths[paths.length >= 2 ? 1 : 0] ?? "";
|
|
9005
|
+
}
|
|
9006
|
+
get pathname() {
|
|
9007
|
+
const paths = this.fullPath.split("?");
|
|
9008
|
+
return paths[0];
|
|
9009
|
+
}
|
|
9010
|
+
get query() {
|
|
9011
|
+
const paths = this.fullPath.split("?");
|
|
9012
|
+
return paths[1] ?? "";
|
|
9013
|
+
}
|
|
9014
|
+
getQueryParamDecodeURI(key) {
|
|
9015
|
+
const p = this.queryParamsDecodeURI;
|
|
9016
|
+
if (key) {
|
|
9017
|
+
return p[key];
|
|
9018
|
+
} else {
|
|
9019
|
+
return p;
|
|
9020
|
+
}
|
|
9021
|
+
}
|
|
9022
|
+
getQueryParamDecodeURIFirst(key) {
|
|
9023
|
+
const param = this.getQueryParamDecodeURI(key);
|
|
9024
|
+
if (Array.isArray(param)) {
|
|
9025
|
+
return param[0];
|
|
9026
|
+
} else {
|
|
9027
|
+
return param;
|
|
9028
|
+
}
|
|
9029
|
+
}
|
|
9030
|
+
getQueryParam(key) {
|
|
9031
|
+
const p = this.queryParams;
|
|
9032
|
+
if (key) {
|
|
9033
|
+
return p[key];
|
|
9034
|
+
} else {
|
|
9035
|
+
return p;
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
getQueryParamFirst(key) {
|
|
9039
|
+
const param = this.getQueryParam(key);
|
|
9040
|
+
if (Array.isArray(param)) {
|
|
9041
|
+
return param[0];
|
|
9042
|
+
} else {
|
|
9043
|
+
return param;
|
|
9044
|
+
}
|
|
9045
|
+
}
|
|
9046
|
+
get queryParams() {
|
|
9047
|
+
const param = {};
|
|
9048
|
+
this.query.split("&")?.forEach((it) => {
|
|
9049
|
+
const a = it.split("=");
|
|
9050
|
+
if (param[a[0]]) {
|
|
9051
|
+
if (Array.isArray(param[a[0]])) {
|
|
9052
|
+
param[a[0]].push(a[1]);
|
|
9053
|
+
} else {
|
|
9054
|
+
param[a[0]] = [param[a[0]], a[1]];
|
|
9055
|
+
}
|
|
9056
|
+
} else {
|
|
9057
|
+
param[a[0]] = a[1];
|
|
9058
|
+
}
|
|
9059
|
+
});
|
|
9060
|
+
return param;
|
|
9061
|
+
}
|
|
9062
|
+
get queryParamsDecodeURI() {
|
|
9063
|
+
const params = this.queryParams;
|
|
9064
|
+
for (const key in params) {
|
|
9065
|
+
if (params.hasOwnProperty(key)) {
|
|
9066
|
+
const param = params[key];
|
|
9067
|
+
if (Array.isArray(param)) {
|
|
9068
|
+
params[key] = param.map((p) => decodeURIComponent(p));
|
|
9069
|
+
} else {
|
|
9070
|
+
params[key] = decodeURIComponent(param);
|
|
9071
|
+
}
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9074
|
+
return params;
|
|
9075
|
+
}
|
|
9076
|
+
getPathnameData(urlExpression) {
|
|
9077
|
+
return Expression.Path.pathNameData(this.pathname, urlExpression);
|
|
9078
|
+
}
|
|
9079
|
+
get isSymbolScheme() {
|
|
9080
|
+
return this.symbols !== void 0;
|
|
9081
|
+
}
|
|
9082
|
+
};
|
|
9083
|
+
|
|
9084
|
+
// ../simple-boot/dist/esm/intent/IntentSubscribe.js
|
|
9085
|
+
var isIntentSubscribe = (obj) => {
|
|
9086
|
+
return !!obj && typeof obj.intentSubscribe === "function";
|
|
9087
|
+
};
|
|
9088
|
+
|
|
9089
|
+
// ../simple-boot/dist/esm/intent/IntentManager.js
|
|
9090
|
+
var isRouterPublishType = (it) => typeof it === "object" && it !== null && typeof it.router === "string" && typeof it.rootRouter === "function";
|
|
9091
|
+
var isSymbolPublishType = (it) => typeof it === "object" && it !== null && "symbol" in it && "path" in it;
|
|
9092
|
+
var isSchemePublishType = (it) => typeof it === "object" && it !== null && "scheme" in it && "path" in it;
|
|
9093
|
+
var IntentManager = class {
|
|
9094
|
+
constructor(simpleApplication, simstanceManager, routerManager, simOption) {
|
|
9095
|
+
this.simpleApplication = simpleApplication;
|
|
9096
|
+
this.simstanceManager = simstanceManager;
|
|
9097
|
+
this.routerManager = routerManager;
|
|
9098
|
+
this.simOption = simOption;
|
|
9099
|
+
this.subject = new Subject();
|
|
9100
|
+
}
|
|
9101
|
+
get observable() {
|
|
9102
|
+
return this.subject.asObservable();
|
|
9103
|
+
}
|
|
9104
|
+
async makeIntentData(it, data) {
|
|
9105
|
+
const target = [];
|
|
9106
|
+
const rootRouter = isRouterPublishType(it) ? it.rootRouter : this.simOption.rootRouter;
|
|
9107
|
+
if (isRouterPublishType(it)) {
|
|
9108
|
+
it = it.router;
|
|
9109
|
+
}
|
|
9110
|
+
const routerMatch = typeof it === "string" && it.match(/^Router\((.+)\):\/(.*)$/);
|
|
9111
|
+
if (routerMatch && typeof it === "string") {
|
|
9112
|
+
const routerBasePath = routerMatch[1];
|
|
9113
|
+
const actualPath = routerMatch[2];
|
|
9114
|
+
const routerModule = await this.routerManager.routing(routerBasePath, {
|
|
9115
|
+
router: rootRouter
|
|
9116
|
+
});
|
|
9117
|
+
const instance = routerModule.getModuleInstance();
|
|
9118
|
+
if (instance) {
|
|
9119
|
+
target.push(instance);
|
|
9120
|
+
}
|
|
9121
|
+
it = new Intent(actualPath, data);
|
|
9122
|
+
} else if (isSymbolPublishType(it)) {
|
|
9123
|
+
it = new Intent({ symbol: it.symbol, uri: it.path }, data);
|
|
9124
|
+
} else if (isSchemePublishType(it)) {
|
|
9125
|
+
it = new Intent(`${it.scheme}://${it.path}`, data);
|
|
9126
|
+
} else if (typeof it === "string") {
|
|
9127
|
+
it = new Intent(it, data);
|
|
9128
|
+
}
|
|
9129
|
+
const intent = it;
|
|
9130
|
+
if (!routerMatch) {
|
|
9131
|
+
if (intent.symbols) {
|
|
9132
|
+
target.push(...intent.symbols.map((sym) => this.simstanceManager.findSims(sym)).flat());
|
|
9133
|
+
} else if (intent.scheme) {
|
|
9134
|
+
target.push(...this.simstanceManager.getSimConfig(intent.scheme));
|
|
9135
|
+
} else {
|
|
9136
|
+
target.push(...this.simstanceManager.getSimAtomics());
|
|
9137
|
+
}
|
|
9138
|
+
}
|
|
9139
|
+
return { intent, target };
|
|
9140
|
+
}
|
|
9141
|
+
async publishMeta(it, data) {
|
|
9142
|
+
const { intent, target } = await this.makeIntentData(it, data);
|
|
9143
|
+
const r = [];
|
|
9144
|
+
const targetInstances = target.map((it2) => {
|
|
9145
|
+
if (it2 instanceof SimAtomic) {
|
|
9146
|
+
return it2.getValue();
|
|
9147
|
+
} else {
|
|
9148
|
+
return it2;
|
|
9149
|
+
}
|
|
9150
|
+
});
|
|
9151
|
+
this.subject.next(intent);
|
|
9152
|
+
for (let data2 of targetInstances) {
|
|
9153
|
+
let orNewSim = data2;
|
|
9154
|
+
if (orNewSim) {
|
|
9155
|
+
const filteredPaths = intent.paths.filter((i) => i);
|
|
9156
|
+
if (filteredPaths.length > 0) {
|
|
9157
|
+
let callthis = orNewSim;
|
|
9158
|
+
let lastProp = "";
|
|
9159
|
+
filteredPaths.forEach((i) => {
|
|
9160
|
+
callthis = orNewSim;
|
|
9161
|
+
orNewSim = orNewSim?.[i];
|
|
9162
|
+
lastProp = i;
|
|
9163
|
+
});
|
|
9164
|
+
if (orNewSim && typeof orNewSim === "function") {
|
|
9165
|
+
const intentData = Array.isArray(intent.data) ? intent.data : intent.data !== void 0 ? [intent.data] : [];
|
|
9166
|
+
const result = await this.simstanceManager.executeBindParameterSimPromise({
|
|
9167
|
+
target: callthis,
|
|
9168
|
+
targetKey: lastProp,
|
|
9169
|
+
parameterCount: intentData.length,
|
|
9170
|
+
inputParameters: intentData,
|
|
9171
|
+
firstCheckMaker: [
|
|
9172
|
+
(obj, token, idx) => {
|
|
9173
|
+
if (idx < intentData.length) {
|
|
9174
|
+
return intentData[idx];
|
|
9175
|
+
}
|
|
9176
|
+
if (token === Intent && idx === 0) {
|
|
9177
|
+
return intent;
|
|
9178
|
+
}
|
|
9179
|
+
}
|
|
9180
|
+
]
|
|
9181
|
+
});
|
|
9182
|
+
r.push(result);
|
|
9183
|
+
} else if (orNewSim) {
|
|
9184
|
+
callthis[lastProp] = intent.data;
|
|
9185
|
+
r.push(callthis[lastProp]);
|
|
9186
|
+
}
|
|
9187
|
+
} else {
|
|
9188
|
+
const intentData = Array.isArray(intent.data) ? intent.data : intent.data !== void 0 ? [intent.data] : [];
|
|
9189
|
+
if (isIntentSubscribe(orNewSim)) {
|
|
9190
|
+
r.push(orNewSim.intentSubscribe(...intentData));
|
|
9191
|
+
}
|
|
9192
|
+
}
|
|
9193
|
+
}
|
|
9194
|
+
}
|
|
9195
|
+
return { return: r, target };
|
|
9196
|
+
}
|
|
9197
|
+
async publish(it, data) {
|
|
9198
|
+
const rdata = await this.publishMeta(it, data);
|
|
9199
|
+
return rdata.return;
|
|
9200
|
+
}
|
|
9201
|
+
};
|
|
9202
|
+
|
|
9203
|
+
// ../simple-boot/dist/esm/decorators/inject/Injection.js
|
|
9204
|
+
var InjectionMetadataKey = Symbol("Injection");
|
|
9205
|
+
var getInjection = (target, propertyKey) => {
|
|
9206
|
+
return ReflectUtils.getMetadata(InjectionMetadataKey, target, propertyKey);
|
|
9207
|
+
};
|
|
9208
|
+
|
|
9209
|
+
// ../simple-boot/dist/esm/throwable/MethodNoSuch.js
|
|
9210
|
+
var MethodNoSuch = class extends SimError {
|
|
9211
|
+
constructor(message, name, propertyKeys, stack) {
|
|
9212
|
+
super(message, name, stack);
|
|
9213
|
+
this.propertyKeys = propertyKeys;
|
|
9214
|
+
}
|
|
9215
|
+
};
|
|
9216
|
+
|
|
9217
|
+
// ../simple-boot/dist/esm/decorators/route/Router.js
|
|
9218
|
+
var RouterMetadataKey = Symbol("Router");
|
|
9219
|
+
var getRouter = (target) => {
|
|
9220
|
+
if (target != null && typeof target === "object") {
|
|
9221
|
+
target = target.constructor;
|
|
9222
|
+
}
|
|
9223
|
+
try {
|
|
9224
|
+
return ReflectUtils.getMetadata(RouterMetadataKey, target);
|
|
9225
|
+
} catch (e) {
|
|
9226
|
+
}
|
|
9227
|
+
};
|
|
9228
|
+
var RouteMetadataKey = Symbol("RouteMetadataKey");
|
|
9229
|
+
|
|
9230
|
+
// ../simple-boot/dist/esm/route/RouterModule.js
|
|
9231
|
+
var RouterModule = class {
|
|
9232
|
+
constructor(simstanceManager, router, module, routerChains = []) {
|
|
9233
|
+
this.simstanceManager = simstanceManager;
|
|
9234
|
+
this.router = router;
|
|
9235
|
+
this.module = module;
|
|
9236
|
+
this.routerChains = routerChains;
|
|
9237
|
+
}
|
|
9238
|
+
get path() {
|
|
9239
|
+
return this._path;
|
|
9240
|
+
}
|
|
9241
|
+
set path(value) {
|
|
9242
|
+
this._path = value;
|
|
9243
|
+
}
|
|
9244
|
+
get data() {
|
|
9245
|
+
return this._data;
|
|
9246
|
+
}
|
|
9247
|
+
set data(value) {
|
|
9248
|
+
this._data = value;
|
|
9249
|
+
}
|
|
9250
|
+
get intent() {
|
|
9251
|
+
return this._intent;
|
|
9252
|
+
}
|
|
9253
|
+
set intent(value) {
|
|
9254
|
+
this._intent = value;
|
|
9255
|
+
}
|
|
9256
|
+
get propertyKeys() {
|
|
9257
|
+
return this._propertyKeys;
|
|
9258
|
+
}
|
|
9259
|
+
set propertyKeys(value) {
|
|
9260
|
+
this._propertyKeys = value;
|
|
9261
|
+
}
|
|
9262
|
+
get pathData() {
|
|
9263
|
+
return this._pathData;
|
|
9264
|
+
}
|
|
9265
|
+
getPathData() {
|
|
9266
|
+
return this._pathData;
|
|
9267
|
+
}
|
|
9268
|
+
set pathData(value) {
|
|
9269
|
+
this._pathData = value;
|
|
9270
|
+
}
|
|
9271
|
+
getRouterPath(join = "") {
|
|
9272
|
+
return this.getRouterPaths().map((it) => it ?? "").join(join);
|
|
9273
|
+
}
|
|
9274
|
+
getRouterPaths() {
|
|
9275
|
+
return this.routerChains.map((it) => getRouter(it instanceof SimAtomic ? it.type.targetKeyType : it)?.path);
|
|
9276
|
+
}
|
|
9277
|
+
getRouterPathData(pathName) {
|
|
9278
|
+
return Expression.Path.pathNameData(pathName, this.getRouterPath());
|
|
9279
|
+
}
|
|
9280
|
+
getModuleInstance(propertyKey, instanceBind = true) {
|
|
9281
|
+
const instance = this.simstanceManager.getOrNewSim({ target: this.module?.targetKeyType, originTypeTarget: this.module?.originalType });
|
|
9282
|
+
if (propertyKey && this.propertyKeys && this.propertyKeys.includes(propertyKey)) {
|
|
9283
|
+
let instanceElement = instance[propertyKey];
|
|
9284
|
+
if (instanceBind && typeof instanceBind === "boolean") {
|
|
9285
|
+
instanceElement = instanceElement.bind(instance);
|
|
9286
|
+
} else if (instanceBind && typeof instanceBind === "object") {
|
|
9287
|
+
instanceElement = instanceElement.bind(instanceBind);
|
|
9288
|
+
}
|
|
9289
|
+
return instanceElement;
|
|
9290
|
+
} else {
|
|
9291
|
+
return instance;
|
|
9292
|
+
}
|
|
9293
|
+
}
|
|
9294
|
+
executeModuleProperty(propertyKey, ...param) {
|
|
9295
|
+
const target = this.getModuleInstance();
|
|
9296
|
+
if (propertyKey) {
|
|
9297
|
+
const config = getInjection(target, propertyKey);
|
|
9298
|
+
if (config) {
|
|
9299
|
+
const other = /* @__PURE__ */ new Map();
|
|
9300
|
+
param.forEach((it) => other.set(it.constructor, it));
|
|
9301
|
+
return this.simstanceManager.executeBindParameterSim({ target, targetKey: propertyKey }, other);
|
|
9302
|
+
} else {
|
|
9303
|
+
if (target[propertyKey]) {
|
|
9304
|
+
return target[propertyKey]?.(...param);
|
|
9305
|
+
} else {
|
|
9306
|
+
throw new MethodNoSuch(`${propertyKey.toString()} noSuch`, propertyKey.toString(), propertyKey);
|
|
9307
|
+
}
|
|
9308
|
+
}
|
|
9309
|
+
}
|
|
9310
|
+
}
|
|
9311
|
+
get firstRouteChain() {
|
|
9312
|
+
return this.routerChains[0];
|
|
9313
|
+
}
|
|
9314
|
+
get firstRouteChainValue() {
|
|
9315
|
+
return this.firstRouteChain?.getValue();
|
|
9316
|
+
}
|
|
9317
|
+
get lastRouteChain() {
|
|
9318
|
+
return this.routerChains[this.routerChains.length - 1];
|
|
9319
|
+
}
|
|
9320
|
+
get lastRouteChainValue() {
|
|
9321
|
+
return this.lastRouteChain?.getValue();
|
|
9322
|
+
}
|
|
9323
|
+
hasActivateInLastRoute(obj) {
|
|
9324
|
+
return this.lastRouteChainValue?.hasActivate(obj) === true;
|
|
9325
|
+
}
|
|
9326
|
+
getQueryParamDecodeURI(key) {
|
|
9327
|
+
if (this.intent) {
|
|
9328
|
+
return this.intent.getQueryParamDecodeURI(key);
|
|
9329
|
+
}
|
|
9330
|
+
}
|
|
9331
|
+
getQueryParamDecodeURIFirst(key) {
|
|
9332
|
+
if (this.intent) {
|
|
9333
|
+
return this.intent.getQueryParamDecodeURIFirst(key);
|
|
9334
|
+
}
|
|
9335
|
+
}
|
|
9336
|
+
getQueryParam(key) {
|
|
9337
|
+
if (this.intent) {
|
|
9338
|
+
return this.intent.getQueryParam(key);
|
|
9339
|
+
}
|
|
9340
|
+
}
|
|
9341
|
+
getQueryParamFirst(key) {
|
|
9342
|
+
if (this.intent) {
|
|
9343
|
+
return this.intent.getQueryParamFirst(key);
|
|
9344
|
+
}
|
|
9345
|
+
}
|
|
9346
|
+
get queryParams() {
|
|
9347
|
+
if (this.intent) {
|
|
9348
|
+
return this.intent.queryParams;
|
|
9349
|
+
}
|
|
9350
|
+
}
|
|
9351
|
+
get queryParamsAfterDecodeURI() {
|
|
9352
|
+
if (this.intent) {
|
|
9353
|
+
return this.intent.queryParamsDecodeURI;
|
|
9354
|
+
}
|
|
9355
|
+
}
|
|
9356
|
+
};
|
|
9357
|
+
|
|
9358
|
+
// ../simple-boot/dist/esm/route/RouterAction.js
|
|
9359
|
+
var RouterAction;
|
|
9360
|
+
((RouterAction2) => {
|
|
9361
|
+
RouterAction2.isCanActivate = (obj) => {
|
|
9362
|
+
return typeof obj?.canActivate === "function";
|
|
9363
|
+
};
|
|
9364
|
+
RouterAction2.isOnRouting = (obj) => {
|
|
9365
|
+
return typeof obj?.onRouting === "function";
|
|
9366
|
+
};
|
|
9367
|
+
RouterAction2.isHasActivate = (obj) => {
|
|
9368
|
+
return typeof obj?.hasActivate === "function";
|
|
9369
|
+
};
|
|
9370
|
+
})(RouterAction || (RouterAction = {}));
|
|
9371
|
+
|
|
9372
|
+
// ../simple-boot/dist/esm/route/RouterManager.js
|
|
9373
|
+
var RouterManager = class {
|
|
9374
|
+
constructor(simpleApplication, simstanceManager, simOption) {
|
|
9375
|
+
this.simpleApplication = simpleApplication;
|
|
9376
|
+
this.simstanceManager = simstanceManager;
|
|
9377
|
+
this.simOption = simOption;
|
|
9378
|
+
this.subject = new Subject();
|
|
9379
|
+
}
|
|
9380
|
+
// @SimNoProxy
|
|
9381
|
+
get observable() {
|
|
9382
|
+
return this.subject.asObservable();
|
|
9383
|
+
}
|
|
9384
|
+
routingMap(option) {
|
|
9385
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9386
|
+
if (!targetRouter) {
|
|
9387
|
+
throw new Error("no router");
|
|
9388
|
+
}
|
|
9389
|
+
const map = {};
|
|
9390
|
+
if (targetRouter) {
|
|
9391
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9392
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9393
|
+
const routerAtomic = new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9394
|
+
const routerData = routerAtomic.getConfig(RouterMetadataKey);
|
|
9395
|
+
if (routerData) {
|
|
9396
|
+
const currentPrefix = (option?.prefix ?? "") + routerData.path;
|
|
9397
|
+
if (routerData.route && routerData.route[""]) {
|
|
9398
|
+
map[currentPrefix] = routerData.route[""];
|
|
9399
|
+
}
|
|
9400
|
+
if (routerData.route) {
|
|
9401
|
+
Object.entries(routerData.route).forEach(([key, value]) => {
|
|
9402
|
+
map[currentPrefix + key] = value;
|
|
9403
|
+
});
|
|
9404
|
+
}
|
|
9405
|
+
routerData.routers?.forEach((it) => {
|
|
9406
|
+
Object.assign(map, this.routingMap({ ...option, router: it, prefix: currentPrefix }));
|
|
9407
|
+
});
|
|
9408
|
+
}
|
|
9409
|
+
}
|
|
9410
|
+
return map;
|
|
9411
|
+
}
|
|
9412
|
+
/** 일반적인 lifecycle 타지않는 그냥 find.. 의미가없을듯.
|
|
9413
|
+
* @deprecated
|
|
9414
|
+
*/
|
|
9415
|
+
async routings(intent, option) {
|
|
9416
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9417
|
+
if (!targetRouter) {
|
|
9418
|
+
throw new Error("no router");
|
|
9419
|
+
}
|
|
9420
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9421
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9422
|
+
const routerAtomic = new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9423
|
+
const allMatches = this._collectAllMatchingModules(routerAtomic, intent, []);
|
|
9424
|
+
const exactModuleMatches = allMatches.filter((rm) => rm.path === intent.pathname && rm.module);
|
|
9425
|
+
if (exactModuleMatches.length > 0) {
|
|
9426
|
+
exactModuleMatches.forEach((it) => this.subject.next({ intent, routerManager: this, routerModule: it }));
|
|
9427
|
+
return exactModuleMatches;
|
|
9428
|
+
}
|
|
9429
|
+
const exactPathMatches = allMatches.filter((rm) => rm.path === intent.pathname);
|
|
9430
|
+
if (exactPathMatches.length > 0) {
|
|
9431
|
+
exactPathMatches.forEach((it) => this.subject.next({ intent, routerManager: this, routerModule: it }));
|
|
9432
|
+
return exactPathMatches;
|
|
9433
|
+
}
|
|
9434
|
+
return [];
|
|
9435
|
+
}
|
|
9436
|
+
async routing(intent, option) {
|
|
9437
|
+
if (typeof intent === "string") {
|
|
9438
|
+
intent = new Intent(intent);
|
|
9439
|
+
}
|
|
9440
|
+
const targetRouter = option?.router ?? this.simOption.rootRouter;
|
|
9441
|
+
const callCheckOnRouting = option?.noOnRouting !== true;
|
|
9442
|
+
if (!targetRouter) {
|
|
9443
|
+
debugger;
|
|
9444
|
+
throw new Error("no router");
|
|
9445
|
+
}
|
|
9446
|
+
const targetType = typeof targetRouter === "object" ? targetRouter.constructor : targetRouter;
|
|
9447
|
+
const targetValue = typeof targetRouter === "object" ? targetRouter : void 0;
|
|
9448
|
+
const routerAtomic = typeof targetType === "symbol" ? this.simstanceManager.findFirstSim(targetType) : new SimAtomic({ targetKeyType: targetType, originalType: targetType, value: targetValue }, this.simstanceManager);
|
|
9449
|
+
const rootRouter = routerAtomic.getValue();
|
|
9450
|
+
const executeModuleResult = this.getExecuteModule(routerAtomic, intent, [], option);
|
|
9451
|
+
if (executeModuleResult) {
|
|
9452
|
+
const [executeModule, routerChains] = executeModuleResult;
|
|
9453
|
+
executeModule.routerChains = routerChains;
|
|
9454
|
+
this.activeRouterModule = executeModule;
|
|
9455
|
+
const routingDataSet = { intent, routerModule: executeModule, routerManager: this };
|
|
9456
|
+
if (routerChains.length > 0) {
|
|
9457
|
+
for (let i = 0; i < routerChains.length; i++) {
|
|
9458
|
+
const current = routerChains[i];
|
|
9459
|
+
const next = routerChains[i + 1];
|
|
9460
|
+
const value = current.getValue();
|
|
9461
|
+
if (RouterAction.isCanActivate(value) && next) {
|
|
9462
|
+
await value.canActivate(routingDataSet, next.getValue());
|
|
9463
|
+
}
|
|
9464
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value) && next) {
|
|
9465
|
+
await value.onRouting(routingDataSet);
|
|
9466
|
+
}
|
|
9467
|
+
}
|
|
9468
|
+
}
|
|
9469
|
+
this.activeRouterModule = executeModule;
|
|
9470
|
+
const moduleInstance = executeModule.getModuleInstance();
|
|
9471
|
+
if (!executeModule?.module) {
|
|
9472
|
+
const routerChain = executeModule.routerChains[executeModule.routerChains.length - 1];
|
|
9473
|
+
const value = routerChain?.getValue();
|
|
9474
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9475
|
+
await value.canActivate(routingDataSet, moduleInstance);
|
|
9476
|
+
}
|
|
9477
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value)) {
|
|
9478
|
+
await value.onRouting(routingDataSet);
|
|
9479
|
+
}
|
|
9480
|
+
} else {
|
|
9481
|
+
const value = executeModule.router?.getValue();
|
|
9482
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9483
|
+
await value.canActivate(routingDataSet, moduleInstance);
|
|
9484
|
+
}
|
|
9485
|
+
if (callCheckOnRouting && RouterAction.isOnRouting(value)) {
|
|
9486
|
+
await value.onRouting(routingDataSet);
|
|
9487
|
+
}
|
|
9488
|
+
if (moduleInstance && callCheckOnRouting && RouterAction.isOnRouting(moduleInstance)) {
|
|
9489
|
+
await moduleInstance.onRouting(routingDataSet);
|
|
9490
|
+
}
|
|
9491
|
+
}
|
|
9492
|
+
const find = this.activeRouterModule;
|
|
9493
|
+
this.subject.next({ intent, routerModule: find, routerManager: this });
|
|
9494
|
+
return find;
|
|
9495
|
+
} else {
|
|
9496
|
+
const empty = await this._handleNotFoundRouting(rootRouter, intent);
|
|
9497
|
+
this.subject.next({ intent, routerModule: empty, routerManager: this });
|
|
9498
|
+
return empty;
|
|
9499
|
+
}
|
|
9500
|
+
}
|
|
9501
|
+
/**
|
|
9502
|
+
* URL과 일치하는 라우트를 찾지 못했을 경우를 처리합니다.
|
|
9503
|
+
* "Not Found" 상태를 나타내는 비어있는 RouterModule 객체를 생성하여 반환합니다.
|
|
9504
|
+
* 이 과정에서 rootRouter의 라이프사이클을 호출하여 공통 레이아웃등을 처리할 수 있습니다.
|
|
9505
|
+
* @param rootRouter 앱의 최상위 라우터 인스턴스
|
|
9506
|
+
* @param intent 확인에 실패한 원본 Intent 객체
|
|
9507
|
+
* @private
|
|
9508
|
+
*/
|
|
9509
|
+
async _handleNotFoundRouting(rootRouter, intent) {
|
|
9510
|
+
const routerModule = new RouterModule(this.simstanceManager, rootRouter, void 0, []);
|
|
9511
|
+
const routingDataSet = { intent, routerModule, routerManager: this };
|
|
9512
|
+
const value = rootRouter;
|
|
9513
|
+
if (RouterAction.isCanActivate(value)) {
|
|
9514
|
+
await value.canActivate(routingDataSet, null);
|
|
9515
|
+
}
|
|
9516
|
+
if (RouterAction.isOnRouting(value)) {
|
|
9517
|
+
await value.onRouting(routingDataSet);
|
|
9518
|
+
}
|
|
9519
|
+
this.activeRouterModule = routerModule;
|
|
9520
|
+
return this.activeRouterModule;
|
|
9521
|
+
}
|
|
9522
|
+
getExecuteModule(router, intent, parentRouters, option) {
|
|
9523
|
+
const path = intent.pathname;
|
|
9524
|
+
const routerConfig = router.getConfig(RouterMetadataKey);
|
|
9525
|
+
if (routerConfig) {
|
|
9526
|
+
const filters = [];
|
|
9527
|
+
if (Array.isArray(routerConfig.filters)) {
|
|
9528
|
+
filters.push(...routerConfig.filters);
|
|
9529
|
+
} else if (routerConfig.filters) {
|
|
9530
|
+
filters.push(routerConfig.filters);
|
|
9531
|
+
}
|
|
9532
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9533
|
+
if (noAccept) {
|
|
9534
|
+
return;
|
|
9535
|
+
}
|
|
9536
|
+
const routerStrings = parentRouters.map((it) => it.getConfig(RouterMetadataKey)?.path || "");
|
|
9537
|
+
const isRoot = this.isRootUrl(routerConfig.path, routerStrings, path);
|
|
9538
|
+
if (isRoot) {
|
|
9539
|
+
const currentParentRouters = [...parentRouters, router];
|
|
9540
|
+
if (routerConfig.routers && routerConfig.routers.length > 0) {
|
|
9541
|
+
let bestMatchModule = void 0;
|
|
9542
|
+
let bestMatchLength = -1;
|
|
9543
|
+
for (const child of routerConfig.routers) {
|
|
9544
|
+
const routerAtomic = typeof child === "symbol" ? this.simstanceManager.findFirstSim(child) : new SimAtomic({ targetKeyType: child, originalType: child }, this.simstanceManager);
|
|
9545
|
+
if (!routerAtomic) {
|
|
9546
|
+
continue;
|
|
9547
|
+
}
|
|
9548
|
+
const executeModule = this.getExecuteModule(routerAtomic, intent, currentParentRouters, option);
|
|
9549
|
+
if (executeModule) {
|
|
9550
|
+
const [rm, chains] = executeModule;
|
|
9551
|
+
const currentMatchLength = rm.path?.length || 0;
|
|
9552
|
+
if (currentMatchLength > bestMatchLength) {
|
|
9553
|
+
bestMatchLength = currentMatchLength;
|
|
9554
|
+
bestMatchModule = executeModule;
|
|
9555
|
+
} else if (currentMatchLength === bestMatchLength) {
|
|
9556
|
+
if (option?.find?.router === "last") {
|
|
9557
|
+
bestMatchModule = executeModule;
|
|
9558
|
+
}
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
}
|
|
9562
|
+
if (bestMatchModule) {
|
|
9563
|
+
return bestMatchModule;
|
|
9564
|
+
}
|
|
9565
|
+
}
|
|
9566
|
+
const module = this.findRouterOrModule(router, routerConfig, routerStrings, intent);
|
|
9567
|
+
if (module) {
|
|
9568
|
+
return [module, currentParentRouters];
|
|
9569
|
+
}
|
|
9570
|
+
}
|
|
9571
|
+
}
|
|
9572
|
+
}
|
|
9573
|
+
// path: 지금 내 라우터의 path, parentRoots: 부모router path들, url: 사용자가 원하는 full intent url
|
|
9574
|
+
isRootUrl(path, parentRoots, url) {
|
|
9575
|
+
const searchString = parentRoots.join("") + (path || "");
|
|
9576
|
+
if (searchString === "/") {
|
|
9577
|
+
return true;
|
|
9578
|
+
}
|
|
9579
|
+
const searchs = searchString.split("/");
|
|
9580
|
+
const urls = url.split("/");
|
|
9581
|
+
const trimmedUrls = urls.slice(0, searchs.length).join("/");
|
|
9582
|
+
return !!Expression.Path.pathNameData(trimmedUrls, searchString);
|
|
9583
|
+
}
|
|
9584
|
+
_collectAllMatchingModules(router, intent, parentRouters) {
|
|
9585
|
+
const matches = [];
|
|
9586
|
+
const path = intent.pathname;
|
|
9587
|
+
const routerConfig = router.getConfig(RouterMetadataKey);
|
|
9588
|
+
if (routerConfig) {
|
|
9589
|
+
const filters = [];
|
|
9590
|
+
if (Array.isArray(routerConfig.filters)) {
|
|
9591
|
+
filters.push(...routerConfig.filters);
|
|
9592
|
+
} else if (routerConfig.filters) {
|
|
9593
|
+
filters.push(routerConfig.filters);
|
|
9594
|
+
}
|
|
9595
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9596
|
+
if (noAccept) {
|
|
9597
|
+
return matches;
|
|
9598
|
+
}
|
|
9599
|
+
const routerStrings = parentRouters.map((it) => it.getConfig(RouterMetadataKey)?.path || "");
|
|
9600
|
+
const isRoot = this.isRootUrl(routerConfig.path, routerStrings, path);
|
|
9601
|
+
if (isRoot) {
|
|
9602
|
+
const currentParentRouters = [...parentRouters, router];
|
|
9603
|
+
if (routerConfig.routers && routerConfig.routers.length > 0) {
|
|
9604
|
+
for (const child of routerConfig.routers) {
|
|
9605
|
+
const routerAtomic = typeof child === "symbol" ? this.simstanceManager.findFirstSim(child) : new SimAtomic({ targetKeyType: child, originalType: child }, this.simstanceManager);
|
|
9606
|
+
if (!routerAtomic) {
|
|
9607
|
+
continue;
|
|
9608
|
+
}
|
|
9609
|
+
matches.push(...this._collectAllMatchingModules(routerAtomic, intent, currentParentRouters));
|
|
9610
|
+
}
|
|
9611
|
+
}
|
|
9612
|
+
const module = this.findRouterOrModule(router, routerConfig, routerStrings, intent);
|
|
9613
|
+
if (module) {
|
|
9614
|
+
module.routerChains = currentParentRouters;
|
|
9615
|
+
matches.push(module);
|
|
9616
|
+
}
|
|
9617
|
+
}
|
|
9618
|
+
}
|
|
9619
|
+
return matches;
|
|
9620
|
+
}
|
|
9621
|
+
findRouterOrModule(router, routerData, parentRoots, intent) {
|
|
9622
|
+
const module = this.findRouting(router, routerData, parentRoots, intent);
|
|
9623
|
+
if (module?.module) {
|
|
9624
|
+
module.intent = intent;
|
|
9625
|
+
return module;
|
|
9626
|
+
}
|
|
9627
|
+
const urlRoot = parentRoots.join("") + (routerData.path || "");
|
|
9628
|
+
if (this.isRootUrl(routerData.path, parentRoots, intent.pathname)) {
|
|
9629
|
+
const rm = new RouterModule(this.simstanceManager, router);
|
|
9630
|
+
rm.intent = intent;
|
|
9631
|
+
rm.path = urlRoot;
|
|
9632
|
+
rm.pathData = intent.getPathnameData(urlRoot);
|
|
9633
|
+
return rm;
|
|
9634
|
+
}
|
|
9635
|
+
return void 0;
|
|
9636
|
+
}
|
|
9637
|
+
findRouting(router, routerData, parentRoots, intent) {
|
|
9638
|
+
const urlRoot = parentRoots.join("") + routerData.path;
|
|
9639
|
+
if (routerData.route) {
|
|
9640
|
+
for (const it of Object.keys(routerData.route).filter((it2) => !it2.startsWith("_"))) {
|
|
9641
|
+
const path = urlRoot + it;
|
|
9642
|
+
const pathnameData = intent.getPathnameData(path);
|
|
9643
|
+
if (pathnameData) {
|
|
9644
|
+
try {
|
|
9645
|
+
const dataSet = this.findRouteProperty(routerData.route, it, intent);
|
|
9646
|
+
const rm = new RouterModule(this.simstanceManager, router, dataSet.child);
|
|
9647
|
+
rm.data = dataSet.data;
|
|
9648
|
+
rm.path = path;
|
|
9649
|
+
rm.pathData = pathnameData;
|
|
9650
|
+
rm.propertyKeys = dataSet.propertyKeys;
|
|
9651
|
+
return rm;
|
|
9652
|
+
} catch (e) {
|
|
9653
|
+
}
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9656
|
+
}
|
|
9657
|
+
}
|
|
9658
|
+
findRouteProperty(route, propertyName, intent) {
|
|
9659
|
+
let child;
|
|
9660
|
+
let data;
|
|
9661
|
+
let propertyKeys;
|
|
9662
|
+
const routeElement = route[propertyName];
|
|
9663
|
+
if (typeof routeElement === "function") {
|
|
9664
|
+
child = { targetKeyType: routeElement, originalType: routeElement };
|
|
9665
|
+
} else if (typeof routeElement === "symbol") {
|
|
9666
|
+
const findSimType = this.simstanceManager.findLastSim(routeElement)?.type;
|
|
9667
|
+
if (findSimType?.originalType) {
|
|
9668
|
+
child = { targetKeyType: findSimType.originalType, originalType: findSimType.originalType };
|
|
9669
|
+
}
|
|
9670
|
+
} else if (typeof routeElement === "string") {
|
|
9671
|
+
return this.findRouteProperty(route, routeElement, intent);
|
|
9672
|
+
} else if (Array.isArray(routeElement)) {
|
|
9673
|
+
const r = routeElement?.[0];
|
|
9674
|
+
if (typeof r === "object" && "filters" in r && "target" in r) {
|
|
9675
|
+
const filters = [];
|
|
9676
|
+
if (Array.isArray(r.filters)) {
|
|
9677
|
+
filters.push(...r.filters);
|
|
9678
|
+
} else if (r.filters) {
|
|
9679
|
+
filters.push(r.filters);
|
|
9680
|
+
}
|
|
9681
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9682
|
+
if (!noAccept) {
|
|
9683
|
+
child = { targetKeyType: r.target, originalType: r.target };
|
|
9684
|
+
}
|
|
9685
|
+
} else {
|
|
9686
|
+
child = { targetKeyType: r, originalType: r };
|
|
9687
|
+
}
|
|
9688
|
+
data = routeElement?.[1];
|
|
9689
|
+
} else if (typeof routeElement === "object" && "target" in routeElement && "propertyKeys" in routeElement) {
|
|
9690
|
+
const noAccept = routeElement.filters?.filter((it) => it).some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9691
|
+
if (!noAccept) {
|
|
9692
|
+
child = { targetKeyType: routeElement.target, originalType: routeElement.target };
|
|
9693
|
+
propertyKeys = routeElement.propertyKeys;
|
|
9694
|
+
}
|
|
9695
|
+
} else if (typeof routeElement === "object" && "filters" in routeElement && "target" in routeElement) {
|
|
9696
|
+
const filters = [];
|
|
9697
|
+
if (Array.isArray(routeElement.filters)) {
|
|
9698
|
+
filters.push(...routeElement.filters);
|
|
9699
|
+
} else if (routeElement.filters) {
|
|
9700
|
+
filters.push(routeElement.filters);
|
|
9701
|
+
}
|
|
9702
|
+
const noAccept = filters.some((it) => (typeof it === "function" ? this.simstanceManager.getOrNewSim({ target: it }) : it)?.isAccept(intent) === false);
|
|
9703
|
+
if (!noAccept) {
|
|
9704
|
+
child = { targetKeyType: routeElement.target, originalType: routeElement.target };
|
|
9705
|
+
}
|
|
9706
|
+
}
|
|
9707
|
+
return {
|
|
9708
|
+
child,
|
|
9709
|
+
data,
|
|
9710
|
+
propertyKeys
|
|
9711
|
+
};
|
|
9712
|
+
}
|
|
9713
|
+
};
|
|
9714
|
+
|
|
9715
|
+
// ../simple-boot/dist/esm/SimpleApplication.js
|
|
9716
|
+
var SimpleApplication = class _SimpleApplication {
|
|
9717
|
+
// public rootRouter?: ConstructorType<any>;
|
|
9718
|
+
// constructor();
|
|
9719
|
+
// constructor(option: SimOption);
|
|
9720
|
+
// constructor(rootRouter?: ConstructorType<Object> | Function);
|
|
9721
|
+
// constructor(rootRouter?: ConstructorType<Object> | Function, option?: SimOption);
|
|
9722
|
+
// constructor(rootRouter?: (ConstructorType<Object> | Function) | SimOption, option = new SimOption()) {
|
|
9723
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
9724
|
+
constructor(option = new SimOption()) {
|
|
9725
|
+
this.option = option;
|
|
9726
|
+
this.simstanceManager = new SimstanceManager(this, option);
|
|
9727
|
+
this.simstanceManager.setStoreSet(SimstanceManager, this.simstanceManager);
|
|
9728
|
+
this.routerManager = new RouterManager(this, this.simstanceManager, option);
|
|
9729
|
+
this.intentManager = new IntentManager(this, this.simstanceManager, this.routerManager, option);
|
|
9730
|
+
this.simstanceManager.setStoreSet(IntentManager, this.intentManager);
|
|
9731
|
+
this.simstanceManager.setStoreSet(RouterManager, this.routerManager);
|
|
9732
|
+
containers.add(this);
|
|
9733
|
+
}
|
|
9734
|
+
getSimstanceManager() {
|
|
9735
|
+
return this.simstanceManager;
|
|
9736
|
+
}
|
|
9737
|
+
getIntentManager() {
|
|
9738
|
+
return this.intentManager;
|
|
9739
|
+
}
|
|
9740
|
+
getRouterManager() {
|
|
9741
|
+
return this.routerManager;
|
|
9742
|
+
}
|
|
9743
|
+
run(otherInstanceSim) {
|
|
9744
|
+
otherInstanceSim ?? (otherInstanceSim = /* @__PURE__ */ new Map());
|
|
9745
|
+
otherInstanceSim.set(_SimpleApplication, this);
|
|
9746
|
+
this.simstanceManager.run(otherInstanceSim);
|
|
9747
|
+
return this;
|
|
9748
|
+
}
|
|
9749
|
+
simAtomic(type) {
|
|
9750
|
+
if (typeof type === "symbol") {
|
|
9751
|
+
return this.simstanceManager.findFirstSim(type);
|
|
9752
|
+
} else if (typeof type === "function") {
|
|
9753
|
+
return this.simstanceManager.findFirstSim({ type });
|
|
9754
|
+
}
|
|
9755
|
+
}
|
|
9756
|
+
simAtomics(type) {
|
|
9757
|
+
if (typeof type === "symbol") {
|
|
9758
|
+
return this.simstanceManager.findSims(type) ?? [];
|
|
9759
|
+
} else if (typeof type === "function") {
|
|
9760
|
+
return this.simstanceManager.findSims({ type }) ?? [];
|
|
9761
|
+
} else {
|
|
9762
|
+
return [];
|
|
9763
|
+
}
|
|
9764
|
+
}
|
|
9765
|
+
getInstance(type) {
|
|
9766
|
+
const i = this.sim(type);
|
|
9767
|
+
if (i) {
|
|
9768
|
+
return i;
|
|
9769
|
+
} else {
|
|
9770
|
+
throw new SimNoSuch("SimNoSuch: no simple instance(getInstance) name:" + type?.prototype?.constructor?.name + "," + type);
|
|
9771
|
+
}
|
|
9772
|
+
}
|
|
9773
|
+
sim(type) {
|
|
9774
|
+
return this.simAtomic(type)?.getValue();
|
|
9775
|
+
}
|
|
9776
|
+
sims(type) {
|
|
9777
|
+
return this.simAtomics(type).map((it) => it.getValue());
|
|
9778
|
+
}
|
|
9779
|
+
addSim(configOrTarget, target) {
|
|
9780
|
+
const r = Sim(configOrTarget);
|
|
9781
|
+
if (typeof r === "function" && target) {
|
|
9782
|
+
r(target);
|
|
9783
|
+
}
|
|
9784
|
+
}
|
|
9785
|
+
publishIntent(i, data) {
|
|
9786
|
+
return this.intentManager.publish(i, data);
|
|
9787
|
+
}
|
|
9788
|
+
routing(i, option) {
|
|
9789
|
+
if (i instanceof Intent) {
|
|
9790
|
+
return this.routerManager.routing(i, option);
|
|
9791
|
+
} else if (typeof i === "string") {
|
|
9792
|
+
const intent = new Intent(i);
|
|
9793
|
+
return this.routerManager.routing(intent, option);
|
|
9794
|
+
} else {
|
|
9795
|
+
const intent = new Intent(i.path, i.data);
|
|
9796
|
+
return this.routerManager.routing(intent, option);
|
|
9797
|
+
}
|
|
9798
|
+
}
|
|
9799
|
+
};
|
|
9800
|
+
|
|
9801
|
+
// ../core-web/dist/esm/element/CanvasUtils.js
|
|
9802
|
+
var CanvasUtils;
|
|
9803
|
+
((CanvasUtils2) => {
|
|
9804
|
+
let Context2D;
|
|
9805
|
+
((Context2D2) => {
|
|
9806
|
+
Context2D2.resetTransform = (context) => {
|
|
9807
|
+
context.setTransform(1, 0, 0, 1, 0, 0);
|
|
9808
|
+
};
|
|
9809
|
+
})(Context2D = CanvasUtils2.Context2D || (CanvasUtils2.Context2D = {}));
|
|
9810
|
+
CanvasUtils2.fontSize = (ctx, config) => {
|
|
9811
|
+
const { text, maxWidth, maxHeight, fontOption } = config;
|
|
9812
|
+
if (!text || maxWidth <= 0 || maxHeight <= 0) {
|
|
9813
|
+
return 0;
|
|
9814
|
+
}
|
|
9815
|
+
const lines = text.split("\n").filter((line) => line.trim().length > 0);
|
|
9816
|
+
if (lines.length === 0) {
|
|
9817
|
+
return 0;
|
|
9818
|
+
}
|
|
9819
|
+
const lineHeightMultiplier = 1.2;
|
|
9820
|
+
const maxFontSizeByHeight = Math.floor(maxHeight / (lines.length * lineHeightMultiplier));
|
|
9821
|
+
if (maxFontSizeByHeight <= 0) {
|
|
9822
|
+
return 0;
|
|
9823
|
+
}
|
|
9824
|
+
let minSizeForWidth = 1;
|
|
9825
|
+
let maxSizeForWidth = maxFontSizeByHeight;
|
|
9826
|
+
let bestSizeForWidth = 0;
|
|
9827
|
+
const maxIterations = 100;
|
|
9828
|
+
let iteration = 0;
|
|
9829
|
+
while (minSizeForWidth <= maxSizeForWidth && iteration < maxIterations) {
|
|
9830
|
+
const midSize = Math.floor((minSizeForWidth + maxSizeForWidth) / 2);
|
|
9831
|
+
if (midSize === 0) break;
|
|
9832
|
+
ctx.font = `${fontOption?.fontWeight || "normal"} ${midSize}px ${fontOption?.fontFamily || "sans-serif"}`;
|
|
9833
|
+
const maxLineWidth = Math.max(...lines.map((line) => ctx.measureText(line).width));
|
|
9834
|
+
if (maxLineWidth <= maxWidth) {
|
|
9835
|
+
bestSizeForWidth = midSize;
|
|
9836
|
+
minSizeForWidth = midSize + 1;
|
|
9837
|
+
} else {
|
|
9838
|
+
maxSizeForWidth = midSize - 1;
|
|
9839
|
+
}
|
|
9840
|
+
iteration++;
|
|
9841
|
+
}
|
|
9842
|
+
return Math.min(bestSizeForWidth, maxFontSizeByHeight);
|
|
9843
|
+
};
|
|
9844
|
+
CanvasUtils2.textMetrics = (context, text) => {
|
|
9845
|
+
return context.measureText(text);
|
|
9846
|
+
};
|
|
9847
|
+
})(CanvasUtils || (CanvasUtils = {}));
|
|
9848
|
+
|
|
9849
|
+
// ../core-web/dist/esm/element/ElementUtils.js
|
|
9850
|
+
var ElementUtils;
|
|
9851
|
+
((ElementUtils2) => {
|
|
9852
|
+
function removeAllChildren(el, els) {
|
|
9853
|
+
if (!els) {
|
|
9854
|
+
el.replaceChildren();
|
|
9855
|
+
} else if (Array.isArray(els)) {
|
|
9856
|
+
el.replaceChildren(...els);
|
|
9857
|
+
} else {
|
|
9858
|
+
el.replaceChildren(els);
|
|
7966
9859
|
}
|
|
7967
9860
|
}
|
|
7968
9861
|
ElementUtils2.removeAllChildren = removeAllChildren;
|
|
@@ -8665,6 +10558,392 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8665
10558
|
return /Mobi/i.test(targetWindow.navigator.userAgent);
|
|
8666
10559
|
};
|
|
8667
10560
|
})(ValidUtils2 || (ValidUtils2 = {}));
|
|
10561
|
+
|
|
10562
|
+
// ../simple-boot/dist/esm/index.js
|
|
10563
|
+
var import_reflect_metadata = __toESM(require_Reflect(), 1);
|
|
10564
|
+
|
|
10565
|
+
// ../simple-boot/dist/esm/alert/AlertAction.js
|
|
10566
|
+
var AlertAction = /* @__PURE__ */ ((AlertAction2) => {
|
|
10567
|
+
AlertAction2["ACTIVE"] = "ACTIVE";
|
|
10568
|
+
AlertAction2["IN_ACTIVE"] = "IN_ACTIVE";
|
|
10569
|
+
return AlertAction2;
|
|
10570
|
+
})(AlertAction || {});
|
|
10571
|
+
|
|
10572
|
+
// ../simple-boot/dist/esm/alert/Alert.js
|
|
10573
|
+
var Alert = class {
|
|
10574
|
+
constructor(alertService, config) {
|
|
10575
|
+
this.alertService = alertService;
|
|
10576
|
+
this.config = config;
|
|
10577
|
+
this.isActive = false;
|
|
10578
|
+
this.activateBefore = [];
|
|
10579
|
+
this.activateAfter = [];
|
|
10580
|
+
this.deActivateBefore = [];
|
|
10581
|
+
this.deActivateAfter = [];
|
|
10582
|
+
this.data = /* @__PURE__ */ new Map();
|
|
10583
|
+
if (config?.uuid) {
|
|
10584
|
+
this.uuid = config.uuid;
|
|
10585
|
+
} else {
|
|
10586
|
+
this.uuid = RandomUtils.uuid();
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
addOpenBefore(fn) {
|
|
10590
|
+
this.activateBefore.push(fn);
|
|
10591
|
+
}
|
|
10592
|
+
addOpenAfter(fn) {
|
|
10593
|
+
this.activateAfter.push(fn);
|
|
10594
|
+
}
|
|
10595
|
+
addCloseBefore(fn) {
|
|
10596
|
+
this.deActivateBefore.push(fn);
|
|
10597
|
+
}
|
|
10598
|
+
addCloseAfter(fn) {
|
|
10599
|
+
this.deActivateAfter.push(fn);
|
|
10600
|
+
}
|
|
10601
|
+
setData(key, value) {
|
|
10602
|
+
this.data.set(key, value);
|
|
10603
|
+
}
|
|
10604
|
+
getData(key) {
|
|
10605
|
+
return this.data.get(key);
|
|
10606
|
+
}
|
|
10607
|
+
async activate() {
|
|
10608
|
+
try {
|
|
10609
|
+
await Promise.allSettled(this.activateBefore.map((it) => it())).then((it) => {
|
|
10610
|
+
this.result = this.make();
|
|
10611
|
+
this.alertService?.publish({ action: AlertAction.ACTIVE, alert: this });
|
|
10612
|
+
this.isActive = true;
|
|
10613
|
+
if (this.config?.closeTime !== void 0 && this.config?.closeTime > 0) {
|
|
10614
|
+
setTimeout(() => {
|
|
10615
|
+
this.deActivate();
|
|
10616
|
+
}, this.config.closeTime);
|
|
10617
|
+
}
|
|
10618
|
+
this.config?.activate?.(this.result, this);
|
|
10619
|
+
});
|
|
10620
|
+
} catch (e) {
|
|
10621
|
+
} finally {
|
|
10622
|
+
await Promise.allSettled(this.activateAfter.map((it) => it())).then((it) => {
|
|
10623
|
+
});
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10626
|
+
async deActivate() {
|
|
10627
|
+
try {
|
|
10628
|
+
await Promise.allSettled(this.deActivateBefore.map((it) => it())).then((it) => {
|
|
10629
|
+
this.alertService?.publish({ action: AlertAction.IN_ACTIVE, alert: this });
|
|
10630
|
+
this.isActive = false;
|
|
10631
|
+
this.config?.deActivate?.(this.result, this);
|
|
10632
|
+
});
|
|
10633
|
+
} catch (e) {
|
|
10634
|
+
} finally {
|
|
10635
|
+
await Promise.allSettled(this.deActivateAfter.map((it) => it())).then((it) => {
|
|
10636
|
+
});
|
|
10637
|
+
}
|
|
10638
|
+
}
|
|
10639
|
+
};
|
|
10640
|
+
|
|
10641
|
+
// ../simple-boot/dist/esm/alert/AlertFactory.js
|
|
10642
|
+
var __decorate = function(decorators, target, key, desc) {
|
|
10643
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10644
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10645
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10646
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10647
|
+
};
|
|
10648
|
+
var AlertFactory;
|
|
10649
|
+
(function(AlertFactory2) {
|
|
10650
|
+
AlertFactory2.SYMBOL = Symbol("AlertFactory");
|
|
10651
|
+
})(AlertFactory || (AlertFactory = {}));
|
|
10652
|
+
var DefaultAlertFactory = class DefaultAlertFactory2 {
|
|
10653
|
+
create(data) {
|
|
10654
|
+
return void 0;
|
|
10655
|
+
}
|
|
10656
|
+
};
|
|
10657
|
+
DefaultAlertFactory = __decorate([
|
|
10658
|
+
Sim({ symbol: AlertFactory.SYMBOL })
|
|
10659
|
+
], DefaultAlertFactory);
|
|
10660
|
+
|
|
10661
|
+
// ../simple-boot/dist/esm/alert/AlertType.js
|
|
10662
|
+
var AlertType = /* @__PURE__ */ ((AlertType2) => {
|
|
10663
|
+
AlertType2["DANGER"] = "DANGER";
|
|
10664
|
+
AlertType2["NORMAL"] = "NORMAL";
|
|
10665
|
+
AlertType2["PROGRESS"] = "PROGRESS";
|
|
10666
|
+
AlertType2["SUCCESS"] = "SUCCESS";
|
|
10667
|
+
AlertType2["ERROR"] = "ERROR";
|
|
10668
|
+
AlertType2["INFO"] = "INFO";
|
|
10669
|
+
AlertType2["WARNING"] = "WARNING";
|
|
10670
|
+
AlertType2["CONSOLE"] = "CONSOLE";
|
|
10671
|
+
AlertType2["ETC"] = "ETC";
|
|
10672
|
+
return AlertType2;
|
|
10673
|
+
})(AlertType || {});
|
|
10674
|
+
|
|
10675
|
+
// ../simple-boot/dist/esm/alert/AlertService.js
|
|
10676
|
+
var __decorate2 = function(decorators, target, key, desc) {
|
|
10677
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10678
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10679
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10680
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10681
|
+
};
|
|
10682
|
+
var __metadata = function(k, v) {
|
|
10683
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10684
|
+
};
|
|
10685
|
+
var __param = function(paramIndex, decorator) {
|
|
10686
|
+
return function(target, key) {
|
|
10687
|
+
decorator(target, key, paramIndex);
|
|
10688
|
+
};
|
|
10689
|
+
};
|
|
10690
|
+
var _a;
|
|
10691
|
+
var AlertService = class AlertService2 {
|
|
10692
|
+
constructor(alertFactory) {
|
|
10693
|
+
this.name = (/* @__PURE__ */ new Date()).toUTCString();
|
|
10694
|
+
this.subject = new ReplaySubject();
|
|
10695
|
+
this.alertFactory = alertFactory;
|
|
10696
|
+
}
|
|
10697
|
+
// @PostConstruct
|
|
10698
|
+
// postConstruct(
|
|
10699
|
+
// ) {
|
|
10700
|
+
// this.alertFactory = alertFactory;
|
|
10701
|
+
// }
|
|
10702
|
+
get observable() {
|
|
10703
|
+
return this.subject.asObservable();
|
|
10704
|
+
}
|
|
10705
|
+
publish(data) {
|
|
10706
|
+
this.subject.next(data);
|
|
10707
|
+
}
|
|
10708
|
+
create(factory, config) {
|
|
10709
|
+
return new class extends Alert {
|
|
10710
|
+
make() {
|
|
10711
|
+
return factory(this);
|
|
10712
|
+
}
|
|
10713
|
+
}(this, config);
|
|
10714
|
+
}
|
|
10715
|
+
createFromFactory(type, config) {
|
|
10716
|
+
return this.alertFactory?.create({ caller: this, type, config });
|
|
10717
|
+
}
|
|
10718
|
+
danger(config) {
|
|
10719
|
+
return this.createFromFactory(AlertType.DANGER, config);
|
|
10720
|
+
}
|
|
10721
|
+
progress(config) {
|
|
10722
|
+
config = config ?? {};
|
|
10723
|
+
return this.createFromFactory(AlertType.PROGRESS, config);
|
|
10724
|
+
}
|
|
10725
|
+
success(config) {
|
|
10726
|
+
return this.createFromFactory(AlertType.SUCCESS, config);
|
|
10727
|
+
}
|
|
10728
|
+
info(config) {
|
|
10729
|
+
return this.createFromFactory(AlertType.INFO, config);
|
|
10730
|
+
}
|
|
10731
|
+
error(config) {
|
|
10732
|
+
return this.createFromFactory(AlertType.ERROR, config);
|
|
10733
|
+
}
|
|
10734
|
+
warning(config) {
|
|
10735
|
+
return this.createFromFactory(AlertType.WARNING, config);
|
|
10736
|
+
}
|
|
10737
|
+
};
|
|
10738
|
+
AlertService = __decorate2([
|
|
10739
|
+
Sim,
|
|
10740
|
+
__param(0, Inject({ symbol: AlertFactory.SYMBOL })),
|
|
10741
|
+
__metadata("design:paramtypes", [typeof (_a = typeof AlertFactory !== "undefined" && AlertFactory) === "function" ? _a : Object])
|
|
10742
|
+
], AlertService);
|
|
10743
|
+
|
|
10744
|
+
// ../simple-boot/dist/esm/decorators/cache/CacheDecorator.js
|
|
10745
|
+
var simpleApplicationCache = /* @__PURE__ */ new WeakMap();
|
|
10746
|
+
var getCacheSet = (simpleApplication) => {
|
|
10747
|
+
return simpleApplicationCache.get(simpleApplication);
|
|
10748
|
+
};
|
|
10749
|
+
var findCacheByKey = (simpleApplication, key) => {
|
|
10750
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10751
|
+
if (storage) {
|
|
10752
|
+
return Array.from(storage.config.entries()).find(([k, v]) => k === key);
|
|
10753
|
+
}
|
|
10754
|
+
};
|
|
10755
|
+
var findCacheByKeyStartWith = (simpleApplication, key) => {
|
|
10756
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10757
|
+
if (storage) {
|
|
10758
|
+
return Array.from(storage.config.entries()).filter(([k, v]) => k.startsWith(key));
|
|
10759
|
+
} else {
|
|
10760
|
+
return [];
|
|
10761
|
+
}
|
|
10762
|
+
};
|
|
10763
|
+
var deleteCacheByKey = (simpleApplication, key) => {
|
|
10764
|
+
const storage = simpleApplicationCache.get(simpleApplication);
|
|
10765
|
+
if (storage) {
|
|
10766
|
+
storage.storage.delete(key);
|
|
10767
|
+
findCacheByKeyStartWith(simpleApplication, key).forEach(([k, v]) => {
|
|
10768
|
+
const data = storage.config.get(k);
|
|
10769
|
+
if (data?.expireTimeout) {
|
|
10770
|
+
clearTimeout(data.expireTimeout);
|
|
10771
|
+
}
|
|
10772
|
+
storage.config.delete(k);
|
|
10773
|
+
storage.storage.delete(k);
|
|
10774
|
+
});
|
|
10775
|
+
}
|
|
10776
|
+
};
|
|
10777
|
+
var deleteCacheByKeyStartWith = (simpleApplication, key) => {
|
|
10778
|
+
findCacheByKeyStartWith(simpleApplication, key).forEach(([key2, data]) => deleteCacheByKey(simpleApplication, key2));
|
|
10779
|
+
};
|
|
10780
|
+
var CacheMetadataKey = Symbol("Cache");
|
|
10781
|
+
|
|
10782
|
+
// ../simple-boot/dist/esm/cache/CacheManager.js
|
|
10783
|
+
var __decorate3 = function(decorators, target, key, desc) {
|
|
10784
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10785
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10786
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10787
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10788
|
+
};
|
|
10789
|
+
var __metadata2 = function(k, v) {
|
|
10790
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10791
|
+
};
|
|
10792
|
+
var _a2;
|
|
10793
|
+
var CacheManager = class CacheManager2 {
|
|
10794
|
+
constructor(simpleApplication) {
|
|
10795
|
+
this.simpleApplication = simpleApplication;
|
|
10796
|
+
}
|
|
10797
|
+
findCacheByKey(key) {
|
|
10798
|
+
return findCacheByKey(this.simpleApplication, key);
|
|
10799
|
+
}
|
|
10800
|
+
findCacheByKeyStartWith(key) {
|
|
10801
|
+
return findCacheByKeyStartWith(this.simpleApplication, key);
|
|
10802
|
+
}
|
|
10803
|
+
deleteCacheByKey(key) {
|
|
10804
|
+
return deleteCacheByKey(this.simpleApplication, key);
|
|
10805
|
+
}
|
|
10806
|
+
deleteCacheByKeyStartWith(key) {
|
|
10807
|
+
return deleteCacheByKeyStartWith(this.simpleApplication, key);
|
|
10808
|
+
}
|
|
10809
|
+
getCacheSet() {
|
|
10810
|
+
return getCacheSet(this.simpleApplication);
|
|
10811
|
+
}
|
|
10812
|
+
};
|
|
10813
|
+
CacheManager = __decorate3([
|
|
10814
|
+
Sim,
|
|
10815
|
+
__metadata2("design:paramtypes", [typeof (_a2 = typeof SimpleApplication !== "undefined" && SimpleApplication) === "function" ? _a2 : Object])
|
|
10816
|
+
], CacheManager);
|
|
10817
|
+
|
|
10818
|
+
// ../simple-boot/dist/esm/decorators/event/EventListener.js
|
|
10819
|
+
var EventListenerMetadataKey = Symbol("EventListener");
|
|
10820
|
+
|
|
10821
|
+
// ../simple-boot/dist/esm/decorators/validate/Validation.js
|
|
10822
|
+
var ValidMetadataKey = Symbol("ValidMetadataKey");
|
|
10823
|
+
var ValidationMetadataKey = Symbol("ValidationMetadataKey");
|
|
10824
|
+
|
|
10825
|
+
// ../simple-boot/dist/esm/fetch/ApiService.js
|
|
10826
|
+
var __decorate4 = function(decorators, target, key, desc) {
|
|
10827
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10828
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
10829
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10830
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
10831
|
+
};
|
|
10832
|
+
var __metadata3 = function(k, v) {
|
|
10833
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10834
|
+
};
|
|
10835
|
+
var _a3;
|
|
10836
|
+
var _b;
|
|
10837
|
+
var ApiServiceInterceptor;
|
|
10838
|
+
(function(ApiServiceInterceptor2) {
|
|
10839
|
+
ApiServiceInterceptor2.TOKEN = Symbol("ApiServiceInterceptor");
|
|
10840
|
+
ApiServiceInterceptor2.resolveAll = (simstanceManager) => {
|
|
10841
|
+
try {
|
|
10842
|
+
return (simstanceManager.findSims(ApiServiceInterceptor2.TOKEN) ?? []).map((it) => it.getValue()).filter(ValidUtils.isDefined);
|
|
10843
|
+
} catch (e) {
|
|
10844
|
+
return [];
|
|
10845
|
+
}
|
|
10846
|
+
};
|
|
10847
|
+
})(ApiServiceInterceptor || (ApiServiceInterceptor = {}));
|
|
10848
|
+
var ApiService = class ApiService2 extends HttpJsonFetcher {
|
|
10849
|
+
constructor(simstanceManager, alertService) {
|
|
10850
|
+
super();
|
|
10851
|
+
this.simstanceManager = simstanceManager;
|
|
10852
|
+
this.subject = new Subject();
|
|
10853
|
+
this.alertService = alertService;
|
|
10854
|
+
}
|
|
10855
|
+
// @PostConstruct
|
|
10856
|
+
// postConstruct(alertService: AlertService<any>) {
|
|
10857
|
+
// this.alertService = alertService;
|
|
10858
|
+
// }
|
|
10859
|
+
get observable() {
|
|
10860
|
+
return this.subject.asObservable();
|
|
10861
|
+
}
|
|
10862
|
+
createPipe(config) {
|
|
10863
|
+
return {};
|
|
10864
|
+
}
|
|
10865
|
+
async beforeProxyFetch(config) {
|
|
10866
|
+
let interceptors = ApiServiceInterceptor.resolveAll(this.simstanceManager);
|
|
10867
|
+
for (const interceptor of interceptors) {
|
|
10868
|
+
if (interceptor.beforeProxyFetch) {
|
|
10869
|
+
config = await interceptor.beforeProxyFetch(config);
|
|
10870
|
+
}
|
|
10871
|
+
}
|
|
10872
|
+
this.subject.next({ type: "beforeFetchData", config });
|
|
10873
|
+
return config;
|
|
10874
|
+
}
|
|
10875
|
+
async afterProxyFetch(config) {
|
|
10876
|
+
let interceptors = ApiServiceInterceptor.resolveAll(this.simstanceManager);
|
|
10877
|
+
let r = config.response;
|
|
10878
|
+
for (const interceptor of interceptors) {
|
|
10879
|
+
if (interceptor.afterProxyFetch) {
|
|
10880
|
+
r = await interceptor.afterProxyFetch(config);
|
|
10881
|
+
}
|
|
10882
|
+
}
|
|
10883
|
+
this.subject.next({ type: "afterFetchData", response: r });
|
|
10884
|
+
return r;
|
|
10885
|
+
}
|
|
10886
|
+
beforeFetch(fetch2) {
|
|
10887
|
+
this.subject.next({ type: "beforeFetch", fetch: fetch2 });
|
|
10888
|
+
}
|
|
10889
|
+
afterFetch(fetch2, response) {
|
|
10890
|
+
this.subject.next({ type: "afterFetch", fetch: fetch2, response });
|
|
10891
|
+
}
|
|
10892
|
+
before(config, pipe) {
|
|
10893
|
+
this.subject.next({ type: "progress", config, pipe });
|
|
10894
|
+
config.config?.config?.callBackProgress?.(config, pipe);
|
|
10895
|
+
if (config.config?.config?.alertProgress) {
|
|
10896
|
+
const alert = this.alertService?.progress({ title: config.config.config.title });
|
|
10897
|
+
if (alert) {
|
|
10898
|
+
pipe.progress = alert;
|
|
10899
|
+
alert.activate();
|
|
10900
|
+
}
|
|
10901
|
+
}
|
|
10902
|
+
}
|
|
10903
|
+
afterSuccess(config, pipe) {
|
|
10904
|
+
this.subject.next({ type: "success", config, pipe });
|
|
10905
|
+
config.config?.config?.callBackSuccess?.(config, pipe);
|
|
10906
|
+
if (config.config?.config?.alertSuccessMsg) {
|
|
10907
|
+
this.alertService?.success({ title: config.config.config.title })?.activate();
|
|
10908
|
+
}
|
|
10909
|
+
}
|
|
10910
|
+
afterSuccessTransform(config, pipe) {
|
|
10911
|
+
}
|
|
10912
|
+
finally(config, pipe) {
|
|
10913
|
+
this.subject.next({ type: "final", config, pipe });
|
|
10914
|
+
config.config?.config?.callBackFinal?.(config, pipe);
|
|
10915
|
+
pipe.progress?.deActivate();
|
|
10916
|
+
}
|
|
10917
|
+
error(config, pipe, e) {
|
|
10918
|
+
console.log("error", e);
|
|
10919
|
+
this.subject.next({ type: "error", config, pipe, e });
|
|
10920
|
+
config.config?.config?.callBackError?.(config, pipe, e);
|
|
10921
|
+
if (config.config?.config?.alertErrorMsg) {
|
|
10922
|
+
this.alertService?.danger({
|
|
10923
|
+
title: `${config.config.config.title ? config.config.config.title : ""}${e.message ? `(${e.message})` : ""}`
|
|
10924
|
+
})?.activate();
|
|
10925
|
+
}
|
|
10926
|
+
if (config.config?.config?.enableErrorConsole) {
|
|
10927
|
+
console.error(`apiService Error ${config?.config?.config?.title}`, e);
|
|
10928
|
+
}
|
|
10929
|
+
}
|
|
10930
|
+
async execute(fetcherRequest) {
|
|
10931
|
+
const target = fetcherRequest.target;
|
|
10932
|
+
const config = fetcherRequest.config;
|
|
10933
|
+
let r = { target, config };
|
|
10934
|
+
const interceptor = ApiServiceInterceptor.resolveAll(this.simstanceManager) ?? [];
|
|
10935
|
+
for (const apiServiceInterceptor of interceptor) {
|
|
10936
|
+
if (apiServiceInterceptor.beforeProxyExecute) {
|
|
10937
|
+
r = await apiServiceInterceptor.beforeProxyExecute?.(r);
|
|
10938
|
+
}
|
|
10939
|
+
}
|
|
10940
|
+
return super.execute(r);
|
|
10941
|
+
}
|
|
10942
|
+
};
|
|
10943
|
+
ApiService = __decorate4([
|
|
10944
|
+
Sim,
|
|
10945
|
+
__metadata3("design:paramtypes", [typeof (_a3 = typeof SimstanceManager !== "undefined" && SimstanceManager) === "function" ? _a3 : Object, typeof (_b = typeof AlertService !== "undefined" && AlertService) === "function" ? _b : Object])
|
|
10946
|
+
], ApiService);
|
|
8668
10947
|
return __toCommonJS(bundle_entry_exports);
|
|
8669
10948
|
})();
|
|
8670
10949
|
/*! Bundled license information:
|