@dooboostore/simple-web-component 1.0.45 → 1.0.47
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/dist/cjs/bundle-entry.js +22 -0
- package/dist/cjs/bundle-entry.js.map +2 -2
- package/dist/cjs/decorators/applyAttribute.js.map +2 -2
- package/dist/cjs/decorators/applyNode.js +3 -1
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/applyProperty.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +5 -8
- package/dist/cjs/decorators/elementDefine.js.map +3 -3
- package/dist/cjs/decorators/lifecycles.js +11 -36
- package/dist/cjs/decorators/lifecycles.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +6 -2
- package/dist/cjs/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm/bundle-entry.js +8 -0
- package/dist/esm/bundle-entry.js.map +2 -2
- package/dist/esm/decorators/applyAttribute.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +3 -1
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/applyProperty.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +6 -9
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/lifecycles.js +11 -36
- package/dist/esm/decorators/lifecycles.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +6 -2
- package/dist/esm/elements/SwcAppMixin.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +5524 -231
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/bundle-entry.d.ts +3 -0
- package/dist/types/bundle-entry.d.ts.map +1 -1
- package/dist/types/decorators/applyAttribute.d.ts +1 -0
- package/dist/types/decorators/applyAttribute.d.ts.map +1 -1
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/applyProperty.d.ts +1 -0
- package/dist/types/decorators/applyProperty.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/lifecycles.d.ts +12 -13
- package/dist/types/decorators/lifecycles.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts.map +1 -1
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js +5520 -231
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +6 -7
- package/src/bundle-entry.ts +8 -0
- package/src/decorators/applyAttribute.ts +1 -0
- package/src/decorators/applyNode.ts +3 -1
- package/src/decorators/applyProperty.ts +1 -0
- package/src/decorators/elementDefine.ts +8 -11
- package/src/decorators/lifecycles.ts +53 -52
- package/src/elements/SwcAppMixin.ts +7 -3
- package/dist/cjs/examples/RxJSOperatorsExample.js +0 -285
- package/dist/cjs/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/esm/examples/RxJSOperatorsExample.js +0 -266
- package/dist/esm/examples/RxJSOperatorsExample.js.map +0 -7
- package/dist/types/examples/RxJSOperatorsExample.d.ts +0 -94
- package/dist/types/examples/RxJSOperatorsExample.d.ts.map +0 -1
- package/src/examples/RxJSOperatorsExample.ts +0 -279
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dooboostore/simple-web-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.47",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -67,7 +67,10 @@
|
|
|
67
67
|
},
|
|
68
68
|
"author": "dooboostore <dooboostore@gmail.com> (https://github.com/dooboostore)",
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"reflect-metadata": "^0.2.2"
|
|
70
|
+
"reflect-metadata": "^0.2.2",
|
|
71
|
+
"@dooboostore/core": "1.0.32",
|
|
72
|
+
"@dooboostore/core-web": "1.0.12",
|
|
73
|
+
"@dooboostore/simple-boot": "1.0.56"
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
76
|
"@babel/core": "^7.24.0",
|
|
@@ -91,11 +94,7 @@
|
|
|
91
94
|
"typescript": "^5.9.2",
|
|
92
95
|
"webpack": "^5.93.0",
|
|
93
96
|
"webpack-cli": "^5.1.4",
|
|
94
|
-
"webpack-dev-server": "^5.2.0"
|
|
95
|
-
"@dooboostore/core": "1.0.32",
|
|
96
|
-
"@dooboostore/core-node": "1.0.12",
|
|
97
|
-
"@dooboostore/core-web": "1.0.12",
|
|
98
|
-
"@dooboostore/simple-boot": "1.0.56"
|
|
97
|
+
"webpack-dev-server": "^5.2.0"
|
|
99
98
|
},
|
|
100
99
|
"scripts": {
|
|
101
100
|
"clean": "rm -rf dist",
|
package/src/bundle-entry.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
|
|
3
|
+
// simple-web-component itself
|
|
2
4
|
export * from './index';
|
|
5
|
+
|
|
6
|
+
// Re-export peer dependencies so bundle consumers can access them
|
|
7
|
+
// without separately importing each package
|
|
8
|
+
export * as Core from '@dooboostore/core';
|
|
9
|
+
export * as CoreWeb from '@dooboostore/core-web';
|
|
10
|
+
export * as SimpleBoot from '@dooboostore/simple-boot';
|
|
@@ -381,6 +381,7 @@ export function applyAttribute(selector: AttributeSelector, targetAttributeNameO
|
|
|
381
381
|
*
|
|
382
382
|
* Note: This decorator is for FIELDS ONLY. For methods, use @setAttribute.
|
|
383
383
|
*/
|
|
384
|
+
export function attribute(target: Object, propertyKey: string | symbol): void;
|
|
384
385
|
export function attribute(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
385
386
|
export function attribute(attributeName: string, options?: AttributeOptions): PropertyDecorator;
|
|
386
387
|
export function attribute(selector: AttributeSelector, attributeName: string, options?: AttributeOptions): PropertyDecorator;
|
|
@@ -95,7 +95,9 @@ const applyToDom = (currentThis: any, targetEl: HTMLElement, res: Node | string,
|
|
|
95
95
|
|
|
96
96
|
const nodes: Node[] = [];
|
|
97
97
|
|
|
98
|
-
if (
|
|
98
|
+
if (res instanceof win.Node) {
|
|
99
|
+
nodes.push(res);
|
|
100
|
+
} else if (typeof res === 'string' && pos === 'innerHtml') {
|
|
99
101
|
const t = win.document.createElement('template');
|
|
100
102
|
t.innerHTML = res;
|
|
101
103
|
nodes.push(...Array.from(t.content.childNodes));
|
|
@@ -301,6 +301,7 @@ export function applyProperty(selector: PropertySelector, targetPropertyKeyOrOpt
|
|
|
301
301
|
*
|
|
302
302
|
* Note: This decorator is for FIELDS ONLY. For methods, use @setProperty.
|
|
303
303
|
*/
|
|
304
|
+
export function property(target: Object, propertyKey: string | symbol): void;
|
|
304
305
|
export function property(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): PropertyDescriptor | void;
|
|
305
306
|
export function property(selector: PropertySelector, targetPropertyKey: string | symbol, options?: PropertyOptions): PropertyDecorator;
|
|
306
307
|
export function property(selector: PropertySelector, options?: PropertyOptions): PropertyDecorator;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {ActionExpression, FunctionUtils, ReflectUtils} from '@dooboostore/core';
|
|
2
|
-
import {
|
|
3
|
-
import {debounceTime, throttleTime, distinctUntilChanged} from '@dooboostore/core/message/operators';
|
|
1
|
+
import {ActionExpression, FunctionUtils, ReflectUtils, Subject} from '@dooboostore/core';
|
|
2
|
+
import {debounceTime, distinctUntilChanged, throttleTime} from '@dooboostore/core/message/operators';
|
|
4
3
|
import {getAddEventListenerMetadata} from './addEventListener';
|
|
5
4
|
import {findAllLifecycleMetadata, findAllOnConnectedAfterMetadata, findAllOnConnectedBeforeMetadata, findAllOnConnectedMetadata, ON_AFTER_ADOPTED_METADATA_KEY, ON_AFTER_DISCONNECTED_METADATA_KEY, ON_BEFORE_ADOPTED_METADATA_KEY, ON_BEFORE_DISCONNECTED_METADATA_KEY, ON_CONNECTED_COMPLETED_METADATA_KEY, ON_INITIALIZE_METADATA_KEY} from './lifecycles';
|
|
6
5
|
import {getEmitCustomEventMetadataList} from './emitCustomEvent';
|
|
@@ -12,9 +11,8 @@ import {SwcUtils} from '../utils/Utils';
|
|
|
12
11
|
import {DOM_EVENT_NAMES, HTML_TAG_ENTRIES} from '../config/config';
|
|
13
12
|
import {SituationTypeContainer, SituationTypeContainers} from '@dooboostore/simple-boot/decorators/inject/Inject';
|
|
14
13
|
import {HelperHostSet, HostSet, InjectSituationType} from '../types';
|
|
15
|
-
import {ConvertUtils, ElementApply
|
|
14
|
+
import {ConvertUtils, ElementApply} from '@dooboostore/core-web';
|
|
16
15
|
import {isSSR} from "../elements/SwcAppMixin";
|
|
17
|
-
import {findAllApplySlotMetadata} from "./applySlot";
|
|
18
16
|
import {findAllStateMetadata} from "./state";
|
|
19
17
|
import {findAllPropertyMetadata} from "./applyProperty";
|
|
20
18
|
|
|
@@ -385,14 +383,15 @@ export const elementDefine =
|
|
|
385
383
|
const conf = getElementConfig(this);
|
|
386
384
|
const currentWin = (this as any)._resolveWindow(conf);
|
|
387
385
|
|
|
388
|
-
const bMethods = findAllOnConnectedBeforeMetadata(this)
|
|
386
|
+
const bMethods = findAllOnConnectedBeforeMetadata(this);//.filter(it => useSsr ? !it.options.ssrFirst : true);
|
|
389
387
|
// console.log('beforeConnected', bMethods)
|
|
390
388
|
for (const m of bMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
391
389
|
(this as any)._executeSwcScript('swc-on-before-connected', helperHostSet);
|
|
392
390
|
|
|
393
391
|
// console.log('vvvvvvvvvvvvvvvu-seSsr-vvvvvvvvvv>', useSsr, this.tagName, this.getAttribute('seq'))
|
|
394
392
|
// // ssr 처리라서 이미 내려준거그대로 상요하면된다 따라서 호출안한다
|
|
395
|
-
const targetConnectedList = findAllOnConnectedMetadata(constructor).filter(it => useSsr ? !it.options.ssrFirst : true);
|
|
393
|
+
// const targetConnectedList = findAllOnConnectedMetadata(constructor).filter(it => useSsr ? !it.options.ssrFirst : true);
|
|
394
|
+
const targetConnectedList = useSsr ? [] : findAllOnConnectedMetadata(constructor);
|
|
396
395
|
const shadowMode = conf?.useShadow || targetConnectedList.find(it => it.options.useShadow)?.options.useShadow;
|
|
397
396
|
// console.log('--------->', this.tagName, shadowMode && !this.shadowRoot)
|
|
398
397
|
if (shadowMode && !this.shadowRoot) {
|
|
@@ -510,7 +509,7 @@ export const elementDefine =
|
|
|
510
509
|
const unifiedHandler = async (event: Event) => {
|
|
511
510
|
for (const meta of sortedMetaList) {
|
|
512
511
|
const {selector, options} = meta;
|
|
513
|
-
const matchedEl = (event.target as HTMLElement)
|
|
512
|
+
const matchedEl = (event.target as HTMLElement)?.closest(selector);
|
|
514
513
|
if (matchedEl && (br as any).contains(matchedEl)) {
|
|
515
514
|
// Apply filter if specified
|
|
516
515
|
if (options.filter) {
|
|
@@ -655,9 +654,7 @@ export const elementDefine =
|
|
|
655
654
|
|
|
656
655
|
if (originalConnected) await (originalConnected.apply(this));
|
|
657
656
|
|
|
658
|
-
const aMethods = findAllOnConnectedAfterMetadata(this)
|
|
659
|
-
return useSsr ? !it.options.ssrFirst : true;
|
|
660
|
-
});
|
|
657
|
+
const aMethods = findAllOnConnectedAfterMetadata(this); //.filter(it => { return useSsr ? !it.options.ssrFirst : true; });
|
|
661
658
|
// console.log('afterConnected', this.tagName, aMethods, getOnConnectedAfterMetadata(this))
|
|
662
659
|
for (const m of aMethods) await (this as any)._invokeLifecycleMethod(m.propertyKey, helperHostSet);
|
|
663
660
|
(this as any)._executeSwcScript('swc-on-connected', helperHostSet);
|
|
@@ -8,24 +8,25 @@ export const ON_AFTER_DISCONNECTED_METADATA_KEY = Symbol.for('simple-web-compone
|
|
|
8
8
|
export const ON_BEFORE_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-before-adopted');
|
|
9
9
|
export const ON_AFTER_ADOPTED_METADATA_KEY = Symbol.for('simple-web-component:on-after-adopted');
|
|
10
10
|
export const ON_ADD_EVENT_LISTENER_METADATA_KEY = Symbol.for('simple-web-component:on-add-event-listener');
|
|
11
|
-
export const
|
|
11
|
+
export const ON_CONNECTED_BODY_METADATA_KEY = Symbol.for('simple-web-component:on-connected-body');
|
|
12
12
|
export const ON_CONNECTED_SWC_APP_METADATA_KEY = Symbol.for('simple-web-component:on-connected-swc-app');
|
|
13
13
|
export const ON_CONNECTED_COMPLETED_METADATA_KEY = Symbol.for('simple-web-component:on-completed');
|
|
14
14
|
|
|
15
15
|
export const ATTRIBUTE_CHANGED_WILDCARD = '*';
|
|
16
16
|
|
|
17
|
-
export interface
|
|
18
|
-
ssrFirst?: boolean;
|
|
17
|
+
export interface OnConnectedAppendChildOptions {
|
|
18
|
+
// ssrFirst?: boolean;
|
|
19
19
|
// replaceWrap?:{ start: string, end:string},
|
|
20
20
|
useShadow?: boolean;
|
|
21
|
+
order?: number;
|
|
21
22
|
}
|
|
22
|
-
export interface
|
|
23
|
+
export interface OnConnectedAppendChildOptionsMetadata {
|
|
23
24
|
propertyKey: string | symbol;
|
|
24
|
-
options:
|
|
25
|
+
options: OnConnectedAppendChildOptions;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export interface OnConnectedOptions {
|
|
28
|
-
ssrFirst?: boolean;
|
|
29
|
+
// ssrFirst?: boolean;
|
|
29
30
|
order?: number;
|
|
30
31
|
}
|
|
31
32
|
export interface OnConnectedMetadata {
|
|
@@ -87,33 +88,33 @@ export function onConnectedAfter(arg1?: OnConnectedOptions | Object, arg2?: stri
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
|
|
90
|
-
function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
91
|
+
// function createLifecycleDecorator(metadataKey: symbol): ((options?: LifecycleOptions) => MethodDecorator) & MethodDecorator {
|
|
92
|
+
// const decorator = (options?: LifecycleOptions): MethodDecorator => {
|
|
93
|
+
// return (target: Object, propertyKey: string | symbol) => {
|
|
94
|
+
// const constructor = target.constructor;
|
|
95
|
+
// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
|
|
96
|
+
// if (!list) {
|
|
97
|
+
// list = [];
|
|
98
|
+
// ReflectUtils.defineMetadata(metadataKey, list, constructor);
|
|
99
|
+
// }
|
|
100
|
+
// list.push({ propertyKey, order: options?.order ?? 0 });
|
|
101
|
+
// };
|
|
102
|
+
// };
|
|
103
|
+
//
|
|
104
|
+
// // Support both @decorator and @decorator() syntax
|
|
105
|
+
// return Object.assign(
|
|
106
|
+
// (target: Object, propertyKey: string | symbol) => {
|
|
107
|
+
// const constructor = target.constructor;
|
|
108
|
+
// let list = ReflectUtils.getOwnMetadata(metadataKey, constructor) as LifecycleMetadata[];
|
|
109
|
+
// if (!list) {
|
|
110
|
+
// list = [];
|
|
111
|
+
// ReflectUtils.defineMetadata(metadataKey, list, constructor);
|
|
112
|
+
// }
|
|
113
|
+
// list.push({ propertyKey, order: 0 });
|
|
114
|
+
// },
|
|
115
|
+
// { __isDecorator: true, __decorator: decorator }
|
|
116
|
+
// ) as any;
|
|
117
|
+
// }
|
|
117
118
|
|
|
118
119
|
// Helper to handle both @decorator and @decorator() syntax
|
|
119
120
|
function createLifecycleDecoratorWithOptions(metadataKey: symbol) {
|
|
@@ -193,19 +194,19 @@ export function onConnectedCompleted(optionOrTarget?: LifecycleOptions | Object,
|
|
|
193
194
|
|
|
194
195
|
|
|
195
196
|
|
|
196
|
-
const decorator = (options:
|
|
197
|
+
const decorator = (options: OnConnectedAppendChildOptions, target: Object, propertyKey: string | symbol) => {
|
|
197
198
|
const constructor = target.constructor;
|
|
198
|
-
let list = ReflectUtils.getMetadata<
|
|
199
|
+
let list = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor);
|
|
199
200
|
if (!list) {
|
|
200
201
|
list = [];
|
|
201
|
-
ReflectUtils.defineMetadata(
|
|
202
|
+
ReflectUtils.defineMetadata(ON_CONNECTED_BODY_METADATA_KEY, list, constructor);
|
|
202
203
|
}
|
|
203
204
|
list.push({ propertyKey, options });
|
|
204
205
|
};
|
|
205
206
|
|
|
206
|
-
export function
|
|
207
|
-
export function
|
|
208
|
-
export function
|
|
207
|
+
export function onConnectedBodyShadow(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
208
|
+
export function onConnectedBodyShadow(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
209
|
+
export function onConnectedBodyShadow(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
209
210
|
if (propertyKey) { // no parameter option @decorator
|
|
210
211
|
return decorator({useShadow: true}, optionOrTarget!, propertyKey);
|
|
211
212
|
}
|
|
@@ -215,9 +216,9 @@ export function onConnectedShadow(optionOrTarget: Omit<InnerHtmlOptions, 'useSha
|
|
|
215
216
|
};
|
|
216
217
|
}
|
|
217
218
|
|
|
218
|
-
export function
|
|
219
|
-
export function
|
|
220
|
-
export function
|
|
219
|
+
export function onConnectedBodyLight(options: Omit<OnConnectedAppendChildOptions, 'useShadow'>): MethodDecorator; // 파라미터있음
|
|
220
|
+
export function onConnectedBodyLight(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void; // 파라미터없음
|
|
221
|
+
export function onConnectedBodyLight(optionOrTarget: Omit<OnConnectedAppendChildOptions, 'useShadow'> | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
221
222
|
if (propertyKey) { // no parameter option @decorator
|
|
222
223
|
return decorator({useShadow: false}, optionOrTarget!, propertyKey);
|
|
223
224
|
}
|
|
@@ -226,15 +227,15 @@ export function onConnectedLight(optionOrTarget: Omit<InnerHtmlOptions, 'useShad
|
|
|
226
227
|
decorator({...optionOrTarget??{}, useShadow: false}, target, propertyKey);
|
|
227
228
|
};
|
|
228
229
|
}
|
|
229
|
-
export function
|
|
230
|
-
export function
|
|
231
|
-
export function
|
|
230
|
+
export function onConnectedBody(options: OnConnectedAppendChildOptions): MethodDecorator;
|
|
231
|
+
export function onConnectedBody(target: Object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;
|
|
232
|
+
export function onConnectedBody(optionOrTarget: OnConnectedAppendChildOptions | Object, propertyKey?: string | symbol, arg3?: PropertyDescriptor): MethodDecorator | void {
|
|
232
233
|
if (propertyKey) { // no parameter option @decorator
|
|
233
234
|
return decorator({}, optionOrTarget!, propertyKey);
|
|
234
235
|
}
|
|
235
236
|
// parameter option @decorator()
|
|
236
237
|
return (target: Object, propertyKey: string | symbol) => {
|
|
237
|
-
decorator((optionOrTarget as
|
|
238
|
+
decorator((optionOrTarget as OnConnectedAppendChildOptions) || {}, target, propertyKey);
|
|
238
239
|
};
|
|
239
240
|
}
|
|
240
241
|
|
|
@@ -248,27 +249,27 @@ export const findAllLifecycleMetadata = (target: any, metadataKey: symbol): Life
|
|
|
248
249
|
return [...results].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
249
250
|
};
|
|
250
251
|
|
|
251
|
-
export const findAllOnConnectedMetadata = (target: any):
|
|
252
|
+
export const findAllOnConnectedMetadata = (target: any): OnConnectedAppendChildOptionsMetadata[] => {
|
|
252
253
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
253
|
-
const results = ReflectUtils.getMetadata(
|
|
254
|
+
const results = ReflectUtils.getMetadata<OnConnectedAppendChildOptionsMetadata[]>(ON_CONNECTED_BODY_METADATA_KEY, constructor) ?? [];
|
|
254
255
|
// Sort by order (default 0 if not specified)
|
|
255
256
|
return [...results].sort((a, b) => {
|
|
256
|
-
const orderA =
|
|
257
|
-
const orderB =
|
|
257
|
+
const orderA = a.options?.order ?? 0;
|
|
258
|
+
const orderB = b.options?.order ?? 0;
|
|
258
259
|
return orderA - orderB;
|
|
259
260
|
});
|
|
260
261
|
};
|
|
261
262
|
|
|
262
263
|
export const findAllOnConnectedBeforeMetadata = (target: any): OnConnectedMetadata[] => {
|
|
263
264
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
264
|
-
const results = ReflectUtils.getMetadata(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
265
|
+
const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_BEFORE_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
265
266
|
// Sort by order
|
|
266
267
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
267
268
|
};
|
|
268
269
|
|
|
269
270
|
export const findAllOnConnectedAfterMetadata = (target: any): OnConnectedMetadata[] => {
|
|
270
271
|
const constructor = target instanceof Function ? target : target.constructor;
|
|
271
|
-
const results = ReflectUtils.getMetadata(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
272
|
+
const results = ReflectUtils.getMetadata<OnConnectedMetadata[]>(ON_AFTER_CONNECTED_METADATA_KEY, constructor) ?? [];
|
|
272
273
|
// Sort by order
|
|
273
274
|
return [...results].sort((a, b) => (a.options?.order ?? 0) - (b.options?.order ?? 0));
|
|
274
275
|
};
|
|
@@ -2,7 +2,7 @@ import { SwcAppInterface, SwcAppMessage } from '../types';
|
|
|
2
2
|
import { APPLY_NODE_METADATA_KEY, findAllLifecycleMetadata, getSubscribeSwcAppMessageWhileConnectedMetadata, getSubscribeSwcAppRouteChangeWhileConnectedMetadata, ON_CONNECTED_SWC_APP_METADATA_KEY, SUBSCRIBE_SWC_APP_ROUTE_CHANGE_WHILE_CONNECTED_METADATA_KEY } from '../decorators';
|
|
3
3
|
import { SwcAppEngine, SwcAttributeConfigType, SwcConfigType } from '../SwcAppEngine';
|
|
4
4
|
import { debounceTimeIntervalLock, FunctionUtils, Subscription } from '@dooboostore/core';
|
|
5
|
-
import {
|
|
5
|
+
import {RouterEventType, ValidUtils} from '@dooboostore/core-web';
|
|
6
6
|
import { SwcUtils } from '../utils/Utils';
|
|
7
7
|
|
|
8
8
|
export const isSSR = (i: HTMLElement) => {
|
|
@@ -137,7 +137,9 @@ export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Bas
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
} finally {
|
|
140
|
-
|
|
140
|
+
// this.config?.window
|
|
141
|
+
const isBrowser = ValidUtils.isBrowser();
|
|
142
|
+
if (!isBrowser && this.config?.ssr) {
|
|
141
143
|
setSSRAttribute(instance);
|
|
142
144
|
} else {
|
|
143
145
|
removeSSRAttribute(instance);
|
|
@@ -188,7 +190,9 @@ export function SwcAppMixin<T extends { new (...args: any[]): HTMLElement }>(Bas
|
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
|
|
191
|
-
|
|
193
|
+
const isBrowser = ValidUtils.isBrowser();
|
|
194
|
+
console.log('------>', isBrowser, this.config?.ssr)
|
|
195
|
+
if (!isBrowser && this.config?.ssr) {
|
|
192
196
|
setSSRAttribute(instance);
|
|
193
197
|
} else {
|
|
194
198
|
removeSSRAttribute(instance);
|
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var RxJSOperatorsExample_exports = {};
|
|
19
|
-
__export(RxJSOperatorsExample_exports, {
|
|
20
|
-
AutoSaveEditor: () => AutoSaveEditor,
|
|
21
|
-
FormInput: () => FormInput,
|
|
22
|
-
InfiniteScroll: () => InfiniteScroll,
|
|
23
|
-
KeyboardHandler: () => KeyboardHandler,
|
|
24
|
-
LengthTracker: () => LengthTracker,
|
|
25
|
-
MouseTracker: () => MouseTracker,
|
|
26
|
-
ResponsiveLayout: () => ResponsiveLayout,
|
|
27
|
-
SearchComponent: () => SearchComponent
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(RxJSOperatorsExample_exports);
|
|
30
|
-
var import_decorators = require("../decorators");
|
|
31
|
-
var __decorate = function(decorators, target, key, desc) {
|
|
32
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
33
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
34
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
35
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
36
|
-
};
|
|
37
|
-
var __metadata = function(k, v) {
|
|
38
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
39
|
-
};
|
|
40
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
|
-
let SearchComponent = class SearchComponent2 extends HTMLElement {
|
|
42
|
-
constructor() {
|
|
43
|
-
super(...arguments);
|
|
44
|
-
this.results = [];
|
|
45
|
-
}
|
|
46
|
-
async onSearchInput(event) {
|
|
47
|
-
const input = event.target;
|
|
48
|
-
const query = input.value.trim();
|
|
49
|
-
if (query.length > 2) {
|
|
50
|
-
try {
|
|
51
|
-
const response = await fetch(`/api/search?q=${encodeURIComponent(query)}`);
|
|
52
|
-
this.results = await response.json();
|
|
53
|
-
this.renderResults();
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error("Search failed:", error);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
this.results = [];
|
|
59
|
-
this.renderResults();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
renderResults() {
|
|
63
|
-
console.log("Rendering results:", this.results);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
__decorate([
|
|
67
|
-
(0, import_decorators.addEventListener)("$this", "input", { debounceTime: 1e3 }),
|
|
68
|
-
__metadata("design:type", Function),
|
|
69
|
-
__metadata("design:paramtypes", [typeof (_a = typeof Event !== "undefined" && Event) === "function" ? _a : Object]),
|
|
70
|
-
__metadata("design:returntype", Promise)
|
|
71
|
-
], SearchComponent.prototype, "onSearchInput", null);
|
|
72
|
-
SearchComponent = __decorate([
|
|
73
|
-
(0, import_decorators.elementDefine)("search-component")
|
|
74
|
-
], SearchComponent);
|
|
75
|
-
let ResponsiveLayout = class ResponsiveLayout2 extends HTMLElement {
|
|
76
|
-
onWindowResize(event) {
|
|
77
|
-
const width = window.innerWidth;
|
|
78
|
-
const height = window.innerHeight;
|
|
79
|
-
console.log(`Window resized to: ${width}x${height}`);
|
|
80
|
-
this.updateLayout(width, height);
|
|
81
|
-
}
|
|
82
|
-
updateLayout(width, height) {
|
|
83
|
-
if (width < 768) {
|
|
84
|
-
this.classList.add("mobile");
|
|
85
|
-
this.classList.remove("desktop");
|
|
86
|
-
} else {
|
|
87
|
-
this.classList.add("desktop");
|
|
88
|
-
this.classList.remove("mobile");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
__decorate([
|
|
93
|
-
(0, import_decorators.addEventListener)("$window", "resize", { throttleTime: 250 }),
|
|
94
|
-
__metadata("design:type", Function),
|
|
95
|
-
__metadata("design:paramtypes", [typeof (_b = typeof Event !== "undefined" && Event) === "function" ? _b : Object]),
|
|
96
|
-
__metadata("design:returntype", void 0)
|
|
97
|
-
], ResponsiveLayout.prototype, "onWindowResize", null);
|
|
98
|
-
ResponsiveLayout = __decorate([
|
|
99
|
-
(0, import_decorators.elementDefine)("responsive-layout")
|
|
100
|
-
], ResponsiveLayout);
|
|
101
|
-
let FormInput = class FormInput2 extends HTMLElement {
|
|
102
|
-
onFormInput(event) {
|
|
103
|
-
const input = event.target;
|
|
104
|
-
const fieldName = input.name;
|
|
105
|
-
const value = input.value;
|
|
106
|
-
console.log(`Validating ${fieldName}: ${value}`);
|
|
107
|
-
this.validateField(fieldName, value);
|
|
108
|
-
}
|
|
109
|
-
validateField(name, value) {
|
|
110
|
-
const isValid = value.length > 0;
|
|
111
|
-
console.log(`Field ${name} is ${isValid ? "valid" : "invalid"}`);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
__decorate([
|
|
115
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
116
|
-
debounceTime: 300,
|
|
117
|
-
distinctUntilChanged: true
|
|
118
|
-
}),
|
|
119
|
-
__metadata("design:type", Function),
|
|
120
|
-
__metadata("design:paramtypes", [typeof (_c = typeof Event !== "undefined" && Event) === "function" ? _c : Object]),
|
|
121
|
-
__metadata("design:returntype", void 0)
|
|
122
|
-
], FormInput.prototype, "onFormInput", null);
|
|
123
|
-
FormInput = __decorate([
|
|
124
|
-
(0, import_decorators.elementDefine)("form-input")
|
|
125
|
-
], FormInput);
|
|
126
|
-
let InfiniteScroll = class InfiniteScroll2 extends HTMLElement {
|
|
127
|
-
constructor() {
|
|
128
|
-
super(...arguments);
|
|
129
|
-
this.isLoading = false;
|
|
130
|
-
}
|
|
131
|
-
onScroll(event) {
|
|
132
|
-
if (this.isLoading)
|
|
133
|
-
return;
|
|
134
|
-
if (this.isNearBottom()) {
|
|
135
|
-
console.log("Near bottom, loading more content...");
|
|
136
|
-
this.loadMoreContent();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
isNearBottom() {
|
|
140
|
-
const scrollTop = window.scrollY;
|
|
141
|
-
const windowHeight = window.innerHeight;
|
|
142
|
-
const documentHeight = document.documentElement.scrollHeight;
|
|
143
|
-
return scrollTop + windowHeight >= documentHeight - 500;
|
|
144
|
-
}
|
|
145
|
-
async loadMoreContent() {
|
|
146
|
-
this.isLoading = true;
|
|
147
|
-
try {
|
|
148
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
149
|
-
console.log("Content loaded");
|
|
150
|
-
} finally {
|
|
151
|
-
this.isLoading = false;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
__decorate([
|
|
156
|
-
(0, import_decorators.addEventListener)("$window", "scroll", { throttleTime: 100 }),
|
|
157
|
-
__metadata("design:type", Function),
|
|
158
|
-
__metadata("design:paramtypes", [typeof (_d = typeof Event !== "undefined" && Event) === "function" ? _d : Object]),
|
|
159
|
-
__metadata("design:returntype", void 0)
|
|
160
|
-
], InfiniteScroll.prototype, "onScroll", null);
|
|
161
|
-
InfiniteScroll = __decorate([
|
|
162
|
-
(0, import_decorators.elementDefine)("infinite-scroll")
|
|
163
|
-
], InfiniteScroll);
|
|
164
|
-
let LengthTracker = class LengthTracker2 extends HTMLElement {
|
|
165
|
-
onInputChange(event) {
|
|
166
|
-
const input = event.target;
|
|
167
|
-
const length = input.value.length;
|
|
168
|
-
console.log(`Input length changed to: ${length}`);
|
|
169
|
-
this.updateLengthDisplay(length);
|
|
170
|
-
}
|
|
171
|
-
updateLengthDisplay(length) {
|
|
172
|
-
const display = this.querySelector(".length-display");
|
|
173
|
-
if (display) {
|
|
174
|
-
display.textContent = `${length} characters`;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
__decorate([
|
|
179
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
180
|
-
distinctUntilChanged: (prev, curr) => {
|
|
181
|
-
return prev?.length === curr?.length;
|
|
182
|
-
}
|
|
183
|
-
}),
|
|
184
|
-
__metadata("design:type", Function),
|
|
185
|
-
__metadata("design:paramtypes", [typeof (_e = typeof Event !== "undefined" && Event) === "function" ? _e : Object]),
|
|
186
|
-
__metadata("design:returntype", void 0)
|
|
187
|
-
], LengthTracker.prototype, "onInputChange", null);
|
|
188
|
-
LengthTracker = __decorate([
|
|
189
|
-
(0, import_decorators.elementDefine)("length-tracker")
|
|
190
|
-
], LengthTracker);
|
|
191
|
-
let AutoSaveEditor = class AutoSaveEditor2 extends HTMLElement {
|
|
192
|
-
constructor() {
|
|
193
|
-
super(...arguments);
|
|
194
|
-
this.lastSavedContent = "";
|
|
195
|
-
}
|
|
196
|
-
async onContentChange(event) {
|
|
197
|
-
const textarea = event.target;
|
|
198
|
-
const content = textarea.value;
|
|
199
|
-
if (content !== this.lastSavedContent) {
|
|
200
|
-
console.log("Auto-saving content...");
|
|
201
|
-
await this.saveContent(content);
|
|
202
|
-
this.lastSavedContent = content;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
async saveContent(content) {
|
|
206
|
-
try {
|
|
207
|
-
const response = await fetch("/api/save", {
|
|
208
|
-
method: "POST",
|
|
209
|
-
headers: { "Content-Type": "application/json" },
|
|
210
|
-
body: JSON.stringify({ content })
|
|
211
|
-
});
|
|
212
|
-
if (response.ok) {
|
|
213
|
-
console.log("Content saved successfully");
|
|
214
|
-
this.showSaveIndicator();
|
|
215
|
-
}
|
|
216
|
-
} catch (error) {
|
|
217
|
-
console.error("Save failed:", error);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
showSaveIndicator() {
|
|
221
|
-
const indicator = this.querySelector(".save-indicator");
|
|
222
|
-
if (indicator) {
|
|
223
|
-
indicator.classList.add("show");
|
|
224
|
-
setTimeout(() => indicator.classList.remove("show"), 2e3);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
__decorate([
|
|
229
|
-
(0, import_decorators.addEventListener)("$this", "input", {
|
|
230
|
-
debounceTime: 2e3,
|
|
231
|
-
distinctUntilChanged: (prev, curr) => {
|
|
232
|
-
return prev === curr;
|
|
233
|
-
}
|
|
234
|
-
}),
|
|
235
|
-
__metadata("design:type", Function),
|
|
236
|
-
__metadata("design:paramtypes", [typeof (_f = typeof Event !== "undefined" && Event) === "function" ? _f : Object]),
|
|
237
|
-
__metadata("design:returntype", Promise)
|
|
238
|
-
], AutoSaveEditor.prototype, "onContentChange", null);
|
|
239
|
-
AutoSaveEditor = __decorate([
|
|
240
|
-
(0, import_decorators.elementDefine)("auto-save-editor")
|
|
241
|
-
], AutoSaveEditor);
|
|
242
|
-
let KeyboardHandler = class KeyboardHandler2 extends HTMLElement {
|
|
243
|
-
onSaveShortcut(event) {
|
|
244
|
-
event.preventDefault();
|
|
245
|
-
console.log("Save shortcut triggered");
|
|
246
|
-
this.handleSave();
|
|
247
|
-
}
|
|
248
|
-
handleSave() {
|
|
249
|
-
console.log("Saving...");
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
__decorate([
|
|
253
|
-
(0, import_decorators.addEventListener)("$document", "keydown", {
|
|
254
|
-
throttleTime: 500,
|
|
255
|
-
filter: (event) => {
|
|
256
|
-
return (event.ctrlKey || event.metaKey) && event.key === "s";
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
__metadata("design:type", Function),
|
|
260
|
-
__metadata("design:paramtypes", [typeof (_g = typeof KeyboardEvent !== "undefined" && KeyboardEvent) === "function" ? _g : Object]),
|
|
261
|
-
__metadata("design:returntype", void 0)
|
|
262
|
-
], KeyboardHandler.prototype, "onSaveShortcut", null);
|
|
263
|
-
KeyboardHandler = __decorate([
|
|
264
|
-
(0, import_decorators.elementDefine)("keyboard-handler")
|
|
265
|
-
], KeyboardHandler);
|
|
266
|
-
let MouseTracker = class MouseTracker2 extends HTMLElement {
|
|
267
|
-
onMouseMove(event) {
|
|
268
|
-
const x = event.clientX;
|
|
269
|
-
const y = event.clientY;
|
|
270
|
-
this.updateCursorPosition(x, y);
|
|
271
|
-
}
|
|
272
|
-
updateCursorPosition(x, y) {
|
|
273
|
-
console.log(`Cursor at: ${x}, ${y}`);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
__decorate([
|
|
277
|
-
(0, import_decorators.addEventListener)("$document", "mousemove", { throttleTime: 100 }),
|
|
278
|
-
__metadata("design:type", Function),
|
|
279
|
-
__metadata("design:paramtypes", [typeof (_h = typeof MouseEvent !== "undefined" && MouseEvent) === "function" ? _h : Object]),
|
|
280
|
-
__metadata("design:returntype", void 0)
|
|
281
|
-
], MouseTracker.prototype, "onMouseMove", null);
|
|
282
|
-
MouseTracker = __decorate([
|
|
283
|
-
(0, import_decorators.elementDefine)("mouse-tracker")
|
|
284
|
-
], MouseTracker);
|
|
285
|
-
//# sourceMappingURL=RxJSOperatorsExample.js.map
|