@dooboostore/simple-web-component 1.0.18 → 1.0.21
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 +2065 -164
- package/dist/cjs/config/config.js +2 -0
- package/dist/cjs/config/config.js.map +2 -2
- package/dist/cjs/decorators/addEventListener.js +8 -8
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/appendChild.js +53 -9
- package/dist/cjs/decorators/appendChild.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +141 -0
- package/dist/cjs/decorators/attribute.js.map +7 -0
- package/dist/cjs/decorators/changedAttribute.js +5 -5
- package/dist/cjs/decorators/changedAttribute.js.map +2 -2
- package/dist/cjs/decorators/classList.js +104 -0
- package/dist/cjs/decorators/classList.js.map +7 -0
- package/dist/cjs/decorators/elementDefine.js +334 -425
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/emitCustomEvent.js +65 -13
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/index.js +4 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +4 -4
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/onConnectedInnerHtml.js +4 -4
- package/dist/cjs/decorators/onConnectedInnerHtml.js.map +2 -2
- package/dist/cjs/decorators/query.js +60 -36
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js +47 -23
- package/dist/cjs/decorators/queryAll.js.map +2 -2
- package/dist/cjs/decorators/replaceChildren.js +32 -6
- package/dist/cjs/decorators/replaceChildren.js.map +2 -2
- package/dist/cjs/decorators/setAttribute.js +64 -10
- 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 +30 -15
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +79 -0
- package/dist/cjs/elements/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/SwcAsync.js +58 -123
- package/dist/cjs/elements/SwcAsync.js.map +3 -3
- package/dist/cjs/elements/SwcChoose.js +52 -76
- package/dist/cjs/elements/SwcChoose.js.map +3 -3
- package/dist/cjs/elements/SwcIf.js +66 -94
- package/dist/cjs/elements/SwcIf.js.map +3 -3
- package/dist/cjs/elements/SwcLoop.js +73 -174
- 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 +14 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +7 -7
- package/dist/cjs/router/ElementRouter.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 +5 -5
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/appendChild.js +52 -8
- package/dist/esm/decorators/appendChild.js.map +2 -2
- package/dist/esm/decorators/attribute.js +122 -0
- package/dist/esm/decorators/attribute.js.map +7 -0
- package/dist/esm/decorators/changedAttribute.js +1 -1
- package/dist/esm/decorators/changedAttribute.js.map +1 -1
- package/dist/esm/decorators/classList.js +85 -0
- package/dist/esm/decorators/classList.js.map +7 -0
- package/dist/esm/decorators/elementDefine.js +334 -425
- package/dist/esm/decorators/elementDefine.js.map +3 -3
- package/dist/esm/decorators/emitCustomEvent.js +62 -10
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/index.js +4 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +1 -1
- package/dist/esm/decorators/lifecycles.js.map +1 -1
- package/dist/esm/decorators/onConnectedInnerHtml.js +1 -1
- package/dist/esm/decorators/onConnectedInnerHtml.js.map +1 -1
- package/dist/esm/decorators/query.js +58 -34
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js +45 -21
- package/dist/esm/decorators/queryAll.js.map +2 -2
- package/dist/esm/decorators/replaceChildren.js +28 -2
- package/dist/esm/decorators/replaceChildren.js.map +2 -2
- package/dist/esm/decorators/setAttribute.js +62 -8
- 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 +27 -12
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +60 -0
- package/dist/esm/elements/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/SwcAsync.js +58 -123
- package/dist/esm/elements/SwcAsync.js.map +3 -3
- package/dist/esm/elements/SwcChoose.js +52 -76
- package/dist/esm/elements/SwcChoose.js.map +3 -3
- package/dist/esm/elements/SwcIf.js +66 -94
- package/dist/esm/elements/SwcIf.js.map +3 -3
- package/dist/esm/elements/SwcLoop.js +72 -173
- 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 +14 -3
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +2 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- 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 +4910 -7463
- 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 +1 -1
- package/dist/types/decorators/appendChild.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +23 -0
- package/dist/types/decorators/attribute.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 +4 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/types/decorators/setAttribute.d.ts +16 -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 +6 -5
- 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 +8 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/router/ElementRouter.d.ts +1 -1
- package/dist/types/router/ElementRouter.d.ts.map +1 -1
- package/dist/types/types.d.ts +8 -2
- 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 +4910 -7463
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +11 -6
- package/src/config/config.ts +2 -0
- package/src/decorators/addEventListener.ts +13 -12
- package/src/decorators/appendChild.ts +53 -9
- package/src/decorators/attribute.ts +158 -0
- package/src/decorators/changedAttribute.ts +1 -1
- package/src/decorators/classList.ts +117 -0
- package/src/decorators/elementDefine.ts +371 -425
- package/src/decorators/emitCustomEvent.ts +77 -13
- package/src/decorators/index.ts +4 -0
- package/src/decorators/lifecycles.ts +1 -1
- package/src/decorators/onConnectedInnerHtml.ts +1 -1
- package/src/decorators/query.ts +58 -38
- package/src/decorators/queryAll.ts +45 -29
- package/src/decorators/replaceChildren.ts +31 -2
- package/src/decorators/setAttribute.ts +86 -12
- package/src/decorators/style.ts +89 -0
- package/src/elements/SwcAppEngine.ts +34 -18
- package/src/elements/SwcAppMixin.ts +65 -0
- package/src/elements/SwcAsync.ts +58 -128
- package/src/elements/SwcChoose.ts +51 -77
- package/src/elements/SwcIf.ts +64 -86
- package/src/elements/SwcLoop.ts +71 -168
- 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 +17 -5
- package/src/router/ElementRouter.ts +2 -2
- package/src/types.ts +15 -6
- package/src/utils/TemplateUtils.ts +83 -0
- package/src/utils/Utils.ts +6 -3
- 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/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/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,49 +1,85 @@
|
|
|
1
|
-
import { ReflectUtils } from '@dooboostore/core
|
|
2
|
-
import { FunctionUtils } from '@dooboostore/core
|
|
1
|
+
import { ReflectUtils } from '@dooboostore/core';
|
|
2
|
+
import { FunctionUtils } from '@dooboostore/core';
|
|
3
3
|
import { getOnConnectedInnerHtmlMetadata } from './onConnectedInnerHtml';
|
|
4
|
-
import { getQueryMetadata } from './query';
|
|
5
|
-
import { getQueryAllMetadata } from './queryAll';
|
|
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';
|
|
11
9
|
import { findAllReplaceChildrenMetadata } from './replaceChildren';
|
|
12
10
|
import { findAllAppendChildMetadata } from './appendChild';
|
|
11
|
+
import { findAllClassListMetadata } from './classList';
|
|
12
|
+
import { findAllStyleMetadata } from './style';
|
|
13
|
+
import { findAllAttributeMetadata } from './attribute';
|
|
13
14
|
import { SwcUtils } from '../utils/Utils';
|
|
14
15
|
import { HTML_TAG_ENTRIES, DOM_EVENT_NAMES } from '../config/config';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { SimpleApplication } from '@dooboostore/simple-boot/SimpleApplication';
|
|
18
|
-
import { Router } from '@dooboostore/core-web/routers/Router';
|
|
19
|
-
import { InjectSituationType, HostSet, SwcAppInterface } from '../types';
|
|
16
|
+
import { SituationTypeContainer, SituationTypeContainers } from '@dooboostore/simple-boot/decorators/inject/Inject';
|
|
17
|
+
import { InjectSituationType, HostSet } from '../types';
|
|
20
18
|
|
|
21
19
|
// --- Core Interfaces & Types ---
|
|
22
20
|
|
|
21
|
+
export const ELEMENT_CONFIG_KEY = Symbol('simple-web-component:element-config');
|
|
22
|
+
|
|
23
23
|
export interface ElementConfig {
|
|
24
|
-
name: string;
|
|
25
24
|
extends?: string;
|
|
26
25
|
observedAttributes?: string[];
|
|
27
|
-
customElementRegistry?:
|
|
26
|
+
customElementRegistry?: any;
|
|
28
27
|
window?: Window;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
export
|
|
30
|
+
export interface ElementMetadata extends Omit<ElementConfig, 'window'> {
|
|
31
|
+
name: string;
|
|
32
|
+
window: Window;
|
|
33
|
+
}
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
export const getElementConfig = (target: any): ElementMetadata | undefined => {
|
|
36
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
37
|
+
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const ensureInit = (inst: any) => {
|
|
41
|
+
if (!inst.__swc_initialized) {
|
|
42
|
+
inst._swcId = Math.random().toString(36).substring(2, 11);
|
|
43
|
+
inst._emitHandlers = new Map();
|
|
44
|
+
inst._boundListeners = [];
|
|
45
|
+
inst.__swc_initialized = true;
|
|
46
|
+
|
|
47
|
+
// Call constructor script if present
|
|
48
|
+
const hostSet = SwcUtils.getHostSet(inst);
|
|
49
|
+
inst._executeSwcScript?.('swc-on-constructor', hostSet);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// --- Global Event Handling ---
|
|
34
54
|
const globalDelegatedRoots = new WeakSet<Node>();
|
|
35
55
|
|
|
36
|
-
|
|
56
|
+
const handleGlobalSwcEvent = async (event: Event) => {
|
|
57
|
+
if ((event as any).__swc_handled) return;
|
|
58
|
+
const path = event.composedPath();
|
|
59
|
+
const type = event.type;
|
|
60
|
+
const attrName = `swc-on-${type}`;
|
|
61
|
+
|
|
62
|
+
for (const node of path) {
|
|
63
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
64
|
+
const script = node.getAttribute?.(attrName);
|
|
65
|
+
if (script && !getElementConfig(node)) {
|
|
66
|
+
const host: any = SwcUtils.findNearestSwcHost(node);
|
|
67
|
+
if (host && host.isConnected && typeof host.__swc_executeAttributeEvent === 'function') {
|
|
68
|
+
await host.__swc_executeAttributeEvent(node, attrName, script, event);
|
|
69
|
+
(event as any).__swc_handled = true;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
37
75
|
|
|
38
76
|
function buildEnv(configWindow?: Window) {
|
|
39
|
-
const win:
|
|
77
|
+
const win: Window = configWindow || ((typeof window !== 'undefined' ? window : undefined) as any);
|
|
40
78
|
const doc: Document = win?.document;
|
|
41
|
-
|
|
42
79
|
const builtInTagMap = new Map<any, string>();
|
|
43
80
|
for (const [cls, tag] of HTML_TAG_ENTRIES) {
|
|
44
81
|
if (win?.[cls]) builtInTagMap.set(win[cls], tag);
|
|
45
82
|
}
|
|
46
|
-
|
|
47
83
|
const domHelpers = SwcUtils.getHelperSet(win);
|
|
48
84
|
return { win, doc, builtInTagMap, domHelpers };
|
|
49
85
|
}
|
|
@@ -53,479 +89,389 @@ const getHandlers = (inst: any) => {
|
|
|
53
89
|
return inst.__swc_attributeEventHandlers;
|
|
54
90
|
};
|
|
55
91
|
|
|
92
|
+
const setupPrototype = (proto: any) => {
|
|
93
|
+
if (proto.__swc_proto_setup) return;
|
|
94
|
+
proto.__swc_proto_setup = true;
|
|
95
|
+
|
|
96
|
+
proto._executeSwcScript = function (attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {
|
|
97
|
+
ensureInit(this);
|
|
98
|
+
const script = this.getAttribute(attrName);
|
|
99
|
+
if (script) {
|
|
100
|
+
try {
|
|
101
|
+
const conf = getElementConfig(this);
|
|
102
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
103
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
104
|
+
const args = { ...hostSet, ...helpers, ...extraArgs, $el: this, $root: this.getRootNode() };
|
|
105
|
+
FunctionUtils.execute({ script, context: this, args });
|
|
106
|
+
} catch (e) {
|
|
107
|
+
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
proto._resolveWindow = function (localConfig?: ElementConfig): Window {
|
|
113
|
+
ensureInit(this);
|
|
114
|
+
if (localConfig?.window) return localConfig.window;
|
|
115
|
+
const ancestors = SwcUtils.findAllSwcHosts(this as any);
|
|
116
|
+
for (let i = ancestors.length - 1; i >= 0; i--) {
|
|
117
|
+
const aConf = getElementConfig(ancestors[i]);
|
|
118
|
+
if (aConf?.window) return aConf.window;
|
|
119
|
+
}
|
|
120
|
+
return (typeof window !== 'undefined' ? window : undefined) as Window;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
proto._invokeLifecycleMethod = function (methodName: string | symbol, hostSet: HostSet, extraArgs: any[] = []) {
|
|
124
|
+
ensureInit(this);
|
|
125
|
+
if (typeof (this as any)[methodName] !== 'function') return;
|
|
126
|
+
const app = hostSet.$appHost?.simpleApplication;
|
|
127
|
+
|
|
128
|
+
if (app) {
|
|
129
|
+
const otherStorage = new Map<any, any>();
|
|
130
|
+
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 })]);
|
|
131
|
+
otherStorage.set(SituationTypeContainers, situations);
|
|
132
|
+
|
|
133
|
+
return app.simstanceManager.executeBindParameterSimPromise(
|
|
134
|
+
{
|
|
135
|
+
target: this,
|
|
136
|
+
targetKey: methodName,
|
|
137
|
+
inputParameters: extraArgs
|
|
138
|
+
},
|
|
139
|
+
otherStorage
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
return (this as any)[methodName](...extraArgs);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
proto._bindAttributeEvent = function (el: HTMLElement, attrName: string, script: string, eventName?: string) {
|
|
147
|
+
ensureInit(this);
|
|
148
|
+
if (!eventName) {
|
|
149
|
+
if (!attrName.startsWith('swc-on-')) return;
|
|
150
|
+
eventName = attrName.substring(7);
|
|
151
|
+
}
|
|
152
|
+
const elHandlers = getHandlers(this);
|
|
153
|
+
let handlers = elHandlers.get(el);
|
|
154
|
+
if (!handlers) {
|
|
155
|
+
handlers = new Map();
|
|
156
|
+
elHandlers.set(el, handlers);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const oldHandler = handlers.get(attrName);
|
|
160
|
+
if (oldHandler) el.removeEventListener(eventName, oldHandler);
|
|
161
|
+
|
|
162
|
+
const handler = async (event: any) => {
|
|
163
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
164
|
+
const conf = getElementConfig(this);
|
|
165
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
166
|
+
const helpers = SwcUtils.getHelperSet(currentWin);
|
|
167
|
+
const args = {
|
|
168
|
+
event,
|
|
169
|
+
$data: (event as CustomEvent).detail,
|
|
170
|
+
...hostSet,
|
|
171
|
+
...helpers,
|
|
172
|
+
$el: el,
|
|
173
|
+
$root: this.getRootNode()
|
|
174
|
+
};
|
|
175
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
el.addEventListener(eventName, handler);
|
|
179
|
+
handlers.set(attrName, handler);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
proto.__swc_executeAttributeEvent = async function (el: HTMLElement, attrName: string, script: string, event: Event) {
|
|
183
|
+
ensureInit(this);
|
|
184
|
+
const hostSet = SwcUtils.getHostSet(el);
|
|
185
|
+
const conf = getElementConfig(this);
|
|
186
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
187
|
+
const currentHelpers = SwcUtils.getHelperSet(currentWin);
|
|
188
|
+
const args = {
|
|
189
|
+
event,
|
|
190
|
+
$data: (event as CustomEvent).detail,
|
|
191
|
+
...hostSet,
|
|
192
|
+
...currentHelpers,
|
|
193
|
+
$el: el,
|
|
194
|
+
$root: this.getRootNode()
|
|
195
|
+
};
|
|
196
|
+
await FunctionUtils.execute({ script, context: el, args });
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
|
|
56
200
|
export const elementDefine =
|
|
57
|
-
(
|
|
201
|
+
(name: string, config: Partial<ElementConfig> = {}): ClassDecorator =>
|
|
58
202
|
(constructor: any) => {
|
|
59
|
-
const config: ElementConfig = typeof inConfig === 'string' ? { name: inConfig } : inConfig;
|
|
60
203
|
const { win, doc, builtInTagMap: BUILT_IN_TAG_MAP, domHelpers: SWC_DOM_HELPERS } = buildEnv(config.window);
|
|
61
|
-
config
|
|
204
|
+
const metadata: ElementMetadata = { ...config, name, window: win };
|
|
62
205
|
|
|
63
|
-
|
|
206
|
+
if (!metadata.window) {
|
|
207
|
+
throw new Error('window is required');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
let extendsTagName = metadata.extends;
|
|
64
211
|
if (!extendsTagName) {
|
|
65
212
|
let proto = constructor;
|
|
66
|
-
|
|
213
|
+
const BaseHTMLElement = (win as any).HTMLElement;
|
|
214
|
+
while (proto && proto !== BaseHTMLElement && proto !== Function.prototype) {
|
|
67
215
|
extendsTagName = BUILT_IN_TAG_MAP.get(proto);
|
|
68
216
|
if (extendsTagName) break;
|
|
69
217
|
proto = Object.getPrototypeOf(proto);
|
|
70
218
|
}
|
|
71
|
-
|
|
219
|
+
metadata.extends = extendsTagName;
|
|
72
220
|
}
|
|
73
221
|
|
|
74
222
|
const emitCustomEventList = getEmitCustomEventMetadataList(constructor) || [];
|
|
75
223
|
const addEventListenerList = getAddEventListenerMetadata(constructor) || [];
|
|
76
224
|
const attrChangeMap = findAllAttributeChangedMetadata(constructor);
|
|
77
|
-
const
|
|
78
|
-
const replaceChildrenMap = findAllReplaceChildrenMetadata(constructor);
|
|
79
|
-
const appendChildMap = findAllAppendChildMetadata(constructor);
|
|
225
|
+
const attributeList = findAllAttributeMetadata(constructor);
|
|
80
226
|
|
|
81
227
|
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'];
|
|
82
228
|
const swcOnEvents = DOM_EVENT_NAMES.map(e => `swc-on-${e}`);
|
|
83
229
|
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const NewClass = class extends (constructor as any) {
|
|
88
|
-
private _swcId = Math.random().toString(36).substring(2, 11);
|
|
89
|
-
private _emitHandlers = new Map<string, EventListener>();
|
|
90
|
-
private _boundListeners: Array<{ target: EventTarget; type: string; handler: EventListener; options?: any }> = [];
|
|
91
|
-
|
|
92
|
-
private _executeSwcScript(attrName: string, hostSet: HostSet, extraArgs: Record<string, any> = {}) {
|
|
93
|
-
const script = this.getAttribute(attrName);
|
|
94
|
-
if (script) {
|
|
95
|
-
try {
|
|
96
|
-
const args = { ...hostSet, ...SWC_DOM_HELPERS, ...extraArgs };
|
|
97
|
-
FunctionUtils.execute({ script, context: this, args });
|
|
98
|
-
} catch (e) {
|
|
99
|
-
console.error(`[SWC] Failed to execute ${attrName}:`, e);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
230
|
+
// Collect all observed attributes from all decorators
|
|
231
|
+
const mergedObservedAttributes = [...new Set([...(metadata.observedAttributes ?? []), ...attrChangeMap.keys(), ...Array.from(findAllSetAttributeMetadata(constructor).values()).map(it => it.name), ...attributeList.map(it => it.options.name || String(it.propertyKey)), ...emitCustomEventList.map(it => it.options.attributeName!), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
103
232
|
|
|
104
|
-
|
|
105
|
-
if (typeof (this as any)[methodName] !== 'function') return;
|
|
106
|
-
const app = hostSet.$appHost?.simpleApplication;
|
|
107
|
-
|
|
108
|
-
if (app) {
|
|
109
|
-
const otherStorage = new Map<any, any>();
|
|
110
|
-
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 })]);
|
|
111
|
-
otherStorage.set(SituationTypeContainers, situations);
|
|
112
|
-
|
|
113
|
-
return app.simstanceManager.executeBindParameterSimPromise(
|
|
114
|
-
{
|
|
115
|
-
target: this,
|
|
116
|
-
targetKey: methodName,
|
|
117
|
-
inputParameters: extraArgs
|
|
118
|
-
},
|
|
119
|
-
otherStorage
|
|
120
|
-
);
|
|
121
|
-
} else {
|
|
122
|
-
return (this as any)[methodName](...extraArgs);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private _bindAttributeEvent(el: HTMLElement, attrName: string, script: string, eventName?: string) {
|
|
127
|
-
if (!eventName) {
|
|
128
|
-
if (!attrName.startsWith('swc-on-')) return;
|
|
129
|
-
eventName = attrName.substring(7);
|
|
130
|
-
}
|
|
131
|
-
if (swcLifecycleAttributes.includes(attrName)) return;
|
|
132
|
-
|
|
133
|
-
const elHandlers = getHandlers(this);
|
|
134
|
-
let handlers = elHandlers.get(el);
|
|
135
|
-
if (!handlers) {
|
|
136
|
-
handlers = new Map();
|
|
137
|
-
elHandlers.set(el, handlers);
|
|
138
|
-
}
|
|
233
|
+
const connectedInnerHtmlList = getOnConnectedInnerHtmlMetadata(constructor) || [];
|
|
139
234
|
|
|
140
|
-
|
|
141
|
-
|
|
235
|
+
const proto = constructor.prototype;
|
|
236
|
+
setupPrototype(proto);
|
|
142
237
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
event,
|
|
147
|
-
$data: (event as CustomEvent).detail,
|
|
148
|
-
...hostSet,
|
|
149
|
-
...SWC_DOM_HELPERS
|
|
150
|
-
};
|
|
151
|
-
FunctionUtils.execute({ script, context: el, args });
|
|
152
|
-
};
|
|
238
|
+
const originalConnected = proto.connectedCallback;
|
|
239
|
+
proto.connectedCallback = function () {
|
|
240
|
+
ensureInit(this);
|
|
153
241
|
|
|
154
|
-
|
|
155
|
-
|
|
242
|
+
if (connectedInnerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {
|
|
243
|
+
this.attachShadow({ mode: 'open' });
|
|
156
244
|
}
|
|
157
245
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
this._executeSwcScript('swc-on-constructor', hostSet);
|
|
162
|
-
|
|
163
|
-
if (connectedInnerHtmlList.some(it => it.options.useShadow === true) && !this.shadowRoot) {
|
|
164
|
-
this.attachShadow({ mode: 'open' });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
246
|
+
const conf = getElementConfig(this);
|
|
247
|
+
const currentWin = (this as any)._resolveWindow(conf);
|
|
248
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
167
249
|
|
|
168
|
-
|
|
169
|
-
|
|
250
|
+
(this as any)._executeSwcScript('swc-on-before-connected', hostSet);
|
|
251
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
252
|
+
if (bMethods) {
|
|
253
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
170
254
|
}
|
|
171
255
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (typeof (this as any).initCore === 'function') (this as any).initCore();
|
|
186
|
-
|
|
187
|
-
if (connectedInnerHtmlList.length > 0) {
|
|
188
|
-
let sContent = '',
|
|
189
|
-
lContent = '';
|
|
190
|
-
for (const meta of connectedInnerHtmlList) {
|
|
191
|
-
const res = await (this as any)[meta.propertyKey]();
|
|
192
|
-
if (res !== undefined) {
|
|
193
|
-
if (meta.options.useShadow) sContent += res;
|
|
194
|
-
else lContent += res;
|
|
256
|
+
// Initialize @attribute fields (DOM <-> JS Sync)
|
|
257
|
+
attributeList.forEach(meta => {
|
|
258
|
+
const attrName = meta.options.name || String(meta.propertyKey);
|
|
259
|
+
if (meta.options.connectedInitialize) {
|
|
260
|
+
// JS -> DOM (FORCE OVERWRITE)
|
|
261
|
+
const memoryVal = (this as any)[meta.privateKey];
|
|
262
|
+
if (memoryVal !== undefined) {
|
|
263
|
+
(this as any).__swc_syncing_init = true;
|
|
264
|
+
try {
|
|
265
|
+
(this as any)[meta.propertyKey] = memoryVal; // Trigger setter to update DOM
|
|
266
|
+
} finally {
|
|
267
|
+
(this as any).__swc_syncing_init = false;
|
|
195
268
|
}
|
|
196
269
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const type = event.type;
|
|
207
|
-
const attrName = `swc-on-${type}`;
|
|
208
|
-
|
|
209
|
-
for (const node of path) {
|
|
210
|
-
if (node === delegateHost) break;
|
|
211
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
212
|
-
|
|
213
|
-
const script = node.getAttribute?.(attrName);
|
|
214
|
-
if (script && !getElementConfig(node)) {
|
|
215
|
-
const host = SwcUtils.findNearestSwcHost(node);
|
|
216
|
-
if (host) {
|
|
217
|
-
const childHostSet = SwcUtils.getHostSet(node);
|
|
218
|
-
const args = {
|
|
219
|
-
event,
|
|
220
|
-
$data: (event as CustomEvent).detail,
|
|
221
|
-
...childHostSet,
|
|
222
|
-
...SWC_DOM_HELPERS
|
|
223
|
-
};
|
|
224
|
-
FunctionUtils.execute({ script, context: node, args });
|
|
225
|
-
(event as any).__swc_handled = true;
|
|
226
|
-
break;
|
|
227
|
-
}
|
|
270
|
+
} else if (meta.selector === ':host' || !meta.selector) {
|
|
271
|
+
// DOM -> JS (Pull from HTML)
|
|
272
|
+
const domVal = this.getAttribute(attrName);
|
|
273
|
+
if (domVal !== null) {
|
|
274
|
+
(this as any).__swc_syncing_init = true;
|
|
275
|
+
try {
|
|
276
|
+
(this as any)[meta.propertyKey] = domVal; // Update memory with DOM value
|
|
277
|
+
} finally {
|
|
278
|
+
(this as any).__swc_syncing_init = false;
|
|
228
279
|
}
|
|
229
280
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// 1. Local Delegation (To itself)
|
|
233
|
-
DOM_EVENT_NAMES.forEach(type => {
|
|
234
|
-
const handler = createDelegationHandler(this);
|
|
235
|
-
this.addEventListener(type, handler);
|
|
236
|
-
this._boundListeners.push({ target: this as any, type, handler });
|
|
237
|
-
});
|
|
281
|
+
}
|
|
282
|
+
});
|
|
238
283
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});
|
|
248
|
-
globalDelegatedRoots.add(root);
|
|
284
|
+
if (connectedInnerHtmlList.length > 0) {
|
|
285
|
+
let sContent = '',
|
|
286
|
+
lContent = '';
|
|
287
|
+
for (const meta of connectedInnerHtmlList) {
|
|
288
|
+
const res = (this as any)[meta.propertyKey]();
|
|
289
|
+
if (res !== undefined) {
|
|
290
|
+
if (meta.options.useShadow) sContent += res;
|
|
291
|
+
else lContent += res;
|
|
249
292
|
}
|
|
250
293
|
}
|
|
294
|
+
if (this.shadowRoot) this.shadowRoot.innerHTML = sContent;
|
|
295
|
+
if (lContent) this.innerHTML = lContent;
|
|
296
|
+
}
|
|
251
297
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
if (selector === ':window') {
|
|
261
|
-
bindTargets.push(currentWin);
|
|
262
|
-
} else if (selector === ':document') {
|
|
263
|
-
bindTargets.push(currentDoc);
|
|
264
|
-
} else if (selector === ':parentHost') {
|
|
265
|
-
if (hostSet.$parentHost) bindTargets.push(hostSet.$parentHost);
|
|
266
|
-
} else if (selector === ':appHost') {
|
|
267
|
-
if (hostSet.$appHost) bindTargets.push(hostSet.$appHost);
|
|
268
|
-
} else if (selector === ':firstHost') {
|
|
269
|
-
if (hostSet.$firstHost) bindTargets.push(hostSet.$firstHost);
|
|
270
|
-
} else if (selector === ':lastHost') {
|
|
271
|
-
if (hostSet.$lastHost) bindTargets.push(hostSet.$lastHost);
|
|
272
|
-
} else if (selector === ':firstAppHost') {
|
|
273
|
-
if (hostSet.$firstAppHost) bindTargets.push(hostSet.$firstAppHost);
|
|
274
|
-
} else if (selector === ':lastAppHost') {
|
|
275
|
-
if (hostSet.$lastAppHost) bindTargets.push(hostSet.$lastAppHost);
|
|
276
|
-
} else if (!selector || selector === ':host') {
|
|
277
|
-
bindTargets.push(this as any);
|
|
278
|
-
} else if (delegate) {
|
|
279
|
-
const bindRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
280
|
-
const r = root || 'auto';
|
|
281
|
-
if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));
|
|
282
|
-
else if (r === 'light') bindRoots.push(this as any);
|
|
283
|
-
else if (r === 'shadow') {
|
|
284
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);
|
|
285
|
-
} else if (r === 'all') {
|
|
286
|
-
bindRoots.push(this as any);
|
|
287
|
-
if (this.shadowRoot) bindRoots.push(this.shadowRoot as any);
|
|
288
|
-
}
|
|
298
|
+
const root = this.getRootNode();
|
|
299
|
+
if (!globalDelegatedRoots.has(root)) {
|
|
300
|
+
DOM_EVENT_NAMES.forEach(type => {
|
|
301
|
+
root.addEventListener(type, handleGlobalSwcEvent);
|
|
302
|
+
});
|
|
303
|
+
globalDelegatedRoots.add(root);
|
|
304
|
+
}
|
|
289
305
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
br.addEventListener(type, handler, opts);
|
|
302
|
-
const self: any = this;
|
|
303
|
-
if (removeOnDisconnected === true || (br !== self && br !== self.shadowRoot)) {
|
|
304
|
-
this._boundListeners.push({ target: br, type, handler, options: opts });
|
|
305
|
-
}
|
|
306
|
-
});
|
|
306
|
+
addEventListenerList.forEach(meta => {
|
|
307
|
+
const { selector, type, options } = meta;
|
|
308
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
309
|
+
const bindTargets: EventTarget[] = [];
|
|
310
|
+
const r = options.root || 'auto';
|
|
311
|
+
const applyRootOption = (target: any) => {
|
|
312
|
+
if (!target) return;
|
|
313
|
+
if (r === 'auto') {
|
|
314
|
+
bindTargets.push(target.shadowRoot || target);
|
|
307
315
|
} else {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
else if (r === 'shadow') {
|
|
313
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);
|
|
314
|
-
} else if (r === 'all') {
|
|
315
|
-
searchRoots.push(this as any);
|
|
316
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot as any);
|
|
317
|
-
}
|
|
316
|
+
if (r === 'light' || r === 'all') bindTargets.push(target);
|
|
317
|
+
if ((r === 'shadow' || r === 'all') && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
318
320
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
if (selector === ':window') bindTargets.push(currentWin);
|
|
322
|
+
else if (selector === ':document') bindTargets.push(currentWin.document);
|
|
323
|
+
else if (selector === ':parentHost') applyRootOption(hostSet.$parentHost);
|
|
324
|
+
else if (selector === ':appHost') applyRootOption(hostSet.$appHost);
|
|
325
|
+
else if (selector === ':firstHost') applyRootOption(hostSet.$firstHost);
|
|
326
|
+
else if (selector === ':lastHost') applyRootOption(hostSet.$lastHost);
|
|
327
|
+
else if (selector === ':firstAppHost') applyRootOption(hostSet.$firstAppHost);
|
|
328
|
+
else if (selector === ':lastAppHost') applyRootOption(hostSet.$lastAppHost);
|
|
329
|
+
else if (selector === ':hosts') hostSet.$hosts.forEach(applyRootOption);
|
|
330
|
+
else if (selector === ':appHosts') hostSet.$appHosts.forEach(applyRootOption);
|
|
331
|
+
else if (selector === ':host' || !selector) applyRootOption(this);
|
|
332
|
+
else if (options.delegate) {
|
|
333
|
+
const bindRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
334
|
+
if (r === 'auto') bindRoots.push(this.shadowRoot || (this as any));
|
|
335
|
+
else if (r === 'light') bindRoots.push(this as any);
|
|
336
|
+
else if (r === 'shadow' && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
337
|
+
else if (r === 'all') {
|
|
338
|
+
bindRoots.push(this as any);
|
|
339
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
322
340
|
}
|
|
323
341
|
|
|
324
|
-
|
|
325
|
-
const handler = (event: Event) => {
|
|
326
|
-
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
342
|
+
bindRoots.forEach(br => {
|
|
343
|
+
const handler = async (event: Event) => {
|
|
344
|
+
const matchedEl = (event.target as HTMLElement).closest(selector);
|
|
345
|
+
if (matchedEl && (br as any).contains(matchedEl)) {
|
|
346
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
347
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
348
|
+
if (options.preventDefault) event.preventDefault();
|
|
349
|
+
const currentHostSet = SwcUtils.getHostSet(this as any);
|
|
350
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
351
|
+
await (this as any)._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, matchedEl, args]);
|
|
352
|
+
}
|
|
331
353
|
};
|
|
332
|
-
|
|
333
|
-
if (removeOnDisconnected === true ||
|
|
334
|
-
this._boundListeners.push({ target, type, handler, options: opts });
|
|
354
|
+
br.addEventListener(type, handler, opts);
|
|
355
|
+
if (options.removeOnDisconnected === true || (br !== this && br !== this.shadowRoot)) {
|
|
356
|
+
(this as any)._boundListeners.push({ target: br, type, handler, options: opts });
|
|
335
357
|
}
|
|
336
358
|
});
|
|
337
|
-
}
|
|
359
|
+
} else {
|
|
360
|
+
const searchRoots: (HTMLElement | ShadowRoot)[] = [];
|
|
361
|
+
if (r === 'auto') searchRoots.push(this.shadowRoot || (this as any));
|
|
362
|
+
else if (r === 'light') searchRoots.push(this as any);
|
|
363
|
+
else if (r === 'shadow' && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
364
|
+
else if (r === 'all') {
|
|
365
|
+
searchRoots.push(this as any);
|
|
366
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
367
|
+
}
|
|
338
368
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
for (const m of aMethods) await this._invokeLifecycleMethod(m, hostSet);
|
|
369
|
+
searchRoots.forEach(sr => {
|
|
370
|
+
sr.querySelectorAll(selector).forEach(el => bindTargets.push(el));
|
|
371
|
+
});
|
|
343
372
|
}
|
|
344
373
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
374
|
+
bindTargets.forEach(t => {
|
|
375
|
+
const handler = async (event: Event) => {
|
|
376
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
377
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
378
|
+
if (options.preventDefault) event.preventDefault();
|
|
379
|
+
const currentHostSet = SwcUtils.getHostSet(this as any);
|
|
380
|
+
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
381
|
+
await (this as any)._invokeLifecycleMethod(meta.propertyKey, currentHostSet, [event, currentHostSet, args]);
|
|
382
|
+
};
|
|
383
|
+
t.addEventListener(type, handler, opts);
|
|
384
|
+
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
385
|
+
(this as any)._boundListeners.push({ target: t, type, handler, options: opts });
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
});
|
|
357
389
|
|
|
358
|
-
|
|
390
|
+
if (originalConnected) originalConnected.apply(this);
|
|
359
391
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
this.
|
|
363
|
-
this._executeSwcScript('swc-on-after-disconnected', hostSet);
|
|
392
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_CONNECTED_METADATA_KEY);
|
|
393
|
+
if (aMethods) {
|
|
394
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
364
395
|
}
|
|
396
|
+
(this as any)._executeSwcScript('swc-on-connected', hostSet);
|
|
397
|
+
(this as any)._executeSwcScript('swc-on-after-connected', hostSet);
|
|
398
|
+
(this as any).__swc_connected = true;
|
|
399
|
+
};
|
|
365
400
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
|
|
375
|
-
if (aMethods) aMethods.forEach(m => this._invokeLifecycleMethod(m, hostSet));
|
|
376
|
-
this._executeSwcScript('swc-on-adopted', hostSet);
|
|
377
|
-
this._executeSwcScript('swc-on-after-adopted', hostSet);
|
|
401
|
+
const originalDisconnected = proto.disconnectedCallback;
|
|
402
|
+
proto.disconnectedCallback = function () {
|
|
403
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
404
|
+
(this as any)._executeSwcScript('swc-on-before-disconnected', hostSet);
|
|
405
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
406
|
+
if (bMethods) {
|
|
407
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
378
408
|
}
|
|
379
409
|
|
|
380
|
-
|
|
381
|
-
|
|
410
|
+
if ((this as any)._boundListeners) {
|
|
411
|
+
(this as any)._boundListeners.forEach((l: any) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
412
|
+
(this as any)._boundListeners = [];
|
|
413
|
+
}
|
|
382
414
|
|
|
383
|
-
|
|
384
|
-
if (newVal !== null) {
|
|
385
|
-
const customEventMeta = emitCustomEventList.find(it => it.options.attributeName === name);
|
|
386
|
-
const eventName = customEventMeta ? customEventMeta.options.type : name.substring(7);
|
|
387
|
-
this._bindAttributeEvent(this as any, name, newVal, eventName);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
415
|
+
if (originalDisconnected) originalDisconnected.apply(this);
|
|
390
416
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
mKeys.forEach(key => this._invokeLifecycleMethod(key, hSet, [newVal, old, name]));
|
|
395
|
-
}
|
|
417
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
418
|
+
if (aMethods) {
|
|
419
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
396
420
|
}
|
|
421
|
+
(this as any)._executeSwcScript('swc-on-disconnected', hostSet);
|
|
422
|
+
(this as any)._executeSwcScript('swc-on-after-disconnected', hostSet);
|
|
423
|
+
(this as any).__swc_connected = false;
|
|
397
424
|
};
|
|
398
425
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (res === null) this.removeAttribute(attrName);
|
|
407
|
-
else this.setAttribute(attrName, String(res));
|
|
408
|
-
}
|
|
409
|
-
return res;
|
|
410
|
-
};
|
|
426
|
+
const originalAdopted = proto.adoptedCallback;
|
|
427
|
+
proto.adoptedCallback = function () {
|
|
428
|
+
const hostSet = SwcUtils.getHostSet(this as any);
|
|
429
|
+
(this as any)._executeSwcScript('swc-on-before-adopted', hostSet);
|
|
430
|
+
const bMethods = findAllLifecycleMetadata(this, ON_BEFORE_ADOPTED_METADATA_KEY);
|
|
431
|
+
if (bMethods) {
|
|
432
|
+
for (const m of bMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
411
433
|
}
|
|
412
|
-
});
|
|
413
434
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
NewClass.prototype[propertyKey as any] = function (...args: any[]) {
|
|
420
|
-
const detail = original.apply(this, args);
|
|
421
|
-
const event = new CustomEvent(options.type, {
|
|
422
|
-
detail,
|
|
423
|
-
bubbles: options.bubbles,
|
|
424
|
-
composed: options.composed,
|
|
425
|
-
cancelable: options.cancelable
|
|
426
|
-
});
|
|
427
|
-
this.dispatchEvent(event);
|
|
428
|
-
return detail;
|
|
429
|
-
};
|
|
435
|
+
if (originalAdopted) originalAdopted.apply(this);
|
|
436
|
+
|
|
437
|
+
const aMethods = findAllLifecycleMetadata(this, ON_AFTER_ADOPTED_METADATA_KEY);
|
|
438
|
+
if (aMethods) {
|
|
439
|
+
for (const m of aMethods) (this as any)._invokeLifecycleMethod(m, hostSet);
|
|
430
440
|
}
|
|
431
|
-
|
|
441
|
+
(this as any)._executeSwcScript('swc-on-adopted', hostSet);
|
|
442
|
+
(this as any)._executeSwcScript('swc-on-after-adopted', hostSet);
|
|
443
|
+
};
|
|
432
444
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
if (typeof original === 'function') {
|
|
437
|
-
NewClass.prototype[methodName as any] = function (...args: any[]) {
|
|
438
|
-
const res = original.apply(this, args);
|
|
439
|
-
if (res !== undefined) {
|
|
440
|
-
const conf = getElementConfig(this);
|
|
441
|
-
const currentWin = conf?.window || window;
|
|
442
|
-
const currentDoc = currentWin.document;
|
|
443
|
-
|
|
444
|
-
let targetEl: Element | null = null;
|
|
445
|
-
if (selector === ':host' || !selector) {
|
|
446
|
-
targetEl = this;
|
|
447
|
-
} else {
|
|
448
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
449
|
-
}
|
|
445
|
+
const originalAttributeChanged = proto.attributeChangedCallback;
|
|
446
|
+
proto.attributeChangedCallback = function (name: string, old: string | null, newVal: string | null) {
|
|
447
|
+
if (originalAttributeChanged) originalAttributeChanged.apply(this, [name, old, newVal]);
|
|
450
448
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
-
return n as Node;
|
|
460
|
-
});
|
|
461
|
-
(targetEl as any).replaceChildren(...normalizedNodes);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
return res;
|
|
465
|
-
};
|
|
449
|
+
// Handle swc-on-* events
|
|
450
|
+
if (name.startsWith('swc-on-') && !swcLifecycleAttributes.includes(name)) {
|
|
451
|
+
if (newVal !== null) {
|
|
452
|
+
const customEventMeta = emitCustomEventList.find(it => it.options.attributeName === name);
|
|
453
|
+
const eventName = customEventMeta ? customEventMeta.type : name.substring(7);
|
|
454
|
+
(this as any)._bindAttributeEvent(this as any, name, newVal, eventName);
|
|
455
|
+
}
|
|
466
456
|
}
|
|
467
|
-
});
|
|
468
457
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
NewClass.prototype[methodName as any] = function (...args: any[]) {
|
|
475
|
-
const res = original.apply(this, args);
|
|
476
|
-
if (res !== undefined) {
|
|
477
|
-
const conf = getElementConfig(this);
|
|
478
|
-
const currentWin = conf?.window || window;
|
|
479
|
-
const currentDoc = currentWin.document;
|
|
480
|
-
|
|
481
|
-
let targetEl: Element | null = null;
|
|
482
|
-
if (selector === ':host' || !selector) {
|
|
483
|
-
targetEl = this;
|
|
484
|
-
} else {
|
|
485
|
-
targetEl = (this.shadowRoot || this).querySelector(selector);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
if (targetEl) {
|
|
489
|
-
const nodes: (Node | string)[] = Array.isArray(res) ? res : [res];
|
|
490
|
-
const normalizedNodes = nodes.map(n => {
|
|
491
|
-
if (typeof n === 'string') {
|
|
492
|
-
const t = currentDoc.createElement('template');
|
|
493
|
-
t.innerHTML = n;
|
|
494
|
-
return t.content;
|
|
495
|
-
}
|
|
496
|
-
return n as Node;
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
const pos = options.position || 'lastChild';
|
|
500
|
-
if (pos === 'lastChild') (targetEl as any).append(...normalizedNodes);
|
|
501
|
-
else if (pos === 'firstChild') (targetEl as any).prepend(...normalizedNodes);
|
|
502
|
-
else if (pos === 'nextSibling') (targetEl as any).after(...normalizedNodes);
|
|
503
|
-
else if (pos === 'previousSibling') (targetEl as any).before(...normalizedNodes);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return res;
|
|
507
|
-
};
|
|
458
|
+
// Handle @changedAttribute callbacks
|
|
459
|
+
const mKeys = attrChangeMap.get(name);
|
|
460
|
+
if (mKeys && Array.isArray(mKeys)) {
|
|
461
|
+
const hSet = SwcUtils.getHostSet(this as any);
|
|
462
|
+
for (const key of mKeys) (this as any)._invokeLifecycleMethod(key, hSet, [newVal, old, name]);
|
|
508
463
|
}
|
|
509
|
-
}
|
|
464
|
+
};
|
|
510
465
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (name === 'constructor') return;
|
|
515
|
-
const keys = Reflect.getMetadataKeys(originalProto, name);
|
|
516
|
-
keys.forEach(key => Reflect.defineMetadata(key, Reflect.getMetadata(key, originalProto, name), newProto, name));
|
|
466
|
+
Object.defineProperty(constructor, 'observedAttributes', {
|
|
467
|
+
get: () => mergedObservedAttributes,
|
|
468
|
+
configurable: true
|
|
517
469
|
});
|
|
518
470
|
|
|
519
|
-
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY,
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
registry.define(config.name, NewClass as any, config.extends ? { extends: config.extends } : undefined);
|
|
471
|
+
ReflectUtils.defineMetadata(ELEMENT_CONFIG_KEY, metadata, constructor);
|
|
472
|
+
const registry = metadata.customElementRegistry || (win as any)?.customElements;
|
|
473
|
+
if (registry && !registry.get(metadata.name)) {
|
|
474
|
+
registry.define(metadata.name, constructor as any, metadata.extends ? { extends: metadata.extends } : undefined);
|
|
524
475
|
}
|
|
525
|
-
return
|
|
476
|
+
return constructor;
|
|
526
477
|
};
|
|
527
|
-
|
|
528
|
-
export const getElementConfig = (target: any): ElementConfig | undefined => {
|
|
529
|
-
const constructor = target instanceof Function ? target : target.constructor;
|
|
530
|
-
return ReflectUtils.getMetadata(ELEMENT_CONFIG_KEY, constructor);
|
|
531
|
-
};
|