@dooboostore/simple-web-component 1.0.34 → 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/applyNode.js +4 -0
- package/dist/cjs/decorators/applyNode.js.map +2 -2
- package/dist/cjs/decorators/attribute.js +1 -1
- package/dist/cjs/decorators/attribute.js.map +2 -2
- package/dist/cjs/decorators/changedAttributeHost.js.map +2 -2
- package/dist/cjs/decorators/elementDefine.js +225 -180
- package/dist/cjs/decorators/elementDefine.js.map +2 -2
- package/dist/cjs/decorators/emitCustomEvent.js +10 -4
- 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/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/cjs/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/cjs/elements/SwcAppEngine.js +8 -2
- package/dist/cjs/elements/SwcAppEngine.js.map +2 -2
- package/dist/cjs/elements/SwcAppMixin.js +120 -65
- 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 +51 -32
- 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 +244 -117
- 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 +18 -4
- package/dist/cjs/utils/Utils.js.map +2 -2
- package/dist/esm/decorators/applyNode.js +4 -0
- package/dist/esm/decorators/applyNode.js.map +2 -2
- package/dist/esm/decorators/attribute.js +1 -1
- package/dist/esm/decorators/attribute.js.map +2 -2
- package/dist/esm/decorators/changedAttributeHost.js.map +2 -2
- package/dist/esm/decorators/elementDefine.js +226 -181
- package/dist/esm/decorators/elementDefine.js.map +2 -2
- package/dist/esm/decorators/emitCustomEvent.js +10 -4
- 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/subscribeSwcAppRouteChangeWhileConnected.js +2 -2
- package/dist/esm/decorators/subscribeSwcAppRouteChangeWhileConnected.js.map +2 -2
- package/dist/esm/elements/SwcAppEngine.js +9 -2
- package/dist/esm/elements/SwcAppEngine.js.map +2 -2
- package/dist/esm/elements/SwcAppMixin.js +122 -66
- 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 +51 -32
- 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 +244 -117
- 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 +18 -4
- package/dist/esm/utils/Utils.js.map +2 -2
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js +319 -276
- package/dist/esm-bundle/dooboostore-simple-web-component.esm.js.map +4 -4
- package/dist/types/decorators/applyNode.d.ts +1 -0
- package/dist/types/decorators/applyNode.d.ts.map +1 -1
- package/dist/types/decorators/changedAttributeHost.d.ts +1 -0
- package/dist/types/decorators/changedAttributeHost.d.ts.map +1 -1
- package/dist/types/decorators/elementDefine.d.ts.map +1 -1
- package/dist/types/decorators/emitCustomEvent.d.ts +10 -6
- 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/subscribeSwcAppRouteChangeWhileConnected.d.ts +4 -5
- package/dist/types/decorators/subscribeSwcAppRouteChangeWhileConnected.d.ts.map +1 -1
- package/dist/types/elements/SwcAppEngine.d.ts +4 -1
- package/dist/types/elements/SwcAppEngine.d.ts.map +1 -1
- package/dist/types/elements/SwcAppMixin.d.ts +11 -8
- 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 +319 -276
- package/dist/umd-bundle/dooboostore-simple-web-component.umd.js.map +4 -4
- package/package.json +4 -4
- package/src/decorators/applyNode.ts +13 -1
- package/src/decorators/attribute.ts +1 -1
- package/src/decorators/changedAttributeHost.ts +3 -2
- package/src/decorators/elementDefine.ts +397 -354
- package/src/decorators/emitCustomEvent.ts +29 -15
- package/src/decorators/lifecycles.ts +11 -10
- package/src/decorators/subscribeSwcAppRouteChangeWhileConnected.ts +10 -10
- package/src/elements/SwcAppEngine.ts +10 -3
- package/src/elements/SwcAppMixin.ts +177 -97
- package/src/elements/SwcAsync.ts +28 -17
- package/src/elements/SwcChoose.ts +71 -34
- package/src/elements/SwcIf.ts +59 -22
- package/src/elements/SwcLoop.ts +140 -27
- package/src/elements/register.ts +296 -98
- package/src/types.ts +1 -0
- package/src/utils/Utils.ts +23 -5
- package/tsconfig.json +2 -2
|
@@ -142,7 +142,13 @@ const setupPrototype = (proto) => {
|
|
|
142
142
|
const app = useHostSet?.$appHost?.simpleApplication;
|
|
143
143
|
if (app) {
|
|
144
144
|
const otherStorage = /* @__PURE__ */ new Map();
|
|
145
|
-
const situations = new import_Inject.SituationTypeContainers([new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOST_SET, data: useHostSet }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOST, data: useHostSet.$appHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts }), new import_Inject.SituationTypeContainer({
|
|
145
|
+
const situations = new import_Inject.SituationTypeContainers([new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOST_SET, data: useHostSet }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOST, data: useHostSet.$appHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.APP_HOSTS, data: useHostSet.$appHosts }), new import_Inject.SituationTypeContainer({
|
|
146
|
+
situationType: import_types.InjectSituationType.HOST,
|
|
147
|
+
data: useHostSet.$host
|
|
148
|
+
}), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.HOSTS, data: useHostSet.$hosts }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.FIRST_HOST, data: useHostSet.$firstHost }), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_HOST, data: useHostSet.$lastHost }), new import_Inject.SituationTypeContainer({
|
|
149
|
+
situationType: import_types.InjectSituationType.FIRST_APP_HOST,
|
|
150
|
+
data: useHostSet.$firstAppHost
|
|
151
|
+
}), new import_Inject.SituationTypeContainer({ situationType: import_types.InjectSituationType.LAST_APP_HOST, data: useHostSet.$lastAppHost })]);
|
|
146
152
|
otherStorage.set(import_Inject.SituationTypeContainers, situations);
|
|
147
153
|
return app.simstanceManager.executeBindParameterSim(
|
|
148
154
|
{
|
|
@@ -235,203 +241,243 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
235
241
|
const swcOnEvents = import_config.DOM_EVENT_NAMES.map((e) => `swc-on-${e}`);
|
|
236
242
|
const attributeApplyNames = Array.from(applyAttributeMap.values()).map((it) => it.options.name).filter(Boolean);
|
|
237
243
|
const hostAttributes = attributeList.filter((it) => it.selector === ":host").map((it) => it.options.name || String(it.propertyKey));
|
|
238
|
-
const proto = constructor.prototype;
|
|
239
244
|
const originalStaticObservedAttributes = constructor.observedAttributes ?? [];
|
|
240
|
-
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([
|
|
241
|
-
...metadata.observedAttributes ?? [],
|
|
242
|
-
...originalStaticObservedAttributes,
|
|
243
|
-
...attrChangeMap.keys(),
|
|
244
|
-
...attributeApplyNames,
|
|
245
|
-
...hostAttributes,
|
|
246
|
-
...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean),
|
|
247
|
-
...swcLifecycleAttributes,
|
|
248
|
-
...swcOnEvents
|
|
249
|
-
])];
|
|
245
|
+
const mergedObservedAttributes = [.../* @__PURE__ */ new Set([...metadata.observedAttributes ?? [], ...originalStaticObservedAttributes, ...attrChangeMap.keys(), ...attributeApplyNames, ...hostAttributes, ...emitHostCustomEventList.map((it) => it.options.attributeName).filter(Boolean), ...swcLifecycleAttributes, ...swcOnEvents])];
|
|
250
246
|
const connectedInnerHtmlList = (0, import_lifecycles.getOnConnectedInnerHtmlMetadata)(constructor) || [];
|
|
247
|
+
const proto = constructor.prototype;
|
|
251
248
|
setupPrototype(proto);
|
|
249
|
+
let helperHostSet = null;
|
|
252
250
|
const originalConnected = proto.connectedCallback;
|
|
253
|
-
proto.connectedCallback = function() {
|
|
251
|
+
proto.connectedCallback = async function() {
|
|
254
252
|
ensureInit(this);
|
|
255
|
-
|
|
256
|
-
const appHost =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
this._executeSwcScript("swc-on-before-connected", hostSet);
|
|
265
|
-
const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
266
|
-
if (bMethods) {
|
|
267
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
268
|
-
}
|
|
269
|
-
if (connectedInnerHtmlList.length > 0) {
|
|
270
|
-
let sContent = "", lContent = "";
|
|
271
|
-
for (const meta of connectedInnerHtmlList) {
|
|
272
|
-
const res = this._invokeLifecycleMethod(meta.propertyKey, hostSet);
|
|
273
|
-
if (res !== void 0) {
|
|
274
|
-
if (meta.options.useShadow || conf?.useShadow) sContent += res;
|
|
275
|
-
else lContent += res;
|
|
276
|
-
}
|
|
253
|
+
helperHostSet = import_Utils.SwcUtils.getHelperAndHostSet(win, this);
|
|
254
|
+
const appHost = helperHostSet.$appHost;
|
|
255
|
+
try {
|
|
256
|
+
if (appHost && typeof appHost._connected === "function") {
|
|
257
|
+
await appHost._connected(this);
|
|
258
|
+
} else if (appHost && typeof appHost) {
|
|
259
|
+
appHost._connected_safari ?? (appHost._connected_safari = []);
|
|
260
|
+
appHost._connected_safari.push(this);
|
|
277
261
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
const root = this.getRootNode();
|
|
286
|
-
if (!globalDelegatedRoots.has(root)) {
|
|
287
|
-
import_config.DOM_EVENT_NAMES.forEach((type) => {
|
|
288
|
-
root.addEventListener(type, handleGlobalSwcEvent);
|
|
289
|
-
});
|
|
290
|
-
globalDelegatedRoots.add(root);
|
|
291
|
-
}
|
|
292
|
-
const delegateListeners = [];
|
|
293
|
-
const nonDelegateListeners = [];
|
|
294
|
-
addEventListenerList.forEach((meta) => {
|
|
295
|
-
if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
|
|
296
|
-
delegateListeners.push(meta);
|
|
297
|
-
} else {
|
|
298
|
-
nonDelegateListeners.push(meta);
|
|
262
|
+
const conf = getElementConfig(this);
|
|
263
|
+
const currentWin = this._resolveWindow(conf);
|
|
264
|
+
const shadowMode = conf?.useShadow || connectedInnerHtmlList.find((it) => it.options.useShadow)?.options.useShadow;
|
|
265
|
+
if (shadowMode && !this.shadowRoot) {
|
|
266
|
+
const mode = shadowMode === true ? "open" : shadowMode;
|
|
267
|
+
this.attachShadow({ mode });
|
|
299
268
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const r = meta.options.root || "auto";
|
|
304
|
-
const rootKey = `${meta.type}:${r}`;
|
|
305
|
-
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
306
|
-
delegatesByTypeAndRoot.set(rootKey, []);
|
|
269
|
+
const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_CONNECTED_METADATA_KEY);
|
|
270
|
+
if (bMethods) {
|
|
271
|
+
for (const m of bMethods) await this._invokeLifecycleMethod(m, helperHostSet);
|
|
307
272
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
273
|
+
this._executeSwcScript("swc-on-before-connected", helperHostSet);
|
|
274
|
+
if (connectedInnerHtmlList.length > 0) {
|
|
275
|
+
let sContent = "", lContent = "";
|
|
276
|
+
for (const meta of connectedInnerHtmlList) {
|
|
277
|
+
let res = await this._invokeLifecycleMethod(meta.propertyKey, helperHostSet);
|
|
278
|
+
const actionExpression = new import_core.ActionExpression(res, {
|
|
279
|
+
expression: {
|
|
280
|
+
replace: {
|
|
281
|
+
start: meta.options.replaceWrap?.start || "{%{",
|
|
282
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
283
|
+
},
|
|
284
|
+
callReturn: {
|
|
285
|
+
start: meta.options.replaceWrap?.start || "{%{=",
|
|
286
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
287
|
+
},
|
|
288
|
+
call: {
|
|
289
|
+
start: meta.options.replaceWrap?.start || "{%{@",
|
|
290
|
+
end: meta.options.replaceWrap?.end || "}%}"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
actionExpression.getExpressions().filter((it) => it.type === "replace").forEach((it) => {
|
|
295
|
+
try {
|
|
296
|
+
const sr = import_core.FunctionUtils.executeReturn({ script: it.script, context: this, args: helperHostSet });
|
|
297
|
+
actionExpression.replace(it, sr);
|
|
298
|
+
} catch (e) {
|
|
299
|
+
console.error(`[SWC] Failed to execute connectedInnerHTML:`, e);
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
res = actionExpression.getUnprocessedTemplate();
|
|
303
|
+
if (res !== void 0) {
|
|
304
|
+
if (meta.options.useShadow || conf?.useShadow) sContent += res;
|
|
305
|
+
else lContent += res;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
try {
|
|
309
|
+
if (this.shadowRoot) {
|
|
310
|
+
this.shadowRoot.innerHTML = sContent;
|
|
311
|
+
}
|
|
312
|
+
if (lContent) {
|
|
313
|
+
this.innerHTML = lContent;
|
|
314
|
+
}
|
|
315
|
+
} catch (e) {
|
|
316
|
+
console.error("[ElementDefine] innerHTML setting error:", e);
|
|
317
|
+
}
|
|
321
318
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return bStop - aStop;
|
|
319
|
+
const root = this.getRootNode();
|
|
320
|
+
if (!globalDelegatedRoots.has(root)) {
|
|
321
|
+
import_config.DOM_EVENT_NAMES.forEach((type) => {
|
|
322
|
+
root.addEventListener(type, handleGlobalSwcEvent);
|
|
327
323
|
});
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
324
|
+
globalDelegatedRoots.add(root);
|
|
325
|
+
}
|
|
326
|
+
const delegateListeners = [];
|
|
327
|
+
const nonDelegateListeners = [];
|
|
328
|
+
addEventListenerList.forEach((meta) => {
|
|
329
|
+
if (meta.options.delegate && meta.selector !== ":window" && meta.selector !== ":document" && meta.selector !== ":parentHost" && meta.selector !== ":appHost" && meta.selector !== ":firstHost" && meta.selector !== ":lastHost" && meta.selector !== ":firstAppHost" && meta.selector !== ":lastAppHost" && meta.selector !== ":hosts" && meta.selector !== ":appHosts" && meta.selector !== ":host" && meta.selector !== "") {
|
|
330
|
+
delegateListeners.push(meta);
|
|
331
|
+
} else {
|
|
332
|
+
nonDelegateListeners.push(meta);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
const delegatesByTypeAndRoot = /* @__PURE__ */ new Map();
|
|
336
|
+
delegateListeners.forEach((meta) => {
|
|
337
|
+
const r = meta.options.root || "auto";
|
|
338
|
+
const rootKey = `${meta.type}:${r}`;
|
|
339
|
+
if (!delegatesByTypeAndRoot.has(rootKey)) {
|
|
340
|
+
delegatesByTypeAndRoot.set(rootKey, []);
|
|
341
|
+
}
|
|
342
|
+
delegatesByTypeAndRoot.get(rootKey).push(meta);
|
|
343
|
+
});
|
|
344
|
+
delegatesByTypeAndRoot.forEach((metaList, typeRootKey) => {
|
|
345
|
+
const [type, rStr] = typeRootKey.split(":");
|
|
346
|
+
const r = rStr === "auto" ? "auto" : rStr;
|
|
347
|
+
const opts = { capture: metaList[0].options.capture, once: metaList[0].options.once, passive: metaList[0].options.passive };
|
|
348
|
+
const bindRoots = [];
|
|
349
|
+
if (r === "auto") bindRoots.push(this.shadowRoot || this);
|
|
350
|
+
else if (r === "light") bindRoots.push(this);
|
|
351
|
+
else if (r === "shadow" && this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
352
|
+
else if (r === "all") {
|
|
353
|
+
bindRoots.push(this);
|
|
354
|
+
if (this.shadowRoot) bindRoots.push(this.shadowRoot);
|
|
355
|
+
}
|
|
356
|
+
bindRoots.forEach((br) => {
|
|
357
|
+
const sortedMetaList = [...metaList].sort((a, b) => {
|
|
358
|
+
const aStop = a.options.stopPropagation ? 1 : 0;
|
|
359
|
+
const bStop = b.options.stopPropagation ? 1 : 0;
|
|
360
|
+
return bStop - aStop;
|
|
361
|
+
});
|
|
362
|
+
const unifiedHandler = async (event) => {
|
|
363
|
+
for (const meta of sortedMetaList) {
|
|
364
|
+
const { selector, options } = meta;
|
|
365
|
+
const matchedEl = event.target.closest(selector);
|
|
366
|
+
if (matchedEl && br.contains(matchedEl)) {
|
|
367
|
+
if (options.filter) {
|
|
368
|
+
const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, matchedEl);
|
|
369
|
+
if (!options.filter(event, helper)) {
|
|
370
|
+
continue;
|
|
371
|
+
}
|
|
337
372
|
}
|
|
373
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
374
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
375
|
+
if (options.preventDefault) event.preventDefault();
|
|
376
|
+
const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
377
|
+
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
378
|
+
await this[meta.propertyKey](event, { ...currentHostSet, $matchedElement: matchedEl }, args);
|
|
379
|
+
if (event.cancelBubble) break;
|
|
338
380
|
}
|
|
339
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
340
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
341
|
-
if (options.preventDefault) event.preventDefault();
|
|
342
|
-
const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
343
|
-
const args = { event, ...currentHostSet, $el: matchedEl, $root: br };
|
|
344
|
-
await this[meta.propertyKey](event, currentHostSet, matchedEl, args);
|
|
345
|
-
if (event.cancelBubble) break;
|
|
346
381
|
}
|
|
382
|
+
};
|
|
383
|
+
br.addEventListener(type, unifiedHandler, opts);
|
|
384
|
+
this._boundListeners.push({ target: br, type, handler: unifiedHandler, options: opts });
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
nonDelegateListeners.forEach((meta) => {
|
|
388
|
+
const { selector, type, options } = meta;
|
|
389
|
+
const opts = { capture: options.capture, once: options.once, passive: options.passive };
|
|
390
|
+
const bindTargets = [];
|
|
391
|
+
const r = options.root || "auto";
|
|
392
|
+
const applyRootOption = (target) => {
|
|
393
|
+
if (!target) return;
|
|
394
|
+
if (r === "auto") {
|
|
395
|
+
bindTargets.push(target.shadowRoot || target);
|
|
396
|
+
} else {
|
|
397
|
+
if (r === "light" || r === "all") bindTargets.push(target);
|
|
398
|
+
if ((r === "shadow" || r === "all") && target.shadowRoot) bindTargets.push(target.shadowRoot);
|
|
347
399
|
}
|
|
348
400
|
};
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
if (!
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (r === "light"
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
else if (selector === ":lastHost") applyRootOption(hostSet.$lastHost);
|
|
373
|
-
else if (selector === ":firstAppHost") applyRootOption(hostSet.$firstAppHost);
|
|
374
|
-
else if (selector === ":lastAppHost") applyRootOption(hostSet.$lastAppHost);
|
|
375
|
-
else if (selector === ":hosts") hostSet.$hosts.forEach(applyRootOption);
|
|
376
|
-
else if (selector === ":appHosts") hostSet.$appHosts.forEach(applyRootOption);
|
|
377
|
-
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
378
|
-
else {
|
|
379
|
-
const searchRoots = [];
|
|
380
|
-
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
381
|
-
else if (r === "light") searchRoots.push(this);
|
|
382
|
-
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
383
|
-
else if (r === "all") {
|
|
384
|
-
searchRoots.push(this);
|
|
385
|
-
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
401
|
+
if (selector === ":window") bindTargets.push(currentWin);
|
|
402
|
+
else if (selector === ":document") bindTargets.push(currentWin.document);
|
|
403
|
+
else if (selector === ":parentHost") applyRootOption(helperHostSet.$parentHost);
|
|
404
|
+
else if (selector === ":appHost") applyRootOption(helperHostSet.$appHost);
|
|
405
|
+
else if (selector === ":firstHost") applyRootOption(helperHostSet.$firstHost);
|
|
406
|
+
else if (selector === ":lastHost") applyRootOption(helperHostSet.$lastHost);
|
|
407
|
+
else if (selector === ":firstAppHost") applyRootOption(helperHostSet.$firstAppHost);
|
|
408
|
+
else if (selector === ":lastAppHost") applyRootOption(helperHostSet.$lastAppHost);
|
|
409
|
+
else if (selector === ":hosts") helperHostSet.$hosts.forEach(applyRootOption);
|
|
410
|
+
else if (selector === ":appHosts") helperHostSet.$appHosts.forEach(applyRootOption);
|
|
411
|
+
else if (selector === ":host" || !selector) applyRootOption(this);
|
|
412
|
+
else {
|
|
413
|
+
const searchRoots = [];
|
|
414
|
+
if (r === "auto") searchRoots.push(this.shadowRoot || this);
|
|
415
|
+
else if (r === "light") searchRoots.push(this);
|
|
416
|
+
else if (r === "shadow" && this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
417
|
+
else if (r === "all") {
|
|
418
|
+
searchRoots.push(this);
|
|
419
|
+
if (this.shadowRoot) searchRoots.push(this.shadowRoot);
|
|
420
|
+
}
|
|
421
|
+
searchRoots.forEach((sr) => {
|
|
422
|
+
sr.querySelectorAll(selector).forEach((el) => bindTargets.push(el));
|
|
423
|
+
});
|
|
386
424
|
}
|
|
387
|
-
|
|
388
|
-
|
|
425
|
+
bindTargets.forEach((t) => {
|
|
426
|
+
const handler = async (event) => {
|
|
427
|
+
if (options.filter) {
|
|
428
|
+
const helper = import_Utils.SwcUtils.getHelperAndHostSet(currentWin, t);
|
|
429
|
+
if (!options.filter(event, { currentThis: this, helper })) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (options.stopPropagation) event.stopPropagation();
|
|
434
|
+
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
435
|
+
if (options.preventDefault) event.preventDefault();
|
|
436
|
+
const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
437
|
+
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
438
|
+
await this[meta.propertyKey](event, { currentHostSet, $$matchedElement: event.currentTarget }, args);
|
|
439
|
+
};
|
|
440
|
+
t.addEventListener(type, handler, opts);
|
|
441
|
+
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
442
|
+
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
443
|
+
}
|
|
389
444
|
});
|
|
445
|
+
});
|
|
446
|
+
if (originalConnected) await originalConnected.apply(this);
|
|
447
|
+
const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_CONNECTED_METADATA_KEY);
|
|
448
|
+
if (aMethods) {
|
|
449
|
+
for (const m of aMethods) await this._invokeLifecycleMethod(m, helperHostSet);
|
|
390
450
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
451
|
+
this._executeSwcScript("swc-on-connected", helperHostSet);
|
|
452
|
+
this._executeSwcScript("swc-on-after-connected", helperHostSet);
|
|
453
|
+
this.__swc_connected = true;
|
|
454
|
+
for (let [name2, metaList] of Array.from(attrChangeMap)) {
|
|
455
|
+
for (const meta of metaList) {
|
|
456
|
+
if (meta.options.while === "connected") {
|
|
457
|
+
const val = (0, import_attribute.getAttributeValue)(this, name2, { type: meta.options.type });
|
|
458
|
+
if (val !== null) {
|
|
459
|
+
await this[meta.propertyKey](val, null, name2, helperHostSet);
|
|
397
460
|
}
|
|
398
461
|
}
|
|
399
|
-
if (options.stopPropagation) event.stopPropagation();
|
|
400
|
-
if (options.stopImmediatePropagation) event.stopImmediatePropagation();
|
|
401
|
-
if (options.preventDefault) event.preventDefault();
|
|
402
|
-
const currentHostSet = import_Utils.SwcUtils.getHostSet(this);
|
|
403
|
-
const args = { event, ...currentHostSet, $el: t, $root: t };
|
|
404
|
-
await this[meta.propertyKey](event, currentHostSet, args);
|
|
405
|
-
};
|
|
406
|
-
t.addEventListener(type, handler, opts);
|
|
407
|
-
if (options.removeOnDisconnected === true || t === currentWin || t === currentWin.document) {
|
|
408
|
-
this._boundListeners.push({ target: t, type, handler, options: opts });
|
|
409
462
|
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m, hostSet);
|
|
416
|
-
}
|
|
417
|
-
this._executeSwcScript("swc-on-connected", hostSet);
|
|
418
|
-
this._executeSwcScript("swc-on-after-connected", hostSet);
|
|
419
|
-
this.__swc_connected = true;
|
|
420
|
-
const appHostss = import_Utils.SwcUtils.findAllParentAppHostsDirect(this);
|
|
421
|
-
if (appHost && typeof appHost._connected === "function") {
|
|
422
|
-
appHost._connected(this);
|
|
423
|
-
} else if (appHost && typeof appHost) {
|
|
424
|
-
appHost._connected_safari ?? (appHost._connected_safari = []);
|
|
425
|
-
appHost._connected_safari.push(this);
|
|
463
|
+
}
|
|
464
|
+
} finally {
|
|
465
|
+
if (appHost && typeof appHost._connectedDone === "function") {
|
|
466
|
+
await appHost._connectedDone(this);
|
|
467
|
+
}
|
|
426
468
|
}
|
|
427
469
|
};
|
|
428
470
|
const originalDisconnected = proto.disconnectedCallback;
|
|
429
471
|
proto.disconnectedCallback = function() {
|
|
430
|
-
|
|
431
|
-
|
|
472
|
+
console.log("disconnnnnnnnnnnnnnnnnnn", helperHostSet, this);
|
|
473
|
+
const appHost = helperHostSet.$appHost;
|
|
474
|
+
if (appHost && typeof appHost._disconnected === "function") {
|
|
475
|
+
appHost._disconnected(this);
|
|
476
|
+
}
|
|
477
|
+
this._executeSwcScript("swc-on-before-disconnected", helperHostSet);
|
|
432
478
|
const bMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_BEFORE_DISCONNECTED_METADATA_KEY);
|
|
433
479
|
if (bMethods) {
|
|
434
|
-
for (const m of bMethods) this._invokeLifecycleMethod(m,
|
|
480
|
+
for (const m of bMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
435
481
|
}
|
|
436
482
|
if (this._boundListeners) {
|
|
437
483
|
this._boundListeners.forEach((l) => l.target.removeEventListener(l.type, l.handler, l.options));
|
|
@@ -440,15 +486,11 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
440
486
|
if (originalDisconnected) originalDisconnected.apply(this);
|
|
441
487
|
const aMethods = (0, import_lifecycles.findAllLifecycleMetadata)(this, import_lifecycles.ON_AFTER_DISCONNECTED_METADATA_KEY);
|
|
442
488
|
if (aMethods) {
|
|
443
|
-
for (const m of aMethods) this._invokeLifecycleMethod(m,
|
|
489
|
+
for (const m of aMethods) this._invokeLifecycleMethod(m, helperHostSet);
|
|
444
490
|
}
|
|
445
|
-
this._executeSwcScript("swc-on-disconnected",
|
|
446
|
-
this._executeSwcScript("swc-on-after-disconnected",
|
|
491
|
+
this._executeSwcScript("swc-on-disconnected", helperHostSet);
|
|
492
|
+
this._executeSwcScript("swc-on-after-disconnected", helperHostSet);
|
|
447
493
|
this.__swc_connected = false;
|
|
448
|
-
const appHost = hostSet.$appHost;
|
|
449
|
-
if (appHost && typeof appHost._disconnected === "function") {
|
|
450
|
-
appHost._disconnected(this);
|
|
451
|
-
}
|
|
452
494
|
};
|
|
453
495
|
const originalAdopted = proto.adoptedCallback;
|
|
454
496
|
proto.adoptedCallback = function() {
|
|
@@ -473,12 +515,12 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
473
515
|
let processedVal = newVal;
|
|
474
516
|
if (newVal !== null) {
|
|
475
517
|
const ae = new import_core.ActionExpression(newVal);
|
|
476
|
-
const expr = ae.getFirstExpression("
|
|
518
|
+
const expr = ae.getFirstExpression("callReturn");
|
|
477
519
|
if (expr) {
|
|
478
520
|
const win2 = this._resolveWindow?.() || (typeof window !== "undefined" ? window : void 0);
|
|
479
521
|
const helperAndHostSet = import_Utils.SwcUtils.getHelperAndHostSet(win2, this);
|
|
522
|
+
const script = import_core_web.ConvertUtils.decodeHtmlEntity(expr.script, win2.document);
|
|
480
523
|
try {
|
|
481
|
-
const script = import_core_web.ConvertUtils.decodeHtmlEntity(expr.script, win2.document);
|
|
482
524
|
const result = import_core.FunctionUtils.executeReturn({
|
|
483
525
|
script,
|
|
484
526
|
context: this,
|
|
@@ -504,6 +546,9 @@ const elementDefine = (name, config = {}) => (constructor) => {
|
|
|
504
546
|
const metaList = attrChangeMap.get(name2);
|
|
505
547
|
if (metaList && Array.isArray(metaList)) {
|
|
506
548
|
for (const meta of metaList) {
|
|
549
|
+
if (meta.options.while === "connected" && !this.__swc_connected) {
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
507
552
|
const convertedVal = (0, import_changedAttributeHost.convertAttributeValue)(processedVal, meta.options.type);
|
|
508
553
|
this[meta.propertyKey](convertedVal, old, name2, hSet);
|
|
509
554
|
}
|