mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove references to service workers in RN globals (#49727)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/49727 Changelog: [internal] React Native doesn't define or use Service Workers, so this entire section for types is unnecessary. Reviewed By: cortinico Differential Revision: D70327703 fbshipit-source-id: b998eade21d19ed124824cb255a37cb9e805d151
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e808011b26
commit
eb877cba39
@@ -352,7 +352,6 @@ declare class Navigator
|
||||
usb?: USB;
|
||||
maxTouchPoints: number;
|
||||
permissions: Permissions;
|
||||
serviceWorker?: ServiceWorkerContainer;
|
||||
getGamepads?: () => Array<Gamepad | null>;
|
||||
webkitGetGamepads?: Function;
|
||||
mozGetGamepads?: Function;
|
||||
@@ -929,84 +928,6 @@ declare class WebSocket extends EventTarget {
|
||||
CLOSED: 3;
|
||||
}
|
||||
|
||||
type WorkerOptions = {
|
||||
type?: WorkerType,
|
||||
credentials?: CredentialsType,
|
||||
name?: string,
|
||||
...
|
||||
};
|
||||
|
||||
declare class Worker extends EventTarget {
|
||||
constructor(
|
||||
stringUrl: string | TrustedScriptURL,
|
||||
workerOptions?: WorkerOptions,
|
||||
): void;
|
||||
onerror: null | ((ev: any) => mixed);
|
||||
onmessage: null | ((ev: MessageEvent) => mixed);
|
||||
onmessageerror: null | ((ev: MessageEvent) => mixed);
|
||||
postMessage(message: any, ports?: any): void;
|
||||
terminate(): void;
|
||||
}
|
||||
|
||||
declare class SharedWorker extends EventTarget {
|
||||
constructor(stringUrl: string | TrustedScriptURL, name?: string): void;
|
||||
constructor(
|
||||
stringUrl: string | TrustedScriptURL,
|
||||
workerOptions?: WorkerOptions,
|
||||
): void;
|
||||
port: MessagePort;
|
||||
onerror: (ev: any) => mixed;
|
||||
}
|
||||
|
||||
declare function importScripts(...urls: Array<string | TrustedScriptURL>): void;
|
||||
|
||||
declare class WorkerGlobalScope extends EventTarget {
|
||||
self: this;
|
||||
location: WorkerLocation;
|
||||
navigator: WorkerNavigator;
|
||||
close(): void;
|
||||
importScripts(...urls: Array<string | TrustedScriptURL>): void;
|
||||
onerror: (ev: any) => mixed;
|
||||
onlanguagechange: (ev: any) => mixed;
|
||||
onoffline: (ev: any) => mixed;
|
||||
ononline: (ev: any) => mixed;
|
||||
onrejectionhandled: (ev: PromiseRejectionEvent) => mixed;
|
||||
onunhandledrejection: (ev: PromiseRejectionEvent) => mixed;
|
||||
}
|
||||
|
||||
declare class DedicatedWorkerGlobalScope extends WorkerGlobalScope {
|
||||
onmessage: (ev: MessageEvent) => mixed;
|
||||
onmessageerror: (ev: MessageEvent) => mixed;
|
||||
postMessage(message: any, transfer?: Iterable<any>): void;
|
||||
}
|
||||
|
||||
declare class SharedWorkerGlobalScope extends WorkerGlobalScope {
|
||||
name: string;
|
||||
onconnect: (ev: MessageEvent) => mixed;
|
||||
}
|
||||
|
||||
declare class WorkerLocation {
|
||||
origin: string;
|
||||
protocol: string;
|
||||
host: string;
|
||||
hostname: string;
|
||||
port: string;
|
||||
pathname: string;
|
||||
search: string;
|
||||
hash: string;
|
||||
}
|
||||
|
||||
declare class WorkerNavigator
|
||||
mixins
|
||||
NavigatorID,
|
||||
NavigatorLanguage,
|
||||
NavigatorOnLine,
|
||||
NavigatorConcurrentHardware,
|
||||
NavigatorStorage
|
||||
{
|
||||
permissions: Permissions;
|
||||
}
|
||||
|
||||
// deprecated
|
||||
declare class XDomainRequest {
|
||||
timeout: number;
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
* @oncall flow
|
||||
*/
|
||||
|
||||
// https://github.com/flow-typed/flow-typed/blob/main/definitions/environments/serviceworkers/flow_v0.261.x-/serviceworkers.js
|
||||
|
||||
type FrameType = 'auxiliary' | 'top-level' | 'nested' | 'none';
|
||||
type VisibilityState = 'hidden' | 'visible' | 'prerender' | 'unloaded';
|
||||
|
||||
declare class WindowClient extends Client {
|
||||
visibilityState: VisibilityState;
|
||||
focused: boolean;
|
||||
focus(): Promise<WindowClient>;
|
||||
navigate(url: string): Promise<WindowClient>;
|
||||
}
|
||||
|
||||
declare class Client {
|
||||
id: string;
|
||||
reserved: boolean;
|
||||
url: string;
|
||||
frameType: FrameType;
|
||||
postMessage(message: any, transfer?: Iterator<any> | Array<any>): void;
|
||||
}
|
||||
|
||||
declare class ExtendableEvent extends Event {
|
||||
waitUntil(f: Promise<mixed>): void;
|
||||
}
|
||||
|
||||
type NotificationEvent$Init = {
|
||||
...Event$Init,
|
||||
notification: Notification,
|
||||
action?: string,
|
||||
...
|
||||
};
|
||||
|
||||
declare class NotificationEvent extends ExtendableEvent {
|
||||
constructor(type: string, eventInitDict?: NotificationEvent$Init): void;
|
||||
+notification: Notification;
|
||||
+action: string;
|
||||
}
|
||||
|
||||
type ForeignFetchOptions = {
|
||||
scopes: Iterator<string>,
|
||||
origins: Iterator<string>,
|
||||
...
|
||||
};
|
||||
|
||||
declare class InstallEvent extends ExtendableEvent {
|
||||
registerForeignFetch(options: ForeignFetchOptions): void;
|
||||
}
|
||||
|
||||
declare class FetchEvent extends ExtendableEvent {
|
||||
request: Request;
|
||||
clientId: string;
|
||||
isReload: boolean;
|
||||
respondWith(response: Response | Promise<Response>): void;
|
||||
preloadResponse: Promise<?Response>;
|
||||
}
|
||||
|
||||
type ClientType = 'window' | 'worker' | 'sharedworker' | 'all';
|
||||
type ClientQueryOptions = {
|
||||
includeUncontrolled?: boolean,
|
||||
includeReserved?: boolean,
|
||||
type?: ClientType,
|
||||
...
|
||||
};
|
||||
|
||||
declare class Clients {
|
||||
get(id: string): Promise<?Client>;
|
||||
matchAll(options?: ClientQueryOptions): Promise<Array<Client>>;
|
||||
openWindow(url: string): Promise<?WindowClient>;
|
||||
claim(): Promise<void>;
|
||||
}
|
||||
|
||||
type ServiceWorkerState =
|
||||
| 'installing'
|
||||
| 'installed'
|
||||
| 'activating'
|
||||
| 'activated'
|
||||
| 'redundant';
|
||||
|
||||
declare class ServiceWorker extends EventTarget {
|
||||
scriptURL: string;
|
||||
state: ServiceWorkerState;
|
||||
|
||||
postMessage(message: any, transfer?: Iterator<any>): void;
|
||||
|
||||
onstatechange?: EventHandler;
|
||||
}
|
||||
|
||||
declare class NavigationPreloadState {
|
||||
enabled: boolean;
|
||||
headerValue: string;
|
||||
}
|
||||
|
||||
declare class NavigationPreloadManager {
|
||||
enable: Promise<void>;
|
||||
disable: Promise<void>;
|
||||
setHeaderValue(value: string): Promise<void>;
|
||||
getState: Promise<NavigationPreloadState>;
|
||||
}
|
||||
|
||||
type PushSubscriptionOptions = {
|
||||
userVisibleOnly?: boolean,
|
||||
applicationServerKey?: string | ArrayBuffer | $ArrayBufferView,
|
||||
...
|
||||
};
|
||||
|
||||
declare class PushSubscriptionJSON {
|
||||
endpoint: string;
|
||||
expirationTime: number | null;
|
||||
keys: {[string]: string, ...};
|
||||
}
|
||||
|
||||
declare class PushSubscription {
|
||||
+endpoint: string;
|
||||
+expirationTime: number | null;
|
||||
+options: PushSubscriptionOptions;
|
||||
getKey(name: string): ArrayBuffer | null;
|
||||
toJSON(): PushSubscriptionJSON;
|
||||
unsubscribe(): Promise<boolean>;
|
||||
}
|
||||
|
||||
declare class PushManager {
|
||||
+supportedContentEncodings: Array<string>;
|
||||
subscribe(options?: PushSubscriptionOptions): Promise<PushSubscription>;
|
||||
getSubscription(): Promise<PushSubscription | null>;
|
||||
permissionState(
|
||||
options?: PushSubscriptionOptions,
|
||||
): Promise<'granted' | 'denied' | 'prompt'>;
|
||||
}
|
||||
|
||||
type ServiceWorkerUpdateViaCache = 'imports' | 'all' | 'none';
|
||||
|
||||
type GetNotificationOptions = {
|
||||
tag?: string,
|
||||
...
|
||||
};
|
||||
|
||||
declare class ServiceWorkerRegistration extends EventTarget {
|
||||
+installing: ?ServiceWorker;
|
||||
+waiting: ?ServiceWorker;
|
||||
+active: ?ServiceWorker;
|
||||
+navigationPreload: NavigationPreloadManager;
|
||||
+scope: string;
|
||||
+updateViaCache: ServiceWorkerUpdateViaCache;
|
||||
+pushManager: PushManager;
|
||||
|
||||
getNotifications?: (
|
||||
filter?: GetNotificationOptions,
|
||||
) => Promise<$ReadOnlyArray<Notification>>;
|
||||
showNotification?: (
|
||||
title: string,
|
||||
options?: NotificationOptions,
|
||||
) => Promise<void>;
|
||||
update(): Promise<void>;
|
||||
unregister(): Promise<boolean>;
|
||||
|
||||
onupdatefound?: EventHandler;
|
||||
}
|
||||
|
||||
type WorkerType = 'classic' | 'module';
|
||||
|
||||
type RegistrationOptions = {
|
||||
scope?: string,
|
||||
type?: WorkerType,
|
||||
updateViaCache?: ServiceWorkerUpdateViaCache,
|
||||
...
|
||||
};
|
||||
|
||||
declare class ServiceWorkerContainer extends EventTarget {
|
||||
+controller: ?ServiceWorker;
|
||||
+ready: Promise<ServiceWorkerRegistration>;
|
||||
|
||||
getRegistration(
|
||||
clientURL?: string,
|
||||
): Promise<ServiceWorkerRegistration | void>;
|
||||
getRegistrations(): Promise<Iterator<ServiceWorkerRegistration>>;
|
||||
register(
|
||||
scriptURL: string | TrustedScriptURL,
|
||||
options?: RegistrationOptions,
|
||||
): Promise<ServiceWorkerRegistration>;
|
||||
startMessages(): void;
|
||||
|
||||
oncontrollerchange?: EventHandler;
|
||||
onmessage?: EventHandler;
|
||||
onmessageerror?: EventHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* This feature has been removed from the Web standards.
|
||||
*/
|
||||
declare class ServiceWorkerMessageEvent extends Event {
|
||||
data: any;
|
||||
lastEventId: string;
|
||||
origin: string;
|
||||
ports: Array<MessagePort>;
|
||||
source: ?(ServiceWorker | MessagePort);
|
||||
}
|
||||
|
||||
declare class ExtendableMessageEvent extends ExtendableEvent {
|
||||
data: any;
|
||||
lastEventId: string;
|
||||
origin: string;
|
||||
ports: Array<MessagePort>;
|
||||
source: ?(ServiceWorker | MessagePort);
|
||||
}
|
||||
|
||||
type CacheQueryOptions = {
|
||||
ignoreSearch?: boolean,
|
||||
ignoreMethod?: boolean,
|
||||
ignoreVary?: boolean,
|
||||
cacheName?: string,
|
||||
...
|
||||
};
|
||||
|
||||
declare class Cache {
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
|
||||
matchAll(
|
||||
request: RequestInfo,
|
||||
options?: CacheQueryOptions,
|
||||
): Promise<Array<Response>>;
|
||||
add(request: RequestInfo): Promise<void>;
|
||||
addAll(requests: Array<RequestInfo>): Promise<void>;
|
||||
put(request: RequestInfo, response: Response): Promise<void>;
|
||||
delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
|
||||
keys(
|
||||
request?: RequestInfo,
|
||||
options?: CacheQueryOptions,
|
||||
): Promise<Array<Request>>;
|
||||
}
|
||||
|
||||
declare class CacheStorage {
|
||||
match(request: RequestInfo, options?: CacheQueryOptions): Promise<Response>;
|
||||
has(cacheName: string): Promise<true>;
|
||||
open(cacheName: string): Promise<Cache>;
|
||||
delete(cacheName: string): Promise<boolean>;
|
||||
keys(): Promise<Array<string>>;
|
||||
}
|
||||
|
||||
// Service worker global scope
|
||||
// https://www.w3.org/TR/service-workers/#service-worker-global-scope
|
||||
declare var clients: Clients;
|
||||
declare var caches: CacheStorage;
|
||||
declare var registration: ServiceWorkerRegistration;
|
||||
declare function skipWaiting(): Promise<void>;
|
||||
declare var onactivate: ?EventHandler;
|
||||
declare var oninstall: ?EventHandler;
|
||||
declare var onfetch: ?EventHandler;
|
||||
declare var onforeignfetch: ?EventHandler;
|
||||
declare var onmessage: ?EventHandler;
|
||||
Reference in New Issue
Block a user