Remove packages superceded by lib.dom.d.ts in TS3.5 (#34641)

This commit is contained in:
Nathan Shively-Sanders 2019-04-11 10:41:54 -07:00 committed by GitHub
parent e853ebb6cb
commit fbdefe009e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 18 additions and 707 deletions

View File

@ -1416,6 +1416,12 @@
"sourceRepoURL": "https://github.com/apache/couchdb-nano",
"asOfVersion": "7.0.0"
},
{
"libraryName": "typescript",
"typingsPackageName": "navigator-permissions",
"sourceRepoURL": "https://developer.mozilla.org/en-US/docs/Web/API/Permissions",
"asOfVersion": "2.0.0"
},
{
"libraryName": "ng-table",
"typingsPackageName": "ng-table",
@ -2592,6 +2598,12 @@
"sourceRepoURL": "https://github.com/vuejs/vue-router",
"asOfVersion": "2.0.0"
},
{
"libraryName": "typescript",
"typingsPackageName": "w3c-permissions",
"sourceRepoURL": "https://www.w3.org/TR/permissions/",
"asOfVersion": "2.0.0"
},
{
"libraryName": "wait-for-localhost",
"typingsPackageName": "wait-for-localhost",
@ -2604,6 +2616,12 @@
"sourceRepoURL": "https://github.com/sindresorhus/wallpaper",
"asOfVersion": "4.3.0"
},
{
"libraryName": "typescript",
"typingsPackageName": "webassembly-js-api",
"sourceRepoURL": "https://github.com/winksaville/test-webassembly-js-ts",
"asOfVersion": "2.0.0"
},
{
"libraryName": "webcola",
"typingsPackageName": "webcola",

View File

@ -1,187 +0,0 @@
// Type definitions for non-npm package Navigator.Permissions 0.1
// Project: https://developer.mozilla.org/en-US/docs/Web/API/Permissions
// Definitions by: Vince Varga <https://github.com/vargavince91>, MindDoc <https://github.com/minddocdev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/**
* Namespace for `navigator.permissions` type definitions.
*
* As the Permissions API is only supported by Firefox and Chrome
* https://caniuse.com/#feat=permissions-api
* the TypeScript team has not yet added it to lib.dom.d.ts
* https://github.com/Microsoft/TypeScript/issues/24923
* In the meantime, these type definitions can be used.
*
* The documentation is based on the MDN web docs
* https://developer.mozilla.org/en-US/docs/Web/API/Permissions
*/
declare namespace NavigatorPermissions {
/**
* Permission state values.
*/
type PermissionState =
'granted' |
'denied' |
'prompt';
/**
* The `PermissionStatus` interface of the Permissions API provides the state
* of an object and an event handler for monitoring changes to said state.
*
* This is an experimental technology
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/PermissionStatus}
*/
interface PermissionStatus extends EventTarget {
/**
* Returns the state of a requested permission.
*/
readonly state: PermissionState;
/**
* Returns the state of a requested permission.
* Later versions of the specification replace this with
* `PermissionStatus.state`.
* @deprecated
*/
readonly status: PermissionState;
/**
* An event called whenever `PermissionStatus.status` changes.
*/
onchange: ((this: this, event: Event) => any) | null;
}
/**
* Permission name options.
*/
type PermissionName =
'accelerometer' |
'accessibility-events' |
'ambient-light-sensor' |
'background-sync' |
'camera' |
'clipboard-read' |
'clipboard-write' |
'geolocation' |
'gyroscope' |
'magnetometer' |
'microphone' |
'midi' |
'notifications' |
'payment-handler' |
'persistent-storage' |
'push';
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query}
*/
interface PermissionDescriptor<N extends PermissionName> {
/**
* The name of the API whose permissions you want to query.
*
* Please, be aware, that not all of these are supported in every browser
* that supports the Permissions API. For example, in Firefox you can't query
* the `'microphone'` or `'camera'` and it'll throw `TypeError`
*/
name: N;
}
interface PushPermissionDescriptor extends PermissionDescriptor<'push'> {
/**
* Indicates whether you want to show a notification for every message
* or be able to send silent push
* notifications. The default is `false`. Not supported in Firefox.
*/
userVisibleOnly?: boolean;
}
interface MidiPermissionDescriptor extends PermissionDescriptor<'midi'> {
/**
* Indicates whether you need and/or receive system exclusive
* messages. The default is false.
*/
sysex?: boolean;
}
// Map permission names to correctly typed descriptors.
interface QueryNameDescriptorMap {
// ??? Question ???:
// Is there a better way to handle this case and remove repeated code,
// something like
// <N extends PermissionName, D extends PermissionDescriptor<N>> {
// [n in N]: D; // this line to cover all basic cases
// // and the custom permission descriptors for midi and push
// }
'accelerometer': PermissionDescriptor<'accelerometer'>;
'accessibility-events': PermissionDescriptor<'accessibility-events'>;
'ambient-light-sensor': PermissionDescriptor<'ambient-light-sensor'>;
'background-sync': PermissionDescriptor<'background-sync'>;
'camera': PermissionDescriptor<'camera'>;
'clipboard-read': PermissionDescriptor<'clipboard-read'>;
'clipboard-write': PermissionDescriptor<'clipboard-write'>;
'geolocation': PermissionDescriptor<'geolocation'>;
'gyroscope': PermissionDescriptor<'gyroscope'>;
'magnetometer': PermissionDescriptor<'magnetometer'>;
'microphone': PermissionDescriptor<'microphone'>;
'notifications': PermissionDescriptor<'notifications'>;
'payment-handler': PermissionDescriptor<'payment-handler'>;
'persistent-storage': PermissionDescriptor<'persistent-storage'>;
// These permission descriptors support extra properties
'midi': MidiPermissionDescriptor;
'push': PushPermissionDescriptor;
}
interface RevokeNameDescriptorMap {
'geolocation': PermissionDescriptor<'geolocation'>;
'notifications': PermissionDescriptor<'notifications'>;
'midi': MidiPermissionDescriptor;
'push': PushPermissionDescriptor;
}
/**
* The `Permissions` interface of the Permissions API provides the core
* Permission API functionality, such as methods for querying and
* revoking permissions.
*
* This is an experimental technology.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions}
*/
interface Permissions {
/**
* The `Permissions.query()` method of the `Permissions` interface returns
* the state of a user permission on the global scope.
* @param permissionDescriptor object that sets
* options for the query operation consisting of a comma-separated list
* of name-value pairs.
* (Is comma-separated list really supported? It is mentioned in the docs, but does not work).
* @returns the user permission status for a given API.
* @throws `TypeError` Retrieving the `PermissionDescriptor` information
* failed in some way, or the permission doesn't exist or is currently
* unsupported (e.g. `midi`, or `push` with `userVisibleOnly`).
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query}
*/
query(permissionDescriptor: QueryNameDescriptorMap[keyof QueryNameDescriptorMap]): Promise<PermissionStatus>;
/**
* The `Permissions.revoke()` method of the `Permissions` interface reverts a
* currently set permission back to its default state, which is usually `prompt`.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Permissions/revoke}
*/
revoke(permissionDescriptor: RevokeNameDescriptorMap[keyof RevokeNameDescriptorMap]): Promise<PermissionStatus>;
}
/**
* Navigator type definition with possible `permissions` API support.
*
* This interface adds the `permissions` property to the navigator.
*/
interface NavigatorPermissions extends Navigator {
/**
* Provides the core Permission API functionality, such as querying and revoking permissions.
*
* The typing takes into account that the feature is not widely supported,
* making code using this API more secure by forcing considering the `undefined` case.
*/
permissions?: Permissions;
}
}

View File

@ -1,91 +0,0 @@
// Here are some examples for Navigator.Permissions types.
// Open it in your IDE with TypeScript support and observe the types and documentation help
// that this module provides
// Navigator from lib.dom might have permissions
const nav = navigator as NavigatorPermissions.NavigatorPermissions;
async function exampleQueryAndEventListeners() {
// Force users to check for undefined as the feature is not widely supported
if (typeof nav.permissions === 'undefined') { return; }
const permissionsStatus = await nav.permissions.query({ name: 'camera' });
// Possible state values are known to users:
const isDenied = permissionsStatus.state === 'denied';
// if compared to any non-valid value, it warns
// const tsShouldWarn = permissionsStatus.state === 'can you see the warning?';
permissionsStatus.addEventListener('change', (event) => {
console.log('permission state changed');
// I couldn't find a way to set the EventTarget's type to PermissionStatus
console.log('new PermissionStatus', event.target);
});
}
function exampleQueryOptions() {
// Force users to check for undefined as the feature is not widely supported
if (typeof nav.permissions === 'undefined') { return; }
// query method checks if the name is a valid permission name
nav.permissions.query({ name: 'camera' });
// Other names would cause type errors
// nav.permissions.query({ name: 'invalid name' });
// When permission name is 'push', userVisibleOnly property is also supported
nav.permissions.query({ name: 'push', userVisibleOnly: true });
// For other names, it would fail:
// nav.permissions.query({ name: 'camera', userVisibleOnly: true });
// When permission name is 'midi', sysex property is also supported
nav.permissions.query({ name: 'midi', sysex: true });
// For other names, it would fail:
// nav.permissions.query({ name: 'camera', sysex: true });
}
function exampleIgnoreUndefinedCheck() {
// Using the ! after permissions will let you bypass the undefined-check
nav.permissions!.query({ name: 'microphone' });
}
function exampleRevokeDoesNotSupportTheSameDescriptorsAsQuery() {
const cameraQueryPromise: Promise<NavigatorPermissions.PermissionStatus> = nav.permissions!.query({ name: 'camera' });
// Revoke only supports a subset of descriptors
// nav.permissions!.revoke({ name: 'camera' });
// For example name: 'notifications'
const notificationRevocalPromise: Promise<NavigatorPermissions.PermissionStatus> = nav.permissions!.revoke({ name: 'notifications' });
}
function exampleFromMdnForQueryMethod() {
if (nav.permissions === undefined) {
console.error('Permissions API not supported');
return;
}
function showLocalNewsWithGeolocation() { /* Not implemented */ }
function showButtonToEnableLocalNews() { /* Not implemented */ }
// Using .then instead of async-await
nav.permissions.query({ name: 'geolocation' }).then((result) => {
if (result.state === 'granted') {
showLocalNewsWithGeolocation();
} else if (result.state === 'prompt') {
showButtonToEnableLocalNews();
}
// Don't do anything if the permission was denied.
});
}
function exampleFromMdnForRevokeMethod() {
// Just an example report function I made up
function report(state: NavigatorPermissions.PermissionState) {
switch (state) {
case 'denied': console.error('State: DENIED'); break;
case 'granted': console.log('State: GRANTED'); break;
case 'prompt': console.info('State: PROMPT'); break;
// Using a string that's an invalid state would result in an error from TypeScript
// case 'invalid': console.warn('Type "invalid" is not comparable to type "PermissionState".');
}
}
// This is a slightly modified example from the MDN revoke method documentation
// https://developer.mozilla.org/en-US/docs/Web/API/Permissions/revoke#Example
// Using .then instead of async-await
nav.permissions!.revoke({ name: 'geolocation' }).then((result) => {
report(result.state);
});
}

View File

@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"navigator-permissions-tests.ts"
]
}

View File

@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,92 +0,0 @@
// Type definitions for non-npm package W3C Permissions API 1.0
// Project: https://www.w3.org/TR/permissions/
// Definitions by: Julien Bérubé <https://github.com/jberube>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// https://www.w3.org/TR/permissions/#permissions-interface
declare class Permissions {
query(permissionDesc: PermissionDescriptor): Promise<PermissionStatus>;
}
// https://www.w3.org/TR/permissions/#status-of-a-permission
type PermissionState = "granted" | "denied" | "prompt";
// https://www.w3.org/TR/permissions/#permission-registry
type PermissionName =
"geolocation" |
"notifications" |
"push" |
"midi" |
"camera" |
"microphone" |
"speaker" |
"device-info" |
"background-sync" |
"bluetooth" |
"persistent-storage" |
"ambient-light-sensor" |
"accelerometer" |
"gyroscope" |
"magnetometer" |
"clipboard";
// https://www.w3.org/TR/permissions/#status-of-a-permission
declare class PermissionStatus extends EventTarget {
readonly state: PermissionState;
onchange(): (this: this, ev: Event) => any;
}
// https://www.w3.org/TR/permissions/#permission-descriptor
interface PermissionDescriptor {
name: string;
}
// https://www.w3.org/TR/permissions/#geolocation
type GeolocationPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#notifications
type NotificationsPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#push
interface PushPermissionDescriptor extends PermissionDescriptor {
userVisibleOnly?: boolean;
}
// https://www.w3.org/TR/permissions/#midi
interface MidiPermissionDescriptor extends PermissionDescriptor {
sysex: boolean;
}
// https://www.w3.org/TR/permissions/#media-devices
interface DevicePermissionDescriptor extends PermissionDescriptor {
deviceId: string;
}
// https://www.w3.org/TR/permissions/#background-sync
type BackgroundSyncPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#ambient-light-sensor
type AmbientLightSensorPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#accelerometer
type AccelerometerPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#gyroscope
type GyroscopePermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#magnetometer
type MagnetometerPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#clipboard
type ClipboardPermissionDescriptor = PermissionDescriptor;
// https://www.w3.org/TR/permissions/#navigator-and-workernavigator-extension
interface Navigator {
readonly permissions: Permissions;
}
// https://www.w3.org/TR/permissions/#navigator-and-workernavigator-extension
interface WorkerNavigator {
readonly permissions: Permissions;
}

View File

@ -1,24 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"w3c-permissions-tests.ts"
]
}

View File

@ -1 +0,0 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,45 +0,0 @@
// Modified from Permissions API spec: https://w3c.github.io/permissions/#examples
// NOTE: Code kept as close to spec examples as possible
// Example 3
function showLocalNewsWithGeolocation() {}
function showButtonToEnableLocalNews() {}
const test = navigator.permissions.query({ name: "geolocation" }).then(({ state }) => {
switch (state) {
case "granted":
showLocalNewsWithGeolocation();
break;
case "prompt":
showButtonToEnableLocalNews();
break;
default:
// Dont do anything if the permission was denied.
break;
}
});
// Example 4
function updateNotificationButton(state: PermissionState) {
const button = document.getElementById('chat-notification-button');
if (button) {
button.setAttribute('disabled', state === 'denied' ? 'disabled' : '');
}
}
navigator.permissions.query({ name: 'notifications' }).then((result) => {
updateNotificationButton(result.state);
result.addEventListener('change', () => {
updateNotificationButton(result.state);
});
});
// Example 5
Promise.all([
navigator.permissions.query({ name: "geolocation" }),
navigator.permissions.query({ name: "notifications" })
])
.then(([{ state: geoState }, { state: notifState }]) => {
console.log("Geolocation permission state is:", geoState);
console.log("Notifications permission state is:", notifState);
});

View File

@ -1,131 +0,0 @@
// Type definitions for WebAssembly v1 (MVP)
// Project: https://github.com/winksaville/test-webassembly-js-ts
// Definitions by: 01alchemist <https://twitter.com/01alchemist>
// Wink Saville <wink@saville.com>
// Periklis Tsirakidis <https://github.com/periklis>
// Sergey Rubanov <https://github.com/chicoxyzzy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/**
* The WebAssembly namespace, see [WebAssembly](https://github.com/webassembly)
* and [WebAssembly JS API](http://webassembly.org/getting-started/js-api/)
* for more information.
*/
declare namespace WebAssembly {
type Imports = Array<{
name: string;
kind: string;
}>;
type Exports = Array<{
module: string;
name: string;
kind: string;
}>;
type BufferSource = ArrayBufferView | ArrayBuffer;
/**
* WebAssembly.Module
*/
class Module {
constructor(bufferSource: BufferSource);
static customSections(module: Module, sectionName: string): ArrayBuffer[];
static exports(module: Module): Imports;
static imports(module: Module): Exports;
}
/**
* WebAssembly.Global
*/
interface GlobalDescriptor {
value: 'i32' | 'i64' | 'f32' | 'f64';
mutable?: boolean;
}
class Global {
value: number;
constructor(descriptor: GlobalDescriptor, value?: number);
valueOf(): number;
}
/**
* WebAssembly.Instance
*/
class Instance {
readonly exports: any;
constructor(module: Module, importObject?: any);
}
/**
* WebAssembly.Memory
* Note: A WebAssembly page has a constant size of 65,536 bytes, i.e., 64KiB.
*/
interface MemoryDescriptor {
initial: number;
maximum?: number;
}
class Memory {
readonly buffer: ArrayBuffer;
constructor(memoryDescriptor: MemoryDescriptor);
grow(numPages: number): number;
}
/**
* WebAssembly.Table
*/
interface TableDescriptor {
element: "anyfunc";
initial: number;
maximum?: number;
}
class Table {
readonly length: number;
constructor(tableDescriptor: TableDescriptor);
get(index: number): (args: any[]) => any;
grow(numElements: number): number;
set(index: number, value: (args: any[]) => any): void;
}
/**
* Errors
*/
class CompileError extends Error {
readonly fileName: string;
readonly lineNumber: string;
readonly columnNumber: string;
constructor(message?: string, fileName?: string, lineNumber?: number);
toString(): string;
}
class LinkError extends Error {
readonly fileName: string;
readonly lineNumber: string;
readonly columnNumber: string;
constructor(message?: string, fileName?: string, lineNumber?: number);
toString(): string;
}
class RuntimeError extends Error {
readonly fileName: string;
readonly lineNumber: string;
readonly columnNumber: string;
constructor(message?: string, fileName?: string, lineNumber?: number);
toString(): string;
}
function compile(bufferSource: BufferSource): Promise<Module>;
interface ResultObject {
module: Module;
instance: Instance;
}
function instantiate(bufferSource: BufferSource, importObject?: object): Promise<ResultObject>;
function instantiate(module: Module, importObject?: object): Promise<Instance>;
function validate(bufferSource: BufferSource): boolean;
}

View File

@ -1,23 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webassembly-js-api-tests.ts"
]
}

View File

@ -1,9 +0,0 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODOs
"dt-header": false,
"npm-naming": false,
"no-unnecessary-class": false
}
}

View File

@ -1,79 +0,0 @@
function debug(s: string) {
// debug(s)
}
// Table
let table = new WebAssembly.Table({element: "anyfunc", initial: 1, maximum: 10});
debug(`table.length=${table.length}`);
debug(`table.get(0)=${table.get(0)}`);
table.grow(1);
// Memory
let memory = new WebAssembly.Memory({initial: 2, maximum: 8});
debug(`memory.grow(6)=${memory.grow(6)}`);
let u8 = new Uint8Array(memory.buffer);
u8[0] = 1;
u8[1] = 2;
debug(`u8[0]=${u8[0]}`);
debug(`u8[1]=${u8[1]}`);
let wasmDataU8 = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7]);
debug(`wasmDataU8.length=${wasmDataU8.length}`);
debug(`wasmDataU8[0]=${wasmDataU8[0].toString(16)}`);
debug(`wasmDataU8[1]=${wasmDataU8[1].toString(16)}`);
debug(`wasmDataU8[2]=${wasmDataU8[2].toString(16)}`);
debug(`wasmDataU8[3]=${wasmDataU8[3].toString(16)}`);
debug(`wasmDataU8[4]=${wasmDataU8[4].toString(16)}`);
debug(`wasmDataU8[5]=${wasmDataU8[5].toString(16)}`);
debug(`wasmDataU8[6]=${wasmDataU8[6].toString(16)}`);
debug(`wasmDataU8[7]=${wasmDataU8[7].toString(16)}`);
// Validate
let valid = WebAssembly.validate(wasmDataU8);
debug(`wasmDataU8 is ${valid ? "" : "not "}a valid wasm wasmModule`);
// Module
let wasmModule = new WebAssembly.Module(wasmDataU8);
debug(`wasmModule=${wasmModule}`);
// Global
let wasmGlobal = new WebAssembly.Global({ value: 'i32', mutable: true }, 0);
debug(`wasmGlobal=${wasmGlobal}`);
// CustomSections
let nameSections = WebAssembly.Module.customSections(wasmModule, "name");
debug(`Module contains ${nameSections.length} name sections`);
if (nameSections.length !== 0) {
debug("Module contains a name section");
debug(nameSections[0].toString());
}
// Instance
let instance = new WebAssembly.Instance(wasmModule);
debug(`instance=${instance}`);
debug(`instance.exports=${instance.exports}`);
// Compile Asynchronously
debug("instantiateAsync compile:");
WebAssembly.compile(wasmDataU8).then((mod: WebAssembly.Module) => {
debug(`instantiateAsync compiled: ${JSON.stringify(mod)}`);
});
// Instantiate
// Primary overload — taking wasm binary code
WebAssembly.instantiate(wasmDataU8).then((result: WebAssembly.ResultObject) => {
debug(`Primary overload mod=${result.module}`);
debug(`Primary overload inst=${result.instance}`);
debug(`Primary exec instance.exports.addTwo1(-1, 1)=${result.instance.exports.addTwo1(-1, 1)}`);
});
// Instantiate
// Secondary overload — taking a Module object
WebAssembly.instantiate(wasmModule).then((instance: WebAssembly.Instance) => {
debug(`Secondary overload instance=${instance}`);
debug(`Secondary exec instance.exports.addTwo1(0, -1)=${instance.exports.addTwo1(0, -1)}`);
});
// Validate
WebAssembly.validate(new ArrayBuffer(8));
WebAssembly.validate(wasmDataU8);