@dooboostore/simple-web-component 1.0.42 → 1.0.43
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 +423 -68
- package/dist/cjs/decorators/addEventListener.js +10 -0
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +11 -2
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +9 -2
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +11 -2
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js +10 -2
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +11 -2
- package/dist/cjs/decorators/applySlot.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +9 -2
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +2 -0
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/publishSwcAppMessage.js +37 -23
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +10 -0
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +11 -2
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +9 -2
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +11 -2
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js +10 -2
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +11 -2
- package/dist/esm/decorators/applySlot.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +9 -2
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +2 -0
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/publishSwcAppMessage.js +37 -23
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +146 -71
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +3 -3
- package/dist/types/decorators/addEventListener.d.ts +5 -0
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +26 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +6 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +26 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +6 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +6 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +17 -0
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts +19 -0
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +146 -71
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +3 -3
- package/package.json +7 -9
- package/src/decorators/addEventListener.ts +7 -0
- package/src/decorators/applyAttribute.ts +58 -2
- package/src/decorators/applyClass.ts +24 -2
- package/src/decorators/applyNode.ts +26 -2
- package/src/decorators/applyProperty.ts +57 -2
- package/src/decorators/applySlot.ts +24 -10
- package/src/decorators/applyStyle.ts +24 -2
- package/src/decorators/emitCustomEvent.ts +19 -0
- package/src/decorators/publishSwcAppMessage.ts +71 -27
|
@@ -1215,9 +1215,15 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1215
1215
|
defineSwcAppNav: () => defineSwcAppNav,
|
|
1216
1216
|
defineSwcAppSection: () => defineSwcAppSection,
|
|
1217
1217
|
elementDefine: () => elementDefine,
|
|
1218
|
+
emit: () => emit,
|
|
1218
1219
|
emitCustomEvent: () => emitCustomEvent,
|
|
1219
1220
|
emitCustomEventThis: () => emitCustomEventThis,
|
|
1220
1221
|
ensureInit: () => ensureInit,
|
|
1222
|
+
event: () => event,
|
|
1223
|
+
eventDelegate: () => eventDelegate,
|
|
1224
|
+
eventDelegateAllDom: () => eventDelegateAllDom,
|
|
1225
|
+
eventDelegateLightDom: () => eventDelegateLightDom,
|
|
1226
|
+
eventDelegateShadowDom: () => eventDelegateShadowDom,
|
|
1221
1227
|
findAllApplyNodeMetadata: () => findAllApplyNodeMetadata,
|
|
1222
1228
|
findAllApplySlotMetadata: () => findAllApplySlotMetadata,
|
|
1223
1229
|
findAllAttributeApplyMetadata: () => findAllAttributeApplyMetadata,
|
|
@@ -1283,6 +1289,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
1283
1289
|
prependTextSlot: () => prependTextSlot,
|
|
1284
1290
|
property: () => property,
|
|
1285
1291
|
propertyThis: () => propertyThis,
|
|
1292
|
+
publish: () => publish,
|
|
1286
1293
|
publishSwcAppMessage: () => publishSwcAppMessage,
|
|
1287
1294
|
query: () => query,
|
|
1288
1295
|
queryAll: () => queryAll,
|
|
@@ -6544,6 +6551,11 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
6544
6551
|
function addEventListenerDelegate(selector, type, options) {
|
|
6545
6552
|
return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
|
|
6546
6553
|
}
|
|
6554
|
+
var event = addEventListener;
|
|
6555
|
+
var eventDelegateLightDom = addEventListenerDelegateLightDom;
|
|
6556
|
+
var eventDelegateShadowDom = addEventListenerDelegateShadowDom;
|
|
6557
|
+
var eventDelegateAllDom = addEventListenerDelegateAllDom;
|
|
6558
|
+
var eventDelegate = addEventListenerDelegate;
|
|
6547
6559
|
function addEventListenerThis(type, options) {
|
|
6548
6560
|
return addEventListener("$this", type, options);
|
|
6549
6561
|
}
|
|
@@ -7718,7 +7730,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7718
7730
|
};
|
|
7719
7731
|
DocumentUtils2.eventObservable = (document2, type, options) => {
|
|
7720
7732
|
return new Observable((subscriber) => {
|
|
7721
|
-
const handler = (
|
|
7733
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7722
7734
|
window.addEventListener(type, handler, options);
|
|
7723
7735
|
return () => {
|
|
7724
7736
|
window.removeEventListener(type, handler, options);
|
|
@@ -7732,7 +7744,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7732
7744
|
((EventUtils2) => {
|
|
7733
7745
|
EventUtils2.htmlElementEventObservable = (element, type, options) => {
|
|
7734
7746
|
return new Observable((subscriber) => {
|
|
7735
|
-
const handler = (
|
|
7747
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7736
7748
|
element.addEventListener(type, handler, options);
|
|
7737
7749
|
return () => {
|
|
7738
7750
|
element.removeEventListener(type, handler, options);
|
|
@@ -7746,7 +7758,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
7746
7758
|
((WindowUtils2) => {
|
|
7747
7759
|
WindowUtils2.eventObservable = (window2, type, options) => {
|
|
7748
7760
|
return new Observable((subscriber) => {
|
|
7749
|
-
const handler = (
|
|
7761
|
+
const handler = (event2) => subscriber.next(event2);
|
|
7750
7762
|
window2.addEventListener(type, handler, options);
|
|
7751
7763
|
return () => {
|
|
7752
7764
|
window2.removeEventListener(type, handler, options);
|
|
@@ -8123,7 +8135,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8123
8135
|
routeData = { ...this.getRouteData(), triggerPoint: "first-end" };
|
|
8124
8136
|
this.behaviorSubject = new BehaviorSubject(routeData);
|
|
8125
8137
|
}
|
|
8126
|
-
this.config.window.addEventListener("popstate", (
|
|
8138
|
+
this.config.window.addEventListener("popstate", (event2) => {
|
|
8127
8139
|
const routeData2 = { ...this.getRouteData(), triggerPoint: "end" };
|
|
8128
8140
|
this.behaviorSubject.next(routeData2);
|
|
8129
8141
|
});
|
|
@@ -8515,7 +8527,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
8515
8527
|
divideSize
|
|
8516
8528
|
}) => {
|
|
8517
8529
|
return new Observable((subscriber) => {
|
|
8518
|
-
const handler = (
|
|
8530
|
+
const handler = (event2) => subscriber.next(event2);
|
|
8519
8531
|
let fps2 = 0;
|
|
8520
8532
|
const getDrawFpsGap = () => {
|
|
8521
8533
|
return Math.floor(fps2 / divideSize);
|
|
@@ -9036,7 +9048,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9036
9048
|
ensureInit(this);
|
|
9037
9049
|
const res = original.apply(this, args);
|
|
9038
9050
|
const handleResult = (detail) => {
|
|
9039
|
-
const
|
|
9051
|
+
const event2 = new CustomEvent(type, {
|
|
9040
9052
|
detail,
|
|
9041
9053
|
bubbles: fullOptions.bubbles,
|
|
9042
9054
|
composed: fullOptions.composed,
|
|
@@ -9086,7 +9098,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9086
9098
|
if (fullOptions.filter && !fullOptions.filter(t, detail, { currentThis: this, helper: hostSet })) {
|
|
9087
9099
|
return;
|
|
9088
9100
|
}
|
|
9089
|
-
t.dispatchEvent(
|
|
9101
|
+
t.dispatchEvent(event2);
|
|
9090
9102
|
});
|
|
9091
9103
|
return detail;
|
|
9092
9104
|
};
|
|
@@ -9102,6 +9114,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9102
9114
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
9103
9115
|
return ReflectUtils.getMetadata(EMIT_CUSTOM_EVENT_METADATA_KEY, constructor);
|
|
9104
9116
|
};
|
|
9117
|
+
var emit = emitCustomEvent;
|
|
9105
9118
|
function emitCustomEventThis(type, optionsOrAttributeaName) {
|
|
9106
9119
|
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === "string") {
|
|
9107
9120
|
return emitCustomEventThis(type, { attributeName: optionsOrAttributeaName });
|
|
@@ -9730,13 +9743,21 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9730
9743
|
descriptor.value = function(...args) {
|
|
9731
9744
|
ensureInit(this);
|
|
9732
9745
|
const res = original.apply(this, args);
|
|
9746
|
+
const extractValue = (v) => {
|
|
9747
|
+
if (v && typeof v === "object" && PROPERTY_METADATA_KEY in v) {
|
|
9748
|
+
return v[PROPERTY_METADATA_KEY];
|
|
9749
|
+
}
|
|
9750
|
+
return v;
|
|
9751
|
+
};
|
|
9733
9752
|
if (res instanceof Promise) {
|
|
9734
9753
|
return res.then((v) => {
|
|
9735
|
-
|
|
9754
|
+
const extracted = extractValue(v);
|
|
9755
|
+
applyValueToTargets(this, extracted);
|
|
9736
9756
|
return v;
|
|
9737
9757
|
});
|
|
9738
9758
|
} else {
|
|
9739
|
-
|
|
9759
|
+
const extracted = extractValue(res);
|
|
9760
|
+
applyValueToTargets(this, extracted);
|
|
9740
9761
|
return res;
|
|
9741
9762
|
}
|
|
9742
9763
|
};
|
|
@@ -9862,10 +9883,10 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9862
9883
|
}
|
|
9863
9884
|
};
|
|
9864
9885
|
var globalDelegatedRoots = /* @__PURE__ */ new WeakSet();
|
|
9865
|
-
var handleGlobalSwcEvent = async (
|
|
9866
|
-
if (
|
|
9867
|
-
const path =
|
|
9868
|
-
const type =
|
|
9886
|
+
var handleGlobalSwcEvent = async (event2) => {
|
|
9887
|
+
if (event2.__swc_handled) return;
|
|
9888
|
+
const path = event2.composedPath();
|
|
9889
|
+
const type = event2.type;
|
|
9869
9890
|
const attrName = `swc-on-${type}`;
|
|
9870
9891
|
for (const node of path) {
|
|
9871
9892
|
if (!(node instanceof HTMLElement)) continue;
|
|
@@ -9873,8 +9894,8 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9873
9894
|
if (script && !getElementConfig(node)) {
|
|
9874
9895
|
const host = SwcUtils.findNearestSwcHostIncludingSelf(node);
|
|
9875
9896
|
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === "function") {
|
|
9876
|
-
await host.__swc_executeAttributeEvent(node, attrName, script,
|
|
9877
|
-
|
|
9897
|
+
await host.__swc_executeAttributeEvent(node, attrName, script, event2);
|
|
9898
|
+
event2.__swc_handled = true;
|
|
9878
9899
|
break;
|
|
9879
9900
|
}
|
|
9880
9901
|
}
|
|
@@ -9963,14 +9984,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9963
9984
|
}
|
|
9964
9985
|
const oldHandler = handlers.get(attrName);
|
|
9965
9986
|
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
9966
|
-
const handler = async (
|
|
9987
|
+
const handler = async (event2) => {
|
|
9967
9988
|
const hostSet = SwcUtils.getHostSet(el);
|
|
9968
9989
|
const conf = getElementConfig(this);
|
|
9969
9990
|
const currentWin = this._resolveWindow(conf);
|
|
9970
9991
|
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
9971
9992
|
const args = {
|
|
9972
|
-
event,
|
|
9973
|
-
$data:
|
|
9993
|
+
event: event2,
|
|
9994
|
+
$data: event2.detail,
|
|
9974
9995
|
...hostSet,
|
|
9975
9996
|
...helpers,
|
|
9976
9997
|
$el: el,
|
|
@@ -9981,16 +10002,16 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
9981
10002
|
el.addEventListener(eventName, handler);
|
|
9982
10003
|
handlers.set(attrName, handler);
|
|
9983
10004
|
};
|
|
9984
|
-
proto.__swc_executeAttributeEvent = async function(el, attrName, script,
|
|
10005
|
+
proto.__swc_executeAttributeEvent = async function(el, attrName, script, event2) {
|
|
9985
10006
|
ensureInit(this);
|
|
9986
10007
|
const hostSet = SwcUtils.getHostSet(el);
|
|
9987
10008
|
const conf = getElementConfig(this);
|
|
9988
10009
|
const currentWin = this._resolveWindow(conf);
|
|
9989
10010
|
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
9990
|
-
const detail =
|
|
10011
|
+
const detail = event2.detail;
|
|
9991
10012
|
const args = {
|
|
9992
|
-
event,
|
|
9993
|
-
$event:
|
|
10013
|
+
event: event2,
|
|
10014
|
+
$event: event2,
|
|
9994
10015
|
$data: detail,
|
|
9995
10016
|
$detail: detail,
|
|
9996
10017
|
...hostSet,
|
|
@@ -10141,24 +10162,24 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10141
10162
|
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
10142
10163
|
return bStop - aStop;
|
|
10143
10164
|
});
|
|
10144
|
-
const unifiedHandler = async (
|
|
10165
|
+
const unifiedHandler = async (event2) => {
|
|
10145
10166
|
for (const meta of sortedMetaList) {
|
|
10146
10167
|
const { selector, options } = meta;
|
|
10147
|
-
const matchedEl =
|
|
10168
|
+
const matchedEl = event2.target.closest(selector);
|
|
10148
10169
|
if (matchedEl && br.contains(matchedEl)) {
|
|
10149
10170
|
if (options.filter) {
|
|
10150
10171
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
10151
|
-
if (!options.filter(
|
|
10172
|
+
if (!options.filter(event2, helper)) {
|
|
10152
10173
|
continue;
|
|
10153
10174
|
}
|
|
10154
10175
|
}
|
|
10155
|
-
if (options.stopPropagation)
|
|
10156
|
-
if (options.stopImmediatePropagation)
|
|
10157
|
-
if (options.preventDefault)
|
|
10176
|
+
if (options.stopPropagation) event2.stopPropagation();
|
|
10177
|
+
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
10178
|
+
if (options.preventDefault) event2.preventDefault();
|
|
10158
10179
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
10159
|
-
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
10160
|
-
await this[meta.propertyKey](
|
|
10161
|
-
if (
|
|
10180
|
+
const args = { event: event2, ...currentHostSet, $el: matchedEl, $root: br };
|
|
10181
|
+
await this[meta.propertyKey](event2, { ...currentHostSet, $matchedElement: matchedEl }, args);
|
|
10182
|
+
if (event2.cancelBubble) break;
|
|
10162
10183
|
}
|
|
10163
10184
|
}
|
|
10164
10185
|
};
|
|
@@ -10206,19 +10227,19 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10206
10227
|
});
|
|
10207
10228
|
}
|
|
10208
10229
|
bindTargets.forEach((t) => {
|
|
10209
|
-
const handler = async (
|
|
10230
|
+
const handler = async (event2) => {
|
|
10210
10231
|
if (options.filter) {
|
|
10211
10232
|
const helper = SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
10212
|
-
if (!options.filter(
|
|
10233
|
+
if (!options.filter(event2, { currentThis: this, helper })) {
|
|
10213
10234
|
return;
|
|
10214
10235
|
}
|
|
10215
10236
|
}
|
|
10216
|
-
if (options.stopPropagation)
|
|
10217
|
-
if (options.stopImmediatePropagation)
|
|
10218
|
-
if (options.preventDefault)
|
|
10237
|
+
if (options.stopPropagation) event2.stopPropagation();
|
|
10238
|
+
if (options.stopImmediatePropagation) event2.stopImmediatePropagation();
|
|
10239
|
+
if (options.preventDefault) event2.preventDefault();
|
|
10219
10240
|
const currentHostSet = SwcUtils.getHostSet(this);
|
|
10220
|
-
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
10221
|
-
await this[meta.propertyKey](
|
|
10241
|
+
const args = { event: event2, ...currentHostSet, $el: t, $root: t };
|
|
10242
|
+
await this[meta.propertyKey](event2, { currentHostSet, $$matchedElement: event2.currentTarget }, args);
|
|
10222
10243
|
};
|
|
10223
10244
|
t.addEventListener(type, handler, opts);
|
|
10224
10245
|
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
@@ -10473,13 +10494,22 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10473
10494
|
descriptor.value = function(...args) {
|
|
10474
10495
|
ensureInit(this);
|
|
10475
10496
|
const res = original.apply(this, args);
|
|
10497
|
+
const extractValue = (v) => {
|
|
10498
|
+
const keyToUse = finalOptions.valueKey ?? ATTRIBUTE_METADATA_KEY;
|
|
10499
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10500
|
+
return v[keyToUse];
|
|
10501
|
+
}
|
|
10502
|
+
return v;
|
|
10503
|
+
};
|
|
10476
10504
|
if (res instanceof Promise) {
|
|
10477
10505
|
return res.then((v) => {
|
|
10478
|
-
|
|
10506
|
+
const extracted = extractValue(v);
|
|
10507
|
+
applyValueToTargets(this, extracted);
|
|
10479
10508
|
return v;
|
|
10480
10509
|
});
|
|
10481
10510
|
} else {
|
|
10482
|
-
|
|
10511
|
+
const extracted = extractValue(res);
|
|
10512
|
+
applyValueToTargets(this, extracted);
|
|
10483
10513
|
return res;
|
|
10484
10514
|
}
|
|
10485
10515
|
};
|
|
@@ -10623,6 +10653,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10623
10653
|
};
|
|
10624
10654
|
const targetEl = getTarget();
|
|
10625
10655
|
const res = original.apply(this, args);
|
|
10656
|
+
const extractValue = (v) => {
|
|
10657
|
+
const keyToUse = options.valueKey ?? APPLY_NODE_METADATA_KEY;
|
|
10658
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10659
|
+
return v[keyToUse];
|
|
10660
|
+
}
|
|
10661
|
+
return v;
|
|
10662
|
+
};
|
|
10626
10663
|
const runApply = (target, val) => {
|
|
10627
10664
|
const pos = options.position || "beforeEnd";
|
|
10628
10665
|
const processedVal = val;
|
|
@@ -10637,12 +10674,14 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10637
10674
|
}
|
|
10638
10675
|
if (res instanceof Promise) {
|
|
10639
10676
|
return res.then((finalRes) => {
|
|
10677
|
+
const extracted = extractValue(finalRes);
|
|
10640
10678
|
fallbackNodes.forEach((it) => it.remove());
|
|
10641
|
-
if (
|
|
10679
|
+
if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
|
|
10642
10680
|
return finalRes;
|
|
10643
10681
|
});
|
|
10644
10682
|
} else {
|
|
10645
|
-
|
|
10683
|
+
const extracted = extractValue(res);
|
|
10684
|
+
if (extracted !== void 0 && targetEl) runApply(targetEl, extracted);
|
|
10646
10685
|
return res;
|
|
10647
10686
|
}
|
|
10648
10687
|
};
|
|
@@ -10769,6 +10808,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10769
10808
|
descriptor.value = function(...args) {
|
|
10770
10809
|
ensureInit(this);
|
|
10771
10810
|
const res = original.apply(this, args);
|
|
10811
|
+
const extractValue = (v) => {
|
|
10812
|
+
const keyToUse = finalOptions.valueKey ?? CLASS_METADATA_KEY;
|
|
10813
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10814
|
+
return v[keyToUse];
|
|
10815
|
+
}
|
|
10816
|
+
return v;
|
|
10817
|
+
};
|
|
10772
10818
|
const handleResult = (resolvedValue) => {
|
|
10773
10819
|
if (resolvedValue !== void 0) {
|
|
10774
10820
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -10848,9 +10894,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10848
10894
|
return resolvedValue;
|
|
10849
10895
|
};
|
|
10850
10896
|
if (res instanceof Promise) {
|
|
10851
|
-
return res.then(handleResult);
|
|
10897
|
+
return res.then((v) => handleResult(extractValue(v)));
|
|
10852
10898
|
} else {
|
|
10853
|
-
return handleResult(res);
|
|
10899
|
+
return handleResult(extractValue(res));
|
|
10854
10900
|
}
|
|
10855
10901
|
};
|
|
10856
10902
|
return descriptor;
|
|
@@ -10900,6 +10946,13 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10900
10946
|
descriptor.value = function(...args) {
|
|
10901
10947
|
ensureInit(this);
|
|
10902
10948
|
const res = original.apply(this, args);
|
|
10949
|
+
const extractValue = (v) => {
|
|
10950
|
+
const keyToUse = options.valueKey ?? STYLE_METADATA_KEY;
|
|
10951
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
10952
|
+
return v[keyToUse];
|
|
10953
|
+
}
|
|
10954
|
+
return v;
|
|
10955
|
+
};
|
|
10903
10956
|
const handleResult = (resolvedValue) => {
|
|
10904
10957
|
if (resolvedValue !== void 0) {
|
|
10905
10958
|
const win = this.ownerDocument?.defaultView || window;
|
|
@@ -10965,9 +11018,9 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
10965
11018
|
return resolvedValue;
|
|
10966
11019
|
};
|
|
10967
11020
|
if (res instanceof Promise) {
|
|
10968
|
-
return res.then(handleResult);
|
|
11021
|
+
return res.then((v) => handleResult(extractValue(v)));
|
|
10969
11022
|
} else {
|
|
10970
|
-
return handleResult(res);
|
|
11023
|
+
return handleResult(extractValue(res));
|
|
10971
11024
|
}
|
|
10972
11025
|
};
|
|
10973
11026
|
return descriptor;
|
|
@@ -11080,7 +11133,7 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
11080
11133
|
|
|
11081
11134
|
// src/decorators/publishSwcAppMessage.ts
|
|
11082
11135
|
var PUBLISH_SWC_APP_MESSAGE_METADATA_KEY = Symbol.for("simple-web-component:publish-swc-app-message");
|
|
11083
|
-
function createPublishSwcAppMessage(messageType) {
|
|
11136
|
+
function createPublishSwcAppMessage(messageType, options) {
|
|
11084
11137
|
return (target, propertyKey, descriptor) => {
|
|
11085
11138
|
const constructor = target.constructor;
|
|
11086
11139
|
let list = ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -11095,45 +11148,58 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
11095
11148
|
const originalMethod = descriptor.value;
|
|
11096
11149
|
descriptor.value = function(...args) {
|
|
11097
11150
|
const result = originalMethod.apply(this, args);
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
|
|
11102
|
-
|
|
11103
|
-
|
|
11104
|
-
|
|
11105
|
-
|
|
11106
|
-
});
|
|
11107
|
-
}
|
|
11108
|
-
}).catch((err) => {
|
|
11109
|
-
console.warn("publishSwcAppMessage async error:", err);
|
|
11110
|
-
});
|
|
11111
|
-
} else {
|
|
11151
|
+
const extractValue = (v) => {
|
|
11152
|
+
const keyToUse = options?.valueKey ?? PUBLISH_SWC_APP_MESSAGE_METADATA_KEY;
|
|
11153
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
11154
|
+
return v[keyToUse];
|
|
11155
|
+
}
|
|
11156
|
+
return v;
|
|
11157
|
+
};
|
|
11158
|
+
const publishMessage = (data) => {
|
|
11112
11159
|
const appHost = SwcUtils.getAppHost(this);
|
|
11113
11160
|
if (appHost) {
|
|
11114
11161
|
appHost.publishMessage({
|
|
11115
11162
|
publisher: this,
|
|
11116
|
-
data
|
|
11163
|
+
data,
|
|
11117
11164
|
type: messageType
|
|
11118
11165
|
});
|
|
11119
11166
|
}
|
|
11167
|
+
};
|
|
11168
|
+
if (result instanceof Promise) {
|
|
11169
|
+
result.then((data) => {
|
|
11170
|
+
const extracted = extractValue(data);
|
|
11171
|
+
publishMessage(extracted);
|
|
11172
|
+
}).catch((err) => {
|
|
11173
|
+
console.warn("publishSwcAppMessage async error:", err);
|
|
11174
|
+
});
|
|
11175
|
+
} else {
|
|
11176
|
+
const extracted = extractValue(result);
|
|
11177
|
+
publishMessage(extracted);
|
|
11120
11178
|
}
|
|
11121
11179
|
return result;
|
|
11122
11180
|
};
|
|
11123
11181
|
return descriptor;
|
|
11124
11182
|
};
|
|
11125
11183
|
}
|
|
11126
|
-
function publishSwcAppMessage(
|
|
11127
|
-
if (
|
|
11128
|
-
const target =
|
|
11129
|
-
return createPublishSwcAppMessage()(target,
|
|
11184
|
+
function publishSwcAppMessage(targetOrMessageTypeOrOptions, propertyKeyOrOptions, descriptor) {
|
|
11185
|
+
if (targetOrMessageTypeOrOptions && typeof targetOrMessageTypeOrOptions === "object" && propertyKeyOrOptions && (typeof propertyKeyOrOptions === "string" || typeof propertyKeyOrOptions === "symbol") && descriptor) {
|
|
11186
|
+
const target = targetOrMessageTypeOrOptions;
|
|
11187
|
+
return createPublishSwcAppMessage()(target, propertyKeyOrOptions, descriptor);
|
|
11130
11188
|
}
|
|
11131
11189
|
let messageType;
|
|
11132
|
-
|
|
11133
|
-
|
|
11190
|
+
let options;
|
|
11191
|
+
if (typeof targetOrMessageTypeOrOptions === "string") {
|
|
11192
|
+
messageType = targetOrMessageTypeOrOptions;
|
|
11193
|
+
if (typeof propertyKeyOrOptions === "object" && propertyKeyOrOptions !== null) {
|
|
11194
|
+
options = propertyKeyOrOptions;
|
|
11195
|
+
}
|
|
11196
|
+
} else if (typeof targetOrMessageTypeOrOptions === "object" && targetOrMessageTypeOrOptions !== null) {
|
|
11197
|
+
options = targetOrMessageTypeOrOptions;
|
|
11198
|
+
messageType = options.messageType;
|
|
11134
11199
|
}
|
|
11135
|
-
return createPublishSwcAppMessage(messageType);
|
|
11200
|
+
return createPublishSwcAppMessage(messageType, options);
|
|
11136
11201
|
}
|
|
11202
|
+
var publish = publishSwcAppMessage;
|
|
11137
11203
|
var getPublishSwcAppMessageMetadata = (target) => {
|
|
11138
11204
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
11139
11205
|
return ReflectUtils.getOwnMetadata(PUBLISH_SWC_APP_MESSAGE_METADATA_KEY, constructor);
|
|
@@ -11193,15 +11259,24 @@ var dooboostoreSimpleWebComponent = (() => {
|
|
|
11193
11259
|
fallbackNodes.push(...nodes);
|
|
11194
11260
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
11195
11261
|
}
|
|
11262
|
+
const extractValue = (v) => {
|
|
11263
|
+
const keyToUse = options.valueKey ?? APPLY_SLOT_METADATA_KEY;
|
|
11264
|
+
if (v && typeof v === "object" && keyToUse in v) {
|
|
11265
|
+
return v[keyToUse];
|
|
11266
|
+
}
|
|
11267
|
+
return v;
|
|
11268
|
+
};
|
|
11196
11269
|
let res = original.apply(this, args);
|
|
11197
11270
|
if (res instanceof Promise) {
|
|
11198
11271
|
return res.then((asyncRes) => {
|
|
11199
|
-
const
|
|
11272
|
+
const extracted = extractValue(asyncRes);
|
|
11273
|
+
const nodes = resToNodes(extracted);
|
|
11200
11274
|
fallbackNodes.forEach((it) => it.remove());
|
|
11201
11275
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
11202
11276
|
});
|
|
11203
11277
|
} else {
|
|
11204
|
-
const
|
|
11278
|
+
const extracted = extractValue(res);
|
|
11279
|
+
const nodes = resToNodes(extracted);
|
|
11205
11280
|
applyToDom2(swcId, targetId, options.position, nodes);
|
|
11206
11281
|
}
|
|
11207
11282
|
};
|