@dooboostore/simple-web-component 1.0.36 → 1.0.38
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 +396 -68
- package/dist/cjs/{elements/SwcAppEngine.js → SwcAppEngine.js} +9 -6
- package/dist/cjs/SwcAppEngine.js.map +7 -0
- package/dist/cjs/decorators/addEventListener.js +20 -4
- package/dist/cjs/decorators/addEventListener.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js.map +1 -1
- package/dist/cjs/decorators/applyClass.js.map +1 -1
- package/dist/cjs/decorators/applyNode.js +109 -26
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applySlot.js +129 -0
- package/dist/cjs/decorators/applySlot.js.map +7 -0
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js.map +1 -1
- package/dist/cjs/decorators/elementDefine.js +90 -52
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js.map +1 -1
- package/dist/cjs/decorators/index.js +2 -0
- package/dist/cjs/decorators/index.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +88 -24
- package/dist/cjs/decorators/lifecycles.js.map +3 -3
- package/dist/cjs/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/cjs/decorators/query.js +1 -1
- package/dist/cjs/decorators/query.js.map +2 -2
- package/dist/cjs/decorators/queryAll.js.map +1 -1
- package/dist/cjs/decorators/setProperty.js.map +1 -1
- package/dist/cjs/decorators/state.js +84 -0
- package/dist/cjs/decorators/state.js.map +7 -0
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcApp.js +231 -0
- package/dist/cjs/elements/SwcApp.js.map +7 -0
- package/dist/cjs/elements/SwcAppMixin.js +78 -80
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/index.js +2 -1
- package/dist/cjs/elements/index.js.map +2 -2
- package/dist/cjs/elements/tt/SwcAppMixin.js +1 -0
- package/dist/cjs/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsync.js +1 -0
- package/dist/cjs/elements/tt/SwcAsync.js.map +7 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChoose.js +1 -0
- package/dist/cjs/elements/tt/SwcChoose.js.map +7 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIf.js +1 -0
- package/dist/cjs/elements/tt/SwcIf.js.map +7 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoop.js +1 -0
- package/dist/cjs/elements/tt/SwcLoop.js.map +7 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/cjs/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/cjs/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/cjs/elements/tt/register.js +1 -0
- package/dist/cjs/elements/tt/register.js.map +7 -0
- package/dist/cjs/index.js +10 -8
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/{types.js → types/index.js} +1 -1
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/types/window.d.js +16 -0
- package/dist/cjs/types/window.d.js.map +7 -0
- package/dist/cjs/utils/Utils.js +168 -26
- package/dist/cjs/utils/Utils.js.map +3 -3
- package/dist/esm/{elements/SwcAppEngine.js → SwcAppEngine.js} +7 -4
- package/dist/esm/SwcAppEngine.js.map +7 -0
- package/dist/esm/decorators/addEventListener.js +20 -4
- package/dist/esm/decorators/addEventListener.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js.map +1 -1
- package/dist/esm/decorators/applyClass.js.map +1 -1
- package/dist/esm/decorators/applyNode.js +109 -26
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applySlot.js +110 -0
- package/dist/esm/decorators/applySlot.js.map +7 -0
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js.map +1 -1
- package/dist/esm/decorators/elementDefine.js +96 -58
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js.map +1 -1
- package/dist/esm/decorators/index.js +2 -0
- package/dist/esm/decorators/index.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +88 -24
- package/dist/esm/decorators/lifecycles.js.map +3 -3
- package/dist/esm/decorators/publishSwcAppMessage.js.map +2 -2
- package/dist/esm/decorators/query.js +1 -1
- package/dist/esm/decorators/query.js.map +2 -2
- package/dist/esm/decorators/queryAll.js.map +1 -1
- package/dist/esm/decorators/setProperty.js.map +1 -1
- package/dist/esm/decorators/state.js +65 -0
- package/dist/esm/decorators/state.js.map +7 -0
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcApp.js +212 -0
- package/dist/esm/elements/SwcApp.js.map +7 -0
- package/dist/esm/elements/SwcAppMixin.js +76 -78
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/index.js +2 -1
- package/dist/esm/elements/index.js.map +2 -2
- package/dist/esm/elements/tt/SwcAppMixin.js +1 -0
- package/dist/esm/elements/tt/SwcAppMixin.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsync.js +1 -0
- package/dist/esm/elements/tt/SwcAsync.js.map +7 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcAsyncTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcChoose.js +1 -0
- package/dist/esm/elements/tt/SwcChoose.js.map +7 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcChooseTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcIf.js +1 -0
- package/dist/esm/elements/tt/SwcIf.js.map +7 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcIfTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoop.js +1 -0
- package/dist/esm/elements/tt/SwcLoop.js.map +7 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js +1 -0
- package/dist/esm/elements/tt/SwcLoopTemplate.js.map +7 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js +1 -0
- package/dist/esm/elements/tt/SwcSubTemplates.js.map +7 -0
- package/dist/esm/elements/tt/register.js +1 -0
- package/dist/esm/elements/tt/register.js.map +7 -0
- package/dist/esm/index.js +11 -9
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/{types.js → types/index.js} +1 -1
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/types/window.d.js +1 -0
- package/dist/esm/types/window.d.js.map +7 -0
- package/dist/esm/utils/Utils.js +168 -26
- package/dist/esm/utils/Utils.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +7477 -2828
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/{elements/SwcAppEngine.d.ts → SwcAppEngine.d.ts} +9 -4
- package/dist/types/SwcAppEngine.d.ts.map +1 -0
- package/dist/types/decorators/addEventListener.d.ts +5 -2
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +24 -8
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applySlot.d.ts +27 -0
- package/dist/types/decorators/applySlot.d.ts.map +1 -0
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/index.d.ts +2 -0
- package/dist/types/decorators/index.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +26 -15
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/publishSwcAppMessage.d.ts.map +1 -1
- package/dist/types/decorators/query.d.ts +1 -1
- package/dist/types/decorators/query.d.ts.map +1 -1
- package/dist/types/decorators/queryAll.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +1 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/state.d.ts +9 -0
- package/dist/types/decorators/state.d.ts.map +1 -0
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcApp.d.ts +36 -0
- package/dist/types/elements/SwcApp.d.ts.map +1 -0
- package/dist/types/elements/SwcAppMixin.d.ts +26 -7
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/index.d.ts +2 -1
- package/dist/types/elements/index.d.ts.map +1 -1
- package/dist/types/elements/tt/SwcAppMixin.d.ts +1 -0
- package/dist/types/elements/tt/SwcAppMixin.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsync.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcAsyncTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts +1 -0
- package/dist/types/elements/tt/SwcChoose.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcChooseTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcIf.d.ts +1 -0
- package/dist/types/elements/{SwcIf.d.ts.map → tt/SwcIf.d.ts.map} +1 -1
- package/dist/types/elements/tt/SwcIfTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcIfTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoop.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts +1 -0
- package/dist/types/elements/tt/SwcLoopTemplate.d.ts.map +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts +1 -0
- package/dist/types/elements/tt/SwcSubTemplates.d.ts.map +1 -0
- package/dist/types/elements/tt/register.d.ts +1 -0
- package/dist/types/elements/tt/register.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/{types.d.ts → types/index.d.ts} +12 -12
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/Utils.d.ts +18 -5
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +7478 -2829
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/{elements/SwcAppEngine.ts → SwcAppEngine.ts} +17 -8
- package/src/decorators/addEventListener.ts +21 -5
- package/src/decorators/applyAttribute.ts +1 -1
- package/src/decorators/applyClass.ts +1 -1
- package/src/decorators/applyNode.ts +186 -66
- package/src/decorators/applySlot.ts +188 -0
- package/src/decorators/applyStyle.ts +4 -4
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/elementDefine.ts +142 -68
- package/src/decorators/emitCustomEvent.ts +1 -1
- package/src/decorators/index.ts +3 -0
- package/src/decorators/lifecycles.ts +119 -30
- package/src/decorators/publishSwcAppMessage.ts +2 -3
- package/src/decorators/query.ts +4 -4
- package/src/decorators/queryAll.ts +1 -1
- package/src/decorators/setProperty.ts +1 -1
- package/src/decorators/state.ts +84 -0
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +1 -1
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +4 -3
- package/src/elements/SwcApp.ts +241 -0
- package/src/elements/SwcAppMixin.ts +98 -146
- package/src/elements/index.ts +4 -1
- package/src/elements/tt/SwcAppMixin.ts +13 -0
- package/src/elements/tt/SwcAsync.ts +139 -0
- package/src/elements/tt/SwcAsyncTemplate.ts +126 -0
- package/src/elements/tt/SwcChoose.ts +182 -0
- package/src/elements/tt/SwcChooseTemplate.ts +229 -0
- package/src/elements/tt/SwcIf.ts +145 -0
- package/src/elements/tt/SwcIfTemplate.ts +158 -0
- package/src/elements/tt/SwcLoop.ts +222 -0
- package/src/elements/tt/SwcLoopTemplate.ts +255 -0
- package/src/elements/tt/SwcSubTemplates.ts +6 -0
- package/src/elements/tt/register.ts +720 -0
- package/src/index.ts +11 -9
- package/src/{types.ts → types/index.ts} +15 -11
- package/src/types/window.d.ts +46 -0
- package/src/utils/Utils.ts +214 -24
- package/dist/cjs/elements/SwcAppEngine.js.map +0 -7
- package/dist/cjs/elements/SwcAsync.js +0 -129
- package/dist/cjs/elements/SwcAsync.js.map +0 -7
- package/dist/cjs/elements/SwcChoose.js +0 -155
- package/dist/cjs/elements/SwcChoose.js.map +0 -7
- package/dist/cjs/elements/SwcIf.js +0 -117
- package/dist/cjs/elements/SwcIf.js.map +0 -7
- package/dist/cjs/elements/SwcLoop.js +0 -176
- package/dist/cjs/elements/SwcLoop.js.map +0 -7
- package/dist/cjs/elements/SwcSubTemplates.js +0 -13
- package/dist/cjs/elements/SwcSubTemplates.js.map +0 -7
- package/dist/cjs/elements/register.js +0 -1026
- package/dist/cjs/elements/register.js.map +0 -7
- package/dist/cjs/types.js.map +0 -7
- package/dist/esm/elements/SwcAppEngine.js.map +0 -7
- package/dist/esm/elements/SwcAsync.js +0 -129
- package/dist/esm/elements/SwcAsync.js.map +0 -7
- package/dist/esm/elements/SwcChoose.js +0 -155
- package/dist/esm/elements/SwcChoose.js.map +0 -7
- package/dist/esm/elements/SwcIf.js +0 -117
- package/dist/esm/elements/SwcIf.js.map +0 -7
- package/dist/esm/elements/SwcLoop.js +0 -176
- package/dist/esm/elements/SwcLoop.js.map +0 -7
- package/dist/esm/elements/SwcSubTemplates.js +0 -13
- package/dist/esm/elements/SwcSubTemplates.js.map +0 -7
- package/dist/esm/elements/register.js +0 -1007
- package/dist/esm/elements/register.js.map +0 -7
- package/dist/esm/types.js.map +0 -7
- package/dist/types/elements/SwcAppEngine.d.ts.map +0 -1
- package/dist/types/elements/SwcAsync.d.ts +0 -2
- package/dist/types/elements/SwcAsync.d.ts.map +0 -1
- package/dist/types/elements/SwcChoose.d.ts +0 -2
- package/dist/types/elements/SwcChoose.d.ts.map +0 -1
- package/dist/types/elements/SwcIf.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts +0 -2
- package/dist/types/elements/SwcLoop.d.ts.map +0 -1
- package/dist/types/elements/SwcSubTemplates.d.ts +0 -13
- package/dist/types/elements/SwcSubTemplates.d.ts.map +0 -1
- package/dist/types/elements/register.d.ts +0 -4
- package/dist/types/elements/register.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/src/elements/SwcAsync.ts +0 -126
- package/src/elements/SwcChoose.ts +0 -190
- package/src/elements/SwcIf.ts +0 -124
- package/src/elements/SwcLoop.ts +0 -205
- package/src/elements/SwcSubTemplates.ts +0 -6
- package/src/elements/register.ts +0 -1022
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
var window_d_exports = {};
|
|
15
|
+
module.exports = __toCommonJS(window_d_exports);
|
|
16
|
+
//# sourceMappingURL=window.d.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/window.d.ts"],
|
|
4
|
+
"sourcesContent": ["import {HTMLDialogElement} from \"@dooboostore/dom-parser\";\n\n/**\n * Global type augmentation for @dooboostore showcase\n */\ndeclare global {\n interface Window {\n HTMLElement: typeof HTMLElement;\n HTMLDivElement: typeof HTMLDivElement;\n HTMLButtonElement: typeof HTMLButtonElement;\n HTMLTemplateElement: typeof HTMLTemplateElement;\n HTMLAnchorElement: typeof HTMLAnchorElement;\n HTMLDialogElement: typeof HTMLDialogElement;\n HTMLBodyElement: typeof HTMLBodyElement;\n HTMLSectionElement: typeof HTMLSectionElement;\n HTMLMainElement: typeof HTMLMainElement;\n ShadowRoot: typeof ShadowRoot;\n location: Location;\n document: Document;\n history: History;\n console: Console;\n IntersectionObserver: typeof IntersectionObserver;\n SwaggerUIBundle: any;\n\n }\n\n namespace Dooboostore {\n interface PackageInfo {\n id: string;\n name: string;\n description: string;\n longDescription: string;\n icon: string;\n color: string;\n features: PackageFeature[];\n example: string;\n }\n\n interface PackageFeature {\n title: string;\n desc: string;\n }\n }\n}\n\nexport {};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/utils/Utils.js
CHANGED
|
@@ -21,6 +21,7 @@ __export(Utils_exports, {
|
|
|
21
21
|
SwcUtils: () => SwcUtils,
|
|
22
22
|
commentNode: () => commentNode,
|
|
23
23
|
createElement: () => createElement,
|
|
24
|
+
html: () => html,
|
|
24
25
|
htmlAElement: () => htmlAElement,
|
|
25
26
|
htmlArticleElement: () => htmlArticleElement,
|
|
26
27
|
htmlButtonElement: () => htmlButtonElement,
|
|
@@ -36,12 +37,22 @@ __export(Utils_exports, {
|
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(Utils_exports);
|
|
38
39
|
var import_decorators = require("../decorators");
|
|
40
|
+
var import_core = require("@dooboostore/core");
|
|
41
|
+
var import_core_web = require("@dooboostore/core-web");
|
|
39
42
|
const SWC_NOT_FOUND = Symbol.for("simple-web-component:not-found");
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const html = (str, document2) => {
|
|
44
|
+
return [...document2.createRange().createContextualFragment(str).childNodes];
|
|
45
|
+
};
|
|
46
|
+
const htmlFragment = (html2, doc) => {
|
|
47
|
+
if (!doc) throw new Error("Document is not available");
|
|
48
|
+
const template = doc.createElement("template");
|
|
49
|
+
if (typeof html2 === "string") {
|
|
50
|
+
template.innerHTML = html2.trim();
|
|
51
|
+
} else if (html2 instanceof Node) {
|
|
52
|
+
template.appendChild(html2);
|
|
53
|
+
} else if (Array.isArray(html2)) {
|
|
54
|
+
template.append(...html2);
|
|
55
|
+
}
|
|
45
56
|
return template.content;
|
|
46
57
|
};
|
|
47
58
|
const textNode = (text, doc) => {
|
|
@@ -54,41 +65,44 @@ const commentNode = (comment, doc) => {
|
|
|
54
65
|
if (!d) throw new Error("Document is not available");
|
|
55
66
|
return d.createComment(comment !== void 0 && comment !== null ? String(comment) : "");
|
|
56
67
|
};
|
|
57
|
-
const createElement = (tagName, options) => {
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
const el =
|
|
61
|
-
if (options?.
|
|
68
|
+
const createElement = (documentOrWindow, tagName, options) => {
|
|
69
|
+
const doc = "document" in documentOrWindow ? documentOrWindow.document : documentOrWindow;
|
|
70
|
+
if (!doc) throw new Error("Document is not available");
|
|
71
|
+
const el = doc.createElement(tagName);
|
|
72
|
+
if (options?.innerHtml) el.innerHTML = options.innerHtml;
|
|
62
73
|
if (options?.attrs) {
|
|
63
|
-
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
74
|
+
Object.entries(options.attrs).filter(([k, v]) => v).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
75
|
+
}
|
|
76
|
+
if (options?.property) {
|
|
77
|
+
Object.entries(options.property).forEach(([k, v]) => el[k] = v);
|
|
64
78
|
}
|
|
65
79
|
return el;
|
|
66
80
|
};
|
|
67
|
-
const htmlDivElement = (
|
|
81
|
+
const htmlDivElement = (html2, options) => {
|
|
68
82
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
69
83
|
if (!d) throw new Error("Document is not available");
|
|
70
84
|
const el = d.createElement("div");
|
|
71
|
-
el.innerHTML =
|
|
85
|
+
el.innerHTML = html2.trim();
|
|
72
86
|
if (options?.attrs) {
|
|
73
87
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
74
88
|
}
|
|
75
89
|
return el;
|
|
76
90
|
};
|
|
77
|
-
const htmlSpanElement = (
|
|
91
|
+
const htmlSpanElement = (html2, options) => {
|
|
78
92
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
79
93
|
if (!d) throw new Error("Document is not available");
|
|
80
94
|
const el = d.createElement("span");
|
|
81
|
-
el.innerHTML =
|
|
95
|
+
el.innerHTML = html2.trim();
|
|
82
96
|
if (options?.attrs) {
|
|
83
97
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
84
98
|
}
|
|
85
99
|
return el;
|
|
86
100
|
};
|
|
87
|
-
const htmlButtonElement = (
|
|
101
|
+
const htmlButtonElement = (html2, options) => {
|
|
88
102
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
89
103
|
if (!d) throw new Error("Document is not available");
|
|
90
104
|
const el = d.createElement("button");
|
|
91
|
-
el.innerHTML =
|
|
105
|
+
el.innerHTML = html2.trim();
|
|
92
106
|
if (options?.attrs) {
|
|
93
107
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
94
108
|
}
|
|
@@ -103,42 +117,42 @@ const htmlUlElement = (options) => {
|
|
|
103
117
|
}
|
|
104
118
|
return el;
|
|
105
119
|
};
|
|
106
|
-
const htmlLiElement = (
|
|
120
|
+
const htmlLiElement = (html2, options) => {
|
|
107
121
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
108
122
|
if (!d) throw new Error("Document is not available");
|
|
109
123
|
const el = d.createElement("li");
|
|
110
|
-
el.innerHTML =
|
|
124
|
+
el.innerHTML = html2.trim();
|
|
111
125
|
if (options?.attrs) {
|
|
112
126
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
113
127
|
}
|
|
114
128
|
return el;
|
|
115
129
|
};
|
|
116
|
-
const htmlAElement = (
|
|
130
|
+
const htmlAElement = (html2, options) => {
|
|
117
131
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
118
132
|
if (!d) throw new Error("Document is not available");
|
|
119
133
|
const el = d.createElement("a");
|
|
120
|
-
el.innerHTML =
|
|
134
|
+
el.innerHTML = html2.trim();
|
|
121
135
|
if (options?.href) el.href = options.href;
|
|
122
136
|
if (options?.attrs) {
|
|
123
137
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
124
138
|
}
|
|
125
139
|
return el;
|
|
126
140
|
};
|
|
127
|
-
const htmlPElement = (
|
|
141
|
+
const htmlPElement = (html2, options) => {
|
|
128
142
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
129
143
|
if (!d) throw new Error("Document is not available");
|
|
130
144
|
const el = d.createElement("p");
|
|
131
|
-
el.innerHTML =
|
|
145
|
+
el.innerHTML = html2.trim();
|
|
132
146
|
if (options?.attrs) {
|
|
133
147
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
134
148
|
}
|
|
135
149
|
return el;
|
|
136
150
|
};
|
|
137
|
-
const htmlHeadingElement = (level,
|
|
151
|
+
const htmlHeadingElement = (level, html2, options) => {
|
|
138
152
|
const d = options?.doc || (typeof document !== "undefined" ? document : void 0);
|
|
139
153
|
if (!d) throw new Error("Document is not available");
|
|
140
154
|
const el = d.createElement(`h${level}`);
|
|
141
|
-
el.innerHTML =
|
|
155
|
+
el.innerHTML = html2.trim();
|
|
142
156
|
if (options?.attrs) {
|
|
143
157
|
Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));
|
|
144
158
|
}
|
|
@@ -253,6 +267,134 @@ var SwcUtils;
|
|
|
253
267
|
if ((0, import_decorators.getElementConfig)(el)) return el;
|
|
254
268
|
return (0, SwcUtils2.findNearestSwcHostIncludingSelf)(el);
|
|
255
269
|
};
|
|
270
|
+
function projectProcessHtml(id, htmlOrNode, document2) {
|
|
271
|
+
if (typeof htmlOrNode === "string") {
|
|
272
|
+
let t = htmlOrNode;
|
|
273
|
+
t = SwcUtils2.processHtml(id, t, { document: document2, replaceWrap: { start: "<!--[[", end: "]]-->" }, replacer: (id2, script) => import_core_web.NodeSlot.slot(id2, script) });
|
|
274
|
+
t = SwcUtils2.processHtml(id, t, { document: document2, replaceWrap: { start: "<!--[html", end: "]-->" }, replacer: (id2, script) => import_core_web.ElementApply.html(id2, script) });
|
|
275
|
+
t = SwcUtils2.processHtml(id, t, { document: document2, replaceWrap: { start: "<!--[text", end: "]-->" }, replacer: (id2, script) => import_core_web.ElementApply.text(id2, script) });
|
|
276
|
+
t = SwcUtils2.processHtml(id, t, {
|
|
277
|
+
document: document2,
|
|
278
|
+
replaceWrap: { start: /a::\w+=\s*"/, end: /"\s/ },
|
|
279
|
+
replacer: (id2, script, er) => {
|
|
280
|
+
console.log("start: /a-->", er);
|
|
281
|
+
const match = er.expressionStart.match(/^\w+::(\w+)="/);
|
|
282
|
+
const name = match?.[1];
|
|
283
|
+
return import_core_web.ElementApply.attribute(id2, name, script);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
t = SwcUtils2.processHtml(id, t, {
|
|
287
|
+
document: document2,
|
|
288
|
+
replaceWrap: { start: /e::\w+=\s*"/, end: /"\s/ },
|
|
289
|
+
replacer: (id2, script, er) => {
|
|
290
|
+
console.log("start: /e-->", er);
|
|
291
|
+
const match = er.expressionStart.match(/^\w+::(\w+)="/);
|
|
292
|
+
const name = match?.[1];
|
|
293
|
+
return import_core_web.ElementApply.event(id2, name, script);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
t = SwcUtils2.processHtml(id, t, {
|
|
297
|
+
document: document2,
|
|
298
|
+
replaceWrap: { start: /p:\w+=\s*"/, end: /"\s/ },
|
|
299
|
+
replacer: (id2, script, er) => {
|
|
300
|
+
console.log("start: /p-->", er);
|
|
301
|
+
const match = er.expressionStart.match(/^\w+:(\w+)="/);
|
|
302
|
+
const name = match?.[1];
|
|
303
|
+
return import_core_web.ElementApply.property(id2, name, script);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return t;
|
|
307
|
+
} else if (htmlOrNode) {
|
|
308
|
+
const nodes = Array.isArray(htmlOrNode) ? htmlOrNode : [htmlOrNode];
|
|
309
|
+
const window2 = document2.defaultView;
|
|
310
|
+
nodes.forEach((node) => {
|
|
311
|
+
node.normalize();
|
|
312
|
+
const nodes2 = document2.createTreeWalker(node, window2.NodeFilter.SHOW_ELEMENT | window2.NodeFilter.SHOW_COMMENT);
|
|
313
|
+
const getSlotData = (s) => {
|
|
314
|
+
return s.match(/^\[\[([\s\S]+)\]\]$/)?.[1]?.trim();
|
|
315
|
+
};
|
|
316
|
+
const getHtmlData = (s) => {
|
|
317
|
+
return s.match(/^\[html([\s\S]+)\]$/)?.[1]?.trim();
|
|
318
|
+
};
|
|
319
|
+
const getTextData = (s) => {
|
|
320
|
+
return s.match(/^\[text([\s\S]+)\]$/)?.[1]?.trim();
|
|
321
|
+
};
|
|
322
|
+
while (nodes2.nextNode()) {
|
|
323
|
+
const currentNode = nodes2.currentNode;
|
|
324
|
+
if (currentNode.nodeType === window2.Node.COMMENT_NODE) {
|
|
325
|
+
const targetNode = currentNode;
|
|
326
|
+
const v = targetNode.data.trim();
|
|
327
|
+
const slotData = getSlotData(v);
|
|
328
|
+
const htmlData = getHtmlData(v);
|
|
329
|
+
const textData = getTextData(v);
|
|
330
|
+
if (v && slotData) {
|
|
331
|
+
const res = import_core_web.NodeSlot.slotIds(id, slotData);
|
|
332
|
+
targetNode.data = res.start;
|
|
333
|
+
const end = document2.createComment(res.end);
|
|
334
|
+
targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);
|
|
335
|
+
} else if (v && htmlData) {
|
|
336
|
+
const s = import_core_web.ElementApply.htmlDataSet(id, htmlData);
|
|
337
|
+
targetNode.data = s.start;
|
|
338
|
+
const end = document2.createComment(s.end);
|
|
339
|
+
targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);
|
|
340
|
+
} else if (v && textData) {
|
|
341
|
+
const s = import_core_web.ElementApply.textDataSet(id, textData);
|
|
342
|
+
const end = document2.createComment(s.end);
|
|
343
|
+
targetNode.data = s.start;
|
|
344
|
+
targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);
|
|
345
|
+
}
|
|
346
|
+
} else if (currentNode.nodeType === window2.Node.ELEMENT_NODE) {
|
|
347
|
+
const targetNode = currentNode;
|
|
348
|
+
targetNode.getAttributeNames().forEach((it) => {
|
|
349
|
+
const e = it.match(/e::(\w+)$/);
|
|
350
|
+
const eventName = e?.[1];
|
|
351
|
+
const p = it.match(/p::(\w+)$/);
|
|
352
|
+
const propertyName = p?.[1];
|
|
353
|
+
const a = it.match(/a::(\w+)$/);
|
|
354
|
+
const attributeName = a?.[1];
|
|
355
|
+
const value = targetNode.getAttribute(it);
|
|
356
|
+
if (eventName) {
|
|
357
|
+
targetNode.setAttribute(import_core_web.ElementApply.eventName(id, eventName), value);
|
|
358
|
+
targetNode.removeAttribute(it);
|
|
359
|
+
} else if (propertyName) {
|
|
360
|
+
targetNode.setAttribute(import_core_web.ElementApply.propertyName(id, propertyName), value);
|
|
361
|
+
targetNode.removeAttribute(it);
|
|
362
|
+
} else if (attributeName) {
|
|
363
|
+
targetNode.setAttribute(import_core_web.ElementApply.attributeName(id, attributeName), value);
|
|
364
|
+
targetNode.removeAttribute(it);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
return nodes;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
SwcUtils2.projectProcessHtml = projectProcessHtml;
|
|
374
|
+
function processHtml(id, html2, config) {
|
|
375
|
+
const replaceStart = config.replaceWrap.start;
|
|
376
|
+
const replaceEnd = config.replaceWrap.end;
|
|
377
|
+
const callReturnStart = `${config.replaceWrap.start}=`;
|
|
378
|
+
const callReturnEnd = `${config.replaceWrap.end}`;
|
|
379
|
+
const callStart = `${config.replaceWrap.start}@`;
|
|
380
|
+
const callEnd = `${config.replaceWrap.end}`;
|
|
381
|
+
const hasPattern = (text, start, end) => {
|
|
382
|
+
if (!text) return false;
|
|
383
|
+
const s = text.indexOf(start);
|
|
384
|
+
const e = text.indexOf(end, s + start.length);
|
|
385
|
+
return s !== -1 && e !== -1 && s < e;
|
|
386
|
+
};
|
|
387
|
+
const actionConfig = { expression: { replace: { start: replaceStart, end: replaceEnd }, callReturn: { start: callReturnStart, end: callReturnEnd }, call: { start: callStart, end: callEnd } } };
|
|
388
|
+
const runActionExpression = (source) => {
|
|
389
|
+
const actionExpression = new import_core.ActionExpression(source, actionConfig);
|
|
390
|
+
actionExpression.getExpressions().filter((it) => it.type === "replace").forEach((it) => {
|
|
391
|
+
actionExpression.replace(it, config.replacer(id, it.script?.trim(), it));
|
|
392
|
+
});
|
|
393
|
+
return actionExpression.toResult();
|
|
394
|
+
};
|
|
395
|
+
return runActionExpression(html2);
|
|
396
|
+
}
|
|
397
|
+
SwcUtils2.processHtml = processHtml;
|
|
256
398
|
SwcUtils2.getAppHosts = (el) => {
|
|
257
399
|
const hosts = SwcUtils2.findAllAppHostsIncludingSelfDirect(el);
|
|
258
400
|
return hosts;
|
|
@@ -315,7 +457,7 @@ var SwcUtils;
|
|
|
315
457
|
$hosts,
|
|
316
458
|
$firstHost,
|
|
317
459
|
$lastHost: $host,
|
|
318
|
-
$templateHost: el.__swc_template_host,
|
|
460
|
+
// $templateHost: (el as any).__swc_template_host,
|
|
319
461
|
$appHost,
|
|
320
462
|
$appHosts,
|
|
321
463
|
$firstAppHost,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/Utils.ts"],
|
|
4
|
-
"sourcesContent": ["import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';\nimport {getElementConfig} from \"../decorators\";\nimport { getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult } from '@dooboostore/core';\nimport {Router} from \"@dooboostore/core-web\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n// DOM Creation Utilities\nexport const htmlFragment = (html: string, doc?: Document): DocumentFragment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const template = d.createElement('template');\n template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport const createElement = <T extends HTMLElement>(\n tagName: string,\n options?: { html?: string; attrs?: Record<string, any>; doc?: Document }\n): T => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(tagName) as T;\n if (options?.html) el.innerHTML = options.html;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n\n\n export const getParentContainer = (e: Node) => {\n return e.parentElement ?? e.getRootNode() as any;\n }\n\n export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {\n return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/\"/g, \"'\");\n }\n\n export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {\n // if (!path) {\n // return;\n // }\n urlAndRouter ??= '/'\n const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;\n const searchParams = new URLSearchParams();\n const qs = p.split('?')[1];\n qs?.split('&').forEach(it => {\n const [k, v] = it.split('=');\n searchParams.set(k,v);\n })\n return {\n path: p,\n searchParams,\n pathData: SwcUtils.parsePathPatterns(pathPattern, p)\n };\n };\n export const parsePathPatterns = (pathPattern: string[], path: string) => {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, path || '/');\n if (data !== null) {\n return data;\n }\n }\n };\n\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet,\n $this: el,\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHostIncludingSelf = (el: HTMLElement | Node): HTMLElement | undefined => {\n const el1 = el as any;\n if (el1.__swc_host) return el1.__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHostIncludingSelf(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHostIncludingSelf(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHostsIncludingSelf(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHostIncludingSelf(el);\n };\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n // const hosts = getHosts(el);\n // return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const hosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n return hosts;\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n /**\n * Find the closest app host by traversing DOM tree directly, including the element itself.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAppHostIncludingSelfDirect = (el: HTMLElement): SwcAppInterface | null => {\n const appHosts = findAllAppHostsIncludingSelfDirect(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;\n };\n\n /**\n * Find all app hosts by traversing DOM tree directly, including the element itself.\n * Returns array of all app hosts in [root, ..., closest-parent-or-self] order.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAllAppHostsIncludingSelfDirect = (el: HTMLElement): SwcAppInterface[] => {\n const appHosts: SwcAppInterface[] = [];\n\n const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // Guard against SSR environment where window might be undefined\n if (!w) {\n return appHosts;\n }\n\n // console.log('------?',w.ShadowRoot);\n // el \uC790\uCCB4\uBD80\uD130 \uC2DC\uC791 (el\uC774 app host\uC77C \uC218\uB3C4 \uC788\uC74C)\n let current: HTMLElement | null = el;\n\n while (current) {\n const isAppHost =\n current.tagName.toLowerCase() === 'swc-app' ||\n current.getAttribute('is')?.startsWith('swc-app-');\n if (isAppHost) {\n appHosts.push(current as SwcAppInterface);\n }\n\n // \uB2E4\uC74C \uBD80\uBAA8 \uCC3E\uAE30\n if (current.parentElement) {\n // Light DOM: \uC815\uC0C1\uC801\uC778 \uBD80\uBAA8 \uC694\uC18C\n current = current.parentElement;\n } else {\n // parentElement\uAC00 \uC5C6\uC74C = Shadow root\uC758 \uC9C1\uC811 \uC790\uC2DD\uC77C \uC218 \uC788\uC74C\n const root = current.getRootNode();\n if (w.ShadowRoot && root instanceof w.ShadowRoot) {\n // Shadow host\uB85C \uC62C\uB77C\uAC00\uAE30\n current = (root as ShadowRoot).host as HTMLElement;\n } else {\n // Document root \uB3C4\uB2EC\n break;\n }\n }\n }\n return appHosts.reverse(); // [root, ..., closest-parent-or-self]\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const ancestors = findAllSwcHostsIncludingSelf(el); // [root, ..., parent]\n \n const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n const $hosts = ancestors;\n const $firstHost = ancestors.length > 0 ? ancestors[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $host,\n $templateHost: (el as any).__swc_template_host,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n \n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n \n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n \n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n \n if (!match) return null;\n \n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n \n return result;\n };\n\n\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,wBAA+B;AAIxB,MAAM,gBAAgB,OAAO,IAAI,gCAAgC;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CAACC,QAAO,WAAW,gBAAgB;AACpG,iBAAW,KAAK,SAAS;AAEzB,aAAO,IAAI,eAAe,OAAO;AAAA,IACnC,CAAC;AAED,UAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAC5C,UAAM,QAAQ,YAAY,MAAM,KAAK;AAErC,QAAI,CAAC,MAAO,QAAO;AAEnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,QAAQ,CAAC,MAAM,UAAU;AAClC,aAAO,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,IAChC,CAAC;AAED,WAAO;AAAA,EACT;AAAA,GA/Pe;AAkQhB;",
|
|
6
|
-
"names": ["SwcUtils", "match"]
|
|
4
|
+
"sourcesContent": ["import {SwcAppInterface, HostSet, HelperSet, HelperHostSet} from '../types';\nimport {getElementConfig} from \"../decorators\";\nimport {getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult, ActionExpression} from '@dooboostore/core';\nimport {ElementApply, NodeSlot, Router} from \"@dooboostore/core-web\";\n\nexport const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');\n\n\nexport const html = (str: string, document: Document) => {\n return [...document.createRange().createContextualFragment(str).childNodes];\n}\n// DOM Creation Utilities\nexport const htmlFragment = (html: string | Node | Node[], doc: Document): DocumentFragment => {\n if (!doc) throw new Error('Document is not available');\n const template = doc.createElement('template');\n if (typeof html === 'string') {\n template.innerHTML = html.trim();\n } else if (html instanceof Node) {\n template.appendChild(html);\n } else if (Array.isArray(html)) {\n template.append(...html);\n }\n // template.innerHTML = html.trim();\n return template.content;\n};\n\nexport const textNode = (text: string | any, doc?: Document): Text => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createTextNode(text !== undefined && text !== null ? String(text) : '');\n};\n\nexport const commentNode = (comment: string | any, doc?: Document): Comment => {\n const d = doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n return d.createComment(comment !== undefined && comment !== null ? String(comment) : '');\n};\n\nexport type CreateElementConfig = { innerHtml?: string; property?: Record<string, any>, attrs?: Record<string, any>; };\nexport const createElement = <T extends HTMLElement>(\n documentOrWindow: Document | Window,\n tagName: string,\n options?: CreateElementConfig\n): T => {\n const doc = 'document' in documentOrWindow ? documentOrWindow.document : documentOrWindow;\n if (!doc) throw new Error('Document is not available');\n const el = doc.createElement(tagName) as T;\n if (options?.innerHtml) el.innerHTML = options.innerHtml;\n if (options?.attrs) {\n Object.entries(options.attrs).filter(([k,v])=>v).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n if (options?.property) {\n Object.entries(options.property).forEach(([k, v]) => el[k] = v);\n }\n return el;\n};\n\n// Element factory functions\nexport const htmlDivElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLDivElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('div') as HTMLDivElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSpanElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLSpanElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('span') as HTMLSpanElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlButtonElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLButtonElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('button') as HTMLButtonElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlUlElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLUListElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('ul') as HTMLUListElement;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlLiElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLLIElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('li') as HTMLLIElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlAElement = (html: string, options?: { href?: string; doc?: Document; attrs?: Record<string, any> }): HTMLAnchorElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('a') as HTMLAnchorElement;\n el.innerHTML = html.trim();\n if (options?.href) el.href = options.href;\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlPElement = (html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLParagraphElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('p') as HTMLParagraphElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlHeadingElement = (level: 1 | 2 | 3 | 4 | 5 | 6, html: string, options?: { doc?: Document; attrs?: Record<string, any> }): HTMLHeadingElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement(`h${level}`) as HTMLHeadingElement;\n el.innerHTML = html.trim();\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlSectionElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('section');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<string, any> }): HTMLElement => {\n const d = options?.doc || (typeof document !== 'undefined' ? document : undefined);\n if (!d) throw new Error('Document is not available');\n const el = d.createElement('article');\n if (options?.attrs) {\n Object.entries(options.attrs).forEach(([k, v]) => el.setAttribute(k, String(v)));\n }\n return el;\n};\n\nexport namespace SwcUtils {\n\n\n export const getParentContainer = (e: Node) => {\n return e.parentElement ?? e.getRootNode() as any;\n }\n\n export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {\n return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/\"/g, \"'\");\n }\n\n export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {\n // if (!path) {\n // return;\n // }\n urlAndRouter ??= '/'\n const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;\n const searchParams = new URLSearchParams();\n const qs = p.split('?')[1];\n qs?.split('&').forEach(it => {\n const [k, v] = it.split('=');\n searchParams.set(k, v);\n })\n return {\n path: p,\n searchParams,\n pathData: SwcUtils.parsePathPatterns(pathPattern, p)\n };\n };\n export const parsePathPatterns = (pathPattern: string[], path: string) => {\n for (const pattern of pathPattern) {\n const data = SwcUtils.parsePathPattern(pattern, path || '/');\n if (data !== null) {\n return data;\n }\n }\n };\n\n export const getHelperSet = (win: Window): HelperSet => {\n const doc: Document = win.document;\n return {\n $d: doc,\n $w: win,\n $q: (sel: string, root?: Element | Document | ShadowRoot) => (root ?? doc).querySelector(sel),\n $qa: (sel: string, root?: Element | Document | ShadowRoot) => Array.from((root ?? doc).querySelectorAll(sel)) as HTMLElement[],\n $qi: (id: string, root?: Document | ShadowRoot) => (root ?? doc).getElementById(id) as HTMLElement\n } as const;\n };\n\n export const getHelperAndHostSet = (win: Window, el: HTMLElement): HelperHostSet => {\n const helperSet = getHelperSet(win);\n const hostSet = getHostSet(el);\n return {\n ...helperSet,\n ...hostSet,\n $this: el,\n };\n };\n\n export const getValueByPath = (obj: any, path: string, rootName: string) => {\n if (!obj || !path) return SWC_NOT_FOUND;\n\n const parts = path.split('.');\n let current = obj;\n\n for (const part of parts) {\n if (current === null || current === undefined) return SWC_NOT_FOUND;\n current = current[part];\n }\n return current;\n };\n\n /**\n * Finds the nearest logical SWC host for an element.\n * Checks __swc_host property first, then climbs the DOM tree.\n */\n export const findNearestSwcHostIncludingSelf = (el: HTMLElement | Node): HTMLElement | undefined => {\n const el1 = el as any;\n if (el1.__swc_host) return el1.__swc_host;\n\n let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;\n const doc = el.ownerDocument;\n const win = doc?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n while (current && current !== doc && current !== win) {\n if (current.__swc_host) return current.__swc_host;\n if (getElementConfig(current)) return current as HTMLElement;\n current = current.parentElement || (current.getRootNode?.() as any)?.host;\n }\n return undefined;\n };\n\n /**\n * Returns all SWC ancestors (excluding self) in [root, ..., parent] order.\n */\n export const findAllSwcHostsIncludingSelf = (el: HTMLElement | Node): HTMLElement[] => {\n const hosts: HTMLElement[] = [];\n let current = findNearestSwcHostIncludingSelf(el);\n while (current) {\n hosts.push(current);\n // To find the next ancestor, we must start searching from the PARENT of the found host\n current = findNearestSwcHostIncludingSelf(current);\n }\n return hosts.reverse();\n };\n\n export const getHosts = (el: HTMLElement): HTMLElement[] => {\n const ancestors = findAllSwcHostsIncludingSelf(el);\n if (getElementConfig(el)) return [...ancestors, el];\n return ancestors;\n };\n\n export const getHost = (el: HTMLElement): HTMLElement | undefined => {\n if (getElementConfig(el)) return el;\n return findNearestSwcHostIncludingSelf(el);\n };\n\n\n export function projectProcessHtml(id: string, htmlOrNode: string, document: Document): string;\n export function projectProcessHtml(id: string, htmlOrNode: ((Node)[]) | Node, document: Document): (Node)[];\n export function projectProcessHtml(id: string, htmlOrNode: string | ((Node)[]) | Node, document: Document): string | (Node)[] {\n if (typeof htmlOrNode === 'string') {\n // slot\n let t = htmlOrNode;\n // if (!config?.excludeSlot) {\n t = SwcUtils.processHtml(id, t, {document: document, replaceWrap: {start: '<!--[[', end: ']]-->'}, replacer: (id, script) => NodeSlot.slot(id, script)});\n // }\n // if (!config?.excludeHtml) {\n // Ea html\n t = SwcUtils.processHtml(id, t, {document: document, replaceWrap: {start: '<!--[html', end: ']-->'}, replacer: (id, script) => ElementApply.html(id, script)});\n // }\n\n // if (!config?.excludeText) {\n // Ea text\n t = SwcUtils.processHtml(id, t, {document: document, replaceWrap: {start: '<!--[text', end: ']-->'}, replacer: (id, script) => ElementApply.text(id, script)});\n // }\n\n // if (!config.excludeAttribute) {\n // Ea attribute\n t = SwcUtils.processHtml(id, t, {\n document: document,\n replaceWrap: {start: /a::\\w+=\\s*\"/, end: /\"\\s/}, replacer: (id, script, er) => {\n console.log('start: /a-->', er)\n const match = er.expressionStart.match(/^\\w+::(\\w+)=\"/)\n const name = match?.[1];\n return ElementApply.attribute(id, name, script)\n }\n });\n // }\n\n // if (!config.excludeEvent) {\n t = SwcUtils.processHtml(id, t, {\n document: document,\n replaceWrap: {start: /e::\\w+=\\s*\"/, end: /\"\\s/}, replacer: (id, script, er) => {\n console.log('start: /e-->', er)\n const match = er.expressionStart.match(/^\\w+::(\\w+)=\"/)\n const name = match?.[1];\n return ElementApply.event(id, name, script)\n }\n });\n // }\n\n\n // if (!config.excludeProperty) {\n t = SwcUtils.processHtml(id, t, {\n document: document,\n replaceWrap: {start: /p:\\w+=\\s*\"/, end: /\"\\s/}, replacer: (id, script, er) => {\n console.log('start: /p-->', er)\n const match = er.expressionStart.match(/^\\w+:(\\w+)=\"/)\n const name = match?.[1];\n return ElementApply.property(id, name, script)\n }\n });\n return t;\n } else if (htmlOrNode) {\n\n // \uC544\uB798 node\uC77C\uB584\uB3C4 \uCC98\uB9AC\uD558\uB3C4\uB85D \uB9CC\uB4EC \uC544\uC9C1\uD14C\uC2A4\uD2B8\uB294 \uC548\uD574\uBD04 \uD14C\uC2A4\uD2B8\uD6C4 \uC8FC\uC11D\uC9C0\uC6B8\uAC83.\n const nodes = Array.isArray(htmlOrNode) ? htmlOrNode : [htmlOrNode];\n const window = document.defaultView;\n nodes.forEach(node => {\n // TextNode \uD569\uCE58\uAE30\n node.normalize();\n const nodes = document.createTreeWalker(node, window.NodeFilter.SHOW_ELEMENT | window.NodeFilter.SHOW_COMMENT)\n\n const getSlotData = (s: string) => {\n return s.match(/^\\[\\[([\\s\\S]+)\\]\\]$/)?.[1]?.trim();\n }\n const getHtmlData = (s: string) => {\n return s.match(/^\\[html([\\s\\S]+)\\]$/)?.[1]?.trim();\n // return s.startsWith('[html') && s.endsWith(']');\n }\n const getTextData = (s: string) => {\n return s.match(/^\\[text([\\s\\S]+)\\]$/)?.[1]?.trim();\n // return s.startsWith('[text') && s.endsWith(']');\n }\n while (nodes.nextNode()) {\n const currentNode = nodes.currentNode;\n if (currentNode.nodeType === window.Node.COMMENT_NODE) {\n const targetNode = currentNode as Comment;\n const v = targetNode.data.trim();\n const slotData = getSlotData(v);\n const htmlData = getHtmlData(v);\n const textData = getTextData(v);\n if (v && slotData) {\n const res = NodeSlot.slotIds(id, slotData)\n targetNode.data = res.start;\n const end = document.createComment(res.end)\n targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);\n // document.createTe\n\n } else if (v && htmlData) {\n const s = ElementApply.htmlDataSet(id, htmlData);\n targetNode.data = s.start;\n const end = document.createComment(s.end)\n targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);\n } else if (v && textData) {\n const s = ElementApply.textDataSet(id, textData);\n const end = document.createComment(s.end)\n targetNode.data = s.start;\n targetNode.parentNode?.insertBefore(end, targetNode.nextSibling);\n }\n\n } else if (currentNode.nodeType === window.Node.ELEMENT_NODE) {\n const targetNode = currentNode as Element;\n targetNode.getAttributeNames().forEach(it => {\n const e = it.match(/e::(\\w+)$/);\n const eventName = e?.[1];\n const p = it.match(/p::(\\w+)$/);\n const propertyName = p?.[1];\n const a = it.match(/a::(\\w+)$/);\n const attributeName = a?.[1];\n\n const value = targetNode.getAttribute(it);\n if (eventName) {\n targetNode.setAttribute(ElementApply.eventName(id, eventName), value);\n targetNode.removeAttribute(it);\n } else if (propertyName) {\n targetNode.setAttribute(ElementApply.propertyName(id, propertyName), value);\n targetNode.removeAttribute(it);\n } else if (attributeName) {\n targetNode.setAttribute(ElementApply.attributeName(id, attributeName), value);\n targetNode.removeAttribute(it);\n }\n })\n }\n }\n\n })\n\n return nodes;\n }\n // }\n\n\n }\n\n // export function processHtml(id: string, htmlOrNode: string, config: { document: Document, replaceWrap: { start: string | RegExp, end: string | RegExp }, replacer: (id: string, script: string, er: ExpressionResult) => string }): string;\n // export function processHtml(id: string, htmlOrNode: (Node | string)[], config: { document: Document, replaceWrap: { start: string | RegExp, end: string | RegExp }, replacer: (id: string, script: string, er: ExpressionResult) => string }): (Node | string)[] ;\n export function processHtml(\n id: string,\n html: string,\n config: { document: Document, replaceWrap: { start: string | RegExp, end: string | RegExp }, replacer: (id: string, script: string, er: ExpressionResult) => string }\n ): string {\n const replaceStart = config.replaceWrap.start;\n const replaceEnd = config.replaceWrap.end;\n const callReturnStart = `${config.replaceWrap.start}=`;\n const callReturnEnd = `${config.replaceWrap.end}`;\n const callStart = `${config.replaceWrap.start}@`;\n const callEnd = `${config.replaceWrap.end}`;\n const hasPattern = (text: string | null | undefined, start: string, end: string) => {\n if (!text) return false;\n const s = text.indexOf(start);\n const e = text.indexOf(end, s + start.length);\n return s !== -1 && e !== -1 && s < e;\n };\n\n const actionConfig: GetExpressionConfig = {expression: {replace: {start: replaceStart, end: replaceEnd}, callReturn: {start: callReturnStart, end: callReturnEnd}, call: {start: callStart, end: callEnd}}};\n const runActionExpression = (source: string) => {\n const actionExpression = new ActionExpression(source, actionConfig);\n actionExpression.getExpressions().filter(it => it.type === 'replace').forEach(it => {\n actionExpression.replace(it, config.replacer(id, it.script?.trim(), it));\n });\n return actionExpression.toResult();\n };\n\n return runActionExpression(html);\n // if (typeof html === 'string') {\n // } else {\n // }\n }\n\n export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {\n // const hosts = getHosts(el);\n // return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];\n const hosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n return hosts;\n };\n\n export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {\n const appHosts = getAppHosts(el);\n const appHostsWithoutSelf = appHosts.filter(h => h !== el);\n return appHostsWithoutSelf.length > 0 ? appHostsWithoutSelf[appHostsWithoutSelf.length - 1] : undefined;\n };\n\n /**\n * Find the closest app host by traversing DOM tree directly, including the element itself.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAppHostIncludingSelfDirect = (el: HTMLElement): SwcAppInterface | null => {\n const appHosts = findAllAppHostsIncludingSelfDirect(el);\n return appHosts.length > 0 ? appHosts[appHosts.length - 1] : null;\n };\n\n /**\n * Find all app hosts by traversing DOM tree directly, including the element itself.\n * Returns array of all app hosts in [root, ..., closest-parent-or-self] order.\n * Only checks tagName and is attribute - no SWC host discovery.\n * Useful for Safari polyfill compatibility where is=\"\" elements upgrade in child-first order.\n */\n export const findAllAppHostsIncludingSelfDirect = (el: HTMLElement): SwcAppInterface[] => {\n const appHosts: SwcAppInterface[] = [];\n\n const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);\n\n // Guard against SSR environment where window might be undefined\n if (!w) {\n return appHosts;\n }\n\n // console.log('------?',w.ShadowRoot);\n // el \uC790\uCCB4\uBD80\uD130 \uC2DC\uC791 (el\uC774 app host\uC77C \uC218\uB3C4 \uC788\uC74C)\n let current: HTMLElement | null = el;\n\n while (current) {\n const isAppHost =\n current.tagName.toLowerCase() === 'swc-app' ||\n current.getAttribute('is')?.startsWith('swc-app-');\n if (isAppHost) {\n appHosts.push(current as SwcAppInterface);\n }\n\n // \uB2E4\uC74C \uBD80\uBAA8 \uCC3E\uAE30\n if (current.parentElement) {\n // Light DOM: \uC815\uC0C1\uC801\uC778 \uBD80\uBAA8 \uC694\uC18C\n current = current.parentElement;\n } else {\n // parentElement\uAC00 \uC5C6\uC74C = Shadow root\uC758 \uC9C1\uC811 \uC790\uC2DD\uC77C \uC218 \uC788\uC74C\n const root = current.getRootNode();\n if (w.ShadowRoot && root instanceof w.ShadowRoot) {\n // Shadow host\uB85C \uC62C\uB77C\uAC00\uAE30\n current = (root as ShadowRoot).host as HTMLElement;\n } else {\n // Document root \uB3C4\uB2EC\n break;\n }\n }\n }\n return appHosts.reverse(); // [root, ..., closest-parent-or-self]\n };\n\n export const getHostSet = (el: HTMLElement): HostSet => {\n const ancestors = findAllSwcHostsIncludingSelf(el); // [root, ..., parent]\n\n const $host = ancestors.length > 0 ? ancestors[ancestors.length - 1] : null;\n const $parentHost = ancestors.length > 1 ? ancestors[ancestors.length - 2] : null;\n const $hosts = ancestors;\n const $firstHost = ancestors.length > 0 ? ancestors[0] : null;\n\n // Collect loop contexts\n const loopContext: Record<string, any> = {};\n let curr: any = el;\n const rootEl = el.ownerDocument?.documentElement;\n while (curr && curr !== rootEl) {\n if (curr.__swc_loop_context) {\n Object.assign(loopContext, curr.__swc_loop_context);\n }\n curr = curr.parentElement || (curr.getRootNode() as any).host;\n }\n\n const $appHosts = SwcUtils.findAllAppHostsIncludingSelfDirect(el);\n const $appHost = $appHosts.length > 0 ? ($appHosts[$appHosts.length - 1] === el ? ($appHosts.length > 1 ? $appHosts[$appHosts.length - 2] : null) : $appHosts[$appHosts.length - 1]) : null;\n const $firstAppHost = $appHosts.length > 0 ? $appHosts[0] : null;\n\n return {\n $host,\n $parentHost,\n $hosts,\n $firstHost,\n $lastHost: $host,\n // $templateHost: (el as any).__swc_template_host,\n $appHost,\n $appHosts,\n $firstAppHost,\n $lastAppHost: $appHost,\n ...loopContext\n } as any;\n };\n\n export const parsePathPattern = (pattern: string | undefined, currentPath: string): { [key: string]: string } | null => {\n // pattern\uC774 null/undefined\uBA74 \uC640\uC77C\uB4DC\uCE74\uB4DC (\uBAA8\uB4E0 \uACBD\uB85C \uB9E4\uCE6D)\n if (pattern === null || pattern === undefined) return {};\n\n // \uACF5\uBC31\uB9CC \uC788\uB294 \uD328\uD134\uB3C4 \uC640\uC77C\uB4DC\uCE74\uB4DC\n const trimmedPattern = pattern.trim();\n if (trimmedPattern === '' && pattern !== '') return {}; // \uACF5\uBC31 \uBB38\uC790\uB9CC \uC788\uB294 \uACBD\uC6B0\n\n // \uD328\uD134\uC744 \uC815\uADDC\uC2DD\uC73C\uB85C \uBCC0\uD658\n // \uC9C0\uC6D0 \uD615\uC2DD:\n // {id} \u2192 ([^/]+) \uAE30\uBCF8 (/ \uC81C\uC678\uD55C \uBAA8\uB4E0 \uBB38\uC790)\n // {tail:.*} \u2192 (.*) \uC815\uADDC\uD45C\uD604\uC2DD \uC9C1\uC811 \uC9C0\uC815\n // {slug:[a-z0-9-]+} \u2192 ([a-z0-9-]+)\n const paramNames: string[] = [];\n const regexPattern = trimmedPattern.replace(/{(\\w+)(?::(.+?))?}/g, (match, paramName, customRegex) => {\n paramNames.push(paramName);\n // customRegex\uAC00 \uC788\uC73C\uBA74 \uC0AC\uC6A9, \uC5C6\uC73C\uBA74 \uAE30\uBCF8\uAC12 ([^/]+)\n return `(${customRegex || '[^/]+'})`;\n });\n\n const regex = new RegExp(`^${regexPattern}$`);\n const match = currentPath.match(regex);\n\n if (!match) return null;\n\n const result: { [key: string]: string } = {};\n paramNames.forEach((name, index) => {\n result[name] = match[index + 1];\n });\n\n return result;\n };\n\n\n}\n;\n"],
|
|
5
|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IAAI,UAAU,UAAU,SAAS,CAAC,IAAI,OAAQ,UAAU,UAAU,SAAS,CAAC,IAAK;AACvL,UAAM,gBAAgB,UAAU,SAAS,IAAI,UAAU,CAAC,IAAI;AAE5D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW;AAAA;AAAA,MAEX;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd,GAAG;AAAA,IACL;AAAA,EACF;AAEO,EAAMA,UAAA,mBAAmB,CAAC,SAA6B,gBAA0D;AAEtH,QAAI,YAAY,QAAQ,YAAY,OAAW,QAAO,CAAC;AAGvD,UAAM,iBAAiB,QAAQ,KAAK;AACpC,QAAI,mBAAmB,MAAM,YAAY,GAAI,QAAO,CAAC;AAOrD,UAAM,aAAuB,CAAC;AAC9B,UAAM,eAAe,eAAe,QAAQ,uBAAuB,CAACI,QAAO,WAAW,gBAAgB;AACpG,iBAAW,KAAK,SAAS;AAEzB,aAAO,IAAI,eAAe,OAAO;AAAA,IACnC,CAAC;AAED,UAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAC5C,UAAM,QAAQ,YAAY,MAAM,KAAK;AAErC,QAAI,CAAC,MAAO,QAAO;AAEnB,UAAM,SAAoC,CAAC;AAC3C,eAAW,QAAQ,CAAC,MAAM,UAAU;AAClC,aAAO,IAAI,IAAI,MAAM,QAAQ,CAAC;AAAA,IAChC,CAAC;AAED,WAAO;AAAA,EACT;AAAA,GA7ae;AAibjB;",
|
|
6
|
+
"names": ["document", "html", "SwcUtils", "id", "window", "nodes", "match"]
|
|
7
7
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { SimpleApplication } from "@dooboostore/simple-boot
|
|
4
|
+
import { SimpleApplication } from "@dooboostore/simple-boot";
|
|
5
5
|
import { HashRouter, PathRouter, Router } from "@dooboostore/core-web";
|
|
6
|
-
import { ElementRouter } from "
|
|
7
|
-
import { SimOption } from "@dooboostore/simple-boot
|
|
6
|
+
import { ElementRouter } from "./router/ElementRouter.js";
|
|
7
|
+
import { SimOption } from "@dooboostore/simple-boot";
|
|
8
8
|
class SwcAppEngine {
|
|
9
9
|
constructor(host) {
|
|
10
10
|
this.host = host;
|
|
@@ -38,8 +38,11 @@ class SwcAppEngine {
|
|
|
38
38
|
});
|
|
39
39
|
if (this.router) otherInstanceSim.set(Router, this.router);
|
|
40
40
|
this.simpleApplication.run(otherInstanceSim);
|
|
41
|
+
if (this._config.onStartedLazyDefineComponent) {
|
|
42
|
+
await Promise.all(this._config.onStartedLazyDefineComponent.map((it) => it(this._config.window)));
|
|
43
|
+
}
|
|
41
44
|
if (this._config.onEngineStarted) {
|
|
42
|
-
this._config.onEngineStarted(this.simpleApplication, this.host);
|
|
45
|
+
await this._config.onEngineStarted(this.simpleApplication, this.host);
|
|
43
46
|
}
|
|
44
47
|
} catch (e) {
|
|
45
48
|
console.error("[SWC-APP-ENGINE] Init failed:", e, this._config);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/SwcAppEngine.ts"],
|
|
4
|
+
"sourcesContent": ["import { SimpleApplication } from '@dooboostore/simple-boot';\nimport { HashRouter, PathRouter, Router, RouterEventType } from '@dooboostore/core-web';\nimport { ElementRouter } from './router/ElementRouter';\nimport { SimOption } from '@dooboostore/simple-boot';\nimport { ConstructorType, OptionalType, Subscription } from '@dooboostore/core';\nimport { SwcAppInterface } from './types';\nimport { SimConfig } from '@dooboostore/simple-boot';\n\nexport type SwcConfigType = {\n routeType: 'path' | 'hash' | 'element';\n // connectMode?: 'direct' | 'swap' | 'clear-swap'; // hydrate \uC544\uC9C1 \uAC1C\uBC1C\uC911\n container?: symbol;\n otherInstanceSim?: Map<ConstructorType<any> | Function | SimConfig | symbol, any>;\n path?: string;\n window: Window;\n onEngineStarted?: (sp: SimpleApplication, app: SwcAppInterface) => Promise<void> | void;\n onConnectedChildAfter?: (swcEl: HTMLElement) => void;\n onConnectedChildBefore?: (swcEl: HTMLElement) => void;\n onDisconnectedChildAfter?: (swcEl: HTMLElement) => void;\n onDisconnectedChildBefore?: (swcEl: HTMLElement) => void;\n onConnected?: (app: SwcAppInterface) => void;\n onDisconnected?: (app: SwcAppInterface) => void;\n ssr?: boolean;\n onStartedLazyDefineComponent?: ((w: Window)=> Promise<CustomElementConstructor> | void | string | any | CustomElementConstructor)[];\n\n onChildrenConnectedDone?: (app: SwcAppInterface) => void;\n // onChildrenSwcAppStartedDone?: (app: SwcAppInterface) => void;\n // childrenSwcAppStartedDoneCheckIntervalTime?: number;\n onChildrenRouteChanged?: (event: RouterEventType, app: SwcAppInterface) => void;\n childrenRouteChangedCheckIntervalTime?: number; // \uC790\uC2DD \uC5F0\uACB0 \uC644\uB8CC \uC774\uBCA4\uD2B8 \uB514\uBC14\uC6B4\uC2A4 \uD0C0\uC784 (ms)\n childrenConnectedDoneCheckIntervalTime?: number;\n};\n\nexport type SwcAttributeConfigType = OptionalType<SwcConfigType, 'routeType' | 'window'>;\n\nexport class SwcAppEngine {\n public simpleApplication?: SimpleApplication;\n public router?: Router;\n private routerSubscription?: Subscription;\n private _config?: SwcConfigType;\n\n constructor(private host: HTMLElement) {}\n\n get config() {\n return this._config;\n }\n\n async connect(config: SwcConfigType) {\n try {\n this._config = config;\n\n // Router Selection\n if (this._config.routeType === 'path') {\n this.router = new PathRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'hash') {\n this.router = new HashRouter({ window: this._config.window, firstUrl: this._config.path });\n } else if (this._config.routeType === 'element') {\n this.router = new ElementRouter({ window: this._config.window, firstUrl: this._config.path });\n }\n\n // console.log('vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv', this.router)\n\n // App start\n this.simpleApplication = new SimpleApplication(\n new SimOption({\n excludeProxys: [(this._config.window as any).Node],\n container: this._config.container\n })\n );\n\n const otherInstanceSim = new Map<any, any>();\n this.config?.otherInstanceSim?.forEach((v, k) => {\n otherInstanceSim.set(k, v);\n });\n if (this.router) otherInstanceSim.set(Router, this.router);\n this.simpleApplication.run(otherInstanceSim);\n\n\n if (this._config.onStartedLazyDefineComponent) {\n await Promise.all(this._config.onStartedLazyDefineComponent.map(it => it(this._config.window)))\n }\n if (this._config.onEngineStarted) {\n await this._config.onEngineStarted(this.simpleApplication, this.host as unknown as SwcAppInterface);\n }\n } catch (e) {\n console.error('[SWC-APP-ENGINE] Init failed:', e, this._config);\n }\n }\n\n disconnect() {\n this.routerSubscription?.unsubscribe();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;AAAA,SAAS,yBAAyB;AAClC,SAAS,YAAY,YAAY,cAA+B;AAChE,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAgCnB,MAAM,aAAa;AAAA,EAMxB,YAAoB,MAAmB;AAAnB;AALpB,wBAAO;AACP,wBAAO;AACP,wBAAQ;AACR,wBAAQ;AAAA,EAEgC;AAAA,EAExC,IAAI,SAAS;AACX,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAM,QAAQ,QAAuB;AACnC,QAAI;AACF,WAAK,UAAU;AAGf,UAAI,KAAK,QAAQ,cAAc,QAAQ;AACrC,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,QAAQ;AAC5C,aAAK,SAAS,IAAI,WAAW,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC3F,WAAW,KAAK,QAAQ,cAAc,WAAW;AAC/C,aAAK,SAAS,IAAI,cAAc,EAAE,QAAQ,KAAK,QAAQ,QAAQ,UAAU,KAAK,QAAQ,KAAK,CAAC;AAAA,MAC9F;AAKA,WAAK,oBAAoB,IAAI;AAAA,QAC3B,IAAI,UAAU;AAAA,UACZ,eAAe,CAAE,KAAK,QAAQ,OAAe,IAAI;AAAA,UACjD,WAAW,KAAK,QAAQ;AAAA,QAC1B,CAAC;AAAA,MACH;AAEA,YAAM,mBAAmB,oBAAI,IAAc;AAC3C,WAAK,QAAQ,kBAAkB,QAAQ,CAAC,GAAG,MAAM;AAC/C,yBAAiB,IAAI,GAAG,CAAC;AAAA,MAC3B,CAAC;AACD,UAAI,KAAK,OAAQ,kBAAiB,IAAI,QAAQ,KAAK,MAAM;AACzD,WAAK,kBAAkB,IAAI,gBAAgB;AAG3C,UAAI,KAAK,QAAQ,8BAA8B;AAC7C,cAAM,QAAQ,IAAI,KAAK,QAAQ,6BAA6B,IAAI,QAAM,GAAG,KAAK,QAAQ,MAAM,CAAC,CAAC;AAAA,MAChG;AACA,UAAI,KAAK,QAAQ,iBAAiB;AAChC,cAAM,KAAK,QAAQ,gBAAgB,KAAK,mBAAmB,KAAK,IAAkC;AAAA,MACpG;AAAA,IACF,SAAS,GAAG;AACV,cAAQ,MAAM,iCAAiC,GAAG,KAAK,OAAO;AAAA,IAChE;AAAA,EACF;AAAA,EAEA,aAAa;AACX,SAAK,oBAAoB,YAAY;AAAA,EACvC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -11,10 +11,18 @@ function addEventListener(selectorOrTarget, type, options = {}) {
|
|
|
11
11
|
listeners.push({ propertyKey, selector: selectorOrTarget, type, options });
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
function addEventListenerDelegateLightDom(selector, type, options) {
|
|
15
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "light", delegate: true });
|
|
16
|
+
}
|
|
17
|
+
function addEventListenerDelegateShadowDom(selector, type, options) {
|
|
18
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "shadow", delegate: true });
|
|
19
|
+
}
|
|
20
|
+
function addEventListenerDelegateAllDom(selector, type, options) {
|
|
21
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "all", delegate: true });
|
|
22
|
+
}
|
|
23
|
+
function addEventListenerDelegate(selector, type, options) {
|
|
24
|
+
return addEventListener(selector, type, { ...options ?? {}, root: "auto", delegate: true });
|
|
25
|
+
}
|
|
18
26
|
function addEventListenerThis(type, options) {
|
|
19
27
|
return addEventListener("$this", type, options);
|
|
20
28
|
}
|
|
@@ -27,10 +35,18 @@ function addEventListenerWindow(type, options) {
|
|
|
27
35
|
function addEventListenerDocument(type, options) {
|
|
28
36
|
return addEventListener("$document", type, options);
|
|
29
37
|
}
|
|
38
|
+
const getAddEventListenerMetadata = (target) => {
|
|
39
|
+
const constructor = target instanceof Function ? target : target.constructor;
|
|
40
|
+
return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);
|
|
41
|
+
};
|
|
30
42
|
export {
|
|
31
43
|
ADD_EVENT_LISTENER_METADATA_KEY,
|
|
32
44
|
addEventListener,
|
|
33
45
|
addEventListenerAppHost,
|
|
46
|
+
addEventListenerDelegate,
|
|
47
|
+
addEventListenerDelegateAllDom,
|
|
48
|
+
addEventListenerDelegateLightDom,
|
|
49
|
+
addEventListenerDelegateShadowDom,
|
|
34
50
|
addEventListenerDocument,
|
|
35
51
|
addEventListenerThis,
|
|
36
52
|
addEventListenerWindow,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/addEventListener.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n removeOnDisconnected?: boolean;\n delegate?: boolean;\n filter?: (target: Event | CustomEvent, meta:{currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\nexport
|
|
5
|
-
"mappings": "AAAA,SAAS,oBAAoB;AAsBtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAO5F,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,aAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,mBAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAAU,KAAK,EAAE,aAAa,UAAU,kBAAkB,MAAM,QAAQ,CAAC;AAAA,EAC3E;AACF;
|
|
4
|
+
"sourcesContent": ["import { ReflectUtils } from '@dooboostore/core';\nimport { SpecialSelector, SwcQueryOptions, HelperHostSet } from '../types';\n\nexport interface AddEventListenerBaseOptions extends EventListenerOptions {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n stopPropagation?: boolean;\n stopImmediatePropagation?: boolean;\n preventDefault?: boolean;\n // removeOnDisconnected?: boolean;\n delegate?: boolean;\n filter?: (target: Event | CustomEvent, meta:{currentThis: any, helper: HelperHostSet}) => boolean;\n}\n\nexport interface AddEventListenerMetadata {\n propertyKey: string | symbol;\n selector: string;\n type: string;\n options: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean };\n}\n\nexport const ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:add-event-listener');\n\nexport function addEventListener(target: SpecialSelector, type: string, options?: AddEventListenerBaseOptions): MethodDecorator;\nexport function addEventListener(selector: string, type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions & { delegate?: boolean }): MethodDecorator;\n/**\n * @addEventListener decorator to bind events to elements.\n */\nexport function addEventListener(selectorOrTarget: string, type: string, options: any = {}): MethodDecorator {\n return (targetObj: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const constructor = targetObj.constructor;\n\n let listeners = ReflectUtils.getMetadata<AddEventListenerMetadata[]>(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n if (!listeners) {\n listeners = [];\n ReflectUtils.defineMetadata(ADD_EVENT_LISTENER_METADATA_KEY, listeners, constructor);\n }\n\n listeners.push({ propertyKey, selector: selectorOrTarget, type, options });\n };\n}\n\n\nexport function addEventListenerDelegateLightDom(selector: string, type: string, options?: Omit<AddEventListenerBaseOptions, 'delegate'>): MethodDecorator {\n return addEventListener(selector, type, {...options??{}, root:'light', delegate: true});\n}\n\nexport function addEventListenerDelegateShadowDom(selector: string, type: string, options?: Omit<AddEventListenerBaseOptions, 'delegate'>): MethodDecorator {\n return addEventListener(selector, type, {...options??{}, root:'shadow', delegate: true});\n}\nexport function addEventListenerDelegateAllDom(selector: string, type: string, options?: Omit<AddEventListenerBaseOptions, 'delegate'>): MethodDecorator {\n return addEventListener(selector, type, {...options??{}, root:'all', delegate: true});\n}\nexport function addEventListenerDelegate(selector: string, type: string, options?: Omit<AddEventListenerBaseOptions, 'delegate'>): MethodDecorator {\n return addEventListener(selector, type, {...options??{}, root:'auto', delegate: true});\n}\n\n/**\n * @addEventListenerThis decorator - simplified version of @addEventListener for $this selector\n */\nexport function addEventListenerThis(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener('$this', type, options);\n}\n\n/**\n * @addEventListenerAppHost decorator - simplified version of @addEventListener for $appHost selector\n */\nexport function addEventListenerAppHost(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener('$appHost', type, options);\n}\n\nexport function addEventListenerWindow(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener('$window', type, options);\n}\nexport function addEventListenerDocument(type: string, options?: AddEventListenerBaseOptions & SwcQueryOptions): MethodDecorator {\n return addEventListener('$document', type, options);\n}\n\nexport const getAddEventListenerMetadata = (target: any): AddEventListenerMetadata[] | undefined => {\n const constructor = target instanceof Function ? target : target.constructor;\n return ReflectUtils.getMetadata(ADD_EVENT_LISTENER_METADATA_KEY, constructor);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAsBtB,MAAM,kCAAkC,OAAO,IAAI,yCAAyC;AAO5F,SAAS,iBAAiB,kBAA0B,MAAc,UAAe,CAAC,GAAoB;AAC3G,SAAO,CAAC,WAAmB,aAA8B,eAAmC;AAC1F,UAAM,cAAc,UAAU;AAE9B,QAAI,YAAY,aAAa,YAAwC,iCAAiC,WAAW;AACjH,QAAI,CAAC,WAAW;AACd,kBAAY,CAAC;AACb,mBAAa,eAAe,iCAAiC,WAAW,WAAW;AAAA,IACrF;AAEA,cAA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