@dooboostore/simple-web-component 1.0.33 → 1.0.35
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 +23 -30
- package/dist/cjs/decorators/addEventListener.js.map +1 -1
- package/dist/cjs/decorators/applyAttribute.js +67 -57
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyClass.js +80 -70
- package/dist/cjs/decorators/applyClass.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +5 -8
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyStyle.js +66 -56
- package/dist/cjs/decorators/applyStyle.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +35 -29
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js +32 -12
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +238 -180
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +67 -48
- package/dist/cjs/decorators/emitCustomEvent.js.map +2 -2
- package/dist/cjs/decorators/lifecycles.js +15 -17
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/decorators/setProperty.js +50 -39
- package/dist/cjs/decorators/setProperty.js.map +2 -2
- package/dist/cjs/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +14 -8
- package/dist/cjs/elements/SwcAppEngine.js.map +3 -3
- package/dist/cjs/elements/SwcAppMixin.js +154 -81
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/cjs/elements/SwcAsync.js +28 -18
- package/dist/cjs/elements/SwcAsync.js.map +2 -2
- package/dist/cjs/elements/SwcChoose.js +68 -45
- package/dist/cjs/elements/SwcChoose.js.map +2 -2
- package/dist/cjs/elements/SwcIf.js +52 -30
- package/dist/cjs/elements/SwcIf.js.map +2 -2
- package/dist/cjs/elements/SwcLoop.js +109 -35
- package/dist/cjs/elements/SwcLoop.js.map +2 -2
- package/dist/cjs/elements/register.js +263 -131
- package/dist/cjs/elements/register.js.map +2 -2
- package/dist/cjs/router/ElementRouter.js +4 -2
- package/dist/cjs/router/ElementRouter.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/Utils.js +25 -7
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/addEventListener.js.map +1 -1
- package/dist/esm/decorators/applyAttribute.js +67 -57
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyClass.js +80 -70
- package/dist/esm/decorators/applyClass.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +5 -8
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyStyle.js +66 -56
- package/dist/esm/decorators/applyStyle.js.map +2 -2
- package/dist/esm/decorators/attribute.js +35 -29
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js +32 -12
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +240 -182
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +67 -48
- package/dist/esm/decorators/emitCustomEvent.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +15 -17
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/decorators/setProperty.js +50 -39
- package/dist/esm/decorators/setProperty.js.map +2 -2
- package/dist/esm/decorators/subscribeSwcAppMessageWhileConnected.js.map +1 -1
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +14 -7
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +156 -82
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/elements/SwcAsync.js +28 -18
- package/dist/esm/elements/SwcAsync.js.map +2 -2
- package/dist/esm/elements/SwcChoose.js +69 -46
- package/dist/esm/elements/SwcChoose.js.map +2 -2
- package/dist/esm/elements/SwcIf.js +53 -31
- package/dist/esm/elements/SwcIf.js.map +2 -2
- package/dist/esm/elements/SwcLoop.js +110 -36
- package/dist/esm/elements/SwcLoop.js.map +2 -2
- package/dist/esm/elements/register.js +264 -132
- package/dist/esm/elements/register.js.map +2 -2
- package/dist/esm/router/ElementRouter.js +5 -2
- package/dist/esm/router/ElementRouter.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/Utils.js +25 -7
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +728 -595
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/addEventListener.d.ts +4 -1
- package/dist/types/decorators/addEventListener.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +5 -1
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyClass.d.ts +4 -0
- package/dist/types/decorators/applyClass.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts +5 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyStyle.d.ts +5 -1
- package/dist/types/decorators/applyStyle.d.ts.map +1 -1
- package/dist/types/decorators/attribute.d.ts +5 -0
- package/dist/types/decorators/attribute.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts +14 -3
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +15 -7
- package/dist/types/decorators/emitCustomEvent.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +10 -7
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/decorators/setProperty.d.ts +5 -1
- package/dist/types/decorators/setProperty.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts +2 -2
- package/dist/types/decorators/subscribeSwcAppMessageWhileConnected.d.ts.map +1 -1
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts +5 -6
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +9 -3
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +12 -7
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/types/elements/register.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/Utils.d.ts +4 -1
- package/dist/types/utils/Utils.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +728 -595
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +5 -5
- package/src/decorators/addEventListener.ts +1 -1
- package/src/decorators/applyAttribute.ts +74 -61
- package/src/decorators/applyClass.ts +91 -77
- package/src/decorators/applyNode.ts +16 -13
- package/src/decorators/applyStyle.ts +75 -61
- package/src/decorators/attribute.ts +55 -43
- package/src/decorators/changedAttributeHost.ts +49 -15
- package/src/decorators/elementDefine.ts +401 -340
- package/src/decorators/emitCustomEvent.ts +92 -62
- package/src/decorators/lifecycles.ts +11 -10
- package/src/decorators/setProperty.ts +58 -44
- package/src/decorators/subscribeSwcAppMessageWhileConnected.ts +2 -2
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +11 -11
- package/src/elements/SwcAppEngine.ts +19 -13
- package/src/elements/SwcAppMixin.ts +214 -102
- package/src/elements/SwcAsync.ts +28 -17
- package/src/elements/SwcChoose.ts +94 -36
- package/src/elements/SwcIf.ts +59 -22
- package/src/elements/SwcLoop.ts +140 -27
- package/src/elements/register.ts +319 -100
- package/src/types.ts +1 -0
- package/src/utils/Utils.ts +38 -10
- package/tsconfig.json +2 -2
package/src/utils/Utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SwcAppInterface, HostSet, HelperSet, HelperHostSet } from '../types';
|
|
2
2
|
import {getElementConfig} from "../decorators";
|
|
3
3
|
import { getExpression, ExpressionResult, GetExpressionConfig, GetExpressionResult } from '@dooboostore/core';
|
|
4
|
+
import {Router} from "@dooboostore/core-web";
|
|
4
5
|
|
|
5
6
|
export const SWC_NOT_FOUND = Symbol.for('simple-web-component:not-found');
|
|
6
7
|
|
|
@@ -151,14 +152,30 @@ export const htmlArticleElement = (options?: { doc?: Document; attrs?: Record<st
|
|
|
151
152
|
export namespace SwcUtils {
|
|
152
153
|
|
|
153
154
|
|
|
155
|
+
export const getParentContainer = (e: Node) => {
|
|
156
|
+
return e.parentElement ?? e.getRootNode() as any;
|
|
157
|
+
}
|
|
158
|
+
|
|
154
159
|
export const parsePathPatternsSetAttributeString = (pathPattern: string[], path: string) => {
|
|
155
160
|
return JSON.stringify(SwcUtils.parsePathPatternsSet(pathPattern, path)).replace(/"/g, "'");
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
export const parsePathPatternsSet = (pathPattern: string[],
|
|
163
|
+
export const parsePathPatternsSet = (pathPattern: string[], urlAndRouter?: string | Router) => {
|
|
164
|
+
// if (!path) {
|
|
165
|
+
// return;
|
|
166
|
+
// }
|
|
167
|
+
urlAndRouter ??= '/'
|
|
168
|
+
const p = typeof urlAndRouter === 'string' ? urlAndRouter : urlAndRouter.value.url;
|
|
169
|
+
const searchParams = new URLSearchParams();
|
|
170
|
+
const qs = p.split('?')[1];
|
|
171
|
+
qs?.split('&').forEach(it => {
|
|
172
|
+
const [k, v] = it.split('=');
|
|
173
|
+
searchParams.set(k,v);
|
|
174
|
+
})
|
|
159
175
|
return {
|
|
160
|
-
path:
|
|
161
|
-
|
|
176
|
+
path: p,
|
|
177
|
+
searchParams,
|
|
178
|
+
pathData: SwcUtils.parsePathPatterns(pathPattern, p)
|
|
162
179
|
};
|
|
163
180
|
};
|
|
164
181
|
export const parsePathPatterns = (pathPattern: string[], path: string) => {
|
|
@@ -209,8 +226,8 @@ export namespace SwcUtils {
|
|
|
209
226
|
* Checks __swc_host property first, then climbs the DOM tree.
|
|
210
227
|
*/
|
|
211
228
|
export const findNearestSwcHost = (el: HTMLElement | Node): HTMLElement | undefined => {
|
|
212
|
-
|
|
213
|
-
|
|
229
|
+
const el1 = el as any;
|
|
230
|
+
if (el1.__swc_host) return el1.__swc_host;
|
|
214
231
|
|
|
215
232
|
let current: any = el.parentElement || (el.getRootNode?.() as any)?.host;
|
|
216
233
|
const doc = el.ownerDocument;
|
|
@@ -249,8 +266,10 @@ export namespace SwcUtils {
|
|
|
249
266
|
};
|
|
250
267
|
|
|
251
268
|
export const getAppHosts = (el: HTMLElement): SwcAppInterface[] => {
|
|
252
|
-
const hosts = getHosts(el);
|
|
253
|
-
return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];
|
|
269
|
+
// const hosts = getHosts(el);
|
|
270
|
+
// return hosts.filter(host => host.tagName.toLowerCase() === 'swc-app' || host.getAttribute('is')?.startsWith('swc-app-')) as SwcAppInterface[];
|
|
271
|
+
const hosts = SwcUtils.findAllParentAppHostsDirect(el);
|
|
272
|
+
return hosts;
|
|
254
273
|
};
|
|
255
274
|
|
|
256
275
|
export const getAppHost = (el: HTMLElement): SwcAppInterface | undefined => {
|
|
@@ -277,7 +296,15 @@ export namespace SwcUtils {
|
|
|
277
296
|
*/
|
|
278
297
|
export const findAllParentAppHostsDirect = (el: HTMLElement): SwcAppInterface[] => {
|
|
279
298
|
const appHosts: SwcAppInterface[] = [];
|
|
280
|
-
|
|
299
|
+
|
|
300
|
+
const w = el.ownerDocument?.defaultView || ((typeof window !== 'undefined' ? window : undefined) as any);
|
|
301
|
+
|
|
302
|
+
// Guard against SSR environment where window might be undefined
|
|
303
|
+
if (!w) {
|
|
304
|
+
return appHosts;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// console.log('------?',w.ShadowRoot);
|
|
281
308
|
// el 자체부터 시작 (el이 app host일 수도 있음)
|
|
282
309
|
let current: HTMLElement | null = el;
|
|
283
310
|
|
|
@@ -296,9 +323,9 @@ export namespace SwcUtils {
|
|
|
296
323
|
} else {
|
|
297
324
|
// parentElement가 없음 = Shadow root의 직접 자식일 수 있음
|
|
298
325
|
const root = current.getRootNode();
|
|
299
|
-
if (root instanceof ShadowRoot) {
|
|
326
|
+
if (w.ShadowRoot && root instanceof w.ShadowRoot) {
|
|
300
327
|
// Shadow host로 올라가기
|
|
301
|
-
current = root.host as HTMLElement;
|
|
328
|
+
current = (root as ShadowRoot).host as HTMLElement;
|
|
302
329
|
} else {
|
|
303
330
|
// Document root 도달
|
|
304
331
|
break;
|
|
@@ -338,6 +365,7 @@ export namespace SwcUtils {
|
|
|
338
365
|
$hosts,
|
|
339
366
|
$firstHost,
|
|
340
367
|
$lastHost: $parentHost,
|
|
368
|
+
$templateHost: (el as any).__swc_template_host,
|
|
341
369
|
$appHost,
|
|
342
370
|
$appHosts,
|
|
343
371
|
$firstAppHost,
|
package/tsconfig.json
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"declaration": true,
|
|
7
7
|
"declarationMap": true,
|
|
8
8
|
"stripInternal": true,
|
|
9
|
-
"target": "
|
|
9
|
+
"target": "es2022",
|
|
10
10
|
"noEmit": true,
|
|
11
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
11
|
+
"lib": ["dom", "dom.iterable", "es2024", "esnext"],
|
|
12
12
|
"experimentalDecorators": true,
|
|
13
13
|
"emitDecoratorMetadata": true,
|
|
14
14
|
"esModuleInterop": true,
|