@dooboostore/simple-web-component 1.0.35 → 1.0.37
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 +58 -21
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +6 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +12 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js +19 -18
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +23 -22
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +28 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +122 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js +20 -19
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +16 -15
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/{changedAttributeHost.js → changedAttributeThis.js} +6 -6
- package/dist/cjs/decorators/changedAttributeThis.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +59 -50
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +18 -16
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +2 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +56 -8
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/query.js +38 -60
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +31 -63
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +13 -12
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/elements/{SwcAppMixin.js → SwcApp.js} +107 -57
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/index.js +21 -2
- package/dist/cjs/elements/index.js.map +3 -3
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +12 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +22 -19
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +4 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +12 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js +19 -18
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +23 -22
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +28 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +103 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js +20 -19
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +16 -15
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/{changedAttributeHost.js → changedAttributeThis.js} +3 -3
- package/dist/esm/decorators/changedAttributeThis.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +60 -51
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +18 -16
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +2 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +56 -8
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/query.js +38 -60
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +31 -63
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +13 -12
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/elements/{SwcAppMixin.js → SwcApp.js} +102 -53
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/index.js +7 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +13 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +22 -19
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +4189 -456
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -7
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +4 -4
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +6 -6
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +9 -9
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts +4 -4
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -5
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeThis.d.ts +18 -0
- package/dist/types/decorators/changedAttributeThis.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +4 -9
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +21 -6
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +17 -63
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +6 -63
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +7 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +5 -5
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +13 -12
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +4189 -456
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +12 -7
- package/src/decorators/addEventListener.ts +11 -9
- package/src/decorators/applyAttribute.ts +16 -15
- package/src/decorators/applyClass.ts +18 -17
- package/src/decorators/applyNode.ts +30 -27
- package/src/decorators/applySlot.ts +228 -0
- package/src/decorators/applyStyle.ts +17 -16
- package/src/decorators/attribute.ts +20 -19
- package/src/decorators/{changedAttributeHost.ts → changedAttributeThis.ts} +10 -12
- package/src/decorators/elementDefine.ts +80 -57
- package/src/decorators/emitCustomEvent.ts +21 -26
- package/src/decorators/index.ts +2 -1
- package/src/decorators/lifecycles.ts +76 -11
- package/src/decorators/query.ts +51 -124
- package/src/decorators/queryAll.ts +30 -127
- package/src/decorators/setProperty.ts +12 -11
- package/src/elements/{SwcAppMixin.ts → SwcApp.ts} +98 -31
- package/src/elements/index.ts +11 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +13 -9
- package/src/types/window.d.ts +43 -0
- package/src/types.ts +9 -8
- package/src/utils/Utils.ts +28 -24
- package/dist/cjs/decorators/changedAttributeHost.js.map +0 -7
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAppMixin.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/esm/decorators/changedAttributeHost.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAppMixin.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/types/decorators/changedAttributeHost.d.ts +0 -20
- package/dist/types/decorators/changedAttributeHost.d.ts.map +0 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAppMixin.d.ts +0 -386
- package/dist/types/elements/SwcAppMixin.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -77,20 +77,21 @@ export const resolveTargetEls = (inst: any, selector: string, options: Attribute
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
if (selector === '
|
|
80
|
+
if (selector === '$this' || !selector) {
|
|
81
81
|
applyRoot(inst);
|
|
82
|
-
} else if (selector === '
|
|
82
|
+
} else if (selector === '$window') {
|
|
83
83
|
results.push(currentWin);
|
|
84
|
-
} else if (selector === '
|
|
84
|
+
} else if (selector === '$document') {
|
|
85
85
|
results.push(currentWin.document);
|
|
86
86
|
} else {
|
|
87
87
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
88
|
-
if (selector === '
|
|
89
|
-
else if (selector === '
|
|
90
|
-
else if (selector === '
|
|
91
|
-
else if (selector === '
|
|
92
|
-
else if (selector === '
|
|
93
|
-
else if (selector === '
|
|
88
|
+
if (selector === '$host') applyRoot(hostSet.$host);
|
|
89
|
+
else if (selector === '$parentHost') applyRoot(hostSet.$parentHost);
|
|
90
|
+
else if (selector === '$appHost') applyRoot(hostSet.$appHost as any);
|
|
91
|
+
else if (selector === '$firstHost') applyRoot(hostSet.$firstHost);
|
|
92
|
+
else if (selector === '$lastHost') applyRoot(hostSet.$lastHost);
|
|
93
|
+
else if (selector === '$firstAppHost') applyRoot(hostSet.$firstAppHost as any);
|
|
94
|
+
else if (selector === '$lastAppHost') applyRoot(hostSet.$lastAppHost as any);
|
|
94
95
|
else {
|
|
95
96
|
if (r === 'shadow') {
|
|
96
97
|
const found = inst.shadowRoot?.querySelectorAll(selector);
|
|
@@ -189,29 +190,29 @@ export function attribute(selector: string, options: AttributeFieldOptions = {})
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
/**
|
|
192
|
-
* @
|
|
193
|
+
* @attributeThis decorator to sync a field value with the $this element's attribute.
|
|
193
194
|
*/
|
|
194
|
-
export function
|
|
195
|
-
export function
|
|
196
|
-
export function
|
|
197
|
-
export function
|
|
198
|
-
export function
|
|
195
|
+
export function attributeThis(target: Object, propertyKey: string | symbol): void;
|
|
196
|
+
export function attributeThis(options: AttributeFieldOptions): PropertyDecorator;
|
|
197
|
+
export function attributeThis(attrName: string): PropertyDecorator;
|
|
198
|
+
export function attributeThis(attrName: string, options: AttributeFieldOptions): PropertyDecorator;
|
|
199
|
+
export function attributeThis(targetOrAttrOrOptions?: any, propertyKeyOrOptions?: any): any {
|
|
199
200
|
if (propertyKeyOrOptions !== undefined && (typeof propertyKeyOrOptions === 'string' || typeof propertyKeyOrOptions === 'symbol')) {
|
|
200
|
-
return attribute('
|
|
201
|
+
return attribute('$this', { name: String(propertyKeyOrOptions) })(targetOrAttrOrOptions, propertyKeyOrOptions);
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
if (typeof targetOrAttrOrOptions === 'string') {
|
|
204
205
|
const attrName = targetOrAttrOrOptions;
|
|
205
206
|
const options = (typeof propertyKeyOrOptions === 'object' ? propertyKeyOrOptions : {}) as AttributeFieldOptions;
|
|
206
|
-
return attribute('
|
|
207
|
+
return attribute('$this', { ...options, name: attrName });
|
|
207
208
|
} else if (typeof targetOrAttrOrOptions === 'object') {
|
|
208
209
|
const options = targetOrAttrOrOptions as AttributeFieldOptions;
|
|
209
210
|
return (target: Object, propertyKey: string | symbol) => {
|
|
210
|
-
return attribute('
|
|
211
|
+
return attribute('$this', { ...options, name: String(propertyKey) })(target, propertyKey);
|
|
211
212
|
};
|
|
212
213
|
} else {
|
|
213
214
|
return (target: Object, propertyKey: string | symbol) => {
|
|
214
|
-
return attribute('
|
|
215
|
+
return attribute('$this', { name: String(propertyKey) })(target, propertyKey);
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
}
|
|
@@ -2,15 +2,15 @@ import { ReflectUtils } from '@dooboostore/core';
|
|
|
2
2
|
|
|
3
3
|
export const ON_ATTRIBUTE_CHANGED_METADATA_KEY = Symbol.for('simple-web-component:on-attribute-changed');
|
|
4
4
|
|
|
5
|
-
export interface
|
|
5
|
+
export interface ChangedAttributeThisOptions {
|
|
6
6
|
type?: typeof Number | typeof Boolean | typeof String;
|
|
7
7
|
while?: 'connected';
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface ChangedAttributeThisMetadata {
|
|
11
11
|
attributeName: string;
|
|
12
12
|
propertyKey: string | symbol;
|
|
13
|
-
options:
|
|
13
|
+
options: ChangedAttributeThisOptions;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const convertValue = (val: any, type: any): any => {
|
|
@@ -21,14 +21,12 @@ const convertValue = (val: any, type: any): any => {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
|
-
* @
|
|
25
|
-
* Usage: @changedAttributeHost('data-product-id')
|
|
26
|
-
* @changedAttributeHost('count', { type: Number })
|
|
24
|
+
* @changedAttributeThis decorator - fires when any attribute on $this changes
|
|
27
25
|
*/
|
|
28
|
-
export function
|
|
26
|
+
export function changedAttributeThis(attributeName?: string, options: ChangedAttributeThisOptions = {}): MethodDecorator {
|
|
29
27
|
return (target: Object, propertyKey: string | symbol) => {
|
|
30
28
|
const constructor = target.constructor;
|
|
31
|
-
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as
|
|
29
|
+
let metaList = ReflectUtils.getOwnMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) as ChangedAttributeThisMetadata[];
|
|
32
30
|
if (!metaList) {
|
|
33
31
|
metaList = [];
|
|
34
32
|
ReflectUtils.defineMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, metaList, constructor);
|
|
@@ -43,16 +41,16 @@ export function changedAttributeHost(attributeName?: string, options: ChangedAtt
|
|
|
43
41
|
};
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
export const getChangedAttributeMetadata = (target: any):
|
|
44
|
+
export const getChangedAttributeMetadata = (target: any): ChangedAttributeThisMetadata[] | undefined => {
|
|
47
45
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
48
46
|
return ReflectUtils.getMetadata(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor);
|
|
49
47
|
};
|
|
50
48
|
|
|
51
|
-
export const findAllAttributeChangedMetadata = (target: any): Map<string,
|
|
49
|
+
export const findAllAttributeChangedMetadata = (target: any): Map<string, ChangedAttributeThisMetadata[]> => {
|
|
52
50
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
53
|
-
const metaList = ReflectUtils.findAllMetadata<
|
|
51
|
+
const metaList = ReflectUtils.findAllMetadata<ChangedAttributeThisMetadata[]>(ON_ATTRIBUTE_CHANGED_METADATA_KEY, constructor) || [];
|
|
54
52
|
|
|
55
|
-
const result = new Map<string,
|
|
53
|
+
const result = new Map<string, ChangedAttributeThisMetadata[]>();
|
|
56
54
|
metaList.forEach(meta => {
|
|
57
55
|
meta.forEach(item => {
|
|
58
56
|
if (!result.has(item.attributeName)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {ReflectUtils, FunctionUtils, ActionExpression} from '@dooboostore/core';
|
|
2
2
|
import {getAddEventListenerMetadata} from './addEventListener';
|
|
3
|
-
import {ON_INITIALIZE_METADATA_KEY, ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, findAllLifecycleMetadata, getOnConnectedInnerHtmlMetadata} from './lifecycles';
|
|
3
|
+
import {ON_INITIALIZE_METADATA_KEY, ON_BEFORE_CONNECTED_METADATA_KEY, ON_AFTER_CONNECTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_AFTER_ADOPTED_METADATA_KEY, findAllLifecycleMetadata, getOnConnectedInnerHtmlMetadata, getOnConnectedBeforeMetadata, getOnConnectedAfterMetadata, ON_CONNECTED_COMPLETED_METADATA_KEY} from './lifecycles';
|
|
4
4
|
import {getEmitCustomEventMetadataList} from './emitCustomEvent';
|
|
5
|
-
import {findAllAttributeChangedMetadata, convertAttributeValue} from './
|
|
5
|
+
import {findAllAttributeChangedMetadata, convertAttributeValue} from './changedAttributeThis';
|
|
6
6
|
import {findAllAttributeApplyMetadata} from './applyAttribute';
|
|
7
7
|
import {findAllAttributeMetadata, getAttributeValue} from './attribute';
|
|
8
8
|
import {getQueryMetadata} from './query';
|
|
@@ -10,8 +10,10 @@ import {getQueryAllMetadata} from './queryAll';
|
|
|
10
10
|
import {SwcUtils} from '../utils/Utils';
|
|
11
11
|
import {HTML_TAG_ENTRIES, DOM_EVENT_NAMES} from '../config/config';
|
|
12
12
|
import {SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot/decorators/inject/Inject';
|
|
13
|
-
import {InjectSituationType, HostSet, HelperHostSet} from '../types';
|
|
14
|
-
import {ConvertUtils} from '@dooboostore/core-web';
|
|
13
|
+
import {InjectSituationType, HostSet, HelperHostSet, SwcAppInterface} from '../types';
|
|
14
|
+
import {ConvertUtils, NodeSlot} from '@dooboostore/core-web';
|
|
15
|
+
import {isSSR} from "../elements/SwcApp";
|
|
16
|
+
import {findAllApplySlotMetadata} from "./applySlot";
|
|
15
17
|
|
|
16
18
|
// --- Core Interfaces & Types ---
|
|
17
19
|
|
|
@@ -35,9 +37,9 @@ export const getElementConfig = (target: any): ElementMetadata | undefined => {
|
|
|
35
37
|
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
36
38
|
};
|
|
37
39
|
|
|
38
|
-
export const ensureInit = (inst: any) => {
|
|
40
|
+
export const ensureInit = (inst: any) => { // HTMLElement
|
|
39
41
|
if (!inst.__swc_initialized) {
|
|
40
|
-
inst._swcId = Math.random().toString(36).substring(2, 11);
|
|
42
|
+
inst._swcId = inst?.getAttribute?.('swc-use-ssr') ?? Math.random().toString(36).substring(2, 11);
|
|
41
43
|
inst._emitHandlers = new Map();
|
|
42
44
|
inst._boundListeners = [];
|
|
43
45
|
inst.__swc_initialized = true;
|
|
@@ -54,7 +56,7 @@ export const ensureInit = (inst: any) => {
|
|
|
54
56
|
// ║ ║
|
|
55
57
|
// ║ 이유: ║
|
|
56
58
|
// ║ 1. TypeScript는 초기값이 있는 필드를 constructor에서 own property로 생성 ║
|
|
57
|
-
// ║ @
|
|
59
|
+
// ║ @attributeThis('id') myId: string = "default" → this.myId = "default" ║
|
|
58
60
|
// ║ ║
|
|
59
61
|
// ║ 2. JavaScript의 property lookup은 own property를 먼저 찾음 ║
|
|
60
62
|
// ║ - this.myId 접근 ║
|
|
@@ -89,10 +91,16 @@ export const ensureInit = (inst: any) => {
|
|
|
89
91
|
delete (inst as any)[meta.propertyKey];
|
|
90
92
|
});
|
|
91
93
|
}
|
|
94
|
+
const slotAllList = findAllApplySlotMetadata(target);
|
|
95
|
+
if (slotAllList) {
|
|
96
|
+
slotAllList.filter(it=>it.type === 'property').forEach(meta => {
|
|
97
|
+
delete (inst as any)[meta.propertyKey];
|
|
98
|
+
});
|
|
99
|
+
}
|
|
92
100
|
|
|
93
101
|
// Call constructor script if present
|
|
94
102
|
const hostSet = SwcUtils.getHostSet(inst);
|
|
95
|
-
const appHosts = SwcUtils.
|
|
103
|
+
const appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(inst);
|
|
96
104
|
inst._executeSwcScript?.('swc-on-constructor', hostSet);
|
|
97
105
|
|
|
98
106
|
// Call @onInitialize lifecycle methods
|
|
@@ -116,7 +124,7 @@ const handleGlobalSwcEvent = async (event: Event) => {
|
|
|
116
124
|
if (!(node instanceof HTMLElement)) continue;
|
|
117
125
|
const script = node.getAttribute?.(attrName);
|
|
118
126
|
if (script && !getElementConfig(node)) {
|
|
119
|
-
const host: any = SwcUtils.
|
|
127
|
+
const host: any = SwcUtils.findNearestSwcHostIncludingSelf(node);
|
|
120
128
|
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {
|
|
121
129
|
await host.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
122
130
|
(event as any).__swc_handled = true;
|
|
@@ -143,7 +151,7 @@ const getHandlers = (inst: any) => {
|
|
|
143
151
|
return inst.__swc_attributeEventHandlers;
|
|
144
152
|
};
|
|
145
153
|
|
|
146
|
-
const setupPrototype = (proto: any) => {
|
|
154
|
+
const setupPrototype = (proto: any, win: Window) => {
|
|
147
155
|
if (proto.__swc_proto_setup) return;
|
|
148
156
|
proto.__swc_proto_setup = true;
|
|
149
157
|
|
|
@@ -166,7 +174,7 @@ const setupPrototype = (proto: any) => {
|
|
|
166
174
|
proto._resolveWindow = function (localConfig?: ElementConfig): Window {
|
|
167
175
|
ensureInit(this);
|
|
168
176
|
if (localConfig?.window) return localConfig.window;
|
|
169
|
-
const ancestors = SwcUtils.
|
|
177
|
+
const ancestors = SwcUtils.findAllSwcHostsIncludingSelf(this as any);
|
|
170
178
|
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
171
179
|
const aConf = getElementConfig(ancestors[i]);
|
|
172
180
|
if (aConf?.window) return aConf.window;
|
|
@@ -177,7 +185,7 @@ const setupPrototype = (proto: any) => {
|
|
|
177
185
|
proto._invokeLifecycleMethod = function (methodName: string | symbol, hostSet?: HostSet, extraArgs: any[] = []) {
|
|
178
186
|
ensureInit(this);
|
|
179
187
|
if (typeof (this as any)[methodName] !== 'function') return;
|
|
180
|
-
const useHostSet = hostSet ?? SwcUtils.
|
|
188
|
+
const useHostSet = hostSet ?? SwcUtils.getHelperAndHostSet(win, this);
|
|
181
189
|
const app = useHostSet?.$appHost?.simpleApplication;
|
|
182
190
|
// console.log('---->hh',app, this, methodName);
|
|
183
191
|
if (app) {
|
|
@@ -285,7 +293,7 @@ export const elementDefine =
|
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
288
|
-
const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '
|
|
296
|
+
const emitHostCustomEventList = emitCustomEventList.filter(meta => meta.selector === '$this' || meta.selector === '');
|
|
289
297
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
290
298
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
291
299
|
const attributeList = findAllAttributeMetadata(constructor);
|
|
@@ -297,14 +305,14 @@ export const elementDefine =
|
|
|
297
305
|
const attributeApplyNames = Array.from(applyAttributeMap.values())
|
|
298
306
|
.map(it => it.options.name)
|
|
299
307
|
.filter(Boolean) as string[];
|
|
300
|
-
const hostAttributes = attributeList.filter(it => it.selector === '
|
|
308
|
+
const hostAttributes = attributeList.filter(it => it.selector === '$this').map(it => it.options.name || String(it.propertyKey));
|
|
301
309
|
// Get original static observedAttributes before they're overwritten by Object.defineProperty
|
|
302
310
|
const originalStaticObservedAttributes = (constructor.observedAttributes ?? []) as string[];
|
|
303
311
|
const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map(it => (it.options as any).attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
304
|
-
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
312
|
+
// const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
305
313
|
|
|
306
314
|
const proto = constructor.prototype;
|
|
307
|
-
setupPrototype(proto);
|
|
315
|
+
setupPrototype(proto, win);
|
|
308
316
|
|
|
309
317
|
// 값을 기대하지않는다.
|
|
310
318
|
let helperHostSet: HelperHostSet | null = null;
|
|
@@ -314,61 +322,69 @@ export const elementDefine =
|
|
|
314
322
|
// connected 됐을시 최신화
|
|
315
323
|
helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);
|
|
316
324
|
const appHost = helperHostSet.$appHost;
|
|
325
|
+
const useSsr = isSSR(this);
|
|
326
|
+
// console.log('isSsr', useSsr, this);
|
|
327
|
+
// console.log('----helperHostSet--->', this, helperHostSet, useSsr)
|
|
328
|
+
// let connectedApp: SwcAppInterface |undefined;
|
|
317
329
|
try {
|
|
318
330
|
if (appHost && typeof (appHost as any)._connected === 'function') {
|
|
319
|
-
|
|
331
|
+
await (appHost as any)._connected(this);
|
|
320
332
|
} else if (appHost && typeof (appHost as any)) {
|
|
321
|
-
(appHost as any).
|
|
322
|
-
(appHost as any).
|
|
333
|
+
(appHost as any)._connected_safari_and_standby ??= [];
|
|
334
|
+
(appHost as any)._connected_safari_and_standby.push(this);
|
|
323
335
|
}
|
|
324
336
|
|
|
325
337
|
// const hostSet = SwcUtils.getHostSet(this as any);
|
|
326
338
|
const conf = getElementConfig(this);
|
|
327
339
|
const currentWin = (this as any)._resolveWindow(conf);
|
|
328
340
|
|
|
329
|
-
const
|
|
341
|
+
const bMethods = getOnConnectedBeforeMetadata(this).filter(it => useSsr ? !it.options.ssrFirst : true);
|
|
342
|
+
// console.log('beforeConnected', bMethods)
|
|
343
|
+
if (bMethods) {
|
|
344
|
+
for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
345
|
+
}
|
|
346
|
+
(this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);
|
|
347
|
+
|
|
348
|
+
// console.log('vvvvvvvvvvvvvvvu-seSsr-vvvvvvvvvv>', useSsr, this.tagName, this.getAttribute('seq'))
|
|
349
|
+
// // ssr 처리라서 이미 내려준거그대로 상요하면된다 따라서 호출안한다
|
|
350
|
+
const targetConnectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor).filter(it => useSsr ? !it.options.ssrFirst : true);
|
|
351
|
+
const shadowMode = conf?.useShadow || targetConnectedInnerHtmlList.find(it => it.options.useShadow)?.options.useShadow;
|
|
330
352
|
if (shadowMode && !this.shadowRoot) {
|
|
331
353
|
const mode = shadowMode === true ? 'open' : shadowMode;
|
|
332
354
|
this.attachShadow({mode: mode as ShadowRootMode});
|
|
333
355
|
}
|
|
334
356
|
|
|
335
|
-
|
|
336
|
-
if (bMethods) {
|
|
337
|
-
for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m, helperHostSet);
|
|
338
|
-
}
|
|
339
|
-
(this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);
|
|
340
|
-
|
|
341
|
-
if (connectedInnerHtmlList.length > 0) {
|
|
357
|
+
if (targetConnectedInnerHtmlList.length > 0) {
|
|
342
358
|
let sContent = '',
|
|
343
359
|
lContent = '';
|
|
344
|
-
for (const meta of
|
|
360
|
+
for (const meta of targetConnectedInnerHtmlList) {
|
|
345
361
|
// const res = (this as any)[meta.propertyKey]();
|
|
346
362
|
let res = await (this as any)._invokeLifecycleMethod(meta.propertyKey, helperHostSet);
|
|
347
363
|
const actionExpression = new ActionExpression(res, {
|
|
348
364
|
expression: {
|
|
349
365
|
replace: {
|
|
350
|
-
start: meta.options.replaceWrap?.start || '
|
|
351
|
-
end: meta.options.replaceWrap?.end || '
|
|
366
|
+
start: meta.options.replaceWrap?.start || '[[',
|
|
367
|
+
end: meta.options.replaceWrap?.end || ']]'
|
|
352
368
|
},
|
|
353
369
|
callReturn: {
|
|
354
|
-
start: meta.options.replaceWrap?.start || '
|
|
355
|
-
end: meta.options.replaceWrap?.end || '
|
|
370
|
+
start: meta.options.replaceWrap?.start || '[[=',
|
|
371
|
+
end: meta.options.replaceWrap?.end || ']]'
|
|
356
372
|
},
|
|
357
373
|
call: {
|
|
358
|
-
start: meta.options.replaceWrap?.start || '
|
|
359
|
-
end: meta.options.replaceWrap?.end || '
|
|
374
|
+
start: meta.options.replaceWrap?.start || '[[@',
|
|
375
|
+
end: meta.options.replaceWrap?.end || ']]'
|
|
360
376
|
}
|
|
361
377
|
}
|
|
362
378
|
});
|
|
363
379
|
|
|
364
380
|
actionExpression.getExpressions().filter(it => it.type === 'replace').forEach(it => {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
} catch (e) {
|
|
370
|
-
|
|
371
|
-
}
|
|
381
|
+
actionExpression.replace(it, NodeSlot.slot(`${this._swcId}-${it.script}`));
|
|
382
|
+
// try {
|
|
383
|
+
// const sr = FunctionUtils.executeReturn({script: it.script, context: this, args: helperHostSet});
|
|
384
|
+
// actionExpression.replace(it, sr);
|
|
385
|
+
// } catch (e) {
|
|
386
|
+
// console.error(`[SWC] Failed to execute connectedInnerHTML:`, e);
|
|
387
|
+
// }
|
|
372
388
|
});
|
|
373
389
|
res = actionExpression.getUnprocessedTemplate();
|
|
374
390
|
|
|
@@ -402,7 +418,7 @@ export const elementDefine =
|
|
|
402
418
|
const nonDelegateListeners: typeof addEventListenerList = [];
|
|
403
419
|
|
|
404
420
|
addEventListenerList.forEach(meta => {
|
|
405
|
-
if (meta.options.delegate && meta.selector !== '
|
|
421
|
+
if (meta.options.delegate && meta.selector !== '$window' && meta.selector !== '$document' && meta.selector !== '$host' && meta.selector !== '$appHost' && meta.selector !== '$firstHost' && meta.selector !== '$lastHost' && meta.selector !== '$firstAppHost' && meta.selector !== '$lastAppHost' && meta.selector !== '$hosts' && meta.selector !== '$appHosts' && meta.selector !== '$this' && meta.selector !== '') {
|
|
406
422
|
delegateListeners.push(meta);
|
|
407
423
|
} else {
|
|
408
424
|
nonDelegateListeners.push(meta);
|
|
@@ -482,17 +498,18 @@ export const elementDefine =
|
|
|
482
498
|
}
|
|
483
499
|
};
|
|
484
500
|
|
|
485
|
-
if (selector === '
|
|
486
|
-
else if (selector === '
|
|
487
|
-
else if (selector === '
|
|
488
|
-
else if (selector === '
|
|
489
|
-
else if (selector === '
|
|
490
|
-
else if (selector === '
|
|
491
|
-
else if (selector === '
|
|
492
|
-
else if (selector === '
|
|
493
|
-
else if (selector === '
|
|
494
|
-
else if (selector === '
|
|
495
|
-
else if (selector === '
|
|
501
|
+
if (selector === '$window') bindTargets.push(currentWin);
|
|
502
|
+
else if (selector === '$document') bindTargets.push(currentWin.document);
|
|
503
|
+
else if (selector === '$host') applyRootOption(helperHostSet.$host);
|
|
504
|
+
else if (selector === '$parentHost') applyRootOption(helperHostSet.$parentHost);
|
|
505
|
+
else if (selector === '$appHost') applyRootOption(helperHostSet.$appHost);
|
|
506
|
+
else if (selector === '$firstHost') applyRootOption(helperHostSet.$firstHost);
|
|
507
|
+
else if (selector === '$lastHost') applyRootOption(helperHostSet.$lastHost);
|
|
508
|
+
else if (selector === '$firstAppHost') applyRootOption(helperHostSet.$firstAppHost);
|
|
509
|
+
else if (selector === '$lastAppHost') applyRootOption(helperHostSet.$lastAppHost);
|
|
510
|
+
else if (selector === '$hosts') helperHostSet.$hosts.forEach(applyRootOption);
|
|
511
|
+
else if (selector === '$appHosts') helperHostSet.$appHosts.forEach(applyRootOption);
|
|
512
|
+
else if (selector === '$this' || !selector) applyRootOption(this);
|
|
496
513
|
else {
|
|
497
514
|
const searchRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
498
515
|
if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));
|
|
@@ -533,15 +550,18 @@ export const elementDefine =
|
|
|
533
550
|
|
|
534
551
|
if (originalConnected) await (originalConnected.apply(this));
|
|
535
552
|
|
|
536
|
-
const aMethods =
|
|
553
|
+
const aMethods = getOnConnectedAfterMetadata(this).filter(it => {
|
|
554
|
+
return useSsr ? !it.options.ssrFirst : true;
|
|
555
|
+
});
|
|
556
|
+
// console.log('afterConnected', this.tagName, aMethods, getOnConnectedAfterMetadata(this))
|
|
537
557
|
if (aMethods) {
|
|
538
|
-
for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m, helperHostSet);
|
|
558
|
+
for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
539
559
|
}
|
|
540
560
|
(this as any)._executeSwcScript('swc-on-connected', helperHostSet);
|
|
541
561
|
(this as any)._executeSwcScript('swc-on-after-connected', helperHostSet);
|
|
542
562
|
(this as any).__swc_connected = true;
|
|
543
563
|
|
|
544
|
-
// Trigger @
|
|
564
|
+
// Trigger @changedAttributeThis with while: 'connected'
|
|
545
565
|
for (let [name, metaList] of Array.from(attrChangeMap)) {
|
|
546
566
|
for (const meta of metaList) {
|
|
547
567
|
if (meta.options.while === 'connected') {
|
|
@@ -553,6 +573,9 @@ export const elementDefine =
|
|
|
553
573
|
}
|
|
554
574
|
}
|
|
555
575
|
} finally {
|
|
576
|
+
for (let mPropertyKey of findAllLifecycleMetadata(this, ON_CONNECTED_COMPLETED_METADATA_KEY)) {
|
|
577
|
+
await (this as any)._invokeLifecycleMethod(mPropertyKey, helperHostSet);
|
|
578
|
+
}
|
|
556
579
|
if (appHost && typeof (appHost as any)._connectedDone === 'function') {
|
|
557
580
|
await (appHost as any)._connectedDone(this);
|
|
558
581
|
}
|
|
@@ -563,7 +586,7 @@ export const elementDefine =
|
|
|
563
586
|
proto.disconnectedCallback = function () {
|
|
564
587
|
// const helperHostSet = SwcUtils.getHelperAndHostSet(win, this as any);
|
|
565
588
|
// Remove from appHost LAST when disconnected
|
|
566
|
-
console.log('disconnnnnnnnnnnnnnnnnnn', helperHostSet, this)
|
|
589
|
+
// console.log('disconnnnnnnnnnnnnnnnnnn', helperHostSet, this)
|
|
567
590
|
const appHost = helperHostSet.$appHost;
|
|
568
591
|
if (appHost && typeof (appHost as any)._disconnected === 'function') {
|
|
569
592
|
(appHost as any)._disconnected(this);
|
|
@@ -60,25 +60,27 @@ export function emitCustomEvent(selectorOrTarget: string, type: string, options:
|
|
|
60
60
|
const currentWin = (this as any)._resolveWindow?.(conf) || ((typeof window !== 'undefined' ? window : undefined) as Window);
|
|
61
61
|
|
|
62
62
|
const eventTargets: EventTarget[] = [];
|
|
63
|
-
if (selectorOrTarget === '
|
|
64
|
-
else if (selectorOrTarget === '
|
|
65
|
-
else if (selectorOrTarget === '
|
|
63
|
+
if (selectorOrTarget === '$window') eventTargets.push(currentWin);
|
|
64
|
+
else if (selectorOrTarget === '$document') eventTargets.push(currentWin.document);
|
|
65
|
+
else if (selectorOrTarget === '$host') {
|
|
66
|
+
if (hostSet.$host) eventTargets.push(hostSet.$host);
|
|
67
|
+
} else if (selectorOrTarget === '$parentHost') {
|
|
66
68
|
if (hostSet.$parentHost) eventTargets.push(hostSet.$parentHost);
|
|
67
|
-
} else if (selectorOrTarget === '
|
|
69
|
+
} else if (selectorOrTarget === '$appHost') {
|
|
68
70
|
if (hostSet.$appHost) eventTargets.push(hostSet.$appHost);
|
|
69
|
-
} else if (selectorOrTarget === '
|
|
71
|
+
} else if (selectorOrTarget === '$firstHost') {
|
|
70
72
|
if (hostSet.$firstHost) eventTargets.push(hostSet.$firstHost);
|
|
71
|
-
} else if (selectorOrTarget === '
|
|
73
|
+
} else if (selectorOrTarget === '$lastHost') {
|
|
72
74
|
if (hostSet.$lastHost) eventTargets.push(hostSet.$lastHost);
|
|
73
|
-
} else if (selectorOrTarget === '
|
|
75
|
+
} else if (selectorOrTarget === '$firstAppHost') {
|
|
74
76
|
if (hostSet.$firstAppHost) eventTargets.push(hostSet.$firstAppHost);
|
|
75
|
-
} else if (selectorOrTarget === '
|
|
77
|
+
} else if (selectorOrTarget === '$lastAppHost') {
|
|
76
78
|
if (hostSet.$lastAppHost) eventTargets.push(hostSet.$lastAppHost);
|
|
77
|
-
} else if (selectorOrTarget === '
|
|
79
|
+
} else if (selectorOrTarget === '$hosts') {
|
|
78
80
|
hostSet.$hosts.forEach(h => eventTargets.push(h));
|
|
79
|
-
} else if (selectorOrTarget === '
|
|
81
|
+
} else if (selectorOrTarget === '$appHosts') {
|
|
80
82
|
hostSet.$appHosts.forEach(h => eventTargets.push(h));
|
|
81
|
-
} else if (selectorOrTarget === '
|
|
83
|
+
} else if (selectorOrTarget === '$this' || !selectorOrTarget) {
|
|
82
84
|
eventTargets.push(this as any);
|
|
83
85
|
} else {
|
|
84
86
|
const r = fullOptions.root || 'auto';
|
|
@@ -121,27 +123,20 @@ export const getEmitCustomEventMetadataList = (target: any): EmitCustomEventMeta
|
|
|
121
123
|
};
|
|
122
124
|
|
|
123
125
|
/**
|
|
124
|
-
* @
|
|
125
|
-
* Usage: @emitCustomEventHost('navigate') // default attributeName: 'on-emit-navigate'
|
|
126
|
-
* Usage: @emitCustomEventHost('navigate', { attributeName: 'on-navigate' })
|
|
127
|
-
*
|
|
128
|
-
* The attributeName option is used to automatically observe attributes for this event.
|
|
129
|
-
* For example, { attributeName: 'on-navigate' } will add 'on-navigate' to observedAttributes.
|
|
126
|
+
* @emitCustomEventThis decorator - simplified version of @emitCustomEvent for $this selector
|
|
130
127
|
*/
|
|
131
|
-
export function
|
|
132
|
-
export function
|
|
133
|
-
export function
|
|
134
|
-
export function
|
|
128
|
+
export function emitCustomEventThis(type: string, options: EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string }): MethodDecorator ;
|
|
129
|
+
export function emitCustomEventThis(type: string, attributeName: string): MethodDecorator ;
|
|
130
|
+
export function emitCustomEventThis(type: string): MethodDecorator;
|
|
131
|
+
export function emitCustomEventThis(type: string, optionsOrAttributeaName?: string | (EmitCustomEventBaseOptions & SwcQueryOptions & { attributeName?: string })): MethodDecorator {
|
|
135
132
|
if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'string') {
|
|
136
|
-
return
|
|
133
|
+
return emitCustomEventThis(type, {attributeName: optionsOrAttributeaName});
|
|
137
134
|
} else if (optionsOrAttributeaName && typeof optionsOrAttributeaName === 'object') {
|
|
138
135
|
if (!optionsOrAttributeaName.attributeName) {
|
|
139
136
|
optionsOrAttributeaName.attributeName = `on-emit-${type}`;
|
|
140
137
|
}
|
|
141
|
-
return emitCustomEvent('
|
|
138
|
+
return emitCustomEvent('$this', type, optionsOrAttributeaName);
|
|
142
139
|
} else {
|
|
143
|
-
return emitCustomEvent('
|
|
140
|
+
return emitCustomEvent('$this', type, {attributeName: `on-emit-${type}`});
|
|
144
141
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
142
|
}
|
package/src/decorators/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './addEventListener';
|
|
2
2
|
export * from './attribute';
|
|
3
3
|
export * from './elementDefine';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './changedAttributeThis';
|
|
5
5
|
export * from './emitCustomEvent';
|
|
6
6
|
export * from './applyNode';
|
|
7
7
|
export * from './lifecycles';
|
|
@@ -14,3 +14,4 @@ export * from './setProperty';
|
|
|
14
14
|
export * from './subscribeSwcAppRouteChangeWhileConnected';
|
|
15
15
|
export * from './subscribeSwcAppMessageWhileConnected';
|
|
16
16
|
export * from './publishSwcAppMessage';
|
|
17
|
+
export * from './applySlot';
|