@spectrum-web-components/base
Advanced tools
Comparing version 0.4.4-alpha.101 to 0.4.4-alpha.135
{ | ||
"name": "@spectrum-web-components/base", | ||
"version": "0.4.4-alpha.101+24b598bc7", | ||
"version": "0.4.4-alpha.135+ed84dff79", | ||
"publishConfig": { | ||
@@ -51,3 +51,3 @@ "access": "public" | ||
"sideEffects": false, | ||
"gitHead": "24b598bc7c57c7f279c8957abbc0b0827ecd7089" | ||
"gitHead": "ed84dff79fd23708ed6c63a8114290217d9c17ad" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { Part } from 'lit'; | ||
import { nothing, Part } from 'lit'; | ||
import { AsyncDirective } from 'lit/async-directive.js'; | ||
@@ -12,3 +12,3 @@ import type { DirectiveResult } from 'lit/directive.js'; | ||
declare class StreamingListenerDirective extends AsyncDirective { | ||
host: EventTarget | object | Element; | ||
host: EventTarget | Record<string, unknown> | Element; | ||
element: Element; | ||
@@ -20,12 +20,12 @@ start: ListenerConfig; | ||
state: 'off' | 'on'; | ||
render(_configGroup: ListenerConfigGroup): symbol; | ||
render(_configGroup: ListenerConfigGroup): typeof nothing; | ||
update(part: Part, [{ start, end, streamInside, streamOutside, },]: Parameters<this['render']>): void; | ||
addListeners(state?: 'on' | 'off'): void; | ||
callHandler(value: Function | EventListenerObject, event: any): void; | ||
handleStart: (event: any) => void; | ||
handleStream: (event: any) => void; | ||
handleEnd: (event: any) => void; | ||
handleBetween: (event: any) => void; | ||
addListener(type: string | string[], fn: (event: any) => void): void; | ||
removeListener(type: string | string[], fn: (event: any) => void): void; | ||
callHandler(value: (event: Event) => void | EventListenerObject, event: Event): void; | ||
handleStart: (event: Event) => void; | ||
handleStream: (event: Event) => void; | ||
handleEnd: (event: Event) => void; | ||
handleBetween: (event: Event) => void; | ||
addListener(type: string | string[], fn: (event: Event) => void): void; | ||
removeListener(type: string | string[], fn: (event: Event) => void): void; | ||
removeListeners(): void; | ||
@@ -32,0 +32,0 @@ disconnected(): void; |
@@ -15,4 +15,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import { directive, AsyncDirective } from 'lit/async-directive.js'; | ||
/* c8 ignore next */ | ||
const defaultListener = ['', () => { }]; | ||
/* c8 ignore next 6 */ | ||
const defaultListener = [ | ||
'', | ||
() => { | ||
return; | ||
}, | ||
]; | ||
class StreamingListenerDirective extends AsyncDirective { | ||
@@ -46,3 +51,4 @@ constructor() { | ||
} | ||
/* c8 ignore next 3 */ | ||
/* c8 ignore next 4 */ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
render(_configGroup) { | ||
@@ -57,3 +63,4 @@ return nothing; | ||
} | ||
this.host = ((_a = part.options) === null || _a === void 0 ? void 0 : _a.host) || this.element; | ||
this.host = | ||
((_a = part.options) === null || _a === void 0 ? void 0 : _a.host) || this.element; | ||
this.start = start; | ||
@@ -60,0 +67,0 @@ this.end = end; |
@@ -25,7 +25,12 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/* c8 ignore next */ | ||
const defaultListener: ListenerConfig = ['', () => {}]; | ||
/* c8 ignore next 6 */ | ||
const defaultListener: ListenerConfig = [ | ||
'', | ||
(): void => { | ||
return; | ||
}, | ||
]; | ||
class StreamingListenerDirective extends AsyncDirective { | ||
host!: EventTarget | object | Element; | ||
host!: EventTarget | Record<string, unknown> | Element; | ||
element!: Element; | ||
@@ -40,4 +45,5 @@ | ||
/* c8 ignore next 3 */ | ||
render(_configGroup: ListenerConfigGroup) { | ||
/* c8 ignore next 4 */ | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
render(_configGroup: ListenerConfigGroup): typeof nothing { | ||
return nothing; | ||
@@ -56,3 +62,3 @@ } | ||
]: Parameters<this['render']> | ||
) { | ||
): void { | ||
if (this.element !== (part as ElementPart).element) { | ||
@@ -62,3 +68,4 @@ this.element = (part as ElementPart).element; | ||
} | ||
this.host = part.options?.host || this.element; | ||
this.host = | ||
(part.options?.host as Record<string, unknown>) || this.element; | ||
this.start = start; | ||
@@ -82,5 +89,8 @@ this.end = end; | ||
callHandler(value: Function | EventListenerObject, event: any): void { | ||
callHandler( | ||
value: (event: Event) => void | EventListenerObject, | ||
event: Event | ||
): void { | ||
if (typeof value === 'function') { | ||
(value as Function).call(this.host, event); | ||
(value as (event: Event) => void).call(this.host, event); | ||
} else { | ||
@@ -91,3 +101,3 @@ (value as EventListenerObject).handleEvent(event); | ||
handleStart = (event: any): void => { | ||
handleStart = (event: Event): void => { | ||
this.callHandler(this.start[1], event); | ||
@@ -101,7 +111,7 @@ if (event.defaultPrevented) { | ||
handleStream = (event: any): void => { | ||
handleStream = (event: Event): void => { | ||
this.callHandler(this.streamInside[1], event); | ||
}; | ||
handleEnd = (event: any): void => { | ||
handleEnd = (event: Event): void => { | ||
this.callHandler(this.end[1], event); | ||
@@ -112,7 +122,7 @@ this.removeListeners(); | ||
handleBetween = (event: any): void => { | ||
handleBetween = (event: Event): void => { | ||
this.callHandler(this.streamOutside[1], event); | ||
}; | ||
addListener(type: string | string[], fn: (event: any) => void): void { | ||
addListener(type: string | string[], fn: (event: Event) => void): void { | ||
if (Array.isArray(type)) { | ||
@@ -127,3 +137,3 @@ type.map((eventName) => { | ||
removeListener(type: string | string[], fn: (event: any) => void): void { | ||
removeListener(type: string | string[], fn: (event: Event) => void): void { | ||
if (Array.isArray(type)) { | ||
@@ -145,7 +155,7 @@ type.map((eventName) => { | ||
disconnected() { | ||
disconnected(): void { | ||
this.removeListeners(); | ||
} | ||
reconnected() { | ||
reconnected(): void { | ||
this.addListeners(); | ||
@@ -152,0 +162,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
72114
711