diff --git a/types/cookie_js/cookie_js-tests.ts b/types/cookie_js/cookie_js-tests.ts index 51a71f4bab..b7e00f66a1 100644 --- a/types/cookie_js/cookie_js-tests.ts +++ b/types/cookie_js/cookie_js-tests.ts @@ -29,3 +29,23 @@ cookie.removeSpecific(['a', 'b'], {path: '/search'}); cookie.empty(); cookie.all(); + +cookie.utils; +cookie.utils.isArray('a'); +cookie.utils.isArray([]); +cookie.utils.isObject('a'); +cookie.utils.isObject({}); +cookie.utils.toArray({}); +cookie.utils.toArray([]); +cookie.utils.getKeys({}); +cookie.utils.encode('a'); +cookie.utils.decode('a'); +cookie.utils.retrieve('a', 'b'); + +cookie.defaults; +cookie.defaults.expires = 1; +cookie.defaults.expires = new Date; +cookie.defaults.expires = 'Wed, 07 Feb 2018 17:00:26 GMT'; +cookie.defaults.domain = 'example.com'; +cookie.defaults.path = '/foo'; +cookie.defaults.secure = true; diff --git a/types/cookie_js/index.d.ts b/types/cookie_js/index.d.ts index 6e5a0813b6..2f197253d6 100644 --- a/types/cookie_js/index.d.ts +++ b/types/cookie_js/index.d.ts @@ -17,6 +17,23 @@ declare module 'cookiejs' { declare function cookie(key : string, fallback?: string) : string; declare function cookie(keys : string[], fallback?: string) : string; +interface UtilStatic { + isArray: (value: any) => boolean; + isObject: (value: any) => boolean; + toArray: (...args: any[]) => any[]; + getKeys: (value: {}) => any[]; + encode: (value: string) => string; + decode: (value: string) => string; + retrieve: (x: string, y: string) => string; +} + +interface Options { + expires: number | string | Date, + domain: string, + path: string, + secure: boolean, +} + declare namespace cookie { /** * Create a cookie. The value will automatically be escaped. @@ -57,4 +74,12 @@ declare namespace cookie { * Test if cookies are enabled */ export function enabled() : boolean; + /** + * Utility methods + */ + export var utils: UtilStatic; + /** + * Set default options + */ + export var defaults: Options; } diff --git a/types/dat-gui/dat-gui-tests.ts b/types/dat.gui/dat.gui-tests.ts similarity index 100% rename from types/dat-gui/dat-gui-tests.ts rename to types/dat.gui/dat.gui-tests.ts diff --git a/types/dat-gui/index.d.ts b/types/dat.gui/index.d.ts similarity index 100% rename from types/dat-gui/index.d.ts rename to types/dat.gui/index.d.ts diff --git a/types/dat-gui/tsconfig.json b/types/dat.gui/tsconfig.json similarity index 94% rename from types/dat-gui/tsconfig.json rename to types/dat.gui/tsconfig.json index 4961272694..3b5d3231ef 100644 --- a/types/dat-gui/tsconfig.json +++ b/types/dat.gui/tsconfig.json @@ -19,6 +19,6 @@ }, "files": [ "index.d.ts", - "dat-gui-tests.ts" + "dat.gui-tests.ts" ] } \ No newline at end of file diff --git a/types/dat-gui/tslint.json b/types/dat.gui/tslint.json similarity index 100% rename from types/dat-gui/tslint.json rename to types/dat.gui/tslint.json diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 4a3d7d45d1..bb268646be 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -20,6 +20,7 @@ declare module 'ember' { import { Registry as ServiceRegistry } from '@ember/service'; import { Registry as ControllerRegistry } from '@ember/controller'; + import ModuleComputed from '@ember/object/computed'; // Get an alias to the global Array type to use in inner scope below. type GlobalArray = T[]; @@ -27,7 +28,7 @@ declare module 'ember' { /** * Deconstructs computed properties into the types which would be returned by `.get()`. */ - type ComputedProperties = { [K in keyof T]: Ember.ComputedProperty | T[K] }; + type ComputedProperties = { [K in keyof T]: Ember.ComputedProperty | ModuleComputed | T[K] }; /** * Check that any arguments to `create()` match the type's properties. @@ -1523,7 +1524,7 @@ declare module 'ember' { * Remove an object at the specified index using the `replace()` primitive * method. You can pass either a single index, or a start and a length. */ - removeAt(start: number, len: number): this; + removeAt(start: number, len?: number): this; /** * Push the object onto the end of the array. Works just like `push()` but it * is KVO-compliant. diff --git a/types/ember/test/computed.ts b/types/ember/test/computed.ts index c812ef62b3..f93b07a0f5 100755 --- a/types/ember/test/computed.ts +++ b/types/ember/test/computed.ts @@ -1,6 +1,6 @@ import Ember from 'ember'; import Component from '@ember/component'; -import { or } from '@ember/object/computed'; +import Computed, { alias, or } from '@ember/object/computed'; import { assertType } from './lib/assert'; const Person = Ember.Object.extend({ @@ -50,7 +50,9 @@ const Person = Ember.Object.extend({ }).property('firstName') .meta({ foo: 'bar' }) .volatile() - .readOnly() + .readOnly(), + + explicitlyDeclared: alias('fullName') as Computed, }); const person = Person.create({ @@ -68,6 +70,7 @@ assertType>(person.fullNameWritable); assertType>(person.fullNameGetOnly); assertType>(person.fullNameSetOnly); assertType>(person.combinators); +assertType>(person.explicitlyDeclared); assertType(person.get('firstName')); assertType(person.get('age')); @@ -78,6 +81,7 @@ assertType(person.get('fullNameWritable')); assertType(person.get('fullNameGetOnly')); assertType(person.get('fullNameSetOnly')); assertType(person.get('combinators')); +assertType(person.get('explicitlyDeclared')); assertType<{ firstName: string, fullName: string, age: number }>(person.getProperties('firstName', 'fullName', 'age')); diff --git a/types/expo/expo-tests.tsx b/types/expo/expo-tests.tsx index 79c80aa29d..6a1f17ae3f 100644 --- a/types/expo/expo-tests.tsx +++ b/types/expo/expo-tests.tsx @@ -1,4 +1,5 @@ import * as React from 'react'; +import { Text } from 'react-native'; import { Accelerometer, @@ -12,6 +13,7 @@ import { BlurView, Brightness, Camera, + CameraObject, DocumentPicker, Facebook, FacebookAds, @@ -19,7 +21,13 @@ import { ImagePicker, ImageManipulator, FaceDetector, - Svg + Svg, + IntentLauncherAndroid, + KeepAwake, + LinearGradient, + Permissions, + registerRootComponent, + ScreenOrientation } from 'expo'; Accelerometer.addListener((obj) => { @@ -36,7 +44,7 @@ Amplitude.setUserProperties({key: 1}); Amplitude.clearUserProperties(); Amplitude.logEvent('name'); Amplitude.logEventWithProperties('event', {key: 'value'}); -Amplitude.setGroup('type', {key: 'value'}); +Amplitude.setGroup('type', ['value']); const asset = Asset.fromModule(1); asset.downloadAsync(); @@ -86,8 +94,83 @@ Audio.setAudioModeAsync({ allowsRecordingIOS: true }); Audio.setIsEnabledAsync(true); + +Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS === 0; +Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX === 1; +Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS === 2; + +Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX === 1; +Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS === 2; + +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_DEFAULT === 0; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP === 1; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4 === 2; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_NB === 3; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_WB === 4; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADIF === 5; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS === 6; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_RTP_AVP === 7; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG2TS === 8; +Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_WEBM === 9; + +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_DEFAULT === 0; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB === 1; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_WB === 2; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC === 3; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC === 4; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC_ELD === 5; +Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_VORBIS === 6; + +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_LINEARPCM === 'lpcm'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AC3 === 'ac-3'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_60958AC3 === 'cac3'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLEIMA4 === 'ima4'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC === 'aac '; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4CELP === 'celp'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4HVXC === 'hvxc'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4TWINVQ === 'twvq'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE3 === 'MAC3'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE6 === 'MAC6'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ULAW === 'ulaw'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ALAW === 'alaw'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN === 'QDMC'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN2 === 'QDM2'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QUALCOMM === 'Qclp'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER1 === '.mp1'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER2 === '.mp2'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER3 === '.mp3'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLELOSSLESS === 'alac'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE === 'aach'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_LD === 'aacl'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD === 'aace'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_SBR === 'aacf'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_V2 === 'aacg'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE_V2 === 'aacp'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_SPATIAL === 'aacs'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR === 'samr'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR_WB === 'sawb'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AUDIBLE === 'AUDB'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ILBC === 'ilbc'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_DVIINTELIMA === 0x6d730011; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MICROSOFTGSM === 0x6d730031; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AES3 === 'aes3'; +Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ENHANCEDAC3 === 'ec-3'; + +Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN === 0; +Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_LOW === 0x20; +Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM === 0x40; +Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH === 0x60; +Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX === 0x7f; + +Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_CONSTANT === 0; +Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_LONG_TERM_AVERAGE === 1; +Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE_CONSTRAINED === 2; +Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE === 3; + +Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY; +Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY; async () => { - const result = await Audio.Sound.create('uri', { + const result = await Audio.Sound.create({uri: 'uri'}, { volume: 0.5, rate: 0.6 }, null, true); @@ -103,7 +186,7 @@ async () => { } const _status = await sound.getStatusAsync(); - await sound.loadAsync('uri'); + await sound.loadAsync({uri: 'uri'}); }; () => ( @@ -344,3 +427,124 @@ async () => { ); + +IntentLauncherAndroid.ACTION_ACCESSIBILITY_SETTINGS === 'android.settings.ACCESSIBILITY_SETTINGS'; +IntentLauncherAndroid.ACTION_APP_NOTIFICATION_REDACTION === 'android.settings.ACTION_APP_NOTIFICATION_REDACTION'; +IntentLauncherAndroid.ACTION_CONDITION_PROVIDER_SETTINGS === 'android.settings.ACTION_CONDITION_PROVIDER_SETTINGS'; +IntentLauncherAndroid.ACTION_NOTIFICATION_LISTENER_SETTINGS === 'android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS'; +IntentLauncherAndroid.ACTION_PRINT_SETTINGS === 'android.settings.ACTION_PRINT_SETTINGS'; +IntentLauncherAndroid.ACTION_ADD_ACCOUNT_SETTINGS === 'android.settings.ADD_ACCOUNT_SETTINGS'; +IntentLauncherAndroid.ACTION_AIRPLANE_MODE_SETTINGS === 'android.settings.AIRPLANE_MODE_SETTINGS'; +IntentLauncherAndroid.ACTION_APN_SETTINGS === 'android.settings.APN_SETTINGS'; +IntentLauncherAndroid.ACTION_APPLICATION_DETAILS_SETTINGS === 'android.settings.APPLICATION_DETAILS_SETTINGS'; +IntentLauncherAndroid.ACTION_APPLICATION_DEVELOPMENT_SETTINGS === 'android.settings.APPLICATION_DEVELOPMENT_SETTINGS'; +IntentLauncherAndroid.ACTION_APPLICATION_SETTINGS === 'android.settings.APPLICATION_SETTINGS'; +IntentLauncherAndroid.ACTION_APP_NOTIFICATION_SETTINGS === 'android.settings.APP_NOTIFICATION_SETTINGS'; +IntentLauncherAndroid.ACTION_APP_OPS_SETTINGS === 'android.settings.APP_OPS_SETTINGS'; +IntentLauncherAndroid.ACTION_BATTERY_SAVER_SETTINGS === 'android.settings.BATTERY_SAVER_SETTINGS'; +IntentLauncherAndroid.ACTION_BLUETOOTH_SETTINGS === 'android.settings.BLUETOOTH_SETTINGS'; +IntentLauncherAndroid.ACTION_CAPTIONING_SETTINGS === 'android.settings.CAPTIONING_SETTINGS'; +IntentLauncherAndroid.ACTION_CAST_SETTINGS === 'android.settings.CAST_SETTINGS'; +IntentLauncherAndroid.ACTION_DATA_ROAMING_SETTINGS === 'android.settings.DATA_ROAMING_SETTINGS'; +IntentLauncherAndroid.ACTION_DATE_SETTINGS === 'android.settings.DATE_SETTINGS'; +IntentLauncherAndroid.ACTION_DEVICE_INFO_SETTINGS === 'android.settings.DEVICE_INFO_SETTINGS'; +IntentLauncherAndroid.ACTION_DEVICE_NAME === 'android.settings.DEVICE_NAME'; +IntentLauncherAndroid.ACTION_DISPLAY_SETTINGS === 'android.settings.DISPLAY_SETTINGS'; +IntentLauncherAndroid.ACTION_DREAM_SETTINGS === 'android.settings.DREAM_SETTINGS'; +IntentLauncherAndroid.ACTION_HARD_KEYBOARD_SETTINGS === 'android.settings.HARD_KEYBOARD_SETTINGS'; +IntentLauncherAndroid.ACTION_HOME_SETTINGS === 'android.settings.HOME_SETTINGS'; +IntentLauncherAndroid.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS === 'android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS'; +IntentLauncherAndroid.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS === 'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS'; +IntentLauncherAndroid.ACTION_INPUT_METHOD_SETTINGS === 'android.settings.INPUT_METHOD_SETTINGS'; +IntentLauncherAndroid.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS === 'android.settings.INPUT_METHOD_SUBTYPE_SETTINGS'; +IntentLauncherAndroid.ACTION_INTERNAL_STORAGE_SETTINGS === 'android.settings.INTERNAL_STORAGE_SETTINGS'; +IntentLauncherAndroid.ACTION_LOCALE_SETTINGS === 'android.settings.LOCALE_SETTINGS'; +IntentLauncherAndroid.ACTION_LOCATION_SOURCE_SETTINGS === 'android.settings.LOCATION_SOURCE_SETTINGS'; +IntentLauncherAndroid.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS === 'android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS'; +IntentLauncherAndroid.ACTION_MANAGE_APPLICATIONS_SETTINGS === 'android.settings.MANAGE_APPLICATIONS_SETTINGS'; +IntentLauncherAndroid.ACTION_MANAGE_DEFAULT_APPS_SETTINGS === 'android.settings.MANAGE_DEFAULT_APPS_SETTINGS'; +IntentLauncherAndroid.ACTION_MEMORY_CARD_SETTINGS === 'android.settings.MEMORY_CARD_SETTINGS'; +IntentLauncherAndroid.ACTION_MONITORING_CERT_INFO === 'android.settings.MONITORING_CERT_INFO'; +IntentLauncherAndroid.ACTION_NETWORK_OPERATOR_SETTINGS === 'android.settings.NETWORK_OPERATOR_SETTINGS'; +IntentLauncherAndroid.ACTION_NFCSHARING_SETTINGS === 'android.settings.NFCSHARING_SETTINGS'; +IntentLauncherAndroid.ACTION_NFC_PAYMENT_SETTINGS === 'android.settings.NFC_PAYMENT_SETTINGS'; +IntentLauncherAndroid.ACTION_NFC_SETTINGS === 'android.settings.NFC_SETTINGS'; +IntentLauncherAndroid.ACTION_NIGHT_DISPLAY_SETTINGS === 'android.settings.NIGHT_DISPLAY_SETTINGS'; +IntentLauncherAndroid.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS === 'android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS'; +IntentLauncherAndroid.ACTION_NOTIFICATION_SETTINGS === 'android.settings.NOTIFICATION_SETTINGS'; +IntentLauncherAndroid.ACTION_PAIRING_SETTINGS === 'android.settings.PAIRING_SETTINGS'; +IntentLauncherAndroid.ACTION_PRIVACY_SETTINGS === 'android.settings.PRIVACY_SETTINGS'; +IntentLauncherAndroid.ACTION_QUICK_LAUNCH_SETTINGS === 'android.settings.QUICK_LAUNCH_SETTINGS'; +IntentLauncherAndroid.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS === 'android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS'; +IntentLauncherAndroid.ACTION_SECURITY_SETTINGS === 'android.settings.SECURITY_SETTINGS'; +IntentLauncherAndroid.ACTION_SETTINGS === 'android.settings.SETTINGS'; +IntentLauncherAndroid.ACTION_SHOW_ADMIN_SUPPORT_DETAILS === 'android.settings.SHOW_ADMIN_SUPPORT_DETAILS'; +IntentLauncherAndroid.ACTION_SHOW_INPUT_METHOD_PICKER === 'android.settings.SHOW_INPUT_METHOD_PICKER'; +IntentLauncherAndroid.ACTION_SHOW_REGULATORY_INFO === 'android.settings.SHOW_REGULATORY_INFO'; +IntentLauncherAndroid.ACTION_SHOW_REMOTE_BUGREPORT_DIALOG === 'android.settings.SHOW_REMOTE_BUGREPORT_DIALOG'; +IntentLauncherAndroid.ACTION_SOUND_SETTINGS === 'android.settings.SOUND_SETTINGS'; +IntentLauncherAndroid.ACTION_STORAGE_MANAGER_SETTINGS === 'android.settings.STORAGE_MANAGER_SETTINGS'; +IntentLauncherAndroid.ACTION_SYNC_SETTINGS === 'android.settings.SYNC_SETTINGS'; +IntentLauncherAndroid.ACTION_SYSTEM_UPDATE_SETTINGS === 'android.settings.SYSTEM_UPDATE_SETTINGS'; +IntentLauncherAndroid.ACTION_TETHER_PROVISIONING_UI === 'android.settings.TETHER_PROVISIONING_UI'; +IntentLauncherAndroid.ACTION_TRUSTED_CREDENTIALS_USER === 'android.settings.TRUSTED_CREDENTIALS_USER'; +IntentLauncherAndroid.ACTION_USAGE_ACCESS_SETTINGS === 'android.settings.USAGE_ACCESS_SETTINGS'; +IntentLauncherAndroid.ACTION_USER_DICTIONARY_INSERT === 'android.settings.USER_DICTIONARY_INSERT'; +IntentLauncherAndroid.ACTION_USER_DICTIONARY_SETTINGS === 'android.settings.USER_DICTIONARY_SETTINGS'; +IntentLauncherAndroid.ACTION_USER_SETTINGS === 'android.settings.USER_SETTINGS'; +IntentLauncherAndroid.ACTION_VOICE_CONTROL_AIRPLANE_MODE === 'android.settings.VOICE_CONTROL_AIRPLANE_MODE'; +IntentLauncherAndroid.ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE === 'android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE'; +IntentLauncherAndroid.ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE === 'android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE'; +IntentLauncherAndroid.ACTION_VOICE_INPUT_SETTINGS === 'android.settings.VOICE_INPUT_SETTINGS'; +IntentLauncherAndroid.ACTION_VPN_SETTINGS === 'android.settings.VPN_SETTINGS'; +IntentLauncherAndroid.ACTION_VR_LISTENER_SETTINGS === 'android.settings.VR_LISTENER_SETTINGS'; +IntentLauncherAndroid.ACTION_WEBVIEW_SETTINGS === 'android.settings.WEBVIEW_SETTINGS'; +IntentLauncherAndroid.ACTION_WIFI_IP_SETTINGS === 'android.settings.WIFI_IP_SETTINGS'; +IntentLauncherAndroid.ACTION_WIFI_SETTINGS === 'android.settings.WIFI_SETTINGS'; +IntentLauncherAndroid.ACTION_WIRELESS_SETTINGS === 'android.settings.WIRELESS_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_AUTOMATION_SETTINGS === 'android.settings.ZEN_MODE_AUTOMATION_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_EVENT_RULE_SETTINGS === 'android.settings.ZEN_MODE_EVENT_RULE_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS === 'android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_PRIORITY_SETTINGS === 'android.settings.ZEN_MODE_PRIORITY_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS === 'android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS'; +IntentLauncherAndroid.ACTION_ZEN_MODE_SETTINGS === 'android.settings.ZEN_MODE_SETTINGS'; + +KeepAwake.activate(); +KeepAwake.deactivate(); + +() => ( + +); + +Permissions.CAMERA === 'camera'; +Permissions.CAMERA_ROLL === 'cameraRoll'; +Permissions.AUDIO_RECORDING === 'audioRecording'; +Permissions.CONTACTS === 'contacts'; +Permissions.NOTIFICATIONS === 'remoteNotifications'; +Permissions.REMOTE_NOTIFICATIONS === 'remoteNotifications'; +Permissions.SYSTEM_BRIGHTNESS === 'systemBrightness'; +async () => { + const result = await Permissions.askAsync(Permissions.CAMERA); + + result.status === 'granted'; + result.status === 'denied'; + result.status === 'undetermined'; + + result.expires === 'never'; +}; + +ScreenOrientation.Orientation.ALL; +ScreenOrientation.allow(ScreenOrientation.Orientation.ALL); + +class __TestEntry__ extends React.Component { + render() { + return( + test + ); + } +} +registerRootComponent(__TestEntry__); diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 9a583b830c..ae7e45841d 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -2,36 +2,37 @@ // Project: https://github.com/expo/expo-sdk // Definitions by: Konstantin Kai // Martynas Kadiša +// Jan Aagaard // Sergio Sánchez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 import { EventSubscription } from 'fbemitter'; -import { Component, ComponentClass, Ref } from 'react'; +import { Component, ComponentClass, Ref, ComponentType } from 'react'; import { - ViewStyle, - ViewProperties, ColorPropType, + ImageRequireSource, ImageURISource, NativeEventEmitter, - ImageRequireSource + ViewProperties, + ViewStyle, + Permission } from 'react-native'; -export type URISource = ImageURISource; +export type Axis = number; +export type BarCodeReadCallback = (params: { type: string; data: string; }) => void; +export type FloatFromZeroToOne = 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1; +export type Md5 = string; +export type Orientation = 'portrait' | 'landscape'; export type RequireSource = ImageRequireSource; export type ResizeModeContain = 'contain'; export type ResizeModeCover = 'cover'; export type ResizeModeStretch = 'stretch'; -export type Orientation = 'portrait' | 'landscape'; -export type Axis = number; -export interface HashMap { [key: string]: any; } -export type FloatFromZeroToOne = 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1; -export type BarCodeReadCallback = (params: { type: string; data: string; }) => void; -export type Md5 = string; +export type URISource = ImageURISource; -/** - * Accelerometer - */ +export interface HashMap { [key: string]: any; } + +/** Access the device accelerometer sensor(s) to respond to changes in acceleration in 3d space. */ export namespace Accelerometer { interface AccelerometerObject { x: Axis; @@ -39,27 +40,88 @@ export namespace Accelerometer { z: Axis; } + /** + * Subscribe for updates to the accelerometer. + * @param listener A callback that is invoked when an accelerometer update is available. When invoked, the listener is provided a single argumument that is an object containing keys x, y, z. + * @returns An EventSubscription object that you can call remove() on when you would like to unsubscribe the listener. + */ function addListener(listener: (obj: AccelerometerObject) => any): EventSubscription; + + /** Remove all listeners. */ function removeAllListeners(): void; + + /** + * Subscribe for updates to the accelerometer. + * @param intervalMs Desired interval in milliseconds between accelerometer updates. + */ function setUpdateInterval(intervalMs: number): void; } /** - * Amplitude + * Provides access to Amplitude mobile analytics which basically lets you log various events to the Cloud. This module wraps Amplitude’s iOS and Android SDKs. + * + * Note: Session tracking may not work correctly when running Experiences in the main Expo app. It will work correctly if you create a standalone app. */ export namespace Amplitude { + /** Initializes Amplitude with your Amplitude API key. */ function initialize(apiKey: string): void; + + /** Assign a user ID to the current user. If you don’t have a system for user IDs you don’t need to call this. */ function setUserId(userId: string): void; + + /** Set properties for the current user. */ function setUserProperties(userProperties: HashMap): void; + + /** Clear properties set by `setUserProperties()`. */ function clearUserProperties(): void; + + /** Log an event to Amplitude. */ function logEvent(eventName: string): void; - function logEventWithProperties(eventName: string, properties: HashMap): void; - function setGroup(groupType: string, groupNames: HashMap): void; + + /** Log an event to Amplitude with custom properties. */ + function logEventWithProperties( + eventName: string, + + /** A map of custom properties. */ + properties: HashMap + ): void; + + /** Add the current user to a group. */ + function setGroup( + /** The group name, e.g. `'sports'`. */ + groupType: string, + + /** An array of group names, e.g. `['tennis', 'soccer']`. */ + groupNames: string[] + ): void; } +// #region AppLoading +/** The following props are recommended, but optional for the sake of backwards compatibility (they were introduced in SDK21). If you do not provide any props, you are responsible for coordinating loading assets, handling errors, and updating state to unmount the `AppLoading` component. */ +export type AppLoadingProps = { + /** A `function` that returns a `Promise`. The `Promise` should resolve when the app is done loading data and assets. */ + startAsync: () => Promise; + + /** Required if you provide `startAsync`. Called when `startAsync` resolves or rejects. This should be used to set state and unmount the `AppLoading` component. */ + onFinish: () => void; + + /** If `startAsync` throws an error, it is caught and passed into the function provided to `onError`. */ + onError?: (error: Error) => void; +} | { + startAsync: null; + onFinish: null; + onError?: null; +}; + /** - * Asset + * A React component that tells Expo to keep the app loading screen open if it is the first and only component rendered in your app. When it is removed, the loading screen will disappear and your app will be visible. + * + * This is incredibly useful to let you download and cache fonts, logo and icon images and other assets that you want to be sure the user has on their device for an optimal experience before rendering they start using the app. */ +export class AppLoading extends Component { } +// #endregion AppLoading + +/** This module provides an interface to Expo’s asset system. An asset is any file that lives alongside the source code of your app that the app needs at runtime. Examples include images, fonts and sounds. Expo’s asset system integrates with React Native’s, so that you can refer to files with require('path/to/file'). This is how you refer to static image files in React Native for use in an Image component, for example. */ export class Asset { constructor({ name, type, hash, uri, width, height }: { name: string; @@ -69,116 +131,142 @@ export class Asset { width?: number; height?: number; }); + + /** The MD5 hash of the asset’s data. */ + hash: Md5; + + /** The name of the asset file without the extension. Also without the part from @ onward in the filename (used to specify scale factor for images). */ name: string; + + /** The extension of the asset filename. */ type: string; - hash: string; + + /** A URI that points to the asset’s data on the remote server. When running the published version of your app, this refers to the the location on Expo’s asset server where Expo has stored your asset. When running the app from XDE during development, this URI points to XDE’s server running on your computer and the asset is served directly from your computer. */ uri: string; + + /** If the asset has been downloaded (by calling `downloadAsync()`), the `file://` URI pointing to the local file on the device that contains the asset data. */ localUri: string; + + /** If the asset is an image, the width of the image data divided by the scale factor. The scale factor is the number after `@` in the filename, or `1` if not present. */ width?: number; + + /** If the asset is an image, the height of the image data divided by the scale factor. The scale factor is the number after `@` in the filename, or `1` if not present. */ height?: number; downloading: boolean; downloaded: boolean; downloadCallbacks: Array<{ resolve: () => any, reject: (e?: any) => any }>; + /** Downloads the asset data to a local file in the device’s cache directory. Once the returned promise is fulfilled without error, the localUri field of this asset points to a local file containing the asset data. The asset is only downloaded if an up-to-date local file for the asset isn’t already present due to an earlier download. */ downloadAsync(): Promise; + /** Returns the `Expo.Asset` instance representing an asset given its module. */ static fromModule(module: RequireSource): Asset; + + /** + * A helper that wraps `Expo.Asset.fromModule(module).downloadAsync` for convenience. + * @param moduleIds An array of `require('path/to/file')`. Can also be just one module without an Array. + */ static loadAsync(module: RequireSource[] | RequireSource): Promise; } /** - * AuthSession + * Provides basic sample playback and recording. + * + * Note that Expo does not yet support backgrounding, so audio is not available to play in the background of your experience. Audio also automatically stops if headphones / bluetooth audio devices are disconnected. */ -export namespace AuthSession { - function startAsync(options: { authUrl: string; returnUrl?: string; }): Promise<{ - type: 'cancel'; - } | { - type: 'dismissed'; - } | { - type: 'success'; - params: HashMap; - event: HashMap; - } | { - type: 'error'; - params: HashMap; - errorCode: string; - event: HashMap; - }>; - function dismiss(): void; - function getRedirectUrl(): string; -} - -/** - * AV - */ -export type PlaybackStatus = { - isLoaded: false; - androidImplementation?: string; - error?: string; -} | { - isLoaded: true; - androidImplementation?: string; - uri: string; - progressUpdateIntervalMillis: number; - durationMillis?: number; - positionMillis: number; - playableDurationMillis?: number; - shouldPlay: boolean; - isPlaying: boolean; - isBuffering: boolean; - rate: number; - shouldCorrectPitch: boolean; - volume: number; - isMuted: boolean; - isLooping: boolean; - didJustFinish: boolean; -}; - -export interface PlaybackStatusToSet { - androidImplementation?: string; - progressUpdateIntervalMillis?: number; - positionMillis?: number; - shouldPlay?: boolean; - rate?: FloatFromZeroToOne; - shouldCorrectPitch?: boolean; - volume?: FloatFromZeroToOne; - isMuted?: boolean; - isLooping?: boolean; -} - -export type Source = string | RequireSource | Asset; - -export class PlaybackObject { - loadAsync(source: Source, initialStatus?: PlaybackStatusToSet, downloadFirst?: boolean): Promise; - unloadAsync(): Promise; - getStatusAsync(): Promise; - setOnPlaybackStatusUpdate(onPlaybackStatusUpdate: (status: PlaybackStatus) => void): void; - setStatusAsync(status: PlaybackStatusToSet): Promise; - playAsync(): Promise; - playFromPositionAsync(positionMillis: number): Promise; - pauseAsync(): Promise; - stopAsync(): Promise; - setPositionAsync(positionMillis: number): Promise; - setRateAsync(rate: number, shouldCorrectPitch: boolean): Promise; - setVolumeAsync(volume: number): Promise; - setIsMutedAsync(isMuted: boolean): Promise; - setIsLoopingAsync(isLooping: boolean): Promise; - setProgressUpdateIntervalAsync(progressUpdateIntervalMillis: number): Promise; -} - export namespace Audio { - enum InterruptionModeIOS { + enum InterruptionModeIos { + /** This is the default option. If this option is set, your experience’s audio is mixed with audio playing in background apps. */ INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS = 0, + + /** If this option is set, your experience’s audio interrupts audio from other apps. */ INTERRUPTION_MODE_IOS_DO_NOT_MIX = 1, + + /** If this option is set, your experience’s audio lowers the volume ("ducks") of audio from other apps while your audio plays. */ INTERRUPTION_MODE_IOS_DUCK_OTHERS = 2 } + const INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS: 0; + const INTERRUPTION_MODE_IOS_DO_NOT_MIX: 1; + const INTERRUPTION_MODE_IOS_DUCK_OTHERS: 2; + enum InterruptionModeAndroid { + /** If this option is set, your experience’s audio interrupts audio from other apps. */ INTERRUPTION_MODE_ANDROID_DO_NOT_MIX = 1, + + /** This is the default option. If this option is set, your experience’s audio lowers the volume ("ducks") of audio from other apps while your audio plays. */ INTERRUPTION_MODE_ANDROID_DUCK_OTHERS = 2 } + const INTERRUPTION_MODE_ANDROID_DO_NOT_MIX: 1; + const INTERRUPTION_MODE_ANDROID_DUCK_OTHERS: 2; + + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_DEFAULT: 0; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP: 1; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4: 2; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_NB: 3; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_WB: 4; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADIF: 5; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS: 6; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_RTP_AVP: 7; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG2TS: 8; + const RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_WEBM: 9; + + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_DEFAULT: 0; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB: 1; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_WB: 2; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC: 3; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC: 4; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC_ELD: 5; + const RECORDING_OPTION_ANDROID_AUDIO_ENCODER_VORBIS: 6; + + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_LINEARPCM: 'lpcm'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AC3: 'ac-3'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_60958AC3: 'cac3'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLEIMA4: 'ima4'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC: 'aac '; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4CELP: 'celp'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4HVXC: 'hvxc'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4TWINVQ: 'twvq'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE3: 'MAC3'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE6: 'MAC6'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ULAW: 'ulaw'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ALAW: 'alaw'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN: 'QDMC'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN2: 'QDM2'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_QUALCOMM: 'Qclp'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER1: '.mp1'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER2: '.mp2'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER3: '.mp3'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLELOSSLESS: 'alac'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE: 'aach'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_LD: 'aacl'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD: 'aace'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_SBR: 'aacf'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_V2: 'aacg'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE_V2: 'aacp'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_SPATIAL: 'aacs'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR: 'samr'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR_WB: 'sawb'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AUDIBLE: 'AUDB'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ILBC: 'ilbc'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_DVIINTELIMA: 0x6d730011; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_MICROSOFTGSM: 0x6d730031; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_AES3: 'aes3'; + const RECORDING_OPTION_IOS_OUTPUT_FORMAT_ENHANCEDAC3: 'ec-3'; + + const RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN: 0; + const RECORDING_OPTION_IOS_AUDIO_QUALITY_LOW: 0x20; + const RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM: 0x40; + const RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH: 0x60; + const RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX: 0x7f; + + const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_CONSTANT: 0; + const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_LONG_TERM_AVERAGE: 1; + const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE_CONSTRAINED: 2; + const RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE: 3; + type RecordingStatus = { canRecord: false, isDoneRecording: false @@ -192,27 +280,8 @@ export namespace Audio { durationMillis: number }; - interface AudioMode { - playsInSilentModeIOS: boolean; - allowsRecordingIOS: boolean; - interruptionModeIOS: InterruptionModeIOS; - shouldDuckAndroid: boolean; - interruptionModeAndroid: InterruptionModeAndroid; - } - - function setIsEnabledAsync(value: boolean): Promise; - function setAudioModeAsync(mode: AudioMode): Promise; - - class Sound extends PlaybackObject { - constructor(); - - static create( - source: Source, - initialStatus?: PlaybackStatusToSet, - onPlaybackStatusUpdate?: ((status: PlaybackStatus) => void) | null, - downloadFirst?: boolean - ): Promise<{ sound: Sound, status: PlaybackStatus }>; - } + const RECORDING_OPTIONS_PRESET_HIGH_QUALITY: RecordingOptions; + const RECORDING_OPTIONS_PRESET_LOW_QUALITY: RecordingOptions; interface RecordingOptions { android: { @@ -239,110 +308,320 @@ export namespace Audio { }; } + interface AudioMode { + /** Boolean selecting if your experience’s audio should play in silent mode on iOS. This value defaults to `false`. */ + playsInSilentModeIOS: boolean; + + /** Boolean selecting if recording is enabled on iOS. This value defaults to `false`. NOTE: when this flag is set to true, playback may be routed to the phone receiver instead of to the speaker. */ + allowsRecordingIOS: boolean; + + /** Enum selecting how your experience’s audio should interact with the audio from other apps on iOS. */ + interruptionModeIOS: InterruptionModeIos; + + /** Boolean selecting if your experience’s audio should automatically be lowered in volume ("duck") if audio from another app interrupts your experience. This value defaults to true. If false, audio from other apps will pause your audio. */ + shouldDuckAndroid: boolean; + + /** an enum selecting how your experience’s audio should interact with the audio from other apps on Android: */ + interruptionModeAndroid: InterruptionModeAndroid; + } + + function setIsEnabledAsync(value: boolean): Promise; + function setAudioModeAsync(mode: AudioMode): Promise; + + /** This class represents a sound corresponding to an Asset or URL. */ + class Sound extends PlaybackObject { + constructor(); + + /** + * Creates and loads a sound from source, with optional `initialStatus`, `onPlaybackStatusUpdate`, and `downloadFirst`. + * + * @returns A `Promise` that is rejected if creation failed, or fulfilled with the following dictionary if creation succeeded: + * - `sound`: The newly created and loaded Sound object. + * - `status`: The PlaybackStatus of the Sound object. See the AV documentation for further information. + */ + static create( + /** + * The source of the sound. The following forms are supported: + * + * - A dictionary of the form `{ uri: 'http://path/to/file' }` with a network URL pointing to an audio file on the web. + * - `require('path/to/file')` for an audio file asset in the source code directory. + * - An `Expo.Asset` object for an audio file asset. + */ + source: PlaybackSource, + + /** The initial intended PlaybackStatusToSet of the sound, whose values will override the default initial playback status. This value defaults to `{}` if no parameter is passed. */ + initialStatus?: PlaybackStatusToSet, + + /** A function taking a single parameter PlaybackStatus. This value defaults to `null` if no parameter is passed. */ + onPlaybackStatusUpdate?: ((status: PlaybackStatus) => void) | null, + + /** If set to true, the system will attempt to download the resource to the device before loading. This value defaults to `true`. Note that at the moment, this will only work for `source`s of the form `require('path/to/file')` or `Asset` objects. */ + downloadFirst?: boolean + ): Promise<{ sound: Sound, status: PlaybackStatus }>; + } + class Recording { constructor(); + /** Gets the `status` of the `Recording`. */ getStatusAsync(): Promise; - setOnRecordingStatusUpdate(onRecordingStatusUpdate: (status: RecordingStatus) => void): void; - setProgressUpdateInterval(miliss: number): void; - prepareToRecordAsync(options: Recording): Promise; - isPreparedToRecord(): boolean; + + /** Sets a function to be called regularly with the `status` of the `Recording`. */ + setOnRecordingStatusUpdate(onRecordingStatusUpdate?: (status: RecordingStatus) => void): void; + + /** Sets the interval with which onRecordingStatusUpdate is called while the recording can record. This value defaults to 500 milliseconds. */ + setProgressUpdateInterval(progressUpdateIntervalMillis: number): void; + + /** Loads the recorder into memory and prepares it for recording. This must be called before calling `startAsync()`. This method can only be called if the `Recording` instance has never yet been prepared. */ + prepareToRecordAsync( + /** Options for the recording, including sample rate, bitrate, channels, format, encoder, and extension. If no options are passed to `prepareToRecordAsync()`, the recorder will be created with options `Expo.Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY`. */ + options?: RecordingOptions + ): Promise; + + /** Begins recording. This method can only be called if the `Recording` has been prepared. */ startAsync(): Promise; + + /** + * Pauses recording. This method can only be called if the Recording has been prepared. + * + * NOTE: This is only available on Android API version 24 and later. + */ pauseAsync(): Promise; + + /** Stops the recording and deallocates the recorder from memory. This reverts the Recording instance to an unprepared state, and another Recording instance must be created in order to record again. This method can only be called if the `Recording` has been prepared. */ stopAndUnloadAsync(): Promise; - getURI(): string | undefined; - createNewLoadedSound(initialStatus: PlaybackStatusToSet, onPlaybackStatusUpdate: (status: PlaybackStatus) => void): Promise<{ sound: Sound, status: PlaybackStatus }>; + + /** + * Gets the local URI of the Recording. Note that this will only succeed once the Recording is prepared to record. + * + * @returns A string with the local URI of the `Recording`, or `null` if the `Recording` is not prepared to record. + */ + getURI(): string | null | undefined; + + /** + * Creates and loads a new `Sound` object to play back the `Recording`. Note that this will only succeed once the `Recording` is done recording (once `stopAndUnloadAsync()` has been called). + * + * @returns A Promise that is rejected if creation failed, or fulfilled with the following dictionary if creation succeeded: + * - `sound`: the newly created and loaded Sound object. + * - `status`: the PlaybackStatus of the Sound object. + */ + createNewLoadedSound( + /** The initial intended `PlaybackStatusToSet` of the sound, whose values will override the default initial playback status. This value defaults to `{}` if no parameter is passed. */ + initialStatus?: PlaybackStatusToSet, + + /** A function taking a single parameter `PlaybackStatus`. This value defaults to `null` if no parameter is passed. */ + onPlaybackStatusUpdate?: ((status: PlaybackStatus) => void) | null + ): Promise<{ sound: Sound, status: PlaybackStatus }>; } } /** - * Expo Video + * AuthSession */ -export interface NaturalSize { - width: number; - height: number; - orientation: Orientation; +export namespace AuthSession { + type StartAsyncResponse = { + type: 'cancel'; + } | { + type: 'dismissed'; + } | { + type: 'success'; + params: HashMap; + event: HashMap; + } | { + type: 'error'; + params: HashMap; + errorCode: string; + event: HashMap; + }; + + function startAsync(options: { authUrl: string; returnUrl?: string; }): Promise; + function dismiss(): void; + function getRedirectUrl(): string; } -export interface ReadyForDisplayEvent { - naturalSize: NaturalSize; - status: PlaybackStatus; -} +// #region AV +/** + * AV + */ +export type PlaybackStatus = { + isLoaded: false; + androidImplementation?: string; -export enum FullscreenUpdateVariants { - IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = 0, - IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = 1, - IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = 2, - IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = 3 -} + /** Populated exactly once when an error forces the object to unload. */ + error?: string; +} | { + isLoaded: true; + androidImplementation?: string; + uri: string; + progressUpdateIntervalMillis: number; + durationMillis?: number; + positionMillis: number; + playableDurationMillis?: number; + shouldPlay: boolean; + isPlaying: boolean; + isBuffering: boolean; + rate: number; + shouldCorrectPitch: boolean; + volume: number; + isMuted: boolean; + isLooping: boolean; -export interface FullscreenUpdateEvent { - fullscreenUpdate: FullscreenUpdateVariants; - status: PlaybackStatus; -} + /** True exactly once when the track plays to finish. */ + didJustFinish: boolean; +}; -export interface VideoProps { - source?: Source | null; - posterSource?: URISource | RequireSource; - - resizeMode?: ResizeModeContain | ResizeModeCover | ResizeModeStretch; - useNativeControls?: boolean; - usePoster?: boolean; - - onPlaybackStatusUpdate?: (status: PlaybackStatus) => void; - onReadyForDisplay?: (event: ReadyForDisplayEvent) => void; - onIOSFullscreenUpdate?: (event: FullscreenUpdateEvent) => void; - - onLoadStart?: () => void; - onLoad?: (status: PlaybackStatus) => void; - onError?: (error: string) => void; - - status?: PlaybackStatusToSet; +export interface PlaybackStatusToSet { + androidImplementation?: string; progressUpdateIntervalMillis?: number; positionMillis?: number; shouldPlay?: boolean; - rate?: number; + rate?: FloatFromZeroToOne; shouldCorrectPitch?: boolean; - volume?: number; + volume?: FloatFromZeroToOne; isMuted?: boolean; isLooping?: boolean; - - scaleX?: number; - scaleY?: number; - translateX?: number; - translateY?: number; - rotation?: number; - ref?: Ref; } -export interface VideoState { - showPoster: boolean; +export type PlaybackSource = RequireSource | { uri: string } | Asset; + +export class PlaybackObject { + /** + * Gets the `PlaybackStatus` of the `playbackObject`. + * + * Returns a `Promise` that is fulfilled with the `PlaybackStatus` of the `playbackObject`. + */ + getStatusAsync(): Promise; + + /** + * Loads the media from source into memory and prepares it for playing. This must be called before calling setStatusAsync() or any of the convenience set status methods. This method can only be called if the playbackObject is in an unloaded state. + * + * Returns a `Promise` that is fulfilled with the `PlaybackStatus` of the `playbackObject` once it is loaded, or rejects if loading failed. The `Promise` will also reject if the `playbackObject` was already loaded. See below for details on `PlaybackStatus`. + */ + loadAsync( + /** + * The source of the media. The following forms are supported: + * - A dictionary of the form `{ uri: 'http://path/to/file' }` with a network URL pointing to a media file on the web. + * - `require('path/to/file')` for a media file asset in the source code directory. + * - An `Expo.Asset object` for a media file asset. + */ + source: PlaybackSource, + + /** The initial intended `PlaybackStatusToSet` of the `playbackObject`, whose values will override the default initial playback status. This value defaults to `{}` if no parameter is passed. See below for details on `PlaybackStatusToSet` and the default initial playback status. */ + initialStatus?: PlaybackStatusToSet, + + /** If set to `true`, the system will attempt to download the resource to the device before loading. This value defaults to true. Note that at the moment, this will only work for sources of the form `require('path/to/file')` or `Expo.Asset` objects. */ + downloadFirst?: boolean + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ shouldPlay: false })`. */ + pauseAsync(): Promise; + + /** + * This is equivalent to `playbackObject.setStatusAsync({ shouldPlay: true })`. + * + * Playback may not start immediately after calling this function for reasons such as buffering. Make sure to update your UI based on the `isPlaying` and `isBuffering` properties of the `PlaybackStatus`. + */ + playAsync(): Promise; + + /** + * This is equivalent to `playbackObject.setStatusAsync({ shouldPlay: true, positionMillis: millis })`. + * + * Playback may not start immediately after calling this function for reasons such as buffering. Make sure to update your UI based on the isPlaying and `isBuffering` properties of the `PlaybackStatus`. + */ + playFromPositionAsync( + /** The desired position of playback in milliseconds. */ + positionMillis: number, + + /** This is equivalent to `playbackObject.setStatusAsync({ positionMillis: millis, seekMillisToleranceBefore: toleranceMillisBefore, seekMillisToleranceAfter: toleranceMillisAfter })`. The tolerances are used only on iOS. */ + tolerances?: { + toleranceMillisBefore: number, + toleranceMillisAfter: number + } + ): Promise; + + /** + * Replays the item. When using `playFromPositionAsync(0)` the item is seeked to the position at `0` ms. On iOS this method uses internal implementation of the player and is able to play the item from the beginning immediately. + * + * Returns a `Promise` that is fulfilled with the `PlaybackStatus` of the `playbackObject` once the new status has been set successfully, or rejects if setting the new status failed. + */ + replayAsync( + /** The new `PlaybackStatusToSet` of the `playbackObject`, whose values will override the current playback status. */ + status: PlaybackStatusToSet + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ isLooping: value })`. */ + setIsLoopingAsync( + /** A boolean describing if the media should play once (`false`) or loop indefinitely (`true`). */ + isLooping: boolean + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ isMuted: value })`. */ + setIsMutedAsync( + /** A boolean describing if the audio of this media should be muted. */ + isMuted: boolean + ): Promise; + + /** + * Sets a function to be called regularly with the `PlaybackStatus` of the `playbackObject`. See below for details on `PlaybackStatus` and an example use case of this function. + * + * `onPlaybackStatusUpdate` will be called whenever a call to the API for this `playbackObject` completes (such as `setStatusAsync()`, `getStatusAsync()`, or `unloadAsync()`), and will also be called at regular intervals while the media is in the loaded state. Set `progressUpdateIntervalMillis` via `setStatusAsync()` or `setProgressUpdateIntervalAsync()` to modify the interval with which `onPlaybackStatusUpdate` is called while loaded. + */ + setOnPlaybackStatusUpdate( + /** A function taking a single parameter `PlaybackStatus`. */ + onPlaybackStatusUpdate?: (status: PlaybackStatus) => void + ): void; + + /** This is equivalent to `playbackObject.setStatusAsync({ positionMillis: millis })`. */ + setPositionAsync( + positionMillis: number, + + /** This is equivalent to `playbackObject.setStatusAsync({ positionMillis: millis, seekMillisToleranceBefore: toleranceMillisBefore, seekMillisToleranceAfter: toleranceMillisAfter })`. The tolerances are used only on iOS. */ + tolerances?: { + toleranceMillisBefore: number, + toleranceMillisAfter: number + } + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ progressUpdateIntervalMillis: millis })`. */ + setProgressUpdateIntervalAsync( + /** The new minimum interval in milliseconds between calls of `onPlaybackStatusUpdate`. */ + progressUpdateIntervalMillis: number + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ rate: value, shouldCorrectPitch: shouldCorrectPitch })`. */ + setRateAsync( + /** The desired playback rate of the media. This value must be between `0.0` and `32.0`. Only available on Android API version 23 and later and iOS. */ + rate: number, + + /** A boolean describing if we should correct the pitch for a changed rate. If set to `true`, the pitch of the audio will be corrected (so a rate different than `1.0` will timestretch the audio). */ + shouldCorrectPitch: boolean + ): Promise; + + /** Sets a new `PlaybackStatusToSet` on the `playbackObject`. This method can only be called if the media has been loaded. Return a `Promise` that is fulfilled with the `PlaybackStatus` of the `playbackObject` once the new status has been set successfully, or rejects if setting the new status failed. */ + setStatusAsync( + /** The new `PlaybackStatusToSet` of the `playbackObject`, whose values will override the current playback status. */ + status: PlaybackStatusToSet + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ volume: value })`. */ + setVolumeAsync( + /** A number between `0.0` (silence) and `1.0` (maximum volume). */ + volume: number + ): Promise; + + /** This is equivalent to `playbackObject.setStatusAsync({ shouldPlay: false, positionMillis: 0 })`. */ + stopAsync(): Promise; + + /** + * Unloads the media from memory. `loadAsync()` must be called again in order to be able to play the media. + * + * Returns a `Promise` that is fulfilled with the `PlaybackStatus` of the `playbackObject` once it is unloaded, or rejects if unloading failed. See below for details on `PlaybackStatus`. + */ + unloadAsync(): Promise; } +// #endregion -export class Video extends Component { - static RESIZE_MODE_CONTAIN: ResizeModeContain; - static RESIZE_MODE_COVER: ResizeModeCover; - static RESIZE_MODE_STRETCH: ResizeModeStretch; - static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; - static IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; - static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; - static IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; -} - -/** - * AppLoading - */ -export type AppLoadingProperties = { - startAsync: () => Promise; - onFinish: () => void; - onError?: (error: Error) => void; -} | { - startAsync: null; - onFinish: null; - onError?: null; -}; -export class AppLoading extends Component { } - +// #region BarCodeScanner /** * BarCodeScanner */ @@ -354,7 +633,9 @@ export interface BarCodeScannerProps extends ViewProperties { } export class BarCodeScanner extends Component { } +// #endregion +// #region BlurView /** * BlurView */ @@ -363,6 +644,7 @@ export interface BlurViewProps extends ViewProperties { intensity: number; } export class BlurView extends Component { } +// #endregion /** * Brightness @@ -374,14 +656,14 @@ export namespace Brightness { function setSystemBrightnessAsync(brightnessValue: FloatFromZeroToOne): Promise; } +// #region Camera /** * Camera */ -export interface TakePictureOptions { +export interface PictureOptions { quality?: number; - base64?: boolean; - exif?: boolean; } + export interface PictureResponse { uri: string; width: number; @@ -389,19 +671,21 @@ export interface PictureResponse { exif: string; base64: string; } -export interface RecordOptions { - quality?: string; + +export interface RecordingOptions { + quality?: string | number; maxDuration?: number; maxFileSize?: number; - mute?: boolean; } + export class CameraObject { - takePictureAsync(options: TakePictureOptions): Promise; - recordAsync(options: RecordOptions): Promise<{ uri: string; }>; + takePictureAsync(options: PictureOptions): Promise; + recordAsync(options: RecordingOptions): Promise<{ uri: string; }>; stopRecording(): void; getSupportedRatiosAsync(): Promise; // Android only } -export interface CameraProperties extends ViewProperties { + +export interface CameraProps extends ViewProperties { flashMode?: string | number; type?: string | number; ratio?: string; @@ -415,6 +699,7 @@ export interface CameraProperties extends ViewProperties { onBarCodeRead?: BarCodeReadCallback; ref?: Ref; } + export interface CameraConstants { readonly Type: string; readonly FlashMode: string; @@ -423,9 +708,11 @@ export interface CameraConstants { readonly VideoQuality: string; readonly BarCodeType: string; } -export class Camera extends Component { + +export class Camera extends Component { static readonly Constants: CameraConstants; } +// #endregion /** * Constants @@ -702,6 +989,7 @@ export namespace DocumentPicker { interface Options { type?: string; } + type Response = { type: 'success'; uri: string; @@ -797,6 +1085,75 @@ export namespace FacebookAds { } } +/** + * FaceDetector + */ +export namespace FaceDetector { + interface Point { + x: Axis; + y: Axis; + } + interface FaceFeature { + bounds: { + size: { + width: number; + height: number; + }, + origin: Point; + }; + smilingProbability?: number; + leftEarPosition?: Point; + rightEarPosition?: Point; + leftEyePosition?: Point; + leftEyeOpenProbability?: number; + rightEyePosition?: Point; + rightEyeOpenProbability?: number; + leftCheekPosition?: Point; + rightCheekPosition?: Point; + leftMouthPosition?: Point; + mouthPosition?: Point; + rightMouthPosition?: Point; + bottomMouthPosition?: Point; + noseBasePosition?: Point; + yawAngle?: number; + rollAngle?: number; + } + interface DetectFaceResult { + faces: FaceFeature[]; + image: { + uri: string; + width: number; + height: number; + orientation: number; + }; + } + interface Mode { + fast: 'fast'; + accurate: 'accurate'; + } + interface _Shared { + all: 'all'; + none: 'none'; + } + type Landmarks = _Shared; + type Classifications = _Shared; + interface _Constants { + Mode: Mode; + Landmarks: Landmarks; + Classifications: Classifications; + } + + const Constants: _Constants; + + interface DetectionOptions { + mode?: keyof Mode; + detectLandmarks?: keyof Landmarks; + runClassifications?: keyof Classifications; + } + + function detectFaces(uri: string, options?: DetectionOptions): Promise; +} + /** * FileSystem */ @@ -875,15 +1232,31 @@ export namespace FileSystem { } } -/** - * Fingerprint - */ +/** Use TouchID/FaceID (iOS) or the Fingerprint API (Android) to authenticate the user with a fingerprint scan. */ export namespace Fingerprint { - type FingerprintAuthenticationResult = { success: true } | { success: false, error: string }; + type FingerprintAuthenticationResult = { + success: true + } | { + success: false, + /** Error code in the case where authentication fails. */ + error: string + }; + + /** Determine whether the Fingerprint scanner is available on the device. */ function hasHardwareAsync(): Promise; + + /** Determine whether the device has saved fingerprints to use for authentication. */ function isEnrolledAsync(): Promise; + + /** + * Attempts to authenticate via Fingerprint. Android: When using the fingerprint module on Android, you need to provide a UI component to prompt the user to scan their fingerprint, as the OS has no default alert for it. + * + * @param promptMessage A message that is shown alongside the TouchID/FaceID prompt. (iOS only) + */ function authenticateAsync(promptMessageIOS?: string): Promise; + + /** Cancels the fingerprint authentication flow. (Android only) */ function cancelAuthenticate(): void; } @@ -899,6 +1272,7 @@ export namespace Font { function loadAsync(map: FontMap): Promise; } +// #region GLView /** * GLView */ @@ -906,7 +1280,9 @@ export interface GLViewProps extends ViewProperties { onContextCreate(): void; msaaSamples: number; } + export class GLView extends Component { } +// #endregion /** * Google @@ -943,9 +1319,7 @@ export namespace Google { function logInAsync(config: LogInConfig): Promise; } -/** - * Gyroscope - */ +/** Access the device gyroscope sensor to respond to changes in rotation in 3d space. */ export namespace Gyroscope { interface GyroscopeObject { x: Axis; @@ -953,11 +1327,50 @@ export namespace Gyroscope { z: Axis; } + /** A callback that is invoked when an gyroscope update is available. */ function addListener(listener: (obj: GyroscopeObject) => any): EventSubscription; + + /** Remove all listeners. */ function removeAllListeners(): void; + + /** Subscribe for updates to the gyroscope. */ function setUpdateInterval(intervalMs: number): void; } +/** + * ImageManipulator + */ +export namespace ImageManipulator { + interface ImageResult { + uri: string; + width: number; + height: number; + base64?: string; + } + + interface SaveOptions { + base64?: boolean; + compress?: FloatFromZeroToOne; + format?: 'jpeg' | 'png'; + } + + interface CropParameters { + originX: number; + originY: number; + width: number; + height: number; + } + + interface ImageManipulationOptions { + resize?: { width?: number; height?: number }; + rotate?: number; + flip?: { vertical?: boolean; horizontal?: boolean }; + crop?: CropParameters; + } + + function manipulate(uri: string, actions: ImageManipulationOptions, saveOptions?: SaveOptions): Promise; +} + /** * Image Picker */ @@ -992,6 +1405,7 @@ export namespace ImagePicker { aspect?: [number, number]; quality?: number; } + function launchCameraAsync(options?: CameraOptions): Promise; } @@ -999,86 +1413,86 @@ export namespace ImagePicker { * IntentLauncherAndroid */ export namespace IntentLauncherAndroid { - const ACTION_ACCESSIBILITY_SETTINGS: string; - const ACTION_APP_NOTIFICATION_REDACTION: string; - const ACTION_CONDITION_PROVIDER_SETTINGS: string; - const ACTION_NOTIFICATION_LISTENER_SETTINGS: string; - const ACTION_PRINT_SETTINGS: string; - const ACTION_ADD_ACCOUNT_SETTINGS: string; - const ACTION_AIRPLANE_MODE_SETTINGS: string; - const ACTION_APN_SETTINGS: string; - const ACTION_APPLICATION_DETAILS_SETTINGS: string; - const ACTION_APPLICATION_DEVELOPMENT_SETTINGS: string; - const ACTION_APPLICATION_SETTINGS: string; - const ACTION_APP_NOTIFICATION_SETTINGS: string; - const ACTION_APP_OPS_SETTINGS: string; - const ACTION_BATTERY_SAVER_SETTINGS: string; - const ACTION_BLUETOOTH_SETTINGS: string; - const ACTION_CAPTIONING_SETTINGS: string; - const ACTION_CAST_SETTINGS: string; - const ACTION_DATA_ROAMING_SETTINGS: string; - const ACTION_DATE_SETTINGS: string; - const ACTION_DEVICE_INFO_SETTINGS: string; - const ACTION_DEVICE_NAME: string; - const ACTION_DISPLAY_SETTINGS: string; - const ACTION_DREAM_SETTINGS: string; - const ACTION_HARD_KEYBOARD_SETTINGS: string; - const ACTION_HOME_SETTINGS: string; - const ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS: string; - const ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS: string; - const ACTION_INPUT_METHOD_SETTINGS: string; - const ACTION_INPUT_METHOD_SUBTYPE_SETTINGS: string; - const ACTION_INTERNAL_STORAGE_SETTINGS: string; - const ACTION_LOCALE_SETTINGS: string; - const ACTION_LOCATION_SOURCE_SETTINGS: string; - const ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS: string; - const ACTION_MANAGE_APPLICATIONS_SETTINGS: string; - const ACTION_MANAGE_DEFAULT_APPS_SETTINGS: string; - const ACTION_MEMORY_CARD_SETTINGS: string; - const ACTION_MONITORING_CERT_INFO: string; - const ACTION_NETWORK_OPERATOR_SETTINGS: string; - const ACTION_NFCSHARING_SETTINGS: string; - const ACTION_NFC_PAYMENT_SETTINGS: string; - const ACTION_NFC_SETTINGS: string; - const ACTION_NIGHT_DISPLAY_SETTINGS: string; - const ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS: string; - const ACTION_NOTIFICATION_SETTINGS: string; - const ACTION_PAIRING_SETTINGS: string; - const ACTION_PRIVACY_SETTINGS: string; - const ACTION_QUICK_LAUNCH_SETTINGS: string; - const ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: string; - const ACTION_SECURITY_SETTINGS: string; - const ACTION_SETTINGS: string; - const ACTION_SHOW_ADMIN_SUPPORT_DETAILS: string; - const ACTION_SHOW_INPUT_METHOD_PICKER: string; - const ACTION_SHOW_REGULATORY_INFO: string; - const ACTION_SHOW_REMOTE_BUGREPORT_DIALOG: string; - const ACTION_SOUND_SETTINGS: string; - const ACTION_STORAGE_MANAGER_SETTINGS: string; - const ACTION_SYNC_SETTINGS: string; - const ACTION_SYSTEM_UPDATE_SETTINGS: string; - const ACTION_TETHER_PROVISIONING_UI: string; - const ACTION_TRUSTED_CREDENTIALS_USER: string; - const ACTION_USAGE_ACCESS_SETTINGS: string; - const ACTION_USER_DICTIONARY_INSERT: string; - const ACTION_USER_DICTIONARY_SETTINGS: string; - const ACTION_USER_SETTINGS: string; - const ACTION_VOICE_CONTROL_AIRPLANE_MODE: string; - const ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE: string; - const ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE: string; - const ACTION_VOICE_INPUT_SETTINGS: string; - const ACTION_VPN_SETTINGS: string; - const ACTION_VR_LISTENER_SETTINGS: string; - const ACTION_WEBVIEW_SETTINGS: string; - const ACTION_WIFI_IP_SETTINGS: string; - const ACTION_WIFI_SETTINGS: string; - const ACTION_WIRELESS_SETTINGS: string; - const ACTION_ZEN_MODE_AUTOMATION_SETTINGS: string; - const ACTION_ZEN_MODE_EVENT_RULE_SETTINGS: string; - const ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS: string; - const ACTION_ZEN_MODE_PRIORITY_SETTINGS: string; - const ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS: string; - const ACTION_ZEN_MODE_SETTINGS: string; + const ACTION_ACCESSIBILITY_SETTINGS: 'android.settings.ACCESSIBILITY_SETTINGS'; + const ACTION_APP_NOTIFICATION_REDACTION: 'android.settings.ACTION_APP_NOTIFICATION_REDACTION'; + const ACTION_CONDITION_PROVIDER_SETTINGS: 'android.settings.ACTION_CONDITION_PROVIDER_SETTINGS'; + const ACTION_NOTIFICATION_LISTENER_SETTINGS: 'android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS'; + const ACTION_PRINT_SETTINGS: 'android.settings.ACTION_PRINT_SETTINGS'; + const ACTION_ADD_ACCOUNT_SETTINGS: 'android.settings.ADD_ACCOUNT_SETTINGS'; + const ACTION_AIRPLANE_MODE_SETTINGS: 'android.settings.AIRPLANE_MODE_SETTINGS'; + const ACTION_APN_SETTINGS: 'android.settings.APN_SETTINGS'; + const ACTION_APPLICATION_DETAILS_SETTINGS: 'android.settings.APPLICATION_DETAILS_SETTINGS'; + const ACTION_APPLICATION_DEVELOPMENT_SETTINGS: 'android.settings.APPLICATION_DEVELOPMENT_SETTINGS'; + const ACTION_APPLICATION_SETTINGS: 'android.settings.APPLICATION_SETTINGS'; + const ACTION_APP_NOTIFICATION_SETTINGS: 'android.settings.APP_NOTIFICATION_SETTINGS'; + const ACTION_APP_OPS_SETTINGS: 'android.settings.APP_OPS_SETTINGS'; + const ACTION_BATTERY_SAVER_SETTINGS: 'android.settings.BATTERY_SAVER_SETTINGS'; + const ACTION_BLUETOOTH_SETTINGS: 'android.settings.BLUETOOTH_SETTINGS'; + const ACTION_CAPTIONING_SETTINGS: 'android.settings.CAPTIONING_SETTINGS'; + const ACTION_CAST_SETTINGS: 'android.settings.CAST_SETTINGS'; + const ACTION_DATA_ROAMING_SETTINGS: 'android.settings.DATA_ROAMING_SETTINGS'; + const ACTION_DATE_SETTINGS: 'android.settings.DATE_SETTINGS'; + const ACTION_DEVICE_INFO_SETTINGS: 'android.settings.DEVICE_INFO_SETTINGS'; + const ACTION_DEVICE_NAME: 'android.settings.DEVICE_NAME'; + const ACTION_DISPLAY_SETTINGS: 'android.settings.DISPLAY_SETTINGS'; + const ACTION_DREAM_SETTINGS: 'android.settings.DREAM_SETTINGS'; + const ACTION_HARD_KEYBOARD_SETTINGS: 'android.settings.HARD_KEYBOARD_SETTINGS'; + const ACTION_HOME_SETTINGS: 'android.settings.HOME_SETTINGS'; + const ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS: 'android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS'; + const ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS: 'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS'; + const ACTION_INPUT_METHOD_SETTINGS: 'android.settings.INPUT_METHOD_SETTINGS'; + const ACTION_INPUT_METHOD_SUBTYPE_SETTINGS: 'android.settings.INPUT_METHOD_SUBTYPE_SETTINGS'; + const ACTION_INTERNAL_STORAGE_SETTINGS: 'android.settings.INTERNAL_STORAGE_SETTINGS'; + const ACTION_LOCALE_SETTINGS: 'android.settings.LOCALE_SETTINGS'; + const ACTION_LOCATION_SOURCE_SETTINGS: 'android.settings.LOCATION_SOURCE_SETTINGS'; + const ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS: 'android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS'; + const ACTION_MANAGE_APPLICATIONS_SETTINGS: 'android.settings.MANAGE_APPLICATIONS_SETTINGS'; + const ACTION_MANAGE_DEFAULT_APPS_SETTINGS: 'android.settings.MANAGE_DEFAULT_APPS_SETTINGS'; + const ACTION_MEMORY_CARD_SETTINGS: 'android.settings.MEMORY_CARD_SETTINGS'; + const ACTION_MONITORING_CERT_INFO: 'android.settings.MONITORING_CERT_INFO'; + const ACTION_NETWORK_OPERATOR_SETTINGS: 'android.settings.NETWORK_OPERATOR_SETTINGS'; + const ACTION_NFCSHARING_SETTINGS: 'android.settings.NFCSHARING_SETTINGS'; + const ACTION_NFC_PAYMENT_SETTINGS: 'android.settings.NFC_PAYMENT_SETTINGS'; + const ACTION_NFC_SETTINGS: 'android.settings.NFC_SETTINGS'; + const ACTION_NIGHT_DISPLAY_SETTINGS: 'android.settings.NIGHT_DISPLAY_SETTINGS'; + const ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS: 'android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS'; + const ACTION_NOTIFICATION_SETTINGS: 'android.settings.NOTIFICATION_SETTINGS'; + const ACTION_PAIRING_SETTINGS: 'android.settings.PAIRING_SETTINGS'; + const ACTION_PRIVACY_SETTINGS: 'android.settings.PRIVACY_SETTINGS'; + const ACTION_QUICK_LAUNCH_SETTINGS: 'android.settings.QUICK_LAUNCH_SETTINGS'; + const ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS: 'android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS'; + const ACTION_SECURITY_SETTINGS: 'android.settings.SECURITY_SETTINGS'; + const ACTION_SETTINGS: 'android.settings.SETTINGS'; + const ACTION_SHOW_ADMIN_SUPPORT_DETAILS: 'android.settings.SHOW_ADMIN_SUPPORT_DETAILS'; + const ACTION_SHOW_INPUT_METHOD_PICKER: 'android.settings.SHOW_INPUT_METHOD_PICKER'; + const ACTION_SHOW_REGULATORY_INFO: 'android.settings.SHOW_REGULATORY_INFO'; + const ACTION_SHOW_REMOTE_BUGREPORT_DIALOG: 'android.settings.SHOW_REMOTE_BUGREPORT_DIALOG'; + const ACTION_SOUND_SETTINGS: 'android.settings.SOUND_SETTINGS'; + const ACTION_STORAGE_MANAGER_SETTINGS: 'android.settings.STORAGE_MANAGER_SETTINGS'; + const ACTION_SYNC_SETTINGS: 'android.settings.SYNC_SETTINGS'; + const ACTION_SYSTEM_UPDATE_SETTINGS: 'android.settings.SYSTEM_UPDATE_SETTINGS'; + const ACTION_TETHER_PROVISIONING_UI: 'android.settings.TETHER_PROVISIONING_UI'; + const ACTION_TRUSTED_CREDENTIALS_USER: 'android.settings.TRUSTED_CREDENTIALS_USER'; + const ACTION_USAGE_ACCESS_SETTINGS: 'android.settings.USAGE_ACCESS_SETTINGS'; + const ACTION_USER_DICTIONARY_INSERT: 'android.settings.USER_DICTIONARY_INSERT'; + const ACTION_USER_DICTIONARY_SETTINGS: 'android.settings.USER_DICTIONARY_SETTINGS'; + const ACTION_USER_SETTINGS: 'android.settings.USER_SETTINGS'; + const ACTION_VOICE_CONTROL_AIRPLANE_MODE: 'android.settings.VOICE_CONTROL_AIRPLANE_MODE'; + const ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE: 'android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE'; + const ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE: 'android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE'; + const ACTION_VOICE_INPUT_SETTINGS: 'android.settings.VOICE_INPUT_SETTINGS'; + const ACTION_VPN_SETTINGS: 'android.settings.VPN_SETTINGS'; + const ACTION_VR_LISTENER_SETTINGS: 'android.settings.VR_LISTENER_SETTINGS'; + const ACTION_WEBVIEW_SETTINGS: 'android.settings.WEBVIEW_SETTINGS'; + const ACTION_WIFI_IP_SETTINGS: 'android.settings.WIFI_IP_SETTINGS'; + const ACTION_WIFI_SETTINGS: 'android.settings.WIFI_SETTINGS'; + const ACTION_WIRELESS_SETTINGS: 'android.settings.WIRELESS_SETTINGS'; + const ACTION_ZEN_MODE_AUTOMATION_SETTINGS: 'android.settings.ZEN_MODE_AUTOMATION_SETTINGS'; + const ACTION_ZEN_MODE_EVENT_RULE_SETTINGS: 'android.settings.ZEN_MODE_EVENT_RULE_SETTINGS'; + const ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS: 'android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS'; + const ACTION_ZEN_MODE_PRIORITY_SETTINGS: 'android.settings.ZEN_MODE_PRIORITY_SETTINGS'; + const ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS: 'android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS'; + const ACTION_ZEN_MODE_SETTINGS: 'android.settings.ZEN_MODE_SETTINGS'; function startActivityAsync(activity: string, data?: HashMap): Promise; } @@ -1091,6 +1505,7 @@ export class KeepAwake extends Component { static deactivate(): void; } +// #region LinearGradient /** * LinearGradient */ @@ -1102,6 +1517,7 @@ export interface LinearGradientProps { } export class LinearGradient extends Component { } +// #endregion /** * Location @@ -1243,12 +1659,15 @@ export namespace Permissions { 'camera' | 'contacts' | 'audioRecording'; type PermissionStatus = 'undetermined' | 'granted' | 'denied'; type PermissionExpires = 'never'; + interface PermissionDetailsLocationIOS { scope: 'whenInUse' | 'always'; } + interface PermissionDetailsLocationAndroid { scope: 'fine' | 'coarse' | 'none'; } + interface PermissionResponse { status: PermissionStatus; expires: PermissionExpires; @@ -1259,25 +1678,28 @@ export namespace Permissions { function getAsync(type: PermissionType): Promise; function askAsync(type: PermissionType): Promise; - const CAMERA: string; - const CAMERA_ROLL: string; - const AUDIO_RECORDING: string; - const LOCATION: string; - const REMOTE_NOTIFICATIONS: string; - const NOTIFICATIONS: string; - const CONTACTS: string; + type RemoteNotificationPermission = 'remoteNotifications'; + + const CAMERA: 'camera'; + const CAMERA_ROLL: 'cameraRoll'; + const AUDIO_RECORDING: 'audioRecording'; + const LOCATION: 'location'; + const REMOTE_NOTIFICATIONS: RemoteNotificationPermission; + const NOTIFICATIONS: RemoteNotificationPermission; + const CONTACTS: 'contacts'; + const SYSTEM_BRIGHTNESS: 'systemBrightness'; } /** * Register Root Component */ -export function registerRootComponent(component: Component): Component; +export function registerRootComponent(component: ComponentType): void; /** * ScreenOrientation */ export namespace ScreenOrientation { - interface Orientation { + interface Orientations { ALL: 'ALL'; ALL_BUT_UPSIDE_DOWN: 'ALL_BUT_UPSIDE_DOWN'; PORTRAIT: 'PORTRAIT'; @@ -1287,8 +1709,10 @@ export namespace ScreenOrientation { LANDSCAPE_LEFT: 'LANDSCAPE_LEFT'; LANDSCAPE_RIGHT: 'LANDSCAPE_RIGHT'; } - const Orientation: Orientation; - function allow(orientation: string): void; + + const Orientation: Orientations; + + function allow(orientation: keyof Orientations): void; } /** @@ -1299,6 +1723,7 @@ export namespace SecureStore { keychainService?: string; keychainAccessible?: number; } + function setItemAsync(key: string, value: string, options?: SecureStoreOptions): Promise; function getItemAsync(key: string, options?: SecureStoreOptions): Promise; function deleteItemAsync(key: string, options?: SecureStoreOptions): Promise; @@ -1389,6 +1814,7 @@ export namespace SQLite { ): any; } +// #region Svg /** * Svg */ @@ -1507,7 +1933,7 @@ export interface SvgStopProps extends SvgCommonProps { export class Svg extends Component<{ width: number, height: number }> { static Circle: ComponentClass; static ClipPath: ComponentClass; - static Defs: ComponentClass<{ }>; + static Defs: ComponentClass; static Ellipse: ComponentClass; static G: ComponentClass; static Line: ComponentClass; @@ -1524,6 +1950,7 @@ export class Svg extends Component<{ width: number, height: number }> { static TSpan: ComponentClass; static Use: ComponentClass; } +// #endregion /** * Take Snapshot @@ -1539,19 +1966,102 @@ export function takeSnapshotAsync( } ): Promise; -/** - * Util - */ +/** Helpful utility functions that don’t fit anywhere else, including some localization and internationalization methods. */ export namespace Util { - function getCurrentDeviceCountryAsync(): Promise; + /** Returns the current device country code. */ + function getCurrentDeviceCountryAsync(): Promise; + + /** Returns the current device locale as a string. */ function getCurrentLocaleAsync(): Promise; + + /** Returns the current device time zone name. */ function getCurrentTimeZoneAsync(): Promise; + + /** Reloads the current experience. This will fetch and load the newest available JavaScript supported by the device’s Expo environment. This is useful for triggering an update of your experience if you have published a new version. */ function reload(): void; + + /** _Android only_. Invokes a callback when a new version of your app is successfully downloaded in the background. */ function addNewVersionListenerExperimental(listener: (event: { manifest: object; - }) => void): { remove(): void; }; // Android only + }) => void): { remove(): void; }; } +// #region Video +/** + * Expo Video + */ +export interface NaturalSize { + width: number; + height: number; + orientation: Orientation; +} + +export interface ReadyForDisplayEvent { + naturalSize: NaturalSize; + status: PlaybackStatus; +} + +export enum FullscreenUpdateVariants { + IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT = 0, + IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT = 1, + IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS = 2, + IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS = 3 +} + +export interface FullscreenUpdateEvent { + fullscreenUpdate: FullscreenUpdateVariants; + status: PlaybackStatus; +} + +export interface VideoProps { + source?: PlaybackSource | null; + posterSource?: URISource | RequireSource; + + resizeMode?: ResizeModeContain | ResizeModeCover | ResizeModeStretch; + useNativeControls?: boolean; + usePoster?: boolean; + + onPlaybackStatusUpdate?: (status: PlaybackStatus) => void; + onReadyForDisplay?: (event: ReadyForDisplayEvent) => void; + onIOSFullscreenUpdate?: (event: FullscreenUpdateEvent) => void; + + onLoadStart?: () => void; + onLoad?: (status: PlaybackStatus) => void; + onError?: (error: string) => void; + + status?: PlaybackStatusToSet; + progressUpdateIntervalMillis?: number; + positionMillis?: number; + shouldPlay?: boolean; + rate?: number; + shouldCorrectPitch?: boolean; + volume?: number; + isMuted?: boolean; + isLooping?: boolean; + + scaleX?: number; + scaleY?: number; + translateX?: number; + translateY?: number; + rotation?: number; + ref?: Ref; +} + +export interface VideoState { + showPoster: boolean; +} + +export class Video extends Component { + static RESIZE_MODE_CONTAIN: ResizeModeContain; + static RESIZE_MODE_COVER: ResizeModeCover; + static RESIZE_MODE_STRETCH: ResizeModeStretch; + static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_PRESENT; + static IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_PRESENT; + static IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_WILL_DISMISS; + static IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS: FullscreenUpdateVariants.IOS_FULLSCREEN_UPDATE_PLAYER_DID_DISMISS; +} +// #endregion + /** * Web Browser */ @@ -1560,102 +2070,3 @@ export namespace WebBrowser { function openAuthSessionAsync(url: string, redirectUrl?: string): Promise<{ type: 'cancelled' | 'dismissed' }>; function dismissBrowser(): Promise<{ type: 'dismissed' }>; } - -/** - * ImageManipulator - */ -export namespace ImageManipulator { - interface ImageResult { - uri: string; - width: number; - height: number; - base64?: string; - } - interface SaveOptions { - base64?: boolean; - compress?: FloatFromZeroToOne; - format?: 'jpeg' | 'png'; - } - interface CropParameters { - originX: number; - originY: number; - width: number; - height: number; - } - interface ImageManipulationOptions { - resize?: { width?: number; height?: number }; - rotate?: number; - flip?: { vertical?: boolean; horizontal?: boolean }; - crop?: CropParameters; - } - function manipulate(uri: string, actions: ImageManipulationOptions, saveOptions?: SaveOptions): Promise; -} - -/** - * FaceDetector - */ -export namespace FaceDetector { - interface Point { - x: Axis; - y: Axis; - } - interface Face { - bounds: { - size: { - width: number; - height: number; - }, - origin: Point; - }; - smilingProbability?: number; - leftEarPosition?: Point; - rightEarPosition?: Point; - leftEyePosition?: Point; - leftEyeOpenProbability?: number; - rightEyePosition?: Point; - rightEyeOpenProbability?: number; - leftCheekPosition?: Point; - rightCheekPosition?: Point; - leftMouthPosition?: Point; - mouthPosition?: Point; - rightMouthPosition?: Point; - bottomMouthPosition?: Point; - noseBasePosition?: Point; - yawAngle?: number; - rollAngle?: number; - } - interface DetectFaceResult { - faces: Face[]; - image: { - uri: string; - width: number; - height: number; - orientation: number; - }; - } - interface Mode { - fast: 'fast'; - accurate: 'accurate'; - } - interface _Shared { - all: 'all'; - none: 'none'; - } - type Landmarks = _Shared; - type Classifications = _Shared; - interface _Constants { - Mode: Mode; - Landmarks: Landmarks; - Classifications: Classifications; - } - - const Constants: _Constants; - - interface Options { - mode?: keyof Mode; - detectLandmarks?: keyof Landmarks; - runClassifications?: keyof Classifications; - } - - function detectFaces(uri: string, options?: Options): Promise; -} diff --git a/types/expo/tslint.json b/types/expo/tslint.json index 3db14f85ea..8270136207 100644 --- a/types/expo/tslint.json +++ b/types/expo/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "void-return": false, + "max-line-length": false + } +} diff --git a/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts new file mode 100644 index 0000000000..1e9a2395a4 --- /dev/null +++ b/types/graphql-resolve-batch/graphql-resolve-batch-tests.ts @@ -0,0 +1,93 @@ +import { createBatchResolver, ResolverFunction } from "graphql-resolve-batch"; + +interface SomeTestSource { + someSourceProp: string; +} + +interface SomeTestArgs { + someArg: string; +} + +interface SomeTestContext { + someContextProp: string; +} + +interface SomeTestResult { + someTestResultProp: string; +} + +const withSourceAndResultTyped = createBatchResolver< + SomeTestSource, + SomeTestResult +>((sources, _, __) => { + return sources.map(source => { + const res: SomeTestResult = { + someTestResultProp: "" + }; + + return res; + }); +}); + +const withSourceAndResultTypedAsPromise = createBatchResolver< + SomeTestSource, + SomeTestResult +>((sources, _, __) => { + // $ExpectType ReadonlyArray + const verifySources = sources; + + return sources.map(source => { + return new Promise(resolve => { + const res: SomeTestResult = { + someTestResultProp: "" + }; + + resolve(res); + }); + }); +}); + +const withSourceAndArgsAndResultTyped = createBatchResolver< + SomeTestSource, + SomeTestResult, + SomeTestArgs +>((sources, args, _) => { + // $ExpectType ReadonlyArray + const verifySources = sources; + // $ExpectType string + const verifyArgs = args.someArg; + + return sources.map(source => { + return new Promise(resolve => { + const res: SomeTestResult = { + someTestResultProp: "" + }; + + resolve(res); + }); + }); +}); + +const withSourceAndArgsAndContextTyped = createBatchResolver< + SomeTestSource, + SomeTestResult, + SomeTestArgs, + SomeTestContext +>((sources, args, context) => { + // $ExpectType ReadonlyArray + const verifySources = sources; + // $ExpectType string + const verifyArgs = args.someArg; + // $ExpectType string + const verifyContext = context.someContextProp; + + return sources.map(source => { + return new Promise(resolve => { + const res: SomeTestResult = { + someTestResultProp: "" + }; + + resolve(res); + }); + }); +}); diff --git a/types/graphql-resolve-batch/index.d.ts b/types/graphql-resolve-batch/index.d.ts new file mode 100644 index 0000000000..46f354f7b7 --- /dev/null +++ b/types/graphql-resolve-batch/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for graphql-resolve-batch 1.0 +// Project: https://github.com/calebmer/graphql-resolve-batch#readme +// Definitions by: Rutger Hendrickx +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export function createBatchResolver< + TSource, + TReturn, + TArgs = any, + TContext = any +>( + batchResolveFn: BatchResolveFunction +): ResolverFunction; + +export type ResolverFunction = ( + source: TSource, + args: TArgs, + context: TContext +) => Promise; + +export type BatchResolveFunction = ( + sources: ReadonlyArray, + args: TArgs, + context: TContext +) => TReturn[] | Array>; diff --git a/types/graphql-resolve-batch/tsconfig.json b/types/graphql-resolve-batch/tsconfig.json new file mode 100644 index 0000000000..aa4ad6661d --- /dev/null +++ b/types/graphql-resolve-batch/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "strictFunctionTypes": true, + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "graphql-resolve-batch-tests.ts"] +} diff --git a/types/graphql-resolve-batch/tslint.json b/types/graphql-resolve-batch/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/graphql-resolve-batch/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index e0d73d5c9e..f83c386d09 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -470,7 +470,7 @@ declare namespace jest { * and it is set to a certain numeric value. */ toHaveLength(expected: number): R; - toHaveProperty(propertyPath: string, value?: any): R; + toHaveProperty(propertyPath: string | any[], value?: any): R; /** * Check that a string matches a regular expression. */ diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 4d8ae05e1c..4c37f2bb65 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -642,6 +642,22 @@ describe('rejects', () => { }); }); +// https://facebook.github.io/jest/docs/en/expect.html#tohavepropertykeypath-value +describe('toHaveProperty', () => { + it('it accepts a keyPath as string', () => { + expect({ a: { b: {}}}).toHaveProperty('a'); + }); + it('it accepts a keyPath as string with dot notation', () => { + expect({ a: { b: {}}}).toHaveProperty('a.b'); + }); + it('it accepts a keyPath as an array', () => { + expect({ a: { b: {}}}).toHaveProperty(['a', 'b']); + }); + it('it accepts a keyPath as an array containing non-string values', () => { + expect({ a: ['b']}).toHaveProperty(['a', 0]); + }); +}); + class MyTransformer implements jest.Transformer { process(text: string, path: string) { return ` diff --git a/types/jsonrpc-serializer/index.d.ts b/types/jsonrpc-serializer/index.d.ts index 1f1b58551e..dd5210c23c 100644 --- a/types/jsonrpc-serializer/index.d.ts +++ b/types/jsonrpc-serializer/index.d.ts @@ -1,28 +1,113 @@ // Type definitions for jsonrpc-serializer 0.2 -// Project: https://github.com/soggie/jsonrpc-serializer#readme -// Definitions by: Akim95 +// Project: https://github.com/soggie/jsonrpc-serializer +// Definitions by: Akim95 , many20 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.5 -export function request(id: string | number, method: string, params?: T): string; -export function notification(method: string, params?: T): string; -export function success(id: string, result: T): string; -export function error(id: string, error: T): string; -export function deserialize(msg: string): T; -export function requestObject(id: string | number, method: string, params?: T): string; -export function notificationObject(method: string, params?: T): string; -export function successObject(id: string, result: T): string; -export function errorObject(id: string, error: T): string; -export function deserializeObject(msg: T): void; +export type PayloadType = 'request' | 'notification' | 'success' | 'error'; +// export const PayloadType = { +// request: 'request' as PayloadType, +// notification: 'notification' as PayloadType, +// success: 'success' as PayloadType, +// error: 'error' as PayloadType +// }; -export const errorHandler: any; +export interface DeserializeObject { + type: PayloadType; + payload: RequestPayloadObject | NotificationPayloadObject | SuccessPayloadObject | ErrorPayloadObject; +} + +export interface PayloadObject { + id?: string | number; + method?: string; + params?: any; + result?: any; + error?: SerializerError; +} + +export interface RequestPayloadObject extends PayloadObject { + id: string; + method: string; + params: any; +} + +export interface NotificationPayloadObject extends PayloadObject { + method: string; + params: any; +} + +export interface SuccessPayloadObject extends PayloadObject { + id: string | number; + result: any; +} + +export interface ErrorPayloadObject extends PayloadObject { + id: string | number; + error: SerializerError; +} + +export interface SerializerError extends Error { + name: string; + code: number; + message: string; + data?: any[]; +} + +export function request(id: string | number, method: string, params?: any): string; +export function notification(method: string, params?: any): string; +export function success(id: string | number, result: any): string; +export function error(id: string | number, error: err.JsonRpcError): string; +export function deserialize(msg: string): DeserializeObject; +export function requestObject(id: string | number, method: string, params?: any): PayloadObject; +export function notificationObject(method: string, params?: any): PayloadObject; +export function successObject(id: string | number, result: any): PayloadObject; +export function errorObject(id: string | number, error: SerializerError): PayloadObject; +export function deserializeObject(msg: PayloadObject): DeserializeObject; + +export type errorHandler = (errors: string[] | null) => void; export namespace err { - class JsonRpcError { - constructor(msg: string); - serialize(): any; + type ErrorName = 'JsonRpcError' | 'ParseError' | 'InvalidRequestError' | 'MethodNotFoundError' | 'InvalidParamsError'; + // const ErrorName = { + // JsonRpcError: 'JsonRpcError' as ErrorName, + // ParseError: 'ParseError' as ErrorName, + // InvalidRequestError: 'InvalidRequestError' as ErrorName, + // MethodNotFoundError: 'MethodNotFoundError' as ErrorName, + // InvalidParamsError: 'InvalidParamsError' as ErrorName + // }; + + type ErrorCode = -32603 | -32700 | -32600 | -32601 | -32602; + // const ErrorCode = { + // JsonRpcError: -32603 as ErrorCode, + // ParseError: -32700 as ErrorCode, + // InvalidRequestError: -32600 as ErrorCode, + // MethodNotFoundError: -32601 as ErrorCode, + // InvalidParamsError: -32602 as ErrorCode + // }; + + class JsonRpcError extends Error implements SerializerError { + name: string | ErrorName; + code: number | ErrorCode; + message: string; + data?: any[]; + + constructor(msg: string, ...args: any[]); + serialize(): string; + } + + class InvalidParamsError extends JsonRpcError { + constructor(...args: any[]); + } + + class InvalidRequestError extends JsonRpcError { + constructor(...args: any[]); + } + + class MethodNotFoundError extends JsonRpcError { + constructor(...args: any[]); + } + + class ParseError extends JsonRpcError { + constructor(...args: any[]); } - class InvalidParamsError {} - class InvalidRequestError {} - class MethodNotFoundError {} - class ParseError {} } diff --git a/types/jsonrpc-serializer/jsonrpc-serializer-tests.ts b/types/jsonrpc-serializer/jsonrpc-serializer-tests.ts index 83a6cc6f83..2a80ef1d97 100644 --- a/types/jsonrpc-serializer/jsonrpc-serializer-tests.ts +++ b/types/jsonrpc-serializer/jsonrpc-serializer-tests.ts @@ -1,3 +1,4 @@ +import * as uuid from 'node-uuid'; import * as jrs from 'jsonrpc-serializer'; // request tests @@ -46,3 +47,40 @@ const request = { jrs.deserialize(JSON.stringify(request)); jrs.deserializeObject(request); + +// --- + +const request2 = jrs.request('request-id', 'request-method'); + +// ---> "{\"jsonrpc\":\"2.0\",\"id\":\"request-id\",\"method:\":\"request-method\"}" + +const ok1 = "{\"jsonrpc\":\"2.0\",\"id\":\"request-id\",\"result\":\"success!!\"}"; + +const response1 = jrs.deserialize(ok1); + +// --- + +const payload2 = jrs.request( + uuid.v4(), // generates a V4 UUID string + 'saveUser', // the method to call + { + name : 'Ruben Tan', + email : 'foo@bar.com', + race : 'unicorn' + } +); + +// --- + +const payload3 = jrs.notification( + 'newMessage', // the method to call + { + subject : 'Test message', + message : 'This is a test message' + } +); + +// --- + +const err1 = new jrs.err.JsonRpcError('This is an error'); +const str1 = err1.serialize(); diff --git a/types/moment-range/index.d.ts b/types/moment-range/index.d.ts index e0298abd8e..18538e5c6d 100644 --- a/types/moment-range/index.d.ts +++ b/types/moment-range/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Moment-range.js 3.0 +// Type definitions for Moment-range.js 3.1 // Project: https://github.com/gf3/moment-range // Definitions by: Bart van den Burg // Wilgert Velinga @@ -21,7 +21,7 @@ export class DateRange { intersect(other: DateRange): DateRange; - add(other: DateRange): DateRange; + add(other: DateRange, options?: { adjacent?: boolean }): DateRange; subtract(other: DateRange): DateRange[]; diff --git a/types/moment-range/moment-range-tests.ts b/types/moment-range/moment-range-tests.ts index fc9a8b6e12..cbd55ef183 100644 --- a/types/moment-range/moment-range-tests.ts +++ b/types/moment-range/moment-range-tests.ts @@ -60,18 +60,20 @@ const it10: Iterable = range.reverseByRange(range, { exclusive: t const it11: Iterable = range.reverseByRange(range, { exclusive: false, step: 2 }); const res23: momentRange.DateRange = range.add(range2); +const res24: momentRange.DateRange = range.add(range2, {adjacent: true}); +const res25: momentRange.DateRange = range.add(range2, {adjacent: false}); -const res24: momentRange.DateRange[] = range.subtract(range2); +const res26: momentRange.DateRange[] = range.subtract(range2); -const res25: Date[] = range.toDate(); +const res27: Date[] = range.toDate(); -const res26: string = range.toString(); +const res28: string = range.toString(); -const res27: number = range.valueOf(); +const res29: number = range.valueOf(); -const res28: moment.Moment = range.start; -const res29: moment.Moment = range.end; +const res30: moment.Moment = range.start; +const res31: moment.Moment = range.end; -const res30: boolean = extendedMoment.within(range); -const res31: boolean = extendedMoment().within(range); -const res32: momentRange.DateRange = extendedMoment().range(moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD")); +const res32: boolean = extendedMoment.within(range); +const res33: boolean = extendedMoment().within(range); +const res34: momentRange.DateRange = extendedMoment().range(moment("2011-04-15", "YYYY-MM-DD"), moment("2011-11-27", "YYYY-MM-DD")); diff --git a/types/mongo-sanitize/index.d.ts b/types/mongo-sanitize/index.d.ts new file mode 100644 index 0000000000..44c5d04a7d --- /dev/null +++ b/types/mongo-sanitize/index.d.ts @@ -0,0 +1,9 @@ +// Type definitions for mongo-sanitize 1.0 +// Project: https://github.com/vkarpov15/mongo-sanitize +// Definitions by: Cedric Cazin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export function sanitize(v: T): T; + +export as namespace mongoSanitize; diff --git a/types/mongo-sanitize/mongo-sanitize-tests.ts b/types/mongo-sanitize/mongo-sanitize-tests.ts new file mode 100644 index 0000000000..4d4534bbeb --- /dev/null +++ b/types/mongo-sanitize/mongo-sanitize-tests.ts @@ -0,0 +1,11 @@ +import * as mongoSanitize from 'mongo-sanitize'; + +const objectSanitized = mongoSanitize.sanitize({ $gt: 5, a: 1 }); + +const arraySanitized = mongoSanitize.sanitize([1, 2, 3]); + +class Clazz { + $gt = 5; + a = 1; +} +const classSanitized = mongoSanitize.sanitize(new Clazz()); diff --git a/types/mongo-sanitize/tsconfig.json b/types/mongo-sanitize/tsconfig.json new file mode 100644 index 0000000000..231a306a62 --- /dev/null +++ b/types/mongo-sanitize/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "mongo-sanitize-tests.ts" + ] +} diff --git a/types/mongo-sanitize/tslint.json b/types/mongo-sanitize/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mongo-sanitize/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/odata/index.d.ts b/types/odata/index.d.ts index 349d48763b..e56ac4296c 100644 --- a/types/odata/index.d.ts +++ b/types/odata/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for odata v0.3.4 +// Type definitions for odata v0.3 // Project: https://github.com/janhommes/odata // Definitions by: Jan Hommes , Jean-Christophe Chalte // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -26,14 +26,16 @@ declare module 'odata' { } interface OHandler { - inlinecount : number - data : T + inlinecount: number; // if inlinecount is set, here the counting is gold + data: T; // holds the data after an callback + param: {}; // this object holds all parameter for a route config(options ?: Options) : OHandler progress(callback : () => any) : OHandler - get(callback ?: (data : T) => void) : Q.Promise> - save(callback ?: (data : T) => void) : Q.Promise> + get(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise> + save(callback ?: (data : T) => void, errorCallback?: (status: number) => void) : Q.Promise> + query: () => string; post(params : any) : OHandler patch(params : any) : OHandler @@ -78,11 +80,14 @@ declare module 'odata' { deleteRef(resource : string, id : string | number) : OHandler } - interface OFn extends OHandler { - (options ?: string | Options) : OHandler + interface OHandlerStatic { + (): OHandlerStatic; + (options?: string | Options): OHandler<{}>; + config: (config: Options) => OHandlerStatic; + isEndpoint: () => boolean; } - var o : OFn<{}>; + var o : OHandlerStatic; export = o } \ No newline at end of file diff --git a/types/odata/odata-tests.ts b/types/odata/odata-tests.ts index 58e1505f21..743c5cd906 100644 --- a/types/odata/odata-tests.ts +++ b/types/odata/odata-tests.ts @@ -20,6 +20,8 @@ interface Category { o('http://services.odata.org/V4/OData/OData.svc/Products') .get(function(data) { console.log(data); //returns an array of Product data + }, function(status) { + console.error(status); // error with status }); @@ -70,7 +72,8 @@ o('http://services.odata.org/V4/OData/OData.svc/Products(2)') .get() .then(function(oHandler) { console.log(oHandler.data); - }).fail(function(ex) { + }) + .fail(function(ex) { console.log(ex); }); @@ -114,10 +117,12 @@ o('http://services.odata.org/V4/OData/OData.svc/Products') .get() .then(function(oHandler) { oHandler.data.Name="NewName"; - return(o.save()); - }).then(function(oHandler) { + return(oHandler.save()); + }) + .then(function(oHandler) { console.log(oHandler.data.Name); //NewName - }).fail(function(ex) { + }) + .fail(function(ex) { console.log("error"); }); @@ -132,7 +137,12 @@ o('Products').get(function(data) { //same result like the first example on this page }); - +const oEequest = o('http://services.odata.org/V4/OData/OData.svc/Products') + .find(2); +const queryString = oEequest.query(); +if (queryString !== 'http://services.odata.org/V4/OData/OData.svc/Products(2)') { + throw new Error('assert error'); +} //basic config o().config({ diff --git a/types/random-number/index.d.ts b/types/random-number/index.d.ts new file mode 100644 index 0000000000..2a7d25ee14 --- /dev/null +++ b/types/random-number/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for random-number 0.0 +// Project: https://github.com/ashnur/random-number +// Definitions by: OpenByteDev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// TypeScript Version: 2.2 + +type Generator = (min?: number|null, max?: number|null, integer?: boolean|null) => number; + +interface UnparsedOptions { + min?: number; + max?: number; + integer?: boolean; +} +interface Options { + min: number; + max: number; + integer: boolean; +} + +interface RandomNumber { + (options?: UnparsedOptions): number; + generator(options?: UnparsedOptions): Generator; + defaults(options?: UnparsedOptions): Options; +} + +declare const randomNumber: RandomNumber; + +export = randomNumber; diff --git a/types/random-number/random-number-tests.ts b/types/random-number/random-number-tests.ts new file mode 100644 index 0000000000..72a8fb4628 --- /dev/null +++ b/types/random-number/random-number-tests.ts @@ -0,0 +1,58 @@ +import rn = require('random-number'); + +rn(); + +const options1 = { + min: -1000, + max: 1000, + integer: true +}; +rn(options1); + +const gen1 = rn.generator({ + min: -1000, + max: 1000, + integer: true +}); +gen1(); + +const gen2 = rn.generator({ + min: -1000, + max: 1000, + integer: true +}); +gen2(500); +gen2(500, null, false); + +const options3 = { + min: 9874316514 +}; +rn(options3); + +const options4 = { + max: -9874316514 +}; +rn(options4); + +const options5 = { + integer: true +}; +rn(options5); + +const options6 = { + min: -10, + max: -1 +}; +rn(options6); + +const options7 = { + min: 1000, + integer: true +}; +rn(options7); + +const options8 = { + max: 1000, + integer: true +}; +rn(options8); diff --git a/types/random-number/tsconfig.json b/types/random-number/tsconfig.json new file mode 100644 index 0000000000..96004058a0 --- /dev/null +++ b/types/random-number/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "random-number-tests.ts" + ] +} \ No newline at end of file diff --git a/types/random-number/tslint.json b/types/random-number/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/random-number/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/react-beautiful-dnd/index.d.ts b/types/react-beautiful-dnd/index.d.ts index b405c481c4..085ad4e8b7 100644 --- a/types/react-beautiful-dnd/index.d.ts +++ b/types/react-beautiful-dnd/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-beautiful-dnd 3.0 +// Type definitions for react-beautiful-dnd 4.0 // Project: https://github.com/atlassian/react-beautiful-dnd // Definitions by: varHarrie // Bradley Ayers @@ -8,12 +8,10 @@ import * as React from 'react'; export type Id = string; - export type DraggableId = Id; - export type DroppableId = Id; - export type TypeId = Id; +export type ZIndex = number | string; export interface DraggableLocation { droppableId: DroppableId; @@ -71,9 +69,33 @@ export class Droppable extends React.Component {} * Draggable */ -export type DraggableStyle = any; +export interface NotDraggingStyle { + transform: null | string; + transition: null | 'none'; +} -export interface DragHandleProps { +export interface DraggingStyle { + pointerEvents: 'none'; + position: 'fixed'; + width: number; + height: number; + boxSizing: 'border-box'; + top: number; + left: number; + margin: 0; + transform: null | string; + transition: 'none'; + zIndex: ZIndex; +} + +export interface DraggableProvidedDraggableProps { + // inline style + style: null | DraggingStyle | NotDraggingStyle; + // used for shared global styles + 'data-react-beautiful-dnd-draggable': string; +} + +export interface DraggableProvidedDragHandleProps { onMouseDown: React.MouseEventHandler; onKeyDown: React.KeyboardEventHandler; onClick: React.MouseEventHandler; @@ -85,9 +107,11 @@ export interface DragHandleProps { } export interface DraggableProvided { + draggableProps: DraggableProvidedDraggableProps; + dragHandleProps: DraggableProvidedDragHandleProps | null; + + // will be removed after move to react 16 innerRef(element?: HTMLElement | null): any; - draggableStyle?: DraggableStyle | null; - dragHandleProps?: DragHandleProps | null; placeholder?: React.ReactElement | null; } @@ -97,7 +121,7 @@ export interface DraggableStateSnapshot { export interface DraggableProps { draggableId: DroppableId; - type?: TypeId; + index: number; isDragDisabled?: boolean; disableInteractiveElementBlocking?: boolean; children(provided: DraggableProvided, snapshot: DraggableStateSnapshot): React.ReactElement; diff --git a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx index 8f961e0c7a..b05ff46550 100644 --- a/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx +++ b/types/react-beautiful-dnd/react-beautiful-dnd-tests.tsx @@ -24,7 +24,7 @@ const reorder = (list: any[], startIndex: number, endIndex: number) => { return result; }; -const getItemStyle = (draggableStyle: any, isDragging: any) => ({ +const getItemStyle = (isDragging: boolean, draggableStyle: any) => ({ userSelect: 'none', background: isDragging ? 'lightgreen' : 'grey', ...draggableStyle @@ -68,21 +68,16 @@ class App extends React.Component<{}, AppState> { {(provided, snapshot) => ( -
- {this.state.items.map(item => ( - +
+ {this.state.items.map((item, index) => ( + {(provided, snapshot) => (
{item.content}
diff --git a/types/reactstrap/lib/Input.d.ts b/types/reactstrap/lib/Input.d.ts index c5827f9a75..7236e02fa6 100644 --- a/types/reactstrap/lib/Input.d.ts +++ b/types/reactstrap/lib/Input.d.ts @@ -1,6 +1,6 @@ import { CSSModule } from '../index'; -type InputType = +export type InputType = | 'text' | 'email' | 'select' diff --git a/types/webpack-dev-server/index.d.ts b/types/webpack-dev-server/index.d.ts index 797ae437dc..c6bab12c3b 100644 --- a/types/webpack-dev-server/index.d.ts +++ b/types/webpack-dev-server/index.d.ts @@ -15,6 +15,10 @@ import * as spdy from 'spdy'; import * as httpProxyMiddleware from 'http-proxy-middleware'; declare namespace WebpackDevServer { + interface ListeningApp { + address(): { port?: number }; + } + interface proxyConfigMap { [url: string]: string | httpProxyMiddleware.Config; } @@ -76,6 +80,12 @@ declare class WebpackDevServer { config: WebpackDevServer.Configuration ); + static addDevServerEntrypoints( + webpackOptions: webpack.Configuration | webpack.Configuration[], + config: WebpackDevServer.Configuration, + listeningApp?: WebpackDevServer.ListeningApp + ): void; + listen(port: number, hostname: string, callback?: (error?: Error) => void): http.Server; listen(port: number, callback?: (error?: Error) => void): http.Server; diff --git a/types/webpack-dev-server/webpack-dev-server-tests.ts b/types/webpack-dev-server/webpack-dev-server-tests.ts index a288ea51be..5a23a60ad7 100644 --- a/types/webpack-dev-server/webpack-dev-server-tests.ts +++ b/types/webpack-dev-server/webpack-dev-server-tests.ts @@ -75,7 +75,7 @@ const config: WebpackDevServer.Configuration = { // API example server = new WebpackDevServer(compiler, config); -server.listen(8080, "localhost", () => {}); +server.listen(8080, "localhost", () => { }); // HTTPS example server = new WebpackDevServer(compiler, { @@ -83,10 +83,25 @@ server = new WebpackDevServer(compiler, { https: true }); -server.listen(8080, "localhost", () => {}); +server.listen(8080, "localhost", () => { }); server.close(); -// multiple compilers +WebpackDevServer.addDevServerEntrypoints(config, { + publicPath: "/assets/", + https: true +}); +WebpackDevServer.addDevServerEntrypoints( + [config], + { + publicPath: "/assets/", + https: true + }, + { + address: () => ({ port: 80 }) + } +); + +// multiple compilers server = new WebpackDevServer(multipleCompiler, config);