@dooboostore/simple-web-component 1.0.17 → 1.0.19
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 +130 -143
- package/dist/cjs/config/config.js +2 -0
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +4 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/appendChild.js +92 -0
- package/dist/cjs/decorators/appendChild.js.map +7 -0
- package/dist/cjs/decorators/classList.js +104 -0
- package/dist/cjs/decorators/classList.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +309 -349
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +61 -9
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +5 -1
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/{innerHtml.js → onConnectedInnerHtml.js} +8 -8
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +7 -0
- package/dist/cjs/decorators/query.js +61 -21
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +61 -19
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/replaceChildren.js +79 -0
- package/dist/cjs/decorators/replaceChildren.js.map +7 -0
- package/dist/cjs/decorators/setAttribute.js +35 -7
- package/dist/cjs/decorators/setAttribute.js.map +2 -2
- package/dist/cjs/decorators/style.js +88 -0
- package/dist/cjs/decorators/style.js.map +7 -0
- package/dist/cjs/elements/SwcAppEngine.js +23 -8
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +52 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/SwcAsync.js +57 -122
- package/dist/cjs/elements/SwcAsync.js.map +3 -3
- package/dist/cjs/elements/SwcChoose.js +51 -75
- package/dist/cjs/elements/SwcChoose.js.map +3 -3
- package/dist/cjs/elements/SwcIf.js +65 -93
- package/dist/cjs/elements/SwcIf.js.map +3 -3
- package/dist/cjs/elements/SwcLoop.js +72 -173
- package/dist/cjs/elements/SwcLoop.js.map +3 -3
- package/dist/cjs/elements/SwcSubTemplates.js +12 -37
- package/dist/cjs/elements/SwcSubTemplates.js.map +3 -3
- package/dist/cjs/elements/index.js +1 -8
- package/dist/cjs/elements/index.js.map +2 -2
- package/dist/cjs/elements/register.js +831 -0
- package/dist/cjs/elements/register.js.map +7 -0
- package/dist/cjs/index.js +22 -2
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/TemplateUtils.js +103 -0
- package/dist/cjs/utils/TemplateUtils.js.map +7 -0
- package/dist/cjs/utils/Utils.js +10 -7
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/config/config.js +2 -0
- package/dist/esm/config/config.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js +4 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/appendChild.js +73 -0
- package/dist/esm/decorators/appendChild.js.map +7 -0
- package/dist/esm/decorators/classList.js +85 -0
- package/dist/esm/decorators/classList.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +309 -349
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +61 -9
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +5 -1
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/{innerHtml.js → onConnectedInnerHtml.js} +5 -5
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +7 -0
- package/dist/esm/decorators/query.js +62 -22
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +62 -20
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/replaceChildren.js +60 -0
- package/dist/esm/decorators/replaceChildren.js.map +7 -0
- package/dist/esm/decorators/setAttribute.js +35 -7
- package/dist/esm/decorators/setAttribute.js.map +2 -2
- package/dist/esm/decorators/style.js +69 -0
- package/dist/esm/decorators/style.js.map +7 -0
- package/dist/esm/elements/SwcAppEngine.js +23 -8
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +33 -0
- package/dist/esm/elements/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/SwcAsync.js +57 -122
- package/dist/esm/elements/SwcAsync.js.map +3 -3
- package/dist/esm/elements/SwcChoose.js +51 -75
- package/dist/esm/elements/SwcChoose.js.map +3 -3
- package/dist/esm/elements/SwcIf.js +65 -93
- package/dist/esm/elements/SwcIf.js.map +3 -3
- package/dist/esm/elements/SwcLoop.js +71 -172
- package/dist/esm/elements/SwcLoop.js.map +3 -3
- package/dist/esm/elements/SwcSubTemplates.js +12 -37
- package/dist/esm/elements/SwcSubTemplates.js.map +3 -3
- package/dist/esm/elements/index.js +1 -8
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/register.js +812 -0
- package/dist/esm/elements/register.js.map +7 -0
- package/dist/esm/index.js +18 -2
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/TemplateUtils.js +84 -0
- package/dist/esm/utils/TemplateUtils.js.map +7 -0
- package/dist/esm/utils/Utils.js +6 -3
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +1091 -5545
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/config/config.d.ts +1 -0
- package/dist/types/config/config.d.ts.map +1 -1
- package/dist/types/decorators/addEventListener.d.ts +11 -11
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/appendChild.d.ts +17 -0
- package/dist/types/decorators/appendChild.d.ts.map +1 -0
- package/dist/types/decorators/classList.d.ts +34 -0
- package/dist/types/decorators/classList.d.ts.map +1 -0
- package/dist/types/decorators/elementDefine.d.ts +9 -5
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +7 -4
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +5 -1
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/onConnectedInnerHtml.d.ts +15 -0
- package/dist/types/decorators/onConnectedInnerHtml.d.ts.map +1 -0
- package/dist/types/decorators/query.d.ts +7 -8
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts +5 -9
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/replaceChildren.d.ts +9 -0
- package/dist/types/decorators/replaceChildren.d.ts.map +1 -0
- package/dist/types/decorators/setAttribute.d.ts +13 -3
- package/dist/types/decorators/setAttribute.d.ts.map +1 -1
- package/dist/types/decorators/style.d.ts +24 -0
- package/dist/types/decorators/style.d.ts.map +1 -0
- package/dist/types/elements/SwcAppEngine.d.ts +2 -2
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +364 -0
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/SwcAsync.d.ts +2 -6
- package/dist/types/elements/SwcAsync.d.ts.map +1 -1
- package/dist/types/elements/SwcChoose.d.ts +2 -1
- package/dist/types/elements/SwcChoose.d.ts.map +1 -1
- package/dist/types/elements/SwcIf.d.ts +5 -6
- package/dist/types/elements/SwcIf.d.ts.map +1 -1
- package/dist/types/elements/SwcLoop.d.ts +4 -10
- package/dist/types/elements/SwcLoop.d.ts.map +1 -1
- package/dist/types/elements/SwcSubTemplates.d.ts.map +1 -1
- package/dist/types/elements/index.d.ts +1 -8
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts +2 -0
- package/dist/types/elements/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/TemplateUtils.d.ts +54 -0
- package/dist/types/utils/TemplateUtils.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +1091 -5545
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +2 -2
- package/src/config/config.ts +2 -0
- package/src/decorators/addEventListener.ts +12 -11
- package/src/decorators/appendChild.ts +86 -0
- package/src/decorators/classList.ts +117 -0
- package/src/decorators/elementDefine.ts +345 -349
- package/src/decorators/emitCustomEvent.ts +76 -12
- package/src/decorators/index.ts +5 -1
- package/src/decorators/{innerHtml.ts → onConnectedInnerHtml.ts} +7 -6
- package/src/decorators/query.ts +63 -31
- package/src/decorators/queryAll.ts +60 -28
- package/src/decorators/replaceChildren.ts +64 -0
- package/src/decorators/setAttribute.ts +53 -11
- package/src/decorators/style.ts +89 -0
- package/src/elements/SwcAppEngine.ts +26 -11
- package/src/elements/SwcAppMixin.ts +34 -0
- package/src/elements/SwcAsync.ts +57 -127
- package/src/elements/SwcChoose.ts +50 -76
- package/src/elements/SwcIf.ts +63 -85
- package/src/elements/SwcLoop.ts +70 -167
- package/src/elements/SwcSubTemplates.ts +0 -13
- package/src/elements/index.ts +1 -8
- package/src/elements/register.ts +735 -0
- package/src/index.ts +18 -4
- package/src/types.ts +13 -5
- package/src/utils/TemplateUtils.ts +83 -0
- package/src/utils/Utils.ts +6 -3
- package/dist/cjs/decorators/innerHtml.js.map +0 -7
- package/dist/cjs/elements/SwcApp.js +0 -55
- package/dist/cjs/elements/SwcApp.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppAnchor.js +0 -55
- package/dist/cjs/elements/is/SwcAppAnchor.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppArea.js +0 -55
- package/dist/cjs/elements/is/SwcAppArea.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppAudio.js +0 -55
- package/dist/cjs/elements/is/SwcAppAudio.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppBase.js +0 -55
- package/dist/cjs/elements/is/SwcAppBase.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppBody.js +0 -55
- package/dist/cjs/elements/is/SwcAppBody.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppButton.js +0 -55
- package/dist/cjs/elements/is/SwcAppButton.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppCanvas.js +0 -55
- package/dist/cjs/elements/is/SwcAppCanvas.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppData.js +0 -55
- package/dist/cjs/elements/is/SwcAppData.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDataList.js +0 -55
- package/dist/cjs/elements/is/SwcAppDataList.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDetails.js +0 -55
- package/dist/cjs/elements/is/SwcAppDetails.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDialog.js +0 -55
- package/dist/cjs/elements/is/SwcAppDialog.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDiv.js +0 -55
- package/dist/cjs/elements/is/SwcAppDiv.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppDl.js +0 -55
- package/dist/cjs/elements/is/SwcAppDl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppEmbed.js +0 -55
- package/dist/cjs/elements/is/SwcAppEmbed.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppFieldSet.js +0 -55
- package/dist/cjs/elements/is/SwcAppFieldSet.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppForm.js +0 -55
- package/dist/cjs/elements/is/SwcAppForm.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppHeading.js +0 -55
- package/dist/cjs/elements/is/SwcAppHeading.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppHr.js +0 -55
- package/dist/cjs/elements/is/SwcAppHr.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppIFrame.js +0 -55
- package/dist/cjs/elements/is/SwcAppIFrame.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppImage.js +0 -55
- package/dist/cjs/elements/is/SwcAppImage.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppInput.js +0 -55
- package/dist/cjs/elements/is/SwcAppInput.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLabel.js +0 -55
- package/dist/cjs/elements/is/SwcAppLabel.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLegend.js +0 -55
- package/dist/cjs/elements/is/SwcAppLegend.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLi.js +0 -55
- package/dist/cjs/elements/is/SwcAppLi.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppLink.js +0 -55
- package/dist/cjs/elements/is/SwcAppLink.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMap.js +0 -55
- package/dist/cjs/elements/is/SwcAppMap.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMeta.js +0 -55
- package/dist/cjs/elements/is/SwcAppMeta.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMeter.js +0 -55
- package/dist/cjs/elements/is/SwcAppMeter.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppMod.js +0 -55
- package/dist/cjs/elements/is/SwcAppMod.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppObject.js +0 -55
- package/dist/cjs/elements/is/SwcAppObject.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOl.js +0 -55
- package/dist/cjs/elements/is/SwcAppOl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOptGroup.js +0 -55
- package/dist/cjs/elements/is/SwcAppOptGroup.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOption.js +0 -55
- package/dist/cjs/elements/is/SwcAppOption.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppOutput.js +0 -55
- package/dist/cjs/elements/is/SwcAppOutput.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppParagraph.js +0 -55
- package/dist/cjs/elements/is/SwcAppParagraph.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppParam.js +0 -55
- package/dist/cjs/elements/is/SwcAppParam.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppPicture.js +0 -55
- package/dist/cjs/elements/is/SwcAppPicture.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppPre.js +0 -55
- package/dist/cjs/elements/is/SwcAppPre.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppProgress.js +0 -55
- package/dist/cjs/elements/is/SwcAppProgress.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppQuote.js +0 -55
- package/dist/cjs/elements/is/SwcAppQuote.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppScript.js +0 -55
- package/dist/cjs/elements/is/SwcAppScript.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSelect.js +0 -55
- package/dist/cjs/elements/is/SwcAppSelect.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSlot.js +0 -55
- package/dist/cjs/elements/is/SwcAppSlot.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSource.js +0 -55
- package/dist/cjs/elements/is/SwcAppSource.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppSpan.js +0 -55
- package/dist/cjs/elements/is/SwcAppSpan.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppStyle.js +0 -55
- package/dist/cjs/elements/is/SwcAppStyle.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTable.js +0 -55
- package/dist/cjs/elements/is/SwcAppTable.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableCell.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableCell.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableRow.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableRow.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTableSection.js +0 -55
- package/dist/cjs/elements/is/SwcAppTableSection.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTemplate.js +0 -55
- package/dist/cjs/elements/is/SwcAppTemplate.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTextArea.js +0 -55
- package/dist/cjs/elements/is/SwcAppTextArea.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTime.js +0 -55
- package/dist/cjs/elements/is/SwcAppTime.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTitle.js +0 -55
- package/dist/cjs/elements/is/SwcAppTitle.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppTrack.js +0 -55
- package/dist/cjs/elements/is/SwcAppTrack.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppUl.js +0 -55
- package/dist/cjs/elements/is/SwcAppUl.js.map +0 -7
- package/dist/cjs/elements/is/SwcAppVideo.js +0 -55
- package/dist/cjs/elements/is/SwcAppVideo.js.map +0 -7
- package/dist/cjs/elements/is/index.js +0 -74
- package/dist/cjs/elements/is/index.js.map +0 -7
- package/dist/esm/decorators/innerHtml.js.map +0 -7
- package/dist/esm/elements/SwcApp.js +0 -36
- package/dist/esm/elements/SwcApp.js.map +0 -7
- package/dist/esm/elements/is/SwcAppAnchor.js +0 -36
- package/dist/esm/elements/is/SwcAppAnchor.js.map +0 -7
- package/dist/esm/elements/is/SwcAppArea.js +0 -36
- package/dist/esm/elements/is/SwcAppArea.js.map +0 -7
- package/dist/esm/elements/is/SwcAppAudio.js +0 -36
- package/dist/esm/elements/is/SwcAppAudio.js.map +0 -7
- package/dist/esm/elements/is/SwcAppBase.js +0 -36
- package/dist/esm/elements/is/SwcAppBase.js.map +0 -7
- package/dist/esm/elements/is/SwcAppBody.js +0 -36
- package/dist/esm/elements/is/SwcAppBody.js.map +0 -7
- package/dist/esm/elements/is/SwcAppButton.js +0 -36
- package/dist/esm/elements/is/SwcAppButton.js.map +0 -7
- package/dist/esm/elements/is/SwcAppCanvas.js +0 -36
- package/dist/esm/elements/is/SwcAppCanvas.js.map +0 -7
- package/dist/esm/elements/is/SwcAppData.js +0 -36
- package/dist/esm/elements/is/SwcAppData.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDataList.js +0 -36
- package/dist/esm/elements/is/SwcAppDataList.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDetails.js +0 -36
- package/dist/esm/elements/is/SwcAppDetails.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDialog.js +0 -36
- package/dist/esm/elements/is/SwcAppDialog.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDiv.js +0 -36
- package/dist/esm/elements/is/SwcAppDiv.js.map +0 -7
- package/dist/esm/elements/is/SwcAppDl.js +0 -36
- package/dist/esm/elements/is/SwcAppDl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppEmbed.js +0 -36
- package/dist/esm/elements/is/SwcAppEmbed.js.map +0 -7
- package/dist/esm/elements/is/SwcAppFieldSet.js +0 -36
- package/dist/esm/elements/is/SwcAppFieldSet.js.map +0 -7
- package/dist/esm/elements/is/SwcAppForm.js +0 -36
- package/dist/esm/elements/is/SwcAppForm.js.map +0 -7
- package/dist/esm/elements/is/SwcAppHeading.js +0 -36
- package/dist/esm/elements/is/SwcAppHeading.js.map +0 -7
- package/dist/esm/elements/is/SwcAppHr.js +0 -36
- package/dist/esm/elements/is/SwcAppHr.js.map +0 -7
- package/dist/esm/elements/is/SwcAppIFrame.js +0 -36
- package/dist/esm/elements/is/SwcAppIFrame.js.map +0 -7
- package/dist/esm/elements/is/SwcAppImage.js +0 -36
- package/dist/esm/elements/is/SwcAppImage.js.map +0 -7
- package/dist/esm/elements/is/SwcAppInput.js +0 -36
- package/dist/esm/elements/is/SwcAppInput.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLabel.js +0 -36
- package/dist/esm/elements/is/SwcAppLabel.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLegend.js +0 -36
- package/dist/esm/elements/is/SwcAppLegend.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLi.js +0 -36
- package/dist/esm/elements/is/SwcAppLi.js.map +0 -7
- package/dist/esm/elements/is/SwcAppLink.js +0 -36
- package/dist/esm/elements/is/SwcAppLink.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMap.js +0 -36
- package/dist/esm/elements/is/SwcAppMap.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMeta.js +0 -36
- package/dist/esm/elements/is/SwcAppMeta.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMeter.js +0 -36
- package/dist/esm/elements/is/SwcAppMeter.js.map +0 -7
- package/dist/esm/elements/is/SwcAppMod.js +0 -36
- package/dist/esm/elements/is/SwcAppMod.js.map +0 -7
- package/dist/esm/elements/is/SwcAppObject.js +0 -36
- package/dist/esm/elements/is/SwcAppObject.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOl.js +0 -36
- package/dist/esm/elements/is/SwcAppOl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOptGroup.js +0 -36
- package/dist/esm/elements/is/SwcAppOptGroup.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOption.js +0 -36
- package/dist/esm/elements/is/SwcAppOption.js.map +0 -7
- package/dist/esm/elements/is/SwcAppOutput.js +0 -36
- package/dist/esm/elements/is/SwcAppOutput.js.map +0 -7
- package/dist/esm/elements/is/SwcAppParagraph.js +0 -36
- package/dist/esm/elements/is/SwcAppParagraph.js.map +0 -7
- package/dist/esm/elements/is/SwcAppParam.js +0 -36
- package/dist/esm/elements/is/SwcAppParam.js.map +0 -7
- package/dist/esm/elements/is/SwcAppPicture.js +0 -36
- package/dist/esm/elements/is/SwcAppPicture.js.map +0 -7
- package/dist/esm/elements/is/SwcAppPre.js +0 -36
- package/dist/esm/elements/is/SwcAppPre.js.map +0 -7
- package/dist/esm/elements/is/SwcAppProgress.js +0 -36
- package/dist/esm/elements/is/SwcAppProgress.js.map +0 -7
- package/dist/esm/elements/is/SwcAppQuote.js +0 -36
- package/dist/esm/elements/is/SwcAppQuote.js.map +0 -7
- package/dist/esm/elements/is/SwcAppScript.js +0 -36
- package/dist/esm/elements/is/SwcAppScript.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSelect.js +0 -36
- package/dist/esm/elements/is/SwcAppSelect.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSlot.js +0 -36
- package/dist/esm/elements/is/SwcAppSlot.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSource.js +0 -36
- package/dist/esm/elements/is/SwcAppSource.js.map +0 -7
- package/dist/esm/elements/is/SwcAppSpan.js +0 -36
- package/dist/esm/elements/is/SwcAppSpan.js.map +0 -7
- package/dist/esm/elements/is/SwcAppStyle.js +0 -36
- package/dist/esm/elements/is/SwcAppStyle.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTable.js +0 -36
- package/dist/esm/elements/is/SwcAppTable.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableCell.js +0 -36
- package/dist/esm/elements/is/SwcAppTableCell.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableRow.js +0 -36
- package/dist/esm/elements/is/SwcAppTableRow.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTableSection.js +0 -36
- package/dist/esm/elements/is/SwcAppTableSection.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTemplate.js +0 -36
- package/dist/esm/elements/is/SwcAppTemplate.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTextArea.js +0 -36
- package/dist/esm/elements/is/SwcAppTextArea.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTime.js +0 -36
- package/dist/esm/elements/is/SwcAppTime.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTitle.js +0 -36
- package/dist/esm/elements/is/SwcAppTitle.js.map +0 -7
- package/dist/esm/elements/is/SwcAppTrack.js +0 -36
- package/dist/esm/elements/is/SwcAppTrack.js.map +0 -7
- package/dist/esm/elements/is/SwcAppUl.js +0 -36
- package/dist/esm/elements/is/SwcAppUl.js.map +0 -7
- package/dist/esm/elements/is/SwcAppVideo.js +0 -36
- package/dist/esm/elements/is/SwcAppVideo.js.map +0 -7
- package/dist/esm/elements/is/index.js +0 -58
- package/dist/esm/elements/is/index.js.map +0 -7
- package/dist/types/decorators/innerHtml.d.ts +0 -12
- package/dist/types/decorators/innerHtml.d.ts.map +0 -1
- package/dist/types/elements/SwcApp.d.ts +0 -9
- package/dist/types/elements/SwcApp.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppAnchor.d.ts +0 -9
- package/dist/types/elements/is/SwcAppAnchor.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppArea.d.ts +0 -9
- package/dist/types/elements/is/SwcAppArea.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppAudio.d.ts +0 -9
- package/dist/types/elements/is/SwcAppAudio.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppBase.d.ts +0 -9
- package/dist/types/elements/is/SwcAppBase.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppBody.d.ts +0 -9
- package/dist/types/elements/is/SwcAppBody.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppButton.d.ts +0 -9
- package/dist/types/elements/is/SwcAppButton.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppCanvas.d.ts +0 -9
- package/dist/types/elements/is/SwcAppCanvas.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppData.d.ts +0 -9
- package/dist/types/elements/is/SwcAppData.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDataList.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDataList.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDetails.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDetails.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDialog.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDialog.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDiv.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDiv.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppDl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppDl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppEmbed.d.ts +0 -9
- package/dist/types/elements/is/SwcAppEmbed.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppFieldSet.d.ts +0 -9
- package/dist/types/elements/is/SwcAppFieldSet.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppForm.d.ts +0 -9
- package/dist/types/elements/is/SwcAppForm.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppHeading.d.ts +0 -9
- package/dist/types/elements/is/SwcAppHeading.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppHr.d.ts +0 -9
- package/dist/types/elements/is/SwcAppHr.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppIFrame.d.ts +0 -9
- package/dist/types/elements/is/SwcAppIFrame.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppImage.d.ts +0 -9
- package/dist/types/elements/is/SwcAppImage.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppInput.d.ts +0 -9
- package/dist/types/elements/is/SwcAppInput.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLabel.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLabel.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLegend.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLegend.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLi.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLi.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppLink.d.ts +0 -9
- package/dist/types/elements/is/SwcAppLink.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMap.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMap.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMeta.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMeta.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMeter.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMeter.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppMod.d.ts +0 -9
- package/dist/types/elements/is/SwcAppMod.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppObject.d.ts +0 -9
- package/dist/types/elements/is/SwcAppObject.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOptGroup.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOptGroup.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOption.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOption.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppOutput.d.ts +0 -9
- package/dist/types/elements/is/SwcAppOutput.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppParagraph.d.ts +0 -9
- package/dist/types/elements/is/SwcAppParagraph.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppParam.d.ts +0 -9
- package/dist/types/elements/is/SwcAppParam.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppPicture.d.ts +0 -9
- package/dist/types/elements/is/SwcAppPicture.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppPre.d.ts +0 -9
- package/dist/types/elements/is/SwcAppPre.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppProgress.d.ts +0 -9
- package/dist/types/elements/is/SwcAppProgress.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppQuote.d.ts +0 -9
- package/dist/types/elements/is/SwcAppQuote.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppScript.d.ts +0 -9
- package/dist/types/elements/is/SwcAppScript.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSelect.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSelect.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSlot.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSlot.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSource.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSource.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppSpan.d.ts +0 -9
- package/dist/types/elements/is/SwcAppSpan.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppStyle.d.ts +0 -9
- package/dist/types/elements/is/SwcAppStyle.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTable.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTable.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableCell.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableCell.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableRow.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableRow.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTableSection.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTableSection.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTemplate.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTemplate.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTextArea.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTextArea.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTime.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTime.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTitle.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTitle.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppTrack.d.ts +0 -9
- package/dist/types/elements/is/SwcAppTrack.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppUl.d.ts +0 -9
- package/dist/types/elements/is/SwcAppUl.d.ts.map +0 -1
- package/dist/types/elements/is/SwcAppVideo.d.ts +0 -9
- package/dist/types/elements/is/SwcAppVideo.d.ts.map +0 -1
- package/dist/types/elements/is/index.d.ts +0 -58
- package/dist/types/elements/is/index.d.ts.map +0 -1
- package/src/elements/SwcApp.ts +0 -26
- package/src/elements/is/SwcAppAnchor.ts +0 -26
- package/src/elements/is/SwcAppArea.ts +0 -26
- package/src/elements/is/SwcAppAudio.ts +0 -26
- package/src/elements/is/SwcAppBase.ts +0 -26
- package/src/elements/is/SwcAppBody.ts +0 -26
- package/src/elements/is/SwcAppButton.ts +0 -26
- package/src/elements/is/SwcAppCanvas.ts +0 -26
- package/src/elements/is/SwcAppData.ts +0 -26
- package/src/elements/is/SwcAppDataList.ts +0 -26
- package/src/elements/is/SwcAppDetails.ts +0 -26
- package/src/elements/is/SwcAppDialog.ts +0 -26
- package/src/elements/is/SwcAppDiv.ts +0 -26
- package/src/elements/is/SwcAppDl.ts +0 -26
- package/src/elements/is/SwcAppEmbed.ts +0 -26
- package/src/elements/is/SwcAppFieldSet.ts +0 -26
- package/src/elements/is/SwcAppForm.ts +0 -26
- package/src/elements/is/SwcAppHeading.ts +0 -26
- package/src/elements/is/SwcAppHr.ts +0 -26
- package/src/elements/is/SwcAppIFrame.ts +0 -26
- package/src/elements/is/SwcAppImage.ts +0 -26
- package/src/elements/is/SwcAppInput.ts +0 -26
- package/src/elements/is/SwcAppLabel.ts +0 -26
- package/src/elements/is/SwcAppLegend.ts +0 -26
- package/src/elements/is/SwcAppLi.ts +0 -26
- package/src/elements/is/SwcAppLink.ts +0 -26
- package/src/elements/is/SwcAppMap.ts +0 -26
- package/src/elements/is/SwcAppMeta.ts +0 -26
- package/src/elements/is/SwcAppMeter.ts +0 -26
- package/src/elements/is/SwcAppMod.ts +0 -26
- package/src/elements/is/SwcAppObject.ts +0 -26
- package/src/elements/is/SwcAppOl.ts +0 -26
- package/src/elements/is/SwcAppOptGroup.ts +0 -26
- package/src/elements/is/SwcAppOption.ts +0 -26
- package/src/elements/is/SwcAppOutput.ts +0 -26
- package/src/elements/is/SwcAppParagraph.ts +0 -26
- package/src/elements/is/SwcAppParam.ts +0 -26
- package/src/elements/is/SwcAppPicture.ts +0 -26
- package/src/elements/is/SwcAppPre.ts +0 -26
- package/src/elements/is/SwcAppProgress.ts +0 -26
- package/src/elements/is/SwcAppQuote.ts +0 -26
- package/src/elements/is/SwcAppScript.ts +0 -26
- package/src/elements/is/SwcAppSelect.ts +0 -26
- package/src/elements/is/SwcAppSlot.ts +0 -26
- package/src/elements/is/SwcAppSource.ts +0 -26
- package/src/elements/is/SwcAppSpan.ts +0 -26
- package/src/elements/is/SwcAppStyle.ts +0 -26
- package/src/elements/is/SwcAppTable.ts +0 -26
- package/src/elements/is/SwcAppTableCell.ts +0 -26
- package/src/elements/is/SwcAppTableRow.ts +0 -26
- package/src/elements/is/SwcAppTableSection.ts +0 -26
- package/src/elements/is/SwcAppTemplate.ts +0 -26
- package/src/elements/is/SwcAppTextArea.ts +0 -26
- package/src/elements/is/SwcAppTime.ts +0 -26
- package/src/elements/is/SwcAppTitle.ts +0 -26
- package/src/elements/is/SwcAppTrack.ts +0 -26
- package/src/elements/is/SwcAppUl.ts +0 -26
- package/src/elements/is/SwcAppVideo.ts +0 -26
- package/src/elements/is/index.ts +0 -57
|
@@ -1,47 +1,84 @@
|
|
|
1
1
|
import { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';
|
|
2
2
|
import { FunctionUtils } from '@dooboostore/core/function/FunctionUtils';
|
|
3
|
-
import {
|
|
4
|
-
import { getQueryMetadata } from './query';
|
|
5
|
-
import { getQueryAllMetadata } from './queryAll';
|
|
3
|
+
import { getOnConnectedInnerHtmlMetadata } from './onConnectedInnerHtml';
|
|
6
4
|
import { getAddEventListenerMetadata } from './addEventListener';
|
|
7
|
-
import { 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,
|
|
5
|
+
import { 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 } from './lifecycles';
|
|
8
6
|
import { getEmitCustomEventMetadataList } from './emitCustomEvent';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { findAllAttributeChangedMetadata } from './changedAttribute';
|
|
8
|
+
import { findAllSetAttributeMetadata } from './setAttribute';
|
|
9
|
+
import { findAllReplaceChildrenMetadata } from './replaceChildren';
|
|
10
|
+
import { findAllAppendChildMetadata } from './appendChild';
|
|
11
|
+
import { findAllClassListMetadata } from './classList';
|
|
12
|
+
import { findAllStyleMetadata } from './style';
|
|
11
13
|
import { SwcUtils } from '../utils/Utils';
|
|
12
14
|
import { HTML_TAG_ENTRIES, DOM_EVENT_NAMES } from '../config/config';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
|
|
16
|
-
import { Router } from '@dooboostore/core-web/routers/Router';
|
|
17
|
-
import { InjectSituationType, HostSet, SwcAppInterface } from '../types';
|
|
15
|
+
import { SituationTypeContainer, SituationTypeContainers } from '@dooboostore/simple-boot/decorators/inject/Inject';
|
|
16
|
+
import { InjectSituationType, HostSet } from '../types';
|
|
18
17
|
|
|
19
|
-
// --- Core Interfaces & Types ---
|
|
18
|
+
// --- Core Interfaces & Types (Moved back from base.ts) ---
|
|
19
|
+
|
|
20
|
+
export const ELEMENT_CONFIG_KEY = Symbol('simple-web-component:element-config');
|
|
20
21
|
|
|
21
22
|
export interface ElementConfig {
|
|
22
|
-
name: string;
|
|
23
23
|
extends?: string;
|
|
24
24
|
observedAttributes?: string[];
|
|
25
|
-
customElementRegistry?:
|
|
25
|
+
customElementRegistry?: any;
|
|
26
26
|
window?: Window;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
29
|
+
export interface ElementMetadata extends Omit<ElementConfig, 'window'> {
|
|
30
|
+
name: string;
|
|
31
|
+
window: Window;
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
export const getElementConfig = (target: any): ElementMetadata | undefined => {
|
|
35
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
36
|
+
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const ensureInit = (inst: any) => {
|
|
40
|
+
if (!inst.__swc_initialized) {
|
|
41
|
+
inst._swcId = Math.random().toString(36).substring(2, 11);
|
|
42
|
+
inst._emitHandlers = new Map();
|
|
43
|
+
inst._boundListeners = [];
|
|
44
|
+
inst.__swc_initialized = true;
|
|
45
|
+
|
|
46
|
+
// Call constructor script if present
|
|
47
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
48
|
+
inst._executeSwcScript?.('swc-on-constructor', hostSet);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// --- Global Event Handling ---
|
|
32
53
|
const globalDelegatedRoots = new WeakSet<Node>();
|
|
33
54
|
|
|
34
|
-
|
|
55
|
+
const handleGlobalSwcEvent = async (event: Event) => {
|
|
56
|
+
if ((event as any).__swc_handled) return;
|
|
57
|
+
const path = event.composedPath();
|
|
58
|
+
const type = event.type;
|
|
59
|
+
const attrName = `swc-on-${type}`;
|
|
60
|
+
|
|
61
|
+
for (const node of path) {
|
|
62
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
63
|
+
const script = node.getAttribute?.(attrName);
|
|
64
|
+
if (script && !getElementConfig(node)) {
|
|
65
|
+
const host: any = SwcUtils.findNearestSwcHost(node);
|
|
66
|
+
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {
|
|
67
|
+
await host.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
68
|
+
(event as any).__swc_handled = true;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
35
74
|
|
|
36
75
|
function buildEnv(configWindow?: Window) {
|
|
37
|
-
const win:
|
|
76
|
+
const win: Window = configWindow || ((typeof window !== 'undefined' ? window : undefined) as any);
|
|
38
77
|
const doc: Document = win?.document;
|
|
39
|
-
|
|
40
78
|
const builtInTagMap = new Map<any, string>();
|
|
41
79
|
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
42
80
|
if (win?.[cls]) builtInTagMap.set(win[cls], tag);
|
|
43
81
|
}
|
|
44
|
-
|
|
45
82
|
const domHelpers = SwcUtils.getHelperSet(win);
|
|
46
83
|
return { win, doc, builtInTagMap, domHelpers };
|
|
47
84
|
}
|
|
@@ -51,398 +88,357 @@ const getHandlers = (inst: any) => {
|
|
|
51
88
|
return inst.__swc_attributeEventHandlers;
|
|
52
89
|
};
|
|
53
90
|
|
|
91
|
+
const setupPrototype = (proto: any) => {
|
|
92
|
+
if (proto.__swc_proto_setup) return;
|
|
93
|
+
proto.__swc_proto_setup = true;
|
|
94
|
+
|
|
95
|
+
proto._executeSwcScript = function (attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {
|
|
96
|
+
ensureInit(this);
|
|
97
|
+
const script = this.getAttribute(attrName);
|
|
98
|
+
if (script) {
|
|
99
|
+
try {
|
|
100
|
+
const conf = getElementConfig(this);
|
|
101
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
102
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
103
|
+
const args = { ...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode() };
|
|
104
|
+
FunctionUtils.execute({ script, context: this, args });
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
proto._resolveWindow = function (localConfig?: ElementConfig): Window {
|
|
112
|
+
ensureInit(this);
|
|
113
|
+
if (localConfig?.window) return localConfig.window;
|
|
114
|
+
const ancestors = SwcUtils.findAllSwcHosts(this as any);
|
|
115
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
116
|
+
const aConf = getElementConfig(ancestors[i]);
|
|
117
|
+
if (aConf?.window) return aConf.window;
|
|
118
|
+
}
|
|
119
|
+
return (typeof window !== 'undefined' ? window : undefined) as Window;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
proto._invokeLifecycleMethod = function (methodName: string | symbol, hostSet: HostSet, extraArgs: any[] = []) {
|
|
123
|
+
ensureInit(this);
|
|
124
|
+
if (typeof (this as any)[methodName] !== 'function') return;
|
|
125
|
+
const app = hostSet.$appHost?.simpleApplication;
|
|
126
|
+
|
|
127
|
+
if (app) {
|
|
128
|
+
const otherStorage = new Map<any, any>();
|
|
129
|
+
const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: InjectSituationType.HOST_SET, data: hostSet }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOST, data: hostSet.$appHost }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOSTS, data: hostSet.$appHosts }), new SituationTypeContainer({ situationType: InjectSituationType.HOST, data: hostSet.$host }), new SituationTypeContainer({ situationType: InjectSituationType.HOSTS, data: hostSet.$hosts }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_HOST, data: hostSet.$firstHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_HOST, data: hostSet.$lastHost }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_APP_HOST, data: hostSet.$firstAppHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_APP_HOST, data: hostSet.$lastAppHost })]);
|
|
130
|
+
otherStorage.set(SituationTypeContainers, situations);
|
|
131
|
+
|
|
132
|
+
return app.simstanceManager.executeBindParameterSimPromise(
|
|
133
|
+
{
|
|
134
|
+
target: this,
|
|
135
|
+
targetKey: methodName,
|
|
136
|
+
inputParameters: extraArgs
|
|
137
|
+
},
|
|
138
|
+
otherStorage
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
return (this as any)[methodName](...extraArgs);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
proto._bindAttributeEvent = function (el: HTMLElement, attrName: string, script: string, eventName?: string) {
|
|
146
|
+
ensureInit(this);
|
|
147
|
+
if (!eventName) {
|
|
148
|
+
if (!attrName.startsWith('swc-on-')) return;
|
|
149
|
+
eventName = attrName.substring(7);
|
|
150
|
+
}
|
|
151
|
+
const elHandlers = getHandlers(this);
|
|
152
|
+
let handlers = elHandlers.get(el);
|
|
153
|
+
if (!handlers) {
|
|
154
|
+
handlers = new Map();
|
|
155
|
+
elHandlers.set(el, handlers);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const oldHandler = handlers.get(attrName);
|
|
159
|
+
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
160
|
+
|
|
161
|
+
const handler = async (event: any) => {
|
|
162
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
163
|
+
const conf = getElementConfig(this);
|
|
164
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
165
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
166
|
+
const args = {
|
|
167
|
+
event,
|
|
168
|
+
$data: (event as CustomEvent).detail,
|
|
169
|
+
...hostSet,
|
|
170
|
+
...helpers,
|
|
171
|
+
$el: el,
|
|
172
|
+
$root: this.getRootNode()
|
|
173
|
+
};
|
|
174
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
el.addEventListener(eventName, handler);
|
|
178
|
+
handlers.set(attrName, handler);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
proto.__swc_executeAttributeEvent = async function (el: HTMLElement, attrName: string, script: string, event: Event) {
|
|
182
|
+
ensureInit(this);
|
|
183
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
184
|
+
const conf = getElementConfig(this);
|
|
185
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
186
|
+
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
187
|
+
const args = {
|
|
188
|
+
event,
|
|
189
|
+
$data: (event as CustomEvent).detail,
|
|
190
|
+
...hostSet,
|
|
191
|
+
...currentHelpers,
|
|
192
|
+
$el: el,
|
|
193
|
+
$root: this.getRootNode()
|
|
194
|
+
};
|
|
195
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
|
|
54
199
|
export const elementDefine =
|
|
55
|
-
(
|
|
200
|
+
(name: string, config: Partial<ElementConfig> = {}): ClassDecorator =>
|
|
56
201
|
(constructor: any) => {
|
|
57
|
-
const config: ElementConfig = typeof inConfig === 'string' ? { name: inConfig } : inConfig;
|
|
58
202
|
const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);
|
|
59
|
-
config
|
|
203
|
+
const metadata: ElementMetadata = { ...config, name, window: win };
|
|
60
204
|
|
|
61
|
-
|
|
205
|
+
if (!metadata.window) {
|
|
206
|
+
throw new Error('window is required');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let extendsTagName = metadata.extends;
|
|
62
210
|
if (!extendsTagName) {
|
|
63
211
|
let proto = constructor;
|
|
64
|
-
|
|
212
|
+
const BaseHTMLElement = (win as any).HTMLElement;
|
|
213
|
+
while (proto && proto !== BaseHTMLElement && proto !== Function.prototype) {
|
|
65
214
|
extendsTagName = BUILT_IN_TAG_MAP.get(proto);
|
|
66
215
|
if (extendsTagName) break;
|
|
67
216
|
proto = Object.getPrototypeOf(proto);
|
|
68
217
|
}
|
|
69
|
-
|
|
218
|
+
metadata.extends = extendsTagName;
|
|
70
219
|
}
|
|
71
220
|
|
|
72
221
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
73
222
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
74
223
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
75
|
-
const setAttrMap = findAllSetAttributeMetadata(constructor);
|
|
76
224
|
|
|
77
225
|
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'];
|
|
78
226
|
const swcOnEvents = DOM_EVENT_NAMES.map(e => `swc-on-${e}`);
|
|
79
227
|
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const NewClass = class extends (constructor as any) {
|
|
84
|
-
private _swcId = Math.random().toString(36).substring(2, 11);
|
|
85
|
-
private _emitHandlers = new Map<string, EventListener>();
|
|
86
|
-
private _boundListeners: Array<{ target: EventTarget; type: string; handler: EventListener; options?: any }> = [];
|
|
87
|
-
|
|
88
|
-
private _executeSwcScript(attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {
|
|
89
|
-
const script = this.getAttribute(attrName);
|
|
90
|
-
if (script) {
|
|
91
|
-
try {
|
|
92
|
-
const args = { ...hostSet, ...SWC_DOM_HELPERS, ...extraArgs };
|
|
93
|
-
FunctionUtils.execute({ script, context: this, args });
|
|
94
|
-
} catch (e) {
|
|
95
|
-
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private async _invokeLifecycleMethod(methodName: string | symbol, hostSet: HostSet, extraArgs: any[] = []) {
|
|
101
|
-
if (typeof (this as any)[methodName] !== 'function') return;
|
|
102
|
-
const app = hostSet.$appHost?.simpleApplication;
|
|
103
|
-
|
|
104
|
-
if (app) {
|
|
105
|
-
const otherStorage = new Map<any, any>();
|
|
106
|
-
const situations = new SituationTypeContainers([new SituationTypeContainer({ situationType: InjectSituationType.HOST_SET, data: hostSet }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOST, data: hostSet.$appHost }), new SituationTypeContainer({ situationType: InjectSituationType.APP_HOSTS, data: hostSet.$appHosts }), new SituationTypeContainer({ situationType: InjectSituationType.HOST, data: hostSet.$host }), new SituationTypeContainer({ situationType: InjectSituationType.HOSTS, data: hostSet.$hosts }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_HOST, data: hostSet.$firstHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_HOST, data: hostSet.$lastHost }), new SituationTypeContainer({ situationType: InjectSituationType.FIRST_APP_HOST, data: hostSet.$firstAppHost }), new SituationTypeContainer({ situationType: InjectSituationType.LAST_APP_HOST, data: hostSet.$lastAppHost })]);
|
|
107
|
-
otherStorage.set(SituationTypeContainers, situations);
|
|
108
|
-
|
|
109
|
-
return app.simstanceManager.executeBindParameterSimPromise(
|
|
110
|
-
{
|
|
111
|
-
target: this,
|
|
112
|
-
targetKey: methodName,
|
|
113
|
-
inputParameters: extraArgs
|
|
114
|
-
},
|
|
115
|
-
otherStorage
|
|
116
|
-
);
|
|
117
|
-
} else {
|
|
118
|
-
return (this as any)[methodName](...extraArgs);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private _bindAttributeEvent(el: HTMLElement, attrName: string, script: string, eventName?: string) {
|
|
123
|
-
if (!eventName) {
|
|
124
|
-
if (!attrName.startsWith('swc-on-')) return;
|
|
125
|
-
eventName = attrName.substring(7);
|
|
126
|
-
}
|
|
127
|
-
if (swcLifecycleAttributes.includes(attrName)) return;
|
|
228
|
+
// Collect all observed attributes from all decorators
|
|
229
|
+
const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map(it => it.name), ...emitCustomEventList.map(it => it.options.attributeName!), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
128
230
|
|
|
129
|
-
|
|
130
|
-
let handlers = elHandlers.get(el);
|
|
131
|
-
if (!handlers) {
|
|
132
|
-
handlers = new Map();
|
|
133
|
-
elHandlers.set(el, handlers);
|
|
134
|
-
}
|
|
231
|
+
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
135
232
|
|
|
136
|
-
|
|
137
|
-
|
|
233
|
+
const proto = constructor.prototype;
|
|
234
|
+
setupPrototype(proto);
|
|
138
235
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
event,
|
|
143
|
-
$data: (event as CustomEvent).detail,
|
|
144
|
-
...hostSet,
|
|
145
|
-
...SWC_DOM_HELPERS
|
|
146
|
-
};
|
|
147
|
-
FunctionUtils.execute({ script, context: el, args });
|
|
148
|
-
};
|
|
236
|
+
const originalConnected = proto.connectedCallback;
|
|
237
|
+
proto.connectedCallback = function () {
|
|
238
|
+
ensureInit(this);
|
|
149
239
|
|
|
150
|
-
|
|
151
|
-
|
|
240
|
+
if (connectedInnerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {
|
|
241
|
+
this.attachShadow({ mode: 'open' });
|
|
152
242
|
}
|
|
153
243
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this._executeSwcScript('swc-on-constructor', hostSet);
|
|
158
|
-
|
|
159
|
-
if (innerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {
|
|
160
|
-
this.attachShadow({ mode: 'open' });
|
|
161
|
-
}
|
|
162
|
-
}
|
|
244
|
+
const conf = getElementConfig(this);
|
|
245
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
246
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
163
247
|
|
|
164
|
-
|
|
165
|
-
|
|
248
|
+
(this as any)._executeSwcScript('swc-on-before-connected', hostSet);
|
|
249
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
250
|
+
if (bMethods) {
|
|
251
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
166
252
|
}
|
|
167
253
|
|
|
168
|
-
|
|
169
|
-
const conf = getElementConfig(this);
|
|
170
|
-
const currentWin = conf?.window || window;
|
|
171
|
-
const currentDoc = currentWin.document;
|
|
172
|
-
|
|
173
|
-
const hostSet = SwcUtils.getHostSet(this as any);
|
|
254
|
+
if (typeof (this as any).initCore === 'function') (this as any).initCore();
|
|
174
255
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (innerHtmlList.length > 0) {
|
|
184
|
-
let sContent = '',
|
|
185
|
-
lContent = '';
|
|
186
|
-
for (const meta of innerHtmlList) {
|
|
187
|
-
const res = await (this as any)[meta.propertyKey]();
|
|
188
|
-
if (res !== undefined) {
|
|
189
|
-
if (meta.options.useShadow) sContent += res;
|
|
190
|
-
else lContent += res;
|
|
191
|
-
}
|
|
256
|
+
if (connectedInnerHtmlList.length > 0) {
|
|
257
|
+
let sContent = '',
|
|
258
|
+
lContent = '';
|
|
259
|
+
for (const meta of connectedInnerHtmlList) {
|
|
260
|
+
const res = (this as any)[meta.propertyKey]();
|
|
261
|
+
if (res !== undefined) {
|
|
262
|
+
if (meta.options.useShadow) sContent += res;
|
|
263
|
+
else lContent += res;
|
|
192
264
|
}
|
|
193
|
-
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
194
|
-
if (lContent) this.innerHTML = lContent;
|
|
195
265
|
}
|
|
266
|
+
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
267
|
+
if (lContent) this.innerHTML = lContent;
|
|
268
|
+
}
|
|
196
269
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if ((event as any).__swc_handled) return;
|
|
200
|
-
|
|
201
|
-
const path = event.composedPath();
|
|
202
|
-
const type = event.type;
|
|
203
|
-
const attrName = `swc-on-${type}`;
|
|
204
|
-
|
|
205
|
-
for (const node of path) {
|
|
206
|
-
if (node === delegateHost) break;
|
|
207
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
208
|
-
|
|
209
|
-
const script = node.getAttribute?.(attrName);
|
|
210
|
-
if (script && !getElementConfig(node)) {
|
|
211
|
-
const host = SwcUtils.findNearestSwcHost(node);
|
|
212
|
-
if (host) {
|
|
213
|
-
const childHostSet = SwcUtils.getHostSet(node);
|
|
214
|
-
const args = {
|
|
215
|
-
event,
|
|
216
|
-
$data: (event as CustomEvent).detail,
|
|
217
|
-
...childHostSet,
|
|
218
|
-
...SWC_DOM_HELPERS
|
|
219
|
-
};
|
|
220
|
-
FunctionUtils.execute({ script, context: node, args });
|
|
221
|
-
(event as any).__swc_handled = true;
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// 1. Local Delegation (To itself)
|
|
270
|
+
const root = this.getRootNode();
|
|
271
|
+
if (!globalDelegatedRoots.has(root)) {
|
|
229
272
|
DOM_EVENT_NAMES.forEach(type => {
|
|
230
|
-
|
|
231
|
-
this._boundListeners.push({ target: this as any, type, handler: createDelegationHandler(this) });
|
|
273
|
+
root.addEventListener(type, handleGlobalSwcEvent);
|
|
232
274
|
});
|
|
275
|
+
globalDelegatedRoots.add(root);
|
|
276
|
+
}
|
|
233
277
|
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
globalDelegatedRoots.add(root);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
// --- @addEventListener binding (Direct/Delegate/Global) ---
|
|
248
|
-
addEventListenerList.forEach(meta => {
|
|
249
|
-
const { selector, type, options } = meta;
|
|
250
|
-
const { root, capture, once, passive, stopPropagation, stopImmediatePropagation, preventDefault, delegate, removeOnDisconnected } = options;
|
|
251
|
-
const opts = { capture, once, passive };
|
|
252
|
-
|
|
253
|
-
const bindTargets: EventTarget[] = [];
|
|
254
|
-
|
|
255
|
-
if (selector === ':window') {
|
|
256
|
-
bindTargets.push(currentWin);
|
|
257
|
-
} else if (selector === ':document') {
|
|
258
|
-
bindTargets.push(currentDoc);
|
|
259
|
-
} else if (selector === ':parentHost') {
|
|
260
|
-
if (hostSet.$parentHost) bindTargets.push(hostSet.$parentHost);
|
|
261
|
-
} else if (selector === ':appHost') {
|
|
262
|
-
if (hostSet.$appHost) bindTargets.push(hostSet.$appHost);
|
|
263
|
-
} else if (selector === ':firstHost') {
|
|
264
|
-
if (hostSet.$firstHost) bindTargets.push(hostSet.$firstHost);
|
|
265
|
-
} else if (selector === ':lastHost') {
|
|
266
|
-
if (hostSet.$lastHost) bindTargets.push(hostSet.$lastHost);
|
|
267
|
-
} else if (selector === ':firstAppHost') {
|
|
268
|
-
if (hostSet.$firstAppHost) bindTargets.push(hostSet.$firstAppHost);
|
|
269
|
-
} else if (selector === ':lastAppHost') {
|
|
270
|
-
if (hostSet.$lastAppHost) bindTargets.push(hostSet.$lastAppHost);
|
|
271
|
-
} else if (!selector || selector === ':host') {
|
|
272
|
-
bindTargets.push(this as any);
|
|
273
|
-
} else if (delegate) {
|
|
274
|
-
const bindRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
275
|
-
const r = root || 'auto';
|
|
276
|
-
if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));
|
|
277
|
-
else if (r === 'light') bindRoots.push(this as any);
|
|
278
|
-
else if (r === 'shadow') {
|
|
279
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);
|
|
280
|
-
} else if (r === 'all') {
|
|
281
|
-
bindRoots.push(this as any);
|
|
282
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
bindRoots.forEach(br => {
|
|
286
|
-
const handler = (event: Event) => {
|
|
287
|
-
const matchedEl = (event.target as HTMLElement).closest(selector);
|
|
288
|
-
if (matchedEl && (br as any).contains(matchedEl)) {
|
|
289
|
-
if (stopPropagation) event.stopPropagation();
|
|
290
|
-
if (stopImmediatePropagation) event.stopImmediatePropagation();
|
|
291
|
-
if (preventDefault) event.preventDefault();
|
|
292
|
-
const currentHostSet = SwcUtils.getHostSet(this as any);
|
|
293
|
-
this._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, matchedEl]);
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
br.addEventListener(type, handler, opts);
|
|
297
|
-
const self: any = this;
|
|
298
|
-
if (removeOnDisconnected === true || (br !== self && br !== self.shadowRoot)) {
|
|
299
|
-
this._boundListeners.push({ target: br, type, handler, options: opts });
|
|
300
|
-
}
|
|
301
|
-
});
|
|
278
|
+
addEventListenerList.forEach(meta => {
|
|
279
|
+
const { selector, type, options } = meta;
|
|
280
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
281
|
+
const bindTargets: EventTarget[] = [];
|
|
282
|
+
const r = options.root || 'auto';
|
|
283
|
+
const applyRootOption = (target: any) => {
|
|
284
|
+
if (!target) return;
|
|
285
|
+
if (r === 'auto') {
|
|
286
|
+
bindTargets.push(target.shadowRoot || target);
|
|
302
287
|
} else {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
else if (r === 'shadow') {
|
|
308
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);
|
|
309
|
-
} else if (r === 'all') {
|
|
310
|
-
searchRoots.push(this as any);
|
|
311
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);
|
|
312
|
-
}
|
|
288
|
+
if (r === 'light' || r === 'all') bindTargets.push(target);
|
|
289
|
+
if ((r === 'shadow' || r === 'all') && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
313
292
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
293
|
+
if (selector === ':window') bindTargets.push(currentWin);
|
|
294
|
+
else if (selector === ':document') bindTargets.push(currentWin.document);
|
|
295
|
+
else if (selector === ':parentHost') applyRootOption(hostSet.$parentHost);
|
|
296
|
+
else if (selector === ':appHost') applyRootOption(hostSet.$appHost);
|
|
297
|
+
else if (selector === ':firstHost') applyRootOption(hostSet.$firstHost);
|
|
298
|
+
else if (selector === ':lastHost') applyRootOption(hostSet.$lastHost);
|
|
299
|
+
else if (selector === ':firstAppHost') applyRootOption(hostSet.$firstAppHost);
|
|
300
|
+
else if (selector === ':lastAppHost') applyRootOption(hostSet.$lastAppHost);
|
|
301
|
+
else if (selector === ':hosts') hostSet.$hosts.forEach(applyRootOption);
|
|
302
|
+
else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRootOption);
|
|
303
|
+
else if (selector === ':host' || !selector) applyRootOption(this);
|
|
304
|
+
else if (options.delegate) {
|
|
305
|
+
const bindRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
306
|
+
if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));
|
|
307
|
+
else if (r === 'light') bindRoots.push(this as any);
|
|
308
|
+
else if (r === 'shadow' && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
309
|
+
else if (r === 'all') {
|
|
310
|
+
bindRoots.push(this as any);
|
|
311
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
317
312
|
}
|
|
318
313
|
|
|
319
|
-
|
|
320
|
-
const handler = (event: Event) => {
|
|
321
|
-
|
|
322
|
-
if (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
314
|
+
bindRoots.forEach(br => {
|
|
315
|
+
const handler = async (event: Event) => {
|
|
316
|
+
const matchedEl = (event.target as HTMLElement).closest(selector);
|
|
317
|
+
if (matchedEl && (br as any).contains(matchedEl)) {
|
|
318
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
319
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
320
|
+
if (options.preventDefault) event.preventDefault();
|
|
321
|
+
const currentHostSet = SwcUtils.getHostSet(this as any);
|
|
322
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
323
|
+
await (this as any)._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, matchedEl, args]);
|
|
324
|
+
}
|
|
326
325
|
};
|
|
327
|
-
|
|
328
|
-
if (removeOnDisconnected === true ||
|
|
329
|
-
this._boundListeners.push({ target, type, handler, options: opts });
|
|
326
|
+
br.addEventListener(type, handler, opts);
|
|
327
|
+
if (options.removeOnDisconnected === true || (br !== this && br !== this.shadowRoot)) {
|
|
328
|
+
(this as any)._boundListeners.push({ target: br, type, handler, options: opts });
|
|
330
329
|
}
|
|
331
330
|
});
|
|
332
|
-
}
|
|
331
|
+
} else {
|
|
332
|
+
const searchRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
333
|
+
if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));
|
|
334
|
+
else if (r === 'light') searchRoots.push(this as any);
|
|
335
|
+
else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
336
|
+
else if (r === 'all') {
|
|
337
|
+
searchRoots.push(this as any);
|
|
338
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
339
|
+
}
|
|
333
340
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
for (const m of aMethods) await this._invokeLifecycleMethod(m, hostSet);
|
|
341
|
+
searchRoots.forEach(sr => {
|
|
342
|
+
sr.querySelectorAll(selector).forEach(el => bindTargets.push(el));
|
|
343
|
+
});
|
|
338
344
|
}
|
|
339
345
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
346
|
+
bindTargets.forEach(t => {
|
|
347
|
+
const handler = async (event: Event) => {
|
|
348
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
349
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
350
|
+
if (options.preventDefault) event.preventDefault();
|
|
351
|
+
const currentHostSet = SwcUtils.getHostSet(this as any);
|
|
352
|
+
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
353
|
+
await (this as any)._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, args]);
|
|
354
|
+
};
|
|
355
|
+
t.addEventListener(type, handler, opts);
|
|
356
|
+
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
357
|
+
(this as any)._boundListeners.push({ target: t, type, handler, options: opts });
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
});
|
|
352
361
|
|
|
353
|
-
|
|
362
|
+
if (originalConnected) originalConnected.apply(this);
|
|
363
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
364
|
+
if (aMethods) {
|
|
365
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
366
|
+
}
|
|
367
|
+
(this as any)._executeSwcScript('swc-on-connected', hostSet);
|
|
368
|
+
(this as any)._executeSwcScript('swc-on-after-connected', hostSet);
|
|
369
|
+
};
|
|
354
370
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
371
|
+
const originalDisconnected = proto.disconnectedCallback;
|
|
372
|
+
proto.disconnectedCallback = function () {
|
|
373
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
374
|
+
(this as any)._executeSwcScript('swc-on-before-disconnected', hostSet);
|
|
375
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
376
|
+
if (bMethods) {
|
|
377
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
359
378
|
}
|
|
360
379
|
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this.
|
|
364
|
-
|
|
365
|
-
if (bMethods) bMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));
|
|
380
|
+
if ((this as any)._boundListeners) {
|
|
381
|
+
(this as any)._boundListeners.forEach((l: any) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
382
|
+
(this as any)._boundListeners = [];
|
|
383
|
+
}
|
|
366
384
|
|
|
367
|
-
|
|
385
|
+
if (originalDisconnected) originalDisconnected.apply(this);
|
|
368
386
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
this.
|
|
372
|
-
this._executeSwcScript('swc-on-after-adopted', hostSet);
|
|
387
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
388
|
+
if (aMethods) {
|
|
389
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
373
390
|
}
|
|
391
|
+
(this as any)._executeSwcScript('swc-on-disconnected', hostSet);
|
|
392
|
+
(this as any)._executeSwcScript('swc-on-after-disconnected', hostSet);
|
|
393
|
+
};
|
|
374
394
|
|
|
375
|
-
|
|
376
|
-
|
|
395
|
+
const originalAdopted = proto.adoptedCallback;
|
|
396
|
+
proto.adoptedCallback = function () {
|
|
397
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
398
|
+
(this as any)._executeSwcScript('swc-on-before-adopted', hostSet);
|
|
399
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
400
|
+
if (bMethods) {
|
|
401
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
402
|
+
}
|
|
377
403
|
|
|
378
|
-
|
|
379
|
-
if (newVal !== null) {
|
|
380
|
-
const customEventMeta = emitCustomEventList.find(it => it.options.attributeName === name);
|
|
381
|
-
const eventName = customEventMeta ? customEventMeta.options.type : name.substring(7);
|
|
382
|
-
this._bindAttributeEvent(this as any, name, newVal, eventName);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
404
|
+
if (originalAdopted) originalAdopted.apply(this);
|
|
385
405
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
mKeys.forEach(key => this._invokeLifecycleMethod(key, hSet, [newVal, old, name]));
|
|
390
|
-
}
|
|
406
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
|
|
407
|
+
if (aMethods) {
|
|
408
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
391
409
|
}
|
|
410
|
+
(this as any)._executeSwcScript('swc-on-adopted', hostSet);
|
|
411
|
+
(this as any)._executeSwcScript('swc-on-after-adopted', hostSet);
|
|
392
412
|
};
|
|
393
413
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
return res;
|
|
405
|
-
};
|
|
414
|
+
const originalAttributeChanged = proto.attributeChangedCallback;
|
|
415
|
+
proto.attributeChangedCallback = function (name: string, old: string | null, newVal: string | null) {
|
|
416
|
+
if (originalAttributeChanged) originalAttributeChanged.apply(this, [name, old, newVal]);
|
|
417
|
+
|
|
418
|
+
if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {
|
|
419
|
+
if (newVal !== null) {
|
|
420
|
+
const customEventMeta = emitCustomEventList.find(it => it.options.attributeName === name);
|
|
421
|
+
const eventName = customEventMeta ? customEventMeta.type : name.substring(7);
|
|
422
|
+
(this as any)._bindAttributeEvent(this as any, name, newVal, eventName);
|
|
423
|
+
}
|
|
406
424
|
}
|
|
407
|
-
});
|
|
408
425
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
if (typeof original === 'function') {
|
|
414
|
-
NewClass.prototype[propertyKey as any] = function (...args: any[]) {
|
|
415
|
-
const detail = original.apply(this, args);
|
|
416
|
-
const event = new CustomEvent(options.type, {
|
|
417
|
-
detail,
|
|
418
|
-
bubbles: options.bubbles,
|
|
419
|
-
composed: options.composed,
|
|
420
|
-
cancelable: options.cancelable
|
|
421
|
-
});
|
|
422
|
-
this.dispatchEvent(event);
|
|
423
|
-
return detail;
|
|
424
|
-
};
|
|
426
|
+
const mKeys = attrChangeMap.get(name);
|
|
427
|
+
if (mKeys && Array.isArray(mKeys)) {
|
|
428
|
+
const hSet = SwcUtils.getHostSet(this as any);
|
|
429
|
+
for (const key of mKeys) (this as any)._invokeLifecycleMethod(key, hSet, [newVal, old, name]);
|
|
425
430
|
}
|
|
426
|
-
}
|
|
431
|
+
};
|
|
427
432
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
if (name === 'constructor') return;
|
|
432
|
-
const keys = Reflect.getMetadataKeys(originalProto, name);
|
|
433
|
-
keys.forEach(key => Reflect.defineMetadata(key, Reflect.getMetadata(key, originalProto, name), newProto, name));
|
|
433
|
+
Object.defineProperty(constructor, 'observedAttributes', {
|
|
434
|
+
get: () => mergedObservedAttributes,
|
|
435
|
+
configurable: true
|
|
434
436
|
});
|
|
435
437
|
|
|
436
|
-
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
registry.define(config.name, NewClass as any, config.extends ? { extends: config.extends } : undefined);
|
|
438
|
+
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
|
|
439
|
+
const registry = metadata.customElementRegistry || (win as any)?.customElements;
|
|
440
|
+
if (registry && !registry.get(metadata.name)) {
|
|
441
|
+
registry.define(metadata.name, constructor as any, metadata.extends ? { extends: metadata.extends } : undefined);
|
|
441
442
|
}
|
|
442
|
-
return
|
|
443
|
+
return constructor;
|
|
443
444
|
};
|
|
444
|
-
|
|
445
|
-
export const getElementConfig = (target: any): ElementConfig | undefined => {
|
|
446
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
447
|
-
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
448
|
-
};
|