diff --git a/dist/account.d.ts b/dist/account.d.ts new file mode 100644 index 0000000..be072af --- /dev/null +++ b/dist/account.d.ts @@ -0,0 +1,28 @@ +import 'cross-fetch/polyfill'; +import { DAVAccount } from './types/models'; +export declare const serviceDiscovery: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchPrincipalUrl: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchHomeUrl: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const createAccount: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + loadCollections?: boolean; + loadObjects?: boolean; + fetchOptions?: RequestInit; +}) => Promise; diff --git a/dist/addressBook.d.ts b/dist/addressBook.d.ts new file mode 100644 index 0000000..b99fcb1 --- /dev/null +++ b/dist/addressBook.d.ts @@ -0,0 +1,57 @@ +import { ElementCompact } from 'xml-js'; +import { DAVDepth, DAVResponse } from './types/DAVTypes'; +import { DAVAccount, DAVAddressBook, DAVVCard } from './types/models'; +export declare const addressBookQuery: (params: { + url: string; + props: ElementCompact; + filters?: ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const addressBookMultiGet: (params: { + url: string; + props: ElementCompact; + objectUrls: string[]; + depth: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchAddressBooks: (params?: { + account?: DAVAccount; + props?: ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchVCards: (params: { + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const createVCard: (params: { + addressBook: DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const updateVCard: (params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const deleteVCard: (params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; diff --git a/dist/calendar.d.ts b/dist/calendar.d.ts new file mode 100644 index 0000000..0a7986f --- /dev/null +++ b/dist/calendar.d.ts @@ -0,0 +1,97 @@ +import { ElementCompact } from 'xml-js'; +import { DAVDepth, DAVResponse } from './types/DAVTypes'; +import { SyncCalendars } from './types/functionsOverloads'; +import { DAVAccount, DAVCalendar, DAVCalendarObject } from './types/models'; +export declare const fetchCalendarUserAddresses: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const calendarQuery: (params: { + url: string; + props: ElementCompact; + filters?: ElementCompact; + timezone?: string; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const calendarMultiGet: (params: { + url: string; + props: ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: DAVDepth; + filters?: ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const makeCalendar: (params: { + url: string; + props: ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchCalendars: (params?: { + account?: DAVAccount; + props?: ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const fetchCalendarObjects: (params: { + calendar: DAVCalendar; + objectUrls?: string[]; + filters?: ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + fetchOptions?: RequestInit; +}) => Promise; +export declare const createCalendarObject: (params: { + calendar: DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const updateCalendarObject: (params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const deleteCalendarObject: (params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +/** + * Sync remote calendars to local + */ +export declare const syncCalendars: SyncCalendars; +export declare const freeBusyQuery: (params: { + url: string; + timeRange: { + start: string; + end: string; + }; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; diff --git a/dist/client.d.ts b/dist/client.d.ts new file mode 100644 index 0000000..b8a4e3e --- /dev/null +++ b/dist/client.d.ts @@ -0,0 +1,317 @@ +import { addressBookMultiGet as rawAddressBookMultiGet, addressBookQuery as rawAddressBookQuery, createVCard as rawCreateVCard, deleteVCard as rawDeleteVCard, fetchAddressBooks as rawFetchAddressBooks, fetchVCards as rawFetchVCards, updateVCard as rawUpdateVCard } from './addressBook'; +import { calendarMultiGet as rawCalendarMultiGet, calendarQuery as rawCalendarQuery, createCalendarObject as rawCreateCalendarObject, deleteCalendarObject as rawDeleteCalendarObject, fetchCalendarObjects as rawFetchCalendarObjects, fetchCalendars as rawFetchCalendars, makeCalendar as rawMakeCalendar, updateCalendarObject as rawUpdateCalendarObject, fetchCalendarUserAddresses as rawFetchCalendarUserAddresses } from './calendar'; +import { collectionQuery as rawCollectionQuery, isCollectionDirty as rawIsCollectionDirty, makeCollection as rawMakeCollection, supportedReportSet as rawSupportedReportSet, syncCollection as rawSyncCollection } from './collection'; +import { createObject as rawCreateObject, deleteObject as rawDeleteObject, propfind as rawPropfind, updateObject as rawUpdateObject } from './request'; +import { DAVRequest, DAVResponse } from './types/DAVTypes'; +import { SmartCollectionSync, SyncCalendars } from './types/functionsOverloads'; +import { DAVAccount, DAVAddressBook, DAVCalendar, DAVCalendarObject, DAVCollection, DAVCredentials, DAVObject, DAVVCard } from './types/models'; +import { Optional } from './util/typeHelpers'; +export declare const createDAVClient: (params: { + serverUrl: string; + credentials: DAVCredentials; + authMethod?: "Basic" | "Oauth" | "Digest" | "Custom"; + authFunction?: (credentials: DAVCredentials) => Promise>; + defaultAccountType?: DAVAccount["accountType"] | undefined; +}) => Promise<{ + davRequest: (params0: { + url: string; + init: DAVRequest; + convertIncoming?: boolean; + parseOutgoing?: boolean; + }) => Promise; + propfind: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createAccount: (params0: { + account: Optional; + headers?: Record; + loadCollections?: boolean; + loadObjects?: boolean; + }) => Promise; + createObject: (params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateObject: (params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteObject: (params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + timezone?: string; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + addressBookQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + collectionQuery: (params: { + url: string; + body: any; + depth?: import("./types/DAVTypes").DAVDepth; + defaultNamespace?: import("./consts").DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCollection: (params: { + url: string; + props?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: import("./types/DAVTypes").DAVDepth; + filters?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCalendar: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + syncCollection: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + fetchOptions?: RequestInit; + }) => Promise; + supportedReportSet: (params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + isCollectionDirty: (params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise<{ + isDirty: boolean; + newCtag: string; + }>; + smartCollectionSync: SmartCollectionSync; + fetchCalendars: (params?: { + account?: DAVAccount; + props?: import("xml-js/types").ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + } | undefined) => Promise; + fetchCalendarUserAddresses: (params: { + account: DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchCalendarObjects: (params: { + calendar: DAVCalendar; + objectUrls?: string[]; + filters?: import("xml-js/types").ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + fetchOptions?: RequestInit; + }) => Promise; + createCalendarObject: (params: { + calendar: DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateCalendarObject: (params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteCalendarObject: (params: { + calendarObject: DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + syncCalendars: SyncCalendars; + fetchAddressBooks: (params?: { + account?: DAVAccount; + props?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + } | undefined) => Promise; + addressBookMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls: string[]; + depth: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchVCards: (params: { + addressBook: DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createVCard: (params: { + addressBook: DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateVCard: (params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteVCard: (params: { + vCard: DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; +}>; +export declare class DAVClient { + serverUrl: string; + credentials: DAVCredentials; + authMethod: 'Basic' | 'Oauth' | 'Digest' | 'Custom'; + accountType: DAVAccount['accountType']; + authHeaders?: Record; + account?: DAVAccount; + fetchOptions?: RequestInit; + authFunction?: (credentials: DAVCredentials) => Promise>; + constructor(params: { + serverUrl: string; + credentials: DAVCredentials; + authMethod?: 'Basic' | 'Oauth' | 'Digest' | 'Custom'; + authFunction?: (credentials: DAVCredentials) => Promise>; + defaultAccountType?: DAVAccount['accountType'] | undefined; + fetchOptions?: RequestInit; + }); + login(): Promise; + davRequest(params0: { + url: string; + init: DAVRequest; + convertIncoming?: boolean; + parseOutgoing?: boolean; + fetchOptions?: RequestInit; + }): Promise; + createObject(...params: Parameters): Promise; + updateObject(...params: Parameters): Promise; + deleteObject(...params: Parameters): Promise; + propfind(...params: Parameters): Promise; + createAccount(params0: { + account: Optional; + headers?: Record; + loadCollections?: boolean; + loadObjects?: boolean; + fetchOptions?: RequestInit; + }): Promise; + collectionQuery(...params: Parameters): Promise; + makeCollection(...params: Parameters): Promise; + syncCollection(...params: Parameters): Promise; + supportedReportSet(...params: Parameters): Promise; + isCollectionDirty(...params: Parameters): Promise<{ + isDirty: boolean; + newCtag: string; + }>; + smartCollectionSync(param: { + collection: T; + method?: 'basic' | 'webdav'; + headers?: Record; + fetchOptions?: RequestInit; + account?: DAVAccount; + detailedResult?: false; + }): Promise; + smartCollectionSync(param: { + collection: T; + method?: 'basic' | 'webdav'; + headers?: Record; + fetchOptions?: RequestInit; + account?: DAVAccount; + detailedResult: true; + }): Promise & { + objects: { + created: DAVObject[]; + updated: DAVObject[]; + deleted: DAVObject[]; + }; + }>; + calendarQuery(...params: Parameters): Promise; + makeCalendar(...params: Parameters): Promise; + calendarMultiGet(...params: Parameters): Promise; + fetchCalendars(...params: Parameters): Promise; + fetchCalendarUserAddresses(...params: Parameters): Promise; + fetchCalendarObjects(...params: Parameters): Promise; + createCalendarObject(...params: Parameters): Promise; + updateCalendarObject(...params: Parameters): Promise; + deleteCalendarObject(...params: Parameters): Promise; + syncCalendars(...params: Parameters): Promise>; + addressBookQuery(...params: Parameters): Promise; + addressBookMultiGet(...params: Parameters): Promise; + fetchAddressBooks(...params: Parameters): Promise; + fetchVCards(...params: Parameters): Promise; + createVCard(...params: Parameters): Promise; + updateVCard(...params: Parameters): Promise; + deleteVCard(...params: Parameters): Promise; +} diff --git a/dist/collection.d.ts b/dist/collection.d.ts new file mode 100644 index 0000000..5a126b2 --- /dev/null +++ b/dist/collection.d.ts @@ -0,0 +1,51 @@ +import { ElementCompact } from 'xml-js'; +import { DAVNamespaceShort } from './consts'; +import { DAVDepth, DAVResponse } from './types/DAVTypes'; +import { SmartCollectionSync } from './types/functionsOverloads'; +import { DAVCollection } from './types/models'; +export declare const collectionQuery: (params: { + url: string; + body: any; + depth?: DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const makeCollection: (params: { + url: string; + props?: ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const supportedReportSet: (params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const isCollectionDirty: (params: { + collection: DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise<{ + isDirty: boolean; + newCtag: string; +}>; +/** + * This is for webdav sync-collection only + */ +export declare const syncCollection: (params: { + url: string; + props: ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + fetchOptions?: RequestInit; +}) => Promise; +/** remote collection to local */ +export declare const smartCollectionSync: SmartCollectionSync; diff --git a/dist/consts.d.ts b/dist/consts.d.ts new file mode 100644 index 0000000..0205b03 --- /dev/null +++ b/dist/consts.d.ts @@ -0,0 +1,29 @@ +export declare enum DAVNamespace { + CALENDAR_SERVER = "http://calendarserver.org/ns/", + CALDAV_APPLE = "http://apple.com/ns/ical/", + CALDAV = "urn:ietf:params:xml:ns:caldav", + CARDDAV = "urn:ietf:params:xml:ns:carddav", + DAV = "DAV:" +} +export declare const DAVAttributeMap: { + "urn:ietf:params:xml:ns:caldav": string; + "urn:ietf:params:xml:ns:carddav": string; + "http://calendarserver.org/ns/": string; + "http://apple.com/ns/ical/": string; + "DAV:": string; +}; +export declare enum DAVNamespaceShort { + CALDAV = "c", + CARDDAV = "card", + CALENDAR_SERVER = "cs", + CALDAV_APPLE = "ca", + DAV = "d" +} +export declare enum ICALObjects { + VEVENT = "VEVENT", + VTODO = "VTODO", + VJOURNAL = "VJOURNAL", + VFREEBUSY = "VFREEBUSY", + VTIMEZONE = "VTIMEZONE", + VALARM = "VALARM" +} diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..8f7b0aa --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,526 @@ +import * as client from './client'; +import { DAVNamespace, DAVNamespaceShort } from './consts'; +export type { DAVDepth, DAVMethods, DAVRequest, DAVResponse, DAVTokens } from './types/DAVTypes'; +export type { DAVAccount, DAVAddressBook, DAVCalendar, DAVCalendarObject, DAVCollection, DAVCredentials, DAVObject, DAVVCard, } from './types/models'; +export { DAVClient } from './client'; +export { createDAVClient } from './client'; +export { createAccount } from './account'; +export { davRequest, propfind, createObject, updateObject, deleteObject } from './request'; +export { collectionQuery, supportedReportSet, isCollectionDirty, syncCollection, smartCollectionSync, } from './collection'; +export { calendarQuery, calendarMultiGet, makeCalendar, fetchCalendars, fetchCalendarUserAddresses, fetchCalendarObjects, createCalendarObject, updateCalendarObject, deleteCalendarObject, syncCalendars, freeBusyQuery, } from './calendar'; +export { addressBookQuery, fetchAddressBooks, fetchVCards, createVCard, updateVCard, deleteVCard, } from './addressBook'; +export { getBasicAuthHeaders, getOauthHeaders, fetchOauthTokens, refreshAccessToken, } from './util/authHelpers'; +export { urlContains, urlEquals, getDAVAttribute, cleanupFalsy } from './util/requestHelpers'; +export { DAVNamespace, DAVAttributeMap, DAVNamespaceShort } from './consts'; +declare const _default: { + urlEquals: (urlA?: string, urlB?: string) => boolean; + urlContains: (urlA?: string, urlB?: string) => boolean; + getDAVAttribute: (nsArr: DAVNamespace[]) => { + [key: string]: DAVNamespace; + }; + cleanupFalsy: (obj: T) => import("./util/typeHelpers").NoUndefinedField; + conditionalParam: (key: string, param: T) => { + [key: string]: T; + }; + excludeHeaders: (headers: Record | undefined, headersToExclude: string[] | undefined) => Record; + defaultParam: any>(fn: F, params: Partial[0]>) => (...args: Parameters) => ReturnType; + getBasicAuthHeaders: (credentials: import("./types/models").DAVCredentials) => { + authorization?: string; + }; + fetchOauthTokens: (credentials: import("./types/models").DAVCredentials, fetchOptions?: RequestInit) => Promise; + refreshAccessToken: (credentials: import("./types/models").DAVCredentials, fetchOptions?: RequestInit) => Promise<{ + access_token?: string; + expires_in?: number; + }>; + getOauthHeaders: (credentials: import("./types/models").DAVCredentials, fetchOptions?: RequestInit) => Promise<{ + tokens: import("./types/DAVTypes").DAVTokens; + headers: { + authorization?: string; + }; + }>; + fetchCalendarUserAddresses: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + timezone?: string; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: import("./types/DAVTypes").DAVDepth; + filters?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCalendar: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchCalendars: (params?: { + account?: import("./types/models").DAVAccount; + props?: import("xml-js/types").ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchCalendarObjects: (params: { + calendar: import("./types/models").DAVCalendar; + objectUrls?: string[]; + filters?: import("xml-js/types").ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + fetchOptions?: RequestInit; + }) => Promise; + createCalendarObject: (params: { + calendar: import("./types/models").DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateCalendarObject: (params: { + calendarObject: import("./types/models").DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteCalendarObject: (params: { + calendarObject: import("./types/models").DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + syncCalendars: import("./types/functionsOverloads").SyncCalendars; + freeBusyQuery: (params: { + url: string; + timeRange: { + start: string; + end: string; + }; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + addressBookQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + addressBookMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls: string[]; + depth: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchAddressBooks: (params?: { + account?: import("./types/models").DAVAccount; + props?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchVCards: (params: { + addressBook: import("./types/models").DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createVCard: (params: { + addressBook: import("./types/models").DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateVCard: (params: { + vCard: import("./types/models").DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteVCard: (params: { + vCard: import("./types/models").DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + serviceDiscovery: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchPrincipalUrl: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchHomeUrl: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createAccount: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + loadCollections?: boolean; + loadObjects?: boolean; + fetchOptions?: RequestInit; + }) => Promise; + collectionQuery: (params: { + url: string; + body: any; + depth?: import("./types/DAVTypes").DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCollection: (params: { + url: string; + props?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + supportedReportSet: (params: { + collection: import("./types/models").DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + isCollectionDirty: (params: { + collection: import("./types/models").DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise<{ + isDirty: boolean; + newCtag: string; + }>; + syncCollection: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + fetchOptions?: RequestInit; + }) => Promise; + smartCollectionSync: import("./types/functionsOverloads").SmartCollectionSync; + davRequest: (params: { + url: string; + init: import("./types/DAVTypes").DAVRequest; + convertIncoming?: boolean; + parseOutgoing?: boolean; + fetchOptions?: RequestInit; + }) => Promise; + propfind: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createObject: (params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateObject: (params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteObject: (params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createDAVClient: (params: { + serverUrl: string; + credentials: import("./types/models").DAVCredentials; + authMethod?: "Basic" | "Oauth" | "Digest" | "Custom"; + authFunction?: (credentials: import("./types/models").DAVCredentials) => Promise>; + defaultAccountType?: import("./types/models").DAVAccount["accountType"] | undefined; + }) => Promise<{ + davRequest: (params0: { + url: string; + init: import("./types/DAVTypes").DAVRequest; + convertIncoming?: boolean; + parseOutgoing?: boolean; + }) => Promise; + propfind: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createAccount: (params0: { + account: import("./util/typeHelpers").Optional; + headers?: Record; + loadCollections?: boolean; + loadObjects?: boolean; + }) => Promise; + createObject: (params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateObject: (params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteObject: (params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + timezone?: string; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + addressBookQuery: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + filters?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + collectionQuery: (params: { + url: string; + body: any; + depth?: import("./types/DAVTypes").DAVDepth; + defaultNamespace?: DAVNamespaceShort; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCollection: (params: { + url: string; + props?: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + calendarMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls?: string[]; + timezone?: string; + depth: import("./types/DAVTypes").DAVDepth; + filters?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + makeCalendar: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + depth?: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + syncCollection: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + syncLevel?: number; + syncToken?: string; + fetchOptions?: RequestInit; + }) => Promise; + supportedReportSet: (params: { + collection: import("./types/models").DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + isCollectionDirty: (params: { + collection: import("./types/models").DAVCollection; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise<{ + isDirty: boolean; + newCtag: string; + }>; + smartCollectionSync: import("./types/functionsOverloads").SmartCollectionSync; + fetchCalendars: (params?: { + account?: import("./types/models").DAVAccount; + props?: import("xml-js/types").ElementCompact; + projectedProps?: Record; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + } | undefined) => Promise; + fetchCalendarUserAddresses: (params: { + account: import("./types/models").DAVAccount; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchCalendarObjects: (params: { + calendar: import("./types/models").DAVCalendar; + objectUrls?: string[]; + filters?: import("xml-js/types").ElementCompact; + timeRange?: { + start: string; + end: string; + }; + expand?: boolean; + urlFilter?: (url: string) => boolean; + headers?: Record; + headersToExclude?: string[]; + useMultiGet?: boolean; + fetchOptions?: RequestInit; + }) => Promise; + createCalendarObject: (params: { + calendar: import("./types/models").DAVCalendar; + iCalString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateCalendarObject: (params: { + calendarObject: import("./types/models").DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteCalendarObject: (params: { + calendarObject: import("./types/models").DAVCalendarObject; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + syncCalendars: import("./types/functionsOverloads").SyncCalendars; + fetchAddressBooks: (params?: { + account?: import("./types/models").DAVAccount; + props?: import("xml-js/types").ElementCompact; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + } | undefined) => Promise; + addressBookMultiGet: (params: { + url: string; + props: import("xml-js/types").ElementCompact; + objectUrls: string[]; + depth: import("./types/DAVTypes").DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + fetchVCards: (params: { + addressBook: import("./types/models").DAVAddressBook; + headers?: Record; + objectUrls?: string[]; + urlFilter?: (url: string) => boolean; + useMultiGet?: boolean; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + createVCard: (params: { + addressBook: import("./types/models").DAVAddressBook; + vCardString: string; + filename: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + updateVCard: (params: { + vCard: import("./types/models").DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + deleteVCard: (params: { + vCard: import("./types/models").DAVVCard; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; + }) => Promise; + }>; + DAVClient: typeof client.DAVClient; + DAVNamespace: typeof DAVNamespace; + DAVNamespaceShort: typeof DAVNamespaceShort; + DAVAttributeMap: { + "urn:ietf:params:xml:ns:caldav": string; + "urn:ietf:params:xml:ns:carddav": string; + "http://calendarserver.org/ns/": string; + "http://apple.com/ns/ical/": string; + "DAV:": string; + }; +}; +export default _default; diff --git a/dist/package.json b/dist/package.json index 9699324..37adbc0 100644 --- a/dist/package.json +++ b/dist/package.json @@ -48,14 +48,14 @@ "dependencies": { "base-64": "1.0.0", "cross-fetch": "4.0.0", - "debug": "4.3.7", + "debug": "4.4.0", "xml-js": "1.6.11" }, "devDependencies": { - "@rollup/plugin-commonjs": "26.0.1", - "@rollup/plugin-node-resolve": "15.2.3", + "@rollup/plugin-commonjs": "28.0.1", + "@rollup/plugin-node-resolve": "15.3.0", "@rollup/plugin-terser": "0.4.4", - "@rollup/plugin-typescript": "11.1.6", + "@rollup/plugin-typescript": "12.1.1", "@types/base-64": "1.0.2", "@types/debug": "4.1.12", "@types/jest": "29.5.12", @@ -64,25 +64,25 @@ "@typescript-eslint/parser": "8.5.0", "copyfiles": "2.4.1", "cross-env": "7.0.3", - "dotenv": "16.4.5", - "eslint": "9.10.0", + "dotenv": "16.4.7", + "eslint": "9.16.0", "eslint-config-airbnb": "19.0.4", "eslint-config-airbnb-typescript": "18.0.0", "eslint-config-prettier": "9.1.0", - "eslint-module-utils": "2.11.0", - "eslint-plugin-import": "2.30.0", - "eslint-plugin-prettier": "5.1.3", + "eslint-module-utils": "2.12.0", + "eslint-plugin-import": "2.31.0", + "eslint-plugin-prettier": "5.2.1", "jest": "29.7.0", - "prettier": "3.3.3", + "prettier": "3.4.2", "rimraf": "6.0.1", "rollup": "4.21.2", "rollup-plugin-dts": "6.1.1", "rollup-plugin-node-builtins": "2.1.2", "rollup-plugin-polyfill-node": "0.13.0", - "sort-package-json": "2.10.1", + "sort-package-json": "2.12.0", "ts-jest": "29.2.5", - "tslib": "2.7.0", - "typescript": "5.6.2" + "tslib": "2.8.1", + "typescript": "5.7.2" }, "engines": { "node": ">=10" diff --git a/dist/request.d.ts b/dist/request.d.ts new file mode 100644 index 0000000..fae7f8c --- /dev/null +++ b/dist/request.d.ts @@ -0,0 +1,40 @@ +import 'cross-fetch/polyfill'; +import { ElementCompact } from 'xml-js'; +import { DAVDepth, DAVRequest, DAVResponse } from './types/DAVTypes'; +export declare const davRequest: (params: { + url: string; + init: DAVRequest; + convertIncoming?: boolean; + parseOutgoing?: boolean; + fetchOptions?: RequestInit; +}) => Promise; +export declare const propfind: (params: { + url: string; + props: ElementCompact; + depth?: DAVDepth; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const createObject: (params: { + url: string; + data: BodyInit; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const updateObject: (params: { + url: string; + data: BodyInit; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; +export declare const deleteObject: (params: { + url: string; + etag?: string; + headers?: Record; + headersToExclude?: string[]; + fetchOptions?: RequestInit; +}) => Promise; diff --git a/dist/tsdav.d.ts b/dist/tsdav.d.ts index 8ce428a..3dd5753 100644 --- a/dist/tsdav.d.ts +++ b/dist/tsdav.d.ts @@ -1,5 +1,5 @@ -import * as xml_js from 'xml-js'; import { ElementCompact } from 'xml-js'; +import * as xml_js_types from 'xml-js/types'; type DAVDepth = '0' | '1' | 'infinity'; type DAVMethods = 'COPY' | 'LOCK' | 'MKCOL' | 'MOVE' | 'PROPFIND' | 'PROPPATCH' | 'UNLOCK' | 'REPORT' | 'SEARCH' | 'MKCALENDAR'; @@ -429,7 +429,7 @@ declare const createDAVClient: (params: { }) => Promise; propfind: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -465,8 +465,8 @@ declare const createDAVClient: (params: { }) => Promise; calendarQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; timezone?: string; depth?: DAVDepth; headers?: Record; @@ -475,8 +475,8 @@ declare const createDAVClient: (params: { }) => Promise; addressBookQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -493,7 +493,7 @@ declare const createDAVClient: (params: { }) => Promise; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -501,18 +501,18 @@ declare const createDAVClient: (params: { }) => Promise; calendarMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls?: string[]; timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; }) => Promise; makeCalendar: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -520,7 +520,7 @@ declare const createDAVClient: (params: { }) => Promise; syncCollection: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; syncLevel?: number; @@ -545,7 +545,7 @@ declare const createDAVClient: (params: { smartCollectionSync: SmartCollectionSync; fetchCalendars: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; projectedProps?: Record; headers?: Record; headersToExclude?: string[]; @@ -560,7 +560,7 @@ declare const createDAVClient: (params: { fetchCalendarObjects: (params: { calendar: DAVCalendar; objectUrls?: string[]; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; timeRange?: { start: string; end: string; @@ -595,14 +595,14 @@ declare const createDAVClient: (params: { syncCalendars: SyncCalendars; fetchAddressBooks: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; } | undefined) => Promise; addressBookMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls: string[]; depth: DAVDepth; headers?: Record; @@ -789,8 +789,8 @@ declare const _default: { }) => Promise; calendarQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; timezone?: string; depth?: DAVDepth; headers?: Record; @@ -799,18 +799,18 @@ declare const _default: { }) => Promise; calendarMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls?: string[]; timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; }) => Promise; makeCalendar: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -818,7 +818,7 @@ declare const _default: { }) => Promise; fetchCalendars: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; projectedProps?: Record; headers?: Record; headersToExclude?: string[]; @@ -827,7 +827,7 @@ declare const _default: { fetchCalendarObjects: (params: { calendar: DAVCalendar; objectUrls?: string[]; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; timeRange?: { start: string; end: string; @@ -873,8 +873,8 @@ declare const _default: { }) => Promise; addressBookQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -882,7 +882,7 @@ declare const _default: { }) => Promise; addressBookMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls: string[]; depth: DAVDepth; headers?: Record; @@ -891,7 +891,7 @@ declare const _default: { }) => Promise; fetchAddressBooks: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; @@ -962,7 +962,7 @@ declare const _default: { }) => Promise; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -985,7 +985,7 @@ declare const _default: { }>; syncCollection: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; syncLevel?: number; @@ -1002,7 +1002,7 @@ declare const _default: { }) => Promise; propfind: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -1045,7 +1045,7 @@ declare const _default: { }) => Promise; propfind: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -1081,8 +1081,8 @@ declare const _default: { }) => Promise; calendarQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; timezone?: string; depth?: DAVDepth; headers?: Record; @@ -1091,8 +1091,8 @@ declare const _default: { }) => Promise; addressBookQuery: (params: { url: string; - props: xml_js.ElementCompact; - filters?: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; + filters?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -1109,7 +1109,7 @@ declare const _default: { }) => Promise; makeCollection: (params: { url: string; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -1117,18 +1117,18 @@ declare const _default: { }) => Promise; calendarMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls?: string[]; timezone?: string; depth: DAVDepth; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; }) => Promise; makeCalendar: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; depth?: DAVDepth; headers?: Record; headersToExclude?: string[]; @@ -1136,7 +1136,7 @@ declare const _default: { }) => Promise; syncCollection: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; syncLevel?: number; @@ -1161,7 +1161,7 @@ declare const _default: { smartCollectionSync: SmartCollectionSync; fetchCalendars: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; projectedProps?: Record; headers?: Record; headersToExclude?: string[]; @@ -1176,7 +1176,7 @@ declare const _default: { fetchCalendarObjects: (params: { calendar: DAVCalendar; objectUrls?: string[]; - filters?: xml_js.ElementCompact; + filters?: xml_js_types.ElementCompact; timeRange?: { start: string; end: string; @@ -1211,14 +1211,14 @@ declare const _default: { syncCalendars: SyncCalendars; fetchAddressBooks: (params?: { account?: DAVAccount; - props?: xml_js.ElementCompact; + props?: xml_js_types.ElementCompact; headers?: Record; headersToExclude?: string[]; fetchOptions?: RequestInit; } | undefined) => Promise; addressBookMultiGet: (params: { url: string; - props: xml_js.ElementCompact; + props: xml_js_types.ElementCompact; objectUrls: string[]; depth: DAVDepth; headers?: Record; diff --git a/dist/tsdav.js b/dist/tsdav.js index 5baca37..b811e10 100644 --- a/dist/tsdav.js +++ b/dist/tsdav.js @@ -29,625 +29,636 @@ function getAugmentedNamespace(n) { return a; } -(function(self) { - -((function (exports) { - - var global = - (typeof globalThis !== 'undefined' && globalThis) || - (typeof self !== 'undefined' && self) || - (typeof global !== 'undefined' && global); - - var support = { - searchParams: 'URLSearchParams' in global, - iterable: 'Symbol' in global && 'iterator' in Symbol, - blob: - 'FileReader' in global && - 'Blob' in global && - (function() { - try { - new Blob(); - return true - } catch (e) { - return false - } - })(), - formData: 'FormData' in global, - arrayBuffer: 'ArrayBuffer' in global - }; +var browserPolyfill = {}; + +var hasRequiredBrowserPolyfill; + +function requireBrowserPolyfill () { + if (hasRequiredBrowserPolyfill) return browserPolyfill; + hasRequiredBrowserPolyfill = 1; + (function(self) { + + ((function (exports) { + + var global = + (typeof globalThis !== 'undefined' && globalThis) || + (typeof self !== 'undefined' && self) || + (typeof global !== 'undefined' && global); + + var support = { + searchParams: 'URLSearchParams' in global, + iterable: 'Symbol' in global && 'iterator' in Symbol, + blob: + 'FileReader' in global && + 'Blob' in global && + (function() { + try { + new Blob(); + return true + } catch (e) { + return false + } + })(), + formData: 'FormData' in global, + arrayBuffer: 'ArrayBuffer' in global + }; - function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj) - } - - if (support.arrayBuffer) { - var viewClasses = [ - '[object Int8Array]', - '[object Uint8Array]', - '[object Uint8ClampedArray]', - '[object Int16Array]', - '[object Uint16Array]', - '[object Int32Array]', - '[object Uint32Array]', - '[object Float32Array]', - '[object Float64Array]' - ]; + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj) + } - var isArrayBufferView = - ArrayBuffer.isView || - function(obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 - }; - } + if (support.arrayBuffer) { + var viewClasses = [ + '[object Int8Array]', + '[object Uint8Array]', + '[object Uint8ClampedArray]', + '[object Int16Array]', + '[object Uint16Array]', + '[object Int32Array]', + '[object Uint32Array]', + '[object Float32Array]', + '[object Float64Array]' + ]; + + var isArrayBufferView = + ArrayBuffer.isView || + function(obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + }; + } - function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name); - } - if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { - throw new TypeError('Invalid character in header field name: "' + name + '"') - } - return name.toLowerCase() - } + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') { + throw new TypeError('Invalid character in header field name: "' + name + '"') + } + return name.toLowerCase() + } - function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value); - } - return value - } + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value); + } + return value + } - // Build a destructive iterator for the value list - function iteratorFor(items) { - var iterator = { - next: function() { - var value = items.shift(); - return {done: value === undefined, value: value} - } - }; + // Build a destructive iterator for the value list + function iteratorFor(items) { + var iterator = { + next: function() { + var value = items.shift(); + return {done: value === undefined, value: value} + } + }; - if (support.iterable) { - iterator[Symbol.iterator] = function() { - return iterator - }; - } + if (support.iterable) { + iterator[Symbol.iterator] = function() { + return iterator + }; + } - return iterator - } + return iterator + } - function Headers(headers) { - this.map = {}; + function Headers(headers) { + this.map = {}; + + if (headers instanceof Headers) { + headers.forEach(function(value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function(header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name) { + this.append(name, headers[name]); + }, this); + } + } - if (headers instanceof Headers) { - headers.forEach(function(value, name) { - this.append(name, value); - }, this); - } else if (Array.isArray(headers)) { - headers.forEach(function(header) { - this.append(header[0], header[1]); - }, this); - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]); - }, this); - } - } + Headers.prototype.append = function(name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ', ' + value : value; + }; - Headers.prototype.append = function(name, value) { - name = normalizeName(name); - value = normalizeValue(value); - var oldValue = this.map[name]; - this.map[name] = oldValue ? oldValue + ', ' + value : value; - }; + Headers.prototype['delete'] = function(name) { + delete this.map[normalizeName(name)]; + }; - Headers.prototype['delete'] = function(name) { - delete this.map[normalizeName(name)]; - }; + Headers.prototype.get = function(name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null + }; - Headers.prototype.get = function(name) { - name = normalizeName(name); - return this.has(name) ? this.map[name] : null - }; + Headers.prototype.has = function(name) { + return this.map.hasOwnProperty(normalizeName(name)) + }; - Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - }; + Headers.prototype.set = function(name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; - Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = normalizeValue(value); - }; + Headers.prototype.forEach = function(callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; - Headers.prototype.forEach = function(callback, thisArg) { - for (var name in this.map) { - if (this.map.hasOwnProperty(name)) { - callback.call(thisArg, this.map[name], name, this); - } - } - }; + Headers.prototype.keys = function() { + var items = []; + this.forEach(function(value, name) { + items.push(name); + }); + return iteratorFor(items) + }; - Headers.prototype.keys = function() { - var items = []; - this.forEach(function(value, name) { - items.push(name); - }); - return iteratorFor(items) - }; + Headers.prototype.values = function() { + var items = []; + this.forEach(function(value) { + items.push(value); + }); + return iteratorFor(items) + }; - Headers.prototype.values = function() { - var items = []; - this.forEach(function(value) { - items.push(value); - }); - return iteratorFor(items) - }; + Headers.prototype.entries = function() { + var items = []; + this.forEach(function(value, name) { + items.push([name, value]); + }); + return iteratorFor(items) + }; - Headers.prototype.entries = function() { - var items = []; - this.forEach(function(value, name) { - items.push([name, value]); - }); - return iteratorFor(items) - }; + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } - if (support.iterable) { - Headers.prototype[Symbol.iterator] = Headers.prototype.entries; - } + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')) + } + body.bodyUsed = true; + } - function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')) - } - body.bodyUsed = true; - } + function fileReaderReady(reader) { + return new Promise(function(resolve, reject) { + reader.onload = function() { + resolve(reader.result); + }; + reader.onerror = function() { + reject(reader.error); + }; + }) + } - function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result); - }; - reader.onerror = function() { - reject(reader.error); - }; - }) - } + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise + } - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsArrayBuffer(blob); - return promise - } + function readBlobAsText(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise + } - function readBlobAsText(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsText(blob); - return promise - } + function readArrayBufferAsText(buf) { + var view = new Uint8Array(buf); + var chars = new Array(view.length); - function readArrayBufferAsText(buf) { - var view = new Uint8Array(buf); - var chars = new Array(view.length); + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } + return chars.join('') + } - for (var i = 0; i < view.length; i++) { - chars[i] = String.fromCharCode(view[i]); - } - return chars.join('') - } + function bufferClone(buf) { + if (buf.slice) { + return buf.slice(0) + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer + } + } - function bufferClone(buf) { - if (buf.slice) { - return buf.slice(0) - } else { - var view = new Uint8Array(buf.byteLength); - view.set(new Uint8Array(buf)); - return view.buffer - } - } - - function Body() { - this.bodyUsed = false; - - this._initBody = function(body) { - /* - fetch-mock wraps the Response object in an ES6 Proxy to - provide useful test harness features such as flush. However, on - ES5 browsers without fetch or Proxy support pollyfills must be used; - the proxy-pollyfill is unable to proxy an attribute unless it exists - on the object before the Proxy is created. This change ensures - Response.bodyUsed exists on the instance, while maintaining the - semantic of setting Request.bodyUsed in the constructor before - _initBody is called. - */ - this.bodyUsed = this.bodyUsed; - this._bodyInit = body; - if (!body) { - this._bodyText = ''; - } else if (typeof body === 'string') { - this._bodyText = body; - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body; - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body; - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this._bodyText = body.toString(); - } else if (support.arrayBuffer && support.blob && isDataView(body)) { - this._bodyArrayBuffer = bufferClone(body.buffer); - // IE 10-11 can't handle a DataView body. - this._bodyInit = new Blob([this._bodyArrayBuffer]); - } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { - this._bodyArrayBuffer = bufferClone(body); - } else { - this._bodyText = body = Object.prototype.toString.call(body); - } + function Body() { + this.bodyUsed = false; + + this._initBody = function(body) { + /* + fetch-mock wraps the Response object in an ES6 Proxy to + provide useful test harness features such as flush. However, on + ES5 browsers without fetch or Proxy support pollyfills must be used; + the proxy-pollyfill is unable to proxy an attribute unless it exists + on the object before the Proxy is created. This change ensures + Response.bodyUsed exists on the instance, while maintaining the + semantic of setting Request.bodyUsed in the constructor before + _initBody is called. + */ + this.bodyUsed = this.bodyUsed; + this._bodyInit = body; + if (!body) { + this._bodyText = ''; + } else if (typeof body === 'string') { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + // IE 10-11 can't handle a DataView body. + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } - if (!this.headers.get('content-type')) { - if (typeof body === 'string') { - this.headers.set('content-type', 'text/plain;charset=UTF-8'); - } else if (this._bodyBlob && this._bodyBlob.type) { - this.headers.set('content-type', this._bodyBlob.type); - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); - } - } - }; + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8'); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + } + }; - if (support.blob) { - this.blob = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } + if (support.blob) { + this.blob = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(new Blob([this._bodyArrayBuffer])) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob') - } else { - return Promise.resolve(new Blob([this._bodyText])) - } - }; + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob') + } else { + return Promise.resolve(new Blob([this._bodyText])) + } + }; - this.arrayBuffer = function() { - if (this._bodyArrayBuffer) { - var isConsumed = consumed(this); - if (isConsumed) { - return isConsumed - } - if (ArrayBuffer.isView(this._bodyArrayBuffer)) { - return Promise.resolve( - this._bodyArrayBuffer.buffer.slice( - this._bodyArrayBuffer.byteOffset, - this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength - ) - ) - } else { - return Promise.resolve(this._bodyArrayBuffer) - } - } else { - return this.blob().then(readBlobAsArrayBuffer) - } - }; - } + this.arrayBuffer = function() { + if (this._bodyArrayBuffer) { + var isConsumed = consumed(this); + if (isConsumed) { + return isConsumed + } + if (ArrayBuffer.isView(this._bodyArrayBuffer)) { + return Promise.resolve( + this._bodyArrayBuffer.buffer.slice( + this._bodyArrayBuffer.byteOffset, + this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength + ) + ) + } else { + return Promise.resolve(this._bodyArrayBuffer) + } + } else { + return this.blob().then(readBlobAsArrayBuffer) + } + }; + } - this.text = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } + this.text = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text') - } else { - return Promise.resolve(this._bodyText) - } - }; + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text') + } else { + return Promise.resolve(this._bodyText) + } + }; - if (support.formData) { - this.formData = function() { - return this.text().then(decode) - }; - } + if (support.formData) { + this.formData = function() { + return this.text().then(decode) + }; + } - this.json = function() { - return this.text().then(JSON.parse) - }; + this.json = function() { + return this.text().then(JSON.parse) + }; - return this - } + return this + } - // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; + // HTTP methods whose capitalization should be normalized + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - function normalizeMethod(method) { - var upcased = method.toUpperCase(); - return methods.indexOf(upcased) > -1 ? upcased : method - } + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method + } - function Request(input, options) { - if (!(this instanceof Request)) { - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') - } + function Request(input, options) { + if (!(this instanceof Request)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') + } - options = options || {}; - var body = options.body; + options = options || {}; + var body = options.body; - if (input instanceof Request) { - if (input.bodyUsed) { - throw new TypeError('Already read') - } - this.url = input.url; - this.credentials = input.credentials; - if (!options.headers) { - this.headers = new Headers(input.headers); - } - this.method = input.method; - this.mode = input.mode; - this.signal = input.signal; - if (!body && input._bodyInit != null) { - body = input._bodyInit; - input.bodyUsed = true; - } - } else { - this.url = String(input); - } + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } - this.credentials = options.credentials || this.credentials || 'same-origin'; - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers); - } - this.method = normalizeMethod(options.method || this.method || 'GET'); - this.mode = options.mode || this.mode || null; - this.signal = options.signal || this.signal; - this.referrer = null; + this.credentials = options.credentials || this.credentials || 'same-origin'; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || 'GET'); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests') - } - this._initBody(body); + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests') + } + this._initBody(body); + + if (this.method === 'GET' || this.method === 'HEAD') { + if (options.cache === 'no-store' || options.cache === 'no-cache') { + // Search for a '_' parameter in the query string + var reParamSearch = /([?&])_=[^&]*/; + if (reParamSearch.test(this.url)) { + // If it already exists then set the value with the current time + this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); + } else { + // Otherwise add a new '_' parameter to the end with the current time + var reQueryString = /\?/; + this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); + } + } + } + } - if (this.method === 'GET' || this.method === 'HEAD') { - if (options.cache === 'no-store' || options.cache === 'no-cache') { - // Search for a '_' parameter in the query string - var reParamSearch = /([?&])_=[^&]*/; - if (reParamSearch.test(this.url)) { - // If it already exists then set the value with the current time - this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime()); - } else { - // Otherwise add a new '_' parameter to the end with the current time - var reQueryString = /\?/; - this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime(); - } - } - } - } + Request.prototype.clone = function() { + return new Request(this, {body: this._bodyInit}) + }; - Request.prototype.clone = function() { - return new Request(this, {body: this._bodyInit}) - }; + function decode(body) { + var form = new FormData(); + body + .trim() + .split('&') + .forEach(function(bytes) { + if (bytes) { + var split = bytes.split('='); + var name = split.shift().replace(/\+/g, ' '); + var value = split.join('=').replace(/\+/g, ' '); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form + } - function decode(body) { - var form = new FormData(); - body - .trim() - .split('&') - .forEach(function(bytes) { - if (bytes) { - var split = bytes.split('='); - var name = split.shift().replace(/\+/g, ' '); - var value = split.join('=').replace(/\+/g, ' '); - form.append(decodeURIComponent(name), decodeURIComponent(value)); - } - }); - return form - } - - function parseHeaders(rawHeaders) { - var headers = new Headers(); - // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space - // https://tools.ietf.org/html/rfc7230#section-3.2 - var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); - // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill - // https://github.com/github/fetch/issues/748 - // https://github.com/zloirock/core-js/issues/751 - preProcessedHeaders - .split('\r') - .map(function(header) { - return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header - }) - .forEach(function(line) { - var parts = line.split(':'); - var key = parts.shift().trim(); - if (key) { - var value = parts.join(':').trim(); - headers.append(key, value); - } - }); - return headers - } + function parseHeaders(rawHeaders) { + var headers = new Headers(); + // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); + // Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill + // https://github.com/github/fetch/issues/748 + // https://github.com/zloirock/core-js/issues/751 + preProcessedHeaders + .split('\r') + .map(function(header) { + return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header + }) + .forEach(function(line) { + var parts = line.split(':'); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(':').trim(); + headers.append(key, value); + } + }); + return headers + } - Body.call(Request.prototype); + Body.call(Request.prototype); - function Response(bodyInit, options) { - if (!(this instanceof Response)) { - throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') - } - if (!options) { - options = {}; - } + function Response(bodyInit, options) { + if (!(this instanceof Response)) { + throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.') + } + if (!options) { + options = {}; + } - this.type = 'default'; - this.status = options.status === undefined ? 200 : options.status; - this.ok = this.status >= 200 && this.status < 300; - this.statusText = options.statusText === undefined ? '' : '' + options.statusText; - this.headers = new Headers(options.headers); - this.url = options.url || ''; - this._initBody(bodyInit); - } + this.type = 'default'; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = options.statusText === undefined ? '' : '' + options.statusText; + this.headers = new Headers(options.headers); + this.url = options.url || ''; + this._initBody(bodyInit); + } - Body.call(Response.prototype); + Body.call(Response.prototype); - Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - }; + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + }; - Response.error = function() { - var response = new Response(null, {status: 0, statusText: ''}); - response.type = 'error'; - return response - }; + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}); + response.type = 'error'; + return response + }; - var redirectStatuses = [301, 302, 303, 307, 308]; + var redirectStatuses = [301, 302, 303, 307, 308]; - Response.redirect = function(url, status) { - if (redirectStatuses.indexOf(status) === -1) { - throw new RangeError('Invalid status code') - } + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } - return new Response(null, {status: status, headers: {location: url}}) - }; + return new Response(null, {status: status, headers: {location: url}}) + }; - exports.DOMException = global.DOMException; - try { - new exports.DOMException(); - } catch (err) { - exports.DOMException = function(message, name) { - this.message = message; - this.name = name; - var error = Error(message); - this.stack = error.stack; - }; - exports.DOMException.prototype = Object.create(Error.prototype); - exports.DOMException.prototype.constructor = exports.DOMException; - } + exports.DOMException = global.DOMException; + try { + new exports.DOMException(); + } catch (err) { + exports.DOMException = function(message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; + exports.DOMException.prototype = Object.create(Error.prototype); + exports.DOMException.prototype.constructor = exports.DOMException; + } - function fetch(input, init) { - return new Promise(function(resolve, reject) { - var request = new Request(input, init); + function fetch(input, init) { + return new Promise(function(resolve, reject) { + var request = new Request(input, init); - if (request.signal && request.signal.aborted) { - return reject(new exports.DOMException('Aborted', 'AbortError')) - } + if (request.signal && request.signal.aborted) { + return reject(new exports.DOMException('Aborted', 'AbortError')) + } - var xhr = new XMLHttpRequest(); + var xhr = new XMLHttpRequest(); - function abortXhr() { - xhr.abort(); - } + function abortXhr() { + xhr.abort(); + } - xhr.onload = function() { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') - }; - options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); - var body = 'response' in xhr ? xhr.response : xhr.responseText; - setTimeout(function() { - resolve(new Response(body, options)); - }, 0); - }; + xhr.onload = function() { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || '') + }; + options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); + var body = 'response' in xhr ? xhr.response : xhr.responseText; + setTimeout(function() { + resolve(new Response(body, options)); + }, 0); + }; - xhr.onerror = function() { - setTimeout(function() { - reject(new TypeError('Network request failed')); - }, 0); - }; + xhr.onerror = function() { + setTimeout(function() { + reject(new TypeError('Network request failed')); + }, 0); + }; - xhr.ontimeout = function() { - setTimeout(function() { - reject(new TypeError('Network request failed')); - }, 0); - }; + xhr.ontimeout = function() { + setTimeout(function() { + reject(new TypeError('Network request failed')); + }, 0); + }; - xhr.onabort = function() { - setTimeout(function() { - reject(new exports.DOMException('Aborted', 'AbortError')); - }, 0); - }; + xhr.onabort = function() { + setTimeout(function() { + reject(new exports.DOMException('Aborted', 'AbortError')); + }, 0); + }; - function fixUrl(url) { - try { - return url === '' && global.location.href ? global.location.href : url - } catch (e) { - return url - } - } + function fixUrl(url) { + try { + return url === '' && global.location.href ? global.location.href : url + } catch (e) { + return url + } + } - xhr.open(request.method, fixUrl(request.url), true); + xhr.open(request.method, fixUrl(request.url), true); - if (request.credentials === 'include') { - xhr.withCredentials = true; - } else if (request.credentials === 'omit') { - xhr.withCredentials = false; - } + if (request.credentials === 'include') { + xhr.withCredentials = true; + } else if (request.credentials === 'omit') { + xhr.withCredentials = false; + } - if ('responseType' in xhr) { - if (support.blob) { - xhr.responseType = 'blob'; - } else if ( - support.arrayBuffer && - request.headers.get('Content-Type') && - request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 - ) { - xhr.responseType = 'arraybuffer'; - } - } + if ('responseType' in xhr) { + if (support.blob) { + xhr.responseType = 'blob'; + } else if ( + support.arrayBuffer && + request.headers.get('Content-Type') && + request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1 + ) { + xhr.responseType = 'arraybuffer'; + } + } - if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { - Object.getOwnPropertyNames(init.headers).forEach(function(name) { - xhr.setRequestHeader(name, normalizeValue(init.headers[name])); - }); - } else { - request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value); - }); - } + if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) { + Object.getOwnPropertyNames(init.headers).forEach(function(name) { + xhr.setRequestHeader(name, normalizeValue(init.headers[name])); + }); + } else { + request.headers.forEach(function(value, name) { + xhr.setRequestHeader(name, value); + }); + } - if (request.signal) { - request.signal.addEventListener('abort', abortXhr); + if (request.signal) { + request.signal.addEventListener('abort', abortXhr); - xhr.onreadystatechange = function() { - // DONE (success or failure) - if (xhr.readyState === 4) { - request.signal.removeEventListener('abort', abortXhr); - } - }; - } + xhr.onreadystatechange = function() { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener('abort', abortXhr); + } + }; + } - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); - }) - } + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); + }) + } - fetch.polyfill = true; + fetch.polyfill = true; - if (!global.fetch) { - global.fetch = fetch; - global.Headers = Headers; - global.Request = Request; - global.Response = Response; - } + if (!global.fetch) { + global.fetch = fetch; + global.Headers = Headers; + global.Request = Request; + global.Response = Response; + } - exports.Headers = Headers; - exports.Request = Request; - exports.Response = Response; - exports.fetch = fetch; + exports.Headers = Headers; + exports.Request = Request; + exports.Response = Response; + exports.fetch = fetch; - return exports; + return exports; -}))({}); -})(typeof self !== 'undefined' ? self : commonjsGlobal); + }))({}); + })(typeof self !== 'undefined' ? self : browserPolyfill); + return browserPolyfill; +} + +requireBrowserPolyfill(); var global$1 = (typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : @@ -1048,553 +1059,587 @@ function requireMs () { return ms; } -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ - -function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = requireMs(); - createDebug.destroy = destroy; - - Object.keys(env).forEach(key => { - createDebug[key] = env[key]; - }); +var common; +var hasRequiredCommon; +function requireCommon () { + if (hasRequiredCommon) return common; + hasRequiredCommon = 1; /** - * The currently active debug mode names, and names to skip. - */ + * This is the common logic for both the Node.js and web browser + * implementations of `debug()`. + */ - createDebug.names = []; - createDebug.skips = []; + function setup(env) { + createDebug.debug = createDebug; + createDebug.default = createDebug; + createDebug.coerce = coerce; + createDebug.disable = disable; + createDebug.enable = enable; + createDebug.enabled = enabled; + createDebug.humanize = requireMs(); + createDebug.destroy = destroy; + + Object.keys(env).forEach(key => { + createDebug[key] = env[key]; + }); - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - createDebug.formatters = {}; + /** + * The currently active debug mode names, and names to skip. + */ - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - function selectColor(namespace) { - let hash = 0; - - for (let i = 0; i < namespace.length; i++) { - hash = ((hash << 5) - hash) + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } + createDebug.names = []; + createDebug.skips = []; - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - createDebug.selectColor = selectColor; + /** + * Map of special "%n" handling functions, for the debug "format" argument. + * + * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". + */ + createDebug.formatters = {}; + + /** + * Selects a color for a debug namespace + * @param {String} namespace The namespace string for the debug instance to be colored + * @return {Number|String} An ANSI color code for the given namespace + * @api private + */ + function selectColor(namespace) { + let hash = 0; + + for (let i = 0; i < namespace.length; i++) { + hash = ((hash << 5) - hash) + namespace.charCodeAt(i); + hash |= 0; // Convert to 32bit integer + } - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - function createDebug(namespace) { - let prevTime; - let enableOverride = null; - let namespacesCache; - let enabledCache; - - function debug(...args) { - // Disabled? - if (!debug.enabled) { - return; - } + return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; + } + createDebug.selectColor = selectColor; + + /** + * Create a debugger with the given `namespace`. + * + * @param {String} namespace + * @return {Function} + * @api public + */ + function createDebug(namespace) { + let prevTime; + let enableOverride = null; + let namespacesCache; + let enabledCache; + + function debug(...args) { + // Disabled? + if (!debug.enabled) { + return; + } - const self = debug; + const self = debug; - // Set `diff` timestamp - const curr = Number(new Date()); - const ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; + // Set `diff` timestamp + const curr = Number(new Date()); + const ms = curr - (prevTime || curr); + self.diff = ms; + self.prev = prevTime; + self.curr = curr; + prevTime = curr; - args[0] = createDebug.coerce(args[0]); + args[0] = createDebug.coerce(args[0]); - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); + if (typeof args[0] !== 'string') { + // Anything else let's inspect with %O + args.unshift('%O'); + } + + // Apply any `formatters` transformations + let index = 0; + args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { + // If we encounter an escaped % then don't increase the array index + if (match === '%%') { + return '%'; + } + index++; + const formatter = createDebug.formatters[format]; + if (typeof formatter === 'function') { + const val = args[index]; + match = formatter.call(self, val); + + // Now we need to remove `args[index]` since it's inlined in the `format` + args.splice(index, 1); + index--; + } + return match; + }); + + // Apply env-specific formatting (colors, etc.) + createDebug.formatArgs.call(self, args); + + const logFn = self.log || createDebug.log; + logFn.apply(self, args); } - // Apply any `formatters` transformations - let index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return '%'; - } - index++; - const formatter = createDebug.formatters[format]; - if (typeof formatter === 'function') { - const val = args[index]; - match = formatter.call(self, val); - - // Now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; + debug.namespace = namespace; + debug.useColors = createDebug.useColors(); + debug.color = createDebug.selectColor(namespace); + debug.extend = extend; + debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + + Object.defineProperty(debug, 'enabled', { + enumerable: true, + configurable: false, + get: () => { + if (enableOverride !== null) { + return enableOverride; + } + if (namespacesCache !== createDebug.namespaces) { + namespacesCache = createDebug.namespaces; + enabledCache = createDebug.enabled(namespace); + } + + return enabledCache; + }, + set: v => { + enableOverride = v; } - return match; }); - // Apply env-specific formatting (colors, etc.) - createDebug.formatArgs.call(self, args); + // Env-specific initialization logic for debug instances + if (typeof createDebug.init === 'function') { + createDebug.init(debug); + } - const logFn = self.log || createDebug.log; - logFn.apply(self, args); + return debug; } - debug.namespace = namespace; - debug.useColors = createDebug.useColors(); - debug.color = createDebug.selectColor(namespace); - debug.extend = extend; - debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release. + function extend(namespace, delimiter) { + const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); + newDebug.log = this.log; + return newDebug; + } - Object.defineProperty(debug, 'enabled', { - enumerable: true, - configurable: false, - get: () => { - if (enableOverride !== null) { - return enableOverride; + /** + * Enables a debug mode by namespaces. This can include modes + * separated by a colon and wildcards. + * + * @param {String} namespaces + * @api public + */ + function enable(namespaces) { + createDebug.save(namespaces); + createDebug.namespaces = namespaces; + + createDebug.names = []; + createDebug.skips = []; + + const split = (typeof namespaces === 'string' ? namespaces : '') + .trim() + .replace(' ', ',') + .split(',') + .filter(Boolean); + + for (const ns of split) { + if (ns[0] === '-') { + createDebug.skips.push(ns.slice(1)); + } else { + createDebug.names.push(ns); } - if (namespacesCache !== createDebug.namespaces) { - namespacesCache = createDebug.namespaces; - enabledCache = createDebug.enabled(namespace); - } - - return enabledCache; - }, - set: v => { - enableOverride = v; } - }); - - // Env-specific initialization logic for debug instances - if (typeof createDebug.init === 'function') { - createDebug.init(debug); } - return debug; - } - - function extend(namespace, delimiter) { - const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } - - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.namespaces = namespaces; - - createDebug.names = []; - createDebug.skips = []; - - let i; - const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - const len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; + /** + * Checks if the given string matches a namespace template, honoring + * asterisks as wildcards. + * + * @param {String} search + * @param {String} template + * @return {Boolean} + */ + function matchesTemplate(search, template) { + let searchIndex = 0; + let templateIndex = 0; + let starIndex = -1; + let matchIndex = 0; + + while (searchIndex < search.length) { + if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) { + // Match character or proceed with wildcard + if (template[templateIndex] === '*') { + starIndex = templateIndex; + matchIndex = searchIndex; + templateIndex++; // Skip the '*' + } else { + searchIndex++; + templateIndex++; + } + } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition + // Backtrack to the last '*' and try to match more characters + templateIndex = starIndex + 1; + matchIndex++; + searchIndex = matchIndex; + } else { + return false; // No match + } } - namespaces = split[i].replace(/\*/g, '.*?'); - - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); + // Handle trailing '*' in template + while (templateIndex < template.length && template[templateIndex] === '*') { + templateIndex++; } - } - } - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - function disable() { - const namespaces = [ - ...createDebug.names.map(toNamespace), - ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace) - ].join(','); - createDebug.enable(''); - return namespaces; - } + return templateIndex === template.length; + } - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; + /** + * Disable debug output. + * + * @return {String} namespaces + * @api public + */ + function disable() { + const namespaces = [ + ...createDebug.names, + ...createDebug.skips.map(namespace => '-' + namespace) + ].join(','); + createDebug.enable(''); + return namespaces; } - let i; - let len; + /** + * Returns true if the given mode name is enabled, false otherwise. + * + * @param {String} name + * @return {Boolean} + * @api public + */ + function enabled(name) { + for (const skip of createDebug.skips) { + if (matchesTemplate(name, skip)) { + return false; + } + } - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; + for (const ns of createDebug.names) { + if (matchesTemplate(name, ns)) { + return true; + } } + + return false; } - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; + /** + * Coerce `val`. + * + * @param {Mixed} val + * @return {Mixed} + * @api private + */ + function coerce(val) { + if (val instanceof Error) { + return val.stack || val.message; } + return val; } - return false; - } - - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - function toNamespace(regexp) { - return regexp.toString() - .substring(2, regexp.toString().length - 2) - .replace(/\.\*\?$/, '*'); - } - - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; + /** + * XXX DO NOT USE. This is a temporary stub function. + * XXX It WILL be removed in the next major release. + */ + function destroy() { + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); } - return val; - } - /** - * XXX DO NOT USE. This is a temporary stub function. - * XXX It WILL be removed in the next major release. - */ - function destroy() { - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } + createDebug.enable(createDebug.load()); - createDebug.enable(createDebug.load()); + return createDebug; + } - return createDebug; + common = setup; + return common; } -var common = setup; - -(function (module, exports) { - /** - * This is the web browser implementation of `debug()`. - */ - - exports.formatArgs = formatArgs; - exports.save = save; - exports.load = load; - exports.useColors = useColors; - exports.storage = localstorage(); - exports.destroy = (() => { - let warned = false; - - return () => { - if (!warned) { - warned = true; - console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); - } - }; - })(); - - /** - * Colors. - */ - - exports.colors = [ - '#0000CC', - '#0000FF', - '#0033CC', - '#0033FF', - '#0066CC', - '#0066FF', - '#0099CC', - '#0099FF', - '#00CC00', - '#00CC33', - '#00CC66', - '#00CC99', - '#00CCCC', - '#00CCFF', - '#3300CC', - '#3300FF', - '#3333CC', - '#3333FF', - '#3366CC', - '#3366FF', - '#3399CC', - '#3399FF', - '#33CC00', - '#33CC33', - '#33CC66', - '#33CC99', - '#33CCCC', - '#33CCFF', - '#6600CC', - '#6600FF', - '#6633CC', - '#6633FF', - '#66CC00', - '#66CC33', - '#9900CC', - '#9900FF', - '#9933CC', - '#9933FF', - '#99CC00', - '#99CC33', - '#CC0000', - '#CC0033', - '#CC0066', - '#CC0099', - '#CC00CC', - '#CC00FF', - '#CC3300', - '#CC3333', - '#CC3366', - '#CC3399', - '#CC33CC', - '#CC33FF', - '#CC6600', - '#CC6633', - '#CC9900', - '#CC9933', - '#CCCC00', - '#CCCC33', - '#FF0000', - '#FF0033', - '#FF0066', - '#FF0099', - '#FF00CC', - '#FF00FF', - '#FF3300', - '#FF3333', - '#FF3366', - '#FF3399', - '#FF33CC', - '#FF33FF', - '#FF6600', - '#FF6633', - '#FF9900', - '#FF9933', - '#FFCC00', - '#FFCC33' - ]; - - /** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - - // eslint-disable-next-line complexity - function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } +var hasRequiredBrowser; - // Internet Explorer and Edge do not support colors. - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } +function requireBrowser () { + if (hasRequiredBrowser) return browser.exports; + hasRequiredBrowser = 1; + (function (module, exports) { + /** + * This is the web browser implementation of `debug()`. + */ - let m; - - // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || - // Is firebug? http://stackoverflow.com/a/398120/376773 - (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || - // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || - // Double check webkit in userAgent just in case we are in a worker - (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); - } + exports.formatArgs = formatArgs; + exports.save = save; + exports.load = load; + exports.useColors = useColors; + exports.storage = localstorage(); + exports.destroy = (() => { + let warned = false; - /** - * Colorize log arguments if enabled. - * - * @api public - */ + return () => { + if (!warned) { + warned = true; + console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'); + } + }; + })(); + + /** + * Colors. + */ + + exports.colors = [ + '#0000CC', + '#0000FF', + '#0033CC', + '#0033FF', + '#0066CC', + '#0066FF', + '#0099CC', + '#0099FF', + '#00CC00', + '#00CC33', + '#00CC66', + '#00CC99', + '#00CCCC', + '#00CCFF', + '#3300CC', + '#3300FF', + '#3333CC', + '#3333FF', + '#3366CC', + '#3366FF', + '#3399CC', + '#3399FF', + '#33CC00', + '#33CC33', + '#33CC66', + '#33CC99', + '#33CCCC', + '#33CCFF', + '#6600CC', + '#6600FF', + '#6633CC', + '#6633FF', + '#66CC00', + '#66CC33', + '#9900CC', + '#9900FF', + '#9933CC', + '#9933FF', + '#99CC00', + '#99CC33', + '#CC0000', + '#CC0033', + '#CC0066', + '#CC0099', + '#CC00CC', + '#CC00FF', + '#CC3300', + '#CC3333', + '#CC3366', + '#CC3399', + '#CC33CC', + '#CC33FF', + '#CC6600', + '#CC6633', + '#CC9900', + '#CC9933', + '#CCCC00', + '#CCCC33', + '#FF0000', + '#FF0033', + '#FF0066', + '#FF0099', + '#FF00CC', + '#FF00FF', + '#FF3300', + '#FF3333', + '#FF3366', + '#FF3399', + '#FF33CC', + '#FF33FF', + '#FF6600', + '#FF6633', + '#FF9900', + '#FF9933', + '#FFCC00', + '#FFCC33' + ]; + + /** + * Currently only WebKit-based Web Inspectors, Firefox >= v31, + * and the Firebug extension (any Firefox version) are known + * to support "%c" CSS customizations. + * + * TODO: add a `localStorage` variable to explicitly enable/disable colors + */ + + // eslint-disable-next-line complexity + function useColors() { + // NB: In an Electron preload script, document will be defined but not fully + // initialized. Since we know we're in Chrome, we'll just detect this case + // explicitly + if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { + return true; + } - function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + - this.namespace + - (this.useColors ? ' %c' : ' ') + - args[0] + - (this.useColors ? '%c ' : ' ') + - '+' + module.exports.humanize(this.diff); + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } - if (!this.useColors) { - return; + let m; + + // Is webkit? http://stackoverflow.com/a/16459606/376773 + // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 + // eslint-disable-next-line no-return-assign + return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || + // Is firebug? http://stackoverflow.com/a/398120/376773 + (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || + // Is firefox >= v31? + // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages + (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) || + // Double check webkit in userAgent just in case we are in a worker + (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); } - const c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); - - // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - let index = 0; - let lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, match => { - if (match === '%%') { + /** + * Colorize log arguments if enabled. + * + * @api public + */ + + function formatArgs(args) { + args[0] = (this.useColors ? '%c' : '') + + this.namespace + + (this.useColors ? ' %c' : ' ') + + args[0] + + (this.useColors ? '%c ' : ' ') + + '+' + module.exports.humanize(this.diff); + + if (!this.useColors) { return; } - index++; - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - args.splice(lastC, 0, c); - } + const c = 'color: ' + this.color; + args.splice(1, 0, c, 'color: inherit'); - /** - * Invokes `console.debug()` when available. - * No-op when `console.debug` is not a "function". - * If `console.debug` is not available, falls back - * to `console.log`. - * - * @api public - */ - exports.log = console.debug || console.log || (() => {}); + // The final "%c" is somewhat tricky, because there could be other + // arguments passed either before or after the %c, so we need to + // figure out the correct index to insert the CSS into + let index = 0; + let lastC = 0; + args[0].replace(/%[a-zA-Z%]/g, match => { + if (match === '%%') { + return; + } + index++; + if (match === '%c') { + // We only are interested in the *last* %c + // (the user may have provided their own) + lastC = index; + } + }); - /** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? + args.splice(lastC, 0, c); } - } - /** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - function load() { - let r; - try { - r = exports.storage.getItem('debug'); - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? + /** + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. + * + * @api public + */ + exports.log = console.debug || console.log || (() => {}); + + /** + * Save `namespaces`. + * + * @param {String} namespaces + * @api private + */ + function save(namespaces) { + try { + if (namespaces) { + exports.storage.setItem('debug', namespaces); + } else { + exports.storage.removeItem('debug'); + } + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - if (!r && typeof browser$1$1 !== 'undefined' && 'env' in browser$1$1) { - r = browser$1$1.env.DEBUG; - } + /** + * Load `namespaces`. + * + * @return {String} returns the previously persisted debug modes + * @api private + */ + function load() { + let r; + try { + r = exports.storage.getItem('debug'); + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } - return r; - } + // If debug isn't set in LS, and we're in Electron, try to load $DEBUG + if (!r && typeof browser$1$1 !== 'undefined' && 'env' in browser$1$1) { + r = browser$1$1.env.DEBUG; + } - /** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ + return r; + } - function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) { - // Swallow - // XXX (@Qix-) should we be logging these? + /** + * Localstorage attempts to return the localstorage. + * + * This is necessary because safari throws + * when a user disables cookies/localstorage + * and you attempt to access it. + * + * @return {LocalStorage} + * @api private + */ + + function localstorage() { + try { + // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context + // The Browser also has localStorage in the global context. + return localStorage; + } catch (error) { + // Swallow + // XXX (@Qix-) should we be logging these? + } } - } - module.exports = common(exports); + module.exports = requireCommon()(exports); - const {formatters} = module.exports; + const {formatters} = module.exports; - /** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ + /** + * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. + */ - formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } - }; -} (browser, browser.exports)); + formatters.j = function (v) { + try { + return JSON.stringify(v); + } catch (error) { + return '[UnexpectedJSONParseError]: ' + error.message; + } + }; + } (browser, browser.exports)); + return browser.exports; +} -var browserExports = browser.exports; +var browserExports = requireBrowser(); var getLogger = /*@__PURE__*/getDefaultExportFromCjs(browserExports); var DAVNamespace; @@ -1827,7 +1872,7 @@ function write (buffer, value, offset, isLE, mLen, nBytes) { var toString = {}.toString; -var isArray$4 = Array.isArray || function (arr) { +var isArray$1 = Array.isArray || function (arr) { return toString.call(arr) == '[object Array]'; }; @@ -2111,7 +2156,7 @@ function fromObject (that, obj) { return fromArrayLike(that, obj) } - if (obj.type === 'Buffer' && isArray$4(obj.data)) { + if (obj.type === 'Buffer' && isArray$1(obj.data)) { return fromArrayLike(that, obj.data) } } @@ -2176,7 +2221,7 @@ Buffer.isEncoding = function isEncoding (encoding) { }; Buffer.concat = function concat (list, length) { - if (!isArray$4(list)) { + if (!isArray$1(list)) { throw new TypeError('"list" argument must be an Array of Buffers') } @@ -3607,7 +3652,7 @@ function isSlowBuffer (obj) { return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isFastBuffer(obj.slice(0, 0)) } -var sax$1 = {}; +var sax = {}; var domain; @@ -4347,7 +4392,7 @@ function formatValue(ctx, value, recurseTimes) { var base = '', array = false, braces = ['{', '}']; // Make Array say that they are Array - if (isArray$3(value)) { + if (isArray(value)) { array = true; braces = ['[', ']']; } @@ -4526,7 +4571,7 @@ function reduceToSingleString(output, base, braces) { // NOTE: These type checking functions intentionally don't use `instanceof` // because it is fragile and can be easily faked with `Object.create()`. -function isArray$3(ar) { +function isArray(ar) { return Array.isArray(ar); } @@ -6566,2386 +6611,2450 @@ var require$$0 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_stream); var require$$1 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_string_decoder); -(function (exports) { -(function (sax) { // wrapper for non-node envs - sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }; - sax.SAXParser = SAXParser; - sax.SAXStream = SAXStream; - sax.createStream = createStream; - - // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. - // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), - // since that's the earliest that a buffer overrun could occur. This way, checks are - // as rare as required, but as often as necessary to ensure never crossing this bound. - // Furthermore, buffers are only tested at most once per write(), so passing a very - // large string into write() might have undesirable effects, but this is manageable by - // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme - // edge case, result in creating at most one complete copy of the string passed in. - // Set to Infinity to have unlimited buffers. - sax.MAX_BUFFER_LENGTH = 64 * 1024; - - var buffers = [ - 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', - 'procInstName', 'procInstBody', 'entity', 'attribName', - 'attribValue', 'cdata', 'script' - ]; - - sax.EVENTS = [ - 'text', - 'processinginstruction', - 'sgmldeclaration', - 'doctype', - 'comment', - 'opentagstart', - 'attribute', - 'opentag', - 'closetag', - 'opencdata', - 'cdata', - 'closecdata', - 'error', - 'end', - 'ready', - 'script', - 'opennamespace', - 'closenamespace' - ]; - - function SAXParser (strict, opt) { - if (!(this instanceof SAXParser)) { - return new SAXParser(strict, opt) - } - - var parser = this; - clearBuffers(parser); - parser.q = parser.c = ''; - parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH; - parser.opt = opt || {}; - parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags; - parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'; - parser.tags = []; - parser.closed = parser.closedRoot = parser.sawRoot = false; - parser.tag = parser.error = null; - parser.strict = !!strict; - parser.noscript = !!(strict || parser.opt.noscript); - parser.state = S.BEGIN; - parser.strictEntities = parser.opt.strictEntities; - parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES); - parser.attribList = []; - - // namespaces form a prototype chain. - // it always points at the current tag, - // which protos to its parent tag. - if (parser.opt.xmlns) { - parser.ns = Object.create(rootNS); - } +var hasRequiredSax; - // disallow unquoted attribute values if not otherwise configured - // and strict mode is true - if (parser.opt.unquotedAttributeValues === undefined) { - parser.opt.unquotedAttributeValues = !strict; - } - - // mostly just for error reporting - parser.trackPosition = parser.opt.position !== false; - if (parser.trackPosition) { - parser.position = parser.line = parser.column = 0; - } - emit(parser, 'onready'); - } - - if (!Object.create) { - Object.create = function (o) { - function F () {} - F.prototype = o; - var newf = new F(); - return newf - }; - } - - if (!Object.keys) { - Object.keys = function (o) { - var a = []; - for (var i in o) if (o.hasOwnProperty(i)) a.push(i); - return a - }; - } - - function checkBufferLength (parser) { - var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10); - var maxActual = 0; - for (var i = 0, l = buffers.length; i < l; i++) { - var len = parser[buffers[i]].length; - if (len > maxAllowed) { - // Text/cdata nodes can get big, and since they're buffered, - // we can get here under normal conditions. - // Avoid issues by emitting the text node now, - // so at least it won't get any bigger. - switch (buffers[i]) { - case 'textNode': - closeText(parser); - break - - case 'cdata': - emitNode(parser, 'oncdata', parser.cdata); - parser.cdata = ''; - break - - case 'script': - emitNode(parser, 'onscript', parser.script); - parser.script = ''; - break - - default: - error(parser, 'Max buffer length exceeded: ' + buffers[i]); - } - } - maxActual = Math.max(maxActual, len); - } - // schedule the next check for the earliest possible buffer overrun. - var m = sax.MAX_BUFFER_LENGTH - maxActual; - parser.bufferCheckPosition = m + parser.position; - } - - function clearBuffers (parser) { - for (var i = 0, l = buffers.length; i < l; i++) { - parser[buffers[i]] = ''; - } - } - - function flushBuffers (parser) { - closeText(parser); - if (parser.cdata !== '') { - emitNode(parser, 'oncdata', parser.cdata); - parser.cdata = ''; - } - if (parser.script !== '') { - emitNode(parser, 'onscript', parser.script); - parser.script = ''; +function requireSax () { + if (hasRequiredSax) return sax; + hasRequiredSax = 1; + (function (exports) { +(function (sax) { // wrapper for non-node envs + sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }; + sax.SAXParser = SAXParser; + sax.SAXStream = SAXStream; + sax.createStream = createStream; + + // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. + // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), + // since that's the earliest that a buffer overrun could occur. This way, checks are + // as rare as required, but as often as necessary to ensure never crossing this bound. + // Furthermore, buffers are only tested at most once per write(), so passing a very + // large string into write() might have undesirable effects, but this is manageable by + // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme + // edge case, result in creating at most one complete copy of the string passed in. + // Set to Infinity to have unlimited buffers. + sax.MAX_BUFFER_LENGTH = 64 * 1024; + + var buffers = [ + 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype', + 'procInstName', 'procInstBody', 'entity', 'attribName', + 'attribValue', 'cdata', 'script' + ]; + + sax.EVENTS = [ + 'text', + 'processinginstruction', + 'sgmldeclaration', + 'doctype', + 'comment', + 'opentagstart', + 'attribute', + 'opentag', + 'closetag', + 'opencdata', + 'cdata', + 'closecdata', + 'error', + 'end', + 'ready', + 'script', + 'opennamespace', + 'closenamespace' + ]; + + function SAXParser (strict, opt) { + if (!(this instanceof SAXParser)) { + return new SAXParser(strict, opt) + } + + var parser = this; + clearBuffers(parser); + parser.q = parser.c = ''; + parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH; + parser.opt = opt || {}; + parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags; + parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'; + parser.tags = []; + parser.closed = parser.closedRoot = parser.sawRoot = false; + parser.tag = parser.error = null; + parser.strict = !!strict; + parser.noscript = !!(strict || parser.opt.noscript); + parser.state = S.BEGIN; + parser.strictEntities = parser.opt.strictEntities; + parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES); + parser.attribList = []; + + // namespaces form a prototype chain. + // it always points at the current tag, + // which protos to its parent tag. + if (parser.opt.xmlns) { + parser.ns = Object.create(rootNS); + } + + // disallow unquoted attribute values if not otherwise configured + // and strict mode is true + if (parser.opt.unquotedAttributeValues === undefined) { + parser.opt.unquotedAttributeValues = !strict; + } + + // mostly just for error reporting + parser.trackPosition = parser.opt.position !== false; + if (parser.trackPosition) { + parser.position = parser.line = parser.column = 0; + } + emit(parser, 'onready'); + } + + if (!Object.create) { + Object.create = function (o) { + function F () {} + F.prototype = o; + var newf = new F(); + return newf + }; + } + + if (!Object.keys) { + Object.keys = function (o) { + var a = []; + for (var i in o) if (o.hasOwnProperty(i)) a.push(i); + return a + }; + } + + function checkBufferLength (parser) { + var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10); + var maxActual = 0; + for (var i = 0, l = buffers.length; i < l; i++) { + var len = parser[buffers[i]].length; + if (len > maxAllowed) { + // Text/cdata nodes can get big, and since they're buffered, + // we can get here under normal conditions. + // Avoid issues by emitting the text node now, + // so at least it won't get any bigger. + switch (buffers[i]) { + case 'textNode': + closeText(parser); + break + + case 'cdata': + emitNode(parser, 'oncdata', parser.cdata); + parser.cdata = ''; + break + + case 'script': + emitNode(parser, 'onscript', parser.script); + parser.script = ''; + break + + default: + error(parser, 'Max buffer length exceeded: ' + buffers[i]); + } + } + maxActual = Math.max(maxActual, len); + } + // schedule the next check for the earliest possible buffer overrun. + var m = sax.MAX_BUFFER_LENGTH - maxActual; + parser.bufferCheckPosition = m + parser.position; + } + + function clearBuffers (parser) { + for (var i = 0, l = buffers.length; i < l; i++) { + parser[buffers[i]] = ''; + } + } + + function flushBuffers (parser) { + closeText(parser); + if (parser.cdata !== '') { + emitNode(parser, 'oncdata', parser.cdata); + parser.cdata = ''; + } + if (parser.script !== '') { + emitNode(parser, 'onscript', parser.script); + parser.script = ''; + } + } + + SAXParser.prototype = { + end: function () { end(this); }, + write: write, + resume: function () { this.error = null; return this }, + close: function () { return this.write(null) }, + flush: function () { flushBuffers(this); } + }; + + var Stream; + try { + Stream = require$$0.Stream; + } catch (ex) { + Stream = function () {}; + } + if (!Stream) Stream = function () {}; + + var streamWraps = sax.EVENTS.filter(function (ev) { + return ev !== 'error' && ev !== 'end' + }); + + function createStream (strict, opt) { + return new SAXStream(strict, opt) + } + + function SAXStream (strict, opt) { + if (!(this instanceof SAXStream)) { + return new SAXStream(strict, opt) + } + + Stream.apply(this); + + this._parser = new SAXParser(strict, opt); + this.writable = true; + this.readable = true; + + var me = this; + + this._parser.onend = function () { + me.emit('end'); + }; + + this._parser.onerror = function (er) { + me.emit('error', er); + + // if didn't throw, then means error was handled. + // go ahead and clear error, so we can write again. + me._parser.error = null; + }; + + this._decoder = null; + + streamWraps.forEach(function (ev) { + Object.defineProperty(me, 'on' + ev, { + get: function () { + return me._parser['on' + ev] + }, + set: function (h) { + if (!h) { + me.removeAllListeners(ev); + me._parser['on' + ev] = h; + return h + } + me.on(ev, h); + }, + enumerable: true, + configurable: false + }); + }); + } + + SAXStream.prototype = Object.create(Stream.prototype, { + constructor: { + value: SAXStream + } + }); + + SAXStream.prototype.write = function (data) { + if (typeof Buffer === 'function' && + typeof Buffer.isBuffer === 'function' && + Buffer.isBuffer(data)) { + if (!this._decoder) { + var SD = require$$1.StringDecoder; + this._decoder = new SD('utf8'); + } + data = this._decoder.write(data); + } + + this._parser.write(data.toString()); + this.emit('data', data); + return true + }; + + SAXStream.prototype.end = function (chunk) { + if (chunk && chunk.length) { + this.write(chunk); + } + this._parser.end(); + return true + }; + + SAXStream.prototype.on = function (ev, handler) { + var me = this; + if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) { + me._parser['on' + ev] = function () { + var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments); + args.splice(0, 0, ev); + me.emit.apply(me, args); + }; + } + + return Stream.prototype.on.call(me, ev, handler) + }; + + // this really needs to be replaced with character classes. + // XML allows all manner of ridiculous numbers and digits. + var CDATA = '[CDATA['; + var DOCTYPE = 'DOCTYPE'; + var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'; + var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'; + var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }; + + // http://www.w3.org/TR/REC-xml/#NT-NameStartChar + // This implementation works on strings, a single character at a time + // as such, it cannot ever support astral-plane characters (10000-EFFFF) + // without a significant breaking change to either this parser, or the + // JavaScript language. Implementation of an emoji-capable xml parser + // is left as an exercise for the reader. + var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; + + var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; + + var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/; + var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/; + + function isWhitespace (c) { + return c === ' ' || c === '\n' || c === '\r' || c === '\t' + } + + function isQuote (c) { + return c === '"' || c === '\'' + } + + function isAttribEnd (c) { + return c === '>' || isWhitespace(c) + } + + function isMatch (regex, c) { + return regex.test(c) + } + + function notMatch (regex, c) { + return !isMatch(regex, c) + } + + var S = 0; + sax.STATE = { + BEGIN: S++, // leading byte order mark or whitespace + BEGIN_WHITESPACE: S++, // leading whitespace + TEXT: S++, // general stuff + TEXT_ENTITY: S++, // & and such. + OPEN_WAKA: S++, // < + SGML_DECL: S++, // + SCRIPT: S++, //