Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@edge-runtime/primitives

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edge-runtime/primitives - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0-beta.0

809

dist/index.d.ts

@@ -34,422 +34,2 @@ declare class Crypto$1 implements globalThis.Crypto {

/**
* `Event` interface.
* @see https://dom.spec.whatwg.org/#event
*/
interface Event {
/**
* The type of this event.
*/
readonly type: string
/**
* The target of this event.
*/
readonly target: EventTarget<{}, {}, "standard"> | null
/**
* The current target of this event.
*/
readonly currentTarget: EventTarget<{}, {}, "standard"> | null
/**
* The target of this event.
* @deprecated
*/
readonly srcElement: any | null
/**
* The composed path of this event.
*/
composedPath(): EventTarget<{}, {}, "standard">[]
/**
* Constant of NONE.
*/
readonly NONE: number
/**
* Constant of CAPTURING_PHASE.
*/
readonly CAPTURING_PHASE: number
/**
* Constant of BUBBLING_PHASE.
*/
readonly BUBBLING_PHASE: number
/**
* Constant of AT_TARGET.
*/
readonly AT_TARGET: number
/**
* Indicates which phase of the event flow is currently being evaluated.
*/
readonly eventPhase: number
/**
* Stop event bubbling.
*/
stopPropagation(): void
/**
* Stop event bubbling.
*/
stopImmediatePropagation(): void
/**
* Initialize event.
* @deprecated
*/
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void
/**
* The flag indicating bubbling.
*/
readonly bubbles: boolean
/**
* Stop event bubbling.
* @deprecated
*/
cancelBubble: boolean
/**
* Set or get cancellation flag.
* @deprecated
*/
returnValue: boolean
/**
* The flag indicating whether the event can be canceled.
*/
readonly cancelable: boolean
/**
* Cancel this event.
*/
preventDefault(): void
/**
* The flag to indicating whether the event was canceled.
*/
readonly defaultPrevented: boolean
/**
* The flag to indicating if event is composed.
*/
readonly composed: boolean
/**
* Indicates whether the event was dispatched by the user agent.
*/
readonly isTrusted: boolean
/**
* The unix time of this event.
*/
readonly timeStamp: number
}
/**
* The constructor of `EventTarget` interface.
*/
type EventTargetConstructor<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
> = {
prototype: EventTarget<TEvents, TEventAttributes, TMode>
new(): EventTarget<TEvents, TEventAttributes, TMode>
}
/**
* `EventTarget` interface.
* @see https://dom.spec.whatwg.org/#interface-eventtarget
*/
type EventTarget<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
> = EventTarget.EventAttributes<TEventAttributes> & {
/**
* Add a given listener to this event target.
* @param eventName The event name to add.
* @param listener The listener to add.
* @param options The options for this listener.
*/
addEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
type: TEventType,
listener:
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
| null,
options?: boolean | EventTarget.AddOptions
): void
/**
* Remove a given listener from this event target.
* @param eventName The event name to remove.
* @param listener The listener to remove.
* @param options The options for this listener.
*/
removeEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
type: TEventType,
listener:
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
| null,
options?: boolean | EventTarget.RemoveOptions
): void
/**
* Dispatch a given event.
* @param event The event to dispatch.
* @returns `false` if canceled.
*/
dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>(
event: EventTarget.EventData<TEvents, TEventType, TMode>
): boolean
}
declare const EventTarget: EventTargetConstructor & {
/**
* Create an `EventTarget` instance with detailed event definition.
*
* The detailed event definition requires to use `defineEventAttribute()`
* function later.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* const signal = new EventTarget<{ abort: Event }, { onabort: Event }>()
* defineEventAttribute(signal, "abort")
*/
new <
TEvents extends EventTarget.EventDefinition,
TEventAttributes extends EventTarget.EventDefinition,
TMode extends EventTarget.Mode = "loose"
>(): EventTarget<TEvents, TEventAttributes, TMode>
/**
* Define an `EventTarget` constructor with attribute events and detailed event definition.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
* abort(): void {}
* }
*
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
*/
<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
>(events: string[]): EventTargetConstructor<
TEvents,
TEventAttributes,
TMode
>
/**
* Define an `EventTarget` constructor with attribute events and detailed event definition.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
* abort(): void {}
* }
*
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
*/
<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
>(event0: string, ...events: string[]): EventTargetConstructor<
TEvents,
TEventAttributes,
TMode
>
}
declare namespace EventTarget {
/**
* Options of `removeEventListener()` method.
*/
export interface RemoveOptions {
/**
* The flag to indicate that the listener is for the capturing phase.
*/
capture?: boolean
}
/**
* Options of `addEventListener()` method.
*/
export interface AddOptions extends RemoveOptions {
/**
* The flag to indicate that the listener doesn't support
* `event.preventDefault()` operation.
*/
passive?: boolean
/**
* The flag to indicate that the listener will be removed on the first
* event.
*/
once?: boolean
}
/**
* The type of regular listeners.
*/
export interface FunctionListener<TEvent> {
(event: TEvent): void
}
/**
* The type of object listeners.
*/
export interface ObjectListener<TEvent> {
handleEvent(event: TEvent): void
}
/**
* The type of listeners.
*/
export type Listener<TEvent> =
| FunctionListener<TEvent>
| ObjectListener<TEvent>
/**
* Event definition.
*/
export type EventDefinition = {
readonly [key: string]: Event
}
/**
* Mapped type for event attributes.
*/
export type EventAttributes<TEventAttributes extends EventDefinition> = {
[P in keyof TEventAttributes]:
| FunctionListener<TEventAttributes[P]>
| null
}
/**
* The type of event data for `dispatchEvent()` method.
*/
export type EventData<
TEvents extends EventDefinition,
TEventType extends keyof TEvents | string,
TMode extends Mode
> =
TEventType extends keyof TEvents
? (
// Require properties which are not generated automatically.
& Pick<
TEvents[TEventType],
Exclude<keyof TEvents[TEventType], OmittableEventKeys>
>
// Properties which are generated automatically are optional.
& Partial<Pick<Event, OmittableEventKeys>>
)
: (
TMode extends "standard"
? Event
: Event | NonStandardEvent
)
/**
* The string literal types of the properties which are generated
* automatically in `dispatchEvent()` method.
*/
export type OmittableEventKeys = Exclude<keyof Event, "type">
/**
* The type of event data.
*/
export type NonStandardEvent = {
[key: string]: any
type: string
}
/**
* The type of listeners.
*/
export type PickEvent<
TEvents extends EventDefinition,
TEventType extends keyof TEvents | string,
> =
TEventType extends keyof TEvents
? TEvents[TEventType]
: Event
/**
* Event type candidates.
*/
export type EventType<
TEvents extends EventDefinition,
TMode extends Mode
> =
TMode extends "strict"
? keyof TEvents
: keyof TEvents | string
/**
* - `"strict"` ..... Methods don't accept unknown events.
* `dispatchEvent()` accepts partial objects.
* - `"loose"` ...... Methods accept unknown events.
* `dispatchEvent()` accepts partial objects.
* - `"standard"` ... Methods accept unknown events.
* `dispatchEvent()` doesn't accept partial objects.
*/
export type Mode = "strict" | "standard" | "loose"
}
type Events = {
abort: any
}
type EventAttributes = {
onabort: any
}
/**
* The signal class.
* @see https://dom.spec.whatwg.org/#abortsignal
*/
declare class AbortSignal$1 extends EventTarget<Events, EventAttributes> {
/**
* AbortSignal cannot be constructed directly.
*/
constructor()
/**
* Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise.
*/
readonly aborted: boolean
}
/**
* The AbortController.
* @see https://dom.spec.whatwg.org/#abortcontroller
*/
declare class AbortController {
/**
* Initialize this controller.
*/
constructor()
/**
* Returns the `AbortSignal` object associated with this object.
*/
readonly signal: AbortSignal$1
/**
* Abort and signal to any observers that the associated activity is to be aborted.
*/
abort(): void
}
/// <reference lib="es2018.asynciterable" />

@@ -1165,2 +745,383 @@

/**
* `Event` interface.
* @see https://dom.spec.whatwg.org/#event
*/
interface Event {
/**
* The type of this event.
*/
readonly type: string
/**
* The target of this event.
*/
readonly target: EventTarget<{}, {}, "standard"> | null
/**
* The current target of this event.
*/
readonly currentTarget: EventTarget<{}, {}, "standard"> | null
/**
* The target of this event.
* @deprecated
*/
readonly srcElement: any | null
/**
* The composed path of this event.
*/
composedPath(): EventTarget<{}, {}, "standard">[]
/**
* Constant of NONE.
*/
readonly NONE: number
/**
* Constant of CAPTURING_PHASE.
*/
readonly CAPTURING_PHASE: number
/**
* Constant of BUBBLING_PHASE.
*/
readonly BUBBLING_PHASE: number
/**
* Constant of AT_TARGET.
*/
readonly AT_TARGET: number
/**
* Indicates which phase of the event flow is currently being evaluated.
*/
readonly eventPhase: number
/**
* Stop event bubbling.
*/
stopPropagation(): void
/**
* Stop event bubbling.
*/
stopImmediatePropagation(): void
/**
* Initialize event.
* @deprecated
*/
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void
/**
* The flag indicating bubbling.
*/
readonly bubbles: boolean
/**
* Stop event bubbling.
* @deprecated
*/
cancelBubble: boolean
/**
* Set or get cancellation flag.
* @deprecated
*/
returnValue: boolean
/**
* The flag indicating whether the event can be canceled.
*/
readonly cancelable: boolean
/**
* Cancel this event.
*/
preventDefault(): void
/**
* The flag to indicating whether the event was canceled.
*/
readonly defaultPrevented: boolean
/**
* The flag to indicating if event is composed.
*/
readonly composed: boolean
/**
* Indicates whether the event was dispatched by the user agent.
*/
readonly isTrusted: boolean
/**
* The unix time of this event.
*/
readonly timeStamp: number
}
/**
* The constructor of `EventTarget` interface.
*/
type EventTargetConstructor<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
> = {
prototype: EventTarget<TEvents, TEventAttributes, TMode>
new(): EventTarget<TEvents, TEventAttributes, TMode>
}
/**
* `EventTarget` interface.
* @see https://dom.spec.whatwg.org/#interface-eventtarget
*/
type EventTarget<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
> = EventTarget.EventAttributes<TEventAttributes> & {
/**
* Add a given listener to this event target.
* @param eventName The event name to add.
* @param listener The listener to add.
* @param options The options for this listener.
*/
addEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
type: TEventType,
listener:
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
| null,
options?: boolean | EventTarget.AddOptions
): void
/**
* Remove a given listener from this event target.
* @param eventName The event name to remove.
* @param listener The listener to remove.
* @param options The options for this listener.
*/
removeEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
type: TEventType,
listener:
| EventTarget.Listener<EventTarget.PickEvent<TEvents, TEventType>>
| null,
options?: boolean | EventTarget.RemoveOptions
): void
/**
* Dispatch a given event.
* @param event The event to dispatch.
* @returns `false` if canceled.
*/
dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>(
event: EventTarget.EventData<TEvents, TEventType, TMode>
): boolean
}
declare const EventTarget: EventTargetConstructor & {
/**
* Create an `EventTarget` instance with detailed event definition.
*
* The detailed event definition requires to use `defineEventAttribute()`
* function later.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* const signal = new EventTarget<{ abort: Event }, { onabort: Event }>()
* defineEventAttribute(signal, "abort")
*/
new <
TEvents extends EventTarget.EventDefinition,
TEventAttributes extends EventTarget.EventDefinition,
TMode extends EventTarget.Mode = "loose"
>(): EventTarget<TEvents, TEventAttributes, TMode>
/**
* Define an `EventTarget` constructor with attribute events and detailed event definition.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
* abort(): void {}
* }
*
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
*/
<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
>(events: string[]): EventTargetConstructor<
TEvents,
TEventAttributes,
TMode
>
/**
* Define an `EventTarget` constructor with attribute events and detailed event definition.
*
* Unfortunately, the second type parameter `TEventAttributes` was needed
* because we cannot compute string literal types.
*
* @example
* class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
* abort(): void {}
* }
*
* @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
*/
<
TEvents extends EventTarget.EventDefinition = {},
TEventAttributes extends EventTarget.EventDefinition = {},
TMode extends EventTarget.Mode = "loose"
>(event0: string, ...events: string[]): EventTargetConstructor<
TEvents,
TEventAttributes,
TMode
>
}
declare namespace EventTarget {
/**
* Options of `removeEventListener()` method.
*/
export interface RemoveOptions {
/**
* The flag to indicate that the listener is for the capturing phase.
*/
capture?: boolean
}
/**
* Options of `addEventListener()` method.
*/
export interface AddOptions extends RemoveOptions {
/**
* The flag to indicate that the listener doesn't support
* `event.preventDefault()` operation.
*/
passive?: boolean
/**
* The flag to indicate that the listener will be removed on the first
* event.
*/
once?: boolean
}
/**
* The type of regular listeners.
*/
export interface FunctionListener<TEvent> {
(event: TEvent): void
}
/**
* The type of object listeners.
*/
export interface ObjectListener<TEvent> {
handleEvent(event: TEvent): void
}
/**
* The type of listeners.
*/
export type Listener<TEvent> =
| FunctionListener<TEvent>
| ObjectListener<TEvent>
/**
* Event definition.
*/
export type EventDefinition = {
readonly [key: string]: Event
}
/**
* Mapped type for event attributes.
*/
export type EventAttributes<TEventAttributes extends EventDefinition> = {
[P in keyof TEventAttributes]:
| FunctionListener<TEventAttributes[P]>
| null
}
/**
* The type of event data for `dispatchEvent()` method.
*/
export type EventData<
TEvents extends EventDefinition,
TEventType extends keyof TEvents | string,
TMode extends Mode
> =
TEventType extends keyof TEvents
? (
// Require properties which are not generated automatically.
& Pick<
TEvents[TEventType],
Exclude<keyof TEvents[TEventType], OmittableEventKeys>
>
// Properties which are generated automatically are optional.
& Partial<Pick<Event, OmittableEventKeys>>
)
: (
TMode extends "standard"
? Event
: Event | NonStandardEvent
)
/**
* The string literal types of the properties which are generated
* automatically in `dispatchEvent()` method.
*/
export type OmittableEventKeys = Exclude<keyof Event, "type">
/**
* The type of event data.
*/
export type NonStandardEvent = {
[key: string]: any
type: string
}
/**
* The type of listeners.
*/
export type PickEvent<
TEvents extends EventDefinition,
TEventType extends keyof TEvents | string,
> =
TEventType extends keyof TEvents
? TEvents[TEventType]
: Event
/**
* Event type candidates.
*/
export type EventType<
TEvents extends EventDefinition,
TMode extends Mode
> =
TMode extends "strict"
? keyof TEvents
: keyof TEvents | string
/**
* - `"strict"` ..... Methods don't accept unknown events.
* `dispatchEvent()` accepts partial objects.
* - `"loose"` ...... Methods accept unknown events.
* `dispatchEvent()` accepts partial objects.
* - `"standard"` ... Methods accept unknown events.
* `dispatchEvent()` doesn't accept partial objects.
*/
export type Mode = "strict" | "standard" | "loose"
}
type URLPatternInput = URLPatternInit | string

@@ -1222,4 +1183,4 @@

// abort-controller
AbortController: typeof AbortController
AbortSignal: typeof AbortSignal$1
AbortController: typeof undefined
AbortSignal: typeof AbortSignal

@@ -1287,2 +1248,5 @@ // aggregate-error-ponyfill

Error: typeof Error
Event: typeof Event
FetchEvent: typeof EventTarget
EventTarget: typeof EventTarget
EvalError: typeof EvalError

@@ -1307,2 +1271,3 @@ Float32Array: typeof Float32Array

Promise: typeof Promise
PromiseRejectionEvent: typeof EventTarget
Proxy: typeof Proxy

@@ -1309,0 +1274,0 @@ RangeError: typeof RangeError

@@ -5,3 +5,3 @@ {

"homepage": "https://edge-runtime.vercel.app/packages/primitives",
"version": "1.0.1",
"version": "1.1.0-beta.0",
"main": "dist/index.js",

@@ -36,3 +36,3 @@ "repository": {

"tsup": "6.0.1",
"undici": "5.3.0",
"undici": "5.4.0",
"urlpattern-polyfill": "5.0.3",

@@ -65,3 +65,3 @@ "uuid": "8.3.2",

"types": "dist/index.d.ts",
"gitHead": "4d5c7ddd2216facb2c3e5da32f466f56d15d3894"
"gitHead": "78efad9e63dbbe69cef35ed68a45bff22a3f5d7c"
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc