aboutsummaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/ContextEvent.ts
diff options
context:
space:
mode:
authorGravatar Erika <3019731+Princesseuh@users.noreply.github.com> 2023-01-10 15:29:06 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-10 15:29:06 +0100
commitc55fbcb8edca1fe118a44f68c9f9436a4719d171 (patch)
tree2bde21dfe19aee8a984a3f5b678b2ee6603876da /packages/webapi/src/lib/ContextEvent.ts
parentcf5dc2adae04c1ab3fcf95bb2426e82733737852 (diff)
downloadastro-c55fbcb8edca1fe118a44f68c9f9436a4719d171.tar.gz
astro-c55fbcb8edca1fe118a44f68c9f9436a4719d171.tar.zst
astro-c55fbcb8edca1fe118a44f68c9f9436a4719d171.zip
Remove more unnecessary polyfills from webapi for Node 16 (#5814)
* feat(webapi): Remove unnecessary polyfills now that we dropped support for Node 14 * feat(webapi): Removed more unnecessary polyfills for Node 16 * chore: changeset
Diffstat (limited to 'packages/webapi/src/lib/ContextEvent.ts')
-rw-r--r--packages/webapi/src/lib/ContextEvent.ts57
1 files changed, 0 insertions, 57 deletions
diff --git a/packages/webapi/src/lib/ContextEvent.ts b/packages/webapi/src/lib/ContextEvent.ts
deleted file mode 100644
index e712c4da1..000000000
--- a/packages/webapi/src/lib/ContextEvent.ts
+++ /dev/null
@@ -1,57 +0,0 @@
-import { Event } from 'event-target-shim'
-
-/** An event fired by a context requester to signal it desires a named context. */
-export class ContextEvent<T = unknown> extends Event<'context-request'> {
- constructor(init: ContextEventInit<T>) {
- super('context-request', { bubbles: true, composed: true })
-
- init = Object(init) as Required<ContextEventInit<T>>
-
- this.context = init.context
- }
-
- context!: Context<T>
- multiple!: boolean
- callback!: ContextCallback<Context<T>>
-}
-
-interface ContextEventInit<T = unknown> {
- context: Context<T>
- multiple?: boolean
- callback: ContextCallback<Context<T>>
-}
-
-/** A Context object defines an optional initial value for a Context, as well as a name identifier for debugging purposes. */
-export type Context<T = unknown> = {
- name: string
- initialValue?: T
-}
-
-/** A helper type which can extract a Context value type from a Context type. */
-export type ContextType<T extends Context> = T extends Context<infer Y>
- ? Y
- : never
-
-/** A function which creates a Context value object */
-export function createContext<T>(
- name: string,
- initialValue?: T
-): Readonly<Context<T>> {
- return {
- name,
- initialValue,
- }
-}
-
-/** A callback which is provided by a context requester and is called with the value satisfying the request. */
-export type ContextCallback<ValueType> = (
- value: ValueType,
- dispose?: () => void
-) => void
-
-declare global {
- interface HTMLElementEventMap {
- /** A 'context-request' event can be emitted by any element which desires a context value to be injected by an external provider. */
- 'context-request': ContextEvent
- }
-}