@@ -3,4 +3,48 @@ import RelativeTimeElement from './relative-time-element.js'
33import TimeAgoElement from './time-ago-element.js'
44import TimeUntilElement from './time-until-element.js'
55
6+ const root = ( typeof globalThis !== 'undefined' ? globalThis : window ) as typeof window
7+ try {
8+ customElements . define ( 'relative-time' , RelativeTimeElement )
9+ root . RelativeTimeElement = RelativeTimeElement
10+ } catch ( e : unknown ) {
11+ if ( ! ( e instanceof DOMException && e . name === 'NotSupportedError' ) && ! ( e instanceof ReferenceError ) ) throw e
12+ }
13+
14+ try {
15+ customElements . define ( 'local-time' , LocalTimeElement )
16+ root . LocalTimeElement = LocalTimeElement
17+ } catch ( e : unknown ) {
18+ if ( ! ( e instanceof DOMException && e . name === 'NotSupportedError' ) && ! ( e instanceof ReferenceError ) ) throw e
19+ }
20+
21+ try {
22+ customElements . define ( 'time-ago' , TimeAgoElement )
23+ root . TimeAgoElement = TimeAgoElement
24+ } catch ( e : unknown ) {
25+ if ( ! ( e instanceof DOMException && e . name === 'NotSupportedError' ) && ! ( e instanceof ReferenceError ) ) throw e
26+ }
27+
28+ try {
29+ customElements . define ( 'time-until' , TimeUntilElement )
30+ root . TimeUntilElement = TimeUntilElement
31+ } catch ( e : unknown ) {
32+ if ( ! ( e instanceof DOMException && e . name === 'NotSupportedError' ) && ! ( e instanceof ReferenceError ) ) throw e
33+ }
34+
35+ declare global {
36+ interface Window {
37+ RelativeTimeElement : typeof RelativeTimeElement
38+ LocalTimeElement : typeof LocalTimeElement
39+ TimeAgoElement : typeof TimeAgoElement
40+ TimeUntilElement : typeof TimeUntilElement
41+ }
42+ interface HTMLElementTagNameMap {
43+ 'relative-time' : RelativeTimeElement
44+ 'local-time' : LocalTimeElement
45+ 'time-ago' : TimeAgoElement
46+ 'time-until' : TimeUntilElement
47+ }
48+ }
49+
650export { LocalTimeElement , RelativeTimeElement , TimeAgoElement , TimeUntilElement }
0 commit comments