From 80fd9daed79eb612c3c323fa25e1eb01062d56f4 Mon Sep 17 00:00:00 2001 From: tristancaron Date: Mon, 23 Mar 2015 20:23:45 +0100 Subject: [PATCH 0001/1850] Service Worker Api --- service_worker_api/service_worker_api-test.ts | 188 ++++ service_worker_api/service_worker_api.d.ts | 896 ++++++++++++++++++ 2 files changed, 1084 insertions(+) create mode 100644 service_worker_api/service_worker_api-test.ts create mode 100644 service_worker_api/service_worker_api.d.ts diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts new file mode 100644 index 0000000000..67ce58cd40 --- /dev/null +++ b/service_worker_api/service_worker_api-test.ts @@ -0,0 +1,188 @@ +/// + +var OFFLINE_CACHE = "cache_test"; +var OFFLINE_URL = "localhost"; + +self.addEventListener('fetch', function(event: FetchEvent) { + if (event.request.method === 'GET' && + event.request.headers.get('accept').indexOf('text/html') !== -1) { + console.log('Handling fetch event for', event.request.url); + event.respondWith( + self.fetch(event.request).catch(function(e) { + console.error('Fetch failed; returning offline page instead.', e); + return self.caches.open(OFFLINE_CACHE).then(function(cache: Cache) { + return cache.match(OFFLINE_URL); + }); + }) + ); + } +}); + +self.caches.open('v1').then(function(cache: Cache) { + cache.matchAll('/images/').then(function(response: Array) { + response.forEach(function(element, index, array) { + cache.delete(element); + + }); + }); + +}); + +self.addEventListener('install', function(event: InstallEvent) { + event.waitUntil( + self.caches.open('v1').then(function(cache: Cache) { + return cache.add('/sw-test/index.html'); + }) + ); +}); + +self.addEventListener('install', function(event: InstallEvent) { + event.waitUntil( + self.caches.open('v1').then(function(cache) { + return cache.addAll( + '/sw-test/', + '/sw-test/index.html', + '/sw-test/style.css', + '/sw-test/app.js', + '/sw-test/image-list.js', + '/sw-test/star-wars-logo.jpg', + '/sw-test/gallery/', + '/sw-test/gallery/bountyHunters.jpg', + '/sw-test/gallery/myLittleVader.jpg', + '/sw-test/gallery/snowTroopers.jpg' + ); + }) + ); +}); + +self.addEventListener('fetch', function(event: FetchEvent) { + var cachedResponse = self.caches.match(event.request).catch(function() { + return self.fetch(event.request).then(function(response: Response) { + return self.caches.open('v1').then(function(cache) { + cache.put(event.request, response.clone()); + return response; + }); + }); + }).catch(function() { + return self.caches.match('/sw-test/gallery/myLittleVader.jpg'); + }); + + event.respondWith(cachedResponse); +}); + +self.caches.open('v1').then(function(cache) { + cache.match('/images/image.png').then(function(response) { + cache.delete(response); + }); +}); + +self.caches.open('v1').then(function(cache: Cache) { + cache.keys().then(function(response) { + response.forEach(function(element, index, array) { + cache.delete(element); + }); + }); +}); + +self.caches.has('v1').then(function() { + self.caches.delete('v1').then(function() { + + }); +}); + +self.addEventListener('activate', function(event: ExtendableEvent) { + var cacheWhitelist = ['v2']; + + event.waitUntil( + self.caches.keys().then(function(keyList) { + for(var i = 0; i < keyList.length; i++) { + if (cacheWhitelist.indexOf(keyList[i]) === -1) { + return self.caches.delete(keyList[i]); + } + } + }) + ); +}); + +function sendMessage(message) { + return new Promise(function(resolve, reject) { + var messageChannel = new MessageChannel(); + messageChannel.port1.onmessage = function(event) { + if (event.data.error) { + reject(event.data.error); + } else { + resolve(event.data); + } + }; + navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]); + }); +} + +self.clients.matchAll({type: "test"}).then(function(clients) { + for(var i = 0 ; i < clients.length ; i++) { + if(clients[i].url === 'index.html') { + self.clients.openWindow(clients[i].url); + // or do something else involving the matching client + } + } +}); + +self.addEventListener('activate', function(e: ExtendableEvent) { + e.waitUntil(self.clients.claim()); +}); + +navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(function(registration) { + // At this point, registration has taken place. + // The service worker will not handle requests until this page and any + // other instances of this page (in other tabs, etc.) have been + // closed/reloaded. + var serviceWorker; + if (registration.installing) { + serviceWorker = registration.installing; + } else if (registration.waiting) { + serviceWorker = registration.waiting; + } else if (registration.active) { + serviceWorker = registration.active; + } + if (serviceWorker) { + console.log(serviceWorker.state); + serviceWorker.addEventListener('statechange', function(e) { + console.log(e.target.state); + }); + } +}).catch(function(error) { + // Something went wrong during registration. The service-worker.js file + // might be unavailable or contain a syntax error. + +}); + +navigator.serviceWorker.getRegistration('/app').then(function(registration: ServiceWorkerRegistration) { + +}); + +navigator.serviceWorker.getRegistrations().then(function(registrations: Array) { + +}); + +self.registration.unregister(); + +self.addEventListener('install', function(event: ExtendableEvent) { + event.waitUntil(self.skipWaiting()); +}); + +self.addEventListener('notificationclick', function(event: NotificationEvent) { + console.log('On notification click: ', event.notification.tag); + event.notification.close(); + + // This looks to see if the current is already open and + // focuses if it is + event.waitUntil(self.clients.matchAll({ + type: "window" + }).then(function(clientList) { + for (var i = 0; i < clientList.length; i++) { + var client = clientList[i]; + } + if (self.clients.openWindow) + return self.clients.openWindow('/'); + })); +}); \ No newline at end of file diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts new file mode 100644 index 0000000000..f9b2981463 --- /dev/null +++ b/service_worker_api/service_worker_api.d.ts @@ -0,0 +1,896 @@ +// Type definitions for service_worker_api +// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API +// Definitions by: Tristan Caron +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * Provides methods relating to the body of the response/request, allowing you + * to declare what its content type is and how it should be handled. + */ +interface Body { + /** + * Contains a Boolean that indicates whether the body has been read. + * @readonly + */ + bodyUsed: boolean; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with an ArrayBuffer. + */ + arrayBuffer(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a Blob. + */ + blob(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a FormData object. + */ + formData(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a JSON object. + */ + json(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a USVString (text). + */ + text(): Promise; + +} + +/** + * Represents response/request headers, allowing you to query them and take + * different actions depending on the results. + */ +interface Header { + new(): Header; + + /** + * Appends a new value onto an existing header inside a Headers object, or + * adds the header if it does not already exist. + * + * @param name The name of the HTTP header you want to add to the Headers + * object. + * @param value The value of the HTTP header you want to add. + */ + append(name: string, value: string): void; + + /** + * Deletes a header from a Headers object. + * + * @param name The name of the HTTP header you want to delete from the + * Headers object. + */ + delete(name: string): void; + + /** + * Returns the first value of a given header from within a Headers object. + * + * @param name The name of the HTTP header whose value you want to retrieve + * from the Headers object. If the given name is not the name of an + * HTTP header, this method throws a TypeError. + */ + get(name: string): string; + + /** + * Returns an array of all the values of a header within a Headers object + * with a given name. + * + * @param name The name of the HTTP header whose values you want to retrieve + * from the Headers object. If the given name is not the name of an + * HTTP header, this method throws a TypeError. + */ + getAll(name:string): Array; + + /** + * Returns a boolean stating whether a Headers object contains a + * certain header. + * + * @param name The name of the HTTP header you want to test for. If the + * given name is not the name of an HTTP header, this method throws + * a TypeError. + */ + has(name: string): boolean; + + /** + * Sets a new value for an existing header inside a Headers object, or + * adds the header if it does not already exist. + * + * @param name The name of the HTTP header you want to set to a new value. + * If the given name is not the name of an HTTP header, this method throws + * a TypeError. + * @param value The new value you want to set. + */ + set(name: string, value: string): void; +} + +/** + * Represents the response to a request. + */ +interface Response extends Body { + new(): Response; + + /** + * Contains the type of the response (e.g., basic, cors). + * @readonly + */ + type: string; + + /** + * Contains the URL of the response. + * @readonly + */ + url: string; + + /** + * Contains a boolean stating whether this is the final URL of the response. + */ + useFinalURL: boolean; + + /** + * Contains the status code of the response (e.g., 200 for a success). + * @readonly + */ + status: number; + + /** + * Contains a boolean stating whether the response was successful + * (status in the range 200-299) or not. + * @readonly + */ + ok: boolean; + + /** + * Contains the status message corresponding to the status code + * (e.g., OK for 200). + * @readonly + */ + statusText: string; + + /** + * Contains the Headers object associated with the response. + * @readonly + */ + headers: Header; + + /** + * Creates a clone of a Response object. + */ + clone(): Response; + + /** + * Returns a new Response object associated with a network error. + */ + error(): Response; + + /** + * Creates a new response with a different URL. + */ + redirect(): Response; +} + +/** + * Represents a resource request. + */ +interface Request extends Body { + new(): Request; + + /** + * Contains the request's method (GET, POST, etc.). + * @readonly + */ + method: string; + + /** + * Contains the URL of the request. + * @readonly + */ + url: string; + + /** + * Contains the associated Headers object of the request. + * @readonly + */ + headers: Header; + + /** + * Contains the context of the request (e.g., audio, image, iframe, etc.). + * @readonly + */ + context: string; + + /** + * Contains the referrer of the request (e.g., client). + * @readonly + */ + referrer: string; + + /** + * Contains the mode of the request (e.g., cors, no-cors, same-origin). + * @readonly + */ + mode: string; + + /** + * Contains the credentials of the request (e.g., omit, same-origin). + * @readonly + */ + credentials: string; + + /** + * Contains the cache mode of the request (e.g., default, reload, no-cache). + * @readonly + */ + cache: string; + + /** + * Creates a copy of the current Request object. + */ + clone(): Request; +} + +/** + * An CacheOptions object allowing you to set specific control options for the + * matching done in the match operation. + * + * @property [ignoreSearch] A Boolean that specifies whether the matching + * process should ignore the query string in the url. If set to true, + * the ?value=bar part of http://foo.com/?value=bar would be ignored when + * performing a match. It defaults to false. + * + * @property [ignoreMethod] A Boolean that, when set to true, prevents matching + * operations from validating the Request http method (normally only GET + * and HEAD are allowed.) It defaults to false. + * + * @property [ignoreVary] A Boolean that when set to true tells the matching + * operation not to perform VARY header matching — i.e. if the URL matches you + * will get a match regardless of the Response object having a VARY header or + * not. It defaults to false. + * + * @property [cacheName] A DOMString that represents a specific cache to search + * within. Note that this option is ignored by Cache.match(). + */ +interface CacheOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +/** + * Represents the storage for Request / Response object pairs that are cached as + * part of the ServiceWorker life cycle. + */ +interface Cache { + /** + * Returns a Promise that resolves to the response associated with the first + * matching request in the Cache object. + * + * @param request The Request you are attempting to find in the Cache. + * @param {CacheOptions} options + */ + match(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to an array of all matching requests in + * the Cache object. + * + * @param request The Request you are attempting to find in the Cache. + * @param {CacheOptions} options + */ + matchAll(request: Request | string, options?: CacheOptions): Promise>; + + /** + * Returns a Promise that resolves to a new Cache entry whose key + * is the request. + * + * @param request The Request you want to add to the cache. + */ + add(request: Request | string): Promise; + + /** + * Returns a Promise that resolves to a new array of Cache entries whose + * keys are the requests. + * + * @param request An array of Request objects you want to add to the cache. + */ + addAll(...request: Array): Promise; + + /** + * Adds additional key/value pairs to the current Cache object. + * + * @param request The Request you want to add to the cache. + * @param response The response you want to match up to the request. + */ + put(request: Request, response: Response): Promise; + + /** + * Finds the Cache entry whose key is the request, and if found, deletes the + * Cache entry and returns a Promise that resolves to true. If no Cache + * entry is found, it returns false. + * + * @param request The Request you are looking to delete. + * @param {CacheOptions} options + */ + delete(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to an array of Cache keys. + * + * @param request The Request want to return, if a specific key is desired. + * @param {CacheOptions} options + */ + keys(request?: Request, options?: CacheOptions): Promise>; +} + +/** + * Represents the storage for Cache objects. It provides a master directory of + * all the named caches that a ServiceWorker can access and maintains a mapping + * of string names to corresponding Cache objects. + */ +interface CacheStorage { + /** + * Checks if a given Request is a key in any of the Cache objects that the + * CacheStorage object tracks and returns a Promise that resolves + * to that match. + * + * @param request The Request you are looking for a match for in the CacheStorage. + * @param {CacheOptions} options + */ + match(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to true if a Cache object matching + * the cacheName exists. + * + * @param cacheName The Request you are looking for a match for in the + * CacheStorage. + */ + has(cacheName: string): Promise; + + /** + * Returns a Promise that resolves to the Cache object matching + * the cacheName. + * + * @param cacheName The name of the cache you want to open. + */ + open(cacheName: string): Promise; + + /** + * Finds the Cache object matching the cacheName, and if found, deletes the + * Cache object and returns a Promise that resolves to true. If no + * Cache object is found, it returns false. + * + * @param cacheName The name of the cache you want to delete. + */ + delete(cacheName: string): Promise; + + /** + * Returns a Promise that will resolve with an array containing strings + * corresponding to all of the named Cache objects tracked by the + * CacheStorage. Use this method to iterate over a list of all the + * Cache objects. + */ + keys(): Promise>; +} + +/** + * Represents the scope of a service worker client. A service worker client is + * either a document in a browser context or a SharedWorker, which is controlled + * by an active worker. + */ +interface ServiceWorkerClient { + /** + * Allows a service worker client to send a message to a ServiceWorker. + * + * @param message The message to send to the service worker. + * @param [transfer] A transferable object such as, for example, a reference + * to a port. + */ + postMessage(message: string, transfer?: Object): void; + + /** + * Indicates the type of browsing context of the current client. + * This value can be one of auxiliary, top-level, nested, or none. + * @readonly + */ + frameType: string; + + /** + * Returns the id of the Client object. + * @readonly + */ + id: string; + + /** + * The URL of the current service worker client. + * @readonly + */ + url: string; +} + +interface WindowClient extends ServiceWorkerClient { + /** + * Gives user input focus to the current client. + */ + focus(): Promise; + + /** + * A boolean that indicates whether the current client has focus. + * @readonly + */ + focused: boolean; + + /** + * Indicates the visibility of the current client. This value can be one of + * hidden, visible, prerender, or unloaded. + * @readonly + */ + visibilityState: string; +} + +interface ServiceWorkerClientsMatchOptions { + includeUncontrolled?: boolean; + type?: string; +} + +/** + * Represents a container for a list of Client objects; the main way to access + * the active service worker clients at the current origin. + */ +interface ServiceWorkerClients { + /** + * Gets a list of service worker clients and returns them in a Promise. + * Include the options parameter to return all service worker clients whose + * origin is the same as the associated service worker's origin. If options + * are not included, the method returns only the service worker clients + * controlled by the service worker. + * + * @param options + */ + matchAll(options: ServiceWorkerClientsMatchOptions): Promise>; + + /** + * Opens a service worker Client in a new browser window. + * + * @param url A string representing the URL of the client you want to open + * in the window. + */ + openWindow(url: string): Promise; + + /** + * Allows an active Service Worker to set itself as the active worker for a + * client page when the worker and the page are in the same scope. + */ + claim(): Promise; +} + +/** + * Extends the lifetime of the install and activate events dispatched on the + * ServiceWorkerGlobalScope as part of the service worker lifecycle. This + * ensures that any functional events (like FetchEvent) are not dispatched to + * the ServiceWorker until it upgrades database schemas, deletes outdated cache + * entries, etc. + */ +interface ExtendableEvent extends Event { + /** + * Extends the lifetime of the event. + * It is intended to be called in the install EventHandler for the + * installing worker and on the active EventHandler for the active worker. + * + * @param all + */ + waitUntil(all: any): any; +} + +/** + * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, + * FetchEvent represents a fetch action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about + * the request and resulting response, and provides the FetchEvent.respondWith() + * method, which allows us to provide an arbitrary response back to the + * controlled page. + */ +interface FetchEvent extends Event { + /** + * Returns a Boolean that is true if the event was dispatched with the + * user's intention for the page to reload, and false otherwise. Typically, + * pressing the refresh button in a browser is a reload, while clicking a + * link and pressing the back button is not. + * @readonly + */ + isReload: boolean; + + /** + * Returns the Request that triggered the event handler. + * @readonly + */ + request: Request; + + /** + * Returns the Client that the current service worker is controlling. + * @readonly + */ + client: ServiceWorkerClient; + + /** + * Resolves by returning a Response or a network error to Fetch. + * + * @param any + */ + respondWith(any): Response; +} + +/** + * Represents a service worker. Multiple browsing contexts (e.g. pages, workers, + * etc.) can be associated with the same ServiceWorker object. + */ +interface ServiceWorker extends Worker { + /** + * Returns the ServiceWorker serialized script URL defined as part of + * ServiceWorkerRegistration. The URL must be on the same origin as the + * document that registers the ServiceWorker. + * @readonly + */ + scriptURL: string; + + /** + * Returns the state of the service worker. It returns one of the following + * values: installing, installed, activating, activated, or redundant. + * @readonly + */ + state: string; + + /** + * An EventListener property called whenever an event of type statechange + * is fired; it is basically fired anytime the ServiceWorker.state changes. + * + * @param [statechangeevent] + */ + onstatechange: (statechangeevent?: Event) => void; +} + +/** + * The PushSubscription interface provides a subcription's URL endpoint and + * subscription ID. + */ +interface PushSubscription { + /** + * The endpoint associated with the push subscription. + * @readonly + */ + endpoint: any; + + /** + * The subscription ID associated with the push subscription. + * @readonly + */ + subscriptionId: any; +} + +/** + * The PushManager interface provides a way to receive notifications from + * third-party servers as well as request URLs for push notifications. + * This interface has replaced functionality offered by the obsolete + * PushRegistrationManager. + */ +interface PushManager { + /** + * Returns a promise that resolves to a PushSubscription with details of a + * new push subscription. + */ + subscribe(): Promise; + + /** + * Returns a promise that resolves to a PushSubscription details of + * the retrieved push subscription. + */ + getSubscription(): Promise; + + /** + * Returns a promise that resolves to the PushPermissionStatus of the + * requesting webapp, which will be one of granted, denied, or default. + */ + hasPermission(): Promise; +} + +/** + * Represents a service worker registration. + */ +interface ServiceWorkerRegistration extends EventTarget { + /** + * Returns a unique identifier for a service worker registration. + * This must be on the same origin as the document that registers + * the ServiceWorker. + * @readonly + */ + scope: any; + + /** + * Returns a service worker whose state is installing. This is initially + * set to null. + * @readonly + */ + installing: ServiceWorker; + + /** + * Returns a service worker whose state is installed. This is initially + * set to null. + * @readonly + */ + waiting: ServiceWorker; + + /** + * Returns a service worker whose state is either activating or activated. + * This is initially set to null. An active worker will control a + * ServiceWorkerClient if the client's URL falls within the scope of the + * registration (the scope option set when ServiceWorkerContainer.register + * is first called). + * @readonly + */ + active: ServiceWorker; + + /** + * Returns an interface to for managing push subscriptions, including + * subcribing, getting an anctive subscription, and accessing push + * permission status. + * @readonly + */ + pushManager: PushManager; + + /** + * An EventListener property called whenever an event of type updatefound + * is fired; it is fired any time the ServiceWorkerRegistration.installing + * property acquires a new service worker. + */ + onupdatefound: () => void; + + /** + * Allows you to update a service worker. + */ + update(); + + /** + * Unregisters the service worker registration and returns a promise + * (see Promise). The service worker will finish any ongoing operations + * before it is unregistered. + */ + unregister(): Promise; +} + +interface ServiceWorkerRegisterOptions { + scope: string; +} + +/** + * Provides an object representing the service worker as an overall unit in the + * network ecosystem, including facilities to register, unregister and update + * service workers, and access the state of service workers + * and their registrations. + */ +interface ServiceWorkerContainer { + /** + * Returns a ServiceWorker object if its state is activated (the same object + * returned by ServiceWorkerRegistration.active). This property returns null + * if the request is a force refresh (Shift + refresh) or if there is no + * active worker. + * @readonly + */ + controller: ServiceWorker; + + /** + * Defines whether a service worker is ready to control a page or not. + * It returns a Promise that will never reject, which resolves to a + * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker. + * @readonly + */ + ready: Promise; + + /** + * An event handler fired whenever a controllerchange event occurs — when + * the document's associated ServiceWorkerRegistration acquires a new + * ServiceWorkerRegistration.active worker. + * + * @param [controllerchangeevent] + */ + oncontrollerchange: (controllerchangeevent?: Event) => void; + + /** + * An event handler fired whenever an error event occurs in the associated + * service workers. + * + * @param [errorevent] + */ + onerror: (errorevent?: ErrorEvent) => void; + + /** + * An event handler fired whenever a message event occurs — when incoming + * messages are received to the ServiceWorkerContainer object (e.g. via a + * MessagePort.postMessage() call.) + * + * @param [messageevent] + */ + onmessage: (messageevent?: MessageEvent) => void; + + /** + * Creates or updates a ServiceWorkerRegistration for the given scriptURL. + * + * @param scriptURL The URL of the service worker script. + * @param [options] An options object to provide options upon registration. + * Currently available options are: scope: A USVString representing a URL + * that defines a service worker's registration scope; what range of URLs a + * service worker can control. This is usually a relative URL, and it + * defaults to '/' when not specified. + */ + register(scriptURL: string, options?: ServiceWorkerRegisterOptions): Promise; + + /** + * Gets a ServiceWorkerRegistration object whose scope URL matches the + * provided document URL. If the method can't return a + * ServiceWorkerRegistration, it returns a Promise. + * + * @param [scope] A unique identifier for a service worker registration — the + * scope URL of the registration object you want to return. This is usually + * a relative URL. + */ + getRegistration(scope?: string): Promise; + + /** + * Returns all ServiceWorkerRegistrations associated with a + * ServiceWorkerContainer in an array. If the method can't return + * ServiceWorkerRegistrations, it returns a Promise. + */ + getRegistrations(): Promise>; +} + +/** + * The parameter passed into the oninstall handler, the InstallEvent interface + * represents an install action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, + * it ensures that functional events such as FetchEvent are not dispatched + * during installation. + */ +interface InstallEvent extends ExtendableEvent { + /** + * Returns the ServiceWorker that is currently actively controlling the page. + * @readonly + */ + activeWorker: ServiceWorker; +} + +interface ServiceWorkerGlobalScope { + /** + * Contains the Clients object associated with the service worker. + * @readonly + */ + clients: ServiceWorkerClients; + + /** + * Contains the ServiceWorkerRegistration object that represents the + * service worker's registration. + * @readonly + */ + registration: ServiceWorkerRegistration; + + /** + * An event handler fired whenever an activate event occurs — when a + * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active + * worker. + * + * @param [activateevent] + */ + onactivate: (activateevent?: ExtendableEvent) => void; + + /** + * Not defined in the spec yet, but it looks like this will be fired when + * the device is nearly out of storage space, prompting the UA to start + * claiming back some space from web apps that are using client-side storage, + * and the current app is targeted. + * + * @param [beforeevictedevent] + */ + onbeforeevicted: (beforeevictedevent?: Event) => void; + + /** + * Not defined in the spec yet, but it looks like this will be fired when + * the device is out of storage space, and the UA claims back some space + * from the current app. + * + * @param [evictedevent] + */ + onevicted: (evictedevent?: Event) => void; + + /** + * An event handler fired whenever a fetch event occurs — when a fetch() + * is called. + * + * @param [fetchevent] + */ + onfetch: (fetchevent?: FetchEvent) => void; + + /** + * An event handler fired whenever an install event occurs — when a + * ServiceWorkerRegistration acquires a new + * ServiceWorkerRegistration.installing worker. + * + * @param [installevent] + */ + oninstall: (installevent?: InstallEvent) => void; + + /** + * An event handler fired whenever a message event occurs — when incoming + * messages are received. Controlled pages can use the + * MessagePort.postMessage() method to send messages to service workers. + * The service worker can optionally send a response back via the + * MessagePort exposed in event.data.port, corresponding to the controlled + * page. + * + * @param [messageevent] + */ + onmessage: (messageevent?: MessageEvent) => void; + + /** + * An event handler fired whenever a notificationclick event occurs — when + * a user clicks on a displayed notification. + * + * @param [notificationclickevent] + */ + onnotificationclick: (notificationclickevent?: NotificationEvent) => void; + + /** + * An event handler fired whenever a push event occurs — when a server + * push notification is received. + * + * @param [onpushevent] + */ + onpush: (onpushevent?: Event) => void; + + /** + * An event handler fired whenever a pushsubscriptionchange event occurs — + * when a push subscription has been invalidated, or is about to be + * invalidated (e.g. when a push service sets an expiration time). + * + * @param [pushsubscriptionchangeevent] + */ + onpushsubscriptionchange: (pushsubscriptionchangeevent?: Event) => void; + + /** + * Allows the current service worker registration to progress from waiting + * to active state while service worker clients are using it. + */ + skipWaiting(): Promise; + + /** + * TODO GlobalFetch + * @param url + * @param init + */ + fetch(url: string | Request, init?: Object): Promise; +} + +interface Navigator { + /** + * Returns a ServiceWorkerContainer object, which provides access to + * registration, removal, upgrade, and communication with the ServiceWorker + * objects for the associated document. + */ + serviceWorker: ServiceWorkerContainer; +} + +interface Window extends ServiceWorkerGlobalScope { + caches: CacheStorage; +} + +interface NotificationEvent extends Event, ExtendableEvent { + notification: any; +} \ No newline at end of file From 8164f9d8b9123bf8c71f555276ef826d7a0a9d37 Mon Sep 17 00:00:00 2001 From: tristancaron Date: Mon, 23 Mar 2015 20:25:42 +0100 Subject: [PATCH 0002/1850] Revert "Service Worker Api" This reverts commit 80fd9daed79eb612c3c323fa25e1eb01062d56f4. --- service_worker_api/service_worker_api-test.ts | 188 ---- service_worker_api/service_worker_api.d.ts | 896 ------------------ 2 files changed, 1084 deletions(-) delete mode 100644 service_worker_api/service_worker_api-test.ts delete mode 100644 service_worker_api/service_worker_api.d.ts diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts deleted file mode 100644 index 67ce58cd40..0000000000 --- a/service_worker_api/service_worker_api-test.ts +++ /dev/null @@ -1,188 +0,0 @@ -/// - -var OFFLINE_CACHE = "cache_test"; -var OFFLINE_URL = "localhost"; - -self.addEventListener('fetch', function(event: FetchEvent) { - if (event.request.method === 'GET' && - event.request.headers.get('accept').indexOf('text/html') !== -1) { - console.log('Handling fetch event for', event.request.url); - event.respondWith( - self.fetch(event.request).catch(function(e) { - console.error('Fetch failed; returning offline page instead.', e); - return self.caches.open(OFFLINE_CACHE).then(function(cache: Cache) { - return cache.match(OFFLINE_URL); - }); - }) - ); - } -}); - -self.caches.open('v1').then(function(cache: Cache) { - cache.matchAll('/images/').then(function(response: Array) { - response.forEach(function(element, index, array) { - cache.delete(element); - - }); - }); - -}); - -self.addEventListener('install', function(event: InstallEvent) { - event.waitUntil( - self.caches.open('v1').then(function(cache: Cache) { - return cache.add('/sw-test/index.html'); - }) - ); -}); - -self.addEventListener('install', function(event: InstallEvent) { - event.waitUntil( - self.caches.open('v1').then(function(cache) { - return cache.addAll( - '/sw-test/', - '/sw-test/index.html', - '/sw-test/style.css', - '/sw-test/app.js', - '/sw-test/image-list.js', - '/sw-test/star-wars-logo.jpg', - '/sw-test/gallery/', - '/sw-test/gallery/bountyHunters.jpg', - '/sw-test/gallery/myLittleVader.jpg', - '/sw-test/gallery/snowTroopers.jpg' - ); - }) - ); -}); - -self.addEventListener('fetch', function(event: FetchEvent) { - var cachedResponse = self.caches.match(event.request).catch(function() { - return self.fetch(event.request).then(function(response: Response) { - return self.caches.open('v1').then(function(cache) { - cache.put(event.request, response.clone()); - return response; - }); - }); - }).catch(function() { - return self.caches.match('/sw-test/gallery/myLittleVader.jpg'); - }); - - event.respondWith(cachedResponse); -}); - -self.caches.open('v1').then(function(cache) { - cache.match('/images/image.png').then(function(response) { - cache.delete(response); - }); -}); - -self.caches.open('v1').then(function(cache: Cache) { - cache.keys().then(function(response) { - response.forEach(function(element, index, array) { - cache.delete(element); - }); - }); -}); - -self.caches.has('v1').then(function() { - self.caches.delete('v1').then(function() { - - }); -}); - -self.addEventListener('activate', function(event: ExtendableEvent) { - var cacheWhitelist = ['v2']; - - event.waitUntil( - self.caches.keys().then(function(keyList) { - for(var i = 0; i < keyList.length; i++) { - if (cacheWhitelist.indexOf(keyList[i]) === -1) { - return self.caches.delete(keyList[i]); - } - } - }) - ); -}); - -function sendMessage(message) { - return new Promise(function(resolve, reject) { - var messageChannel = new MessageChannel(); - messageChannel.port1.onmessage = function(event) { - if (event.data.error) { - reject(event.data.error); - } else { - resolve(event.data); - } - }; - navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]); - }); -} - -self.clients.matchAll({type: "test"}).then(function(clients) { - for(var i = 0 ; i < clients.length ; i++) { - if(clients[i].url === 'index.html') { - self.clients.openWindow(clients[i].url); - // or do something else involving the matching client - } - } -}); - -self.addEventListener('activate', function(e: ExtendableEvent) { - e.waitUntil(self.clients.claim()); -}); - -navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(function(registration) { - // At this point, registration has taken place. - // The service worker will not handle requests until this page and any - // other instances of this page (in other tabs, etc.) have been - // closed/reloaded. - var serviceWorker; - if (registration.installing) { - serviceWorker = registration.installing; - } else if (registration.waiting) { - serviceWorker = registration.waiting; - } else if (registration.active) { - serviceWorker = registration.active; - } - if (serviceWorker) { - console.log(serviceWorker.state); - serviceWorker.addEventListener('statechange', function(e) { - console.log(e.target.state); - }); - } -}).catch(function(error) { - // Something went wrong during registration. The service-worker.js file - // might be unavailable or contain a syntax error. - -}); - -navigator.serviceWorker.getRegistration('/app').then(function(registration: ServiceWorkerRegistration) { - -}); - -navigator.serviceWorker.getRegistrations().then(function(registrations: Array) { - -}); - -self.registration.unregister(); - -self.addEventListener('install', function(event: ExtendableEvent) { - event.waitUntil(self.skipWaiting()); -}); - -self.addEventListener('notificationclick', function(event: NotificationEvent) { - console.log('On notification click: ', event.notification.tag); - event.notification.close(); - - // This looks to see if the current is already open and - // focuses if it is - event.waitUntil(self.clients.matchAll({ - type: "window" - }).then(function(clientList) { - for (var i = 0; i < clientList.length; i++) { - var client = clientList[i]; - } - if (self.clients.openWindow) - return self.clients.openWindow('/'); - })); -}); \ No newline at end of file diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts deleted file mode 100644 index f9b2981463..0000000000 --- a/service_worker_api/service_worker_api.d.ts +++ /dev/null @@ -1,896 +0,0 @@ -// Type definitions for service_worker_api -// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API -// Definitions by: Tristan Caron -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -/** - * Provides methods relating to the body of the response/request, allowing you - * to declare what its content type is and how it should be handled. - */ -interface Body { - /** - * Contains a Boolean that indicates whether the body has been read. - * @readonly - */ - bodyUsed: boolean; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with an ArrayBuffer. - */ - arrayBuffer(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a Blob. - */ - blob(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a FormData object. - */ - formData(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a JSON object. - */ - json(): Promise; - - /** - * Takes a Response stream and reads it to completion. - * It returns a promise that resolves with a USVString (text). - */ - text(): Promise; - -} - -/** - * Represents response/request headers, allowing you to query them and take - * different actions depending on the results. - */ -interface Header { - new(): Header; - - /** - * Appends a new value onto an existing header inside a Headers object, or - * adds the header if it does not already exist. - * - * @param name The name of the HTTP header you want to add to the Headers - * object. - * @param value The value of the HTTP header you want to add. - */ - append(name: string, value: string): void; - - /** - * Deletes a header from a Headers object. - * - * @param name The name of the HTTP header you want to delete from the - * Headers object. - */ - delete(name: string): void; - - /** - * Returns the first value of a given header from within a Headers object. - * - * @param name The name of the HTTP header whose value you want to retrieve - * from the Headers object. If the given name is not the name of an - * HTTP header, this method throws a TypeError. - */ - get(name: string): string; - - /** - * Returns an array of all the values of a header within a Headers object - * with a given name. - * - * @param name The name of the HTTP header whose values you want to retrieve - * from the Headers object. If the given name is not the name of an - * HTTP header, this method throws a TypeError. - */ - getAll(name:string): Array; - - /** - * Returns a boolean stating whether a Headers object contains a - * certain header. - * - * @param name The name of the HTTP header you want to test for. If the - * given name is not the name of an HTTP header, this method throws - * a TypeError. - */ - has(name: string): boolean; - - /** - * Sets a new value for an existing header inside a Headers object, or - * adds the header if it does not already exist. - * - * @param name The name of the HTTP header you want to set to a new value. - * If the given name is not the name of an HTTP header, this method throws - * a TypeError. - * @param value The new value you want to set. - */ - set(name: string, value: string): void; -} - -/** - * Represents the response to a request. - */ -interface Response extends Body { - new(): Response; - - /** - * Contains the type of the response (e.g., basic, cors). - * @readonly - */ - type: string; - - /** - * Contains the URL of the response. - * @readonly - */ - url: string; - - /** - * Contains a boolean stating whether this is the final URL of the response. - */ - useFinalURL: boolean; - - /** - * Contains the status code of the response (e.g., 200 for a success). - * @readonly - */ - status: number; - - /** - * Contains a boolean stating whether the response was successful - * (status in the range 200-299) or not. - * @readonly - */ - ok: boolean; - - /** - * Contains the status message corresponding to the status code - * (e.g., OK for 200). - * @readonly - */ - statusText: string; - - /** - * Contains the Headers object associated with the response. - * @readonly - */ - headers: Header; - - /** - * Creates a clone of a Response object. - */ - clone(): Response; - - /** - * Returns a new Response object associated with a network error. - */ - error(): Response; - - /** - * Creates a new response with a different URL. - */ - redirect(): Response; -} - -/** - * Represents a resource request. - */ -interface Request extends Body { - new(): Request; - - /** - * Contains the request's method (GET, POST, etc.). - * @readonly - */ - method: string; - - /** - * Contains the URL of the request. - * @readonly - */ - url: string; - - /** - * Contains the associated Headers object of the request. - * @readonly - */ - headers: Header; - - /** - * Contains the context of the request (e.g., audio, image, iframe, etc.). - * @readonly - */ - context: string; - - /** - * Contains the referrer of the request (e.g., client). - * @readonly - */ - referrer: string; - - /** - * Contains the mode of the request (e.g., cors, no-cors, same-origin). - * @readonly - */ - mode: string; - - /** - * Contains the credentials of the request (e.g., omit, same-origin). - * @readonly - */ - credentials: string; - - /** - * Contains the cache mode of the request (e.g., default, reload, no-cache). - * @readonly - */ - cache: string; - - /** - * Creates a copy of the current Request object. - */ - clone(): Request; -} - -/** - * An CacheOptions object allowing you to set specific control options for the - * matching done in the match operation. - * - * @property [ignoreSearch] A Boolean that specifies whether the matching - * process should ignore the query string in the url. If set to true, - * the ?value=bar part of http://foo.com/?value=bar would be ignored when - * performing a match. It defaults to false. - * - * @property [ignoreMethod] A Boolean that, when set to true, prevents matching - * operations from validating the Request http method (normally only GET - * and HEAD are allowed.) It defaults to false. - * - * @property [ignoreVary] A Boolean that when set to true tells the matching - * operation not to perform VARY header matching — i.e. if the URL matches you - * will get a match regardless of the Response object having a VARY header or - * not. It defaults to false. - * - * @property [cacheName] A DOMString that represents a specific cache to search - * within. Note that this option is ignored by Cache.match(). - */ -interface CacheOptions { - ignoreSearch?: boolean; - ignoreMethod?: boolean; - ignoreVary?: boolean; - cacheName?: string; -} - -/** - * Represents the storage for Request / Response object pairs that are cached as - * part of the ServiceWorker life cycle. - */ -interface Cache { - /** - * Returns a Promise that resolves to the response associated with the first - * matching request in the Cache object. - * - * @param request The Request you are attempting to find in the Cache. - * @param {CacheOptions} options - */ - match(request: Request | string, options?: CacheOptions): Promise; - - /** - * Returns a Promise that resolves to an array of all matching requests in - * the Cache object. - * - * @param request The Request you are attempting to find in the Cache. - * @param {CacheOptions} options - */ - matchAll(request: Request | string, options?: CacheOptions): Promise>; - - /** - * Returns a Promise that resolves to a new Cache entry whose key - * is the request. - * - * @param request The Request you want to add to the cache. - */ - add(request: Request | string): Promise; - - /** - * Returns a Promise that resolves to a new array of Cache entries whose - * keys are the requests. - * - * @param request An array of Request objects you want to add to the cache. - */ - addAll(...request: Array): Promise; - - /** - * Adds additional key/value pairs to the current Cache object. - * - * @param request The Request you want to add to the cache. - * @param response The response you want to match up to the request. - */ - put(request: Request, response: Response): Promise; - - /** - * Finds the Cache entry whose key is the request, and if found, deletes the - * Cache entry and returns a Promise that resolves to true. If no Cache - * entry is found, it returns false. - * - * @param request The Request you are looking to delete. - * @param {CacheOptions} options - */ - delete(request: Request | string, options?: CacheOptions): Promise; - - /** - * Returns a Promise that resolves to an array of Cache keys. - * - * @param request The Request want to return, if a specific key is desired. - * @param {CacheOptions} options - */ - keys(request?: Request, options?: CacheOptions): Promise>; -} - -/** - * Represents the storage for Cache objects. It provides a master directory of - * all the named caches that a ServiceWorker can access and maintains a mapping - * of string names to corresponding Cache objects. - */ -interface CacheStorage { - /** - * Checks if a given Request is a key in any of the Cache objects that the - * CacheStorage object tracks and returns a Promise that resolves - * to that match. - * - * @param request The Request you are looking for a match for in the CacheStorage. - * @param {CacheOptions} options - */ - match(request: Request | string, options?: CacheOptions): Promise; - - /** - * Returns a Promise that resolves to true if a Cache object matching - * the cacheName exists. - * - * @param cacheName The Request you are looking for a match for in the - * CacheStorage. - */ - has(cacheName: string): Promise; - - /** - * Returns a Promise that resolves to the Cache object matching - * the cacheName. - * - * @param cacheName The name of the cache you want to open. - */ - open(cacheName: string): Promise; - - /** - * Finds the Cache object matching the cacheName, and if found, deletes the - * Cache object and returns a Promise that resolves to true. If no - * Cache object is found, it returns false. - * - * @param cacheName The name of the cache you want to delete. - */ - delete(cacheName: string): Promise; - - /** - * Returns a Promise that will resolve with an array containing strings - * corresponding to all of the named Cache objects tracked by the - * CacheStorage. Use this method to iterate over a list of all the - * Cache objects. - */ - keys(): Promise>; -} - -/** - * Represents the scope of a service worker client. A service worker client is - * either a document in a browser context or a SharedWorker, which is controlled - * by an active worker. - */ -interface ServiceWorkerClient { - /** - * Allows a service worker client to send a message to a ServiceWorker. - * - * @param message The message to send to the service worker. - * @param [transfer] A transferable object such as, for example, a reference - * to a port. - */ - postMessage(message: string, transfer?: Object): void; - - /** - * Indicates the type of browsing context of the current client. - * This value can be one of auxiliary, top-level, nested, or none. - * @readonly - */ - frameType: string; - - /** - * Returns the id of the Client object. - * @readonly - */ - id: string; - - /** - * The URL of the current service worker client. - * @readonly - */ - url: string; -} - -interface WindowClient extends ServiceWorkerClient { - /** - * Gives user input focus to the current client. - */ - focus(): Promise; - - /** - * A boolean that indicates whether the current client has focus. - * @readonly - */ - focused: boolean; - - /** - * Indicates the visibility of the current client. This value can be one of - * hidden, visible, prerender, or unloaded. - * @readonly - */ - visibilityState: string; -} - -interface ServiceWorkerClientsMatchOptions { - includeUncontrolled?: boolean; - type?: string; -} - -/** - * Represents a container for a list of Client objects; the main way to access - * the active service worker clients at the current origin. - */ -interface ServiceWorkerClients { - /** - * Gets a list of service worker clients and returns them in a Promise. - * Include the options parameter to return all service worker clients whose - * origin is the same as the associated service worker's origin. If options - * are not included, the method returns only the service worker clients - * controlled by the service worker. - * - * @param options - */ - matchAll(options: ServiceWorkerClientsMatchOptions): Promise>; - - /** - * Opens a service worker Client in a new browser window. - * - * @param url A string representing the URL of the client you want to open - * in the window. - */ - openWindow(url: string): Promise; - - /** - * Allows an active Service Worker to set itself as the active worker for a - * client page when the worker and the page are in the same scope. - */ - claim(): Promise; -} - -/** - * Extends the lifetime of the install and activate events dispatched on the - * ServiceWorkerGlobalScope as part of the service worker lifecycle. This - * ensures that any functional events (like FetchEvent) are not dispatched to - * the ServiceWorker until it upgrades database schemas, deletes outdated cache - * entries, etc. - */ -interface ExtendableEvent extends Event { - /** - * Extends the lifetime of the event. - * It is intended to be called in the install EventHandler for the - * installing worker and on the active EventHandler for the active worker. - * - * @param all - */ - waitUntil(all: any): any; -} - -/** - * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, - * FetchEvent represents a fetch action that is dispatched on the - * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about - * the request and resulting response, and provides the FetchEvent.respondWith() - * method, which allows us to provide an arbitrary response back to the - * controlled page. - */ -interface FetchEvent extends Event { - /** - * Returns a Boolean that is true if the event was dispatched with the - * user's intention for the page to reload, and false otherwise. Typically, - * pressing the refresh button in a browser is a reload, while clicking a - * link and pressing the back button is not. - * @readonly - */ - isReload: boolean; - - /** - * Returns the Request that triggered the event handler. - * @readonly - */ - request: Request; - - /** - * Returns the Client that the current service worker is controlling. - * @readonly - */ - client: ServiceWorkerClient; - - /** - * Resolves by returning a Response or a network error to Fetch. - * - * @param any - */ - respondWith(any): Response; -} - -/** - * Represents a service worker. Multiple browsing contexts (e.g. pages, workers, - * etc.) can be associated with the same ServiceWorker object. - */ -interface ServiceWorker extends Worker { - /** - * Returns the ServiceWorker serialized script URL defined as part of - * ServiceWorkerRegistration. The URL must be on the same origin as the - * document that registers the ServiceWorker. - * @readonly - */ - scriptURL: string; - - /** - * Returns the state of the service worker. It returns one of the following - * values: installing, installed, activating, activated, or redundant. - * @readonly - */ - state: string; - - /** - * An EventListener property called whenever an event of type statechange - * is fired; it is basically fired anytime the ServiceWorker.state changes. - * - * @param [statechangeevent] - */ - onstatechange: (statechangeevent?: Event) => void; -} - -/** - * The PushSubscription interface provides a subcription's URL endpoint and - * subscription ID. - */ -interface PushSubscription { - /** - * The endpoint associated with the push subscription. - * @readonly - */ - endpoint: any; - - /** - * The subscription ID associated with the push subscription. - * @readonly - */ - subscriptionId: any; -} - -/** - * The PushManager interface provides a way to receive notifications from - * third-party servers as well as request URLs for push notifications. - * This interface has replaced functionality offered by the obsolete - * PushRegistrationManager. - */ -interface PushManager { - /** - * Returns a promise that resolves to a PushSubscription with details of a - * new push subscription. - */ - subscribe(): Promise; - - /** - * Returns a promise that resolves to a PushSubscription details of - * the retrieved push subscription. - */ - getSubscription(): Promise; - - /** - * Returns a promise that resolves to the PushPermissionStatus of the - * requesting webapp, which will be one of granted, denied, or default. - */ - hasPermission(): Promise; -} - -/** - * Represents a service worker registration. - */ -interface ServiceWorkerRegistration extends EventTarget { - /** - * Returns a unique identifier for a service worker registration. - * This must be on the same origin as the document that registers - * the ServiceWorker. - * @readonly - */ - scope: any; - - /** - * Returns a service worker whose state is installing. This is initially - * set to null. - * @readonly - */ - installing: ServiceWorker; - - /** - * Returns a service worker whose state is installed. This is initially - * set to null. - * @readonly - */ - waiting: ServiceWorker; - - /** - * Returns a service worker whose state is either activating or activated. - * This is initially set to null. An active worker will control a - * ServiceWorkerClient if the client's URL falls within the scope of the - * registration (the scope option set when ServiceWorkerContainer.register - * is first called). - * @readonly - */ - active: ServiceWorker; - - /** - * Returns an interface to for managing push subscriptions, including - * subcribing, getting an anctive subscription, and accessing push - * permission status. - * @readonly - */ - pushManager: PushManager; - - /** - * An EventListener property called whenever an event of type updatefound - * is fired; it is fired any time the ServiceWorkerRegistration.installing - * property acquires a new service worker. - */ - onupdatefound: () => void; - - /** - * Allows you to update a service worker. - */ - update(); - - /** - * Unregisters the service worker registration and returns a promise - * (see Promise). The service worker will finish any ongoing operations - * before it is unregistered. - */ - unregister(): Promise; -} - -interface ServiceWorkerRegisterOptions { - scope: string; -} - -/** - * Provides an object representing the service worker as an overall unit in the - * network ecosystem, including facilities to register, unregister and update - * service workers, and access the state of service workers - * and their registrations. - */ -interface ServiceWorkerContainer { - /** - * Returns a ServiceWorker object if its state is activated (the same object - * returned by ServiceWorkerRegistration.active). This property returns null - * if the request is a force refresh (Shift + refresh) or if there is no - * active worker. - * @readonly - */ - controller: ServiceWorker; - - /** - * Defines whether a service worker is ready to control a page or not. - * It returns a Promise that will never reject, which resolves to a - * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker. - * @readonly - */ - ready: Promise; - - /** - * An event handler fired whenever a controllerchange event occurs — when - * the document's associated ServiceWorkerRegistration acquires a new - * ServiceWorkerRegistration.active worker. - * - * @param [controllerchangeevent] - */ - oncontrollerchange: (controllerchangeevent?: Event) => void; - - /** - * An event handler fired whenever an error event occurs in the associated - * service workers. - * - * @param [errorevent] - */ - onerror: (errorevent?: ErrorEvent) => void; - - /** - * An event handler fired whenever a message event occurs — when incoming - * messages are received to the ServiceWorkerContainer object (e.g. via a - * MessagePort.postMessage() call.) - * - * @param [messageevent] - */ - onmessage: (messageevent?: MessageEvent) => void; - - /** - * Creates or updates a ServiceWorkerRegistration for the given scriptURL. - * - * @param scriptURL The URL of the service worker script. - * @param [options] An options object to provide options upon registration. - * Currently available options are: scope: A USVString representing a URL - * that defines a service worker's registration scope; what range of URLs a - * service worker can control. This is usually a relative URL, and it - * defaults to '/' when not specified. - */ - register(scriptURL: string, options?: ServiceWorkerRegisterOptions): Promise; - - /** - * Gets a ServiceWorkerRegistration object whose scope URL matches the - * provided document URL. If the method can't return a - * ServiceWorkerRegistration, it returns a Promise. - * - * @param [scope] A unique identifier for a service worker registration — the - * scope URL of the registration object you want to return. This is usually - * a relative URL. - */ - getRegistration(scope?: string): Promise; - - /** - * Returns all ServiceWorkerRegistrations associated with a - * ServiceWorkerContainer in an array. If the method can't return - * ServiceWorkerRegistrations, it returns a Promise. - */ - getRegistrations(): Promise>; -} - -/** - * The parameter passed into the oninstall handler, the InstallEvent interface - * represents an install action that is dispatched on the - * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, - * it ensures that functional events such as FetchEvent are not dispatched - * during installation. - */ -interface InstallEvent extends ExtendableEvent { - /** - * Returns the ServiceWorker that is currently actively controlling the page. - * @readonly - */ - activeWorker: ServiceWorker; -} - -interface ServiceWorkerGlobalScope { - /** - * Contains the Clients object associated with the service worker. - * @readonly - */ - clients: ServiceWorkerClients; - - /** - * Contains the ServiceWorkerRegistration object that represents the - * service worker's registration. - * @readonly - */ - registration: ServiceWorkerRegistration; - - /** - * An event handler fired whenever an activate event occurs — when a - * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active - * worker. - * - * @param [activateevent] - */ - onactivate: (activateevent?: ExtendableEvent) => void; - - /** - * Not defined in the spec yet, but it looks like this will be fired when - * the device is nearly out of storage space, prompting the UA to start - * claiming back some space from web apps that are using client-side storage, - * and the current app is targeted. - * - * @param [beforeevictedevent] - */ - onbeforeevicted: (beforeevictedevent?: Event) => void; - - /** - * Not defined in the spec yet, but it looks like this will be fired when - * the device is out of storage space, and the UA claims back some space - * from the current app. - * - * @param [evictedevent] - */ - onevicted: (evictedevent?: Event) => void; - - /** - * An event handler fired whenever a fetch event occurs — when a fetch() - * is called. - * - * @param [fetchevent] - */ - onfetch: (fetchevent?: FetchEvent) => void; - - /** - * An event handler fired whenever an install event occurs — when a - * ServiceWorkerRegistration acquires a new - * ServiceWorkerRegistration.installing worker. - * - * @param [installevent] - */ - oninstall: (installevent?: InstallEvent) => void; - - /** - * An event handler fired whenever a message event occurs — when incoming - * messages are received. Controlled pages can use the - * MessagePort.postMessage() method to send messages to service workers. - * The service worker can optionally send a response back via the - * MessagePort exposed in event.data.port, corresponding to the controlled - * page. - * - * @param [messageevent] - */ - onmessage: (messageevent?: MessageEvent) => void; - - /** - * An event handler fired whenever a notificationclick event occurs — when - * a user clicks on a displayed notification. - * - * @param [notificationclickevent] - */ - onnotificationclick: (notificationclickevent?: NotificationEvent) => void; - - /** - * An event handler fired whenever a push event occurs — when a server - * push notification is received. - * - * @param [onpushevent] - */ - onpush: (onpushevent?: Event) => void; - - /** - * An event handler fired whenever a pushsubscriptionchange event occurs — - * when a push subscription has been invalidated, or is about to be - * invalidated (e.g. when a push service sets an expiration time). - * - * @param [pushsubscriptionchangeevent] - */ - onpushsubscriptionchange: (pushsubscriptionchangeevent?: Event) => void; - - /** - * Allows the current service worker registration to progress from waiting - * to active state while service worker clients are using it. - */ - skipWaiting(): Promise; - - /** - * TODO GlobalFetch - * @param url - * @param init - */ - fetch(url: string | Request, init?: Object): Promise; -} - -interface Navigator { - /** - * Returns a ServiceWorkerContainer object, which provides access to - * registration, removal, upgrade, and communication with the ServiceWorker - * objects for the associated document. - */ - serviceWorker: ServiceWorkerContainer; -} - -interface Window extends ServiceWorkerGlobalScope { - caches: CacheStorage; -} - -interface NotificationEvent extends Event, ExtendableEvent { - notification: any; -} \ No newline at end of file From 9c55d70b9b91c4a7d95a0993313e9e5e8541890a Mon Sep 17 00:00:00 2001 From: tristancaron Date: Mon, 23 Mar 2015 20:26:39 +0100 Subject: [PATCH 0003/1850] Revert "Revert "Service Worker Api"" This reverts commit 8164f9d8b9123bf8c71f555276ef826d7a0a9d37. --- service_worker_api/service_worker_api-test.ts | 188 ++++ service_worker_api/service_worker_api.d.ts | 896 ++++++++++++++++++ 2 files changed, 1084 insertions(+) create mode 100644 service_worker_api/service_worker_api-test.ts create mode 100644 service_worker_api/service_worker_api.d.ts diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts new file mode 100644 index 0000000000..67ce58cd40 --- /dev/null +++ b/service_worker_api/service_worker_api-test.ts @@ -0,0 +1,188 @@ +/// + +var OFFLINE_CACHE = "cache_test"; +var OFFLINE_URL = "localhost"; + +self.addEventListener('fetch', function(event: FetchEvent) { + if (event.request.method === 'GET' && + event.request.headers.get('accept').indexOf('text/html') !== -1) { + console.log('Handling fetch event for', event.request.url); + event.respondWith( + self.fetch(event.request).catch(function(e) { + console.error('Fetch failed; returning offline page instead.', e); + return self.caches.open(OFFLINE_CACHE).then(function(cache: Cache) { + return cache.match(OFFLINE_URL); + }); + }) + ); + } +}); + +self.caches.open('v1').then(function(cache: Cache) { + cache.matchAll('/images/').then(function(response: Array) { + response.forEach(function(element, index, array) { + cache.delete(element); + + }); + }); + +}); + +self.addEventListener('install', function(event: InstallEvent) { + event.waitUntil( + self.caches.open('v1').then(function(cache: Cache) { + return cache.add('/sw-test/index.html'); + }) + ); +}); + +self.addEventListener('install', function(event: InstallEvent) { + event.waitUntil( + self.caches.open('v1').then(function(cache) { + return cache.addAll( + '/sw-test/', + '/sw-test/index.html', + '/sw-test/style.css', + '/sw-test/app.js', + '/sw-test/image-list.js', + '/sw-test/star-wars-logo.jpg', + '/sw-test/gallery/', + '/sw-test/gallery/bountyHunters.jpg', + '/sw-test/gallery/myLittleVader.jpg', + '/sw-test/gallery/snowTroopers.jpg' + ); + }) + ); +}); + +self.addEventListener('fetch', function(event: FetchEvent) { + var cachedResponse = self.caches.match(event.request).catch(function() { + return self.fetch(event.request).then(function(response: Response) { + return self.caches.open('v1').then(function(cache) { + cache.put(event.request, response.clone()); + return response; + }); + }); + }).catch(function() { + return self.caches.match('/sw-test/gallery/myLittleVader.jpg'); + }); + + event.respondWith(cachedResponse); +}); + +self.caches.open('v1').then(function(cache) { + cache.match('/images/image.png').then(function(response) { + cache.delete(response); + }); +}); + +self.caches.open('v1').then(function(cache: Cache) { + cache.keys().then(function(response) { + response.forEach(function(element, index, array) { + cache.delete(element); + }); + }); +}); + +self.caches.has('v1').then(function() { + self.caches.delete('v1').then(function() { + + }); +}); + +self.addEventListener('activate', function(event: ExtendableEvent) { + var cacheWhitelist = ['v2']; + + event.waitUntil( + self.caches.keys().then(function(keyList) { + for(var i = 0; i < keyList.length; i++) { + if (cacheWhitelist.indexOf(keyList[i]) === -1) { + return self.caches.delete(keyList[i]); + } + } + }) + ); +}); + +function sendMessage(message) { + return new Promise(function(resolve, reject) { + var messageChannel = new MessageChannel(); + messageChannel.port1.onmessage = function(event) { + if (event.data.error) { + reject(event.data.error); + } else { + resolve(event.data); + } + }; + navigator.serviceWorker.controller.postMessage(message, [messageChannel.port2]); + }); +} + +self.clients.matchAll({type: "test"}).then(function(clients) { + for(var i = 0 ; i < clients.length ; i++) { + if(clients[i].url === 'index.html') { + self.clients.openWindow(clients[i].url); + // or do something else involving the matching client + } + } +}); + +self.addEventListener('activate', function(e: ExtendableEvent) { + e.waitUntil(self.clients.claim()); +}); + +navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(function(registration) { + // At this point, registration has taken place. + // The service worker will not handle requests until this page and any + // other instances of this page (in other tabs, etc.) have been + // closed/reloaded. + var serviceWorker; + if (registration.installing) { + serviceWorker = registration.installing; + } else if (registration.waiting) { + serviceWorker = registration.waiting; + } else if (registration.active) { + serviceWorker = registration.active; + } + if (serviceWorker) { + console.log(serviceWorker.state); + serviceWorker.addEventListener('statechange', function(e) { + console.log(e.target.state); + }); + } +}).catch(function(error) { + // Something went wrong during registration. The service-worker.js file + // might be unavailable or contain a syntax error. + +}); + +navigator.serviceWorker.getRegistration('/app').then(function(registration: ServiceWorkerRegistration) { + +}); + +navigator.serviceWorker.getRegistrations().then(function(registrations: Array) { + +}); + +self.registration.unregister(); + +self.addEventListener('install', function(event: ExtendableEvent) { + event.waitUntil(self.skipWaiting()); +}); + +self.addEventListener('notificationclick', function(event: NotificationEvent) { + console.log('On notification click: ', event.notification.tag); + event.notification.close(); + + // This looks to see if the current is already open and + // focuses if it is + event.waitUntil(self.clients.matchAll({ + type: "window" + }).then(function(clientList) { + for (var i = 0; i < clientList.length; i++) { + var client = clientList[i]; + } + if (self.clients.openWindow) + return self.clients.openWindow('/'); + })); +}); \ No newline at end of file diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts new file mode 100644 index 0000000000..f9b2981463 --- /dev/null +++ b/service_worker_api/service_worker_api.d.ts @@ -0,0 +1,896 @@ +// Type definitions for service_worker_api +// Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API +// Definitions by: Tristan Caron +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** + * Provides methods relating to the body of the response/request, allowing you + * to declare what its content type is and how it should be handled. + */ +interface Body { + /** + * Contains a Boolean that indicates whether the body has been read. + * @readonly + */ + bodyUsed: boolean; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with an ArrayBuffer. + */ + arrayBuffer(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a Blob. + */ + blob(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a FormData object. + */ + formData(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a JSON object. + */ + json(): Promise; + + /** + * Takes a Response stream and reads it to completion. + * It returns a promise that resolves with a USVString (text). + */ + text(): Promise; + +} + +/** + * Represents response/request headers, allowing you to query them and take + * different actions depending on the results. + */ +interface Header { + new(): Header; + + /** + * Appends a new value onto an existing header inside a Headers object, or + * adds the header if it does not already exist. + * + * @param name The name of the HTTP header you want to add to the Headers + * object. + * @param value The value of the HTTP header you want to add. + */ + append(name: string, value: string): void; + + /** + * Deletes a header from a Headers object. + * + * @param name The name of the HTTP header you want to delete from the + * Headers object. + */ + delete(name: string): void; + + /** + * Returns the first value of a given header from within a Headers object. + * + * @param name The name of the HTTP header whose value you want to retrieve + * from the Headers object. If the given name is not the name of an + * HTTP header, this method throws a TypeError. + */ + get(name: string): string; + + /** + * Returns an array of all the values of a header within a Headers object + * with a given name. + * + * @param name The name of the HTTP header whose values you want to retrieve + * from the Headers object. If the given name is not the name of an + * HTTP header, this method throws a TypeError. + */ + getAll(name:string): Array; + + /** + * Returns a boolean stating whether a Headers object contains a + * certain header. + * + * @param name The name of the HTTP header you want to test for. If the + * given name is not the name of an HTTP header, this method throws + * a TypeError. + */ + has(name: string): boolean; + + /** + * Sets a new value for an existing header inside a Headers object, or + * adds the header if it does not already exist. + * + * @param name The name of the HTTP header you want to set to a new value. + * If the given name is not the name of an HTTP header, this method throws + * a TypeError. + * @param value The new value you want to set. + */ + set(name: string, value: string): void; +} + +/** + * Represents the response to a request. + */ +interface Response extends Body { + new(): Response; + + /** + * Contains the type of the response (e.g., basic, cors). + * @readonly + */ + type: string; + + /** + * Contains the URL of the response. + * @readonly + */ + url: string; + + /** + * Contains a boolean stating whether this is the final URL of the response. + */ + useFinalURL: boolean; + + /** + * Contains the status code of the response (e.g., 200 for a success). + * @readonly + */ + status: number; + + /** + * Contains a boolean stating whether the response was successful + * (status in the range 200-299) or not. + * @readonly + */ + ok: boolean; + + /** + * Contains the status message corresponding to the status code + * (e.g., OK for 200). + * @readonly + */ + statusText: string; + + /** + * Contains the Headers object associated with the response. + * @readonly + */ + headers: Header; + + /** + * Creates a clone of a Response object. + */ + clone(): Response; + + /** + * Returns a new Response object associated with a network error. + */ + error(): Response; + + /** + * Creates a new response with a different URL. + */ + redirect(): Response; +} + +/** + * Represents a resource request. + */ +interface Request extends Body { + new(): Request; + + /** + * Contains the request's method (GET, POST, etc.). + * @readonly + */ + method: string; + + /** + * Contains the URL of the request. + * @readonly + */ + url: string; + + /** + * Contains the associated Headers object of the request. + * @readonly + */ + headers: Header; + + /** + * Contains the context of the request (e.g., audio, image, iframe, etc.). + * @readonly + */ + context: string; + + /** + * Contains the referrer of the request (e.g., client). + * @readonly + */ + referrer: string; + + /** + * Contains the mode of the request (e.g., cors, no-cors, same-origin). + * @readonly + */ + mode: string; + + /** + * Contains the credentials of the request (e.g., omit, same-origin). + * @readonly + */ + credentials: string; + + /** + * Contains the cache mode of the request (e.g., default, reload, no-cache). + * @readonly + */ + cache: string; + + /** + * Creates a copy of the current Request object. + */ + clone(): Request; +} + +/** + * An CacheOptions object allowing you to set specific control options for the + * matching done in the match operation. + * + * @property [ignoreSearch] A Boolean that specifies whether the matching + * process should ignore the query string in the url. If set to true, + * the ?value=bar part of http://foo.com/?value=bar would be ignored when + * performing a match. It defaults to false. + * + * @property [ignoreMethod] A Boolean that, when set to true, prevents matching + * operations from validating the Request http method (normally only GET + * and HEAD are allowed.) It defaults to false. + * + * @property [ignoreVary] A Boolean that when set to true tells the matching + * operation not to perform VARY header matching — i.e. if the URL matches you + * will get a match regardless of the Response object having a VARY header or + * not. It defaults to false. + * + * @property [cacheName] A DOMString that represents a specific cache to search + * within. Note that this option is ignored by Cache.match(). + */ +interface CacheOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +/** + * Represents the storage for Request / Response object pairs that are cached as + * part of the ServiceWorker life cycle. + */ +interface Cache { + /** + * Returns a Promise that resolves to the response associated with the first + * matching request in the Cache object. + * + * @param request The Request you are attempting to find in the Cache. + * @param {CacheOptions} options + */ + match(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to an array of all matching requests in + * the Cache object. + * + * @param request The Request you are attempting to find in the Cache. + * @param {CacheOptions} options + */ + matchAll(request: Request | string, options?: CacheOptions): Promise>; + + /** + * Returns a Promise that resolves to a new Cache entry whose key + * is the request. + * + * @param request The Request you want to add to the cache. + */ + add(request: Request | string): Promise; + + /** + * Returns a Promise that resolves to a new array of Cache entries whose + * keys are the requests. + * + * @param request An array of Request objects you want to add to the cache. + */ + addAll(...request: Array): Promise; + + /** + * Adds additional key/value pairs to the current Cache object. + * + * @param request The Request you want to add to the cache. + * @param response The response you want to match up to the request. + */ + put(request: Request, response: Response): Promise; + + /** + * Finds the Cache entry whose key is the request, and if found, deletes the + * Cache entry and returns a Promise that resolves to true. If no Cache + * entry is found, it returns false. + * + * @param request The Request you are looking to delete. + * @param {CacheOptions} options + */ + delete(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to an array of Cache keys. + * + * @param request The Request want to return, if a specific key is desired. + * @param {CacheOptions} options + */ + keys(request?: Request, options?: CacheOptions): Promise>; +} + +/** + * Represents the storage for Cache objects. It provides a master directory of + * all the named caches that a ServiceWorker can access and maintains a mapping + * of string names to corresponding Cache objects. + */ +interface CacheStorage { + /** + * Checks if a given Request is a key in any of the Cache objects that the + * CacheStorage object tracks and returns a Promise that resolves + * to that match. + * + * @param request The Request you are looking for a match for in the CacheStorage. + * @param {CacheOptions} options + */ + match(request: Request | string, options?: CacheOptions): Promise; + + /** + * Returns a Promise that resolves to true if a Cache object matching + * the cacheName exists. + * + * @param cacheName The Request you are looking for a match for in the + * CacheStorage. + */ + has(cacheName: string): Promise; + + /** + * Returns a Promise that resolves to the Cache object matching + * the cacheName. + * + * @param cacheName The name of the cache you want to open. + */ + open(cacheName: string): Promise; + + /** + * Finds the Cache object matching the cacheName, and if found, deletes the + * Cache object and returns a Promise that resolves to true. If no + * Cache object is found, it returns false. + * + * @param cacheName The name of the cache you want to delete. + */ + delete(cacheName: string): Promise; + + /** + * Returns a Promise that will resolve with an array containing strings + * corresponding to all of the named Cache objects tracked by the + * CacheStorage. Use this method to iterate over a list of all the + * Cache objects. + */ + keys(): Promise>; +} + +/** + * Represents the scope of a service worker client. A service worker client is + * either a document in a browser context or a SharedWorker, which is controlled + * by an active worker. + */ +interface ServiceWorkerClient { + /** + * Allows a service worker client to send a message to a ServiceWorker. + * + * @param message The message to send to the service worker. + * @param [transfer] A transferable object such as, for example, a reference + * to a port. + */ + postMessage(message: string, transfer?: Object): void; + + /** + * Indicates the type of browsing context of the current client. + * This value can be one of auxiliary, top-level, nested, or none. + * @readonly + */ + frameType: string; + + /** + * Returns the id of the Client object. + * @readonly + */ + id: string; + + /** + * The URL of the current service worker client. + * @readonly + */ + url: string; +} + +interface WindowClient extends ServiceWorkerClient { + /** + * Gives user input focus to the current client. + */ + focus(): Promise; + + /** + * A boolean that indicates whether the current client has focus. + * @readonly + */ + focused: boolean; + + /** + * Indicates the visibility of the current client. This value can be one of + * hidden, visible, prerender, or unloaded. + * @readonly + */ + visibilityState: string; +} + +interface ServiceWorkerClientsMatchOptions { + includeUncontrolled?: boolean; + type?: string; +} + +/** + * Represents a container for a list of Client objects; the main way to access + * the active service worker clients at the current origin. + */ +interface ServiceWorkerClients { + /** + * Gets a list of service worker clients and returns them in a Promise. + * Include the options parameter to return all service worker clients whose + * origin is the same as the associated service worker's origin. If options + * are not included, the method returns only the service worker clients + * controlled by the service worker. + * + * @param options + */ + matchAll(options: ServiceWorkerClientsMatchOptions): Promise>; + + /** + * Opens a service worker Client in a new browser window. + * + * @param url A string representing the URL of the client you want to open + * in the window. + */ + openWindow(url: string): Promise; + + /** + * Allows an active Service Worker to set itself as the active worker for a + * client page when the worker and the page are in the same scope. + */ + claim(): Promise; +} + +/** + * Extends the lifetime of the install and activate events dispatched on the + * ServiceWorkerGlobalScope as part of the service worker lifecycle. This + * ensures that any functional events (like FetchEvent) are not dispatched to + * the ServiceWorker until it upgrades database schemas, deletes outdated cache + * entries, etc. + */ +interface ExtendableEvent extends Event { + /** + * Extends the lifetime of the event. + * It is intended to be called in the install EventHandler for the + * installing worker and on the active EventHandler for the active worker. + * + * @param all + */ + waitUntil(all: any): any; +} + +/** + * The parameter passed into the ServiceWorkerGlobalScope.onfetch handler, + * FetchEvent represents a fetch action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. It contains information about + * the request and resulting response, and provides the FetchEvent.respondWith() + * method, which allows us to provide an arbitrary response back to the + * controlled page. + */ +interface FetchEvent extends Event { + /** + * Returns a Boolean that is true if the event was dispatched with the + * user's intention for the page to reload, and false otherwise. Typically, + * pressing the refresh button in a browser is a reload, while clicking a + * link and pressing the back button is not. + * @readonly + */ + isReload: boolean; + + /** + * Returns the Request that triggered the event handler. + * @readonly + */ + request: Request; + + /** + * Returns the Client that the current service worker is controlling. + * @readonly + */ + client: ServiceWorkerClient; + + /** + * Resolves by returning a Response or a network error to Fetch. + * + * @param any + */ + respondWith(any): Response; +} + +/** + * Represents a service worker. Multiple browsing contexts (e.g. pages, workers, + * etc.) can be associated with the same ServiceWorker object. + */ +interface ServiceWorker extends Worker { + /** + * Returns the ServiceWorker serialized script URL defined as part of + * ServiceWorkerRegistration. The URL must be on the same origin as the + * document that registers the ServiceWorker. + * @readonly + */ + scriptURL: string; + + /** + * Returns the state of the service worker. It returns one of the following + * values: installing, installed, activating, activated, or redundant. + * @readonly + */ + state: string; + + /** + * An EventListener property called whenever an event of type statechange + * is fired; it is basically fired anytime the ServiceWorker.state changes. + * + * @param [statechangeevent] + */ + onstatechange: (statechangeevent?: Event) => void; +} + +/** + * The PushSubscription interface provides a subcription's URL endpoint and + * subscription ID. + */ +interface PushSubscription { + /** + * The endpoint associated with the push subscription. + * @readonly + */ + endpoint: any; + + /** + * The subscription ID associated with the push subscription. + * @readonly + */ + subscriptionId: any; +} + +/** + * The PushManager interface provides a way to receive notifications from + * third-party servers as well as request URLs for push notifications. + * This interface has replaced functionality offered by the obsolete + * PushRegistrationManager. + */ +interface PushManager { + /** + * Returns a promise that resolves to a PushSubscription with details of a + * new push subscription. + */ + subscribe(): Promise; + + /** + * Returns a promise that resolves to a PushSubscription details of + * the retrieved push subscription. + */ + getSubscription(): Promise; + + /** + * Returns a promise that resolves to the PushPermissionStatus of the + * requesting webapp, which will be one of granted, denied, or default. + */ + hasPermission(): Promise; +} + +/** + * Represents a service worker registration. + */ +interface ServiceWorkerRegistration extends EventTarget { + /** + * Returns a unique identifier for a service worker registration. + * This must be on the same origin as the document that registers + * the ServiceWorker. + * @readonly + */ + scope: any; + + /** + * Returns a service worker whose state is installing. This is initially + * set to null. + * @readonly + */ + installing: ServiceWorker; + + /** + * Returns a service worker whose state is installed. This is initially + * set to null. + * @readonly + */ + waiting: ServiceWorker; + + /** + * Returns a service worker whose state is either activating or activated. + * This is initially set to null. An active worker will control a + * ServiceWorkerClient if the client's URL falls within the scope of the + * registration (the scope option set when ServiceWorkerContainer.register + * is first called). + * @readonly + */ + active: ServiceWorker; + + /** + * Returns an interface to for managing push subscriptions, including + * subcribing, getting an anctive subscription, and accessing push + * permission status. + * @readonly + */ + pushManager: PushManager; + + /** + * An EventListener property called whenever an event of type updatefound + * is fired; it is fired any time the ServiceWorkerRegistration.installing + * property acquires a new service worker. + */ + onupdatefound: () => void; + + /** + * Allows you to update a service worker. + */ + update(); + + /** + * Unregisters the service worker registration and returns a promise + * (see Promise). The service worker will finish any ongoing operations + * before it is unregistered. + */ + unregister(): Promise; +} + +interface ServiceWorkerRegisterOptions { + scope: string; +} + +/** + * Provides an object representing the service worker as an overall unit in the + * network ecosystem, including facilities to register, unregister and update + * service workers, and access the state of service workers + * and their registrations. + */ +interface ServiceWorkerContainer { + /** + * Returns a ServiceWorker object if its state is activated (the same object + * returned by ServiceWorkerRegistration.active). This property returns null + * if the request is a force refresh (Shift + refresh) or if there is no + * active worker. + * @readonly + */ + controller: ServiceWorker; + + /** + * Defines whether a service worker is ready to control a page or not. + * It returns a Promise that will never reject, which resolves to a + * ServiceWorkerRegistration with an ServiceWorkerRegistration.active worker. + * @readonly + */ + ready: Promise; + + /** + * An event handler fired whenever a controllerchange event occurs — when + * the document's associated ServiceWorkerRegistration acquires a new + * ServiceWorkerRegistration.active worker. + * + * @param [controllerchangeevent] + */ + oncontrollerchange: (controllerchangeevent?: Event) => void; + + /** + * An event handler fired whenever an error event occurs in the associated + * service workers. + * + * @param [errorevent] + */ + onerror: (errorevent?: ErrorEvent) => void; + + /** + * An event handler fired whenever a message event occurs — when incoming + * messages are received to the ServiceWorkerContainer object (e.g. via a + * MessagePort.postMessage() call.) + * + * @param [messageevent] + */ + onmessage: (messageevent?: MessageEvent) => void; + + /** + * Creates or updates a ServiceWorkerRegistration for the given scriptURL. + * + * @param scriptURL The URL of the service worker script. + * @param [options] An options object to provide options upon registration. + * Currently available options are: scope: A USVString representing a URL + * that defines a service worker's registration scope; what range of URLs a + * service worker can control. This is usually a relative URL, and it + * defaults to '/' when not specified. + */ + register(scriptURL: string, options?: ServiceWorkerRegisterOptions): Promise; + + /** + * Gets a ServiceWorkerRegistration object whose scope URL matches the + * provided document URL. If the method can't return a + * ServiceWorkerRegistration, it returns a Promise. + * + * @param [scope] A unique identifier for a service worker registration — the + * scope URL of the registration object you want to return. This is usually + * a relative URL. + */ + getRegistration(scope?: string): Promise; + + /** + * Returns all ServiceWorkerRegistrations associated with a + * ServiceWorkerContainer in an array. If the method can't return + * ServiceWorkerRegistrations, it returns a Promise. + */ + getRegistrations(): Promise>; +} + +/** + * The parameter passed into the oninstall handler, the InstallEvent interface + * represents an install action that is dispatched on the + * ServiceWorkerGlobalScope of a ServiceWorker. As a child of ExtendableEvent, + * it ensures that functional events such as FetchEvent are not dispatched + * during installation. + */ +interface InstallEvent extends ExtendableEvent { + /** + * Returns the ServiceWorker that is currently actively controlling the page. + * @readonly + */ + activeWorker: ServiceWorker; +} + +interface ServiceWorkerGlobalScope { + /** + * Contains the Clients object associated with the service worker. + * @readonly + */ + clients: ServiceWorkerClients; + + /** + * Contains the ServiceWorkerRegistration object that represents the + * service worker's registration. + * @readonly + */ + registration: ServiceWorkerRegistration; + + /** + * An event handler fired whenever an activate event occurs — when a + * ServiceWorkerRegistration acquires a new ServiceWorkerRegistration.active + * worker. + * + * @param [activateevent] + */ + onactivate: (activateevent?: ExtendableEvent) => void; + + /** + * Not defined in the spec yet, but it looks like this will be fired when + * the device is nearly out of storage space, prompting the UA to start + * claiming back some space from web apps that are using client-side storage, + * and the current app is targeted. + * + * @param [beforeevictedevent] + */ + onbeforeevicted: (beforeevictedevent?: Event) => void; + + /** + * Not defined in the spec yet, but it looks like this will be fired when + * the device is out of storage space, and the UA claims back some space + * from the current app. + * + * @param [evictedevent] + */ + onevicted: (evictedevent?: Event) => void; + + /** + * An event handler fired whenever a fetch event occurs — when a fetch() + * is called. + * + * @param [fetchevent] + */ + onfetch: (fetchevent?: FetchEvent) => void; + + /** + * An event handler fired whenever an install event occurs — when a + * ServiceWorkerRegistration acquires a new + * ServiceWorkerRegistration.installing worker. + * + * @param [installevent] + */ + oninstall: (installevent?: InstallEvent) => void; + + /** + * An event handler fired whenever a message event occurs — when incoming + * messages are received. Controlled pages can use the + * MessagePort.postMessage() method to send messages to service workers. + * The service worker can optionally send a response back via the + * MessagePort exposed in event.data.port, corresponding to the controlled + * page. + * + * @param [messageevent] + */ + onmessage: (messageevent?: MessageEvent) => void; + + /** + * An event handler fired whenever a notificationclick event occurs — when + * a user clicks on a displayed notification. + * + * @param [notificationclickevent] + */ + onnotificationclick: (notificationclickevent?: NotificationEvent) => void; + + /** + * An event handler fired whenever a push event occurs — when a server + * push notification is received. + * + * @param [onpushevent] + */ + onpush: (onpushevent?: Event) => void; + + /** + * An event handler fired whenever a pushsubscriptionchange event occurs — + * when a push subscription has been invalidated, or is about to be + * invalidated (e.g. when a push service sets an expiration time). + * + * @param [pushsubscriptionchangeevent] + */ + onpushsubscriptionchange: (pushsubscriptionchangeevent?: Event) => void; + + /** + * Allows the current service worker registration to progress from waiting + * to active state while service worker clients are using it. + */ + skipWaiting(): Promise; + + /** + * TODO GlobalFetch + * @param url + * @param init + */ + fetch(url: string | Request, init?: Object): Promise; +} + +interface Navigator { + /** + * Returns a ServiceWorkerContainer object, which provides access to + * registration, removal, upgrade, and communication with the ServiceWorker + * objects for the associated document. + */ + serviceWorker: ServiceWorkerContainer; +} + +interface Window extends ServiceWorkerGlobalScope { + caches: CacheStorage; +} + +interface NotificationEvent extends Event, ExtendableEvent { + notification: any; +} \ No newline at end of file From 1e6428c3474fa9174a1d218be30ac350e0a48f6e Mon Sep 17 00:00:00 2001 From: tristancaron Date: Mon, 23 Mar 2015 21:10:09 +0100 Subject: [PATCH 0004/1850] Service Worker API --- service_worker_api/service_worker_api-test.ts | 6 +++--- service_worker_api/service_worker_api.d.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts index 67ce58cd40..a28446a382 100644 --- a/service_worker_api/service_worker_api-test.ts +++ b/service_worker_api/service_worker_api-test.ts @@ -104,7 +104,7 @@ self.addEventListener('activate', function(event: ExtendableEvent) { ); }); -function sendMessage(message) { +function sendMessage(message: string) { return new Promise(function(resolve, reject) { var messageChannel = new MessageChannel(); messageChannel.port1.onmessage = function(event) { @@ -136,7 +136,7 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi // The service worker will not handle requests until this page and any // other instances of this page (in other tabs, etc.) have been // closed/reloaded. - var serviceWorker; + var serviceWorker: ServiceWorkerRegistration; if (registration.installing) { serviceWorker = registration.installing; } else if (registration.waiting) { @@ -146,7 +146,7 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi } if (serviceWorker) { console.log(serviceWorker.state); - serviceWorker.addEventListener('statechange', function(e) { + serviceWorker.addEventListener('statechange', function(e: Event) { console.log(e.target.state); }); } diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts index f9b2981463..3851d0ec10 100644 --- a/service_worker_api/service_worker_api.d.ts +++ b/service_worker_api/service_worker_api.d.ts @@ -1,6 +1,6 @@ // Type definitions for service_worker_api // Project: https://developer.mozilla.org/fr/docs/Web/API/ServiceWorker_API -// Definitions by: Tristan Caron +// Definitions by: Tristan Caron // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -526,9 +526,9 @@ interface FetchEvent extends Event { /** * Resolves by returning a Response or a network error to Fetch. * - * @param any + * @param all */ - respondWith(any): Response; + respondWith(all: any): Response; } /** @@ -658,7 +658,7 @@ interface ServiceWorkerRegistration extends EventTarget { /** * Allows you to update a service worker. */ - update(); + update(): void; /** * Unregisters the service worker registration and returns a promise From d12ab0b655fbe42f35d257773fb23219d608d252 Mon Sep 17 00:00:00 2001 From: tristancaron Date: Mon, 23 Mar 2015 21:19:54 +0100 Subject: [PATCH 0005/1850] Service Worker API --- service_worker_api/service_worker_api-test.ts | 4 ++-- service_worker_api/service_worker_api.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service_worker_api/service_worker_api-test.ts b/service_worker_api/service_worker_api-test.ts index a28446a382..e144880ba1 100644 --- a/service_worker_api/service_worker_api-test.ts +++ b/service_worker_api/service_worker_api-test.ts @@ -136,7 +136,7 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi // The service worker will not handle requests until this page and any // other instances of this page (in other tabs, etc.) have been // closed/reloaded. - var serviceWorker: ServiceWorkerRegistration; + var serviceWorker: ServiceWorker; if (registration.installing) { serviceWorker = registration.installing; } else if (registration.waiting) { @@ -146,7 +146,7 @@ navigator.serviceWorker.register('service-worker.js', {scope: './'}).then(functi } if (serviceWorker) { console.log(serviceWorker.state); - serviceWorker.addEventListener('statechange', function(e: Event) { + serviceWorker.addEventListener('statechange', function(e: any) { console.log(e.target.state); }); } diff --git a/service_worker_api/service_worker_api.d.ts b/service_worker_api/service_worker_api.d.ts index 3851d0ec10..77c80b6706 100644 --- a/service_worker_api/service_worker_api.d.ts +++ b/service_worker_api/service_worker_api.d.ts @@ -557,7 +557,7 @@ interface ServiceWorker extends Worker { * * @param [statechangeevent] */ - onstatechange: (statechangeevent?: Event) => void; + onstatechange: (statechangeevent?: any) => void; } /** From 3405f194a1f2c11e68d524971ab98591648067a5 Mon Sep 17 00:00:00 2001 From: bryn austin bellomy Date: Sat, 25 Apr 2015 20:00:43 -0500 Subject: [PATCH 0006/1850] adding cliff module --- cliff/cliff.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 cliff/cliff.d.ts diff --git a/cliff/cliff.d.ts b/cliff/cliff.d.ts new file mode 100644 index 0000000000..e0db79c986 --- /dev/null +++ b/cliff/cliff.d.ts @@ -0,0 +1,14 @@ +// Type definitions for cliff 0.1.10 +// Project: https://github.com/flatiron/cliff +// Definitions by: bryn austin bellomy +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module "cliff" { + export function inspect(obj:any): string; + export function stringifyRows(rows:string[][], colors?:string[]): string; + export function stringifyObjectRows(rows:Array<{}>, keys:string[], colors?:string[]): string; + export function putRows(level:string, rows:string[][], colors?:string[]): void; + export function putObjectRows(level:string, rows:Array<{}>, keys:string[], colors?:string[]): void; + export function putObject(level:string, object:any, rewriters?:any, padding?:any): void; +} From 4be08db681656d8a5e00d3c02e02c2bd9c8f452f Mon Sep 17 00:00:00 2001 From: bryn austin bellomy Date: Sat, 25 Apr 2015 20:01:25 -0500 Subject: [PATCH 0007/1850] adding blessed module --- blessed/blessed.d.ts | 1269 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1269 insertions(+) create mode 100644 blessed/blessed.d.ts diff --git a/blessed/blessed.d.ts b/blessed/blessed.d.ts new file mode 100644 index 0000000000..6746afe5f5 --- /dev/null +++ b/blessed/blessed.d.ts @@ -0,0 +1,1269 @@ +// Type definitions for blessed 0.1.5 +// Project: https://github.com/chjj/blessed +// Definitions by: bryn austin bellomy +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "blessed" +{ + import events = require('events'); + import buffer = require('buffer'); + import child_process = require('child_process'); + + module Blessed + { + export var colors: Colors; + + export interface GenericCallback { + (...args:any[]): void; + } + + export interface ColorPair { + /** background, must be number (-1 for default). */ + bg?: number; + /** foreground, must be number (-1 for default). */ + fg?: number; + } + + export interface Style extends ColorPair { + bold?: boolean; + underline?: boolean; + border: Border; + hover: ColorPair; + } + + export interface Border extends ColorPair { + /** type of border ('line' or 'bg'). */ + type?: string; //'line'|'bg'; + /** character to use if bg type, default is space. */ + ch?: string; + } + + export interface Padding { + top?:number; + right?:number; + bottom?:number; + left?:number; + } + + export interface Position { + /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */ + top?:number|string; + /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */ + right?:number|string; + /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */ + bottom?:number|string; + /** offsets of the element relative to its parent. can be a number, percentage (0-100%), or keyword (center). right and bottom do not accept keywords. */ + left?:number|string; + /** width of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */ + width?:number|string; + /** height of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */ + height?:number|string; + } + + export interface KeyCode { + name: string; + ctrl: boolean; + meta: boolean; + shift: boolean; + sequence: string; + full: string; + } + + export class Program + { + /** + Wrap the given text in terminal formatting codes corresponding to the given attribute + name. The `attr` string can be of the form `red fg` or `52 bg` where `52` is a 0-255 + integer color number. + */ + text (text:string, attr:string): string; + } + + export interface Colors { + /** Either pass a hex string, an array of 3 numbers, or three separate numbers representing an RGB value. This returns the 0-255 color number for that color. */ + match (r:string|number[]|number, g?:number, b?:number): number; + + /** An array of the 255 colors as hex strings. */ + colors: string[]; + } + + export interface NodeOptions + { + screen?: Screen; + parent?: Node; + children?: Node[]; + } + + export class Node extends events.EventEmitter + { + constructor(options?:NodeOptions); + + type : string; + options : NodeOptions; + parent : Node; + screen : Screen; + children : Node[]; + data : any; + _ : any; + $ : any; + index : number; + + // on(event:string, callback:() => void); + // on(event:'adopt', callback:() => void); + // on(event:'remove', callback:() => void); + // on(event:'reparent', callback:() => void); + // on(event:'attach', callback:() => void); + // on(event:'detach', callback:() => void); + + prepend(node:Node): void; + append(node:Node): void; + remove(node:Node): void; + insert(node:Node, index:number): void; + insertBefore(node:Node, refNode:Node): void; + insertAfter(node:Node, refNode:Node): void; + detach(): void; + // emitDescendants(): void; + // get(key:string): any; + // get(key:string, default:any): any; + // set(key:string, value:any): void; + } + + export interface ScreenOptions extends NodeOptions + { + /** the blessed Program to be associated with. will be automatically instantiated if none is provided. */ + program?: any; + /** attempt to perform CSR optimization on all possible elements (not just full-width ones, elements with uniform cells to their sides). this is known to cause flickering with elements that are not full-width, however, it is more optimal for terminal rendering. */ + smartCSR?: boolean; + /** do CSR on any element within 20 cols of the screen edge on either side. faster than smartCSR, but may cause flickering depending on what is on each side of the element. */ + fastCSR?: boolean; + /** attempt to perform back_color_erase optimizations for terminals that support it. it will also work with terminals that don't support it, but only on lines with the default background color. as it stands with the current implementation, it's uncertain how much terminal performance this adds at the cost of overhead within node. */ + useBCE?: boolean; + /** amount of time (in ms) to redraw the screen after the terminal is resized (default: 300). */ + resizeTimeout?: number; + /** the width of tabs within an element's content. */ + tabSize?: number; + /** automatically position child elements with border and padding in mind. */ + autoPadding?: boolean; + /** the name of the logfile to use. if specified but the file does not exist, it will be created. see log method. */ + log?: string; + /** dump all output and input to desired file. can be used together with log option if set as a boolean. */ + dump?: any; + /** debug mode. enables usage of the `debug` method. also creates a debug console which will display when pressing F12. it will display all log and debug messages. */ + debug?: boolean; + /** Array of keys in their full format (e.g. C-c) to ignore when keys are locked. Useful for creating a key that will always exit no matter whether the keys are locked. */ + ignoreLocked?: string[]; + + /** Do not clear the screen, only scroll down enough to make room for the elements on the screen. do not use the alternate screenbuffer. useful for writing a CLI tool or some kind of prompt (experimental - see test/widget-noalt.js) */ + noAlt?: boolean; + + /** Options for the cursor. */ + cursor?: CursorOptions; + } + + export interface CursorOptions { + /** have blessed draw a custom cursor and hide the terminal cursor (experimental). */ + artificial?: boolean; + /** shape of the artificial cursor. can be: block, underline, or line. */ + shape?: string; //'block'|'underline'|'line'; + /** whether the artificial cursor blinks. */ + blink?: boolean; + /** color of the artificial cursor. accepts any valid color value (null is default). */ + color?: string; + } + + export interface ScreenEventCallback { + (character:string, keyCode:KeyCode): void; + } + + export class Screen extends Node + { + constructor(options?:ScreenOptions); + + /** the blessed Program object. */ + program: any; + /** the blessed Tput object (only available if you passed tput: true to the Program constructor.) */ + tput: any; + /** top of the focus history stack. */ + focused: any; + /** width of the screen (same as program.cols). */ + width: number; + /** height of the screen (same as program.rows). */ + height: number; + /** same as screen.width. */ + cols: number; + /** same as screen.height. */ + rows: number; + + /** calculated relative left offset. */ + left: number; + /** calculated relative right offset. */ + right: number; + /** calculated relative top offset. */ + top: number; + /** calculated relative bottom offset. */ + bottom: number; + /** calculated absolute left offset. */ + aleft: number; + /** calculated absolute right offset. */ + aright: number; + /** calculated absolute top offset. */ + atop: number; + /** calculated absolute bottom offset. */ + abottom: number; + + + /** whether the focused element grabs all keypresses. */ + grabKeys: boolean; + /** prevent keypresses from being received by any element. */ + lockKeys: boolean; + /** the currently hovered element. only set if mouse events are bound. */ + hover: Element; + /** set or get window title. */ + title: string; + + /** write string to the log file if one was created. */ + log(...msg:any[]): void; + /** same as the log method, but only gets called if the debug option was set. */ + debug(...msg:string[]): void; + /** allocate a new pending screen buffer and a new output screen buffer. */ + alloc(): void; + /** draw the screen based on the contents of the screen buffer. */ + draw(start:number, end:number): void; + /** render all child elements, writing all data to the screen buffer and drawing the screen. */ + render(): void; + /** clear any region on the screen. */ + clearRegion(x1:number, x2:number, y1:number, y2:number): void; + /** fill any region with a character of a certain attribute. */ + fillRegion(attr:number, ch:string, x1:number, x2:number, y1:number, y2:number): void; + /** focus element by offset of focusable elements. */ + focusOffset(offset:number): void; + /** focus previous element in the index. */ + focusPrevious(): void; + /** focus next element in the index. */ + focusNext(): void; + /** push element on the focus stack (equivalent to screen.focused = el). */ + focusPush(element:Element): void; + /** pop element off the focus stack. */ + focusPop(): void; + /** save the focused element. */ + saveFocus(): void; + /** restore the saved focused element. */ + restoreFocus(): void; + /** "rewind" focus to the last visible and attached element. */ + rewindFocus(): void; + /** bind a keypress listener for a specific key. */ + key(keyEvents:string|string[], callback:ScreenEventCallback): void; + /** bind a keypress listener for a specific key once. */ + onceKey(keyEvents:string|string[], callback:ScreenEventCallback): void; + /** remove a keypress listener for a specific key. */ + unkey(name:string, listener:ScreenEventCallback): void; + /** spawn a process in the foreground, return to blessed app after exit. */ + spawn(file:string, args:string[], options:NodeChildProcessExecOptions): child_process.ChildProcess; + /** spawn a process in the foreground, return to blessed app after exit. executes callback on error or exit. */ + exec(file:string, args:string[], options:NodeChildProcessExecOptions, callback:GenericCallback): child_process.ChildProcess; + /** read data from text editor. */ + readEditor(options:{}, callback:GenericCallback): void; + /** set effects based on two events and attributes. */ + setEffects(el:Element, fel:Element, over:string, out:string, effects:Style, temp?:string): void; + /** insert a line into the screen (using csr: this bypasses the output buffer). */ + insertLine(n:number, y:number, top:number, bottom:number): void; + /** delete a line from the screen (using csr: this bypasses the output buffer). */ + deleteLine(n:number, y:number, top:number, bottom:number): void; + /** insert a line at the bottom of the screen. */ + insertBottom(top:number, bottom:number): void; + /** insert a line at the top of the screen. */ + insertTop(top:number, bottom:number): void; + /** delete a line at the bottom of the screen. */ + deleteBottom(top:number, bottom:number): void; + /** delete a line at the top of the screen. */ + deleteTop(top:number, bottom:number): void; + + /** enable mouse events for the screen and optionally an element (automatically called when a form of on('mouse') is bound). */ + enableMouse(el?:Element): void; + /** enable keypress events for the screen and optionally an element (automatically called when a form of on('keypress') is bound). */ + enableKeys(el?:Element): void; + /** enable key and mouse events. calls bot enableMouse and enableKeys. */ + enableInput(el?:Element): void; + + /** attempt to copy text to clipboard using iTerm2's propriety sequence. returns true if successful. */ + copyToClipboard(text:string): boolean; + /** attempt to change cursor shape. will not work in all terminals (see artificial cursors for a solution to this). returns true if successful. */ + cursorShape(shape:string, blink:boolean): boolean; + /** attempt to change cursor color. returns true if successful. */ + cursorColor(color: string): boolean; + /** attempt to reset cursor. returns true if successful. */ + cursorReset(): boolean; + + } + + export interface ElementOptions extends NodeOptions + { + fg?: string; + bg?: string; + scrollbar?: ColorPair; + focus?: Style; + hover?: Style; + + /** border object, see below. */ + border?: Border; + /** positioning options. */ + position?: Position; + /** amount of padding on the inside of the element. can be a number or an object containing the properties: left, right, top, and bottom. */ + padding?: number|Padding; + /** element's text content. */ + content?: string; + /** element is clickable. */ + clickable?: boolean; + /** element is focusable and can receive key input. */ + input?: boolean; + /** element is focused. */ + focused?: boolean; + /** whether the element is hidden. */ + hidden?: boolean; + /** a simple text label for the element. */ + label?: string; + /** a floating text label for the element which appears on mouseover. */ + hoverText?: string; + /** text alignment: left, center, or right. */ + align?: string; + /** vertical text alignment: top, middle, or bottom. */ + valign?: string; + /** shrink/flex/grow to content and child elements. width/height during render. */ + shrink?: any; + /** width of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */ + width?: number|string; + /** height of the element, can be a number, percentage (0-100%), or keyword (half or shrink). */ + height?: number|string; + /** whether the element is scrollable or not. */ + scrollable?: boolean; + /** background character (default is whitespace ). */ + ch?: string; + /** allow the element to be dragged with the mouse. */ + draggable?: boolean; + } + + export class Element extends Node + { + constructor(options?:ElementOptions); + + /** name of the element. useful for form submission. */ + name: string; + /** border object. */ + border: Border; + /** contains attributes (e.g. fg/bg/underline). see above. */ + style: Style; + /** raw width, height, and offsets. */ + position: Position; + /** type of border (line or bg). bg by default. */ + type: string; //'line'|'bg'; + /** character to use if bg type, default is space. */ + ch: string; + /** raw text content. */ + content: string; + /** whether the element is hidden or not. */ + hidden: boolean; + /** whether the element is visible or not. */ + visible: boolean; + /** whether the element is attached to a screen in its ancestry somewhere. */ + detached: boolean; + /** calculated width. */ + width: number; + /** calculated height. */ + height: number; + /** whether the element is draggable. set to true to allow dragging. */ + draggable: boolean; + + + + /** calculated relative left offset. */ + left: number; + /** calculated relative right offset. */ + right: number; + /** calculated relative top offset. */ + top: number; + /** calculated relative bottom offset. */ + bottom: number; + /** calculated absolute left offset. */ + aleft: number; + /** calculated absolute right offset. */ + aright: number; + /** calculated absolute top offset. */ + atop: number; + /** calculated absolute bottom offset. */ + abottom: number; + + + /** write content and children to the screen buffer. */ + render(): void; + /** hide element. */ + hide(): void; + /** show element. */ + show(): void; + /** toggle hidden/shown. */ + toggle(): void; + /** focus element. */ + focus(): void; + /** bind a keypress listener for a specific key. */ + key(name:string|string[], listener:(character?:any, keyCode?:any) => void): void; + /** bind a keypress listener for a specific key once. */ + onceKey(name:string, listener:() => void): void; + /** remove a keypress listener for a specific key. */ + unkey(name:string, listener:() => void): void; + /** same as el.on('screen', ...) except this will automatically cleanup listeners after the element is detached. */ + onScreenEvent(event:string, listener:(...args:any[]) => void): void; + /** set the z-index of the element (changes rendering order). */ + setIndex(z:number): void; + /** put the element in front of its siblings. */ + setFront(): void; + /** put the element in back of its siblings. */ + setBack(): void; + /** set the label text for the top-left corner. example options: {text:'foo',side:'left'} */ + setLabel(textOrOptions:string|{}): void; + /** remove the label completely. */ + removeLabel(): void; + /** set the hover text for the bottom-right corner. example options: {text:'foo'} */ + setHover(textOrOptions:string|{}): void; + /** remove the hover label completely. */ + removeHover(): void; + /** set the content. note: when text is input, it will be stripped of all non-SGR escape codes, tabs will be replaced with 8 spaces, and tags will be replaced with SGR codes (if enabled). */ + setContent(text:string): void; + /** return content, slightly different from el.content. assume the above formatting. */ + getContent(): void; + /** similar to setContent, but ignore tags and remove escape codes. */ + setText(text:string): void; + /** similar to getContent, but return content with tags and escape codes removed. */ + getText(): void; + /** insert a line into the box's content. */ + insertLine(index:number, lines:string|string[]): void; + /** delete a line from the box's content. */ + deleteLine(index:number, numLines:number): void; + /** get a line from the box's content. */ + getLine(index:number): void; + /** get a line from the box's content from the visible top. */ + getBaseLine(index:number): void; + /** set a line in the box's content. */ + setLine(index:number, line:string): void; + /** set a line in the box's content from the visible top. */ + setBaseLine(index:number, line:string): void; + /** clear a line from the box's content. */ + clearLine(index:number): void; + /** clear a line from the box's content from the visible top. */ + clearBaseLine(index:number): void; + /** insert a line at the top of the box. */ + insertTop(lines:string|string[]): void; + /** insert a line at the bottom of the box. */ + insertBottom(lines:string|string[]): void; + /** delete a line at the top of the box. */ + deleteTop(): void; + /** delete a line at the bottom of the box. */ + deleteBottom(): void; + /** unshift a line onto the top of the content. */ + unshiftLine(lines:string|string[]): void; + /** shift a line off the top of the content. */ + shiftLine(index:number): void; + /** push a line onto the bottom of the content. */ + pushLine(lines:string|string[]): void; + /** pop a line off the bottom of the content. */ + popLine(index:number): void; + /** an array containing the content lines. */ + getLines(): void; + /** an array containing the lines as they are displayed on the screen. */ + getScreenLines(): void; + /** get a string's real length, taking into account tags. */ + textLength(text:string): number; + + /** enable dragging of the element. */ + enableDrag(): void; + /** disable dragging of the element. */ + disableDrag(): void; + } + + + // + // Box + // + + export interface BoxOptions extends ElementOptions { + // intentionally empty + } + + export class Box extends Element { + constructor(options?:BoxOptions); + // intentionally empty + } + + + // + // ScrollableBox + // + + export interface ScrollableBoxOptions extends BoxOptions { + /** a limit to the childBase. default is `Infinity`. */ + baseLimit: number; + /** a option which causes the ignoring of `childOffset`. this in turn causes the childBase to change every time the element is scrolled. */ + alwaysScroll: boolean; + /** object enabling a scrollbar. */ + scrollbar: ScrollBar; + } + + /** A box with scrollable content. */ + export class ScrollableBox extends Box { + constructor(options?:ScrollableBoxOptions); + + /** the offset of the top of the scroll content. */ + childBase: number; + /** the offset of the chosen item/line. */ + childOffset: number; + /** scroll the content by a relative offset. */ + scroll(offset:number): void; + /** scroll the content to an absolute index. */ + scrollTo(index:number): void; + /** same as `scrollTo`. */ + setScroll(index:number): void; + /** set the current scroll index in percentage (0-100). */ + setScrollPerc(perc:number): void; + /** get the current scroll index in lines. */ + getScroll(): number; + /** get the actual height of the scrolling area. */ + getScrollHeight(): number; + /** get the current scroll index in percentage. */ + getScrollPerc(): number; + /** reset the scroll index to its initial state. */ + resetScroll(): void; + + } + + export interface ScrollBar { + /** style of the scrollbar. */ + style: Style; + /** style of the scrollbar track if present (takes regular style options). */ + track: Style; + } + + + // + // ScrollableText + // + + export interface ScrollableTextOptions extends ScrollableBoxOptions { + /** whether to enable automatic mouse support for this element. */ + mouse: boolean; + /** use predefined keys for navigating the text. */ + keys: boolean; + /** use vi keys with the `keys` option. */ + vi: boolean; + } + + /** __DEPRECATED__ - Use Box with the `scrollable` and `alwaysScroll` options instead. A scrollable text box which can display and scroll text, as well as handle pre-existing newlines and escape codes. */ + export class ScrollableText extends ScrollableBox { + constructor(options?:ScrollableTextOptions); + } + + + + // + // Text + // + + export interface TextOptions extends ElementOptions { + align?: string; //'left'|'center'|'right'; + } + + export class Text extends Element { + constructor(options?:TextOptions); + // intentionally empty + } + + + // + // Line + // + + export interface LineOptions extends BoxOptions { + orientation?: string; //'vertical'|'horizontal'; + style?: Style; + } + + export class Line extends Box { + constructor(options?:LineOptions); + // intentionally empty + } + + + // + // List + // + + export interface ListStyle extends Style { + selected?: Style; + item?: Style; + } + + export interface ListOptions extends BoxOptions + { + style?: ListStyle; + + /** whether to automatically enable mouse support for this list (allows clicking items). */ + mouse?: boolean; + /** use predefined keys for navigating the list. */ + keys?: any; + /** use vi keys with the keys option. */ + vi?: boolean; + /** an array of strings which become the list's items. */ + items?: string[]; + /** a function that is called when vi mode is enabled and the key / is pressed. This function accepts a callback function which should be called with the search string. The search string is then used to jump to an item that is found in items. */ + search?: (callback:(searchString:string) => void) => void; + /** whether the list is interactive and can have items selected (default: true). */ + interactive?: boolean; + } + + export class List extends Box + { + constructor(options?:ListOptions); + + /** The text of the currently selected item. */ + value:string; + /** The items in the list. */ + items:string[]; + /** The items in the list. */ + ritems:string[]; + /** The index of the current selection. */ + selected:number; + + /** add an item based on a string. */ + addItem(text:string): void; + /** returns the item index from the list. child can be an element, index, or string. */ + getItemIndex(child:Element|number|string): void; + /** returns the item element. child can be an element, index, or string. */ + getItem(child:Element|number|string): void; + /** removes an item from the list. child can be an element, index, or string. */ + removeItem(child:Element|number|string): void; + /** clears all items from the list. */ + clearItems(): void; + /** sets the list items to multiple strings. */ + setItems(items:string[]): void; + /** Sets the current selection by absolute index. */ + select(index:number): void; + /** Changes the current selection based on current offset. */ + move(offset:number): void; + /** select item above selected. */ + up(amount:number): void; + /** select item below selected. */ + down(amount:number): void; + /** show/focus list and pick an item. the callback is executed with the result. */ + pick(cwd:string, callback:(err:any, file:string) => void): void; + + /** show/focus list and pick an item. the callback is executed with the result. */ + pick(callback:(err:any, file:string) => void): void; + } + + // + // Input + // + + export interface InputOptions extends BoxOptions { + // intentionally empty + } + + export class Input extends Box { + constructor(options?:InputOptions); + // intentionally empty + } + + export interface InputOptions extends BoxOptions { + // intentionally empty + } + + // + // Textarea + // + + export interface TextareaOptions extends InputOptions + { + /** use pre-defined keys (`i` or `enter` for insert, `e` for editor, `C-e` for editor while inserting). */ + keys?: boolean; + /** use pre-defined mouse events (right-click for editor). */ + mouse?: boolean; + /** call `readInput()` when the element is focused. automatically unfocus. */ + inputOnFocus?: boolean; + } + + /** A box which allows multiline text input. */ + export class Textarea extends Input + { + constructor(options?:TextareaOptions); + + /** the input text. __read-only__. */ + value: string; + + /** submit the textarea (emits `submit`). */ + submit(): void; + /** cancel the textarea (emits `cancel`). */ + cancel(): void; + /** grab key events and start reading text from the keyboard. takes a callback which receives the final value. */ + readInput(callback:GenericCallback): void; + /** open text editor in `$EDITOR`, read the output from the resulting file. takes a callback which receives the final value. */ + readEditor(callback:GenericCallback): void; + /** the same as `this.value`, for now. */ + getValue(): string; + /** clear input. */ + clearValue(): void; + /** set value. */ + setValue(text:string): void; + } + + + // + // Textbox + // + + export interface TextboxOptions extends TextareaOptions { + /** completely hide text. */ + secret?: boolean; + /** replace text with asterisks (`*`). */ + censor?: boolean; + } + + /** A box which allows text input. */ + export class Textbox extends Textarea { + constructor(options?:TextboxOptions); + + /** completely hide text. */ + secret: boolean; + /** replace text with asterisks (`*`). */ + censor: boolean; + } + + + // + // Button + // + + export interface ButtonOptions extends InputOptions { + } + + /** A button which can be focused and allows key and mouse input. */ + export class Button extends Input { + constructor(options?:ButtonOptions); + + // on(event:string, callback:() => void): void; + // on(event:'press', callback:() => void); + + /** press button. emits 'press'. */ + press(): void; + } + + + // + // ProgressBar + // + + export interface ProgressBarOptions extends InputOptions { + /** can be `horizontal` or `vertical`. */ + orientation: string; + /** the character to fill the bar with (default is space). */ + pch: string; + /** the amount filled (0 - 100). */ + filled: number; + /** same as `filled`. */ + value: number; + /** enable key support. */ + keys: boolean; + /** enable mouse support. */ + mouse: boolean; + + /** contains the extra key 'bar', which defines the style of the bar contents itself. */ + style: ProgressBarStyle; + } + + export interface ProgressBarStyle extends Style { + /** style of the bar contents itself. */ + bar: Style; + } + + + export class ProgressBar extends Input { + constructor(options?:ProgressBarOptions); + + /** progress the bar by a fill amount. */ + progress(amount:number): void; + /** set progress to specific amount. */ + setProgress(amount:number): void; + /** reset the bar. */ + reset(): void; + } + + // + // Checkbox + // + + export interface CheckboxOptions extends InputOptions { + /** whether the element is checked or not. */ + checked: boolean; + /** enable mouse support. */ + mouse: boolean; + } + + + /** A checkbox which can be used in a form element. */ + export class Checkbox extends Input + { + constructor(options?:CheckboxOptions); + + /** the text next to the checkbox (do not use setcontent, use `check.text = ''`). */ + text: string; + /** whether the element is checked or not. */ + checked: boolean; + /** same as `checked`. */ + value: boolean; + + /** check the element. */ + check(): void; + /** uncheck the element. */ + uncheck(): void; + /** toggle checked state. */ + toggle(): void; + } + + + // + // RadioSet + // + + export interface RadioSetOptions extends BoxOptions { + } + + + export class RadioSet extends Box { + constructor(options?:RadioSetOptions); + } + + + // + // RadioButton + // + + export interface RadioButtonOptions extends CheckboxOptions { + } + + + /** A radio button which can be used in a form element. */ + export class RadioButton extends Checkbox { + constructor(options?:RadioButtonOptions); + } + + + + // + // Prompt + // + + export interface PromptOptions extends BoxOptions { + } + + + /** A prompt box containing a text input, okay, and cancel buttons (automatically hidden). */ + export class Prompt extends Box + { + constructor(options?:PromptOptions); + + /** show the prompt and wait for the result of the textbox. set text and initial value */ + input(text:string, value:any, callback:(val:any) => void): void; + /** show the prompt and wait for the result of the textbox. set text and initial value */ + setInput(text:string, value:any, callback:(val:any) => void): void; + /** show the prompt and wait for the result of the textbox. set text and initial value */ + readInput(text:string, value:any, callback:(val:any) => void): void; + } + + + // + // Question + // + + export interface QuestionOptions extends BoxOptions { + } + + + /** A question box containing okay and cancel buttons (automatically hidden). */ + export class Question extends Box + { + constructor(options?:QuestionOptions); + + /** ask a `question`. `callback` will yield the result. */ + ask(question:string, callback:(result:any) => void): void; + } + + + // + // Message + // + + export interface MessageOptions extends BoxOptions { + } + + + /** A box containing a message to be displayed (automatically hidden). */ + export class Message extends Box + { + constructor(options?:MessageOptions); + + /** display a message for a time (default is 3 seconds). set time to 0 for a perpetual message that is dismissed on keypress. */ + log(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void; + /** display a message for a time (default is 3 seconds). set time to 0 for a perpetual message that is dismissed on keypress. */ + display(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void; + /** display an error in the same way. */ + error(text:string, timeOrCallback:number|MessageCallback, callback?:MessageCallback): void; + } + + export interface MessageCallback { + (): void; + } + + + // + // Loading + // + + export interface LoadingOptions extends BoxOptions { + } + + /** A box with a spinning line to denote loading (automatically hidden). */ + export class Loading extends Box + { + constructor(options?:LoadingOptions); + + /** display the loading box with a message. will lock keys until `stop` is called. */ + load(text:string): void; + /** hide loading box. unlock keys. */ + stop(): void; + } + + + // + // Listbar + // + + export interface ListbarOptions extends BoxOptions + { + /** Listbar's `style` object includes sub-styles for `selected` and `item`. */ + style?: ListbarStyle; + + /** set buttons using an object with keys as titles of buttons, containing of objects containing keys of `keys` and `callback`. */ + items?: ListbarItemSet; + /** set buttons using an object with keys as titles of buttons, containing of objects containing keys of `keys` and `callback`. */ + commands?: ListbarItemSet; + /** automatically bind list buttons to keys 0-9. */ + autoCommandKeys?: boolean; + } + + export interface ListbarItemSet { + [name: string]: ListbarItem; + } + + export interface ListbarItem { + keys: string[]; + callback: GenericCallback; + } + + export interface ListbarStyle extends Style + { + /** style for a selected item. */ + selected: Style; + /** style for an unselected item. */ + item: Style; + } + + /** A horizontal list. Useful for a main menu bar. */ + export class Listbar extends Box + { + constructor(options?:ListbarOptions); + + /** append an item to the bar. */ + add(item:ListbarItem, callback:GenericCallback): void; + /** append an item to the bar. */ + addItem(item:ListbarItem, callback:GenericCallback): void; + /** append an item to the bar. */ + appendItem(item:ListbarItem, callback:GenericCallback): void; + + /** select button and execute its callback. */ + selectTab(index: number): void; + + /** set commands (see `commands` option above). */ + setItems(commands: ListbarItemSet): void; + /** select an item on the bar. */ + select(offset: number): void; + /** remove item from the bar. */ + removeItem(child:ListbarItem): void; + /** move focus relatively across the bar. */ + move(offset: number): void; + /** move focus left relatively across the bar. */ + moveLeft(offset: number): void; + /** move focus right relatively across the bar. */ + moveRight(offset: number): void; + } + + + // + // Log + // + + export interface LogOptions extends ScrollableTextOptions { + /** amount of scrollback allowed. default: Infinity. */ + scrollback?: number; + /** scroll to bottom on input even if the user has scrolled up. default: false. */ + scrollOnInput?: boolean; + } + + + /** A log permanently scrolled to the bottom. */ + export class Log extends ScrollableText + { + constructor(options?:LogOptions); + + /** amount of scrollback allowed. default: Infinity. */ + scrollback: number; + /** scroll to bottom on input even if the user has scrolled up. default: false. */ + scrollOnInput: boolean; + + /** add a log line. */ + log(text:string): void; + /** add a log line. */ + add(text:string): void; + } + + + // + // Table + // + + export interface TableOptions extends BoxOptions + { + /** array of array of strings representing rows (same as `data`). */ + rows?: string[][]; + /** array of array of strings representing rows (same as `rows`). */ + data?: string[][]; + /** spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side (only useful if the width is shrunken). */ + pad?: number; + /** do not draw inner cells. */ + noCellBorders?: boolean; + /** fill cell borders with the adjacent background color. */ + fillCellBorders?: boolean; + + /** includes `header` and `cell` substyles. */ + style?: TableStyle; + } + + export interface TableStyle extends Style { + /** header style. */ + header: Style; + /** cell style. */ + cell: Style; + } + + /** A stylized table of text elements. */ + export class Table extends Box + { + /** includes `header` and `cell` substyles. */ + style: TableStyle; + + /** set rows in table. array of arrays of strings. */ + setData(rows: string[][]): void; + /** set rows in table. array of arrays of strings. */ + setRows(rows: string[][]): void; + } + + + // + // ListTable + // + + export interface ListTableOptions extends ListOptions + { + /** array of array of strings representing rows (same as `data`). */ + rows?: string[][]; + /** array of array of strings representing rows (same as `rows`). */ + data?: string[][]; + /** spaces to attempt to pad on the sides of each cell. `2` by default: one space on each side (only useful if the width is shrunken). */ + pad?: number; + + /** do not draw inner cells. */ + noCellBorders?: boolean; + + /** includes `header` and `cell` substyles. */ + style?: TableStyle; + } + + export interface ListTableStyle extends TableStyle { + } + + + /** A stylized table of text elements with a list. */ + export class ListTable extends List + { + constructor(options?:ListTableOptions); + + /** set rows in table. array of arrays of strings. */ + setData(rows: string[][]): void; + /** set rows in table. array of arrays of strings. */ + setRows(rows: string[][]): void; + } + + // + // Image + // + + export interface ImageOptions extends BoxOptions { + /** path to image. */ + file: string; + /** path to w3mimgdisplay. if a proper w3mimgdisplay path is not given, blessed will search the entire disk for the binary. */ + w3m: string; + } + + + /** Display an image in the terminal (jpeg, png, gif) using w3mimgdisplay. Requires w3m to be installed. X11 required: works in xterm, urxvt, and possibly other terminals. */ + export class Image extends Box + { + constructor(options?:ImageOptions); + + /** set the image in the box to a new path. */ + setImage (img:string, callback:GenericCallback): void; + /** clear the current image. */ + clearImage (callback:GenericCallback): void; + /** get the size of an image file in pixels. */ + imageSize (img:string, callback:GenericCallback): void; + /** get the size of the terminal in pixels. */ + termSize (callback:GenericCallback): void; + /** get the pixel to cell ratio for the terminal. */ + getPixelRatio (callback:GenericCallback): void; + } + + + // + // Form + // + + export interface FormOptions extends BoxOptions { + /** allow default keys (tab, vi keys, enter). */ + keys?:boolean; + /** allow vi keys. */ + vi?:boolean; + } + + export class Form extends Box + { + constructor(options?:FormOptions); + + /** last submitted data. */ + submission: any; + + // on(event:string, callback:() => void): void; + // on(event:'submit', callback:(data) => void): void; + // on(event:'cancel', callback:() => void): void; + // on(event:'reset', callback:() => void): void; + + next(): void; + previous(): void; + + resetSelected(): void; + /** focus first form element. */ + focusFirst(): void; + /** focus last form element. */ + focusLast(): void; + /** focus next form element. */ + focusNext(): void; + /** focus previous form element. */ + focusPrevious(): void; + /** submit the form. */ + submit(): void; + /** discard the form. */ + cancel(): void; + /** clear the form. */ + reset(): void; + } + + + // + // FileManager + // + + export interface FileManagerOptions extends ListOptions { + cwd?: string; + } + + export interface DirectoryEntry { + name: string; + text: string; + dir: boolean; + symlink: boolean; + } + + export class FileManager extends List + { + constructor(options?:FileManagerOptions); + + cwd: string; + + useFormatter (formatterFn:(entry:DirectoryEntry) => DirectoryEntry): void; + + /** refresh the file list (perform a readdir on cwd and update the list items). */ + refresh (cwd?:string, callback?:() => void): void; + + /** refresh the file list. */ + refresh (callback?:() => void): void; + + /** reset back to original cwd. */ + reset (cwd?:string, callback?:() => void): void; + } + + + // + // Terminal + // + + export interface TerminalOptions extends BoxOptions + { + /** handler for input data. */ + handler?: (userInput:Buffer) => void; + /** name of shell. $SHELL by default. */ + shell?:string; + /** args for shell. */ + args?:any; + /** can be line, underline, and block. */ + cursor?:string; //'line'|'underline'|'block'; + } + + export class Terminal extends Box + { + /** reference to the headless term.js terminal. */ + term: any; + /** reference to the pty.js pseudo terminal. */ + pty: any; + + /** write data to the terminal. */ + write(data:string): void; + + /** nearly identical to `element.screenshot`, however, the specified region includes the terminal's _entire_ scrollback, rather than just what is visible on the screen. */ + screenshot(xi?:number, xl?:number, yi?:number, yl?:number): string; + } + + + export interface NodeChildProcessExecOptions + { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + } + } + + export = Blessed; +} + + + From efd7ae7dd16f7d27e4abf5ec1aa885c07f134e1c Mon Sep 17 00:00:00 2001 From: crissdev Date: Tue, 7 Jul 2015 15:56:05 +0300 Subject: [PATCH 0008/1850] improve definition for knockout.punches --- knockout.punches/knockout.punches-tests.ts | 24 ++++++++++++++++++- knockout.punches/knockout.punches.d.ts | 28 ++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/knockout.punches/knockout.punches-tests.ts b/knockout.punches/knockout.punches-tests.ts index bd5d53a5c5..bec2b1a4ef 100644 --- a/knockout.punches/knockout.punches-tests.ts +++ b/knockout.punches/knockout.punches-tests.ts @@ -2,7 +2,29 @@ function test_enable() { - ko.punches.enableAll(); +} +function test_filters() { + ko.filters.default([], 'Empty'); + ko.filters.default(null, 'Empty'); + ko.filters.default(0, 'Empty'); + ko.filters.default(' ', 'Empty'); + + ko.filters.fit('abcdef0123456789', 10); + ko.filters.fit('abcdef0123456789', 10, '_'); + ko.filters.fit('abcdef0123456789', 10, '_', 'left'); + ko.filters.fit('abcdef0123456789', 10, '_', 'middle'); + ko.filters.fit('abcdef0123456789', 10, '_', 'right'); + + ko.filters.json({}); + ko.filters.json({}, null, 4); + + ko.filters.number('123456789'); + ko.filters.number(12345.6789); + + ko.filters.lowercase('TEST'); + ko.filters.uppercase('test'); + + ko.filters.replace('1234abcd', '1234', ''); } \ No newline at end of file diff --git a/knockout.punches/knockout.punches.d.ts b/knockout.punches/knockout.punches.d.ts index d219d61f15..8bcb29ee89 100644 --- a/knockout.punches/knockout.punches.d.ts +++ b/knockout.punches/knockout.punches.d.ts @@ -9,8 +9,36 @@ interface KnockoutPunchesStatic { enableAll(): void; } +interface KnockoutPunchesFilters { + // Convert the value to uppercase. + uppercase(value: string): string; + + // Convert the value to lowercase. + lowercase(value: string): string; + + // Perform a search and replace on the value using String#replace. + replace(value: string, search: string, replace: string): string; + + // Trim the value if it’s longer than the given length. The trimmed portion is + // replaced with ... or the replacement value, if given. By default, the value + // is trimmed on the right but can be changed to left or middle through the + // where option. For example: name | fit:10::'middle' will + // convert Shakespeare to Shak...are. + fit(value: number | string, length?: number, replacement?: string, trimWhere?: string): string; + + // Convert the value to a JSON string using ko.toJSON. You can give a space value to format the JSON output. + json(rootObject: any, space?: any, replacer?: any): string; + + // Format the value using toLocaleString. + number(value: number | string): string; + + // If the value is blank, null, or an empty array, replace it with the given default value + default(value: any, defaultValue?: any): any; +} + interface KnockoutStatic { punches: KnockoutPunchesStatic; + filters: KnockoutPunchesFilters; } declare module "knockout.punches" { From 83993bac9533e17f7a469aae02f79f7e68decb7a Mon Sep 17 00:00:00 2001 From: kimamula Date: Wed, 30 Sep 2015 00:26:52 +0900 Subject: [PATCH 0009/1850] update jQuery.append, prepend, before and after --- jquery/jquery-tests.ts | 17 ++++++++++++++--- jquery/jquery.d.ts | 16 ++++++++-------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 1f723fde32..b9e835ebc7 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -41,7 +41,7 @@ function test_addClass() { function test_after() { $('.inner').after('

Test

'); - $('
').after('

'); + $('
').after('

').after(document.createDocumentFragment()); $('
').after('

').addClass('foo') .filter('p').attr('id', 'bar').html('hello') .end() @@ -504,7 +504,7 @@ function test_toggle() { function test_append() { $('.inner').append('

Test

'); - $('.container').append($('h2')); + $('.container').append($('h2')).append(document.createDocumentFragment()); var $newdiv1 = $('
'), newdiv2 = document.createElement('div'), @@ -554,7 +554,7 @@ function test_attributeSelectors() { function test_before() { $('.inner').before('

Test

'); - $('.container').before($('h2')); + $('.container').before($('h2')).before(document.createDocumentFragment()); $("
").before("

"); var $newdiv1 = $('
'), newdiv2 = document.createElement('div'), @@ -941,6 +941,17 @@ function test_clone() { .clone()); } +function test_prepend() { + $('.inner').prepend('

Test

'); + $('.container').prepend($('h2')).prepend(document.createDocumentFragment()); + + var $newdiv1 = $('
'), + newdiv2 = document.createElement('div'), + existingdiv1 = document.getElementById('foo'); + + $('body').prepend($newdiv1, [newdiv2, existingdiv1]); +} + function test_prependTo() { $("

Test

").prependTo(".inner"); $("h2").prependTo($(".container")); diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 3641af8503..8f99ce3d5d 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2579,10 +2579,10 @@ interface JQuery { /** * Insert content, specified by the parameter, after each element in the set of matched elements. * - * param content1 HTML string, DOM element, array of elements, or jQuery object to insert after each element in the set of matched elements. + * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert after each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert after each element in the set of matched elements. */ - after(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + after(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, after each element in the set of matched elements. * @@ -2593,10 +2593,10 @@ interface JQuery { /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * - * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. + * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the end of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the end of each element in the set of matched elements. */ - append(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + append(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the end of each element in the set of matched elements. * @@ -2614,10 +2614,10 @@ interface JQuery { /** * Insert content, specified by the parameter, before each element in the set of matched elements. * - * param content1 HTML string, DOM element, array of elements, or jQuery object to insert before each element in the set of matched elements. + * param content1 HTML string, DOM element, DocumentFragment, array of elements, or jQuery object to insert before each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert before each element in the set of matched elements. */ - before(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + before(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, before each element in the set of matched elements. * @@ -2662,10 +2662,10 @@ interface JQuery { /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * - * param content1 DOM element, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. + * param content1 DOM element, DocumentFragment, array of elements, HTML string, or jQuery object to insert at the beginning of each element in the set of matched elements. * param content2 One or more additional DOM elements, arrays of elements, HTML strings, or jQuery objects to insert at the beginning of each element in the set of matched elements. */ - prepend(content1: JQuery|any[]|Element|Text|string, ...content2: any[]): JQuery; + prepend(content1: JQuery|any[]|Element|DocumentFragment|Text|string, ...content2: any[]): JQuery; /** * Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. * From 12cae19c1c23a970d76c45032a2559406bd4c666 Mon Sep 17 00:00:00 2001 From: Hiraash Thawfeek Date: Tue, 29 Sep 2015 23:15:53 +0530 Subject: [PATCH 0010/1850] Including definitions for Commangular library The commangular library definitions are added as per https://github.com/yukatan/commangular --- commangular/commangular-mock.d.ts | 73 ++++++++ commangular/commangular.d.ts | 273 ++++++++++++++++++++++++++++++ 2 files changed, 346 insertions(+) create mode 100644 commangular/commangular-mock.d.ts create mode 100644 commangular/commangular.d.ts diff --git a/commangular/commangular-mock.d.ts b/commangular/commangular-mock.d.ts new file mode 100644 index 0000000000..8f74b659fc --- /dev/null +++ b/commangular/commangular-mock.d.ts @@ -0,0 +1,73 @@ +// Type definitions for Commangular Mock 0.9.0 +// Project: http://commangular.org +// Definitions by: Hiraash Thawfeek +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module commangular { + + /////////////////////////////////////////////////////////////////////////// + // Commangular Static + // see http://commangular.org/docs/#commangular-namespace + /////////////////////////////////////////////////////////////////////////// + interface ICommAngularStatic { + + /** + * Mock dispatch function for testing commands. + */ + dispatch( ec: ICommandCall, callback: Function ); + } + + interface ICommandCall { + /** + * Name of the command that needs to + * execute + */ + command: string; + + /** + * Data that needs to be passed to the command + */ + data?: any; + } + + + /** + * Object type expected to be passed into the callback function + * of the dispatch() function + */ + interface ICommandInfo { + /** + * The data that was passed into the command + * @param key The property name that is in the object that was passed + */ + dataPassed( key : string ) : any; + + /** + * The data that was returned by the command + * @param key The result key that was defined in the command. If no result + * was defined use 'lastResult' as the key + */ + resultKey( key: string ): any; + + /** + * Indicates if the command execution was cancelled. + */ + canceled( ): boolean; + + /** + * Indicates if the command was executed???? + */ + commandExecuted( ): boolean; + } + +} + + +/** +* Mock dispatch function for testing commands. +* @param ec an ICommandCall object +* @param callback The function that will be called upon the completion of the command +* function should expecte an ICommandInfo paramter. +*/ +declare function dispatch( ec: commangular.ICommandCall, callback: Function ); + diff --git a/commangular/commangular.d.ts b/commangular/commangular.d.ts new file mode 100644 index 0000000000..bf3cbb5d94 --- /dev/null +++ b/commangular/commangular.d.ts @@ -0,0 +1,273 @@ +// Type definitions for Commangular 0.9.0 +// Project: http://commangular.org +// Definitions by: Hiraash Thawfeek +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare var commangular: commangular.ICommAngularStatic; + +declare module commangular { + + /////////////////////////////////////////////////////////////////////////// + // Commangular Static + // see http://commangular.org/docs/#commangular-namespace + /////////////////////////////////////////////////////////////////////////// + interface ICommAngularStatic { + + /** + * Use this function to create and register a command with Commangular + * + * @param commandName It's the name of the command you are creating. It's useful to reference the command from the command provider. + * @param commandFunction It's the command class that will be executed when commangular runs this command. + * It has to be something that implements ICommand. Same as angular syntax + * @param commandConfig It's and object with paramaters to configure the command execution. + */ + create (commandName: string, commandFunction: Function, commandConfig?:ICommandConfig) : void; + command (commandName: string, commandFunction: Function, commandConfig?:ICommandConfig) : void; + + /** + * This function allows you to hijack the execution before or after and + * execute some cross cutting functionality. + * see http://commangular.org/docs/#command-aspects + * @param aspectDescriptor The interceptor descriptor has two parts 'Where' and 'What'. + * Where do you want to intercept? you've 5 options : + * - @Before : The interceptor will be executed before the command. You will be able to + * cancel the command or modify the data that will be injected in the command or do + * some other operation you need before the command execution. + * - @After : The interceptor will be executed just after the command and before any other next + * command. You can get the lastResult from the command, cancel execution etc etc. + * - @AfterExecution : This intercetor is executed just after the command execute method and + * it can get the result from the command and update it before the onResult method is executed. + * - @AfterThrowing : This interceptor will be executed if the command or any interceptor of + * the command throws an exception. You can get the error throwed injected to do what you need. + * - @Around : The interceptor is executed around a command.That means that a especial + * object 'processor' will be injected in the interceptor and you can invoke the command + * or the next interceptor. It will be better explained below. + * @param aspectFunction It's the command class execute function that will be run for the given aspect. + * @param order You can chain any number of interceptors to the same command, so if you need to executed + * the interceptor in a specific order you can indicate it here. An order of 0 is assigned by default. + */ + aspect ( aspectDescriptor: string, aspectFunction: ICommand, order: number ) : void; + + /** + * Event aspects work the same way command aspects do, but they intercept all the command groups instead, + * so you can run some function before the command group starts it's execution , after or when any + * command or interceptor in the group throw an exception. + * see http://commangular.org/docs/#event-aspects + * @param aspectDescriptor The interceptor descriptor has two parts 'Where' and 'What'. + * Where do you want to intercept? you've 3 options : + * - @Before : The interceptor will be executed before the command. You will be able to + * cancel the command or modify the data that will be injected in the command or do + * some other operation you need before the command execution. + * - @After : The interceptor will be executed just after the command and before any other next + * command. You can get the lastResult from the command, cancel execution etc etc. + * - @AfterThrowing : This interceptor will be executed if the command or any interceptor of + * the command throws an exception. You can get the error throwed injected to do what you need. + * @param aspectFunction It's the command class execute function that will be run for the given aspect. + * @param order You can chain any number of interceptors to the same command, so if you need to executed + * the interceptor in a specific order you can indicate it here. An order of 0 is assigned by default. + */ + eventAspect( aspectDescriptor: string, aspectFunction: ICommand, order: number ) : void; + + /** + * TBD + */ + resolver( commandName: string, resolverFunction ) : void; + + /** + * Clears all commands and aspects registered with commangular. + */ + reset() : void; + + /** + * Can be used to enable/disable debug + */ + debug( enableDebug : boolean ) : void; + + /** + * TBD + */ + build() : void; + } + + /** + * The command function/object + * see http://commangular.org/docs/#commangular-namespace + */ + interface ICommand { + /** + * This function is what gets called when the command executes. + * It can take parameters in as injected by angular + */ + execute() : any; + + } + + interface IResultCommand extends ICommand{ + /** + * Is executed after the execute method and the interception chain and can receive + * the result from the execute method of the same command. + * + * @param result Value/object returned by the execution. + */ + onResult ( result: any ) : void; + + /** + * Is executed when the executed method ends with an error. Can receive the error throw by the execute method. + * @param error The error that occured during execution + */ + onError ( error: Error ) : void; + } + + /** + * The result object expected in the promise returned by the dispatch function + * This must be extended to add custom result keys + * see http://commangular.org/docs/#returning-result-from-commands + */ + interface ICommandResult { + /** + * By defualt the result of the command will be found in this property + */ + lastResult : any; + } + + /** + * Command creation configuration + * see http://commangular.org/docs/#the-command-config-object + */ + interface ICommandConfig { + /** + * This property instruct commangular to keep the value returned by the command in the value + * key passed in 'resultKey'. It has to be a string. It means that after the execution of this + * commands you will be able to inject on the next command using that key and the result of the command will be injected. + */ + resultKey : string; + } + + /** + * All the command configuration of your application is done in an angular config block and + * with the $commangularProvider. The provider is responsible to build the command strutures and + * map them to the desired event names. You can create multiple configs blocks in angular, so you + * can have multiple command config blocks to separate functional parts of your application. + * see http://commangular.org/docs/#using-the-provider + */ + interface ICommAngularProvider { + + /** + * This function lets you map a even name to a command sequence + * @param eventName An event that will be watched by commangular + */ + mapTo( eventName: string ) : ICommAngularDescriptor; + + /** + * Used along with mapTo function. Creates a sequence of commands that + * execute after one and other + * see http://commangular.org/docs/#building-command-sequences + */ + asSequence(): ICommAngularDescriptor; + + /** + * Used along with mapTo function. Maps commands to be executed parallel + * see http://commangular.org/docs/#building-parallel-commands + */ + asParallel(): ICommAngularDescriptor; + + /** + * A command flow is a decision point inside the command group.You can have any number + * of flows inside a command group and nesting them how you perfer. + * see http://commangular.org/docs/#building-command-flows + */ + asFlow(): ICommAngularDescriptor; + + findCommand( eventName: string ): ICommAngularDescriptor; + + } + + /** + * The service that enables the execution of commands + * see http://commangular.org/docs/#dispatching-events + */ + interface ICommAngularService { + + /** + * This function executes the given command sequence. + * see http://commangular.org/docs/#dispatching-events + * @param eventName Name of the even that will trigger a command sequence + * @param data Data of any type that will be passed to the command. + */ + dispatch( eventName: string, data?: any ) : ng.IPromise; + } + + interface ICommAngularDescriptor { + + /** + * Used along with mapTo function. Creates a sequence of commands that + * execute after one and other + * see http://commangular.org/docs/#building-command-sequences + */ + asSequence (): ICommAngularDescriptor; + + /** + * Used along with mapTo function. Maps commands to be executed parallel + * see http://commangular.org/docs/#building-parallel-commands + */ + asParallel(): ICommAngularDescriptor; + + /** + * A command flow is a decision point inside the command group.You can have any number + * of flows inside a command group and nesting them how you perfer. + * see http://commangular.org/docs/#building-command-flows + */ + asFlow(): ICommAngularDescriptor; + + /** + * Add commands to a descriptor. + * @param command The name that was used to create the command. + */ + add ( command: string ): ICommAngularDescriptor; + + /** + * Add descriptor to a descriptor. + * @param descriptor Another descriptor attached to a sequnce of commands. + */ + add ( descriptor: ICommAngularDescriptor ): ICommAngularDescriptor; + + /** + * This is to be used with flowing commands to attach an expression that + * evaluates using Angular $parse. + * see http://commangular.org/docs/#building-command-flows + * @param expression A string form expression that can make use of services to validate conditions. + * @param services A comma seperated list of services that are used in the above expression + */ + link ( expression: string, services?: string ): ICommAngularDescriptor; + + /** + * Works with the link function to attach a command to the flow if the + * expression becomes truthy. + * see http://commangular.org/docs/#building-command-flows + * @param command The name that was used to create the command. + */ + to ( command: string ): ICommAngularDescriptor; + + } + +} + +/** + * Extending the angular rootScope to include the dispatch function in all scopes. + */ +declare module angular { + + interface IRootScopeService { + + /** + * Commangular method to execute a command. + * @param eventName Name of the even that will trigger a command sequence + * @param data Data of any type that will be passed to the command. + */ + dispatch( eventName: string, data?: any ) : ng.IPromise; + + } + +} \ No newline at end of file From 683a6e7ec04521ccffc299fd89bcedd870d7582b Mon Sep 17 00:00:00 2001 From: Hiraash Thawfeek Date: Tue, 29 Sep 2015 23:31:03 +0530 Subject: [PATCH 0011/1850] Fixes for missing parts of the definition based on the CI test on DefinitelyTyped --- commangular/commangular-mock.d.ts | 4 ++-- commangular/commangular.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commangular/commangular-mock.d.ts b/commangular/commangular-mock.d.ts index 8f74b659fc..134e4d0d1e 100644 --- a/commangular/commangular-mock.d.ts +++ b/commangular/commangular-mock.d.ts @@ -14,7 +14,7 @@ declare module commangular { /** * Mock dispatch function for testing commands. */ - dispatch( ec: ICommandCall, callback: Function ); + dispatch( ec: ICommandCall, callback: Function ): void; } interface ICommandCall { @@ -69,5 +69,5 @@ declare module commangular { * @param callback The function that will be called upon the completion of the command * function should expecte an ICommandInfo paramter. */ -declare function dispatch( ec: commangular.ICommandCall, callback: Function ); +declare function dispatch( ec: commangular.ICommandCall, callback: Function ): void; diff --git a/commangular/commangular.d.ts b/commangular/commangular.d.ts index bf3cbb5d94..b03a22574e 100644 --- a/commangular/commangular.d.ts +++ b/commangular/commangular.d.ts @@ -73,7 +73,7 @@ declare module commangular { /** * TBD */ - resolver( commandName: string, resolverFunction ) : void; + resolver( commandName: string, resolverFunction : Function ) : void; /** * Clears all commands and aspects registered with commangular. From c1f3aa4bc80f8f3c73d17db9fd6ef0003e7f0b18 Mon Sep 17 00:00:00 2001 From: James Gardner Date: Mon, 5 Oct 2015 09:39:03 +1300 Subject: [PATCH 0012/1850] Added AddClasses option to DroppableOptions interface The AddClasses option seems to be missing from the DroppableOptions interface. I have added it to the interface and alphabetically re-ordered the options so they match with the jQueryUI documentation. --- jqueryui/jqueryui.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index a49a779e28..2487087d60 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -474,9 +474,10 @@ declare module JQueryUI { } interface DroppableOptions extends DroppableEvents { - disabled?: boolean; accept?: any; activeClass?: string; + addClasses?: boolean; + disabled?: boolean; greedy?: boolean; hoverClass?: string; scope?: string; From e36c90fb816f60509bdf3984d4851ad6a63446a7 Mon Sep 17 00:00:00 2001 From: Simon Gausmann Date: Thu, 15 Oct 2015 14:43:40 +0200 Subject: [PATCH 0013/1850] adding typings for node-cache-manager lib --- cache-manager/cache-manager-tests.ts | 51 ++++++++++++++++++++++++++++ cache-manager/cache-manager.d.ts | 36 ++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 cache-manager/cache-manager-tests.ts create mode 100644 cache-manager/cache-manager.d.ts diff --git a/cache-manager/cache-manager-tests.ts b/cache-manager/cache-manager-tests.ts new file mode 100644 index 0000000000..36d2a559a0 --- /dev/null +++ b/cache-manager/cache-manager-tests.ts @@ -0,0 +1,51 @@ +/// + +import * as cacheManager from 'cache-manager' + +const memoryCache = cacheManager.caching({store: 'memory', max: 100, ttl: 10/*seconds*/}); +const ttl = 5; + +memoryCache.set('foo', 'bar', {ttl: ttl}, (err) => { + + if (err) { + throw err; + } + + memoryCache.get('foo', (err, result) => { + + // console.log(result); + + memoryCache.del('foo', (err) => { + }); + + }); +}); + +function getUser(id:number, cb:Function) { + + cb(null, {id: id, name: 'Bob'}); +} + +const userId = 123; +const key = 'user_' + userId; + +// Note: ttl is optional in wrap() +memoryCache.wrap<{id: number, name: string}>(key, (cb) => { + + getUser(userId, cb); + +}, {ttl: ttl}, (err, user) => { + + //console.log(user); + + // Second time fetches user from memoryCache + memoryCache.wrap<{id: number, name: string}>(key, (cb)=> { + + getUser(userId, cb); + + }, (err, user) => { + + //console.log(user); + + }); +}); \ No newline at end of file diff --git a/cache-manager/cache-manager.d.ts b/cache-manager/cache-manager.d.ts new file mode 100644 index 0000000000..e7cad31740 --- /dev/null +++ b/cache-manager/cache-manager.d.ts @@ -0,0 +1,36 @@ +// Type definitions for cache-manager v1.2.0 +// Project: https://github.com/BryanDonovan/node-cache-manager +// Definitions by: Simon Gausmann www.gausmann-media.de +// Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module 'cache-manager' { + + + interface ICachingConfig { + ttl: number; + } + interface IStoreConfig extends ICachingConfig { + store:string; + max?: number; + isCacheableValue?:(value:any)=>boolean; + } + interface ICache { + set(key:string, value:T, options:ICachingConfig, callback?:(error:any)=>void):void; + set(key:string, value:T, ttl:number, callback?:(error:any)=>void):void; + + wrap(key:string, wrapper:(callback:(error:any, result:T)=>void)=>void, options:ICachingConfig, callback:(error:any, result:T)=>void):void; + wrap(key:string, wrapper:(callback:(error:any, result:T)=>void)=>void, callback:(error:any, result:T)=>void):void; + + get(key:string, callback:(error:any, result:T)=>void):void; + + del(key:string, callback?:(error:any)=>void):void; + } + + + module cacheManager { + function caching(ICongig:IStoreConfig):ICache; + + function multiCaching(Caches:ICache[]):ICache; + } + + export = cacheManager; +} \ No newline at end of file From d1b97507ac1b9097e48a8cf2abd23f1a5c0c38d1 Mon Sep 17 00:00:00 2001 From: Simon Gausmann Date: Thu, 15 Oct 2015 15:05:49 +0200 Subject: [PATCH 0014/1850] website in comments --- cache-manager/cache-manager.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cache-manager/cache-manager.d.ts b/cache-manager/cache-manager.d.ts index e7cad31740..d912f9f7bd 100644 --- a/cache-manager/cache-manager.d.ts +++ b/cache-manager/cache-manager.d.ts @@ -1,6 +1,6 @@ // Type definitions for cache-manager v1.2.0 // Project: https://github.com/BryanDonovan/node-cache-manager -// Definitions by: Simon Gausmann www.gausmann-media.de +// Definitions by: Simon Gausmann // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module 'cache-manager' { @@ -26,6 +26,7 @@ declare module 'cache-manager' { } + module cacheManager { function caching(ICongig:IStoreConfig):ICache; @@ -33,4 +34,4 @@ declare module 'cache-manager' { } export = cacheManager; -} \ No newline at end of file +} From d201ae04f7545013f581da033384ec7e967b14b2 Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Thu, 15 Oct 2015 14:05:21 -0400 Subject: [PATCH 0015/1850] Sylvester type definitions --- sylvester/sylvester-test.ts | 207 +++++++++ sylvester/sylvester.d.ts | 825 ++++++++++++++++++++++++++++++++++++ 2 files changed, 1032 insertions(+) create mode 100644 sylvester/sylvester-test.ts create mode 100644 sylvester/sylvester.d.ts diff --git a/sylvester/sylvester-test.ts b/sylvester/sylvester-test.ts new file mode 100644 index 0000000000..1eb5e076ec --- /dev/null +++ b/sylvester/sylvester-test.ts @@ -0,0 +1,207 @@ +/// +interface IAny { + a: any; +} + +var obj: IAny; +var n: number = 0; +var bool: boolean = false; +var str: string = ''; + +var l: Line = Line.create(v, v); +var m: Matrix = Matrix.create(v); +var p: Plane = Plane.create(v, v); +var v: Vector = Vector.create([n, n]); + +l = Line.create([n], [n]); +l = Line.X; +l = Line.Y; +l = Line.Z; +v = l.anchor; +bool = l.contains(v); +v = l.direction; +n = l.distanceFrom(l); +n = l.distanceFrom(v); +n = l.distanceFrom(p); +l = l.dup(); +bool = l.eql(l); +v = l.intersectionWith(l); +v = l.intersectionWith(p); +bool = l.intersects(l); +bool = l.intersects(p); +bool = l.isParallelTo(l); +bool = l.isParallelTo(p); +bool = l.liesIn(p); +v = l.pointClosestTo(l); +v = l.pointClosestTo(v); +l = l.reflectionIn(l); +l = l.reflectionIn(p); +l = l.reflectionIn(v); +l = l.rotate(n, l); +l = l.rotate(n, v); +l = l.setVectors([n, n], v); +l = l.setVectors(v, [n, n]); +l = l.translate(v); +l = l.translate([n, n]); + +m = Matrix.create(m); +m = Matrix.create([n]); +m = Matrix.create([[n]]); +m = Matrix.create(v); +m = Matrix.Diagonal(m); +m = Matrix.Diagonal([n]); +m = Matrix.Diagonal([[n]]); +m = Matrix.Diagonal(v); +m = Matrix.I(n); +m = Matrix.Random(n, n); +m = Matrix.Rotation(n); +m = Matrix.Rotation(n, v); +m = Matrix.RotationX(n); +m = Matrix.RotationY(n); +m = Matrix.RotationZ(n); +m = Matrix.Zero(n, n); +m = m.add(m); +m = m.augment(m); +m = m.augment(v); +bool = m.canMultiplyFromLeft(m); +v = m.col(n); +n = m.cols(); +n = m.det(); +n = m.determinant(); +v = m.diagonal(); +obj = m.dimensions(); +m = m.dup(); +v = m.e(n, n); +var element: number[][] = m.elements; +bool = m.eql(m); +bool = m.eql(v); +obj = m.indexOf(n); +str = m.inspect(); +m = m.inv(); +m = m.inverse(); +bool = m.isSameSizeAs(m); +bool = m.isSingular(); +bool = m.isSquare(); + +m = m.map((x, i, j) => { + n = x; + n = i; + n = j; +}); + +n = m.max(); +m = m.minor(n, n, n, n); +m = m.multiply(n); +m = m.multiply(m); +v = m.multiply(v); +n = m.rank(); +n = m.rk(); +m = m.round(); +v = m.row(n); +n = m.rows(); +m = m.setElements(m); +m = m.setElements([n, n]); +m = m.setElements([[n, n]]); +m = m.setElements(v); +m = m.snapTo(n); +m = m.subtract(m); +m = m.toRightTriangular(); +m = m.toUpperTriangular(); +n = m.tr(); +n = m.trace(); +m = m.transpose(); +m = m.x(m); +m = m.x(n); +v = m.x(v); + +p = Plane.create([0], [0]); +p = Plane.XY; +p = Plane.YX; +p = Plane.YZ; +p = Plane.ZX; +v = p.anchor; +bool = p.contains(v); +bool = p.contains(l); +n = p.distanceFrom(p); +n = p.distanceFrom(v); +n = p.distanceFrom(l); +p = p.dup(); +bool = p.eql(p); +v = p.intersectionWith(l); +l = p.intersectionWith(p); +bool = p.intersects(p); +bool = p.intersects(l); +bool = p.isParallelTo(p); +bool = p.isParallelTo(l); +bool = p.isPerpendicularTo(p); +v = p.normal; +v = p.pointClosestTo(v); +p = p.reflectionIn(p); +p = p.reflectionIn(v); +p = p.reflectionIn(l); +p = p.rotate(n, l); +p = p.setVectors([n], [n]); +p = p.setVectors(v, v); +p = p.setVectors([n], [n], [n]); +p = p.setVectors(v, v, v); +p = p.translate([n]); +p = p.translate(v); + +v = Vector.create(v); +v = Vector.i; +v = Vector.j; +v = Vector.k; +v = Vector.Random(n); +v = Vector.Zero(n); +v = v.add(v); +v = v.add([n, n]); +n = v.angleFrom(v); +v = v.cross(v); +v = v.cross([n, n]); +n = v.dimensions(); +n = v.distanceFrom(v); +n = v.distanceFrom(l); +n = v.distanceFrom(p); +n = v.dot(v); +n = v.dot([n, n]); +v = v.dup(); +n = v.e(n); + +v.each((x, i) => { + n = x; + n = i; +}); + +var elements: number[] = v.elements; +bool = v.eql(v); +bool = v.eql([n, n]); +n = v.indexOf(n); +str = v.inspect(); +bool = v.isAntiparallelTo(v); +bool = v.isParallelTo(v); +bool = v.isPerpendicularTo(v); +bool = v.liesIn(p); +bool = v.liesOn(l); + +v = v.map((x, i) => { + n = x; + n = i; +}); + +n = v.max(); +n = v.modulus(); +v = v.multiply(n); +v = v.reflectionIn(v); +v = v.reflectionIn(l); +v = v.reflectionIn(p); +v = v.rotate(n, v); +v = v.rotate(n, l); +v = v.round(); +v = v.setElements(v); +v = v.setElements([n, n]); +v = v.snapTo(n); +v = v.subtract(v); +v = v.to3D(); +m = v.toDiagonalMatrix(); +v = v.toUnitVector(); +v = v.x(n); \ No newline at end of file diff --git a/sylvester/sylvester.d.ts b/sylvester/sylvester.d.ts new file mode 100644 index 0000000000..0aa869d38c --- /dev/null +++ b/sylvester/sylvester.d.ts @@ -0,0 +1,825 @@ +// Type definitions for sylvester 0.1.3 +// Project: https://github.com/jcoglan/sylvester +// Definitions by: Stephane Alie +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// === Sylvester === +// Vector and Matrix mathematics modules for JavaScript +// Copyright (c) 2007 James Coglan + +interface VectorStatic { + /** + * Constructor function. + */ + create(elements: Vector|Array): Vector; + + i: Vector; + j: Vector; + k: Vector; + + /** + * Random vector of size n. + * + * @param {number} n The vector size. + */ + Random(n: number): Vector; + + /** + * Vector filled with zeros. + * + * @param {number} n The vector size. + */ + Zero(n: number): Vector; +} + +interface Vector { + /** + * Gets an array containing the vector's elements. + */ + elements: Array; + + /** + * Returns element i of the vector. + */ + e(i: number): number; + + /** + * Returns the number of elements the vector has. + */ + dimensions(): number; + + /** + * Returns the modulus ('length') of the vector. + */ + modulus(): number; + + /** + * Returns true if the vector is equal to the argument. + * + * @param {Vector|Array} vector The vector to compare equality. + */ + eql(vector: Vector|Array): boolean; + + /** + * Returns a copy of the vector. + */ + dup(): Vector; + + /** + * Maps the vector to another vector according to the given function. + * + * @param {Function} fn The function to apply to each element (x, i) => {}. + */ + map(fn: (x: number, i: number) => any): Vector; + + /** + * Calls the iterator for each element of the vector in turn. + * + * @param {Function} fn The function to apply to each element (x, i) => {}. + */ + each(fn: (x: number, i: number) => any): void; + + /** + * Returns a new vector created by normalizing the receiver. + */ + toUnitVector(): Vector; + + /** + * Returns the angle between the vector and the argument (also a vector). + * + * @param {Vector} vector The other vector to calculate the angle. + */ + angleFrom(vector: Vector): number; + + /** + * Returns true if the vector is parallel to the argument. + * + * @param {Vector} vector The other vector. + */ + isParallelTo(vector: Vector): boolean; + + /** + * Returns true if the vector is antiparallel to the argument. + * + * @param {Vector} vector The other vector. + */ + isAntiparallelTo(vector: Vector): boolean; + + /** + * Returns true iff the vector is perpendicular to the argument. + * + * @param {Vector} vector The other vector. + */ + isPerpendicularTo(vector: Vector): boolean; + + /** + * Returns the result of adding the argument to the vector. + * + * @param {Vector|Array} vector The vector. + */ + add(vector: Vector|Array): Vector; + + /** + * Returns the result of subtracting the argument from the vector. + * + * @param {Vector|Array} vector The vector. + */ + subtract(vector: Vector|Array): Vector; + + /** + * Returns the result of multiplying the elements of the vector by the argument. + * + * @param {number} k The value by which to multiply the vector. + */ + multiply(k: number): Vector; + + /** + * Returns the result of multiplying the elements of the vector by the argument (Alias for multiply(k)). + * + * @param {number} k The value by which to multiply the vector. + */ + x(k: number): Vector; + + /** + * Returns the scalar product of the vector with the argument. Both vectors must have equal dimensionality. + * + * @param: {Vector|Array} vector The other vector. + */ + dot(vector: Vector|Array): number; + + /** + * Returns the vector product of the vector with the argument. Both vectors must have dimensionality 3. + * + * @param {Vector|Array} vector The other vector. + */ + cross(vector: Vector|Array): Vector; + + /** + * Returns the (absolute) largest element of the vector. + */ + max(): number; + + /** + * Returns the index of the first match found. + * + * @param {number} x The value. + */ + indexOf(x: number): number; + + /** + * Returns a diagonal matrix with the vector's elements as its diagonal elements. + */ + toDiagonalMatrix(): Matrix; + + /** + * Returns the result of rounding the elements of the vector. + */ + round(): Vector; + + /** + * Returns a copy of the vector with elements set to the given value if they differ from + * it by less than Sylvester.precision. + * + * @param {number} x The value to snap to. + */ + snapTo(x: number): Vector; + + /** + * Returns the vector's distance from the argument, when considered as a point in space. + * + * @param {Vector|Line|Plane} obj The object to calculate the distance. + */ + distanceFrom(obj: Vector|Line|Plane): number; + + /** + * Returns true if the vector is point on the given line. + * + * @param {Line} line The line. + */ + liesOn(line: Line): boolean; + + /** + * Return true if the vector is a point in the given plane. + * + * @param {Plane} plane The plane. + */ + liesIn(plane: Plane): boolean; + + /** + * Rotates the vector about the given object. The object should be a point if the vector is 2D, + * and a line if it is 3D. Be careful with line directions! + * + * @param {number} t The angle in radians. + * @param {Vector|Line} obj The rotation axis. + */ + rotate(t: number, obj: Vector|Line): Vector; + + /** + * Returns the result of reflecting the point in the given point, line or plane. + * + * @param {Vector|Line|Plane} obj The object. + */ + reflectionIn(obj: Vector|Line|Plane): Vector; + + /** + * Utility to make sure vectors are 3D. If they are 2D, a zero z-component is added. + */ + to3D(): Vector; + + /** + * Returns a string representation of the vector. + */ + inspect(): string; + + /** + * Set vector's elements from an array. + * + * @param {Vector|Array} els The elements. + */ + setElements(els: Vector|Array): Vector; +} + +interface MatrixStatic { + /** + * Constructor function. + * + * @param {Array|Array>|Vector|Matrix} elements The elements. + */ + create(elements: Array|Array>|Vector | Matrix): Matrix; + + /** + * Identity matrix of size n. + * + * @param {number} n The size. + */ + I(n: number): Matrix; + + /** + * Diagonal matrix - all off-diagonal elements are zero + * + * @param {any} elements The elements. + */ + Diagonal(elements: Array|Array>|Vector | Matrix): Matrix; + + /** + * Rotation matrix about some axis. If no axis is supplied, assume we're after a 2D transform. + * + * @param {number} theta The angle in radians. + * @param {Vector} a [Optional] The axis. + */ + Rotation(theta: number, a?: Vector): Matrix; + + RotationX(t: number): Matrix; + RotationY(t: number): Matrix; + RotationZ(t: number): Matrix; + + /** + * Random matrix of n rows, m columns. + * + * @param {number} n The number of rows. + * @param {number} m The number of columns. + */ + Random(n: number, m: number): Matrix; + + /** + * Matrix filled with zeros. + * + * @param {number} n The number of rows. + * @param {number} m The number of columns. + */ + Zero(n: number, m: number): Matrix; +} + +interface Matrix { + /** + * Gets a nested array containing the matrix's elements. + */ + elements: Array>; + /** + * Returns element (i,j) of the matrix. + * + * @param {number} i The row index. + * @param {number} j The column index. + */ + e(i: number, j: number): any; + + /** + * Returns row k of the matrix as a vector. + * + * @param {number} i The row index. + */ + row(i: number): Vector; + + /** + * Returns column k of the matrix as a vector. + * + * @param {number} j The column index. + */ + col(j: number): Vector; + + /** + * Returns the number of rows/columns the matrix has. + * + * @return {any} An object { rows: , cols: }. + */ + dimensions(): any; + + /** + * Returns the number of rows in the matrix. + */ + rows(): number; + + /** + * Returns the number of columns in the matrix. + */ + cols(): number; + + /** + * Returns true if the matrix is equal to the argument. You can supply a vector as the argument, + * in which case the receiver must be a one-column matrix equal to the vector. + * + * @param {Vector|Matrix} matrix The argument to compare. + */ + eql(matrix: Vector|Matrix): boolean; + + /** + * Returns a copy of the matrix. + */ + dup(): Matrix; + + /** + * Maps the matrix to another matrix (of the same dimensions) according to the given function. + * + * @param {Function} fn The function. + */ + map(fn: (x: number, i: number, j: number) => any): Matrix; + + /** + * Returns true iff the argument has the same dimensions as the matrix. + * + * @param {Matrix} matrix The other matrix. + */ + isSameSizeAs(matrix: Matrix): boolean; + + /** + * Returns the result of adding the argument to the matrix. + * + * @param {Matrix} matrix The matrix to add. + */ + add(matrix: Matrix): Matrix; + + /** + * Returns the result of subtracting the argument from the matrix. + * + * @param {Matrix} matrix The matrix to substract. + */ + subtract(matrix: Matrix): Matrix; + + /** + * Returns true iff the matrix can multiply the argument from the left. + * + * @param {Matrix} matrix The matrix. + */ + canMultiplyFromLeft(matrix: Matrix): boolean; + + /** + * Returns the result of multiplying the matrix from the right by the argument. If the argument is a scalar + * then just multiply all the elements. If the argument is a vector, a vector is returned, which saves you + * having to remember calling col(1) on the result. + * + * @param {number|Matrix} matrix The multiplier. + */ + multiply(matrix: number|Matrix): Matrix; + + /** + * Returns the result of multiplying the matrix from the right by the argument. If the argument is a scalar + * then just multiply all the elements. If the argument is a vector, a vector is returned, which saves you + * having to remember calling col(1) on the result. + * + * @param {Vector} vector The multiplier. + */ + multiply(vector: Vector): Vector; + + x(matrix: number|Matrix): Matrix; + + x(vector: Vector): Vector; + + /** + * Returns a submatrix taken from the matrix. Argument order is: start row, start col, nrows, ncols. + * Element selection wraps if the required index is outside the matrix's bounds, so you could use + * this to perform row/column cycling or copy-augmenting. + * + * @param {number} a Starting row index. + * @param {number} b Starting column index. + * @param {number} c Number of rows. + * @param {number} d Number of columns. + */ + minor(a: number, b: number, c: number, d: number): Matrix; + + /** + * Returns the transpose of the matrix. + */ + transpose(): Matrix; + + /** + * Returns true if the matrix is square. + */ + isSquare(): boolean; + + /** + * Returns the (absolute) largest element of the matrix. + */ + max(): number; + + /** + * Returns the indeces of the first match found by reading row-by-row from left to right. + * + * @param {number} x The value. + * + * @return {any} The element indeces i.e: { row:1, col:1 } + */ + indexOf(x: number): any; + + /** + * If the matrix is square, returns the diagonal elements as a vector; otherwise, returns null. + */ + diagonal(): Vector; + + /** + * Make the matrix upper (right) triangular by Gaussian elimination. This method only adds multiples + * of rows to other rows. No rows are scaled up or switched, and the determinant is preserved. + */ + toRightTriangular(): Matrix; + toUpperTriangular(): Matrix; + + /** + * Returns the determinant for square matrices. + */ + determinant(): number; + det(): number; + + /** + * Returns true if the matrix is singular. + */ + isSingular(): boolean; + + /** + * Returns the trace for square matrices. + */ + trace(): number; + tr(): number; + + /** + * Returns the rank of the matrix. + */ + rank(): number; + rk(): number; + + /** + * Returns the result of attaching the given argument to the right-hand side of the matrix. + * + * @param {Matrix|Vector} matrix The matrix or vector. + */ + augment(matrix: Matrix|Vector): Matrix; + + /** + * Returns the inverse (if one exists) using Gauss-Jordan. + */ + inverse(): Matrix; + inv(): Matrix; + + /** + * Returns the result of rounding all the elements. + */ + round(): Matrix; + + /** + * Returns a copy of the matrix with elements set to the given value if they differ from it + * by less than Sylvester.precision. + * + * @param {number} x The value. + */ + snapTo(x: number): Matrix; + + /** + * Returns a string representation of the matrix. + */ + inspect(): string; + + /** + * Set the matrix's elements from an array. If the argument passed is a vector, the resulting matrix + * will be a single column. + * + * @param {Array|Array>|Vector|Matrix} matrix The elements. + */ + setElements(matrix: Array|Array>|Vector|Matrix): Matrix; +} + +interface LineStatic { + /** + * Constructor function. + * + * @param Array|Vector anchor The anchor vector. + * @param Array|Vector direction The direction vector. + */ + create(anchor: Array|Vector, direction: Array|Vector): Line; + + X: Line; + Y: Line; + Z: Line; +} + +interface Line { + /** + * Gets the 3D vector corresponding to a point on the line. + */ + anchor: Vector; + + /** + * Gets a normalized 3D vector representing the line's direction. + */ + direction: Vector; + + /** + * Returns true if the argument occupies the same space as the line. + * + * @param {Line} line The other line. + */ + eql(line: Line): boolean; + + /** + * Returns a copy of the line. + */ + dup(): Line; + + /** + * Returns the result of translating the line by the given vector/array. + * + * @param {Vector|Array} vector The translation vector. + */ + translate(vector: Vector|Array): Line; + + /** + * Returns true if the line is parallel to the argument. Here, 'parallel to' means that the argument's + * direction is either parallel or antiparallel to the line's own direction. A line is parallel to a + * plane if the two do not have a unique intersection. + * + * @param {Line|Plane} obj The object. + */ + isParallelTo(obj: Line|Plane): boolean; + + /** + * Returns the line's perpendicular distance from the argument, which can be a point, a line or a plane. + * + * @param {Vector|Line|Plane} obj The object. + */ + distanceFrom(obj: Vector|Line|Plane): number; + + /** + * Returns true if the argument is a point on the line. + * + * @param {Vector} point The point. + */ + contains(point: Vector): boolean; + + /** + * Returns true if the line lies in the given plane. + * + * @param {Plane} plane The plane. + */ + liesIn(plane: Plane): boolean; + + /** + * Returns true if the line has a unique point of intersection with the argument. + * + * @param {Line|Plane} obj The object. + */ + intersects(obj: Line|Plane): boolean; + + /** + * Returns the unique intersection point with the argument, if one exists. + * + * @param {Line|Plane} obj The object. + */ + intersectionWith(obj: Line|Plane): Vector; + + /** + * Returns the point on the line that is closest to the given point or line. + * + * @param {Vector|Line} obj The object. + */ + pointClosestTo(obj: Vector|Line): Vector; + + /** + * Returns a copy of the line rotated by t radians about the given line. Works by finding the argument's + * closest point to this line's anchor point (call this C) and rotating the anchor about C. Also rotates + * the line's direction about the argument's. Be careful with this - the rotation axis' direction + * affects the outcome! + * + * @param {number} t The angle in radians. + * @param {Vector|Line} axis The axis. + */ + rotate(t: number, axis: Vector|Line): Line; + + /** + * Returns the line's reflection in the given point or line. + * + * @param {Vector|Line|Plane} obj The object. + */ + reflectionIn(obj: Vector|Line|Plane): Line; + + /** + * Set the line's anchor point and direction. + * + * @param {Array|Vector} anchor The anchor vector. + * @param {Array|Vector} direction The direction vector. + */ + setVectors(anchor: Array|Vector, direction: Array|Vector): Line; +} + +interface PlaneStatic { + /** + * Constructor function. + */ + create(anchor: Array|Vector, normal: Array|Vector): Plane; + + /** + * Constructor function. + */ + create(anchor: Array|Vector, v1: Array|Vector, v2: Array|Vector): Plane; + + XY: Plane; + YZ: Plane; + ZX: Plane; + YX: Plane; +} + +interface Plane { + /** + * Gets the 3D vector corresponding to a point in the plane. + */ + anchor: Vector; + + /** + * Gets a normalized 3D vector perpendicular to the plane. + */ + normal: Vector; + + /** + * Returns true if the plane occupies the same space as the argument. + * + * @param {Plane} plane The other plane. + */ + eql(plane: Plane): boolean; + + /** + * Returns a copy of the plane. + */ + dup(): Plane; + + /** + * Returns the result of translating the plane by the given vector. + * + * @param {Array|Vector} vector The translation vector. + */ + translate(vector: Array|Vector): Plane; + + /** + * Returns true if the plane is parallel to the argument. Will return true if the planes are equal, + * or if you give a line and it lies in the plane. + * + * @param {Line|Plane} obj The object. + */ + isParallelTo(obj: Line|Plane): boolean; + + /** + * Returns true if the receiver is perpendicular to the argument. + * + * @param {Plane} plane The other plane. + */ + isPerpendicularTo(plane: Plane): boolean; + + /** + * Returns the plane's distance from the given object (point, line or plane). + * + * @parm {Vector|Line|Plane} obj The object. + */ + distanceFrom(obj: Vector|Line|Plane): number; + + /** + * Returns true if the plane contains the given point or line. + * + * @param {Vector|Line} obj The object. + */ + contains(obj: Vector|Line): boolean; + + /** + * Returns true if the plane has a unique point/line of intersection with the argument. + * + * @param {Line|Plane} obj The object. + */ + intersects(obj: Line|Plane): boolean; + + /** + * Returns the unique intersection with the argument, if one exists. + * + * @param {Line} line The line. + */ + intersectionWith(line: Line): Vector; + + /** + * Returns the unique intersection with the argument, if one exists. + * + * @param {Plane} plane The plane. + */ + intersectionWith(plane: Plane): Line; + + /** + * Returns the point in the plane closest to the given point. + * + * @param {Vector} point The point. + */ + pointClosestTo(point: Vector): Vector; + + /** + * Returns a copy of the plane, rotated by t radians about the given line. See notes on Line#rotate. + * + * @param {number} t The angle in radians. + * @param {Line} axis The line axis. + */ + rotate(t: number, axis: Line): Plane; + + /** + * Returns the reflection of the plane in the given point, line or plane. + * + * @param {Vector|Line|Plane} obj The object. + */ + reflectionIn(obj: Vector|Line|Plane): Plane; + + /** + * Sets the anchor point and normal to the plane. Normal vector is normalised before storage. + * + * @param {Array|Vector} anchor The anchor vector. + * @param {Array|Vector} normal The normal vector. + */ + setVectors(anchor: Array|Vector, normal: Array|Vector): Plane; + + /** + * Sets the anchor point and normal to the plane. The normal is calculated by assuming the three points + * should lie in the same plane. Normal vector is normalised before storage. + * + * @param {Array|Vector} anchor The anchor vector. + * @param {Array|Vector} v1 The first direction vector. + * @param {Array|Vector} v2 The second direction vector. + */ + setVectors(anchor: Array|Vector, v1: Array|Vector, v2: Array|Vector): Plane; +} + +declare module Sylvester { + export var version: string; + export var precision: number; +} + +declare var Vector: VectorStatic; +declare var Matrix: MatrixStatic; +declare var Line: LineStatic; +declare var Plane: PlaneStatic; + +/** +* Constructor function. +* +* @param {Vector|Array): Vector; + +/** +* Constructor function. +* +* @param {Array|Array>|Vector|Matrix} elements The elements. +*/ +declare function $M(elements: Array|Array>|Vector | Matrix): Matrix; + +/** +* Constructor function. +* +* @param Array|Vector anchor The anchor vector. +* @param Array|Vector direction The direction vector. +*/ +declare function $L(anchor: Array|Vector, direction: Array|Vector): Line; + +/** +* Constructor function. +* +* @param {Array|Vector} anchor The anchor vector. +* @param {Array|Vector} normal The normal vector. +*/ +declare function $P(anchor: Array|Vector, normal: Array|Vector): Plane; + +/** + * Constructor function. + * + * @param {Array|Vector} anchor The anchor vector. + * @param {Array|Vector} v1 The first direction vector. + * @param {Array|Vecotr} v2 The second direction vector. + */ +declare function $P(anchor: Array|Vector, v1: Array|Vector, v2: Array|Vector): Plane; \ No newline at end of file From 1fbadc073327fd627065c772509069b23c755d30 Mon Sep 17 00:00:00 2001 From: Simon Gausmann Date: Wed, 21 Oct 2015 20:45:16 +0200 Subject: [PATCH 0016/1850] removing I from Interface-Names --- cache-manager/cache-manager-tests.ts | 16 ++++++++-------- cache-manager/cache-manager.d.ts | 27 +++++++++++++-------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/cache-manager/cache-manager-tests.ts b/cache-manager/cache-manager-tests.ts index 36d2a559a0..36eeb4c141 100644 --- a/cache-manager/cache-manager-tests.ts +++ b/cache-manager/cache-manager-tests.ts @@ -2,10 +2,10 @@ import * as cacheManager from 'cache-manager' -const memoryCache = cacheManager.caching({store: 'memory', max: 100, ttl: 10/*seconds*/}); +const memoryCache = cacheManager.caching({ store: 'memory', max: 100, ttl: 10/*seconds*/ }); const ttl = 5; -memoryCache.set('foo', 'bar', {ttl: ttl}, (err) => { +memoryCache.set('foo', 'bar', { ttl: ttl }, (err) => { if (err) { throw err; @@ -21,25 +21,25 @@ memoryCache.set('foo', 'bar', {ttl: ttl}, (err) => { }); }); -function getUser(id:number, cb:Function) { +function getUser(id: number, cb: Function) { - cb(null, {id: id, name: 'Bob'}); + cb(null, { id: id, name: 'Bob' }); } const userId = 123; const key = 'user_' + userId; // Note: ttl is optional in wrap() -memoryCache.wrap<{id: number, name: string}>(key, (cb) => { +memoryCache.wrap<{ id: number, name: string }>(key, (cb) => { getUser(userId, cb); -}, {ttl: ttl}, (err, user) => { +}, { ttl: ttl }, (err, user) => { //console.log(user); // Second time fetches user from memoryCache - memoryCache.wrap<{id: number, name: string}>(key, (cb)=> { + memoryCache.wrap<{ id: number, name: string }>(key, (cb) => { getUser(userId, cb); @@ -48,4 +48,4 @@ memoryCache.wrap<{id: number, name: string}>(key, (cb) => { //console.log(user); }); -}); \ No newline at end of file +}); diff --git a/cache-manager/cache-manager.d.ts b/cache-manager/cache-manager.d.ts index d912f9f7bd..9570857f01 100644 --- a/cache-manager/cache-manager.d.ts +++ b/cache-manager/cache-manager.d.ts @@ -5,32 +5,31 @@ declare module 'cache-manager' { - interface ICachingConfig { + interface CachingConfig { ttl: number; } - interface IStoreConfig extends ICachingConfig { - store:string; + interface StoreConfig extends CachingConfig { + store: string; max?: number; - isCacheableValue?:(value:any)=>boolean; + isCacheableValue?: (value: any) => boolean; } - interface ICache { - set(key:string, value:T, options:ICachingConfig, callback?:(error:any)=>void):void; - set(key:string, value:T, ttl:number, callback?:(error:any)=>void):void; + interface Cache { + set(key: string, value: T, options: CachingConfig, callback?: (error: any) => void): void; + set(key: string, value: T, ttl: number, callback?: (error: any) => void): void; - wrap(key:string, wrapper:(callback:(error:any, result:T)=>void)=>void, options:ICachingConfig, callback:(error:any, result:T)=>void):void; - wrap(key:string, wrapper:(callback:(error:any, result:T)=>void)=>void, callback:(error:any, result:T)=>void):void; + wrap(key: string, wrapper: (callback: (error: any, result: T) => void) => void, options: CachingConfig, callback: (error: any, result: T) => void): void; + wrap(key: string, wrapper: (callback: (error: any, result: T) => void) => void, callback: (error: any, result: T) => void): void; - get(key:string, callback:(error:any, result:T)=>void):void; + get(key: string, callback: (error: any, result: T) => void): void; - del(key:string, callback?:(error:any)=>void):void; + del(key: string, callback?: (error: any) => void): void; } module cacheManager { - function caching(ICongig:IStoreConfig):ICache; - - function multiCaching(Caches:ICache[]):ICache; + function caching(ICongig: StoreConfig): Cache; + function multiCaching(Caches: Cache[]): Cache; } export = cacheManager; From 2319d7a678b044b3a31c00acbd87f23c233cfd73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Ostroz=CC=8Cli=CC=81k?= Date: Thu, 29 Oct 2015 13:28:44 +0100 Subject: [PATCH 0017/1850] Added karma-chai-sinon --- karma-chai-sinon/karma-chai-sinon.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 karma-chai-sinon/karma-chai-sinon.d.ts diff --git a/karma-chai-sinon/karma-chai-sinon.d.ts b/karma-chai-sinon/karma-chai-sinon.d.ts new file mode 100644 index 0000000000..059a1b80ef --- /dev/null +++ b/karma-chai-sinon/karma-chai-sinon.d.ts @@ -0,0 +1,12 @@ +// Type definitions for karma-chai-sinon 0.1.5 +// Project: https://github.com/tubalmartin/karma-chai-sinon +// Definitions by: Václav Ostrožlík +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare var should: Chai.Should; +declare var expect: Chai.ExpectStatic; +declare var assert: Chai.AssertStatic; +declare var sinon: Sinon.SinonStatic; From 6d2b4cc7a04d45df15cafe6bdb16c697e7413d2e Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Fri, 30 Oct 2015 10:12:18 -0400 Subject: [PATCH 0018/1850] Fix namespace issue --- sylvester/sylvester-test.ts | 17 +++ sylvester/sylvester.d.ts | 212 ++++++++++++++++++------------------ 2 files changed, 123 insertions(+), 106 deletions(-) diff --git a/sylvester/sylvester-test.ts b/sylvester/sylvester-test.ts index 1eb5e076ec..e42bb374e0 100644 --- a/sylvester/sylvester-test.ts +++ b/sylvester/sylvester-test.ts @@ -13,10 +13,14 @@ var m: Matrix = Matrix.create(v); var p: Plane = Plane.create(v, v); var v: Vector = Vector.create([n, n]); +l = $L(v, v); +l = $L([n], [n]); l = Line.create([n], [n]); + l = Line.X; l = Line.Y; l = Line.Z; + v = l.anchor; bool = l.contains(v); v = l.direction; @@ -44,10 +48,15 @@ l = l.setVectors(v, [n, n]); l = l.translate(v); l = l.translate([n, n]); +m = $M(m); +m = $M([n]); +m = $M([[n]]); +m = $M(v); m = Matrix.create(m); m = Matrix.create([n]); m = Matrix.create([[n]]); m = Matrix.create(v); + m = Matrix.Diagonal(m); m = Matrix.Diagonal([n]); m = Matrix.Diagonal([[n]]); @@ -114,11 +123,15 @@ m = m.x(m); m = m.x(n); v = m.x(v); +p = $P([n], [n]); +p = $P(v, v); p = Plane.create([0], [0]); + p = Plane.XY; p = Plane.YX; p = Plane.YZ; p = Plane.ZX; + v = p.anchor; bool = p.contains(v); bool = p.contains(l); @@ -147,10 +160,14 @@ p = p.setVectors(v, v, v); p = p.translate([n]); p = p.translate(v); +v = $V(v); +v = $V([n]); v = Vector.create(v); + v = Vector.i; v = Vector.j; v = Vector.k; + v = Vector.Random(n); v = Vector.Zero(n); v = v.add(v); diff --git a/sylvester/sylvester.d.ts b/sylvester/sylvester.d.ts index 0aa869d38c..2b899728f7 100644 --- a/sylvester/sylvester.d.ts +++ b/sylvester/sylvester.d.ts @@ -7,29 +7,111 @@ // Vector and Matrix mathematics modules for JavaScript // Copyright (c) 2007 James Coglan -interface VectorStatic { - /** - * Constructor function. - */ - create(elements: Vector|Array): Vector; +declare module Sylvester { + interface VectorStatic { + /** + * Constructor function. + */ + create(elements: Vector|Array): Vector; - i: Vector; - j: Vector; - k: Vector; + i: Vector; + j: Vector; + k: Vector; - /** - * Random vector of size n. - * - * @param {number} n The vector size. - */ - Random(n: number): Vector; + /** + * Random vector of size n. + * + * @param {number} n The vector size. + */ + Random(n: number): Vector; - /** - * Vector filled with zeros. - * - * @param {number} n The vector size. - */ - Zero(n: number): Vector; + /** + * Vector filled with zeros. + * + * @param {number} n The vector size. + */ + Zero(n: number): Vector; + } + interface MatrixStatic { + /** + * Constructor function. + * + * @param {Array|Array>|Vector|Matrix} elements The elements. + */ + create(elements: Array|Array>|Vector | Matrix): Matrix; + + /** + * Identity matrix of size n. + * + * @param {number} n The size. + */ + I(n: number): Matrix; + + /** + * Diagonal matrix - all off-diagonal elements are zero + * + * @param {any} elements The elements. + */ + Diagonal(elements: Array|Array>|Vector | Matrix): Matrix; + + /** + * Rotation matrix about some axis. If no axis is supplied, assume we're after a 2D transform. + * + * @param {number} theta The angle in radians. + * @param {Vector} a [Optional] The axis. + */ + Rotation(theta: number, a?: Vector): Matrix; + + RotationX(t: number): Matrix; + RotationY(t: number): Matrix; + RotationZ(t: number): Matrix; + + /** + * Random matrix of n rows, m columns. + * + * @param {number} n The number of rows. + * @param {number} m The number of columns. + */ + Random(n: number, m: number): Matrix; + + /** + * Matrix filled with zeros. + * + * @param {number} n The number of rows. + * @param {number} m The number of columns. + */ + Zero(n: number, m: number): Matrix; + } + + interface LineStatic { + /** + * Constructor function. + * + * @param Array|Vector anchor The anchor vector. + * @param Array|Vector direction The direction vector. + */ + create(anchor: Array|Vector, direction: Array|Vector): Line; + + X: Line; + Y: Line; + Z: Line; + } + interface PlaneStatic { + /** + * Constructor function. + */ + create(anchor: Array|Vector, normal: Array|Vector): Plane; + + /** + * Constructor function. + */ + create(anchor: Array|Vector, v1: Array|Vector, v2: Array|Vector): Plane; + + XY: Plane; + YZ: Plane; + ZX: Plane; + YX: Plane; + } } interface Vector { @@ -239,57 +321,6 @@ interface Vector { setElements(els: Vector|Array): Vector; } -interface MatrixStatic { - /** - * Constructor function. - * - * @param {Array|Array>|Vector|Matrix} elements The elements. - */ - create(elements: Array|Array>|Vector | Matrix): Matrix; - - /** - * Identity matrix of size n. - * - * @param {number} n The size. - */ - I(n: number): Matrix; - - /** - * Diagonal matrix - all off-diagonal elements are zero - * - * @param {any} elements The elements. - */ - Diagonal(elements: Array|Array>|Vector | Matrix): Matrix; - - /** - * Rotation matrix about some axis. If no axis is supplied, assume we're after a 2D transform. - * - * @param {number} theta The angle in radians. - * @param {Vector} a [Optional] The axis. - */ - Rotation(theta: number, a?: Vector): Matrix; - - RotationX(t: number): Matrix; - RotationY(t: number): Matrix; - RotationZ(t: number): Matrix; - - /** - * Random matrix of n rows, m columns. - * - * @param {number} n The number of rows. - * @param {number} m The number of columns. - */ - Random(n: number, m: number): Matrix; - - /** - * Matrix filled with zeros. - * - * @param {number} n The number of rows. - * @param {number} m The number of columns. - */ - Zero(n: number, m: number): Matrix; -} - interface Matrix { /** * Gets a nested array containing the matrix's elements. @@ -515,20 +546,6 @@ interface Matrix { setElements(matrix: Array|Array>|Vector|Matrix): Matrix; } -interface LineStatic { - /** - * Constructor function. - * - * @param Array|Vector anchor The anchor vector. - * @param Array|Vector direction The direction vector. - */ - create(anchor: Array|Vector, direction: Array|Vector): Line; - - X: Line; - Y: Line; - Z: Line; -} - interface Line { /** * Gets the 3D vector corresponding to a point on the line. @@ -637,23 +654,6 @@ interface Line { setVectors(anchor: Array|Vector, direction: Array|Vector): Line; } -interface PlaneStatic { - /** - * Constructor function. - */ - create(anchor: Array|Vector, normal: Array|Vector): Plane; - - /** - * Constructor function. - */ - create(anchor: Array|Vector, v1: Array|Vector, v2: Array|Vector): Plane; - - XY: Plane; - YZ: Plane; - ZX: Plane; - YX: Plane; -} - interface Plane { /** * Gets the 3D vector corresponding to a point in the plane. @@ -780,10 +780,10 @@ declare module Sylvester { export var precision: number; } -declare var Vector: VectorStatic; -declare var Matrix: MatrixStatic; -declare var Line: LineStatic; -declare var Plane: PlaneStatic; +declare var Vector: Sylvester.VectorStatic; +declare var Matrix: Sylvester.MatrixStatic; +declare var Line: Sylvester.LineStatic; +declare var Plane: Sylvester.PlaneStatic; /** * Constructor function. From 9c433c79496fb2b79a6e87f7e4be5d3bc3dfdf5a Mon Sep 17 00:00:00 2001 From: Dominic Alie Date: Mon, 2 Nov 2015 09:52:28 -0500 Subject: [PATCH 0019/1850] Renamed test file --- sylvester/{sylvester-test.ts => sylvester-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sylvester/{sylvester-test.ts => sylvester-tests.ts} (100%) diff --git a/sylvester/sylvester-test.ts b/sylvester/sylvester-tests.ts similarity index 100% rename from sylvester/sylvester-test.ts rename to sylvester/sylvester-tests.ts From b97eba0f03f534499b220f6a12af8da7855d5342 Mon Sep 17 00:00:00 2001 From: aaronbeall Date: Fri, 20 Nov 2015 12:59:08 -0500 Subject: [PATCH 0020/1850] Update react-addons-css-transition-group.d.ts with Timeout properties Added missing transitionAppearTimeout, transitionEnterTimeout, transitionLeaveTimeout to CSSTransitionGroupProps --- react/react-addons-css-transition-group.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react/react-addons-css-transition-group.d.ts b/react/react-addons-css-transition-group.d.ts index c9b40476d5..19db30ec5e 100644 --- a/react/react-addons-css-transition-group.d.ts +++ b/react/react-addons-css-transition-group.d.ts @@ -20,8 +20,11 @@ declare namespace __React { interface CSSTransitionGroupProps extends TransitionGroupProps { transitionName: string | CSSTransitionGroupTransitionName; transitionAppear?: boolean; + transitionAppearTimeout?: number; transitionEnter?: boolean; + transitionEnterTimeout?: number; transitionLeave?: boolean; + transitionLeaveTimeout?: number; } type CSSTransitionGroup = ComponentClass; From a98b730f38c175babaad498da2000a41ade24ce0 Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 12:25:55 +0200 Subject: [PATCH 0021/1850] Create lockr.d.ts --- lockr/lockr.d.ts | 108 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 lockr/lockr.d.ts diff --git a/lockr/lockr.d.ts b/lockr/lockr.d.ts new file mode 100644 index 0000000000..eba2b85609 --- /dev/null +++ b/lockr/lockr.d.ts @@ -0,0 +1,108 @@ +// Type definitions for lockr 0.8.3 +// Project: https://github.com/tsironis/lockr +// Definitions by: Dror Weiss +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Lockr: lockr.ILockrStatic; + +declare module lockr { + interface ILockrStatic { + + /** + * Set a key to a particular value or a hash object (Object or Array) under a hash key. + * @param key + * @param value + */ + set(key: string, value: string | number | Object); + + /** + * Set a key to a particular value or a hash object (Object or Array) under a hash key. + * @param key + * @param value + */ + set(key: string, value: Array); + + /** + * Removes all data associated to a key. + * @param key + */ + rm(key: string); + + /** + * Returns the saved value for given key, even if the saved value is hash object. + * If value is null or undefined it returns a default value. + * @param key + * @param defaultValue + */ + get(key: string, defaultValue?: T): T; + + /** + * Adds a unique value to a particular set under a hash key. + * @param key + * @param value + */ + sadd(key: string, value: string | number | Object); + + /** + * Adds a unique value to a particular set under a hash key. + * @param key + * @param value + */ + sadd(key: string, value: Array); + + /** + * Returns the values of a particular set under a hash key. + * @param key + */ + smembers(key: string): (string | number | Object)[]; + + /** + * Returns the values of a particular set under a hash key. + * @param key + */ + smembers(key: string): Array; + + /** + * Returns whether the value exists in a particular set under a hash key. + * @param key + * @param value + */ + sismember(key: string, value: string | number | Object): boolean; + + /** + * Returns whether the value exists in a particular set under a hash key. + * @param key + * @param value + */ + sismember(key: string, value: Array): boolean; + + /** + * Removes a value from a particular set under a hash key. + * @param key + * @param value + */ + srem(key: string, value: string | number | Object); + + /** + * Removes a value from a particular set under a hash key. + * @param key + * @param value + */ + srem(key: string, value: Array); + + /** + * Returns all saved values & objects, in an Array. + */ + getAll(): (string | number | Object)[]; + + /** + * Empties localStorage. + */ + flush(); + } +} + + +declare module "lockr" { + export = Lockr; +} From 8b3ef3165d577de1621fbb174b90bc3a106b3e18 Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 13:05:13 +0200 Subject: [PATCH 0022/1850] Update lockr.d.ts --- lockr/lockr.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lockr/lockr.d.ts b/lockr/lockr.d.ts index eba2b85609..6655bf2b22 100644 --- a/lockr/lockr.d.ts +++ b/lockr/lockr.d.ts @@ -8,6 +8,11 @@ declare var Lockr: lockr.ILockrStatic; declare module lockr { interface ILockrStatic { + /** + * The prefix used by lockr. + */ + prefix: string; + /** * Set a key to a particular value or a hash object (Object or Array) under a hash key. * @param key From 39ac2bba70530ac65281823d8cce5202873d50f4 Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 13:06:11 +0200 Subject: [PATCH 0023/1850] Create lockr-tests.ts --- lockr/lockr-tests.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lockr/lockr-tests.ts diff --git a/lockr/lockr-tests.ts b/lockr/lockr-tests.ts new file mode 100644 index 0000000000..a791413965 --- /dev/null +++ b/lockr/lockr-tests.ts @@ -0,0 +1,25 @@ +/// + +Lockr.set('test', 123); +Lockr.sadd('array', 2); +Lockr.sadd('array', 3); +Lockr.set('hash', {"test": 123, "hey": "whatsup"}); +Lockr.set('hash', [1, 2, 3]); +Lockr.set('valueFalse', false); +Lockr.set('value0', 0); + +let value; +value = Lockr.get('test'); +Lockr.rm('test'); + +let contents; +contents = Lockr.getAll(); +Lockr.flush(); + +Lockr.sadd('test_set', 1); +Lockr.sadd('test_set', 2); +Lockr.smembers('test_set'); +Lockr.sismember('test_set', 1); +Lockr.srem('test_set', 1); + +Lockr.prefix = "imaprefix"; From f3ace73ce186068711d968e124bc1f5f1b1166fc Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 13:12:56 +0200 Subject: [PATCH 0024/1850] Update lockr.d.ts --- lockr/lockr.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lockr/lockr.d.ts b/lockr/lockr.d.ts index 6655bf2b22..169db126f5 100644 --- a/lockr/lockr.d.ts +++ b/lockr/lockr.d.ts @@ -18,20 +18,20 @@ declare module lockr { * @param key * @param value */ - set(key: string, value: string | number | Object); + set(key: string, value: string | number | Object): void; /** * Set a key to a particular value or a hash object (Object or Array) under a hash key. * @param key * @param value */ - set(key: string, value: Array); + set(key: string, value: Array): void; /** * Removes all data associated to a key. * @param key */ - rm(key: string); + rm(key: string): void; /** * Returns the saved value for given key, even if the saved value is hash object. @@ -46,14 +46,14 @@ declare module lockr { * @param key * @param value */ - sadd(key: string, value: string | number | Object); + sadd(key: string, value: string | number | Object): void; /** * Adds a unique value to a particular set under a hash key. * @param key * @param value */ - sadd(key: string, value: Array); + sadd(key: string, value: Array): void; /** * Returns the values of a particular set under a hash key. @@ -86,14 +86,14 @@ declare module lockr { * @param key * @param value */ - srem(key: string, value: string | number | Object); + srem(key: string, value: string | number | Object): void; /** * Removes a value from a particular set under a hash key. * @param key * @param value */ - srem(key: string, value: Array); + srem(key: string, value: Array): void; /** * Returns all saved values & objects, in an Array. @@ -103,7 +103,7 @@ declare module lockr { /** * Empties localStorage. */ - flush(); + flush(): void; } } From e9880e3833ae5f39fbae9b424e9f77a86da62add Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 13:19:03 +0200 Subject: [PATCH 0025/1850] Update lockr-tests.ts --- lockr/lockr-tests.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lockr/lockr-tests.ts b/lockr/lockr-tests.ts index a791413965..d1e2542121 100644 --- a/lockr/lockr-tests.ts +++ b/lockr/lockr-tests.ts @@ -8,12 +8,10 @@ Lockr.set('hash', [1, 2, 3]); Lockr.set('valueFalse', false); Lockr.set('value0', 0); -let value; -value = Lockr.get('test'); +let value = Lockr.get('test'); Lockr.rm('test'); -let contents; -contents = Lockr.getAll(); +let contents = Lockr.getAll(); Lockr.flush(); Lockr.sadd('test_set', 1); From 13e6958c49d05cd0093dd24448811ecbce35be7c Mon Sep 17 00:00:00 2001 From: Droritos Date: Sat, 28 Nov 2015 13:20:38 +0200 Subject: [PATCH 0026/1850] Update lockr-tests.ts --- lockr/lockr-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lockr/lockr-tests.ts b/lockr/lockr-tests.ts index d1e2542121..c8b3596630 100644 --- a/lockr/lockr-tests.ts +++ b/lockr/lockr-tests.ts @@ -8,7 +8,7 @@ Lockr.set('hash', [1, 2, 3]); Lockr.set('valueFalse', false); Lockr.set('value0', 0); -let value = Lockr.get('test'); +let value = Lockr.get('test'); Lockr.rm('test'); let contents = Lockr.getAll(); From 3e1a4a1af0564a993639a72d61835edbd4d0eabc Mon Sep 17 00:00:00 2001 From: Droritos Date: Sun, 6 Dec 2015 15:22:46 +0200 Subject: [PATCH 0027/1850] Update lockr.d.ts Changed naming of interface ILockrStatic to LockrStatic --- lockr/lockr.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lockr/lockr.d.ts b/lockr/lockr.d.ts index 169db126f5..c615c13e5d 100644 --- a/lockr/lockr.d.ts +++ b/lockr/lockr.d.ts @@ -3,10 +3,10 @@ // Definitions by: Dror Weiss // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare var Lockr: lockr.ILockrStatic; +declare var Lockr: lockr.LockrStatic; declare module lockr { - interface ILockrStatic { + interface LockrStatic { /** * The prefix used by lockr. From f4f0812f254fafa92c45bca356aa3e570c163f72 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Mon, 7 Dec 2015 13:22:33 -0500 Subject: [PATCH 0028/1850] Add NavbarHeader to react-bootstrap --- react-bootstrap/react-bootstrap.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/react-bootstrap/react-bootstrap.d.ts b/react-bootstrap/react-bootstrap.d.ts index c63c55e9d0..80286f1743 100644 --- a/react-bootstrap/react-bootstrap.d.ts +++ b/react-bootstrap/react-bootstrap.d.ts @@ -475,6 +475,15 @@ declare module "react-bootstrap" { interface NavBrandClass extends React.ComponentClass { } var NavBrand: NavBrandClass; + // + // ---------------------------------------- + interface NavbarHeaderProps { + + } + interface NavbarHeader extends React.ReactElement { } + interface NavbarHeaderClass extends React.ComponentClass { } + var NavbarHeader: NavbarHeaderClass; + // // ---------------------------------------- From fe3f2f35a881cd824c8da1142ff0b21a3071a372 Mon Sep 17 00:00:00 2001 From: cherrydev Date: Mon, 7 Dec 2015 12:45:56 -0800 Subject: [PATCH 0029/1850] added missing static functions Function definition for Dexie.delete at Dexie.js:3246 Function definition for Dexie.exists at Dexie.js:3259 Other static definitions are still missing. --- dexie/dexie.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dexie/dexie.d.ts b/dexie/dexie.d.ts index 13b9b31e0b..2de122385e 100644 --- a/dexie/dexie.d.ts +++ b/dexie/dexie.d.ts @@ -37,6 +37,10 @@ declare class Dexie { static shallowClone(obj: Object): Object; static deepClone(obj: Object): Object; + + static delete(databaseName : string): Dexie.Promise; + + static exists(databaseName : string): Dexie.Promise; version(versionNumber: number): Dexie.Version; From ae8fce14da334c1e525aa2515bbc494073448232 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Dec 2015 09:37:39 +1100 Subject: [PATCH 0030/1850] Update definitions for ES6 compatability, NOTE: Confusion over cryptojs vs crypto-js. I would suggest merging the two projects but this needs to happen on the npm repository first... --- crypto-js/crypto-js.d.ts | 579 +++++++++++++++++++++++++++++++++++---- 1 file changed, 520 insertions(+), 59 deletions(-) diff --git a/crypto-js/crypto-js.d.ts b/crypto-js/crypto-js.d.ts index 0f02514027..cde0abd9b9 100644 --- a/crypto-js/crypto-js.d.ts +++ b/crypto-js/crypto-js.d.ts @@ -1,67 +1,528 @@ -// Type definitions for crypto-js v3.1.3 +// Type definitions for crypto-js v3.1.5 // Project: https://github.com/evanvosberg/crypto-js -// Definitions by: Michael Zabka +// Definitions by: Michael Zabka , Jason Turner // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module CryptoJS { - type Hash = (message: string, key?: string, ...options: any[]) => string; +declare module CryptoJSLocal{ + module lib{ + interface Base{ + extend(overrides: Object): Object + init(...args: any[]): void + //arguments of create() is same as init(). This is true for all subclasses + create(...args: any[]): Base + mixIn(properties: Object): void + clone(): Base + } - export interface Hashes { - MD5: Hash; - SHA1: Hash; - SHA256: Hash; - SHA224: Hash; - SHA512: Hash; - SHA384: Hash; - SHA3: Hash; - RIPEMD160: Hash; - HmacMD5: Hash; - HmacSHA1: Hash; - HmacSHA256: Hash; - HmacSHA224: Hash; - HmacSHA512: Hash; - HmacSHA384: Hash; - HmacSHA3: Hash; - HmacRIPEMD160: Hash; - PBKDF2: Hash; - AES: Hash; - TripleDES: Hash; - RC4: Hash; - Rabbit: Hash; - RabbitLegacy: Hash; - EvpKDF: Hash; - format: { - OpenSSL: Hash; - Hex: Hash; - }; - enc: { - Latin1: Hash; - Utf8: Hash; - Hex: Hash; - Utf16: Hash; - Base64: Hash; - }; - mode: { - CFB: Hash; - CTR: Hash; - CTRGladman: Hash; - OFB: Hash; - ECB: Hash; - }; - pad: { - Pkcs7: Hash; - Ansix923: Hash; - Iso10126: Hash; - Iso97971: Hash; - ZeroPadding: Hash; - NoPadding: Hash; - }; - } + interface WordArray extends Base{ + words: number[] + sigBytes: number + init(words?: number[], sigBytes?: number): void + create(words?: number[], sigBytes?: number): WordArray - export var hashes: Hashes; + init(typedArray: ArrayBuffer): void + init(typedArray: Int8Array): void + + //Because TypeScript uses a structural type system then we don't need (& can't) + //declare oveload function init, create for the following type (same as Int8Array): + //then Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array + //Note also: Uint8ClampedArray is not defined in lib.d.ts & not supported in IE + //@see http://compatibility.shwups-cms.ch/en/home?&property=Uint8ClampedArray + + create(typedArray: ArrayBuffer): WordArray + create(typedArray: Int8Array): WordArray + + toString(encoder?: enc.IEncoder): string + concat(wordArray: WordArray): WordArray + clamp(): void + clone(): WordArray + random(nBytes: number): WordArray + } + + interface BufferedBlockAlgorithm extends Base{ + reset(): void + clone(): BufferedBlockAlgorithm + } + + //tparam C - Configuration type + interface IHasher extends BufferedBlockAlgorithm{ + cfg: C + init(cfg?: C): void + create(cfg?: C): IHasher + + update(messageUpdate: string): Hasher + update(messageUpdate: WordArray): Hasher + + finalize(messageUpdate?: string): WordArray + finalize(messageUpdate?: WordArray): WordArray + + blockSize: number + + _createHelper(hasher: Hasher): IHasherHelper + _createHmacHelper(hasher: Hasher): IHasherHmacHelper + + clone(): IHasher + } + interface Hasher extends IHasher{} + + //tparam C - Configuration type + interface IHasherHelper{ + (message: string, cfg?: C): WordArray + (message: WordArray, cfg?: C): WordArray + } + interface HasherHelper extends IHasherHelper{} + + interface IHasherHmacHelper{ + (message: string, key: string): WordArray + (message: string, key: WordArray): WordArray + (message: WordArray, key: string): WordArray + (message: WordArray, key: WordArray): WordArray + } + + //tparam C - Configuration type + interface ICipher extends BufferedBlockAlgorithm{ + cfg: C + createEncryptor(key: WordArray, cfg?: C): ICipher + createDecryptor(key: WordArray, cfg?: C): ICipher + + create(xformMode?: number, key?: WordArray, cfg?: C): ICipher + init(xformMode?: number, key?: WordArray, cfg?: C): void + + process(dataUpdate: string): WordArray + process(dataUpdate: WordArray): WordArray + + finalize(dataUpdate?: string): WordArray + finalize(dataUpdate?: WordArray): WordArray + + keySize: number + ivSize: number + + _createHelper(cipher: Cipher): ICipherHelper + + clone(): ICipher + } + interface Cipher extends ICipher{} + + interface IStreamCipher extends ICipher{ + drop?: number; + + createEncryptor(key: WordArray, cfg?: C): IStreamCipher + createDecryptor(key: WordArray, cfg?: C): IStreamCipher + + create(xformMode?: number, key?: WordArray, cfg?: C): IStreamCipher + + blockSize: number + } + interface StreamCipher extends IStreamCipher{} + + interface BlockCipherMode extends Base{ + createEncryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherEncryptor + createDecryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherDecryptor + init(cipher?: Cipher, iv?: number[]): void + create(cipher?: Cipher, iv?: number[]): BlockCipherMode + } + + //BlockCipher has interface same as IStreamCipher + interface BlockCipher extends IStreamCipher{} + + interface IBlockCipherCfg { + iv?: WordArray; + mode?: mode.IBlockCipherModeImpl //default CBC + padding?: pad.IPaddingImpl //default Pkcs7 + } + + interface CipherParamsData { + ciphertext?: lib.WordArray + key?: lib.WordArray + iv?: lib.WordArray + salt?: lib.WordArray + algorithm?: Cipher + mode?: mode.IBlockCipherModeImpl + padding?: pad.IPaddingImpl + blockSize?: number + formatter?: format.IFormatter + } + + interface CipherParams extends Base, CipherParamsData{ + init(cipherParams?: CipherParamsData): void + create(cipherParams?: CipherParamsData): CipherParams + toString(formatter?: format.IFormatter): string + } + + //tparam C - Configuration type + interface ISerializableCipher extends Base{ + cfg: C + encrypt(cipher: Cipher, message: WordArray, key: WordArray, cfg?: C): CipherParams + encrypt(cipher: Cipher, message: string, key: WordArray, cfg?: C): CipherParams + + decrypt(cipher: Cipher, ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray + decrypt(cipher: Cipher, ciphertext: string, key: WordArray, cfg?: C): WordArray + } + + interface SerializableCipher extends ISerializableCipher{} + interface ISerializableCipherCfg{ + format?: format.IFormatter //default OpenSSLFormatter + iv?: WordArray; + mode?: mode.IBlockCipherModeImpl; + padding?: pad.IPaddingImpl; + } + + interface IPasswordBasedCipher extends Base{ + cfg: C + encrypt(cipher: Cipher, message: WordArray, password: string, cfg?: C): CipherParams + encrypt(cipher: Cipher, message: string, password: string, cfg?: C): CipherParams + + decrypt(cipher: Cipher, ciphertext: CipherParamsData, password: string, cfg?: C): WordArray + decrypt(cipher: Cipher, ciphertext: string, password: string, cfg?: C): WordArray + } + + interface PasswordBasedCipher extends IPasswordBasedCipher{} + interface IPasswordBasedCipherCfg extends ISerializableCipherCfg{ + kdf?: kdf.IKdfImpl //default OpenSSLKdf + mode?: mode.IBlockCipherModeImpl; + padding?: pad.IPaddingImpl; + } + + /** see Cipher._createHelper */ + interface ICipherHelper{ + encrypt(message: string, password: string, cfg?: C): CipherParams + encrypt(message: string, key: WordArray, cfg?: C): CipherParams + encrypt(message: WordArray, password: string, cfg?: C): CipherParams + encrypt(message: WordArray, key: WordArray, cfg?: C): CipherParams + + decrypt(ciphertext: string, password: string, cfg?: C): WordArray + decrypt(ciphertext: string, key: WordArray, cfg?: C): WordArray + decrypt(ciphertext: CipherParamsData, password: string, cfg?: C): WordArray + decrypt(ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray + } + + interface CipherHelper extends ICipherHelper{} + interface LibStatic{ + Base: lib.Base + WordArray: lib.WordArray + CipherParams: lib.CipherParams + SerializableCipher: lib.SerializableCipher + PasswordBasedCipher: lib.PasswordBasedCipher + } + } + + module enc{ + interface IEncoder{ + stringify(wordArray: lib.WordArray): string + } + interface IDecoder{ + parse(s: string): lib.WordArray + } + interface ICoder extends IEncoder, IDecoder {} + + interface EncStatic{ + Hex: ICoder + Latin1: ICoder + Utf8: ICoder + Base64: ICoder + Utf16: ICoder + Utf16BE: ICoder + Utf16LE: ICoder + } + } + + module kdf{ + interface KdfStatic{ + OpenSSL: IKdfImpl + } + + interface IKdfImpl{ + execute(password: string, keySize: number, ivSize: number, salt?: string): lib.CipherParams + execute(password: string, keySize: number, ivSize: number, salt?: lib.WordArray): lib.CipherParams + } + } + + module format{ + interface FormatStatic{ + OpenSSL: IFormatter + Hex: IFormatter + } + + interface IFormatter{ + stringify(cipherParams: lib.CipherParamsData): string + parse(s: string): lib.CipherParams + } + } + + module algo{ + interface AlgoStatic{ + AES: algo.AES + DES: algo.DES + TripleDES: algo.TripleDES + + RabbitLegacy: algo.RabbitLegacy + Rabbit: algo.Rabbit + RC4: algo.RC4 + + MD5: algo.MD5 + RIPEMD160: algo.RIPEMD160 + SHA1: algo.SHA1 + SHA256: algo.SHA256 + SHA224: algo.SHA224 + SHA384: algo.SHA384 + SHA512: algo.SHA512 + + SHA3: algo.SHA3 + + HMAC: algo.HMAC + + EvpKDF: algo.EvpKDF + PBKDF2: algo.PBKDF2 + + RC4Drop: algo.RC4Drop + } + + interface IBlockCipherImpl extends lib.BlockCipher{ + encryptBlock(M: number[], offset: number): void + decryptBlock(M: number[], offset: number): void + + createEncryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl + createDecryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl + + create(xformMode?: number, key?: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl + } + + interface AES extends IBlockCipherImpl{} + interface DES extends IBlockCipherImpl{} + interface TripleDES extends IBlockCipherImpl{} + + interface RabbitLegacy extends lib.StreamCipher{} + interface Rabbit extends lib.StreamCipher{} + interface RC4 extends lib.StreamCipher{} + + interface MD5 extends lib.Hasher{} + interface RIPEMD160 extends lib.Hasher{} + interface SHA1 extends lib.Hasher{} + interface SHA256 extends lib.Hasher{} + interface SHA224 extends lib.Hasher{} + interface SHA384 extends lib.Hasher{} + interface SHA512 extends lib.Hasher{} + + interface SHA3 extends lib.IHasher{} + interface ISHA3Cfg{ + outputLength?: number //default 512 + } + + interface HMAC extends lib.Base{ + init(hasher?: lib.Hasher, key?: string): void + init(hasher?: lib.Hasher, key?: lib.WordArray): void + create(hasher?: lib.Hasher, key?: string): HMAC + create(hasher?: lib.Hasher, key?: lib.WordArray): HMAC + + update(messageUpdate: string): HMAC + update(messageUpdate: lib.WordArray): HMAC + + finalize(messageUpdate?: string): lib.WordArray + finalize(messageUpdate?: lib.WordArray): lib.WordArray + } + + interface EvpKDF extends lib.Base{ + cfg: IEvpKDFCfg + init(cfg?: IEvpKDFCfg): void + create(cfg?: IEvpKDFCfg): EvpKDF + compute(password: string, salt: string): lib.WordArray + compute(password: string, salt: lib.WordArray): lib.WordArray + compute(password: lib.WordArray, salt: string): lib.WordArray + compute(password: lib.WordArray, salt: lib.WordArray): lib.WordArray + } + interface IEvpKDFCfg{ + keySize?: number //default 128/32 + hasher?: lib.Hasher //default MD5, or SHA1 with PBKDF2 + iterations?: number //default 1 + } + interface IEvpKDFHelper{ + (password: string, salt: string, cfg?: IEvpKDFCfg): lib.WordArray + (password: string, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray + (password: lib.WordArray, salt: string, cfg?: IEvpKDFCfg): lib.WordArray + (password: lib.WordArray, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray + } + + interface PBKDF2 extends EvpKDF{} //PBKDF2 is same as EvpKDF + + interface RC4Drop extends RC4 { } + } + + module mode{ + interface ModeStatic{ + CBC: mode.CBC + CFB: mode.CFB + CTR: mode.CTR + CTRGladman: mode.CTRGladman + ECB: mode.ECB + OFB: mode.OFB + } + + interface IBlockCipherEncryptor extends lib.BlockCipherMode{ + processBlock(words: number[], offset: number): void + } + interface IBlockCipherDecryptor extends lib.BlockCipherMode{ //exactly as IBlockCipherEncryptor + processBlock(words: number[], offset: number): void + } + interface IBlockCipherModeImpl extends lib.BlockCipherMode{ + Encryptor: IBlockCipherEncryptor + Decryptor: IBlockCipherDecryptor + } + + interface CBC extends IBlockCipherModeImpl{} + interface CFB extends IBlockCipherModeImpl{} + interface CTR extends IBlockCipherModeImpl{} + interface CTRGladman extends IBlockCipherModeImpl{} + interface ECB extends IBlockCipherModeImpl{} + interface OFB extends IBlockCipherModeImpl{} + } + + module pad{ + interface PadStatic{ + Pkcs7: pad.Pkcs7 + AnsiX923: pad.AnsiX923 + Iso10126: pad.Iso10126 + Iso97971: pad.Iso97971 + ZeroPadding: pad.ZeroPadding + NoPadding: pad.NoPadding + } + + interface IPaddingImpl{ + pad(data: lib.WordArray, blockSize: number): void + unpad(data: lib.WordArray): void + } + + interface Pkcs7 extends IPaddingImpl{} + interface AnsiX923 extends IPaddingImpl{} + interface Iso10126 extends IPaddingImpl{} + interface Iso97971 extends IPaddingImpl{} + interface ZeroPadding extends IPaddingImpl{} + interface NoPadding extends IPaddingImpl{} + } + + module x64{ + interface X64Static{ + Word: x64.Word + WordArray: x64.WordArray + } + + interface Word extends lib.Base{ + high: number + low: number + + init(high?: number, low?: number): void + create(high?: number, low?: number): Word + } + + interface WordArray extends lib.Base{ + words: Word[] + sigBytes: number + + init(words?: Word[], sigBytes?: number): void + create(words?: Word[], sigBytes?: number): WordArray + toX32(): lib.WordArray + clone(): WordArray + } + } + + interface CryptoJSStatic{ + lib: lib.LibStatic + enc: enc.EncStatic + kdf: kdf.KdfStatic + format: format.FormatStatic + algo: algo.AlgoStatic + mode: mode.ModeStatic + pad: pad.PadStatic + x64: x64.X64Static + + AES: CryptoJSLocal.lib.ICipherHelper + DES: CryptoJSLocal.lib.ICipherHelper + TripleDES: CryptoJSLocal.lib.ICipherHelper + + RabbitLegacy: CryptoJSLocal.lib.CipherHelper + Rabbit: CryptoJSLocal.lib.CipherHelper + RC4: CryptoJSLocal.lib.CipherHelper + RC4Drop: CryptoJSLocal.lib.ICipherHelper + + MD5: CryptoJSLocal.lib.HasherHelper + HmacMD5: CryptoJSLocal.lib.IHasherHmacHelper + RIPEMD160: CryptoJSLocal.lib.HasherHelper + HmacRIPEMD160: CryptoJSLocal.lib.IHasherHmacHelper + SHA1: CryptoJSLocal.lib.HasherHelper + HmacSHA1: CryptoJSLocal.lib.IHasherHmacHelper + SHA256: CryptoJSLocal.lib.HasherHelper + HmacSHA256: CryptoJSLocal.lib.IHasherHmacHelper + SHA224: CryptoJSLocal.lib.HasherHelper + HmacSHA224: CryptoJSLocal.lib.IHasherHmacHelper + SHA512: CryptoJSLocal.lib.HasherHelper + HmacSHA512: CryptoJSLocal.lib.IHasherHmacHelper + SHA384: CryptoJSLocal.lib.HasherHelper + HmacSHA384: CryptoJSLocal.lib.IHasherHmacHelper + + SHA3: CryptoJSLocal.lib.IHasherHelper + HmacSHA3: CryptoJSLocal.lib.IHasherHmacHelper + + EvpKDF: CryptoJSLocal.algo.IEvpKDFHelper + PBKDF2: CryptoJSLocal.algo.IEvpKDFHelper //PBKDF2 is same as EvpKDF + } + type Hash = (message: string, key?: string, ...options: any[]) => string; + + export interface Hashes { + MD5: Hash; + SHA1: Hash; + SHA256: Hash; + SHA224: Hash; + SHA512: Hash; + SHA384: Hash; + SHA3: Hash; + RIPEMD160: Hash; + HmacMD5: Hash; + HmacSHA1: Hash; + HmacSHA256: Hash; + HmacSHA224: Hash; + HmacSHA512: Hash; + HmacSHA384: Hash; + HmacSHA3: Hash; + HmacRIPEMD160: Hash; + PBKDF2: Hash; + AES: Hash; + TripleDES: Hash; + RC4: Hash; + Rabbit: Hash; + RabbitLegacy: Hash; + EvpKDF: Hash; + format: { + OpenSSL: Hash; + Hex: Hash; + }; + enc: { + Latin1: Hash; + Utf8: Hash; + Hex: Hash; + Utf16: Hash; + Base64: Hash; + }; + mode: { + CFB: Hash; + CTR: Hash; + CTRGladman: Hash; + OFB: Hash; + ECB: Hash; + }; + pad: { + Pkcs7: Hash; + Ansix923: Hash; + Iso10126: Hash; + Iso97971: Hash; + ZeroPadding: Hash; + NoPadding: Hash; + }; + } + + export var hashes: Hashes; } -declare module 'crypto-js' { - import hashes = CryptoJS.hashes; - export = hashes; +declare var CryptoJS: CryptoJSLocal.CryptoJSStatic; + +declare module "crypto-js" { + export = CryptoJS; } From ff75d43ec14eb0d457231790b36e68b347c54016 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Thu, 10 Dec 2015 11:04:01 +1100 Subject: [PATCH 0031/1850] Updated to include interceptor defintiions... --- axios/axios.d.ts | 289 ++++++++++++++++++++++++++--------------------- 1 file changed, 159 insertions(+), 130 deletions(-) diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 48f57a73a3..86414bde6b 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -1,162 +1,191 @@ + // Type definitions for axios 0.5.2 // Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing +// Definitions by: Marcel Buesing , Jason Turner // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module Axios { - /** - * - request body data type - */ - interface AxiosXHRConfigBase { + /** + * - request body data type + */ + interface AxiosXHRConfigBase { + + /** + * Change the request data before it is sent to the server. + * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + * The last function in the array must return a string or an ArrayBuffer + */ + transformRequest?: ((data: T) => U) | [(data: T) => U]; + + /** + * change the response data to be made before it is passed to then/catch + */ + transformResponse?: (data: T) => U; + + /** + * custom headers to be sent + */ + headers?: Object; + + /** + * URL parameters to be sent with the request + */ + params?: Object; + + /** + * indicates whether or not cross-site Access-Control requests + * should be made using credentials + */ + withCredentials?: boolean; + + /** + * indicates the type of data that the server will respond with + * options are 'arraybuffer', 'blob', 'document', 'json', 'text' + */ + responseType?: string; + + /** + * name of the cookie to use as a value for xsrf token + */ + xsrfCookieName?: string; + + /** + * name of the http header that carries the xsrf token value + */ + xsrfHeaderName?: string; + + } /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer + * - request body data type */ - transformRequest?: ((data:T) => U)|[(data:T) => U]; + interface AxiosXHRConfig extends AxiosXHRConfigBase { + /** + * server URL that will be used for the request, options are: + * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH + */ + url: string; + + /** + * request method to be used when making the request + */ + method?: string; + + /** + * data to be sent as the request body + * Only applicable for request methods 'PUT', 'POST', and 'PATCH' + * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash + */ + data?: T; + } /** - * change the response data to be made before it is passed to then/catch + * - expected response type, + * - request body data type */ - transformResponse?: (data:T) => U; + interface AxiosXHR { + /** + * Response that was provided by the server + */ + data: T; + + /** + * HTTP status code from the server response + */ + status: number; + + /** + * HTTP status message from the server response + */ + statusText: string; + + /** + * headers that the server responded with + */ + headers: Object; + + /** + * config that was provided to `axios` for the request + */ + config: AxiosXHRConfig; + } /** - * custom headers to be sent + * - expected response type, + * - request body data type */ - headers?: Object; + interface AxiosStatic { - /** - * URL parameters to be sent with the request - */ - params?: Object; + (config: AxiosXHRConfig): Promise>; - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; + new (config: AxiosXHRConfig): Promise>; - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - } - - /** - * - request body data type - */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: Object; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } - - /** - * - expected response type, - * - request body data type - */ - interface AxiosStatic { - - (config: AxiosXHRConfig): Promise>; - - new (config: AxiosXHRConfig): Promise>; - - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = GET + */ + get(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = DELETE + */ + delete(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = HEAD + */ + head(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = POST + */ + post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = PUT + */ + put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - } + /** + * convenience alias, method = PATCH + */ + patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + interceptors: { + request: Interceptor, + response: Interceptor + } + } + + + + export interface Response { + data?: any; + status?: number; + statusText?: string; + headers?: any; + config?: any; + } + export interface success { + (response: Response): void + } + export interface error { + (response: Axios.Response): void; + } + + export interface Interceptor { + use(success: success, error?: error): void; + eject(interceptor: Interceptor); + } } declare var axios: Axios.AxiosStatic; declare module "axios" { - export = axios; + export = axios; } + + + From f1dfef373316e7dac737171498be047e2cb71d52 Mon Sep 17 00:00:00 2001 From: Rafal Witczak Date: Sun, 29 Nov 2015 12:08:33 -0800 Subject: [PATCH 0032/1850] TSD file for angular-q-spread module --- angular-q-spread/angular-q-spread-test.ts | 42 +++++++++++++++++++++++ angular-q-spread/angular-q-spread.d.ts | 17 +++++++++ 2 files changed, 59 insertions(+) create mode 100644 angular-q-spread/angular-q-spread-test.ts create mode 100644 angular-q-spread/angular-q-spread.d.ts diff --git a/angular-q-spread/angular-q-spread-test.ts b/angular-q-spread/angular-q-spread-test.ts new file mode 100644 index 0000000000..932ecc4fa9 --- /dev/null +++ b/angular-q-spread/angular-q-spread-test.ts @@ -0,0 +1,42 @@ +/// + +interface IMyService { + getFirstname(): ng.IPromise; + getLastname(): ng.IPromise; +} + +interface IScope { + name: string; +} + +function TestCtrl($scope: IScope, $q: ng.IQService, MyService: IMyService) { + $scope.name = null; + + function firstCallback(firstname: string, lastname: string) + { + return firstname + ' ' + lastname; + } + + function anotherCallback(fullname: string) + { + $scope.name = fullname; + } + + function failureCallback(reason: any) + { + alert('Could not load data: ' + reason); + } + + $q + .all([ + MyService.getFirstname(), + MyService.getLastname() + ]) + .spread(firstCallback) + .then(anotherCallback) + .catch(failureCallback); +}; + +TestCtrl.$inject = ['$scope', '$q', 'MyService']; + +angular.module('test').controller('TestCtrl', TestCtrl); diff --git a/angular-q-spread/angular-q-spread.d.ts b/angular-q-spread/angular-q-spread.d.ts new file mode 100644 index 0000000000..3eb37dc4e0 --- /dev/null +++ b/angular-q-spread/angular-q-spread.d.ts @@ -0,0 +1,17 @@ +// Type definitions for angular-q-spread module +// Project: https://www.npmjs.com/package/angular-q-spread +// Definitions by: rafw87 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module angular { + interface IPromise { + /** + This method can be used as a replacement for then. Similarly, it takes two parameters, a callback when all promises are resolved and a callback for failure. The resolve callback is going to be called with the result of the list of promises passed to $q.all as separate parameters instead of one parameters which is an array. + * @param successCallback Callback for resolved promise, similar to then's one, but takes multiple parameters instead of single array parameter + * @param errorCallback Callback for error, the same as for then + */ + spread(successCallback: (...promiseValues: any[]) => IPromise|TResult, errorCallback?: (reason: any) => any): IPromise; + } +} From 8561b6b2ded8edbeea5ecfe1a8e24def963f257e Mon Sep 17 00:00:00 2001 From: cherrydev Date: Thu, 10 Dec 2015 14:43:38 -0800 Subject: [PATCH 0033/1850] Update dexie.d.ts Fix embarrassing typo --- dexie/dexie.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dexie/dexie.d.ts b/dexie/dexie.d.ts index 2de122385e..2a527cff93 100644 --- a/dexie/dexie.d.ts +++ b/dexie/dexie.d.ts @@ -13,7 +13,7 @@ interface Thenable { declare class Dexie { constructor(databaseName: string); - constructor(databaseName: string, options: { addons: Array<(db: Dexie) => void> }); + constructor(databaseName: string, options: { addons: Array<(db: Dexie) => void> });b name: string; tables: Dexie.Table[]; @@ -40,7 +40,7 @@ declare class Dexie { static delete(databaseName : string): Dexie.Promise; - static exists(databaseName : string): Dexie.Promise; + static exists(databaseName : string): Dexie.Promise; version(versionNumber: number): Dexie.Version; From 030953bec9719ad5069c5a434fe7f1c31f275ac9 Mon Sep 17 00:00:00 2001 From: cherrydev Date: Thu, 10 Dec 2015 14:49:05 -0800 Subject: [PATCH 0034/1850] Update dexie.d.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cat walked across the keyboard. Just not my day… --- dexie/dexie.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dexie/dexie.d.ts b/dexie/dexie.d.ts index 2a527cff93..ca90689fa0 100644 --- a/dexie/dexie.d.ts +++ b/dexie/dexie.d.ts @@ -13,7 +13,7 @@ interface Thenable { declare class Dexie { constructor(databaseName: string); - constructor(databaseName: string, options: { addons: Array<(db: Dexie) => void> });b + constructor(databaseName: string, options: { addons: Array<(db: Dexie) => void> }); name: string; tables: Dexie.Table[]; From 0a0cadd8536635c3e53a9757b9396d256d6dd2d5 Mon Sep 17 00:00:00 2001 From: darktutu Date: Fri, 11 Dec 2015 18:10:11 +0800 Subject: [PATCH 0035/1850] directive compile can return a function whit void IDirective --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a489141d54..f90992e27e 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1650,7 +1650,7 @@ declare module angular { templateElement: IAugmentedJQuery, templateAttributes: IAttributes, transclude: ITranscludeFunction - ): IDirectivePrePost; + ): void | IDirectivePrePost; } interface IDirective { From 42fc54a14dc7f835da5cacc525926be1ad0f0e00 Mon Sep 17 00:00:00 2001 From: "raf_w87@wp.pl" Date: Sat, 12 Dec 2015 17:09:02 +0100 Subject: [PATCH 0036/1850] TSD file for angular-q-spread module - angular-q-spread-test.ts -> angular-q-spread-tests.ts --- .../{angular-q-spread-test.ts => angular-q-spread-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename angular-q-spread/{angular-q-spread-test.ts => angular-q-spread-tests.ts} (100%) diff --git a/angular-q-spread/angular-q-spread-test.ts b/angular-q-spread/angular-q-spread-tests.ts similarity index 100% rename from angular-q-spread/angular-q-spread-test.ts rename to angular-q-spread/angular-q-spread-tests.ts From 02941d70e88487358f99e3b5700baf5411dc17c3 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 14 Dec 2015 15:34:11 +1100 Subject: [PATCH 0037/1850] Added react bootstrap validation --- .../react-bootstrap-validation.d.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 react-bootstrap-validation/react-bootstrap-validation.d.ts diff --git a/react-bootstrap-validation/react-bootstrap-validation.d.ts b/react-bootstrap-validation/react-bootstrap-validation.d.ts new file mode 100644 index 0000000000..9eeee01c1f --- /dev/null +++ b/react-bootstrap-validation/react-bootstrap-validation.d.ts @@ -0,0 +1,83 @@ +/// + +declare module ReactBootstrapValidation{ + + export interface Form { + model; + validateOne: any; + validateAll: any; + errorHelp: string | any; + validationEvent: string; + onValidSubmit: any; + + } + export interface ValidatedInput + { + + name: string; + validationEvent: string; + validate: any; + + type: any; + label: any; + errorHelp: any; + } + + export interface Radio extends ValidatedInput { + + } + + + export interface RadioGroup extends ValidatedInput { + validationEvent: any; + } + + export interface Validator { + + required(val: String); + //Returns true if the value is not null.Can be used as an alias to !isNull validation rule. + isChecked(val: String); + + } + + export interface FileValidator extends Validator { + ref: any; + name: any; + type :any; + label:any; + multiple: any; + validate: any; + + isEmpty(files: FileList); + + /// Returns true if there are no files in file list. + isSingle(files: FileList); + + // Returns true if files count equals to 1. + isMultiple(files: FileList); + + //Returns true if files count is more than 1. + isFilesCount(files: FileList, min: Number, max:Array ); + + //Returns true if files count is within allowed range.If max is not supplied, checks if files count equals min. + isTotalSize(files: FileList, min: Number, max: Array); + + //Returns true if total size of all files is within allowed range. + isEachFileSize(files: FileList, min: Number, max: Array); + + //Returns true if each file's size is within allowed range. + isExtension(files: FileList, extensions: Array); + + //Returns true if each file's extension is in the extensions array. + isType(files: FileList, types: Array); + } + + export interface InputContainer { + + } + } + + +declare module 'react-bootstrap-validation' { + export = ReactBootstrapValidation; +} \ No newline at end of file From e348fb97b5a21d123b9669d6f6c4134288c5d36f Mon Sep 17 00:00:00 2001 From: samael Date: Mon, 14 Dec 2015 17:20:49 +0800 Subject: [PATCH 0038/1850] Update state-machine.d.ts Update to 2.3.5 --- state-machine/state-machine.d.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/state-machine/state-machine.d.ts b/state-machine/state-machine.d.ts index d17c58dc69..7065ee1983 100644 --- a/state-machine/state-machine.d.ts +++ b/state-machine/state-machine.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Finite State Machine 2.2 +// Type definitions for Finite State Machine 2.3.5 // Project: https://github.com/jakesgordon/javascript-state-machine -// Definitions by: Boris Yankov , Maarten Docter , William Sears +// Definitions by: Boris Yankov , Maarten Docter , William Sears , samael // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StateMachineErrorCallback { @@ -29,7 +29,7 @@ interface StateMachineConfig { interface StateMachineStatic { - VERSION: string; // = "2.2.0" + VERSION: string; // = "2.3.5" WILDCARD: string; // = '*' ASYNC: string; // = 'async' @@ -37,7 +37,7 @@ interface StateMachineStatic { SUCCEEDED: number; // = 1, the event transitioned successfully from one state to another NOTRANSITION: number; // = 2, the event was successfull but no state transition was necessary CANCELLED: number; // = 3, the event was cancelled by the caller in a beforeEvent callback - ASYNC: number; // = 4, the event is asynchronous and the caller is in control of when the transition occurs + PENDING: number; // = 4, the event is asynchronous and the caller is in control of when the transition occurs }; Error: { @@ -62,13 +62,16 @@ interface StateMachineCan { (evt: string): boolean; } +interface StateMachineIsFinished { + (state: string): boolean; +} interface StateMachine { current: string; is: StateMachineIs; can: StateMachineCan; cannot: StateMachineCan; error: StateMachineErrorCallback; - + isFinished: StateMachineIsFinished; /* transition - only available when performing async state transitions; otherwise null. Can be a: [1] fsm.transition(); // called from async callback [2] fsm.transition.cancel(); From 70e18515c62fc1232ee8a4260ac28018d1f30b52 Mon Sep 17 00:00:00 2001 From: samael Date: Mon, 14 Dec 2015 17:23:31 +0800 Subject: [PATCH 0039/1850] Update to 2.3.5 Update to 2.3.5 --- state-machine/state-machine.d.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/state-machine/state-machine.d.ts b/state-machine/state-machine.d.ts index d17c58dc69..7065ee1983 100644 --- a/state-machine/state-machine.d.ts +++ b/state-machine/state-machine.d.ts @@ -1,6 +1,6 @@ -// Type definitions for Finite State Machine 2.2 +// Type definitions for Finite State Machine 2.3.5 // Project: https://github.com/jakesgordon/javascript-state-machine -// Definitions by: Boris Yankov , Maarten Docter , William Sears +// Definitions by: Boris Yankov , Maarten Docter , William Sears , samael // Definitions: https://github.com/borisyankov/DefinitelyTyped interface StateMachineErrorCallback { @@ -29,7 +29,7 @@ interface StateMachineConfig { interface StateMachineStatic { - VERSION: string; // = "2.2.0" + VERSION: string; // = "2.3.5" WILDCARD: string; // = '*' ASYNC: string; // = 'async' @@ -37,7 +37,7 @@ interface StateMachineStatic { SUCCEEDED: number; // = 1, the event transitioned successfully from one state to another NOTRANSITION: number; // = 2, the event was successfull but no state transition was necessary CANCELLED: number; // = 3, the event was cancelled by the caller in a beforeEvent callback - ASYNC: number; // = 4, the event is asynchronous and the caller is in control of when the transition occurs + PENDING: number; // = 4, the event is asynchronous and the caller is in control of when the transition occurs }; Error: { @@ -62,13 +62,16 @@ interface StateMachineCan { (evt: string): boolean; } +interface StateMachineIsFinished { + (state: string): boolean; +} interface StateMachine { current: string; is: StateMachineIs; can: StateMachineCan; cannot: StateMachineCan; error: StateMachineErrorCallback; - + isFinished: StateMachineIsFinished; /* transition - only available when performing async state transitions; otherwise null. Can be a: [1] fsm.transition(); // called from async callback [2] fsm.transition.cancel(); From 06336e28fcead25080b58e7c5aae073b78cfe3c1 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sun, 20 Dec 2015 10:46:02 +1100 Subject: [PATCH 0040/1850] Revert "Merge branch 'master' of https://github.com/brewsoftware/DefinitelyTyped" This reverts commit 0adfcd3dfd9860cef6b73762fa8c1eb5c4886dad, reversing changes made to 40c60850ad6c8175a62d5ab48c4e016ea5b3dffe. --- axios/axios.d.ts | 289 ++++----- crypto-js/crypto-js.d.ts | 583 ++---------------- .../react-bootstrap-validation.d.ts | 83 --- 3 files changed, 191 insertions(+), 764 deletions(-) delete mode 100644 react-bootstrap-validation/react-bootstrap-validation.d.ts diff --git a/axios/axios.d.ts b/axios/axios.d.ts index 86414bde6b..48f57a73a3 100644 --- a/axios/axios.d.ts +++ b/axios/axios.d.ts @@ -1,191 +1,162 @@ - // Type definitions for axios 0.5.2 // Project: https://github.com/mzabriskie/axios -// Definitions by: Marcel Buesing , Jason Turner +// Definitions by: Marcel Buesing // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module Axios { - /** - * - request body data type - */ - interface AxiosXHRConfigBase { - - /** - * Change the request data before it is sent to the server. - * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' - * The last function in the array must return a string or an ArrayBuffer - */ - transformRequest?: ((data: T) => U) | [(data: T) => U]; - - /** - * change the response data to be made before it is passed to then/catch - */ - transformResponse?: (data: T) => U; - - /** - * custom headers to be sent - */ - headers?: Object; - - /** - * URL parameters to be sent with the request - */ - params?: Object; - - /** - * indicates whether or not cross-site Access-Control requests - * should be made using credentials - */ - withCredentials?: boolean; - - /** - * indicates the type of data that the server will respond with - * options are 'arraybuffer', 'blob', 'document', 'json', 'text' - */ - responseType?: string; - - /** - * name of the cookie to use as a value for xsrf token - */ - xsrfCookieName?: string; - - /** - * name of the http header that carries the xsrf token value - */ - xsrfHeaderName?: string; - - } + /** + * - request body data type + */ + interface AxiosXHRConfigBase { /** - * - request body data type + * Change the request data before it is sent to the server. + * This is only applicable for request methods 'PUT', 'POST', and 'PATCH' + * The last function in the array must return a string or an ArrayBuffer */ - interface AxiosXHRConfig extends AxiosXHRConfigBase { - /** - * server URL that will be used for the request, options are: - * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH - */ - url: string; - - /** - * request method to be used when making the request - */ - method?: string; - - /** - * data to be sent as the request body - * Only applicable for request methods 'PUT', 'POST', and 'PATCH' - * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash - */ - data?: T; - } + transformRequest?: ((data:T) => U)|[(data:T) => U]; /** - * - expected response type, - * - request body data type + * change the response data to be made before it is passed to then/catch */ - interface AxiosXHR { - /** - * Response that was provided by the server - */ - data: T; - - /** - * HTTP status code from the server response - */ - status: number; - - /** - * HTTP status message from the server response - */ - statusText: string; - - /** - * headers that the server responded with - */ - headers: Object; - - /** - * config that was provided to `axios` for the request - */ - config: AxiosXHRConfig; - } + transformResponse?: (data:T) => U; /** - * - expected response type, - * - request body data type + * custom headers to be sent */ - interface AxiosStatic { + headers?: Object; - (config: AxiosXHRConfig): Promise>; + /** + * URL parameters to be sent with the request + */ + params?: Object; - new (config: AxiosXHRConfig): Promise>; + /** + * indicates whether or not cross-site Access-Control requests + * should be made using credentials + */ + withCredentials?: boolean; - /** - * convenience alias, method = GET - */ - get(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * indicates the type of data that the server will respond with + * options are 'arraybuffer', 'blob', 'document', 'json', 'text' + */ + responseType?: string; + + /** + * name of the cookie to use as a value for xsrf token + */ + xsrfCookieName?: string; + + /** + * name of the http header that carries the xsrf token value + */ + xsrfHeaderName?: string; + + } + + /** + * - request body data type + */ + interface AxiosXHRConfig extends AxiosXHRConfigBase { + /** + * server URL that will be used for the request, options are: + * GET, PUT, POST, DELETE, CONNECT, HEAD, OPTIONS, TRACE, PATCH + */ + url: string; + + /** + * request method to be used when making the request + */ + method?: string; + + /** + * data to be sent as the request body + * Only applicable for request methods 'PUT', 'POST', and 'PATCH' + * When no `transformRequest` is set, must be a string, an ArrayBuffer or a hash + */ + data?: T; + } + + /** + * - expected response type, + * - request body data type + */ + interface AxiosXHR { + /** + * Response that was provided by the server + */ + data: T; + + /** + * HTTP status code from the server response + */ + status: number; + + /** + * HTTP status message from the server response + */ + statusText: string; + + /** + * headers that the server responded with + */ + headers: Object; + + /** + * config that was provided to `axios` for the request + */ + config: AxiosXHRConfig; + } + + /** + * - expected response type, + * - request body data type + */ + interface AxiosStatic { + + (config: AxiosXHRConfig): Promise>; + + new (config: AxiosXHRConfig): Promise>; + + /** + * convenience alias, method = GET + */ + get(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = DELETE - */ - delete(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = DELETE + */ + delete(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = HEAD - */ - head(url: string, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = HEAD + */ + head(url: string, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = POST - */ - post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = POST + */ + post(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PUT - */ - put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + /** + * convenience alias, method = PUT + */ + put(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - /** - * convenience alias, method = PATCH - */ - patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; - interceptors: { - request: Interceptor, - response: Interceptor - } - } - - - - export interface Response { - data?: any; - status?: number; - statusText?: string; - headers?: any; - config?: any; - } - export interface success { - (response: Response): void - } - export interface error { - (response: Axios.Response): void; - } - - export interface Interceptor { - use(success: success, error?: error): void; - eject(interceptor: Interceptor); - } + /** + * convenience alias, method = PATCH + */ + patch(url: string, data?: any, config?: AxiosXHRConfigBase): Promise>; + } } declare var axios: Axios.AxiosStatic; declare module "axios" { - export = axios; + export = axios; } - - - diff --git a/crypto-js/crypto-js.d.ts b/crypto-js/crypto-js.d.ts index cde0abd9b9..0f02514027 100644 --- a/crypto-js/crypto-js.d.ts +++ b/crypto-js/crypto-js.d.ts @@ -1,528 +1,67 @@ -// Type definitions for crypto-js v3.1.5 +// Type definitions for crypto-js v3.1.3 // Project: https://github.com/evanvosberg/crypto-js -// Definitions by: Michael Zabka , Jason Turner +// Definitions by: Michael Zabka // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare module CryptoJSLocal{ - module lib{ - interface Base{ - extend(overrides: Object): Object - init(...args: any[]): void - //arguments of create() is same as init(). This is true for all subclasses - create(...args: any[]): Base - mixIn(properties: Object): void - clone(): Base - } - - interface WordArray extends Base{ - words: number[] - sigBytes: number - init(words?: number[], sigBytes?: number): void - create(words?: number[], sigBytes?: number): WordArray - - init(typedArray: ArrayBuffer): void - init(typedArray: Int8Array): void - - //Because TypeScript uses a structural type system then we don't need (& can't) - //declare oveload function init, create for the following type (same as Int8Array): - //then Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array - //Note also: Uint8ClampedArray is not defined in lib.d.ts & not supported in IE - //@see http://compatibility.shwups-cms.ch/en/home?&property=Uint8ClampedArray - - create(typedArray: ArrayBuffer): WordArray - create(typedArray: Int8Array): WordArray - - toString(encoder?: enc.IEncoder): string - concat(wordArray: WordArray): WordArray - clamp(): void - clone(): WordArray - random(nBytes: number): WordArray - } - - interface BufferedBlockAlgorithm extends Base{ - reset(): void - clone(): BufferedBlockAlgorithm - } - - //tparam C - Configuration type - interface IHasher extends BufferedBlockAlgorithm{ - cfg: C - init(cfg?: C): void - create(cfg?: C): IHasher - - update(messageUpdate: string): Hasher - update(messageUpdate: WordArray): Hasher - - finalize(messageUpdate?: string): WordArray - finalize(messageUpdate?: WordArray): WordArray - - blockSize: number - - _createHelper(hasher: Hasher): IHasherHelper - _createHmacHelper(hasher: Hasher): IHasherHmacHelper - - clone(): IHasher - } - interface Hasher extends IHasher{} - - //tparam C - Configuration type - interface IHasherHelper{ - (message: string, cfg?: C): WordArray - (message: WordArray, cfg?: C): WordArray - } - interface HasherHelper extends IHasherHelper{} - - interface IHasherHmacHelper{ - (message: string, key: string): WordArray - (message: string, key: WordArray): WordArray - (message: WordArray, key: string): WordArray - (message: WordArray, key: WordArray): WordArray - } - - //tparam C - Configuration type - interface ICipher extends BufferedBlockAlgorithm{ - cfg: C - createEncryptor(key: WordArray, cfg?: C): ICipher - createDecryptor(key: WordArray, cfg?: C): ICipher - - create(xformMode?: number, key?: WordArray, cfg?: C): ICipher - init(xformMode?: number, key?: WordArray, cfg?: C): void - - process(dataUpdate: string): WordArray - process(dataUpdate: WordArray): WordArray - - finalize(dataUpdate?: string): WordArray - finalize(dataUpdate?: WordArray): WordArray - - keySize: number - ivSize: number - - _createHelper(cipher: Cipher): ICipherHelper - - clone(): ICipher - } - interface Cipher extends ICipher{} - - interface IStreamCipher extends ICipher{ - drop?: number; - - createEncryptor(key: WordArray, cfg?: C): IStreamCipher - createDecryptor(key: WordArray, cfg?: C): IStreamCipher - - create(xformMode?: number, key?: WordArray, cfg?: C): IStreamCipher - - blockSize: number - } - interface StreamCipher extends IStreamCipher{} - - interface BlockCipherMode extends Base{ - createEncryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherEncryptor - createDecryptor(cipher: Cipher, iv: number[]): mode.IBlockCipherDecryptor - init(cipher?: Cipher, iv?: number[]): void - create(cipher?: Cipher, iv?: number[]): BlockCipherMode - } - - //BlockCipher has interface same as IStreamCipher - interface BlockCipher extends IStreamCipher{} - - interface IBlockCipherCfg { - iv?: WordArray; - mode?: mode.IBlockCipherModeImpl //default CBC - padding?: pad.IPaddingImpl //default Pkcs7 - } - - interface CipherParamsData { - ciphertext?: lib.WordArray - key?: lib.WordArray - iv?: lib.WordArray - salt?: lib.WordArray - algorithm?: Cipher - mode?: mode.IBlockCipherModeImpl - padding?: pad.IPaddingImpl - blockSize?: number - formatter?: format.IFormatter - } - - interface CipherParams extends Base, CipherParamsData{ - init(cipherParams?: CipherParamsData): void - create(cipherParams?: CipherParamsData): CipherParams - toString(formatter?: format.IFormatter): string - } - - //tparam C - Configuration type - interface ISerializableCipher extends Base{ - cfg: C - encrypt(cipher: Cipher, message: WordArray, key: WordArray, cfg?: C): CipherParams - encrypt(cipher: Cipher, message: string, key: WordArray, cfg?: C): CipherParams - - decrypt(cipher: Cipher, ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray - decrypt(cipher: Cipher, ciphertext: string, key: WordArray, cfg?: C): WordArray - } - - interface SerializableCipher extends ISerializableCipher{} - interface ISerializableCipherCfg{ - format?: format.IFormatter //default OpenSSLFormatter - iv?: WordArray; - mode?: mode.IBlockCipherModeImpl; - padding?: pad.IPaddingImpl; - } - - interface IPasswordBasedCipher extends Base{ - cfg: C - encrypt(cipher: Cipher, message: WordArray, password: string, cfg?: C): CipherParams - encrypt(cipher: Cipher, message: string, password: string, cfg?: C): CipherParams - - decrypt(cipher: Cipher, ciphertext: CipherParamsData, password: string, cfg?: C): WordArray - decrypt(cipher: Cipher, ciphertext: string, password: string, cfg?: C): WordArray - } - - interface PasswordBasedCipher extends IPasswordBasedCipher{} - interface IPasswordBasedCipherCfg extends ISerializableCipherCfg{ - kdf?: kdf.IKdfImpl //default OpenSSLKdf - mode?: mode.IBlockCipherModeImpl; - padding?: pad.IPaddingImpl; - } - - /** see Cipher._createHelper */ - interface ICipherHelper{ - encrypt(message: string, password: string, cfg?: C): CipherParams - encrypt(message: string, key: WordArray, cfg?: C): CipherParams - encrypt(message: WordArray, password: string, cfg?: C): CipherParams - encrypt(message: WordArray, key: WordArray, cfg?: C): CipherParams - - decrypt(ciphertext: string, password: string, cfg?: C): WordArray - decrypt(ciphertext: string, key: WordArray, cfg?: C): WordArray - decrypt(ciphertext: CipherParamsData, password: string, cfg?: C): WordArray - decrypt(ciphertext: CipherParamsData, key: WordArray, cfg?: C): WordArray - } - - interface CipherHelper extends ICipherHelper{} - interface LibStatic{ - Base: lib.Base - WordArray: lib.WordArray - CipherParams: lib.CipherParams - SerializableCipher: lib.SerializableCipher - PasswordBasedCipher: lib.PasswordBasedCipher - } - } - - module enc{ - interface IEncoder{ - stringify(wordArray: lib.WordArray): string - } - interface IDecoder{ - parse(s: string): lib.WordArray - } - interface ICoder extends IEncoder, IDecoder {} - - interface EncStatic{ - Hex: ICoder - Latin1: ICoder - Utf8: ICoder - Base64: ICoder - Utf16: ICoder - Utf16BE: ICoder - Utf16LE: ICoder - } - } - - module kdf{ - interface KdfStatic{ - OpenSSL: IKdfImpl - } - - interface IKdfImpl{ - execute(password: string, keySize: number, ivSize: number, salt?: string): lib.CipherParams - execute(password: string, keySize: number, ivSize: number, salt?: lib.WordArray): lib.CipherParams - } - } - - module format{ - interface FormatStatic{ - OpenSSL: IFormatter - Hex: IFormatter - } - - interface IFormatter{ - stringify(cipherParams: lib.CipherParamsData): string - parse(s: string): lib.CipherParams - } - } - - module algo{ - interface AlgoStatic{ - AES: algo.AES - DES: algo.DES - TripleDES: algo.TripleDES - - RabbitLegacy: algo.RabbitLegacy - Rabbit: algo.Rabbit - RC4: algo.RC4 - - MD5: algo.MD5 - RIPEMD160: algo.RIPEMD160 - SHA1: algo.SHA1 - SHA256: algo.SHA256 - SHA224: algo.SHA224 - SHA384: algo.SHA384 - SHA512: algo.SHA512 - - SHA3: algo.SHA3 - - HMAC: algo.HMAC - - EvpKDF: algo.EvpKDF - PBKDF2: algo.PBKDF2 - - RC4Drop: algo.RC4Drop - } - - interface IBlockCipherImpl extends lib.BlockCipher{ - encryptBlock(M: number[], offset: number): void - decryptBlock(M: number[], offset: number): void - - createEncryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl - createDecryptor(key: lib.WordArray, cfg?: lib.CipherParamsData): IBlockCipherImpl - - create(xformMode?: number, key?: lib.WordArray, cfg?: lib.IBlockCipherCfg): IBlockCipherImpl - } - - interface AES extends IBlockCipherImpl{} - interface DES extends IBlockCipherImpl{} - interface TripleDES extends IBlockCipherImpl{} - - interface RabbitLegacy extends lib.StreamCipher{} - interface Rabbit extends lib.StreamCipher{} - interface RC4 extends lib.StreamCipher{} - - interface MD5 extends lib.Hasher{} - interface RIPEMD160 extends lib.Hasher{} - interface SHA1 extends lib.Hasher{} - interface SHA256 extends lib.Hasher{} - interface SHA224 extends lib.Hasher{} - interface SHA384 extends lib.Hasher{} - interface SHA512 extends lib.Hasher{} - - interface SHA3 extends lib.IHasher{} - interface ISHA3Cfg{ - outputLength?: number //default 512 - } - - interface HMAC extends lib.Base{ - init(hasher?: lib.Hasher, key?: string): void - init(hasher?: lib.Hasher, key?: lib.WordArray): void - create(hasher?: lib.Hasher, key?: string): HMAC - create(hasher?: lib.Hasher, key?: lib.WordArray): HMAC - - update(messageUpdate: string): HMAC - update(messageUpdate: lib.WordArray): HMAC - - finalize(messageUpdate?: string): lib.WordArray - finalize(messageUpdate?: lib.WordArray): lib.WordArray - } - - interface EvpKDF extends lib.Base{ - cfg: IEvpKDFCfg - init(cfg?: IEvpKDFCfg): void - create(cfg?: IEvpKDFCfg): EvpKDF - compute(password: string, salt: string): lib.WordArray - compute(password: string, salt: lib.WordArray): lib.WordArray - compute(password: lib.WordArray, salt: string): lib.WordArray - compute(password: lib.WordArray, salt: lib.WordArray): lib.WordArray - } - interface IEvpKDFCfg{ - keySize?: number //default 128/32 - hasher?: lib.Hasher //default MD5, or SHA1 with PBKDF2 - iterations?: number //default 1 - } - interface IEvpKDFHelper{ - (password: string, salt: string, cfg?: IEvpKDFCfg): lib.WordArray - (password: string, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray - (password: lib.WordArray, salt: string, cfg?: IEvpKDFCfg): lib.WordArray - (password: lib.WordArray, salt: lib.WordArray, cfg?: IEvpKDFCfg): lib.WordArray - } - - interface PBKDF2 extends EvpKDF{} //PBKDF2 is same as EvpKDF - - interface RC4Drop extends RC4 { } - } - - module mode{ - interface ModeStatic{ - CBC: mode.CBC - CFB: mode.CFB - CTR: mode.CTR - CTRGladman: mode.CTRGladman - ECB: mode.ECB - OFB: mode.OFB - } - - interface IBlockCipherEncryptor extends lib.BlockCipherMode{ - processBlock(words: number[], offset: number): void - } - interface IBlockCipherDecryptor extends lib.BlockCipherMode{ //exactly as IBlockCipherEncryptor - processBlock(words: number[], offset: number): void - } - interface IBlockCipherModeImpl extends lib.BlockCipherMode{ - Encryptor: IBlockCipherEncryptor - Decryptor: IBlockCipherDecryptor - } - - interface CBC extends IBlockCipherModeImpl{} - interface CFB extends IBlockCipherModeImpl{} - interface CTR extends IBlockCipherModeImpl{} - interface CTRGladman extends IBlockCipherModeImpl{} - interface ECB extends IBlockCipherModeImpl{} - interface OFB extends IBlockCipherModeImpl{} - } - - module pad{ - interface PadStatic{ - Pkcs7: pad.Pkcs7 - AnsiX923: pad.AnsiX923 - Iso10126: pad.Iso10126 - Iso97971: pad.Iso97971 - ZeroPadding: pad.ZeroPadding - NoPadding: pad.NoPadding - } - - interface IPaddingImpl{ - pad(data: lib.WordArray, blockSize: number): void - unpad(data: lib.WordArray): void - } - - interface Pkcs7 extends IPaddingImpl{} - interface AnsiX923 extends IPaddingImpl{} - interface Iso10126 extends IPaddingImpl{} - interface Iso97971 extends IPaddingImpl{} - interface ZeroPadding extends IPaddingImpl{} - interface NoPadding extends IPaddingImpl{} - } - - module x64{ - interface X64Static{ - Word: x64.Word - WordArray: x64.WordArray - } - - interface Word extends lib.Base{ - high: number - low: number - - init(high?: number, low?: number): void - create(high?: number, low?: number): Word - } - - interface WordArray extends lib.Base{ - words: Word[] - sigBytes: number - - init(words?: Word[], sigBytes?: number): void - create(words?: Word[], sigBytes?: number): WordArray - toX32(): lib.WordArray - clone(): WordArray - } - } - - interface CryptoJSStatic{ - lib: lib.LibStatic - enc: enc.EncStatic - kdf: kdf.KdfStatic - format: format.FormatStatic - algo: algo.AlgoStatic - mode: mode.ModeStatic - pad: pad.PadStatic - x64: x64.X64Static - - AES: CryptoJSLocal.lib.ICipherHelper - DES: CryptoJSLocal.lib.ICipherHelper - TripleDES: CryptoJSLocal.lib.ICipherHelper - - RabbitLegacy: CryptoJSLocal.lib.CipherHelper - Rabbit: CryptoJSLocal.lib.CipherHelper - RC4: CryptoJSLocal.lib.CipherHelper - RC4Drop: CryptoJSLocal.lib.ICipherHelper - - MD5: CryptoJSLocal.lib.HasherHelper - HmacMD5: CryptoJSLocal.lib.IHasherHmacHelper - RIPEMD160: CryptoJSLocal.lib.HasherHelper - HmacRIPEMD160: CryptoJSLocal.lib.IHasherHmacHelper - SHA1: CryptoJSLocal.lib.HasherHelper - HmacSHA1: CryptoJSLocal.lib.IHasherHmacHelper - SHA256: CryptoJSLocal.lib.HasherHelper - HmacSHA256: CryptoJSLocal.lib.IHasherHmacHelper - SHA224: CryptoJSLocal.lib.HasherHelper - HmacSHA224: CryptoJSLocal.lib.IHasherHmacHelper - SHA512: CryptoJSLocal.lib.HasherHelper - HmacSHA512: CryptoJSLocal.lib.IHasherHmacHelper - SHA384: CryptoJSLocal.lib.HasherHelper - HmacSHA384: CryptoJSLocal.lib.IHasherHmacHelper - - SHA3: CryptoJSLocal.lib.IHasherHelper - HmacSHA3: CryptoJSLocal.lib.IHasherHmacHelper - - EvpKDF: CryptoJSLocal.algo.IEvpKDFHelper - PBKDF2: CryptoJSLocal.algo.IEvpKDFHelper //PBKDF2 is same as EvpKDF - } - type Hash = (message: string, key?: string, ...options: any[]) => string; - - export interface Hashes { - MD5: Hash; - SHA1: Hash; - SHA256: Hash; - SHA224: Hash; - SHA512: Hash; - SHA384: Hash; - SHA3: Hash; - RIPEMD160: Hash; - HmacMD5: Hash; - HmacSHA1: Hash; - HmacSHA256: Hash; - HmacSHA224: Hash; - HmacSHA512: Hash; - HmacSHA384: Hash; - HmacSHA3: Hash; - HmacRIPEMD160: Hash; - PBKDF2: Hash; - AES: Hash; - TripleDES: Hash; - RC4: Hash; - Rabbit: Hash; - RabbitLegacy: Hash; - EvpKDF: Hash; - format: { - OpenSSL: Hash; - Hex: Hash; - }; - enc: { - Latin1: Hash; - Utf8: Hash; - Hex: Hash; - Utf16: Hash; - Base64: Hash; - }; - mode: { - CFB: Hash; - CTR: Hash; - CTRGladman: Hash; - OFB: Hash; - ECB: Hash; - }; - pad: { - Pkcs7: Hash; - Ansix923: Hash; - Iso10126: Hash; - Iso97971: Hash; - ZeroPadding: Hash; - NoPadding: Hash; - }; - } - - export var hashes: Hashes; +declare module CryptoJS { + type Hash = (message: string, key?: string, ...options: any[]) => string; + + export interface Hashes { + MD5: Hash; + SHA1: Hash; + SHA256: Hash; + SHA224: Hash; + SHA512: Hash; + SHA384: Hash; + SHA3: Hash; + RIPEMD160: Hash; + HmacMD5: Hash; + HmacSHA1: Hash; + HmacSHA256: Hash; + HmacSHA224: Hash; + HmacSHA512: Hash; + HmacSHA384: Hash; + HmacSHA3: Hash; + HmacRIPEMD160: Hash; + PBKDF2: Hash; + AES: Hash; + TripleDES: Hash; + RC4: Hash; + Rabbit: Hash; + RabbitLegacy: Hash; + EvpKDF: Hash; + format: { + OpenSSL: Hash; + Hex: Hash; + }; + enc: { + Latin1: Hash; + Utf8: Hash; + Hex: Hash; + Utf16: Hash; + Base64: Hash; + }; + mode: { + CFB: Hash; + CTR: Hash; + CTRGladman: Hash; + OFB: Hash; + ECB: Hash; + }; + pad: { + Pkcs7: Hash; + Ansix923: Hash; + Iso10126: Hash; + Iso97971: Hash; + ZeroPadding: Hash; + NoPadding: Hash; + }; + } + + export var hashes: Hashes; } -declare var CryptoJS: CryptoJSLocal.CryptoJSStatic; - -declare module "crypto-js" { - export = CryptoJS; +declare module 'crypto-js' { + import hashes = CryptoJS.hashes; + export = hashes; } diff --git a/react-bootstrap-validation/react-bootstrap-validation.d.ts b/react-bootstrap-validation/react-bootstrap-validation.d.ts deleted file mode 100644 index 9eeee01c1f..0000000000 --- a/react-bootstrap-validation/react-bootstrap-validation.d.ts +++ /dev/null @@ -1,83 +0,0 @@ -/// - -declare module ReactBootstrapValidation{ - - export interface Form { - model; - validateOne: any; - validateAll: any; - errorHelp: string | any; - validationEvent: string; - onValidSubmit: any; - - } - export interface ValidatedInput - { - - name: string; - validationEvent: string; - validate: any; - - type: any; - label: any; - errorHelp: any; - } - - export interface Radio extends ValidatedInput { - - } - - - export interface RadioGroup extends ValidatedInput { - validationEvent: any; - } - - export interface Validator { - - required(val: String); - //Returns true if the value is not null.Can be used as an alias to !isNull validation rule. - isChecked(val: String); - - } - - export interface FileValidator extends Validator { - ref: any; - name: any; - type :any; - label:any; - multiple: any; - validate: any; - - isEmpty(files: FileList); - - /// Returns true if there are no files in file list. - isSingle(files: FileList); - - // Returns true if files count equals to 1. - isMultiple(files: FileList); - - //Returns true if files count is more than 1. - isFilesCount(files: FileList, min: Number, max:Array ); - - //Returns true if files count is within allowed range.If max is not supplied, checks if files count equals min. - isTotalSize(files: FileList, min: Number, max: Array); - - //Returns true if total size of all files is within allowed range. - isEachFileSize(files: FileList, min: Number, max: Array); - - //Returns true if each file's size is within allowed range. - isExtension(files: FileList, extensions: Array); - - //Returns true if each file's extension is in the extensions array. - isType(files: FileList, types: Array); - } - - export interface InputContainer { - - } - } - - -declare module 'react-bootstrap-validation' { - export = ReactBootstrapValidation; -} \ No newline at end of file From adaedc02189c2b4a6429637aef7ca8d88e66b063 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 22 Dec 2015 15:12:14 +1100 Subject: [PATCH 0041/1850] added re-validator --- revalidator/revalidator.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 revalidator/revalidator.d.ts diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts new file mode 100644 index 0000000000..aaf38ba78f --- /dev/null +++ b/revalidator/revalidator.d.ts @@ -0,0 +1,16 @@ +// Type definitions for axios 0.5.2 + +// Definitions by: Jason Turner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Revalidator { + interface RevalidatorStatic { + validate(object: any, schema: any, options: any): any; + } +} + +declare var revalidator: Revalidator.RevalidatorStatic; + +declare module "revalidator" { + export = revalidator; +} From 71a528be4d644460a64ec4c7f4dc727df8c91ff7 Mon Sep 17 00:00:00 2001 From: David Broder-Rodgers Date: Wed, 23 Dec 2015 14:05:39 +0000 Subject: [PATCH 0042/1850] Updated chai-things typing --- chai-things/chai-things.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chai-things/chai-things.d.ts b/chai-things/chai-things.d.ts index bc2b89c46f..0c00e1746e 100644 --- a/chai-things/chai-things.d.ts +++ b/chai-things/chai-things.d.ts @@ -1,7 +1,7 @@ // Type definitions for chai-things // Project: https://github.com/chaijs/chai-things // Definitions by: David Broder-Rodgers -// Definitions: https://github.com/DavidBR-SW/DefinitelyTyped +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -25,14 +25,14 @@ declare module Chai { interface Anything extends Assertion { (): any; - that: Assertion - with: Assertion + that: Assertion; + with: Assertion; } interface Something extends Assertion { (): any; - that: Assertion - with: Assertion + that: Assertion; + with: Assertion; } interface Item { From 3d4881b0799d1b2fabcebd8afbf0e50f450c6387 Mon Sep 17 00:00:00 2001 From: Darren Hill Date: Wed, 23 Dec 2015 11:25:30 -0500 Subject: [PATCH 0043/1850] Added Definitions for jSuite and SuiteScript --- jsuite/jsuite.d.ts | 42 + suitescript/suitescript.d.ts | 6625 ++++++++++++++++++++++++++++++++++ 2 files changed, 6667 insertions(+) create mode 100644 jsuite/jsuite.d.ts create mode 100644 suitescript/suitescript.d.ts diff --git a/jsuite/jsuite.d.ts b/jsuite/jsuite.d.ts new file mode 100644 index 0000000000..2d32c88e68 --- /dev/null +++ b/jsuite/jsuite.d.ts @@ -0,0 +1,42 @@ +// Type definitions for jSuite +// Project: https://github.com/darrenthill/jsuite +// Definitions by: Darren Hill +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +interface Iconfig { + logging?: boolean; + smartConvert?: boolean; + searchId?: string; + recordType?: string; + filterExpression?: any; + columns?: string; + start?: number; + end?: number; + maxUnitsUsage?: number; +} +declare module jSuite { + function getVersion(): string; + function setLogging(toggle: boolean): void; + function getRoleCenter(): any; + function getUser(): any; + function getScriptParameter(paramName: string): any; + function getDeploymentId(): any; + function getScriptId(): any; + function isProduction(): any; + function clearSublist(transaction: nlobjRecord, listType: string): void; + function getCompanyPreference(paramName: string): any; + function roundNum(num: number, length: number): number; + function isNumber(n: any): boolean; + function runSearch(config?: Iconfig): any; + function lookupField(dataIn: any): string; + function submitField(dataIn: any): any; + function asyncLookupField(config: any, callback: any): void; + function asyncSubmitField(config: any): JQueryXHR; + function audit(title: string, message: string): void; + function debug(title: string, message: string): void; + function error(title: string, message: string): void; + function emergency(title: string, message: string): void; +} diff --git a/suitescript/suitescript.d.ts b/suitescript/suitescript.d.ts new file mode 100644 index 0000000000..3fee0a8785 --- /dev/null +++ b/suitescript/suitescript.d.ts @@ -0,0 +1,6625 @@ +// Type definitions for Suite Script +// Project: http://www.netsuite.com +// Definitions by: Darren Hill +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace nlobjRecord.prototype { + // nlobjRecord.prototype.getSubList.!ret + + /** + * + */ + interface GetSubListRet { + + /** + * + */ + prototype : { + + /** + * + */ + addButton : /*no type*/{}; + + /** + * + */ + setLabel : /* nlobjSubList.prototype.setLabel */ any; + + /** + * + */ + setHelpText : /* nlobjSubList.prototype.setHelpText */ any; + + /** + * + */ + setDisplayType : /* nlobjSubList.prototype.setDisplayType */ any; + + /** + * + */ + setLineItemValue : /* nlobjSubList.prototype.setLineItemValue */ any; + + /** + * + */ + setLineItemMatrixValue : /* nlobjSubList.prototype.setLineItemMatrixValue */ any; + + /** + * + */ + setLineItemValues : /* nlobjSubList.prototype.setLineItemValues */ any; + + /** + * + */ + getLineItemCount : /* nlobjSubList.prototype.getLineItemCount */ any; + + /** + * + */ + addField : /* nlobjSubList.prototype.addField */ any; + + /** + * + */ + setUniqueField : /* nlobjSubList.prototype.setUniqueField */ any; + + /** + * + */ + addRefreshButton : /* nlobjSubList.prototype.addRefreshButton */ any; + + /** + * + */ + addMarkAllButtons : /* nlobjSubList.prototype.addMarkAllButtons */ any; + } + } +} +declare namespace nlobjRecord.prototype.GetSubListRet.prototype { + // nlobjRecord.prototype.getSubList.!ret.prototype.addButton.!ret + + /** + * + */ + interface AddButtonRet { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjButton.prototype.setLabel */ any; + + /** + * + */ + setDisabled : /* nlobjButton.prototype.setDisabled */ any; + } + } +} +declare namespace nlobjRecord.prototype { + // nlobjRecord.prototype.getField.!ret + + /** + * + */ + interface GetFieldRet { + + /** + * + */ + prototype : { + + /** + * + */ + getName : /* nlobjField.prototype.getName */ any; + + /** + * + */ + getLabel : /* nlobjField.prototype.getLabel */ any; + + /** + * + */ + getType : /* nlobjField.prototype.getType */ any; + + /** + * + */ + isHidden : /* nlobjField.prototype.isHidden */ any; + + /** + * + */ + isMandatory : /* nlobjField.prototype.isMandatory */ any; + + /** + * + */ + isDisabled : /* nlobjField.prototype.isDisabled */ any; + + /** + * + */ + setLabel : /* nlobjField.prototype.setLabel */ any; + + /** + * + */ + setAlias : /* nlobjField.prototype.setAlias */ any; + + /** + * + */ + setDefaultValue : /* nlobjField.prototype.setDefaultValue */ any; + + /** + * + */ + setDisabled : /* nlobjField.prototype.setDisabled */ any; + + /** + * + */ + setMandatory : /* nlobjField.prototype.setMandatory */ any; + + /** + * + */ + setMaxLength : /* nlobjField.prototype.setMaxLength */ any; + + /** + * + */ + setDisplayType : /* nlobjField.prototype.setDisplayType */ any; + + /** + * + */ + setBreakType : /* nlobjField.prototype.setBreakType */ any; + + /** + * + */ + setLayoutType : /* nlobjField.prototype.setLayoutType */ any; + + /** + * + */ + setLinkText : /* nlobjField.prototype.setLinkText */ any; + + /** + * + */ + setDisplaySize : /* nlobjField.prototype.setDisplaySize */ any; + + /** + * + */ + setPadding : /* nlobjField.prototype.setPadding */ any; + + /** + * + */ + setHelpText : /* nlobjField.prototype.setHelpText */ any; + + /** + * + */ + addSelectOption : /* nlobjField.prototype.addSelectOption */ any; + } + } +} +declare namespace nlobjPortlet.prototype { + // nlobjPortlet.prototype.addEditColumn.!0 + + /** + * + */ + interface AddEditColumn0 { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjColumn.prototype.setLabel */ any; + + /** + * + */ + setURL : /* nlobjColumn.prototype.setURL */ any; + + /** + * + */ + addParamToURL : /* nlobjColumn.prototype.addParamToURL */ any; + } + } +} +declare namespace nlobjForm.prototype { + // nlobjForm.prototype.addTab.!ret + + /** + * + */ + interface AddTabRet { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjTab.prototype.setLabel */ any; + + /** + * + */ + setHelpText : /* nlobjTab.prototype.setHelpText */ any; + } + } +} +declare namespace nlobjAssistant.prototype { + // nlobjAssistant.prototype.setCurrentStep.!0 + + /** + * + */ + interface SetCurrentStep0 { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjAssistantStep.prototype.setLabel */ any; + + /** + * + */ + setHelpText : /* nlobjAssistantStep.prototype.setHelpText */ any; + + /** + * + */ + getStepNumber : /* nlobjAssistantStep.prototype.getStepNumber */ any; + + /** + * + */ + getFieldValue : /* nlobjAssistantStep.prototype.getFieldValue */ any; + + /** + * + */ + getFieldValues : /* nlobjAssistantStep.prototype.getFieldValues */ any; + + /** + * + */ + getLineItemCount : /* nlobjAssistantStep.prototype.getLineItemCount */ any; + + /** + * + */ + getLineItemValue : /* nlobjAssistantStep.prototype.getLineItemValue */ any; + + /** + * + */ + getAllFields : /* nlobjAssistantStep.prototype.getAllFields */ any; + + /** + * + */ + getAllLineItems : /* nlobjAssistantStep.prototype.getAllLineItems */ any; + + /** + * + */ + getAllLineItemFields : /* nlobjAssistantStep.prototype.getAllLineItemFields */ any; + } + } +} +declare namespace nlobjForm.prototype { + // nlobjForm.prototype.addFieldGroup.!ret + + /** + * + */ + interface AddFieldGroupRet { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjFieldGroup.prototype.setLabel */ any; + + /** + * + */ + setCollapsible : /* nlobjFieldGroup.prototype.setCollapsible */ any; + + /** + * + */ + setSingleColumn : /* nlobjFieldGroup.prototype.setSingleColumn */ any; + + /** + * + */ + setShowBorder : /* nlobjFieldGroup.prototype.setShowBorder */ any; + } + } +} +declare namespace nlobjForm.prototype { + // nlobjForm.prototype.addButton.!ret + + /** + * + */ + interface AddButtonRet { + + /** + * + */ + prototype : { + + /** + * + */ + setLabel : /* nlobjButton.prototype.setLabel */ any; + + /** + * + */ + setDisabled : /* nlobjButton.prototype.setDisabled */ any; + } + } +} + +/** + * Return a new record using values from an existing record. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @param {Object} initializeValues Contains an array of name/value pairs of defaults to be used during record initialization. + * @return {nlobjRecord} Returns an nlobjRecord object of a copied record. + * + * @since 2007.0 + * @param type + * @param id + * @param initializeValues + * @return + */ +declare function nlapiCopyRecord(type:string, id:any, initializeValues:any):nlobjRecord; + +declare function nlapiDisableLineItemField(type:string, fldnam:string, val:boolean):void; +declare function nlapiDisableField(fldnam:string, val:any):void; + +/** + * Load an existing record from the system. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @param {Object} initializeValues Contains an array of name/value pairs of defaults to be used during record initialization. + * @return {nlobjRecord} Returns an nlobjRecord object of an existing NetSuite record. + * + * @exception {SSS_INVALID_RECORD_TYPE} + * @exception {SSS_TYPE_ARG_REQD} + * @exception {SSS_INVALID_INTERNAL_ID} + * @exception {SSS_ID_ARG_REQD} + * + * @since 2007.0 + * @param type + * @param id + * @param initializeValues + * @return + */ +declare function nlapiLoadRecord(type:string, id:any, initializeValues:any):nlobjRecord; + +/** + * Instantiate a new nlobjRecord object containing all the default field data for that record type. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * + * @param {string} type record type ID. + * @param {Object} initializeValues Contains an array of name/value pairs of defaults to be used during record initialization. + * @return {nlobjRecord} Returns an nlobjRecord object of a new record from the system. + * + * @exception {SSS_INVALID_RECORD_TYPE} + * @exception {SSS_TYPE_ARG_REQD} + * + * @since 2007.0 + * @param type + * @param initializeValues + * @return + */ +declare function nlapiCreateRecord(type:string, initializeValues:any):nlobjRecord; + +/** + * Submit a record to the system for creation or update. + * @governance 20 units for transactions, 4 for custom records, 8 for all other records + * + * @param {nlobjRecord} record nlobjRecord object containing the data record. + * @param {boolean} [doSourcing] If not set, this argument defaults to false. + * @param {boolean} [ignoreMandatoryFields] Disables mandatory field validation for this submit operation. + * @return {string} internal ID for committed record. + * + * @exception {SSS_INVALID_RECORD_OBJ} + * @exception {SSS_RECORD_OBJ_REQD} + * @exception {SSS_INVALID_SOURCE_ARG} + * + * @since 2007.0 + * @param record + * @param doSourcing? + * @param ignoreMandatoryFields? + * @return + */ +declare function nlapiSubmitRecord(record:any, doSourcing?:boolean, ignoreMandatoryFields?:boolean):string; + +/** + * Delete a record from the system. + * @governance 20 units for transactions, 4 for custom records, 8 for all other records + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @return {void} + * + * @exception {SSS_INVALID_RECORD_TYPE} + * @exception {SSS_TYPE_ARG_REQD} + * @exception {SSS_INVALID_INTERNAL_ID} + * @exception {SSS_ID_ARG_REQD} + * + * @since 2007.0 + * @param type + * @param id + * @return + */ +declare function nlapiDeleteRecord(type:string, id:any):void; + +/** + * Perform a record search using an existing search or filters and columns. + * @governance 10 units + * @restriction returns the first 1000 rows in the search + * + * @param {string} type record type ID. + * @param {int, string} [id] The internal ID or script ID for the saved search to use for search. + * @param {nlobjSearchFilter, nlobjSearchFilter[]} [filters] [optional] A single nlobjSearchFilter object - or - an array of nlobjSearchFilter objects. + * @param {nlobjSearchColumn, nlobjSearchColumn[]} [columns] [optional] A single nlobjSearchColumn object - or - an array of nlobjSearchColumn objects. + * @return {nlobjSearchResult[]} Returns an array of nlobjSearchResult objects corresponding to the searched records. + * + * @exception {SSS_INVALID_RECORD_TYPE} + * @exception {SSS_TYPE_ARG_REQD} + * @exception {SSS_INVALID_SRCH_ID} + * @exception {SSS_INVALID_SRCH_FILTER} + * @exception {SSS_INVALID_SRCH_FILTER_JOIN} + * @exception {SSS_INVALID_SRCH_OPERATOR} + * @exception {SSS_INVALID_SRCH_COL_NAME} + * @exception {SSS_INVALID_SRCH_COL_JOIN} + * + * @since 2007.0 + * @param type + * @param id + * @param filters + * @param columns + */ +declare function nlapiSearchRecord(type:string, id:any, filters:any, columns:any):nlobjSearchResult[]; + +/** + * Perform a global record search across the system. + * @governance 10 units + * @restriction returns the first 1000 rows in the search + * + * @param {string} keywords Global search keywords string or expression. + * @return {nlobjSearchResult[]} Returns an Array of nlobjSearchResult objects containing the following four columns: name, type (as shown in the UI), info1, and info2. + * + * @since 2008.1 + * @param keywords + */ +declare function nlapiSearchGlobal(keywords:string):nlobjSearchResult[]; + +/** + * Perform a duplicate record search using Duplicate Detection criteria. + * @governance 10 units + * @restriction returns the first 1000 rows in the search + * + * @param {string} type The recordType you are checking duplicates for (for example, customer|lead|prospect|partner|vendor|contact). + * @param {string[]} [fields] array of field names used to detect duplicate (for example, companyname|email|name|phone|address1|city|state|zipcode). + * @param {int} [id] internal ID of existing record. Depending on the use case, id may or may not be a required argument. + * @return {nlobjSearchResult[]} Returns an Array of nlobjSearchResult objects corresponding to the duplicate records. + * + * @since 2008.1 + * @param type + * @param fields + * @param id? + */ +declare function nlapiSearchDuplicate(type:string, fields:any, id?:any):nlobjSearchResult[]; + +/** + * Create a new record using values from an existing record of a different type. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @param {string} transformType The recordType you are transforming the existing record into. + * @param {Object} [transformValues] An object containing transform default option/value pairs used to pre-configure transformed record + * @return {nlobjRecord} + * + * @exception {SSS_INVALID_URL_CATEGORY} + * @exception {SSS_CATEGORY_ARG_REQD} + * @exception {SSS_INVALID_TASK_ID} + * @exception {SSS_TASK_ID_REQD} + * @exception {SSS_INVALID_INTERNAL_ID} + * @exception {SSS_INVALID_EDITMODE_ARG} + * + * @since 2007.0 + * @param type + * @param id + * @param transformType + * @param transformValues? + * @return + */ +declare function nlapiTransformRecord(type:string, id:any, transformType:string, transformValues?:any):nlobjRecord; + +/** + * void a transaction based on type and id . + * @governance 10 units for transactions + * + * @param {string} type The transaction type name. + * @param {string} id The internal ID for the record. + * @return {string} if accounting preference is reversing journal, then it is new journal id, + * otherwise, it is the input record id + * + * @since 2014.1 + * @param type + * @param id + * @return + */ +declare function nlapiVoidTransaction(type:string, id:string):string; + +/** + * Fetch the value of one or more fields on a record. This API uses search to look up the fields and is much + * faster than loading the record in order to get the field. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @param {string, string[]} fields - field or fields to look up. + * @param {boolean} [text] If set then the display value is returned instead for select fields. + * @return {string, Object} single value or an Object of field name/value pairs depending on the fields argument. + * + * @since 2008.1 + * @param type + * @param id + * @param fields + * @param text? + */ +declare function nlapiLookupField(type:string, id:number, fields:string, text?:boolean):string; +declare function nlapiLookupField(type:string, id:number, fields:string[], text?:boolean):any; + +/** + * Submit the values of a field or set of fields for an existing record. + * @governance 10 units for transactions, 2 for custom records, 4 for all other records + * @restriction only supported for records and fields where DLE (Direct List Editing) is supported + * + * @param {string} type The record type name. + * @param {int} id The internal ID for the record. + * @param {string, string[]} fields field or fields being updated. + * @param {string, string[]} values field value or field values used for updating. + * @param {boolean} [doSourcing] If not set, this argument defaults to false and field sourcing does not occur. + * @return {void} + * + * @since 2008.1 + * @param type + * @param id + * @param fields + * @param values + * @param doSourcing? + * @return + */ +declare function nlapiSubmitField(type:string, id:any, fields:any, values:any, doSourcing?:boolean):void; + +/** + * Attach a single record to another with optional properties. + * @governance 10 units + * + * @param {string} type1 The record type name being attached + * @param {int} id1 The internal ID for the record being attached + * @param {string} type2 The record type name being attached to + * @param {int} id2 The internal ID for the record being attached to + * @param {Object} [properties] Object containing name/value pairs used to configure attach operation + * @return {void} + * + * @since 2008.2 + * @param type1 + * @param id1 + * @param type2 + * @param id2 + * @param properties? + * @return + */ +declare function nlapiAttachRecord(type1:string, id1:any, type2:string, id2:any, properties?:any):void; + +/** + * Detach a single record from another with optional properties. + * @governance 10 units + * + * @param {string} type1 The record type name being attached + * @param {int} id1 The internal ID for the record being attached + * @param {string} type2 The record type name being attached to + * @param {int} id2 The internal ID for the record being attached to + * @param {Object} [properties] Object containing name/value pairs used to configure detach operation + * @return {void} + * + * @since 2008.2 + * @param type1 + * @param id1 + * @param type2 + * @param id2 + * @param properties? + * @return + */ +declare function nlapiDetachRecord(type1:string, id1:any, type2:string, id2:any, properties?:any):void; + +/** + * Resolve a URL to a resource or object in the system. + * + * @param {string} type type specifier for URL: suitelet|tasklink|record|mediaitem + * @param {string} subtype subtype specifier for URL (corresponding to type): scriptid|taskid|recordtype|mediaid + * @param {string} [id] internal ID specifier (sub-subtype corresponding to type): deploymentid|n/a|recordid|n/a + * @param {string} [pagemode] string specifier used to configure page (suitelet: external|internal, tasklink|record: edit|view) + * @return {string} + * + * @since 2007.0 + * @param type + * @param subtype + * @param id? + * @param pagemode? + * @return + */ +declare function nlapiResolveURL(type:string, subtype:string, id?:string, pagemode?:string):string; + +/** + * Redirect the user to a page. Only valid in the UI on Suitelets and User Events. In Client scripts this will initialize the redirect URL used upon submit. + * + * @param {string} type type specifier for URL: suitelet|tasklink|record|mediaitem + * @param {string} subtype subtype specifier for URL (corresponding to type): scriptid|taskid|recordtype|mediaid + * @param {string} [id] internal ID specifier (sub-subtype corresponding to type): deploymentid|n/a|recordid|n/a + * @param {string} [pagemode] string specifier used to configure page (suitelet: external|internal, tasklink|record: edit|view) + * @param {Object} [parameters] Object used to specify additional URL parameters as name/value pairs + * @return {void} + * + * @since 2007.0 + * @param type + * @param subtype + * @param id? + * @param pagemode? + * @param parameters? + * @return + */ +declare function nlapiSetRedirectURL(type:string, subtype:string, id?:string, pagemode?:string, parameters?:any):void; + +/** + * Request a URL to an external or internal resource. + * @restriction NetSuite maintains a white list of CAs that are allowed for https requests. Please see the online documentation for the complete list. + * @governance 10 units + * + * @param {string} url A fully qualified URL to an HTTP(s) resource + * @param {string, Object} [postdata] - string, document, or Object containing POST payload + * @param {Object} [headers] - Object containing request headers. + * @param {function} [callback] - available on the Client to support asynchronous requests. function is passed an nlobjServerResponse with the results. + * @return {nlobjServerResponse} + * + * @exception {SSS_UNKNOWN_HOST} + * @exception {SSS_INVALID_HOST_CERT} + * @exception {SSS_REQUEST_TIME_EXCEEDED} + * + * @since 2007.0 + * @param url + * @param postdata + * @param headers? + * @param callback? + * @param method + * @return + */ +declare function nlapiRequestURL(url:string, postdata:any, headers?:any, callback?:any, method?:any):any; + +/** + * Return context information about the current user/script. + * + * @return {nlobjContext} + * + * @since 2007.0 + * @return + */ +declare function nlapiGetContext():any; + +/** + * Return the internal ID for the currently logged in user. Returns -4 when called from online forms or "Available without Login" Suitelets. + * + * @return {int} + * + * @since 2005.0 + * @return + */ +declare function nlapiGetUser():any; + +/** + * Return the internal ID for the current user's role. Returns 31 (Online Form User) when called from online forms or "Available without Login" Suitelets. + * + * @return {int} + * + * @since 2005.0 + * @return + */ +declare function nlapiGetRole():any; + +/** + * Return the internal ID for the current user's department. + * + * @return {int} + * + * @since 2005.0 + * @return + */ +declare function nlapiGetDepartment():any; + +/** + * Return the internal ID for the current user's location. + * + * @return {int} + * + * @since 2005.0 + * @return + */ +declare function nlapiGetLocation():any; + +/** + * Return the internal ID for the current user's subsidiary. + * + * @return {int} + * + * @since 2008.1 + * @return + */ +declare function nlapiGetSubsidiary():any; + +/** + * Return the recordtype corresponding to the current page or userevent script. + * + * @return {string} + * + * @since 2007.0 + * @return + */ +declare function nlapiGetRecordType():string; + +/** + * Return the internal ID corresponding to the current page or userevent script. + * + * @return {int} + * + * @since 2007.0 + * @return + */ +declare function nlapiGetRecordId():any; + +/** + * Send out an email and associate it with records in the system. + * Supported base types are entity for entities, transaction for transactions, activity for activities and cases, record|recordtype for custom records + * @governance 10 units + * @restriction all outbound emails subject to email Anti-SPAM policies + * + * @param {int} from internal ID for employee user on behalf of whom this email is sent + * @param {string, int} to email address or internal ID of user that this email is being sent to + * @param {string} subject email subject + * @param {string} body email body + * @param {string, string[]} cc copy email address(es) + * @param {string, string[]} bcc blind copy email address(es) + * @param {Object} records Object of base types -> internal IDs used to associate email to records. i.e. {entity: 100, record: 23, recordtype: customrecord_surveys} + * @param {nlobjFile[]} files array of nlobjFile objects (files) to include as attachments + * @param {boolean} notifySenderOnBounce controls whether or not the sender will receive email notification of bounced emails (defaults to false) + * @param {boolean} internalOnly controls or not the resultingMmessage record will be visible to non-employees on the Communication tab of attached records (defaults to false) + * @param {string} replyTo email reply-to address + * @return {void} + * + * @since 2007.0 + * @param from + * @param to + * @param subject + * @param body + * @param cc + * @param bcc + * @param records + * @param files + * @param notifySenderOnBounce + * @param internalOnly + * @param replyTo + * @return + */ +declare function nlapiSendEmail(from:any, to:any, subject:string, body:string, cc:any, bcc:any, records:any, files:any, notifySenderOnBounce:boolean, internalOnly:boolean, replyTo:string):any; + +/** + * Sends a single on-demand campaign email to a specified recipient and returns a campaign response ID to track the email. + * @governance 10 units + * @restriction works in conjunction with the Lead Nurturing (campaigndrip) sublist only + * + * @param {int} campaigneventid internal ID of the campaign event + * @param {int} recipientid internal ID of the recipient - the recipient must have an email + * @return {int} + * + * @since 2010.1 + * @param campaigneventid + * @param recipientid + * @return + */ +declare function nlapiSendCampaignEmail(campaigneventid:any, recipientid:any):any; + +/** + * Send out a fax and associate it with records in the system. This requires fax preferences to be configured. + * Supported base types are entity for entities, transaction for transactions, activity for activities and cases, record|recordtype for custom records + * @governance 10 units + * + * @param {int} from internal ID for employee user on behalf of whom this fax is sent + * @param {string, int} to fax address or internal ID of user that this fax is being sent to + * @param {string} subject fax subject + * @param {string} body fax body + * @param {Object} records Object of base types -> internal IDs used to associate fax to records. i.e. {entity: 100, record: 23, recordtype: customrecord_surveys} + * @param {nlobjFile[]} files array of nlobjFile objects (files) to include as attachments + * @return {void} + * + * @since 2008.2 + * @param from + * @param to + * @param subject + * @param body + * @param records + * @param files + * @return + */ +declare function nlapiSendFax(from:any, to:any, subject:string, body:string, records:any, files:any):any; + +/** + * Return field definition for a field. + * + * @param {string} fldnam the name of the field + * @return {nlobjField} + * + * @since 2009.1 + * @param fldnam + * @return + */ +declare function nlapiGetField(fldnam:string):any; + +/** + * Return field definition for a matrix field. + * + * @param {string} type matrix sublist name + * @param {string} fldnam matrix field name + * @param {int} column matrix field column index (1-based) + * @return {nlobjField} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @return + */ +declare function nlapiGetMatrixField(type:string, fldnam:string, column:any):any; + +/** + * Return field definition for a sublist field. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} [linenum] line number for sublist field (1-based) and only valid for sublists of type staticlist and list + * @return {nlobjField} + * + * @since 2009.1 + * @param type + * @param fldnam + * @param linenum? + * @return + */ +declare function nlapiGetLineItemField(type:string, fldnam:string, linenum?:any):any; + +/** + * Return an nlobjField containing sublist field metadata. + * + * @param {string} type matrix sublist name + * @param {string} fldnam matrix field name + * @param {int} linenum line number (1-based) + * @param {int} column matrix column index (1-based) + * @return {nlobjField} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param linenum + * @param column + * @return + */ +declare function nlapiGetLineItemMatrixField(type:string, fldnam:string, linenum:any, column:any):any; + +/** + * Return the value of a field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam the field name + * @return {string} + * + * @since 2005.0 + * @param fldnam + * @return + */ +declare function nlapiGetFieldValue(fldnam:string):string; + +/** + * Set the value of a field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} fldnam the field name + * @param {string} value value used to set field + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2005.0 + * @param fldnam + * @param value + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetFieldValue(fldnam:string, value:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Return the display value of a select field's current selection on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam the field name + * @return {string} + * + * @since 2005.0 + * @param fldnam + * @return + */ +declare function nlapiGetFieldText(fldnam:string):string; + +/** + * Set the value of a field on the current record on a page using it's label. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} fldnam the field name + * @param {string} txt display name used to lookup field value + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2005.0 + * @param fldnam + * @param txt + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetFieldText(fldnam:string, txt:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Return the values of a multiselect field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam the field name + * @return {string[]} + * + * @since 2005.0 + * @param fldnam + */ +declare function nlapiGetFieldValues(fldnam:string):void; + +/** + * Set the values of a multiselect field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} fldnam field name + * @param {string[]} values array of strings containing values for field + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2005.0 + * @param fldnam + * @param values + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetFieldValues(fldnam:string, values:any, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Return the values (via display text) of a multiselect field on the current record. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam field name + * @return {string[]} + * + * @since 2009.1 + * @param fldnam + */ +declare function nlapiGetFieldTexts(fldnam:string):void; + +/** + * Set the values (via display text) of a multiselect field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} fldnam field name + * @param {string[]} texts array of strings containing display values for field + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2009.1 + * @param fldnam + * @param texts + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetFieldTexts(fldnam:string, texts:any, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Get the value of a matrix header field + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} column matrix column index (1-based) + * @return {string} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @return + */ +declare function nlapiGetMatrixValue(type:string, fldnam:string, column:any):string; + +/** + * Set the value of a matrix header field + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} column matrix column index (1-based) + * @param {string} value field value for matrix field + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @param value + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetMatrixValue(type:string, fldnam:string, column:any, value:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Get the current value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} column matrix column index (1-based) + * @return {string} value + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @return + */ +declare function nlapiGetCurrentLineItemMatrixValue(type:string, fldnam:string, column:any):string; + +/** + * Set the current value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @restriction synchronous arg is only supported in Client SuiteScript + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} column matrix column index (1-based) + * @param {string} value matrix field value + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @param value + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetCurrentLineItemMatrixValue(type:string, fldnam:string, column:any, value:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Return the value of a sublist matrix field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @param {int} column column index (1-based) + * @param {string} value + * + * @since 2009.2 + * @param type + * @param fldnam + * @param linenum + * @param column + */ +declare function nlapiGetLineItemMatrixValue(type:string, fldnam:string, linenum:any, column:any):void; + +/** + * Return the value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @return {string} + * + * @since 2005.0 + * @param type + * @param fldnam + * @param linenum + * @return + */ +declare function nlapiGetLineItemValue(type:string, fldnam:string, linenum:any):string; + +/** + * Return the value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @param {string} timezone value + * @return {string} + * + * @since 2013.2 + * @param type + * @param fldnam + * @param linenum + * @param timezone + * @return + */ +declare function nlapiGetLineItemDateTimeValue(type:string, fldnam:string, linenum:any, timezone:string):string; + +/** + * Set the value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @param {string} value + * @retun {void} + * + * @since 2005.0 + * @param type + * @param fldnam + * @param linenum + * @param value + */ +declare function nlapiSetLineItemValue(type:string, fldnam:string, linenum:any, value:string):void; + +/** + * Set the value of a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @param {string} datetime value + * @param {string} timezone value + * @retun {void} + * + * @since 2013.2 + * @param type + * @param fldnam + * @param linenum + * @param value + * @param timezone + */ +declare function nlapiSetLineItemDateTimeValue(type:string, fldnam:string, linenum:any, value:any, timezone:string):void; + +/** + * Return the label of a select field's current selection for a particular line. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} linenum line number (1-based) + * @return {string} + * + * @since 2005.0 + * @param type + * @param fldnam + * @param linenum + * @return + */ +declare function nlapiGetLineItemText(type:string, fldnam:string, linenum:any):string; + +/** + * Return the 1st line number that a sublist field value appears in + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} val the value being queried for in a sublist field + * @return {int} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param val + * @return + */ +declare function nlapiFindLineItemValue(type:string, fldnam:string, val:string):any; + +/** + * Return the 1st line number that a matrix field value appears in + * + * @param {string} type sublist name + * @param {string} fldnam matrix field name + * @param {int} column matrix column index (1-based) + * @param {string} val the value being queried for in a matrix field + * @return {int} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @param val + * @return + */ +declare function nlapiFindLineItemMatrixValue(type:string, fldnam:string, column:any, val:string):any; + +/** + * Return the number of columns for a matrix field + * + * @param {string} type sublist name + * @param {string} fldnam matrix field name + * @return {int} + * + * @since 2009.2 + * @param type + * @param fldnam + * @return + */ +declare function nlapiGetMatrixCount(type:string, fldnam:string):any; + +/** + * Return the number of sublists in a sublist on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @return {int} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiGetLineItemCount(type:string):any; + +/** + * Insert and select a new line into the sublist on a page or userevent. + * + * @param {string} type sublist name + * @param {int} [line] line number at which to insert a new line. + * @return{void} + * + * @since 2005.0 + * @param type + * @param line? + */ +declare function nlapiInsertLineItem(type:string, line?:any):void; + +/** + * Remove the currently selected line from the sublist on a page or userevent. + * + * @param {string} type sublist name + * @param {int} [line] line number to remove. + * @return {void} + * + * @since 2005.0 + * @param type + * @param line? + * @return + */ +declare function nlapiRemoveLineItem(type:string, line?:any):any; + +/** + * Set the value of a field on the currently selected line. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} value field value + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2005.0 + * @param type + * @param fldnam + * @param value + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetCurrentLineItemValue(type:string, fldnam:string, value:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Set the value of a field on the currently selected line. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} value field value + * @param {string} timezone value + * @return {void} + * + * @since 2013.2 + * @param type + * @param fldnam + * @param value + * @param timezone + * @return + */ +declare function nlapiSetCurrentLineItemDateTimeValue(type:string, fldnam:string, value:string, timezone:string):any; + +/** + * Set the value of a field on the currently selected line using it's label. + * @restriction synchronous arg is only supported in client SuiteScript + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} txt string containing display value or search text. + * @param {boolean} [firefieldchanged] if false then the field change event is suppressed (defaults to true) + * @param {boolean} [synchronous] if true then sourcing and field change execution happens synchronously (defaults to false). + * @return {void} + * + * @since 2005.0 + * @param type + * @param fldnam + * @param txt + * @param firefieldchanged? + * @param synchronous? + * @return + */ +declare function nlapiSetCurrentLineItemText(type:string, fldnam:string, txt:string, firefieldchanged?:boolean, synchronous?:boolean):any; + +/** + * Return the value of a field on the currently selected line. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @return {string} + * + * @since 2005.0 + * @param type + * @param fldnam + * @return + */ +declare function nlapiGetCurrentLineItemValue(type:string, fldnam:string):string; + +/** + * Return the value of a field on the currently selected line. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} timezone value + * @return {string} + * + * @since 2013.2 + * @param type + * @param fldnam + * @param timezone + * @return + */ +declare function nlapiGetCurrentLineItemDateTimeValue(type:string, fldnam:string, timezone:string):string; + +/** + * Return the label of a select field's current selection on the currently selected line. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @return {string} + * + * @since 2005.0 + * @param type + * @param fldnam + * @return + */ +declare function nlapiGetCurrentLineItemText(type:string, fldnam:string):string; + +/** + * Return the line number for the currently selected line. + * + * @param {string} type sublist name + * @return {int} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiGetCurrentLineItemIndex(type:string):any; + +/** + * Disable a sublist field. + * @restriction Only supported on sublists of type inlineeditor, editor and list (current field only) + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {boolean} disable if true then field is disabled + * @param {int} linenum line number for sublist field (1-based) and only valid for sublists of type list + * @return {void} + * + * @since 2009.1 + * @param type + * @param fldnam + * @param disable + * @param linenum + * @return + */ +declare function nlapiSetLineItemDisabled(type:string, fldnam:string, disable:boolean, linenum:any):any; + +/** + * Return field mandatoriness. + * + * @param {string} fldnam field name + * @return {boolean} + * + * @since 2009.1 + * @param fldnam + * @return + */ +declare function nlapiGetFieldMandatory(fldnam:string):boolean; + +/** + * Return sublist field mandatoriness. + * @restriction Only supported on sublists of type inlineeditor or editor (current field only) + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @return {boolean} + * + * @since 2009.1 + * @param type + * @param fldnam + * @return + */ +declare function nlapiGetLineItemMandatory(type:string, fldnam:string):boolean; + +/** + * Make a field mandatory. + * + * @param {string} fldnam field name + * @param {boolean} mandatory if true then field is made mandatory + * @return {void} + * + * @since 2009.1 + * @param fldnam + * @param mandatory + * @return + */ +declare function nlapiSetFieldMandatory(fldnam:string, mandatory:boolean):any; + +/** + * Make a sublist field mandatory. + * @restriction Only supported on sublists of type inlineeditor or editor (current field only) + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {boolean} mandatory if true then field is made mandatory + * @return {void} + * + * @since 2009.2 + * @param type + * @param fldnam + * @param mandatory + * @return + */ +declare function nlapiSetLineItemMandatory(type:string, fldnam:string, mandatory:boolean):any; + +/** + * Select an existing line in a sublist. + * + * @param {string} type sublist name + * @param {int} linenum line number to select + * @return {void} + * + * @since 2005.0 + * @param type + * @param linenum + * @return + */ +declare function nlapiSelectLineItem(type:string, linenum:any):any; + +/** + * Save changes made on the currently selected line to the sublist. + * + * @param {string} type sublist name + * @return {void} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiCommitLineItem(type:string):any; + +/** + * Cancel any changes made on the currently selected line. + * @restriction Only supported for sublists of type inlineeditor and editor + * + * @param {string} type sublist name + * @return {void} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiCancelLineItem(type:string):any; + +/** + * Select a new line in a sublist. + * @restriction Only supported for sublists of type inlineeditor and editor + * + * @param {string} type sublist name + * @return {void} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiSelectNewLineItem(type:string):any; + +/** + * Refresh the sublist table. + * @restriction Only supported for sublists of type inlineeditor, editor, and staticlist + * @restriction Client SuiteScript only. + * + * @param {string} type sublist name + * @return{void} + * + * @since 2005.0 + * @param type + */ +declare function nlapiRefreshLineItems(type:string):void; + +/** + * Adds a select option to a scripted select or multiselect field. + * @restriction Client SuiteScript only + * + * @param {string} fldnam field name + * @param {string} value internal ID for select option + * @param {string} text display text for select option + * @param {boolean} [selected] if true then option will be selected by default + * @return {void} + * + * @since 2008.2 + * @param fldnam + * @param value + * @param text + * @param selected? + * @return + */ +declare function nlapiInsertSelectOption(fldnam:string, value:string, text:string, selected?:boolean):any; + +/** + * Removes a select option (or all if value is null) from a scripted select or multiselect field. + * @restriction Client SuiteScript only + * + * @param {string} fldnam field name + * @param {string} value internal ID of select option to remove + * @return {void} + * + * @since 2008.2 + * @param fldnam + * @param value + * @return + */ +declare function nlapiRemoveSelectOption(fldnam:string, value:string):any; + +/** + * Adds a select option to a scripted select or multiselect sublist field. + * @restriction Client SuiteScript only + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} value internal ID for select option + * @param {string} text display text for select option + * @param {boolean} [selected] if true then option will be selected by default + * @return {void} + * + * @since 2008.2 + * @param type + * @param fldnam + * @param value + * @param text + * @param selected? + * @return + */ +declare function nlapiInsertLineItemOption(type:string, fldnam:string, value:string, text:string, selected?:boolean):any; + +/** + * Removes a select option (or all if value is null) from a scripted select or multiselect sublist field. + * @restriction Client SuiteScript only + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {string} value internal ID for select option to remove + * @return {void} + * + * @since 2008.2 + * @param type + * @param fldnam + * @param value + * @return + */ +declare function nlapiRemoveLineItemOption(type:string, fldnam:string, value:string):any; + +/** + * Returns true if any changes have been made to a sublist. + * @restriction Client SuiteScript only + * + * @param {string} type sublist name + * @return {boolean} + * + * @since 2005.0 + * @param type + * @return + */ +declare function nlapiIsLineItemChanged(type:string):boolean; + +/** + * Return an record object containing the data being submitted to the system for the currenr record. + * @restriction User Event scripts only + * + * @return {nlobjRecord} + * + * @since 2008.1 + * @return + */ +declare function nlapiGetNewRecord():any; + +/** + * Return an record object containing the current record's data prior to the write operation. + * @restriction beforeSubmit|afterSubmit User Event scripts only + * + * @return {nlobjRecord} + * + * @since 2008.1 + * @return + */ +declare function nlapiGetOldRecord():any; + +/** + * Create an nlobjError object that can be used to abort script execution and configure error notification + * + * @param {string} code error code + * @param {string} details error description + * @param {boolean} [suppressEmail] if true then suppress the error notification emails from being sent out (false by default). + * @return {nlobjError} + * + * @since 2008.2 + * @param code + * @param details + * @param suppressEmail? + * @return + */ +declare function nlapiCreateError(code:string, details:string, suppressEmail?:boolean):any; + +/** + * Return a new entry form page. + * @restriction Suitelets only + * + * @param {string} title page title + * @param {boolean} [hideHeader] true to hide the page header (false by default) + * @return {nlobjForm} + * + * @since 2008.2 + * @param title + * @param hideHeader? + * @return + */ +declare function nlapiCreateForm(title:string, hideHeader?:boolean):nlobjForm; + +/** + * Return a new list page. + * @restriction Suitelets only + * + * @param {string} title page title + * @param {boolean} [hideHeader] true to hide the page header (false by default) + * @return {nlobjList} + * + * @since 2008.2 + * @param title + * @param hideHeader? + * @return + */ +declare function nlapiCreateList(title:string, hideHeader?:boolean):any; + +/** + * Return a new assistant page. + * @restriction Suitelets only + * + * @param {string} title page title + * @param {boolean} [hideHeader] true to hide the page header (false by default) + * @return {nlobjAssistant} + * + * @since 2009.2 + * @param title + * @param hideHeader? + * @return + */ +declare function nlapiCreateAssistant(title:string, hideHeader?:boolean):any; + +/** + * Load a file from the file cabinet (via its internal ID or path). + * @governance 10 units + * @restriction Server SuiteScript only + * + * @param {string, int} id internal ID or relative path to file in the file cabinet (i.e. /SuiteScript/foo.js) + * @return {nlobjFile} + * + * @since 2008.2 + * @param id + * @return + */ +declare function nlapiLoadFile(id:any):any; + +/** + * Add/update a file in the file cabinet. + * @governance 20 units + * @restriction Server SuiteScript only + * + * @param {nlobjFile} file a file object to submit + * @return {int} return internal ID of file + * + * @since 2009.1 + * @param file + * @return + */ +declare function nlapiSubmitFile(file:any):any; + +/** + * Delete a file from the file cabinet. + * @governance 20 units + * @restriction Server SuiteScript only + * + * @param {int} id internal ID of file to be deleted + * @return {id} + * + * @since 2009.1 + * @param id + * @return + */ +declare function nlapiDeleteFile(id:any):any; + +/** + * Instantiate a file object (specifying the name, type, and contents which are base-64 encoded for binary types.) + * @restriction Server SuiteScript only + * + * @param {string} name file name + * @param {string} type file type i.e. plainText, htmlDoc, pdf, word (see documentation for the list of supported file types) + * @param {string} contents string containing file contents (must be base-64 encoded for binary types) + * @return {nlobjFile} + * + * @since 2009.1 + * @param name + * @param type + * @param contents + * @return + */ +declare function nlapiCreateFile(name:string, type:string, contents:string):any; + +/** + * Perform a mail merge operation using any template and up to 2 records and returns an nlobjFile with the results. + * @restriction only supported for record types that are available in mail merge: transactions, entities, custom records, and cases + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {int} id internal ID of template + * @param {string} baseType primary record type + * @param {int} baseId internal ID of primary record + * @param {string} [altType] secondary record type + * @param {int} [altId] internal ID of secondary record + * @param {Object} [fields] Object of merge field values to use in the mail merge (by default all field values are obtained from records) which overrides those from the record. + * @return {nlobjFile} + * + * @since 2008.2 + * @param id + * @param baseType + * @param baseId + * @param altType? + * @param altId? + * @param fields? + * @return + */ +declare function nlapiMergeRecord(id:any, baseType:string, baseId:any, altType?:string, altId?:any, fields?:any):any; + +/** + * Print a record (transaction) gievn its type, id, and output format. + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {string} type print output type: transaction|statement|packingslip|pickingticket + * @param {int} id internal ID of record to print + * @param {string} [format] output format: html|pdf|default + * @param {Object} [properties] Object of properties used to configure print + * @return {nlobjFile} + * + * @since 2008.2 + * @param type + * @param id + * @param format? + * @param properties? + * @return + */ +declare function nlapiPrintRecord(type:string, id:any, format?:string, properties?:any):any; + +/** + * Generate a PDF from XML using the BFO report writer (see http://big.faceless.org/products/report/). + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {string} input string containing BFO compliant XHTML + * @return {nlobjFile} + * + * @since 2009.1 + * @param input + * @return + */ +declare function nlapiXMLToPDF(input:string):any; + +/** + * Create a template renderer used to generate various outputs based on a template. + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {string} type media type: pdf|html + * @param {string} [engineType] [optional]: default is freemarker/html + * @return {nlobjTemplateRenderer} + * @return + */ +declare function nlapiCreateTemplateRenderer():any; + +/** + * Create an email merger used to assemble subject and body text of an email from a given + * FreeMarker template and a set of associated records. + * @restriction Server SuiteScript only + * + * @param {int} templateId internal ID of the template + * @return {nlobjEmailMerger} + * + * @since 2015.1 + * @param id + * @return + */ +declare function nlapiCreateEmailMerger(id:any):any; + +/** + * Create an entry in the script execution log (note that execution log entries are automatically purged after 30 days). + * + * @param {string} type log type: debug|audit|error|emergency + * @param {string} title log title (up to 90 characters supported) + * @param {string} [details] log details (up to 3000 characters supported) + * @return {void} + * + * @since 2008.1 + * @param type + * @param title + * @param details? + * @return + */ +declare function nlapiLogExecution(type:string, title:string, details?:string):any; + +/** + * Queue a scheduled script for immediate execution and return the status QUEUED if successfull. + * @restriction Server SuiteScript only + * @governance 20 units + * + * @param {string, int} script script ID or internal ID of scheduled script + * @param {string, int} [deployment] script ID or internal ID of scheduled script deployment. If empty, the first "free" deployment (i.e. status = Not Scheduled or Completed) will be used + * @param {Object} parameters Object of parameter name->values used in this scheduled script instance + * @return {string} QUEUED or null if no available deployments were found or the current status of the deployment specified if it was not available. + * + * @since 2008.1 + * @param script + * @param deployment + * @param parameters + * @return + */ +declare function nlapiScheduleScript(script:any, deployment:any, parameters:any):string; + +/** + * Return a URL with a generated OAuth token. + * @restriction Suitelets and Portlets only + * @governance 20 units + * + * @param {string} ssoAppKey + * @return {string} + * + * @since 2009.2 + * @param ssoAppKey + * @return + */ +declare function nlapiOutboundSSO(ssoAppKey:string):string; + +/** + * Loads a configuration record + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {string} type + * @return {nlobjConfiguration} + * + * @since 2009.2 + * @param type + * @return + */ +declare function nlapiLoadConfiguration(type:string):any; + +/** + * Commits all changes to a configuration record. + * @restriction Server SuiteScript only + * @governance 10 units + * + * @param {nlobjConfiguration} setup record + * @return (void) + * + * @since 2009.2 + * @param setup + */ +declare function nlapiSubmitConfiguration(setup:any):void; + +/** + * Convert a String into a Date object. + * + * @param {string} str date string in the user's date format, timeofday format, or datetime format + * @param {string} format format type to use: date|datetime|timeofday with date being the default + * @return {date} + * + * @since 2005.0 + * @param str + * @param format + * @return + */ +declare function nlapiStringToDate(str:string, format:string):any; + +/** + * Convert a Date object into a String + * + * @param {date} d date object being converted to a string + * @param {string} [formattype] format type to use: date|datetime|timeofday with date being the default + * @return {string} + * + * @since 2005.0 + * @param d + * @param formattype? + * @return + */ +declare function nlapiDateToString(d:any, formattype?:string):string; + +/** + * Add days to a Date object and returns a new Date + * + * @param {date} d date object used to calculate the new date + * @param {int} days the number of days to add to this date object. + * @return {date} + * + * @since 2008.1 + * @param d + * @param days + * @return + */ +declare function nlapiAddDays(d:any, days:any):any; + +/** + * Add months to a Date object and returns a new Date. + * + * @param {date} d date object used to calculate the new date + * @param {int} months the number of months to add to this date object. + * @return {date} + * + * @since 2008.1 + * @param d + * @param months + * @return + */ +declare function nlapiAddMonths(d:any, months:any):any; + +/** + * Format a number for data entry into a currency field. + * + * @param {string} str numeric string used to format for display as currency using user's locale + * @return {string} + * + * @since 2008.1 + * @param str + * @return + */ +declare function nlapiFormatCurrency(str:string):string; + +/** + * Encrypt a String using a SHA-1 hash function + * + * @param {string} s string to encrypt + * @return {string} + * + * @since 2009.2 + * @param s + * @return + */ +declare function nlapiEncrypt(s:string):string; + +/** + * Escape a String for use in an XML document. + * + * @param {string} text string to escape + * @return {string} + * + * @since 2008.1 + * @param text + * @return + */ +declare function nlapiEscapeXML(text:string):string; + +/** + * Convert a String into an XML document. Note that in Server SuiteScript XML is supported natively by the JS runtime using the e4x standard (http://en.wikipedia.org/wiki/E4X) + * This makes scripting XML simpler and more efficient + * + * @param {string} str string being parsed into an XML document + * @return {document} + * + * @since 2008.1 + * @param str + * @return + */ +declare function nlapiStringToXML(str:string):any; + +/** + * Convert an XML document into a String. Note that in Server SuiteScript XML is supported natively by the JS runtime using the e4x standard (http://en.wikipedia.org/wiki/E4X) + * This makes scripting XML data simpler and more efficient + * + * @param {document} xml document being serialized into a string + * @return {string} + * + * @since 2008.1 + * @param xml + * @return + */ +declare function nlapiXMLToString(xml:any):string; + +/** + * Validate that a given XML document conforms to a given XML schema. XML Schema Definition (XSD) is the expected schema format. + * + * @param {document} xmlDocument xml to validate + * @param {document} schemaDocument schema to enforce + * @param {string} schemaFolderId if your schema utilizes or tags which refer to sub-schemas by file name (as opposed to URL), + * provide the Internal Id of File Cabinet folder containing these sub-schemas as the schemaFolderId argument + * @throws {nlobjError} error containsing validation failure message(s) - limited to first 10 + * + * @since 2014.1 + * @param xmlDocument + * @param schemaDocument + * @param schemaFolderId + */ +declare function nlapiValidateXML(xmlDocument:any, schemaDocument:any, schemaFolderId:string):void; + +/** + * select a value from an XML node using XPath. Supports custom namespaces (nodes in default namespace can be referenced using "nlapi" as the prefix) + * + * @param {node} node node being queried + * @param {string} xpath string containing XPath expression. + * @return {string} + * + * @since 2008.2 + * @param node + * @param xpath + * @return + */ +declare function nlapiSelectValue(node:any, xpath:string):string; + +/** + * Select an array of values from an XML node using XPath. Supports custom namespaces (nodes in default namespace can be referenced using "nlapi" as the prefix) + * + * @param {node} node node being queried + * @param {string} xpath string containing XPath expression. + * @return {string[]} + * + * @since 2008.1 + * @param node + * @param xpath + */ +declare function nlapiSelectValues(node:any, xpath:string):void; + +/** + * Select a node from an XML node using XPath. Supports custom namespaces (nodes in default namespace can be referenced using "nlapi" as the prefix) + * + * @param {node} node node being queried + * @param {string} xpath string containing XPath expression. + * @return {node} + * + * @since 2008.1 + * @param node + * @param xpath + * @return + */ +declare function nlapiSelectNode(node:any, xpath:string):any; + +/** + * Select an array of nodes from an XML node using XPath. Supports custom namespaces (nodes in default namespace can be referenced using "nlapi" as the prefix) + * + * @param {node} node node being queried + * @param {string} xpath string containing XPath expression. + * @return {node[]} + * + * @since 2008.1 + * @param node + * @param xpath + */ +declare function nlapiSelectNodes(node:any, xpath:string):void; + +/** + * Calculate exchange rate between two currencies as of today or an optional effective date. + * @governance 10 units + * + * @param {string, int} fromCurrency internal ID or currency code of currency we are converting from + * @param {string, int} toCurrency internal ID or currency code of currency we are converting to + * @param {string} [date] string containing date of effective exchange rate. defaults to today + * @return {float} + * + * @since 2009.1 + * @param fromCurrency + * @param toCurrency + * @param date? + * @return + */ +declare function nlapiExchangeRate(fromCurrency:any, toCurrency:any, date?:string):any; + +/** + * Initiates a workflow on-demand and returns the workflow instance ID for the workflow-record combination. + * @governance 20 units + * + * @param {string} recordtype record type ID of the workflow base record + * @param {int} id internal ID of the base record + * @param {string, int} workflowid internal ID or script ID for the workflow definition + * @return {int} + * + * @since 2010.1 + * @param recordtype + * @param id + * @param workflowid + * @return + */ +declare function nlapiInitiateWorkflow(recordtype:string, id:any, workflowid:any):any; + +/** + * Initiates a workflow on-demand and returns the workflow instance ID for the workflow-record combination. + * @governance 20 units + * + * @param {string} recordtype record type ID of the workflow base record + * @param {string, int} id internal ID of the base record + * @param {string, int} workflowid internal ID or script ID for the workflow definition + * @return {string} + * + * @since 2014.2 + * @param recordType + * @param id + * @param workflowId + * @param parameters + * @return + */ +declare function nlapiInitiateWorkflowAsync(recordType:any, id:any, workflowId:any, parameters:any):string; + +/** + * Triggers a workflow on a record. + * @governance 20 units + * + * @param {string} recordtype record type ID of the workflow base record + * @param {int} id internal ID of the base record + * @param {string, int} workflowid internal ID or script ID for the workflow definition + * @param {string, int} actionid internal ID or script ID of the action script + * @param {string, int} stateid internal ID or script ID of the state contains the referenced add button action + * @return {int} + * + * @since 2010.1 + * @param recordtype + * @param id + * @param workflowid + * @param actionid + * @param stateid + * @return + */ +declare function nlapiTriggerWorkflow(recordtype:string, id:any, workflowid:any, actionid:any, stateid:any):any; + +/** + * Create a subrecord on a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param type + * @param fldnam + */ +declare function nlapiCreateCurrentLineSubrecord(type:string, fldnam:string):void; + +/** + * edit a subrecord on a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param type + * @param fldnam + */ +declare function nlapiEditCurrentLineItemSubrecord(type:string, fldnam:string):void; + +/** + * remove a subrecord on a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @retun {void} + * + * @since 2011.2 + * @param type + * @param fldnam + */ +declare function nlapiRemoveCurrentLineItemSubrecord(type:string, fldnam:string):void; + +/** + * view a subrecord on a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param type + * @param fldnam + */ +declare function nlapiViewCurrentLineItemSubrecord(type:string, fldnam:string):void; + +/** + * view a subrecord on a sublist field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param type + * @param fldnam + * @param linenum + */ +declare function nlapiViewLineItemSubrecord(type:string, fldnam:string, linenum:any):void; + +/** + * get a cache object. + * @param {string} name of the cache + * @return {nlobjCache} + * + * @since 2013.2 + * @param name + * @return + */ +declare function nlapiGetCache(name:string):any; + +/** + * create a subrecord on body field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam body field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param fldnam + */ +declare function createSubrecord(fldnam:string):void; + +/** + * edit a subrecord on body field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam body field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param fldnam + */ +declare function editSubrecord(fldnam:string):void; + +/** + * remove a subrecord on body field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam body field name + * @retun {void} + * + * @since 2011.2 + * @param fldnam + */ +declare function removeSubrecord(fldnam:string):void; + +/** + * view a subrecord on body field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam body field name + * @retun {nlobjSubrecord} + * + * @since 2011.2 + * @param fldnam + */ +declare function viewSubrecord(fldnam:string):void; + +/** + * Return a new instance of nlobjRecord used for accessing and manipulating record objects. + * + * @classDescription Class definition for business records in the system. + * @return {nlobjRecord} + * @constructor + * + * @since 2008.2 + */ +declare interface nlobjRecord { + + /** + * + * @return + */ + new (): any; + + /** + * Return the internalId of the record or NULL for new records. + * + * @return {int} Return the integer value of the record ID. + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @return + */ + getId(): any; + + /** + * Return the recordType corresponding to this record. + * + * @return {string} The string value of the record name internal ID + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @return + */ + getRecordType(): string; + + /** + * Return field metadata for field. + * + * @param {string} fldnam field name + * @return {nlobjField} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.1 + * @param fldnam + * @return + */ + getField(fldnam:string): () => void; + + /** + * Return sublist metadata for sublist. + * + * @param {string} type sublist name + * @return {nlobjSubList} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @return + */ + getSubList(type:string): () => void; + + /** + * Return field metadata for field. + * + * @param {string} type matrix sublist name + * @param {string} fldnam matrix field name + * @param {column} linenum matrix column (1-based) + * @return {nlobjField} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @param fldnam + * @param column + * @return + */ + getMatrixField(type:string, fldnam:string, column:any): () => void; + + /** + * Return metadata for sublist field. + * + * @param {string} type sublist name + * @param {string} fldnam sublist field name + * @param {int} [linenum] line number (1-based). If empty, the current sublist field is returned. only settable for sublists of type list + * @return {nlobjField} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @param fldnam + * @param linenum? + * @return + */ + getLineItemField(type:string, fldnam:string, linenum?:any): () => void; + + /** + * Return metadata for sublist field. + * + * @param {string} type matrix sublist name + * @param {string} fldnam matrix field name + * @param {int} linenum line number + * @param {column} linenum matrix column (1-based) + * @return {nlobjField} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @param fldnam + * @param linenum + * @param column + * @return + */ + getLineItemMatrixField(type:string, fldnam:string, linenum:any, column:any): () => void; + + /** + * Set the value of a field. + * + * @param {string} name field name + * @param {string} value field value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param name + * @param value + * @return + */ + setFieldValue(name:string, value:string): any; + + /** + * Set the values of a multi-select field. + * + * @param {string} name field name + * @param {string[]} values string array containing field values + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param name + * @param values + */ + setFieldValues(name:string, values:any): void; + + /** + * Return the value of a field. + * + * @param {string} name field name + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param name + * @return + */ + getFieldValue(name:string): string; + + /** + * Return the selected values of a multi-select field as an Array. + * + * @param {string} name field name + * @return {string[]} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param name + */ + getFieldValues(name:string): void; + + /** + * Set the value (via display value) of a select field. + * @restriction only supported for select fields + * + * @param {string} name field name + * @param {string} text field display value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param name + * @param text + * @return + */ + setFieldText(name:string, text:string): any; + + /** + * Set the values (via display values) of a multi-select field. + * @restriction only supported for multi-select fields + * + * @param {string} name field name + * @param {string[]} texts array of field display values + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param name + * @param texts + * @return + */ + setFieldTexts(name:string, texts:any): any; + + /** + * Return the display value for a select field. + * @restriction only supported for select fields + * + * @param {string} name field name + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param name + * @return + */ + getFieldText(name:string): string; + + /** + * Return the selected display values of a multi-select field as an Array. + * @restriction only supported for multi-select fields + * + * @param {string} name field name + * @return {string[]} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param name + */ + getFieldTexts(name:string): void; + + /** + * Get the value of a matrix header field. + * + * @param {string} type matrix sublist name + * @param {string} name matrix field name + * @param {int} column matrix column index (1-based) + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @param name + * @param column + * @return + */ + getMatrixValue(type:string, name:string, column:any): string; + + /** + * Set the value of a matrix header field. + * + * @param {string} type matrix sublist name + * @param {string} name matrix field name + * @param {int} column matrix column index (1-based) + * @param {string} value field value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param type + * @param name + * @param column + * @param value + * @return + */ + setMatrixValue(type:string, name:string, column:any, value:string): any; + + /** + * Return an Array of all field names on the record. + * + * @return {string[]} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + */ + getAllFields(): void; + + /** + * Return an Array of all field names on a record for a particular sublist. + * + * @param {string} group sublist name + * @return {string[]} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param group + */ + getAllLineItemFields(group:string): void; + + /** + * Set the value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line line number (1-based) + * @param {string} value sublist field value + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param group + * @param name + * @param line + * @param value + */ + setLineItemValue(group:string, name:string, line:any, value:string): void; + + /** + * Set the value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line line number (1-based) + * @param {string} datetime value + * @param {string} timezone value + * + * @method + * @memberOf nlobjRecord + * + * @since 2013.2 + * @param group + * @param name + * @param line + * @param value + * @param timezone + */ + setLineItemDateTimeValue(group:string, name:string, line:any, value:any, timezone:string): void; + + /** + * Return the value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line line number (1-based) + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.1 + * @param group + * @param name + * @param line + */ + getLineItemValue(group:string, name:string, line:any): void; + + /** + * Return the value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line line number (1-based) + * @param {string} timezone value + * + * @method + * @memberOf nlobjRecord + * + * @since 2013.2 + * @param group + * @param name + * @param line + * @param timezone + */ + getLineItemDateTimeValue(group:string, name:string, line:any, timezone:string): void; + + /** + * Return the text value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line line number (1-based) + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2008.2 + * @param group + * @param name + * @param line + * @return + */ + getLineItemText(group:string, name:string, line:any): string; + + /** + * Set the current value of a sublist field. + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {string} value sublist field value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @param value + * @return + */ + setCurrentLineItemValue(group:string, name:string, value:string): any; + + /** + * Set the current value of a sublist field. + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {string} value sublist field value + * @param {string} timezone value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2013.2 + * @param group + * @param name + * @param value + * @param timezone + * @return + */ + setCurrentLineItemDateTimeValue(group:string, name:string, value:string, timezone:string): any; + + /** + * Return the current value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @return + */ + getCurrentLineItemValue(group:string, name:string): string; + + /** + * Return the current value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {string} timezone value + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2013.2 + * @param group + * @param name + * @param timezone + * @return + */ + getCurrentLineItemDateTimeValue(group:string, name:string, timezone:string): string; + + /** + * Return the current display value of a sublist field. + * + * @param {string} group sublist name + * @param {string} name sublist field name + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @return + */ + getCurrentLineItemText(group:string, name:string): string; + + /** + * Set the current value of a sublist matrix field. + * + * @param {string} group matrix sublist name + * @param {string} name matrix field name + * @param {int} column matrix field column index (1-based) + * @param {string} value matrix field value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @param column + * @param value + * @return + */ + setCurrentLineItemMatrixValue(group:string, name:string, column:any, value:string): any; + + /** + * Return the current value of a sublist matrix field. + * + * @param {string} group matrix sublist name + * @param {string} name matrix field name + * @param {int} column matrix field column index (1-based) + * @return {string} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @param column + * @return + */ + getCurrentLineItemMatrixValue(group:string, name:string, column:any): string; + + /** + * Return the number of columns for a matrix field. + * + * @param {string} group matrix sublist name + * @param {string} name matrix field name + * @return {int} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param name + * @return + */ + getMatrixCount(group:string, name:string): any; + + /** + * Return the number of lines in a sublist. + * + * @param {string} group sublist name + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + */ + getLineItemCount(group:string): void; + + /** + * Return line number for 1st occurence of field value in a sublist column. + * + * @param {string} group sublist name + * @param {string} fldnam sublist field name + * @param {string} value sublist field value + * @return {int} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param fldnam + * @param value + * @return + */ + findLineItemValue(group:string, fldnam:string, value:string): any; + + /** + * Return line number for 1st occurence of field value in a sublist column. + * + * @param {string} group sublist name + * @param {string} fldnam sublist field name + * @param {int} column matrix column index (1-based) + * @param {string} value matrix field value + * @return {int} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param fldnam + * @param column + * @param value + * @return + */ + findLineItemMatrixValue(group:string, fldnam:string, column:any, value:string): any; + + /** + * Insert a new line into a sublist. + * + * @param {string} group sublist name + * @param {int} [line] line index at which to insert line + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param line? + */ + insertLineItem(group:string, line?:any): void; + + /** + * Remove an existing line from a sublist. + * + * @param {string} group sublist name + * @param {int} [line] line number to remove + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param line? + */ + removeLineItem(group:string, line?:any): void; + + /** + * Insert and select a new line in a sublist. + * + * @param {string} group sublist name + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @return + */ + selectNewLineItem(group:string): any; + + /** + * Select an existing line in a sublist. + * + * @param {string} group sublist name + * @param {int} line line number to select + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @param line + * @return + */ + selectLineItem(group:string, line:any): any; + + /** + * Commit the current line in a sublist. + * + * @param {string} group sublist name + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 2009.2 + * @param group + * @return + */ + commitLineItem(group:string): any; + + /** + * set the value of a field. + * + * @param {string} name field name + * @param {string} value field value + * @return {void} + * + * @method + * @memberOf nlobjRecord + * + * @since 20013.2 + * @param name + * @param value + * @param timezone + * @return + */ + setDateTimeValue(name:string, value:string, timezone:string): any; + + /** + * Return the value of a field on the current record on a page. + * @restriction supported in client and user event scripts only. + * @param {string} fldnam the field name + * @param {string} timezone Olson value + * @return {string} + * + * @since 2013.2 + * @param fldnam + * @param timezone + * @return + */ + getDateTimeValue(fldnam:string, timezone:string): string; +} + +/** + * Return a new instance of nlobjConfiguration.. + * + * @classDescription Class definition for interacting with setup/configuration pages + * @return {nlobjConfiguration} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjConfiguration { + + /** + * + * @return + */ + new (): any; + + /** + * return the type corresponding to this setup record. + * + * @return {string} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @return + */ + getType(): string; + + /** + * return field metadata for field. + * + * @param {string} fldnam field name + * @return {nlobjField} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param fldnam + * @return + */ + getField(fldnam:string): () => void; + + /** + * set the value of a field. + * + * @param {string} name field name + * @param {string} value field value + * @return {void} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @param value + * @return + */ + setFieldValue(name:string, value:string): any; + + /** + * Set the values of a multi-select field. + * @restriction only supported for multi-select fields + * + * @param {string} name field name + * @param {string[]} value field values + * @return {void} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @param value + * @return + */ + setFieldValues(name:string, value:any): any; + + /** + * return the value of a field. + * + * @param {string} name field name + * @return {string} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @return + */ + getFieldValue(name:string): string; + + /** + * return the selected values of a multi-select field as an Array. + * @restriction only supported for multi-select fields + * + * @param {string} name field name + * @return {string[]} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + */ + getFieldValues(name:string): void; + + /** + * set the value (via display value) of a field. + * @restriction only supported for select fields + * + * @param {string} name field name + * @param {string} text field display text + * @return {void} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @param text + * @return + */ + setFieldText(name:string, text:string): any; + + /** + * set the values (via display values) of a multi-select field. + * @restriction only supported for multi-select fields + * + * @param {string} name field name + * @param {string[]} texts array of field display text values + * @return {void} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @param texts + * @return + */ + setFieldTexts(name:string, texts:any): any; + + /** + * return the text value of a field. + * @restriction only supported for select fields + * + * @param {string} name field name + * @return {string} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + * @return + */ + getFieldText(name:string): string; + + /** + * return the selected text values of a multi-select field as an Array. + * @param {string} name field name + * @return {string[]} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + * @param name + */ + getFieldTexts(name:string): void; + + /** + * return an Array of all field names on the record. + * @return {string[]} + * + * @method + * @memberOf nlobjConfiguration + * + * @since 2009.2 + */ + getAllFields(): void; +} + +/** + * Return a new instance of nlobjFile used for accessing and manipulating files in the file cabinet. + * + * @classDescription Encapsulation of files (media items) in the file cabinet. + * @return {nlobjFile} + * @constructor + * + * @since 2009.1 + */ +declare interface nlobjFile { + + /** + * + * @return + */ + new (): any; + + /** + * Return the name of the file. + * @return {string} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getName(): string; + + /** + * Sets the name of a file. + * @param {string} name the name of the file + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @param name + * @return + */ + setName(name:string): any; + + /** + * return the internal ID of the folder that this file is in. + * @return {int} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getFolder(): any; + + /** + * sets the internal ID of the folder that this file is in. + * @param {int} folder + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @param folder + * @return + */ + setFolder(folder:any): any; + + /** + * sets the character encoding for the file. + * @param {String} encoding + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2010.2 + * @param encoding + * @return + */ + setEncoding(encoding:string): any; + + /** + * return true if the file is "Available without Login". + * @return {boolean} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + isOnline(): boolean; + + /** + * sets the file's "Available without Login" status. + * @param {boolean} online + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @param online + * @return + */ + setIsOnline(online:boolean): any; + + /** + * return true if the file is inactive. + * @return {boolean} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + isInactive(): boolean; + + /** + * sets the file's inactive status. + * @param {boolean} inactive + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @param inactive + * @return + */ + setIsInactive(inactive:boolean): any; + + /** + * return the file description. + * @return {string} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getDescription(): string; + + /** + * sets the file's description. + * @param {string} descr the file description + * @return {void} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @param descr + * @return + */ + setDescription(descr:string): any; + + /** + * Return the id of the file (if stored in the FC). + * @return {int} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getId(): any; + + /** + * Return the size of the file in bytes. + * @return {int} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getSize(): any; + + /** + * Return the URL of the file (if stored in the FC). + * @return {string} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getURL(): string; + + /** + * Return the type of the file. + * @return {string} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getType(): string; + + /** + * Return the value (base64 encoded for binary types) of the file. + * @return {string} + * + * @method + * @memberOf nlobjFile + * + * @since 2009.1 + * @return + */ + getValue(): string; +} + +/** + * Return a new instance of nlobjSearchFilter filter objects used to define search criteria. + * + * @classDescription search filter + * @constructor + * @param {string} name filter name. + * @param {string} join internal ID for joined search where this filter is defined + * @param {string} operator operator name (i.e. anyOf, contains, lessThan, etc..) + * @param {string|string[]} value + * @param {string} value2 + * @return {nlobjSearchFilter} + * + * @since 2007.0 + */ +declare interface nlobjSearchFilter { + + /** + * + * @param name + * @param join + * @param operator + * @param value + * @param value2 + * @return + */ + new (name:string, join:string, operator:string, value:any, value2:string): any; + + /** + * Return the name of this search filter. + * @return {string} + * + * @method + * @memberOf nlobjSearchFilter + * + * @since 2007.0 + * @return + */ + getName(): string; + + /** + * Return the join id for this search filter. + * @return {string} + * + * @method + * @memberOf nlobjSearchFilter + * + * @since 2008.1 + * @return + */ + getJoin(): string; + + /** + * Return the filter operator used. + * @return {string} + * + * @method + * @memberOf nlobjSearchFilter + * + * @since 2008.2 + * @return + */ + getOperator(): string; +} + +/** + * Return a new instance of nlobjSearchColumn used for column objects used to define search return columns. + * + * @classDescription search column. + * @return {nlobjSearchColumn} + * @constructor + * @param {string} name column name. + * @param {string} join internal ID for joined search where this column is defined + * @param {string} summary + * + * @since 2007.0 + */ +declare interface nlobjSearchColumn { + + /** + * + * @param name + * @param join + * @param summary + * @return + */ + new (name:string, join:string, summary:string): any; + + /** + * return the name of this search column. + * @return {string} + * + * @method + * @memberOf nlobjSearchColumn + * @since 2008.1 + * @return + */ + getName(): string; + + /** + * return the join id for this search column. + * @return {string} + * + * @method + * @memberOf nlobjSearchColumn + * @since 2008.1 + * @return + */ + getJoin(): string; + + /** + * return the label of this search column. + * @return {string} + * + * @method + * @memberOf nlobjSearchColumn + * + * @since 2009.1 + * @return + */ + getLabel(): string; + + /** + * return the summary type (avg,group,sum,count) of this search column. + * @return {string} + * + * @method + * @memberOf nlobjSearchColumn + * @since 2008.1 + * @return + */ + getSummary(): string; + + /** + * return formula for this search column. + * @return {string} + * + * @method + * @memberOf nlobjSearchColumn + * + * @since 2009.2 + * @return + */ + getFormula(): string; + + /** + * return nlobjSearchColumn sorted in either ascending or descending order. + * @return {nlobjSearchColumn} + * @param {boolean} sort if not set, defaults to false, which returns column data in ascending order. + * + * @method + * @memberOf nlobjSearchColumn + * + * @since 2010.1 + * @param order + * @return + */ + setSort(order:any): (name:string, join:string, summary:string) => void; +} + +/** + * Return a new instance of nlobjSearchResult used for search result row object. + * + * @classDescription Class definition for interacting with the results of a search operation + * @return {nlobjSearchResult} + * @constructor + */ +declare interface nlobjSearchResult { + + /** + * + * @return + */ + new (): any; + + /** + * return the internalId for the record returned in this row. + * @method + * @memberOf nlobjSearchResult + * @return {int} + * @return + */ + getId(): any; + + /** + * return the recordtype for the record returned in this row. + * @method + * @memberOf nlobjSearchResult + * @return {string} + * @return + */ + getRecordType(): string; + + /** + * return the value for a return column specified by name, join ID, and summary type. + * @param {string} name the name of the search column + * @param {string} join the join ID for the search column + * @param {string} summary summary type specified for this column + * @return {string} + * + * @method + * @memberOf nlobjSearchResult + * + * @since 2008.1 + * @param name + * @param join + * @param summary + * @return + */ + getValue(name:string, join:string, summary:string): string; + + /** + * return the text value of this return column if it's a select field. + * @param {string} name the name of the search column + * @param {string} join the join ID for the search column + * @param {string} summary summary type specified for this column + * @return {string} + * + * @method + * @memberOf nlobjSearchResult + * + * @since 2008.1 + * @param name + * @param join + * @param summary + * @return + */ + getText(name:string, join:string, summary:string): string; + + /** + * return an array of all nlobjSearchColumn objects returned in this search. + * @return {nlobjSearchColumn[]} + * + * @method + * @memberOf nlobjSearchResult + * + * @since 2009.2 + */ + getAllColumns(): void; +} + +/** + * Return a new instance of nlobjContext used for user and script context information. + * + * @classDescription Utility class providing information about the current user and the script runtime. + * @return {nlobjContext} + * @constructor + */ +declare interface nlobjContext { + + /** + * + * @return + */ + new (): any; + + /** + * return the name of the current user. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getName(): string; + + /** + * return the internalId of the current user. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getUser(): string; + + /** + * return the internalId of the current user's role. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getRole(): string; + + /** + * return the script ID of the current user's role. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2008.2 + * @return + */ + getRoleId(): string; + + /** + * return the internalId of the current user's center type. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2008.2 + * @return + */ + getRoleCenter(): string; + + /** + * return the email address of the current user. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getEmail(): string; + + /** + * return the internal ID of the contact logged in on behalf of a customer, vendor, or partner. It returns -1 for non-contact logins + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.1 + * @return + */ + getContact(): any; + + /** + * return the account ID of the current user. + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getCompany(): string; + + /** + * return the internalId of the current user's department. + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getDepartment(): any; + + /** + * return the internalId of the current user's location. + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getLocation(): any; + + /** + * return the internalId of the current user's subsidiary. + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getSubsidiary(): any; + + /** + * return the execution context for this script: webServices|csvImport|client|userInterface|scheduledScript|portlet|suitelet|debugger|custommassupdate + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getExecutionContext(): string; + + /** + * return the amount of usage units remaining for this script. + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2007.0 + * @return + */ + getRemainingUsage(): any; + + /** + * return true if feature is enabled, false otherwise + * @param {string} name + * @return {boolean} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param name + * @return + */ + getFeature(name:string): boolean; + + /** + * return current user's permission level (0-4) for this permission + * @param {string} name + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param name + * @return + */ + getPermission(name:string): any; + + /** + * return system or script preference selection for current user + * @param {string} name + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param name + * @return + */ + getPreference(name:string): string; + + /** + * return value of session object set by script + * @param {string} name + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param name + * @return + */ + getSessionObject(name:string): string; + + /** + * set the value of a session object using a key. + * @param {string} name + * @param {string} value + * @return {void} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param name + * @param value + * @return + */ + setSessionObject(name:string, value:string): any; + + /** + * return an array containing the names of all keys used to set session objects + * @return {string[]} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + */ + getAllSessionObjects(): void; + + /** + * return the NetSuite version for the current account + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @return + */ + getVersion(): string; + + /** + * return the environment that the script is executing in: SANDBOX, PRODUCTION, BETA, INTERNAL + * @since 2008.2 + */ + getEnvironment(): void; + + /** + * return the logging level for the current script execution. Not supported in CLIENT scripts + * @since 2008.2 + */ + getLogLevel(): void; + + /** + * return the script ID for the current script + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @return + */ + getScriptId(): string; + + /** + * return the deployment ID for the current script + * @return {string} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @return + */ + getDeploymentId(): string; + + /** + * return the % complete specified for the current scheduled script execution + * @return {int} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @return + */ + getPercentComplete(): any; + + /** + * set the % complete for the current scheduled script execution + * @param {float} ct the percentage of records completed + * @return {void} + * + * @method + * @memberOf nlobjContext + * + * @since 2009.2 + * @param pct + * @return + */ + setPercentComplete(pct:any): any; + + /** + * return a system/script setting. Types are SCRIPT, SESSION, FEATURE, PERMISSION + * + * @param {string} type + * @param {string} name + * @since 2007.0 + * @deprecated + * @param type + * @param name + */ + getSetting(type:string, name:string): void; + + /** + * set a system/script setting. Only supported type is SESSION + * + * @param {string} type + * @param {string} name + * @param {string} value + * @since 2007.0 + * @deprecated + * @param type + * @param name + * @param value + */ + setSetting(type:string, name:string, value:string): void; + + /** + * return an Object containing name/value pairs of color groups to their corresponding RGB hex color based on the currenly logged in user's color them preferences. + * @return {Object} + * + * @method + * @memberOf nlobjContext + * + * @since 2010.1 + * @return + */ + getColorPreferences(): any; + + /** + * return the runtime version of SuiteScript, could be 1.0 or 2.0 + * @return {Object} + * + * @method + * @memberOf nlobjContext + * + * @since 2014.1 + * @return + */ + getRuntimeVersion(): any; +} + +/** + * Return a new instance of nlobjError used system or user-defined error object. + * + * @classDescription Encapsulation of errors thrown during script execution. + * @return {nlobjError} + * @constructor + */ +declare interface nlobjError { + + /** + * + * @return + */ + new (): any; + + /** + * return the error db ID for this error (if it was an unhandled unexpected error). + * @return {string} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + * @return + */ + getId(): string; + + /** + * return the error code for this system or user-defined error. + * @return {string} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + * @return + */ + getCode(): string; + + /** + * return the error description for this error. + * @return {string} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + * @return + */ + getDetails(): string; + + /** + * return a stacktrace containing the location of the error. + * @return {string[]} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + */ + getStackTrace(): void; + + /** + * return the userevent script name where this error was thrown. + * @return {string} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + * @return + */ + getUserEvent(): string; + + /** + * return the internalid of the record if this error was thrown in an aftersubmit script. + * @return {int} + * + * @method + * @memberOf nlobjError + * + * @since 2008.2 + * @return + */ + getInternalId(): any; +} + +/** + * Return a new instance of nlobjServerResponse.. + * + * @classDescription Contains the results of a server response to an outbound Http(s) call. + * @return {nlobjServerResponse} + * @constructor + * + * @since 2008.1 + */ +declare interface nlobjServerResponse { + + /** + * + * @return + */ + new (): any; + + /** + * return the Content-Type header in response + * @return {string} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @return + */ + getContentType(): string; + + /** + * return the value of a header returned. + * @param {string} name the name of the header to return + * @return {string} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @param name + * @return + */ + getHeader(name:string): string; + + /** + * return all the values of a header returned. + * @param {string} name the name of the header to return + * @return {string[]} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @param name + */ + getHeaders(name:string): void; + + /** + * return an Array of all headers returned. + * @return {string[]} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + */ + getAllHeaders(): void; + + /** + * return the response code returned. + * @return {int} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @return + */ + getCode(): any; + + /** + * return the response body returned. + * @return {string} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @return + */ + getBody(): string; + + /** + * return the nlobjError thrown via a client call to nlapiRequestURL. + * @return {nlobjError} + * + * @method + * @memberOf nlobjServerResponse + * + * @since 2008.1 + * @return + */ + getError(): () => void; +} + +/** + * Return a new instance of nlobjResponse used for scripting web responses in Suitelets + * + * @classDescription Accessor to Http response made available to Suitelets. + * @return {nlobjResponse} + * @constructor + */ +declare interface nlobjResponse { + + /** + * + * @return + */ + new (): any; + + /** + * add a value for a response header. + * @param {string} name of header + * @param {string} value for header + * @return {void} + * + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param name + * @param value + * @return + */ + addHeader(name:string, value:string): any; + + /** + * set the value of a response header. + * @param {string} name of header + * @param {string} value for header + * @return {void} + * + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param name + * @param value + * @return + */ + setHeader(name:string, value:string): any; + + /** + * return the value of a response header. + * @param {string} name of header + * @return {string} + * + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @return + */ + getHeader(): string; + + /** + * return an Array of all response header values for a header + * @param {string} name of header + * @return {string[]} + * + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param name + */ + getHeaders(name:string): void; + + /** + * return an Array of all response headers + * @return {Object} + * + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @return + */ + getAllHeaders(): any; + + /** + * suppress caching for this response. + * @return {void} + * + * @method + * @memberOf nlobjResponse + * + * @since 2009.1 + * @return + */ + sendNoCache(): any; + + /** + * sets the content type for the response (and an optional filename for binary output). + * + * @param {string} type the file type i.e. plainText, word, pdf, htmldoc (see list of media item types) + * @param {string} filename the file name + * @param {string} disposition Content Disposition used for streaming attachments: inline|attachment + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param type + * @param filename + * @param disposition + * @return + */ + setContentType(type:string, filename:string, disposition:string): any; + + /** + * sets the redirect URL for the response. all URLs must be internal unless the Suitelet is being executed in an "Available without Login" context + * at which point it can use type "external" to specify an external url via the subtype arg + * + * @param {string} type type specifier for URL: suitelet|tasklink|record|mediaitem|external + * @param {string} subtype subtype specifier for URL (corresponding to type): scriptid|taskid|recordtype|mediaid|url + * @param {string} [id] internal ID specifier (sub-subtype corresponding to type): deploymentid|n/a|recordid|n/a + * @param {string} [pagemode] string specifier used to configure page (suitelet: external|internal, tasklink|record: edit|view) + * @param {Object} [parameters] Object used to specify additional URL parameters as name/value pairs + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param type + * @param subtype + * @param id? + * @param pagemode? + * @param parameters? + * @return + */ + sendRedirect(type:string, subtype:string, id?:string, pagemode?:string, parameters?:any): any; + + /** + * write information (text/xml/html) to the response. + * + * @param {string} output + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param output + * @return + */ + write(output:string): any; + + /** + * write line information (text/xml/html) to the response. + * + * @param {string} output + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param output + * @return + */ + writeLine(output:string): any; + + /** + * write a UI object page. + * + * @param {Object} pageobject page UI object: nlobjList|nlobjAssistant|nlobjForm|nlobjDashboard + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2008.2 + * @param pageobject + * @return + */ + writePage(pageobject:any): any; + + /** + * sets the character encoding for the response. + * @param {String} encoding + * @return {void} + * @method + * @memberOf nlobjResponse + * + * @since 2012.2 + * @param encoding + * @return + */ + setEncoding(encoding:string): any; +} + +/** + * Return a new instance of nlobjRequest used for scripting web requests in Suitelets + * + * @classDescription Accessor to Http request data made available to Suitelets + * @return {nlobjRequest} + * @constructor + */ +declare interface nlobjRequest { + + /** + * + * @return + */ + new (): any; + + /** + * return the value of a request parameter. + * + * @param {string} name parameter name + * @return {string} + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @param name + * @return + */ + getParameter(name:string): string; + + /** + * return the values of a request parameter as an Array. + * + * @param {string} name parameter name + * @return {string[]} + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @param name + */ + getParameterValues(name:string): void; + + /** + * return an Object containing all the request parameters and their values. + * @return {Object} + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @return + */ + getAllParameters(): any; + + /** + * return the value of a sublist value. + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line sublist line number + * @return {string} + * + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @param group + * @param name + * @param line + * @return + */ + getLineItemValue(group:string, name:string, line:any): string; + + /** + * return the number of lines in a sublist. + * @param {string} group sublist name + * @return {int} + * + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @param group + * @return + */ + getLineItemCount(group:string): any; + + /** + * return the value of a request header. + * @param {string} name + * @return {string} + * + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @param name + * @return + */ + getHeader(name:string): string; + + /** + * return an Object containing all the request headers and their values. + * @return {Object} + * + * @method + * @memberOf nlobjRequest + * + * @since 2008.2 + * @return + */ + getAllHeaders(): any; + + /** + * return the value of an uploaded file. + * @param {string} name file field name + * @return {nlobjFile} + * + * @method + * @memberOf nlobjRequest + * + * @since 2009.1 + * @param name + * @return + */ + getFile(name:string): () => void; + + /** + * return an Object containing field names to file objects for all uploaded files. + * @return {Object} + * + * @method + * @memberOf nlobjRequest + * + * @since 2009.1 + * @return + */ + getAllFiles(): any; + + /** + * return the body of the POST request + * @return {string} + * + * @method + * @memberOf nlobjRequest + * @since 2008.1 + * @return + */ + getBody(): string; + + /** + * return the URL of the request + * @return {string} + * + * @method + * @memberOf nlobjRequest + * @since 2008.1 + * @return + */ + getURL(): string; + + /** + * return the METHOD of the request + * @return {string} + * + * @method + * @memberOf nlobjRequest + * @since 2008.1 + * @return + */ + getMethod(): string; +} + +/** + * Return a new instance of nlobjPortlet used for scriptable dashboard portlet. + * + * @classDescription UI Object used for building portlets that are displayed on dashboard pages + * @return {nlobjPortlet} + * @constructor + */ +declare interface nlobjPortlet { + + /** + * + * @return + */ + new (): any; + + /** + * set the portlet title. + * + * @param {string} title + * @since 2008.2 + * @param title + */ + setTitle(title:string): void; + + /** + * set the entire contents of the HTML portlet (will be placed inside a ...). + * + * @param {string} html + * @since 2008.2 + * @param html + */ + setHtml(html:string): void; + + /** + * add a column (nlobjColumn) to this LIST portlet and return it. + * + * @param {string} name column name + * @param {string} type column type + * @param {string} label column label + * @param {string} [align] column alignment + * @since 2008.2 + * @param name + * @param type + * @param label + * @param align? + */ + addColumn(name:string, type:string, label:string, align?:string): void; + + /** + * add an Edit column (nlobjColumn) to the left of the column specified (supported on LIST portlets only). + * + * @param {nlobjColumn} column + * @param {boolean} showView should Edit|View instead of Edit link + * @param {string} [showHref] column that evaluates to T or F that determines whether to disable the edit|view link per-row. + * @return {nlobjColumn} + * + * @since 2008.2 + * @param column + * @param showView + * @param showHref? + * @return + */ + addEditColumn(column:() => void, showView:boolean, showHref?:string): () => void; + + /** + * add a row (nlobjSearchResult or Array of name-value pairs) to this LIST portlet. + * + * @param {string[]|nlobjSearchResult} row + * @since 2008.2 + * @param row + */ + addRow(row:any): void; + + /** + * add multiple rows (Array of nlobjSearchResults or name-value pair Arrays) to this LIST portlet. + * + * @param {string[][]|nlobjSearchResult[]} rows + * @since 2008.2 + * @param rows + */ + addRows(rows:any): void; + + /** + * add a field (nlobjField) to this FORM portlet and return it. + * + * @param {string} name field name + * @param {string} type field type + * @param {string} [label] field label + * @param {string, int} [source] script ID or internal ID for source list (select and multiselects only) -or- radio value for radio fields + * @return {nlobjField} + * + * @since 2008.2 + * @param name + * @param type + * @param label? + * @param source + * @return + */ + addField(name:string, type:string, label?:string, source?:any): () => void; + + /** + * add a FORM submit button to this FORM portlet. + * + * @param {string} url URL that this form portlet will POST to + * @param {string} [label] label for submit button (defaults to Save) + * @since 2008.2 + * @param url + * @param label? + */ + setSubmitButton(url:string, label?:string): void; + + /** + * add a line (containing text or simple HTML) with optional indenting and URL to this LINKS portlet. + * + * @param {string} text data to output to line + * @param {string} [url] URL if this line should be clickable (if NULL then line will not be clickable) + * @param {int} indent # of indents to insert before text + * @since 2008.2 + * @param text + * @param url? + * @param indent + */ + addLine(text:string, url?:string, indent?:any): void; +} + +/** + * Return a new instance of nlobjList used for scriptable list page. + * + * @classDescription UI Object page type used for building lists + * @return {nlobjList} + * @constructor + */ +declare interface nlobjList { + + /** + * + * @return + */ + new (): any; + + /** + * set the page title. + * + * @param {string} title + * @since 2008.2 + * @param title + */ + setTitle(title:string): void; + + /** + * set the global style for this list: grid|report|plain|normal. + * + * @param {string} style overall style used to render list + * @since 2008.2 + * @param style + */ + setStyle(style:string): void; + + /** + * set the Client SuiteScript used for this page. + * + * @param {string, int} script script ID or internal ID for global client script used to enable Client SuiteScript on page + * @since 2008.2 + * @param script + */ + setScript(script:any): void; + + /** + * add a column (nlobjColumn) to this list and return it. + * + * @param {string} name column name + * @param {string} type column type + * @param {string} label column label + * @param {string} [align] column alignment + * @return {nlobjColumn} + * + * @since 2008.2 + * @param name + * @param type + * @param label + * @param align? + * @return + */ + addColumn(name:string, type:string, label:string, align?:string): () => void; + + /** + * add an Edit column (nlobjColumn) to the left of the column specified. + * + * @param {nlobjColumn} column + * @param {boolean} showView should Edit|View instead of Edit link + * @param {string} [showHref] column that evaluates to T or F that determines whether to disable the edit|view link per-row. + * @return {nlobjColumn} + * + * @since 2008.2 + * @param column + * @param showView + * @param showHref? + * @return + */ + addEditColumn(column:() => void, showView:boolean, showHref?:string): () => void; + + /** + * add a row (Array of name-value pairs or nlobjSearchResult) to this portlet. + * + * @param {string[], nlobjSearchResult} row data used to add a single row + * @since 2008.2 + * @param row + */ + addRow(row:any): void; + + /** + * add multiple rows (Array of nlobjSearchResults or name-value pair Arrays) to this portlet. + * + * @param {string[][], nlobjSearchResult[]} rows data used to add multiple rows + * @since 2008.2 + * @param rows + */ + addRows(rows:any): void; + + /** + * add a button (nlobjButton) to the footer of this page. + * + * @param {string} name button name + * @param {string} label button label + * @param {string} script button script (function name) + * @since 2008.2 + * @param name + * @param label + * @param script + */ + addButton(name:string, label:string, script:string): void; + + /** + * add a navigation cross-link to the page. + * + * @param {string} type page link type: crosslink|breadcrumb + * @param {string} title page link title + * @param {string} url URL for page link + * @since 2008.2 + * @param type + * @param title + * @param url + */ + addPageLink(type:string, title:string, url:string): void; +} + +/** + * Return a new instance of nlobjForm used for scriptable form page. + * + * @classDescription UI Object page type used for building basic data entry forms. + * @return {nlobjForm} + * @constructor + */ +declare interface nlobjForm { + + /** + * + * @return + */ + new (): nlobjForm; + + /** + * set the page title. + * + * @param {string} title + * @since 2008.2 + * @param title + */ + setTitle(title:string): void; + + /** + * set additional title Html. INTERNAL ONLY + * + * @param {string} title + * @since 2008.2 + * @param html + */ + addTitleHtml(html:any): void; + + /** + * set the Client Script definition used for this page. + * + * @param {string, int} script script ID or internal ID for global client script used to enable Client SuiteScript on page + * @since 2008.2 + * @param script + */ + setScript(script:any): void; + + /** + * set the values for all the fields on this form. + * + * @param {Object} values Object containing field name/value pairs + * @since 2008.2 + * @param values + */ + setFieldValues(values:any): void; + + /** + * add a navigation cross-link to the page. + * + * @param {string} type page link type: crosslink|breadcrumb + * @param {string} title page link title + * @param {string} url URL for page link + * @since 2008.2 + * @param type + * @param title + * @param url + */ + addPageLink(type:string, title:string, url:string): void; + + /** + * add a button to this form. + * + * @param {string} name button name + * @param {string} label button label + * @param {string} script button script (function name) + * @return {nlobjButton} + * + * @since 2008.2 + * @param name + * @param label + * @param script + * @return + */ + addButton(name:string, label:string, script?:string): nlobjButton; + + /** + * get a button from this form by name. + * @param {string} name + * @return {nlobjButton} + * + * @method + * @memberOf nlobjForm + * + * @since 2009.2 add + * @param name + * @return + */ + getButton(name:string): nlobjButton; + + /** + * add a reset button to this form. + * + * @param {string} [label] label for this button. defaults to "Reset" + * @return {nlobjButton} + * + * @since 2008.2 + * @param label? + * @return + */ + addResetButton(label?:string): nlobjButton; + + /** + * add a submit button to this form. + * + * @param {string} [label] label for this submit button. defaults to "Save" + * @return {nlobjButton} + * + * @since 2008.2 + * @param label? + * @return + */ + addSubmitButton(label?:string): nlobjButton; + + /** + * add a tab (nlobjTab) to this form and return it. + * + * @param {string} name tab name + * @param {string} label tab label + * @return {nlobjTab} + * + * @since 2008.2 + * @param name + * @param label + * @return + */ + addTab(name:string, label:string): nlobjTab; + + /** + * add a field (nlobjField) to this form and return it. + * + * @param {string} name field name + * @param {string} type field type + * @param {string} [label] field label + * @param {string, int} [source] script ID or internal ID for source list (select and multiselects only) -or- radio value for radio fields + * @param {string} [tab] tab name that this field will live on. If empty then the field is added to the main section of the form (immediately below the title bar) + * @return {nlobjField} + * + * @since 2008.2 + * @param name + * @param type + * @param label? + * @param sourceOrRadio + * @param tab? + * @return + */ + addField(name:string, type:string, label?:string, sourceOrRadio?:any, tab?:string): nlobjField; + + /** + * + * @param name + * @param label + * @param domain + * @param scriptId + * @param value + */ + addCredentialField(name:string, label:string, website?:string, scriptId?:string, value?:string, entityMatch?:boolean, tab?:string): nlobjField; + + /** + * add a subtab (nlobjTab) to this form and return it. + * + * @param {string} name subtab name + * @param {string} label subtab label + * @param {string} [tab] parent tab that this subtab lives on. If empty, it is added to the main tab. + * @return {nlobjTab} + * + * @since 2008.2 + * @param name + * @param label + * @param tab? + * @return + */ + addSubTab(name:string, label:string, tab?:string): nlobjTab; + + /** + * add a sublist (nlobjSubList) to this form and return it. + * + * @param {string} name sublist name + * @param {string} type sublist type: inlineeditor|editor|list|staticlist + * @param {string} label sublist label + * @param {string} [tab] parent tab that this sublist lives on. If empty, it is added to the main tab + * @return {nlobjSubList} + * + * @since 2008.2 + * @param name + * @param type + * @param label + * @param tab? + * @return + */ + addSubList(name:string, type:string, label:string, tab?:string): nlobjSubList; + + /** + * insert a tab (nlobjTab) before another tab (name). + * + * @param {nlobjTab} tab the tab object to insert + * @param {string} nexttab the name of the tab before which to insert this tab + * @return {nlobjTab} + * + * @since 2008.2 + * @param tab + * @param nexttab + * @return + */ + insertTab(tab:() => void, nexttab:string): nlobjTab; + + /** + * insert a field (nlobjField) before another field (name). + * + * @param {nlobjField} field the field object to insert + * @param {string} nextfld the name of the field before which to insert this field + * @return {nlobjField} + * + * @since 2008.2 + * @param field + * @param nextfld + * @return + */ + insertField(field:() => void, nextfld:string): nlobjField; + + /** + * insert a subtab (nlobjTab) before another subtab or sublist (name). + * + * @param {nlobjTab} subtab the subtab object to insert + * @param {string} nextsubtab the name of the subtab before which to insert this subtab + * @return {nlobjTab} + * + * @since 2008.2 + * @param subtab + * @param nextsubtab + * @return + */ + insertSubTab(subtab:() => void, nextsubtab:string): nlobjTab; + + /** + * insert a sublist (nlobjSubList) before another subtab or sublist (name). + * + * @param {nlobjSubList} sublist the sublist object to insert + * @param {string} nextsublist the name of the sublist before which to insert this sublist + * @return {nlobjSubList} + * + * @since 2008.2 + * @param sublist + * @param nextsublist + * @return + */ + insertSubList(sublist:() => void, nextsublist:string): nlobjSubList; + + /** + * return a tab (nlobjTab) on this form. + * + * @param {string} name tab name + * @return {nlobjTab} + * + * @since 2008.2 + * @param name + * @return + */ + getTab(name:string): nlobjTab; + + /** + * return a field (nlobjField) on this form. + * + * @param {string} name field name + * @param {string} [radio] if this is a radio field, specify which radio field to return based on radio value + * @return {nlobjField} + * + * @since 2008.2 + * @param name + * @param radio? + * @return + */ + getField(name:string, radio?:string): nlobjField; + + /** + * return a subtab (nlobjTab) on this form. + * + * @param {string} name subtab name + * @return {nlobjTab} + * + * @since 2008.2 + * @param name + * @return + */ + getSubTab(name:string): nlobjTab; + + /** + * return a sublist (nlobjSubList) on this form. + * + * @param {string} name sublist name + * @return {nlobjSubList} + * + * @since 2008.2 + * @param name + * @return + */ + getSubList(name:string): nlobjSubList; + + /** + * add a field group to the form. + * @param {string} name field group name + * @param {string} label field group label + * @param tab + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjForm + * + * @since 2011.1 + * @param name + * @param label + * @param tab + * @return + */ + addFieldGroup(name:string, label:string, tab:any): nlobjFieldGroup; + + /** + * get a list of all tabs. + * @return an array with names of all tabs + * + * @method + * @memberOf nlobjForm + * + * @since 2012.2 + */ + getTabs(): nlobjTab[]; +} + +/** + * Return a new instance of nlobjAssistant. + * + * @classDescription UI Object page type used to build multi-step "assistant" pages to simplify complex workflows. All data and state for an assistant is tracked automatically + * throughout the user's session up until completion of the assistant. + * + * @return {nlobjAssistant} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjAssistant { + + /** + * + * @return + */ + new (): any; + + /** + * set the page title. + * @param {string} title + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param title + * @return + */ + setTitle(title:string): any; + + /** + * set the script ID for Client Script used for this form. + * @param {string, int} script script ID or internal ID for global client script used to enable Client SuiteScript on page + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param script + * @return + */ + setScript(script:any): any; + + /** + * set the splash screen used for this page. + * @param {string} title splash portlet title + * @param {string} text1 splash portlet content (left side) + * @param {string} [text2] splash portlet content (right side) + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param title + * @param text1 + * @param text2? + * @return + */ + setSplash(title:string, text1:string, text2?:string): any; + + /** + * show/hide shortcut link. Always hidden on external pages + * @param {boolean} show enable/disable "Add To Shortcut" link on this page + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param show + * @return + */ + setShortcut(show:boolean): any; + + /** + * set the values for all the fields on this page. + * @param {Object} values Object of field name/value pairs used to set all fields on page + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param values + * @return + */ + setFieldValues(values:any): any; + + /** + * if ordered, steps are show on left and must be completed sequentially, otherwise steps are shown on top and can be done in any order + * @param {boolean} ordered If true (default assistant behavior) then a navigation order thru the steps/pages will be imposed on the user. Otherwise the user + * will be allowed to navigate across steps/pages in any order they choose. + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param ordered + * @return + */ + setOrdered(ordered:boolean): any; + + /** + * if numbered, step numbers are displayed next to the step's label in the navigation area + * @param {boolean} numbered If true (default assistant behavior) step numbers will be displayed next to the step label + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param numbered + * @return + */ + setNumbered(numbered:boolean): any; + + /** + * return true if all the steps have been completed. + * @return {boolean} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + isFinished(): boolean; + + /** + * mark assistant page as completed and optionally set the rich text to display on completed page. + * @param {string} html completion message (rich text) to display on the "Finish" page + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param html + * @return + */ + setFinished(html:string): any; + + /** + * return true if the assistant has an error message to display for the current step. + * @return {boolean} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + hasError(): boolean; + + /** + * set the error message for the currrent step. + * @param {string} html error message (rich text) to display on the page to the user + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param html + * @return + */ + setError(html:string): any; + + /** + * mark a step as current. It will be highlighted accordingly when the page is displayed + * @param {nlobjAssistantStep} step assistant step object representing the current step that the user is on. + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param step + * @return + */ + setCurrentStep(step:() => void): any; + + /** + * add a step to the assistant. + * @param {string} name the name of the step + * @param {string} label label used for this step + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @param label + * @return + */ + addStep(name:string, label:string): () => void; + + /** + * add a field to this page and return it. + * @param {string} name field name + * @param {string} type field type + * @param {string} [label] field label + * @param {string, int} [source] script ID or internal ID for source list (select and multiselects only) -or- radio value for radio fields + * @param {string} [group] group name that this field will live on. If empty then the field is added to the main section of the page + * @return {nlobjField} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @param type + * @param label? + * @param source + * @param group? + * @return + */ + addField(name:string, type:string, label?:string, source?:any, group?:string): () => void; + + /** + * add a sublist to this page and return it. For now only sublists of type inlineeditor are supported + * @param {string} name sublist name + * @param {string} type sublist type (inlineeditor only for now) + * @param {string} label sublist label + * @return {nlobjSubList} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @param type + * @param label + * @return + */ + addSubList(name:string, type:string, label:string): () => void; + + /** + * add a field group to the page. + * @param {string} name field group name + * @param {string} label field group label + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @param label + * @return + */ + addFieldGroup(name:string, label:string): () => void; + + /** + * return an assistant step on this page. + * @param {string} name step name + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @return + */ + getStep(name:string): () => void; + + /** + * return a field on this page. + * @param {string} name field name + * @return {nlobjField} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @return + */ + getField(name:string): () => void; + + /** + * return a sublist on this page. + * @param {string} name sublist name + * @return {nlobjSubList} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @return + */ + getSubList(name:string): () => void; + + /** + * return a field group on this page. + * @param {string} name field group name + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param name + * @return + */ + getFieldGroup(name:string): () => void; + + /** + * return an array of all the assistant steps for this assistant. + * @return {nlobjAssistantStep[]} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + */ + getAllSteps(): void; + + /** + * return an array of the names of all fields on this page. + * @return {string[]} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + */ + getAllFields(): void; + + /** + * return an array of the names of all sublists on this page . + * @return {string[]} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + */ + getAllSubLists(): void; + + /** + * return an array of the names of all field groups on this page. + * @return {string[]} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + */ + getAllFieldGroups(): void; + + /** + * return the last submitted action by the user: next|back|cancel|finish|jump + * @return {string} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + getLastAction(): string; + + /** + * return step from which the last submitted action came from + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + getLastStep(): () => void; + + /** + * return the next logical step corresponding to the user's last submitted action. You should only call this after + * you have successfully captured all the information from the last step and are ready to move on to the next step. You + * would use the return value to set the current step prior to continuing. + * + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + getNextStep(): () => void; + + /** + * return current step set via nlobjAssistant.setCurrentStep(step) + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + getCurrentStep(): () => void; + + /** + * return the total number of steps in the assistant + * @return {int} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @return + */ + getStepCount(): any; + + /** + * redirect the user following a user submit operation. Use this to automatically redirect the user to the next logical step. + * @param {nlobjResponse} response the response object used to communicate back to the user's client + * @return {void} + * + * @method + * @memberOf nlobjAssistant + * + * @since 2009.2 + * @param response + * @return + */ + sendRedirect(response:() => void): any; +} + +/** + * Return a new instance of nlobjField used for scriptable form/sublist field. + * This object is READ-ONLY except for scripted fields created via the UI Object API using Suitelets or beforeLoad user events + * + * @classDescription Core descriptor for fields used to define records and also used to build pages and portlets. + * @return {nlobjField} + * @constructor + */ +declare interface nlobjField { + + /** + * + * @return + */ + new (): /* nlobjField */ any; + + /** + * return field name. + * @return {string} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + getName(): string; + + /** + * return field label. + * @return {string} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + getLabel(): string; + + /** + * return field type. + * @return {string} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + getType(): string; + + /** + * return true if field is hidden. + * @return {boolean} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + isHidden(): boolean; + + /** + * return true if field is mandatory. + * @return {boolean} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + isMandatory(): boolean; + + /** + * return true if field is disabled. + * @return {boolean} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @return + */ + isDisabled(): boolean; + + /** + * set the label for this field. + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} label + * @return {nlobjField} + * + * @since 2008.2 + * @param label + * @return + */ + setLabel(label:string): () => void; + + /** + * set the alias used to set the value for this field. Defaults to field name. + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} alias column used to populate the field (mostly relevant when populating sublist fields) + * @return {nlobjField} + * + * @since 2008.2 + * @param alias + * @return + */ + setAlias(alias:string): () => void; + + /** + * set the default value for this field. + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} value + * @return {nlobjField} + * + * @since 2008.2 + * @param value + * @return + */ + setDefaultValue(value:string): () => void; + + /** + * Disable field via field metadata. + * This method is only supported on scripted fields via the UI Object API + * @param {boolean} disabled if true then field should be disabled. + * @return {nlobjField} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @param disabled + * @return + */ + setDisabled(disabled:boolean): () => void; + + /** + * make this field mandatory. + * This method is only supported on scripted fields via the UI Object API + * + * @param {boolean} mandatory if true then field becomes mandatory + * @return {nlobjField} + * + * @since 2008.2 + * @param mandatory + * @return + */ + setMandatory(mandatory:boolean): () => void; + + /** + * set the maxlength for this field (only valid for certain field types). + * This method is only supported on scripted fields via the UI Object API + * + * @param {int} maxlength maximum length for this field + * @return {nlobjField} + * + * @since 2008.2 + * @param maxlength + * @return + */ + setMaxLength(maxlength:any): () => void; + + /** + * set the display type for this field. + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} type display type: inline|normal|hidden|disabled|readonly|entry + * @return {nlobjField} + * + * @since 2008.2 + * @param type + * @return + */ + setDisplayType(type:string): () => void; + + /** + * set the break type (startcol|startrow|none) for this field. startrow is only used for fields with a layout type of outside + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} breaktype break type used to add a break in flow layout for this field: startcol|startrow|none + * @return {nlobjField} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @param breaktype + * @return + */ + setBreakType(breaktype:string): () => void; + + /** + * set the layout type and optionally the break type. + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} type layout type: outside|startrow|midrow|endrow|normal + * @param {string} [breaktype] break type: startcol|startrow|none + * @return {nlobjField} + * + * @since 2008.2 + * @param type + * @param breaktype? + * @return + */ + setLayoutType(type:string, breaktype?:string): () => void; + + /** + * set the text that gets displayed in lieu of the field value for URL fields. + * + * @param {string} text user-friendly display value in lieu of URL + * @return {nlobjField} + * + * @since 2008.2 + * @param text + * @return + */ + setLinkText(text:string): () => void; + + /** + * set the width and height for this field. + * This method is only supported on scripted fields via the UI Object API + * + * @param {int} width + * @param {int} height + * @return {nlobjField} + * + * @since 2008.2 + * @param width + * @param height + * @return + */ + setDisplaySize(width:any, height:any): () => void; + + /** + * set the amount of emppty vertical space (rows) between this field and the previous field. + * This method is only supported on scripted fields via the UI Object API + * + * @param {int} padding # of empty rows to display above field + * @return {nlobjField} + * + * @since 2008.2 + * @param padding + * @return + */ + setPadding(padding:any): () => void; + + /** + * set help text for this field. If inline is set on assistant pages, help is displayed inline below field + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} help field level help content (rich text) for field + * @param {string} [inline] if true then in addition to the popup field help, the help will also be displayed inline below field (supported on assistant pages only) + * @return {nlobjField} + * + * @method + * @memberOf nlobjField + * + * @since 2009.2 + * @param help + * @param inline? + * @return + */ + setHelpText(help:string, inline?:string): () => void; + + /** + * add a select option to this field (valid for select/multiselect fields). + * This method is only supported on scripted fields via the UI Object API + * + * @param {string} value internal ID for this select option + * @param {string} text display value for this select option + * @param {boolean} [selected] if true then this select option will be selected by default + * @since 2008.2 + * @param value + * @param text + * @param selected? + */ + addSelectOption(value:string, text:string, selected?:boolean): void; +} + +/** + * Return a new instance of nlobjSubList used for scriptable sublist (sublist). + * This object is READ-ONLY except for instances created via the UI Object API using Suitelets or beforeLoad user events. + * + * @classDescription high level container for defining sublist (many to one) relationships on a record or multi-line data entry UIs on pages. + * @return {nlobjSubList} + * @constructor + */ +declare interface nlobjSubList { + + /** + * + * @return + */ + new (): /* nlobjSubList */ any; + + /** + * set the label for this sublist. + * This method is only supported on sublists via the UI Object API + * + * @param {string} label + * @since 2008.2 + * @param label + */ + setLabel(label:string): void; + + /** + * set helper text for this sublist. + * This method is only supported on sublists via the UI Object API + * + * @param {string} help + * @since 2008.2 + * @param help + */ + setHelpText(help:string): void; + + /** + * set the displaytype for this sublist: hidden|normal. + * This method is only supported on scripted or staticlist sublists via the UI Object API + * + * @param {string} type + * @since 2008.2 + * @param type + */ + setDisplayType(type:string): void; + + /** + * set the value of a cell in this sublist. + * + * @param {string} field sublist field name + * @param {int} line line number (1-based) + * @param {string} value sublist value + * + * @method + * @memberOf nlobjSubList + * + * @since 2008.2 + * @param field + * @param line + * @param value + */ + setLineItemValue(field:string, line:any, value:string): void; + + /** + * set the value of a matrix cell in this sublist. + * @param {string} field matrix field name + * @param {int} line line number (1-based) + * @param {int} column matrix column index (1-based) + * @param {string} value matrix field value + * @return {void} + * + * @method + * @memberOf nlobjSubList + * + * @since 2009.2 + * @param field + * @param line + * @param column + * @param value + * @return + */ + setLineItemMatrixValue(field:string, line:any, column:any, value:string): any; + + /** + * set values for multiple lines (Array of nlobjSearchResults or name-value pair Arrays) in this sublist. + * Note that this method is only supported on scripted sublists via the UI Object API + * + * @param {string[][], nlobjSearchResult[]} values + * @since 2008.2 + * @param values + */ + setLineItemValues(values:any): void; + + /** + * Return the number of lines in a sublist. + * + * @param {string} group sublist name + * + * @method + * @memberOf nlobjSubList + * @since 2010.1 + * @param group + */ + getLineItemCount(group:string): void; + + /** + * add a field (column) to this sublist. + * + * @param {string} name field name + * @param {string} type field type + * @param {string} label field label + * @param {string, int} [source] script ID or internal ID for source list used for this select field + * @return {nlobjField} + * + * @method + * @memberOf nlobjSubList + * + * @since 2008.2 + * @param name + * @param type + * @param label + * @param source + * @return + */ + addField(name:string, type:string, label:string, source:any): () => void; + + /** + * designate a field on sublist that must be unique across all lines (only supported on sublists of type inlineeditor, editor). + * @param {string} fldnam the name of a field on this sublist whose value must be unique across all lines + * @return {nlobjField} + * + * @method + * @memberOf nlobjSubList + * + * @since 2009.2 + * @param fldnam + * @return + */ + setUniqueField(fldnam:string): () => void; + + /** + * add a button to this sublist. + * + * @param {string} name button name + * @param {string} label button label + * @param {string} script button script (function name) + * @return {nlobjButton} + * + * @method + * @memberOf nlobjSubList + * + * @since 2008.2 + * @param name + * @param label + * @param script + * @return + */ + addButton(name:string, label:string, script:string): () => void; + + /** + * add "Refresh" button to sublists of type "staticlist" to support manual refreshing of the sublist (without entire page reloads) if it's contents are very volatile + * @return {nlobjButton} + * + * @method + * @memberOf nlobjSubList + * + * @since 2009.2 + * @return + */ + addRefreshButton(): () => void; + + /** + * add "Mark All" and "Unmark All" buttons to this sublist of type "list". + * + * @method + * @memberOf nlobjSubList + * + * @since 2008.2 + */ + addMarkAllButtons(): void; +} + +/** + * Return a new instance of nlobjColumn used for scriptable list column. + * + * @classDescription Class definition for columns used on lists and list portlets. + * @return {nlobjColumn} + * @constructor + */ +declare interface nlobjColumn { + + /** + * + * @return + */ + new (): /* nlobjColumn */ any; + + /** + * set the header name for this column. + * + * @param {string} label the label for this column + * + * @method + * @memberOf nlobjColumn + * + * @since 2008.2 + * @param label + */ + setLabel(label:string): void; + + /** + * set the base URL (optionally defined per row) for this column. + * + * @param {string} value the base URL or a column in the datasource that returns the base URL for each row + * @param {boolean} perRow if true then the 1st arg is expected to be a column in the datasource + * + * @method + * @memberOf nlobjColumn + * + * @since 2008.2 + * @param value + * @param perRow + */ + setURL(value:string, perRow:boolean): void; + + /** + * add a URL parameter (optionally defined per row) to this column's URL. + * + * @param {string} param the name of a parameter to add to URL + * @param {string} value the value of the parameter to add to URL -or- a column in the datasource that returns the parameter value for each row + * @param {boolean} [perRow] if true then the 2nd arg is expected to be a column in the datasource + * + * @method + * @memberOf nlobjColumn + * + * @since 2008.2 + * @param param + * @param value + * @param perRow? + */ + addParamToURL(param:string, value:string, perRow?:boolean): void; +} + +/** + * Return a new instance of nlobjTab used for scriptable tab or subtab. + * + * @classDescription high level grouping for fields on a data entry form (nlobjForm). + * @return {nlobjTab} + * @constructor + */ +declare interface nlobjTab { + + /** + * + * @return + */ + new (): /* nlobjTab */ any; + + /** + * set the label for this tab or subtab. + * + * @param {string} label string used as label for this tab or subtab + * @return {nlobjTab} + * + * @since 2008.2 + * @param label + * @return + */ + setLabel(label:string): () => void; + + /** + * set helper text for this tab or subtab. + * + * @param {string} help inline help text used for this tab or subtab + * @return {nlobjTab} + * + * @since 2008.2 + * @param help + * @return + */ + setHelpText(help:string): () => void; +} + +/** + * Return a new instance of nlobjAssistantStep. + * + * @classDescription assistant step definition. Used to define individual steps/pages in multi-step workflows. + * @return {nlobjAssistantStep} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjAssistantStep { + + /** + * + * @return + */ + new (): /* nlobjAssistantStep */ any; + + /** + * set the label for this assistant step. + * @param {string} label display label used for this assistant step + * @return {void} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param label + * @return + */ + setLabel(label:string): any; + + /** + * set helper text for this assistant step. + * @param {string} help inline help text to display on assistant page for this step + * @return {nlobjAssistantStep} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param help + * @return + */ + setHelpText(help:string): () => void; + + /** + * return the index of this step in the assistant page (1-based) + * @return {int} the index of this step in the assistant (1-based) based on the order in which the steps were added. + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @return + */ + getStepNumber(): any; + + /** + * return the value of a field entered by the user during this step. + * @param {string} name field name + * @return {string} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param name + * @return + */ + getFieldValue(name:string): string; + + /** + * return the selected values of a multi-select field as an Array entered by the user during this step. + * @param {string} name multi-select field name + * @return {string[]} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param name + */ + getFieldValues(name:string): void; + + /** + * return the number of lines previously entered by the user in this step (or -1 if the sublist does not exist). + * @param {string} group sublist name + * @return {int} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param group + * @return + */ + getLineItemCount(group:string): any; + + /** + * return the value of a sublist field entered by the user during this step. + * @param {string} group sublist name + * @param {string} name sublist field name + * @param {int} line sublist (1-based) + * @return {string} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param group + * @param name + * @param line + * @return + */ + getLineItemValue(group:string, name:string, line:any): string; + + /** + * return an array of the names of all fields entered by the user during this step. + * @return {string[]} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + */ + getAllFields(): void; + + /** + * return an array of the names of all sublists entered by the user during this step. + * @return {string[]} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + */ + getAllLineItems(): void; + + /** + * return an array of the names of all sublist fields entered by the user during this step + * @param {string} group sublist name + * @return {string[]} + * + * @method + * @memberOf nlobjAssistantStep + * + * @since 2009.2 + * @param group + */ + getAllLineItemFields(group:string): void; +} + +/** + * Return a new instance of nlobjFieldGroup (currently only supported on nlobjAssistant pages) + * + * @classDescription object used for grouping fields on pages (currently only supported on assistant pages). + * @return {nlobjFieldGroup} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjFieldGroup { + + /** + * + * @return + */ + new (): /* nlobjFieldGroup */ any; + + /** + * set the label for this field group. + * @param {string} label display label for field group + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjFieldGroup + * + * @since 2009.2 + * @param label + * @return + */ + setLabel(label:string): () => void; + + /** + * set collapsibility property for this field group. + * + * @param {boolean} collapsible if true then this field group is collapsible + * @param {boolean} [defaultcollapsed] if true and the field group is collapsible, collapse this field group by default + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjFieldGroup + * + * @since 2009.2 + * @param collapsible + * @param defaultcollapsed? + * @return + */ + setCollapsible(collapsible:boolean, defaultcollapsed?:boolean): () => void; + + /** + * set singleColumn property for this field group. + * + * @param {boolean} singleColumn if true then this field group is displayed in single column + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjFieldGroup + * + * @since 2011.1 + * @param singleColumn + * @return + */ + setSingleColumn(singleColumn:boolean): () => void; + + /** + * set showBorder property for this field group. + * + * @param {boolean} showBorder if true then this field group shows border including label of group + * @return {nlobjFieldGroup} + * + * @method + * @memberOf nlobjFieldGroup + * + * @since 2011.1 + * @param showBorder + * @return + */ + setShowBorder(showBorder:boolean): () => void; +} + +/** + * Return a new instance of nlobjButton. + * + * @classDescription buttons used for triggering custom behaviors on pages. + * @return {nlobjButton} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjButton { + + /** + * + * @return + */ + new (): nlobjButton; + + /** + * set the label for this button. + * @param {string} label display label for button + * @return {nlobjButton} + * + * @method + * @memberOf nlobjButton + * + * @since 2008.2 + * @param label + * @return + */ + setLabel(label:string): nlobjButton; + + /** + * disable or enable button. + * @param {boolean} disabled if true then this button should be disabled on the page + * @return {nlobjButton} + * + * @method + * @memberOf nlobjButton + * + * @since 2008.2 + * @param disabled + * @return + */ + setDisabled(disabled:boolean): nlobjButton; + + setVisible(visible:boolean): nlobjButton; +} + +/** + * Return a new instance of nlobjSelectOption. + * + * @classDescription select|radio option used for building select fields via the UI Object API and for describing select|radio fields. + * @return {nlobjSelectOption} + * @constructor + * + * @since 2009.2 + */ +declare interface nlobjSelectOption { + + /** + * + * @return + */ + new (): any; + + /** + * return internal ID for select option + * @return {string} + * + * @method + * @memberOf nlobjSelectOption + * + * @since 2009.2 + * @return + */ + getId(): string; + + /** + * return display value for select option. + * @return {string} + * + * @method + * @memberOf nlobjSelectOption + * + * @since 2009.2 + * @return + */ + getText(): string; +} + +/** + * @return nlobjLogin + * + * @since 2012.2 + */ +declare function nlapiGetLogin():void; + +/** + * @param {string} Job Type + * @return {nlobjJobManager} + * + * @since 2013.1 + * @param jobType + * @return + */ +declare function nlapiGetJobManager(jobType:any):any; From e7df72296ea2a55f57ece35e28bb930ae93b19b5 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 7 Jan 2016 22:23:43 -0500 Subject: [PATCH 0044/1850] Add redux-promise-middleware --- .../redux-promise-middleware-tests.ts | 46 +++++++++++++++++++ .../redux-promise-middleware.d.ts | 12 +++++ 2 files changed, 58 insertions(+) create mode 100644 redux-promise-middleware/redux-promise-middleware-tests.ts create mode 100644 redux-promise-middleware/redux-promise-middleware.d.ts diff --git a/redux-promise-middleware/redux-promise-middleware-tests.ts b/redux-promise-middleware/redux-promise-middleware-tests.ts new file mode 100644 index 0000000000..ef7e7d82de --- /dev/null +++ b/redux-promise-middleware/redux-promise-middleware-tests.ts @@ -0,0 +1,46 @@ +/// +/// + +import { createStore, applyMiddleware, Store, Dispatch } from "redux"; +import promiseMiddleware from "redux-promise-middleware"; + +declare var rootReducer: Function; +declare var Promise: any; +declare var doSomethingAsyncAndReturnPromise: any; +declare var someActionCreator: any; + +const createStoreWithMiddleware = applyMiddleware( + promiseMiddleware() +)(createStore); + +const store: Store = createStoreWithMiddleware(rootReducer); + +export function myAsyncActionCreator(data: any) { + return { + type: "ACTION", + payload: { + promise: doSomethingAsyncAndReturnPromise(data), + data: data + } + }; +} + +const actionCreator1 = () => ({ + type: "FIRST_ACTION_TYPE", + payload: { + promise: Promise.resolve({ + type: "SECOND_ACTION_TYPE", + payload: "...", + }) + } +}); + +const actionCreator2 = () => ({ + type: "FIRST_ACTION_TYPE", + payload: { + promise: Promise.resolve((action: string, dispatch: Redux.Dispatch, getState: Function) => { + dispatch({ type: "SECEOND_ACTION_TYPE", payload: "..." }); + dispatch(someActionCreator()); + }) + } +}); diff --git a/redux-promise-middleware/redux-promise-middleware.d.ts b/redux-promise-middleware/redux-promise-middleware.d.ts new file mode 100644 index 0000000000..e1350cde0e --- /dev/null +++ b/redux-promise-middleware/redux-promise-middleware.d.ts @@ -0,0 +1,12 @@ +// Type definitions for redux-promise-middleware +// Project: https://github.com/pburtchaell/redux-promise-middleware +// Definitions by: ianks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "redux-promise-middleware" { + function promiseMiddleware(config?: { promiseTypeSuffixes: string[] }): Redux.Middleware; + + export default promiseMiddleware; +} From de8574d395843d0581c09b17e30046abf32354cb Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 19 Jan 2016 10:52:33 +0100 Subject: [PATCH 0045/1850] removed the KeyBinding constructor --- ace/ace.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/ace/ace.d.ts b/ace/ace.d.ts index 8fed295f20..b7ce4ebaa8 100644 --- a/ace/ace.d.ts +++ b/ace/ace.d.ts @@ -77,9 +77,6 @@ declare module AceAjax { onTextInput(text: any): void; } - var KeyBinding: { - new(editor: Editor): KeyBinding; - } export interface TextMode { From b4a6b1adbcb8fda098848a985931f4d5481484f5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Thu, 21 Jan 2016 21:59:19 +0100 Subject: [PATCH 0046/1850] feat(monk): add monk 1.0.1 definitions --- monk/monk.d.ts | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 monk/monk.d.ts diff --git a/monk/monk.d.ts b/monk/monk.d.ts new file mode 100644 index 0000000000..1a467fc6af --- /dev/null +++ b/monk/monk.d.ts @@ -0,0 +1,69 @@ +// Type definitions for Monk v1.0.1 +// Project: http://github.com/LearnBoost/monk.git +// Definitions by: Patrick Bartsch +// Definitions: https://github.com/DefinitelyTyped/Monk + +declare module "monk" { + function m(database: string): m.Monk; + module m { + export interface promise { + type:string + on(eventName:string, fn:Function):void; + error(fn:Function):promise; + success(fn:Function):promise; + } + + export interface Collection { + id(hexstring:string):string // returns ObjectId + id(obj:Object):string // returns ObjectId + id():string // returns new generated ObjectId + + /* + * All commands accept the simple data[, …], options and a callback. + * You can pass fields to select as an array: data[, …], ['field', …], fn + * You can pass fields as a string delimited by spaces: data[, …], 'field1 field2', fn + * To exclude a field, prefix the field name with '-': data[, …], '-field1', fn + */ + cast(obj?:Object):Object; + + count(needle:Object, fn?:Function):promise; + + distinct(field:string, options?:Object, fn?:Function):promise; + + drop(fn?:Function):promise; + + insert(data:Object, options?:Object, fn?:Function):promise; + + find(needle:Object, options?:Object, fn?:Function):promise; + findOne(needle:Object, options?:Object, fn?:Function):promise; + /** + * findAndModify + * + * @param {Object} search query, or { query, update } object + * @param {Object} optional, update object + * @param {Object|String|Array} optional, options or fields + * @param {Function} callback + * @return {Promise} + * @api public + */ + findAndModify(needle:Object, update?:Object, filter?:string[], options?:Object, fn?:Function):promise; + findById(id:string, options?:Object, fn?:Function):promise; + + update(needle:Object, update:Object, filter?:string[], options?:Object, fn?:Function):promise; + updateById(id:string, update:Object, filter?:string[], options?:Object, fn?:Function):promise; + + remove(needle:Object, options?:Object, fn?:Function):promise; + removeById(id:string, options?:Object, fn?:Function):promise; + + } + + export interface Monk { + (database: string): void; + close():void; + + get(collection:string):Collection; + } + } + + export = m; +} From d95cc8609acf50dac01261316fa3e82a47113679 Mon Sep 17 00:00:00 2001 From: Dan Chao Date: Sun, 24 Jan 2016 09:33:08 -0800 Subject: [PATCH 0047/1850] add `on` func for Editor --- ace/ace.d.ts | 2 ++ ace/tests/ace-default-tests.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/ace/ace.d.ts b/ace/ace.d.ts index 8fed295f20..f1b4b69e1d 100644 --- a/ace/ace.d.ts +++ b/ace/ace.d.ts @@ -1037,6 +1037,8 @@ declare module AceAjax { **/ export interface Editor { + on(ev: string, callback: (e: any) => any): void; + addEventListener(ev: 'change', callback: (ev: EditorChangeEvent) => any): void; addEventListener(ev: string, callback: Function): void; diff --git a/ace/tests/ace-default-tests.ts b/ace/tests/ace-default-tests.ts index f8a280c1a2..798550dec9 100644 --- a/ace/tests/ace-default-tests.ts +++ b/ace/tests/ace-default-tests.ts @@ -5,6 +5,9 @@ var editor = ace.edit("editor"); editor.setTheme("ace/theme/monokai"); editor.getSession().setMode("ace/mode/javascript"); +editor.on("blur", (e) => e); +editor.on("change", (e) => e); + editor.setTheme("ace/theme/twilight"); editor.getSession().setMode("ace/mode/javascript"); From d5faebe532cac24ff670443999777f14c29587d7 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 3 Feb 2016 09:32:36 +0100 Subject: [PATCH 0048/1850] React slick definition type --- react-slick/react-slick-test.tsx | 31 ++++++++++++++++++++++ react-slick/react-slick.d.ts | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 react-slick/react-slick-test.tsx create mode 100644 react-slick/react-slick.d.ts diff --git a/react-slick/react-slick-test.tsx b/react-slick/react-slick-test.tsx new file mode 100644 index 0000000000..c351419401 --- /dev/null +++ b/react-slick/react-slick-test.tsx @@ -0,0 +1,31 @@ +/// +/// +/// + +import * as React from "react" +import * as ReactDOM from "react-dom" +import * as Slider from "react-slick" + +class SliderTest extends React.Component, {}> { + + render() { + let settings = { + speed: 500, + slidesToShow: 8, + slidesToScroll: 1, + draggable: false, + infinite: false + }; + + return ( +
+ +

Slide1

+

Slide2

+
+
+ ) + } +} + +ReactDOM.render(, document.body); diff --git a/react-slick/react-slick.d.ts b/react-slick/react-slick.d.ts new file mode 100644 index 0000000000..222089b537 --- /dev/null +++ b/react-slick/react-slick.d.ts @@ -0,0 +1,45 @@ +/// + +declare module 'react-slick' { + interface __config { + className?: string + adaptiveHeight?: boolean + arrows?: boolean + autoplay?: boolean + autoplaySpeed?: number // integer + centerMode?: boolean + centerPadding?: string | any + cssEase?: string | any + dots?: boolean + dotsClass?: string + draggable?: boolean + easing?: string + fade?: boolean + focusOnSelect?: boolean + infinite?: boolean // should the gallery wrap around it's contents + initialSlide?: number // int + lazyLoad?: boolean + rtl?: boolean + slide?: string + slidesToShow?: number // int + slidesToScroll?: number // int + speed?: number //int + swipe?: boolean + swipeToSlide?: boolean + touchMove?: boolean + touchThreshold?: number // int + variableWidth?: boolean + useCSS?: boolean + vertical?: boolean + afterChange?: (() => void) + beforeChange?: (() => void) + slickGoTo?: number // int + } + + interface Slider extends __config { + responsive?: { breakpoint: number; settings: __config}[] + } + + var Slider: __React.ClassicComponentClass; + export = Slider; +} From 65ed470927fc807ffcfd29d726dfda6f4f79b549 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 3 Feb 2016 09:47:43 +0100 Subject: [PATCH 0049/1850] React slick definition type --- react-slick/react-slick.d.ts | 78 ++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/react-slick/react-slick.d.ts b/react-slick/react-slick.d.ts index 222089b537..090037bc52 100644 --- a/react-slick/react-slick.d.ts +++ b/react-slick/react-slick.d.ts @@ -1,45 +1,45 @@ -/// +/// -declare module 'react-slick' { - interface __config { - className?: string - adaptiveHeight?: boolean - arrows?: boolean - autoplay?: boolean - autoplaySpeed?: number // integer - centerMode?: boolean - centerPadding?: string | any - cssEase?: string | any - dots?: boolean - dotsClass?: string - draggable?: boolean - easing?: string - fade?: boolean - focusOnSelect?: boolean - infinite?: boolean // should the gallery wrap around it's contents - initialSlide?: number // int - lazyLoad?: boolean - rtl?: boolean - slide?: string - slidesToShow?: number // int - slidesToScroll?: number // int - speed?: number //int - swipe?: boolean - swipeToSlide?: boolean - touchMove?: boolean - touchThreshold?: number // int - variableWidth?: boolean - useCSS?: boolean - vertical?: boolean - afterChange?: (() => void) - beforeChange?: (() => void) - slickGoTo?: number // int - } +interface __config { + className?: string + adaptiveHeight?: boolean + arrows?: boolean + autoplay?: boolean + autoplaySpeed?: number // integer + centerMode?: boolean + centerPadding?: string | any + cssEase?: string | any + dots?: boolean + dotsClass?: string + draggable?: boolean + easing?: string + fade?: boolean + focusOnSelect?: boolean + infinite?: boolean // should the gallery wrap around it's contents + initialSlide?: number // int + lazyLoad?: boolean + rtl?: boolean + slide?: string + slidesToShow?: number // int + slidesToScroll?: number // int + speed?: number //int + swipe?: boolean + swipeToSlide?: boolean + touchMove?: boolean + touchThreshold?: number // int + variableWidth?: boolean + useCSS?: boolean + vertical?: boolean + afterChange?: (() => void) + beforeChange?: (() => void) + slickGoTo?: number // int +} - interface Slider extends __config { - responsive?: { breakpoint: number; settings: __config}[] - } +interface Slider extends __config { + responsive?: { breakpoint: number; settings: __config}[] +} +declare module "react-slick" { var Slider: __React.ClassicComponentClass; export = Slider; } From 04faa1e002ed6996f20ebf9cb319d35f7f45de1e Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 3 Feb 2016 10:01:59 +0100 Subject: [PATCH 0050/1850] React slick definition type --- react-slick/react-slick.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/react-slick/react-slick.d.ts b/react-slick/react-slick.d.ts index 090037bc52..2dfadcf133 100644 --- a/react-slick/react-slick.d.ts +++ b/react-slick/react-slick.d.ts @@ -1,3 +1,8 @@ +// Type definitions for [react-slick] +// Project: [https://github.com/akiran/react-slick] +// Definitions by: [Andrey Balokha] <[https://github.com/andrewBalekha]> +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + /// interface __config { From 85ae5b9531449b4c878ec30aaea122f6572d6784 Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 3 Feb 2016 10:05:04 +0100 Subject: [PATCH 0051/1850] React slick definition type --- react-slick/react-slick.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/react-slick/react-slick.d.ts b/react-slick/react-slick.d.ts index 2dfadcf133..43c9cdcf69 100644 --- a/react-slick/react-slick.d.ts +++ b/react-slick/react-slick.d.ts @@ -1,6 +1,6 @@ -// Type definitions for [react-slick] -// Project: [https://github.com/akiran/react-slick] -// Definitions by: [Andrey Balokha] <[https://github.com/andrewBalekha]> +// Type definitions for react-slick +// Project: https://github.com/akiran/react-slick +// Definitions by: Andrey Balokha // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 4674eac751cb6820363959532a60f1c420c6a159 Mon Sep 17 00:00:00 2001 From: "jeff.noble" Date: Wed, 3 Feb 2016 10:40:14 -0500 Subject: [PATCH 0052/1850] The casing for the bodyType is different than what comes back from getTypeAsync(). --- office-js/office-js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/office-js/office-js.d.ts b/office-js/office-js.d.ts index e82e78fb3f..41acf23619 100644 --- a/office-js/office-js.d.ts +++ b/office-js/office-js.d.ts @@ -4689,7 +4689,7 @@ declare module Office.MailboxEnums { /** * The body is in HTML format */ - HTML, + Html, /** * The body is in text format */ From 824761509fb46114aa55036829452941f135a543 Mon Sep 17 00:00:00 2001 From: Damiano Date: Fri, 12 Feb 2016 23:27:38 +0100 Subject: [PATCH 0053/1850] Missing "require" property on IComponentOptions Added missing require property on IComponentOptions --- angularjs/angular.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 67b3eb488d..59645137d7 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1706,6 +1706,10 @@ declare module angular { * $attrs - Current attributes object for the element */ templateUrl?: string | Function; + /** + * Define object mapping to other directive or component required controllers. + */ + require?: any; /** * Define DOM attribute binding to component properties. Component properties are always bound to the component * controller and not to the scope. From f9d6506b938c33ab9cb2b9618ab41c4fa8f7b694 Mon Sep 17 00:00:00 2001 From: "Andrew V. Sparrow" Date: Sat, 13 Feb 2016 11:07:50 +0600 Subject: [PATCH 0054/1850] Sockjs should extends WebSocket --- sockjs/sockjs.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sockjs/sockjs.d.ts b/sockjs/sockjs.d.ts index e9569ba22c..ae6819f520 100644 --- a/sockjs/sockjs.d.ts +++ b/sockjs/sockjs.d.ts @@ -8,19 +8,19 @@ interface SockJSSimpleEvent { toString(): string; } -interface SJSOpenEvent extends SockJSSimpleEvent {} +interface SJSOpenEvent extends SockJSSimpleEvent, Event {} -interface SJSCloseEvent extends SockJSSimpleEvent { +interface SJSCloseEvent extends SockJSSimpleEvent, CloseEvent { code: number; reason: string; wasClean: boolean; } -interface SJSMessageEvent extends SockJSSimpleEvent { +interface SJSMessageEvent extends SockJSSimpleEvent, MessageEvent { data: string; } -interface SockJS extends EventTarget { +interface SockJS extends WebSocket { protocol: string; readyState: number; onopen: (ev: SJSOpenEvent) => any; @@ -49,4 +49,4 @@ declare var SockJS: { null_origin?: boolean; }; }): SockJS; -}; \ No newline at end of file +}; From 0a45f056612592dd1e09ecaaa553f633720db351 Mon Sep 17 00:00:00 2001 From: Ryan Schmukler Date: Sat, 9 Jan 2016 16:53:47 -0500 Subject: [PATCH 0055/1850] expand googlemaps definitions --- googlemaps/google.maps.d.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 82a13d9122..bca09b3f39 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1517,7 +1517,7 @@ declare module google.maps { addressControl?: boolean; addressControlOptions?: StreetViewAddressControlOptions; clickToGo?: boolean; - disableDefaultUi?: boolean; + disableDefaultUI?: boolean; disableDoubleClickZoom?: boolean; enableCloseButton?: boolean; imageDateControl?: boolean; @@ -1530,6 +1530,7 @@ declare module google.maps { pov?: StreetViewPov; scrollwheel?: boolean; visible?: boolean; + zoom?: number; zoomControl?: boolean; zoomControlOptions?: ZoomControlOptions; } @@ -1571,7 +1572,29 @@ declare module google.maps { worldSize?: Size; } + export enum StreetViewPreference { + BEST, + NEAREST + } + + export enum StreetViewSource { + DEFAULT, + OUTDOOR + } + + export interface StreetViewLocationRequest { + location: LatLng|LatLngLiteral; + preference?: StreetViewPreference; + radius?: number; + source?: StreetViewSource; + } + + export interface StreetViewPanoRequest { + pano: string; + } + export class StreetViewService { + getPanorama(request: StreetViewLocationRequest|StreetViewPanoRequest, cb: (data: StreetViewPanoramaData, status: StreetViewStatus) => void): void; getPanoramaById(pano: string, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void): void; getPanoramaByLocation(latlng: LatLng|LatLngLiteral, radius: number, callback: (streetViewPanoramaData: StreetViewPanoramaData, streetViewStatus: StreetViewStatus) => void ): void; } From 74a8ca9e7e9e86b4368996da45d740dcf1386a46 Mon Sep 17 00:00:00 2001 From: MizunagiKB Date: Sat, 20 Feb 2016 14:11:16 +0900 Subject: [PATCH 0056/1850] Collection.remove: Argument type is missing. It is different arguments in the add function and remove function. (add - Backbone.Collection.add, remove - Backbone.Collection.remove) Those that can be used in argument, a Model instance, id string or a JS object http://backbonejs.org/#Collection-remove --- backbone/backbone-global.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts index c16e1a59e3..1962bb08ef 100644 --- a/backbone/backbone-global.d.ts +++ b/backbone/backbone-global.d.ts @@ -206,8 +206,8 @@ declare module Backbone { pluck(attribute: string): any[]; push(model: TModel, options?: AddOptions): TModel; pop(options?: Silenceable): TModel; - remove(model: TModel, options?: Silenceable): TModel; - remove(models: TModel[], options?: Silenceable): TModel[]; + remove(model: {}|TModel, options?: Silenceable): TModel; + remove(models: ({}|TModel)[], options?: Silenceable): TModel[]; reset(models?: TModel[], options?: Silenceable): TModel[]; set(models?: TModel[], options?: Silenceable): TModel[]; shift(options?: Silenceable): TModel; From b7973616d40f9f67fbb09cbd5fc7f3aa8817fb4b Mon Sep 17 00:00:00 2001 From: YUDIEL CURBELO Date: Sat, 20 Feb 2016 00:57:52 -0500 Subject: [PATCH 0057/1850] path function to allow (string | number)[] It is totally legal to have something like this: paper.path(['M' + (startX), (startY), 'L' + (startX), (startY)]); --- raphael/raphael.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raphael/raphael.d.ts b/raphael/raphael.d.ts index 80419302ad..38d6c53654 100644 --- a/raphael/raphael.d.ts +++ b/raphael/raphael.d.ts @@ -210,7 +210,7 @@ interface RaphaelPaper { getFont(family: string, weight?: number, style?: string, stretch?: string): RaphaelFont; height: number; image(src: string, x: number, y: number, width: number, height: number): RaphaelElement; - path(pathString?: string): RaphaelPath; + path(pathString?: string | (string | number)[]): RaphaelPath; print(x: number, y: number, str: string, font: RaphaelFont, size?: number, origin?: string, letter_spacing?: number): RaphaelPath; rect(x: number, y: number, width: number, height: number, r?: number): RaphaelElement; remove(): void; From a6f84522683e0abd14258ffeb0162b9e4c3d1cff Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Thu, 25 Feb 2016 14:19:57 +0100 Subject: [PATCH 0058/1850] Whitespace only: remove tabs in foogaloop.d.ts --- vimeo/froogaloop.d.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vimeo/froogaloop.d.ts b/vimeo/froogaloop.d.ts index 61f58e284f..077e79cbce 100644 --- a/vimeo/froogaloop.d.ts +++ b/vimeo/froogaloop.d.ts @@ -4,15 +4,17 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped interface VimeoParams { - name:string; - value:any; + name:string; + value:any; } + interface VimeoPlayerAPI { (method: string): any; (method: string, callback: (value: any, player_id: any) =>void ): any; - (method: string, value: any): any; - (method: string, value: VimeoParams[]): any; + (method: string, value: any): any; + (method: string, value: VimeoParams[]): any; } + interface VimeoPlayer { api: VimeoPlayerAPI; addEvent(eventName: string, callback: (e: any) =>void ): any; @@ -25,4 +27,4 @@ interface VimeoPlayer { getDomainFromUrl(url: string): string; } -declare var $f: VimeoPlayerAPI; \ No newline at end of file +declare var $f: VimeoPlayerAPI; From cca549d09caf1a66fcdb2a259e8b03a2983a89d3 Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Thu, 25 Feb 2016 14:21:23 +0100 Subject: [PATCH 0059/1850] Fix vimeo/froogaloop.d.ts --- vimeo/froogaloop.d.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/vimeo/froogaloop.d.ts b/vimeo/froogaloop.d.ts index 077e79cbce..d0e54e3199 100644 --- a/vimeo/froogaloop.d.ts +++ b/vimeo/froogaloop.d.ts @@ -19,12 +19,7 @@ interface VimeoPlayer { api: VimeoPlayerAPI; addEvent(eventName: string, callback: (e: any) =>void ): any; removeEvent(eventName: string): void; - postMessage(method: string, params:VimeoParams[], target): void; - onMessagReceived(event); - storeCallback(eventName: string, callback, target_id: string); - getCallback(eventName: string, target_id: string); - removeCallback(eventName: string, target_id: string); - getDomainFromUrl(url: string): string; } declare var $f: VimeoPlayerAPI; +declare var Froogaloop: VimeoPlayerAPI; From cbf669a7a0cb7e236ef1ee252cc836344a4a9417 Mon Sep 17 00:00:00 2001 From: Laszlo Pandy Date: Thu, 25 Feb 2016 14:22:36 +0100 Subject: [PATCH 0060/1850] Whitespace only. --- vimeo/froogaloop.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vimeo/froogaloop.d.ts b/vimeo/froogaloop.d.ts index d0e54e3199..b4af11258a 100644 --- a/vimeo/froogaloop.d.ts +++ b/vimeo/froogaloop.d.ts @@ -10,14 +10,14 @@ interface VimeoParams { interface VimeoPlayerAPI { (method: string): any; - (method: string, callback: (value: any, player_id: any) =>void ): any; + (method: string, callback: (value: any, player_id: any) => void): any; (method: string, value: any): any; (method: string, value: VimeoParams[]): any; } interface VimeoPlayer { api: VimeoPlayerAPI; - addEvent(eventName: string, callback: (e: any) =>void ): any; + addEvent(eventName: string, callback: (e: any) => void): any; removeEvent(eventName: string): void; } From 4db61597fa28a9f8bbb19f410f6f38f80271d203 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Tue, 1 Mar 2016 15:13:50 +0100 Subject: [PATCH 0061/1850] Create connect-redis definitions --- connect-redis/connect-redis-tests.ts | 4 +++ connect-redis/connect-redis.d.ts | 38 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 connect-redis/connect-redis-tests.ts create mode 100644 connect-redis/connect-redis.d.ts diff --git a/connect-redis/connect-redis-tests.ts b/connect-redis/connect-redis-tests.ts new file mode 100644 index 0000000000..3c50074117 --- /dev/null +++ b/connect-redis/connect-redis-tests.ts @@ -0,0 +1,4 @@ +import * as connectRedis from "connect-redis"; +import * as session from "express-session"; + +let RedisStore = connectRedis(session); diff --git a/connect-redis/connect-redis.d.ts b/connect-redis/connect-redis.d.ts new file mode 100644 index 0000000000..4ba0490fe1 --- /dev/null +++ b/connect-redis/connect-redis.d.ts @@ -0,0 +1,38 @@ +// Type definitions for connect-redis +// Project: https://npmjs.com/package/connect-redis +// Definitions by: Xavier Stouder +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "connect-redis" { + import * as express from "express"; + import * as session from "express-session"; + import * as redis from "redis"; + + function s(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore; + + namespace s { + interface RedisStore extends session.Store { + new (options: RedisStoreOptions): session.Store; + } + interface RedisStoreOptions { + client?: redis.RedisClient; + host?: string; + port?: number; + socket?: string; + url?: string; + ttl?: number; + disableTTL?: boolean; + db?: number; + pass?: string; + prefix?: string; + unref?: boolean; + serializer?: Serializer | JSON; + } + interface Serializer { + stringify: Function; + parse: Function; + } + } + + export = s; +} From 6b080a6bbf559cc352345f191b8e1aee555d1cf6 Mon Sep 17 00:00:00 2001 From: eloekset Date: Tue, 1 Mar 2016 15:21:45 +0100 Subject: [PATCH 0062/1850] Globalize definition for NuGet package v0.1.3. --- globalize/globalize-0.1.3.d.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 globalize/globalize-0.1.3.d.ts diff --git a/globalize/globalize-0.1.3.d.ts b/globalize/globalize-0.1.3.d.ts new file mode 100644 index 0000000000..8fbd4934b1 --- /dev/null +++ b/globalize/globalize-0.1.3.d.ts @@ -0,0 +1,25 @@ +// Type definitions for Globalize v?.? NuGet package v0.1.3 +// Project: https://github.com/jquery/globalize +// Definitions by: Aram Taieb +// Definitions: https://github.com/afromogli/DefinitelyTyped + +interface GlobalizeStatic { + addCultureInfo(cultureName: string, baseCultureName: string, info: any): void; + findClosestCulture(name: string): any; + format(value: any, format: string): string; + format(value: any, format: string, cultureSelector: string): string; + localize(key: string): string; + localize(key: string, cultureSelector: string): string; + parseDate(value: any): Date; + parseDate(value: any, formats: any): Date; + parseDate(value: any, formats: any, culture: string): Date; + parseInt(value: any): number; + parseInt(value: any, radix: number): number; + parseInt(value: any, radix: number, cultureSelector: string): number; + parseFloat(value: any): number; + parseFloat(value: any, radix: number): number; + parseFloat(value: any, radix: number, cultureSelector: string): number; + culture(cultureSelector: string): any; +} + +declare var Globalize: GlobalizeStatic; From 1ea67ceea476ea5b226130ced5f2cef247eedaab Mon Sep 17 00:00:00 2001 From: abraaoalves Date: Tue, 1 Mar 2016 19:01:41 -0300 Subject: [PATCH 0063/1850] ad files --- .../jquery-truncate-html-tests.ts | 5 +++++ .../jquery-truncate-html.d.ts | 22 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 jquery-truncate-html/jquery-truncate-html-tests.ts create mode 100644 jquery-truncate-html/jquery-truncate-html.d.ts diff --git a/jquery-truncate-html/jquery-truncate-html-tests.ts b/jquery-truncate-html/jquery-truncate-html-tests.ts new file mode 100644 index 0000000000..fe043601b0 --- /dev/null +++ b/jquery-truncate-html/jquery-truncate-html-tests.ts @@ -0,0 +1,5 @@ +/// + +jQuery('

Stuff and Nonsense

').truncate({ + length: 13 +}).html(); diff --git a/jquery-truncate-html/jquery-truncate-html.d.ts b/jquery-truncate-html/jquery-truncate-html.d.ts new file mode 100644 index 0000000000..d7f4abaa3b --- /dev/null +++ b/jquery-truncate-html/jquery-truncate-html.d.ts @@ -0,0 +1,22 @@ +// Type definitions for jQuery-truncate-html.js +// Project: https://github.com/kbwood/timeentry +// Definitions by: Abraão Alves +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface ITruncateOptions{ + length?: number; + stripTags?: boolean; + words?: boolean; + noBreaks?: boolean; + ellipsis?: string; +} + +interface jQuery{ + truncate(options: ITruncateOptions) : jQuery; +} + +interface JQueryStatic { + truncate(html: string, options: ITruncateOptions) : string; +} From 13d212dfb3ef4672039019036bf2d08acbe728eb Mon Sep 17 00:00:00 2001 From: abraaoalves Date: Tue, 1 Mar 2016 21:40:34 -0300 Subject: [PATCH 0064/1850] make tests --- .../jquery-truncate-html-tests.ts | 15 ++++++++++++--- jquery-truncate-html/jquery-truncate-html.d.ts | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/jquery-truncate-html/jquery-truncate-html-tests.ts b/jquery-truncate-html/jquery-truncate-html-tests.ts index fe043601b0..e20f9c22ee 100644 --- a/jquery-truncate-html/jquery-truncate-html-tests.ts +++ b/jquery-truncate-html/jquery-truncate-html-tests.ts @@ -1,5 +1,14 @@ /// -jQuery('

Stuff and Nonsense

').truncate({ - length: 13 -}).html(); + +function truncateHtmlString(): string { + return $.truncate('

Stuff and Nonsense

', { + length: 13 + }); +} + +function truncateVirtualElement (): JQuery { + return $('

Stuff and Nonsense

').truncate({ + length: 13 + }); +} diff --git a/jquery-truncate-html/jquery-truncate-html.d.ts b/jquery-truncate-html/jquery-truncate-html.d.ts index d7f4abaa3b..3a22eaffdb 100644 --- a/jquery-truncate-html/jquery-truncate-html.d.ts +++ b/jquery-truncate-html/jquery-truncate-html.d.ts @@ -13,8 +13,8 @@ interface ITruncateOptions{ ellipsis?: string; } -interface jQuery{ - truncate(options: ITruncateOptions) : jQuery; +interface JQuery{ + truncate(options: ITruncateOptions) : JQuery; } interface JQueryStatic { From 876883d0fd58dc1e24d3f3c147b5f33dfbfb56df Mon Sep 17 00:00:00 2001 From: eloekset Date: Wed, 2 Mar 2016 16:39:17 +0100 Subject: [PATCH 0065/1850] Created test file for the 0.1.3 definition. --- globalize/globalize-0.1.3-tests.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 globalize/globalize-0.1.3-tests.ts diff --git a/globalize/globalize-0.1.3-tests.ts b/globalize/globalize-0.1.3-tests.ts new file mode 100644 index 0000000000..4e3e9056ed --- /dev/null +++ b/globalize/globalize-0.1.3-tests.ts @@ -0,0 +1,11 @@ +/// +module Tests { + Globalize.culture('en-US'); + Globalize.addCultureInfo('nb-NO', 'no', { messages: {Test: "Test"} }); + var cult = Globalize.findClosestCulture('nb-NO'); + var numberString = Globalize.format(1.245, 'n2'); + var testString = Globalize.localize('Test'); + var dateParsed = Globalize.parseDate('2016-02-03'); + var intParsed = Globalize.parseInt('123'); + var floatParsed = Globalize.parseFloat('12.3'); +} \ No newline at end of file From d9e6d03e769ee7013bee70e4f73c8e59d932d91d Mon Sep 17 00:00:00 2001 From: eloekset Date: Wed, 2 Mar 2016 16:40:20 +0100 Subject: [PATCH 0066/1850] Set NuGet version 0.1.3 as Globalize version. --- globalize/globalize-0.1.3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/globalize/globalize-0.1.3.d.ts b/globalize/globalize-0.1.3.d.ts index 8fbd4934b1..b31a1cc092 100644 --- a/globalize/globalize-0.1.3.d.ts +++ b/globalize/globalize-0.1.3.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Globalize v?.? NuGet package v0.1.3 +// Type definitions for Globalize v0.1.3 (NuGet package version) // Project: https://github.com/jquery/globalize // Definitions by: Aram Taieb // Definitions: https://github.com/afromogli/DefinitelyTyped From 41d21c491c0bb1eff11d98265e30a290d4410ce2 Mon Sep 17 00:00:00 2001 From: rgvassar Date: Wed, 2 Mar 2016 10:25:09 -0800 Subject: [PATCH 0067/1850] angular-animate Added the on, off, and pin methods to the IAnimateService interface. --- angularjs/angular-animate.d.ts | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index be83611e07..c29fd1857e 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -27,6 +27,42 @@ declare module angular.animate { * see http://docs.angularjs.org/api/ngAnimate/service/$animate */ interface IAnimateService { + /** + * Sets up an event listener to fire whenever the animation event (enter, leave, move, etc...) has fired + * on the given element or among any of its children. Once the listener is fired, the provided callback + * is fired with the following params: + * + * @event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...) + * @container the container element that will capture each of the animation events that are fired on itself as well as among its children + * @callback the callback function that will be fired when the listener is triggered + * The arguments present in the callback function are: + * element - The captured DOM element that the animation was fired on. + * phase - The phase of the animation. The two possible phases are start (when the animation starts) and close (when it ends). + */ + on(event: string, container: JQuery, callback: (element?: JQuery, phase?: string) => any): void; + + /** + * Deregisters an event listener based on the event which has been associated with the provided element. + * This method can be used in three different ways depending on the arguments. + * + * @event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...) + * @container the container element the event listener was placed on. + * @callback the callback function that was registered as the listener + */ + off(event: string, container?: JQuery, callback?: (element?: JQuery, phase?: string) => any): void; + + /** + * Associates the provided element with a host parent element to allow the element to be animated even if + * it exists outside of the DOM structure of the Angular application. By doing so, any animation triggered + * via $animate can be issued on the element despite being outside the realm of the application or within + * another application. Say for example if the application was bootstrapped on an element that is somewhere + * inside of the tag, but we wanted to allow for an element to be situated as a direct child of document.body, + * then this can be achieved by pinning the element via $animate.pin(element). Keep in mind that calling + * $animate.pin(element, parentElement) will not actually insert into the DOM anywhere; it will just create the association. + * Note that this feature is only active when the ngAnimate module is used. + */ + pin(element: JQuery, parentElement: JQuery): void; + /** * Globally enables / disables animations. * From 90ecfb5cab21366189c700d34c76f6fe13a1bd3f Mon Sep 17 00:00:00 2001 From: artem Date: Fri, 4 Mar 2016 12:10:52 +0200 Subject: [PATCH 0068/1850] Update restangular.d.ts --- restangular/restangular.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index db17e51cf8..68e1144dc0 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -93,6 +93,7 @@ declare module restangular { service(route: string, parent?: any): IService; stripRestangular(element: any): any; extendModel(route: string, extender: (model: IElement) => any): void; + extendCollection(route: string, extender: (collection: ICollection) => any): void; } interface IElement extends IService { From 4064f5b0d8945fc38b3568b5bb6a3b24d9e410fc Mon Sep 17 00:00:00 2001 From: AbraaoAlves Date: Sat, 5 Mar 2016 11:26:59 -0300 Subject: [PATCH 0069/1850] Remove "I" prefix --- jquery-truncate-html/jquery-truncate-html.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery-truncate-html/jquery-truncate-html.d.ts b/jquery-truncate-html/jquery-truncate-html.d.ts index 3a22eaffdb..e410716b0a 100644 --- a/jquery-truncate-html/jquery-truncate-html.d.ts +++ b/jquery-truncate-html/jquery-truncate-html.d.ts @@ -5,7 +5,7 @@ /// -interface ITruncateOptions{ +interface TruncateOptions{ length?: number; stripTags?: boolean; words?: boolean; @@ -14,9 +14,9 @@ interface ITruncateOptions{ } interface JQuery{ - truncate(options: ITruncateOptions) : JQuery; + truncate(options: TruncateOptions) : JQuery; } interface JQueryStatic { - truncate(html: string, options: ITruncateOptions) : string; + truncate(html: string, options: TruncateOptions) : string; } From b906a40b8e52d904daeb69d145de75e0084d5896 Mon Sep 17 00:00:00 2001 From: wagich Date: Sat, 5 Mar 2016 17:25:14 +0100 Subject: [PATCH 0070/1850] corrects naming of `setGallerySize` member in FlickityOptions --- flickity/flickity.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flickity/flickity.d.ts b/flickity/flickity.d.ts index bf4541e5ff..febb09b525 100644 --- a/flickity/flickity.d.ts +++ b/flickity/flickity.d.ts @@ -269,7 +269,7 @@ interface FlickityOptions { * * default: true */ - useSetGallerySize?: boolean; + setGallerySize?: boolean; /** * Adjusts sizes and positions when window is resized. From ec13362958058efcaff223167f987f16a809e668 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 5 Mar 2016 17:56:49 +0100 Subject: [PATCH 0071/1850] Fix references path --- connect-redis/connect-redis.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connect-redis/connect-redis.d.ts b/connect-redis/connect-redis.d.ts index 4ba0490fe1..21af697f38 100644 --- a/connect-redis/connect-redis.d.ts +++ b/connect-redis/connect-redis.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "connect-redis" { - import * as express from "express"; - import * as session from "express-session"; - import * as redis from "redis"; + /// + /// + /// function s(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore; From 252bd4bb4e881da01b0324cc40f7277098c6aead Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 5 Mar 2016 17:58:29 +0100 Subject: [PATCH 0072/1850] Fix path --- connect-redis/connect-redis.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connect-redis/connect-redis.d.ts b/connect-redis/connect-redis.d.ts index 21af697f38..078b99073c 100644 --- a/connect-redis/connect-redis.d.ts +++ b/connect-redis/connect-redis.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "connect-redis" { - /// - /// - /// + /// + /// + /// function s(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore; From 6513e0853e3522c0e06d346e048d815cb0331809 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 5 Mar 2016 18:01:14 +0100 Subject: [PATCH 0073/1850] References & imports --- connect-redis/connect-redis.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/connect-redis/connect-redis.d.ts b/connect-redis/connect-redis.d.ts index 078b99073c..b3a1529569 100644 --- a/connect-redis/connect-redis.d.ts +++ b/connect-redis/connect-redis.d.ts @@ -3,10 +3,15 @@ // Definitions by: Xavier Stouder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// +/// +/// + declare module "connect-redis" { - /// - /// - /// + import * as express from "express"; + import * as session from "express-session"; + import * as redis from "redis"; + function s(options: (options?: session.SessionOptions) => express.RequestHandler): s.RedisStore; From e88d574f91aef319947931009d40477dc501a36e Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 5 Mar 2016 18:03:42 +0100 Subject: [PATCH 0074/1850] Fix tests references --- connect-redis/connect-redis-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/connect-redis/connect-redis-tests.ts b/connect-redis/connect-redis-tests.ts index 3c50074117..fa61b7304c 100644 --- a/connect-redis/connect-redis-tests.ts +++ b/connect-redis/connect-redis-tests.ts @@ -1,3 +1,6 @@ +/// +/// + import * as connectRedis from "connect-redis"; import * as session from "express-session"; From 91d48d1b2823289abec4aabd30dbc6d9899da206 Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Sat, 5 Mar 2016 18:05:51 +0100 Subject: [PATCH 0075/1850] Fix name --- connect-redis/connect-redis-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connect-redis/connect-redis-tests.ts b/connect-redis/connect-redis-tests.ts index fa61b7304c..2ad4d53bd5 100644 --- a/connect-redis/connect-redis-tests.ts +++ b/connect-redis/connect-redis-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// import * as connectRedis from "connect-redis"; From 01c976de75d8564675ed4eba811be31cbf6d82ad Mon Sep 17 00:00:00 2001 From: Strato Date: Thu, 10 Mar 2016 11:56:31 +0100 Subject: [PATCH 0076/1850] Added some missing properties 'getSignalBars()' seems to always return null anyway... Whole Windows.Data.Pdf namespace is still missing. Lots of class of Windows.ApplicationModel.Contacts are missing as well. --- winrt/winrt.d.ts | 166 +++++++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 76 deletions(-) diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 687d7f83d4..5ce721b082 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -8201,6 +8201,7 @@ declare module Windows { getDataPlanStatus(): Windows.Networking.Connectivity.DataPlanStatus; getLocalUsage(StartTime: Date, EndTime: Date): Windows.Networking.Connectivity.DataUsage; getLocalUsage(StartTime: Date, EndTime: Date, States: Windows.Networking.Connectivity.RoamingStates): Windows.Networking.Connectivity.DataUsage; + getSignalBars(): Windows.Foundation.IReference; } export class ConnectionCost implements Windows.Networking.Connectivity.IConnectionCost { approachingDataLimit: boolean; @@ -8267,6 +8268,7 @@ declare module Windows { getDataPlanStatus(): Windows.Networking.Connectivity.DataPlanStatus; getLocalUsage(StartTime: Date, EndTime: Date): Windows.Networking.Connectivity.DataUsage; getLocalUsage(StartTime: Date, EndTime: Date, States: Windows.Networking.Connectivity.RoamingStates): Windows.Networking.Connectivity.DataUsage; + getSignalBars(): Windows.Foundation.IReference; } export class LanIdentifier implements Windows.Networking.Connectivity.ILanIdentifier { infrastructureId: Windows.Networking.Connectivity.LanIdentifierData; @@ -11340,15 +11342,18 @@ declare module Windows { } export interface ILauncherOptions { contentType: string; + desiredRemainingView: Windows.UI.ViewManagement.ViewSizePreference; displayApplicationPicker: boolean; fallbackUri: Windows.Foundation.Uri; preferredApplicationDisplayName: string; preferredApplicationPackageFamilyName: string; treatAsUntrusted: boolean; - uI: Windows.System.LauncherUIOptions; + UI: Windows.System.LauncherUIOptions; + } export class LauncherOptions implements Windows.System.ILauncherOptions { contentType: string; + desiredRemainingView: Windows.UI.ViewManagement.ViewSizePreference; displayApplicationPicker: boolean; fallbackUri: Windows.Foundation.Uri; preferredApplicationDisplayName: string; @@ -11590,87 +11595,96 @@ declare module Windows { } declare module Windows { export module UI { - export module ViewManagement { - export enum ApplicationViewState { - fullScreenLandscape, - filled, - snapped, - fullScreenPortrait, - } + export module ViewManagement { + export enum ViewSizePreference { + default = 0, + useLess = 1, + useHalf = 2, + useMore = 3, + useMinimum = 4, + useNone = 5 + } + + export enum ApplicationViewState { + fullScreenLandscape, + filled, + snapped, + fullScreenPortrait, + } + + /** + * Defines an instance of a window (app view) and the information that describes it. + **/ + export class ApplicationView { + /** + * Gets the window (app view) for the current app. + **/ + static getForCurrentView(): ApplicationView; /** - * Defines an instance of a window (app view) and the information that describes it. + * Attempts to unsnap a previously snapped app. This call will only succeed when the app is running in the foreground. **/ - export class ApplicationView { - /** - * Gets the window (app view) for the current app. - **/ - static getForCurrentView(): ApplicationView; - - /** - * Attempts to unsnap a previously snapped app. This call will only succeed when the app is running in the foreground. - **/ - static tryUnsnap(): boolean; - - /** - * Gets the state of the current app view. - **/ - static value: Windows.UI.ViewManagement.ApplicationViewState; - - /** - * Indicates whether the app terminates when the last window is closed. - **/ - static terminateAppOnFinalViewClose: boolean; - - /** - * Gets the current orientation of the window (app view) with respect to the display. - **/ - orientation: ApplicationViewOrientation; - - /** - * Gets or sets the displayed title of the window. - **/ - title: string; - - /** - * Gets or sets whether screen capture is enabled for the window (app view). - **/ - isScreenCaptureEnabled: boolean; - - /** - * Gets whether the window (app view) is on the Windows lock screen. - **/ - isOnLockScreen: boolean; - - /** - * Gets whether the window(app view) is full screen or not. - **/ - isFullScreen: boolean; - - /** - * Gets the current ID of the window (app view) . - **/ - id: number; - - /** - * Gets whether the current window (app view) is adjacent to the right edge of the screen. - **/ - adjacentToRightDisplayEdge: boolean; - - /** - * Gets whether the current window (app view) is adjacent to the left edge of the screen. - **/ - adjacentToLeftDisplayEdge: number; - - /** - * Gets the title bar of the app. - **/ - titleBar: ApplicationViewTitleBar; - } + static tryUnsnap(): boolean; /** - * Defines the set of display orientation modes for a window (app view). + * Gets the state of the current app view. **/ + static value: Windows.UI.ViewManagement.ApplicationViewState; + + /** + * Indicates whether the app terminates when the last window is closed. + **/ + static terminateAppOnFinalViewClose: boolean; + + /** + * Gets the current orientation of the window (app view) with respect to the display. + **/ + orientation: ApplicationViewOrientation; + + /** + * Gets or sets the displayed title of the window. + **/ + title: string; + + /** + * Gets or sets whether screen capture is enabled for the window (app view). + **/ + isScreenCaptureEnabled: boolean; + + /** + * Gets whether the window (app view) is on the Windows lock screen. + **/ + isOnLockScreen: boolean; + + /** + * Gets whether the window(app view) is full screen or not. + **/ + isFullScreen: boolean; + + /** + * Gets the current ID of the window (app view) . + **/ + id: number; + + /** + * Gets whether the current window (app view) is adjacent to the right edge of the screen. + **/ + adjacentToRightDisplayEdge: boolean; + + /** + * Gets whether the current window (app view) is adjacent to the left edge of the screen. + **/ + adjacentToLeftDisplayEdge: number; + + /** + * Gets the title bar of the app. + **/ + titleBar: ApplicationViewTitleBar; + } + + /** + * Defines the set of display orientation modes for a window (app view). + **/ export enum ApplicationViewOrientation { landscape, portrait From 7f6c9bdbce542f3531022bb16a5753ef9331e58f Mon Sep 17 00:00:00 2001 From: Riron Date: Thu, 10 Mar 2016 16:54:23 +0100 Subject: [PATCH 0077/1850] Add createInstance() method Adds the missing createInstance() method: You can create multiple instances of localForage that point to different stores using createInstance. All the configuration options used by config are supported. ``` var store = localforage.createInstance({ name: "nameHere" }); var otherStore = localforage.createInstance({ name: "otherName" }); // Setting the key on one of these doesn't affect the other. store.setItem("key", "value"); otherStore.setItem("key", "value2"); ``` --- localForage/localForage.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts index d42012e5f2..be1803b308 100644 --- a/localForage/localForage.d.ts +++ b/localForage/localForage.d.ts @@ -86,6 +86,13 @@ interface LocalForage { iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise; iterate(iteratee: (value: any, key: string, iterationNumber: number) => any, callback: (err: any, result: any) => void): void; + + /** + * Create a new instance of localForage to point to a different store. + * All the configuration options used by config are supported. + * @param {LocalForageOptions} options + */ + createInstance(options: LocalForageOptions): LocalForage; } declare module "localforage" { From c2a803dacae48642c117fe358d8c1d929f4d1a0f Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Thu, 10 Mar 2016 17:19:16 +0100 Subject: [PATCH 0078/1850] Update connect-redis-tests.ts --- connect-redis/connect-redis-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connect-redis/connect-redis-tests.ts b/connect-redis/connect-redis-tests.ts index 2ad4d53bd5..abc14977ee 100644 --- a/connect-redis/connect-redis-tests.ts +++ b/connect-redis/connect-redis-tests.ts @@ -1,4 +1,4 @@ -/// +/// /// import * as connectRedis from "connect-redis"; From 5597d81a2dfa7a555e8af3d5bfd57357e902b916 Mon Sep 17 00:00:00 2001 From: RVassar Date: Sat, 12 Mar 2016 20:21:20 -0800 Subject: [PATCH 0079/1850] Not sure what the changes are here. Different line endings or something. --- angular-load/angular-load.d.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/angular-load/angular-load.d.ts b/angular-load/angular-load.d.ts index a35d1c59d8..65d5bc388a 100644 --- a/angular-load/angular-load.d.ts +++ b/angular-load/angular-load.d.ts @@ -1,15 +1,15 @@ -// Type definitions for angular-load v0.4.1 -// Project: https://github.com/urish/angular-load -// Definitions by: david-gang -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module angular.load { - - interface IAngularLoadService { - loadScript(url:string): ng.IPromise; - loadCss(url:string): ng.IPromise; - } - -} +// Type definitions for angular-load v0.4.1 +// Project: https://github.com/urish/angular-load +// Definitions by: david-gang +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module angular.load { + + interface IAngularLoadService { + loadScript(url:string): ng.IPromise; + loadCss(url:string): ng.IPromise; + } + +} From 74f4692670283fd9a547469557079da38bb10084 Mon Sep 17 00:00:00 2001 From: Strato Date: Mon, 14 Mar 2016 00:27:55 +0100 Subject: [PATCH 0080/1850] Fixed what seems to be the problem with travis --- winrt/winrt.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winrt/winrt.d.ts b/winrt/winrt.d.ts index 5ce721b082..3d25a6469f 100644 --- a/winrt/winrt.d.ts +++ b/winrt/winrt.d.ts @@ -11348,7 +11348,7 @@ declare module Windows { preferredApplicationDisplayName: string; preferredApplicationPackageFamilyName: string; treatAsUntrusted: boolean; - UI: Windows.System.LauncherUIOptions; + uI: Windows.System.LauncherUIOptions; } export class LauncherOptions implements Windows.System.ILauncherOptions { From 151405fb054abc189076ea0e8c33703c3c39ce60 Mon Sep 17 00:00:00 2001 From: okamiconcept Date: Tue, 15 Mar 2016 12:28:10 +0100 Subject: [PATCH 0081/1850] Fix module definition for IModule Put the IModule definition in angular module. --- angularjs/angular-animate.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index a34bd479f1..64e1bfe7d5 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -287,9 +287,11 @@ declare module angular.animate { interface IAnimateCssService { (element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner; } +} +declare module angular { interface IModule { - animation(name: string, animationFactory: IAnimateFactory): IModule; + animation(name: string, animationFactory: angular.animate.IAnimateFactory): IModule; animation(name: string, inlineAnnotatedFunction: any[]): IModule; animation(object: Object): IModule; } From ff98d72f5ad685208b16dfa79cd063319fc1397e Mon Sep 17 00:00:00 2001 From: gael Magnan Date: Wed, 16 Mar 2016 13:58:12 +0100 Subject: [PATCH 0082/1850] Added new version of jwt-simple, now supports v 0.5.0 --- jwt-simple/jwt-simple-0.2.0-tests.ts | 12 ++++++++++++ jwt-simple/jwt-simple-0.2.0.d.ts | 22 ++++++++++++++++++++++ jwt-simple/jwt-simple.d.ts | 10 ++++++---- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 jwt-simple/jwt-simple-0.2.0-tests.ts create mode 100644 jwt-simple/jwt-simple-0.2.0.d.ts diff --git a/jwt-simple/jwt-simple-0.2.0-tests.ts b/jwt-simple/jwt-simple-0.2.0-tests.ts new file mode 100644 index 0000000000..8a0cc59c52 --- /dev/null +++ b/jwt-simple/jwt-simple-0.2.0-tests.ts @@ -0,0 +1,12 @@ +/// + +import jwt = require('jwt-simple'); +var payload = { foo: 'bar' }; +var secret:string = 'xxx'; + +// encode +var token = jwt.encode(payload, secret); + +// decode +var decoded = jwt.decode(token, secret); +console.log(decoded); //=> { foo: 'bar' } \ No newline at end of file diff --git a/jwt-simple/jwt-simple-0.2.0.d.ts b/jwt-simple/jwt-simple-0.2.0.d.ts new file mode 100644 index 0000000000..0ee3cc6799 --- /dev/null +++ b/jwt-simple/jwt-simple-0.2.0.d.ts @@ -0,0 +1,22 @@ +// Type definitions for jwt-simple v0.2.0 +// Project: https://github.com/hokaccha/node-jwt-simple +// Definitions by: Ken Fukuyama +// Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module "jwt-simple" { + /** + * Decode jwt + * @param token + * @param key + * @param noVerify + * @api public + */ + export function decode(token:any, key:string, noVerify?:boolean):any; + /** + * Encode jwt + * @param payload + * @param key + * @param algorithm default is HS256 + * @api public + */ + export function encode(payload:any, key:string, algorithm?:string):string; +} diff --git a/jwt-simple/jwt-simple.d.ts b/jwt-simple/jwt-simple.d.ts index 0ee3cc6799..4640f25e33 100644 --- a/jwt-simple/jwt-simple.d.ts +++ b/jwt-simple/jwt-simple.d.ts @@ -1,6 +1,6 @@ -// Type definitions for jwt-simple v0.2.0 +// Type definitions for jwt-simple v0.5.0 // Project: https://github.com/hokaccha/node-jwt-simple -// Definitions by: Ken Fukuyama +// Definitions by: Gael Magnan // Definitions: https://github.com/borisyankov/DefinitelyTyped declare module "jwt-simple" { /** @@ -8,15 +8,17 @@ declare module "jwt-simple" { * @param token * @param key * @param noVerify + * @param algorithm default is HS256 * @api public */ - export function decode(token:any, key:string, noVerify?:boolean):any; + export function decode(token:any, key:string, noVerify?:boolean, algorithm?:string):any; /** * Encode jwt * @param payload * @param key * @param algorithm default is HS256 + * @param options * @api public */ - export function encode(payload:any, key:string, algorithm?:string):string; + export function encode(payload:any, key:string, algorithm?:string, options?:any):string; } From 8afd4a79f7a0c233817d479141c310ed0d8a7540 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Wed, 16 Mar 2016 12:56:54 -0700 Subject: [PATCH 0083/1850] Updated Fuse.js definition to 2.2.0 (partially) --- fuse/fuse.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fuse/fuse.d.ts b/fuse/fuse.d.ts index bf175bff6c..e180c652e0 100644 --- a/fuse/fuse.d.ts +++ b/fuse/fuse.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Fuse.js 1.1.5 +// Type definitions for Fuse.js 2.2.0 // Project: https://github.com/krisk/Fuse // Definitions by: Greg Smith // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -11,12 +11,13 @@ declare class Fuse { declare module fuse { interface IFuseOptions extends ISearchOptions { caseSensitive?: boolean; - includeScore?: boolean; + include?: string[]; shouldSort?: boolean; searchFn?: any; sortFn?: (a: {score: number}, b: {score: number}) => number; getFn?: (obj: any, path: string) => any; - keys?: string[]; + keys?: string[] | { name:string; weight:number} []; + verbose?:boolean; } interface ISearchOptions { From 96ea748284dd67f821642362216c6d336d173207 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 18 Mar 2016 12:56:29 +0100 Subject: [PATCH 0084/1850] HammerJS: Creating an instance of Hammer returns an object, which is not a function. So calling "new" on it doesn't make sense. --- hammerjs/hammerjs.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index e2d4a8c528..4125987d64 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -97,8 +97,6 @@ interface HammerOptions extends HammerDefaults interface HammerManager { - new( element:HTMLElement, options?:any ):HammerManager; - add( recogniser:Recognizer ):Recognizer; add( recogniser:Recognizer ):HammerManager; add( recogniser:Recognizer[] ):Recognizer; From 60ddc18a594f87b9c8d36860c3ff239836211ed6 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Fri, 18 Mar 2016 14:01:19 +0100 Subject: [PATCH 0085/1850] HammerJS: Added the HammerManagerConstructor interface, and used it where it should. --- hammerjs/hammerjs.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 4125987d64..d4ea189dd8 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -39,7 +39,7 @@ interface HammerStatic DIRECTION_VERTICAL: number; DIRECTION_ALL: number; - Manager: HammerManager; + Manager: HammerManagerConstructor; Input: HammerInput; TouchAction: TouchAction; @@ -95,6 +95,10 @@ interface HammerOptions extends HammerDefaults } +interface HammerManagerConstructor { + new( element:HTMLElement, options?:any ):HammerManager; +} + interface HammerManager { add( recogniser:Recognizer ):Recognizer; From 03f28267c52a54f285d3d2a0ee8d7d6e6cb57e1a Mon Sep 17 00:00:00 2001 From: James Moey Date: Tue, 22 Mar 2016 13:58:57 +1100 Subject: [PATCH 0086/1850] Update rabbit.js definition. --- rabbit.js/rabbit.js.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rabbit.js/rabbit.js.d.ts b/rabbit.js/rabbit.js.d.ts index 7e09cfe14a..a6ac4e5c7f 100644 --- a/rabbit.js/rabbit.js.d.ts +++ b/rabbit.js/rabbit.js.d.ts @@ -22,6 +22,7 @@ declare module "rabbit.js" { persistent?: any; topic?: any; task?: any; + routing?: any; } export interface Socket { @@ -43,6 +44,7 @@ declare module "rabbit.js" { export class SubSocket extends stream.Readable implements Socket { constructor(channel: string, opts: SocketOptions); connect(source: string, callback?: Function): any; + connect(source: string, topic?: string, callback?: Function): any; setsockopt(opt: string, value: string): any; close(): any; } From dd12757cc7b16ff579f43ba3cb0e8858977d771f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20P=C3=A9rez?= Date: Tue, 22 Mar 2016 19:21:22 +0100 Subject: [PATCH 0087/1850] missing elementValue(Element) method, meant to return the value in which to apply the constraints out of the Element --- jquery.validation/jquery.validation.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jquery.validation/jquery.validation.d.ts b/jquery.validation/jquery.validation.d.ts index 7527652e80..1225db783d 100644 --- a/jquery.validation/jquery.validation.d.ts +++ b/jquery.validation/jquery.validation.d.ts @@ -213,6 +213,8 @@ declare namespace JQueryValidation * Validates the form, returns true if it is valid, false otherwise. */ form(): boolean; + + elementValue(element: Element): any; invalidElements(): HTMLElement[]; From d59d5bdea31295ff74ce32929da80246a5749580 Mon Sep 17 00:00:00 2001 From: Lou Godmer Date: Wed, 23 Mar 2016 14:23:07 -0700 Subject: [PATCH 0088/1850] update trackRequestSync api that is added in applicationinsights version 0.15.13 --- applicationinsights/applicationinsights.d.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/applicationinsights/applicationinsights.d.ts b/applicationinsights/applicationinsights.d.ts index 17ca4a479f..96d5773fa5 100644 --- a/applicationinsights/applicationinsights.d.ts +++ b/applicationinsights/applicationinsights.d.ts @@ -341,9 +341,31 @@ interface Client { trackMetric(name: string, value: number, count?:number, min?: number, max?: number, stdDev?: number, properties?: { [key: string]: string; }): void; + + /** + * Log an incoming http request to your server. The request data will be tracked during the response "finish" event if it is successful or the request "error" + * event if it fails. The request duration is automatically calculated as the timespan between when the trackRequest method was called, and when the response "finish" + * or request "error" events were fired. + * @param request The http.ServerRequest object to track + * @param response The http.ServerResponse object for this request + * @param properties map[string, string] - additional data used to filter requests in the portal. Defaults to empty. + */ trackRequest(request: any /* http.ServerRequest */, response: any /* http.ServerResponse */, properties?: { [key: string]: string; }): void; + + /** + * Log an incoming http request to your server. The request data is tracked synchronously rather than waiting for the response "finish"" or request "error"" events. + * Use this if you need your request telemetry to respect custom app insights operation and user context (for example if you set any appInsights.client.context.tags). + * @param request The http.ServerRequest object to track + * @param response The http.ServerResponse object for this request + * @param ellapsedMilliseconds The duration for this request. Defaults to 0. + * @param properties map[string, string] - additional data used to filter requests in the portal. Defaults to empty. + * @param error An error that was returned for this request if it was unsuccessful. Defaults to null. + */ + trackRequestSync(request: any /*http.ServerRequest */, response: any /*http.ServerResponse */, ellapsedMilliseconds?: number, properties?: { + [key: string]: string;}, error?: any) : void; + /** * Log information about a dependency of your app. Typically used to track the time database calls or outgoing http requests take from your server. * @param name The name of the dependency (i.e. "myDatabse") From c9ad975e6cc4d5ff7911eafde95365097cc12e55 Mon Sep 17 00:00:00 2001 From: aaronbeall Date: Thu, 24 Mar 2016 11:13:39 -0400 Subject: [PATCH 0089/1850] BaseEvent extend DOM Event to support addEventListener --- sockjs-client/sockjs-client.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sockjs-client/sockjs-client.d.ts b/sockjs-client/sockjs-client.d.ts index 322f821393..0bc7bed08a 100644 --- a/sockjs-client/sockjs-client.d.ts +++ b/sockjs-client/sockjs-client.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped declare namespace __SockJSClient { - interface BaseEvent { + interface BaseEvent extends Event { type: string; } From 3a4bdab25ba029be91c671276e1661512cb37b65 Mon Sep 17 00:00:00 2001 From: Eugen Podaru Date: Fri, 25 Mar 2016 13:45:32 +0100 Subject: [PATCH 0090/1850] support AMD require / ES6 import --- text-encoding/text-encoding.d.ts | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/text-encoding/text-encoding.d.ts b/text-encoding/text-encoding.d.ts index 1442ef2a30..08536c5981 100644 --- a/text-encoding/text-encoding.d.ts +++ b/text-encoding/text-encoding.d.ts @@ -32,14 +32,29 @@ declare namespace TextEncoding { interface TextEncodeOptions { stream?: boolean; } + + interface TextEncoderStatic { + (utfLabel?: string, options?: TextEncoderOptions): TextEncoder; + new (utfLabel?: string, options?: TextEncoderOptions): TextEncoder; + } + + interface TextDecoderStatic { + (label?: string, options?: TextDecoderOptions): TextDecoder; + new (label?: string, options?: TextDecoderOptions): TextDecoder; + } + + interface TextEncodingStatic { + TextEncoder: TextEncoderStatic; + TextDecoder: TextDecoderStatic; + } } -declare var TextDecoder: { - (label?: string, options?: TextEncoding.TextDecoderOptions): TextEncoding.TextDecoder; - new (label?: string, options?: TextEncoding.TextDecoderOptions): TextEncoding.TextDecoder; -}; +declare var TextDecoder: TextEncoding.TextDecoderStatic; -declare var TextEncoder: { - (utfLabel?: string, options?: TextEncoding.TextEncoderOptions): TextEncoding.TextEncoder; - new (utfLabel?: string, options?: TextEncoding.TextEncoderOptions): TextEncoding.TextEncoder; -}; +declare var TextEncoder: TextEncoding.TextEncoderStatic; + +declare var TextEncoding: TextEncoding.TextEncodingStatic; + +declare module "text-encoding" { + export = TextEncoding; +} From 7c5dbff213cb8a7f27200b1fa03af82b2c649c23 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 28 Mar 2016 13:55:13 -0400 Subject: [PATCH 0091/1850] TransitionGroup spreads HTMLAttribute props onto its component --- react/react-addons-transition-group.d.ts | 2 +- react/react-tests.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/react/react-addons-transition-group.d.ts b/react/react-addons-transition-group.d.ts index ca7bb4c31e..b31d7a5d2d 100644 --- a/react/react-addons-transition-group.d.ts +++ b/react/react-addons-transition-group.d.ts @@ -7,7 +7,7 @@ declare namespace __React { - interface TransitionGroupProps { + interface TransitionGroupProps extends HTMLAttributes { component?: ReactType; childFactory?: (child: ReactElement) => ReactElement; } diff --git a/react/react-tests.ts b/react/react-tests.ts index e0d9bb7be7..ca289ebda5 100644 --- a/react/react-tests.ts +++ b/react/react-tests.ts @@ -480,7 +480,9 @@ React.createFactory(CSSTransitionGroup)({ transitionName: "transition", transitionAppear: false, transitionEnter: true, - transitionLeave: true + transitionLeave: true, + id: "some-id", + className: "some-class" }); React.createFactory(CSSTransitionGroup)({ From 81f194ff4468b34b2795e89fcf2a4fe9ad570e0a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 30 Mar 2016 18:04:01 +1100 Subject: [PATCH 0092/1850] Update comments to suite revalidator versions. --- revalidator/revalidator.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index aaf38ba78f..b41e7cd03e 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,7 +1,7 @@ -// Type definitions for axios 0.5.2 +// Type definitions for revalidator 0.3.1 // Definitions by: Jason Turner -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { interface RevalidatorStatic { From 8eb5791010afa08d1a40862192fd0ae239d423ba Mon Sep 17 00:00:00 2001 From: kwiateusz Date: Wed, 30 Mar 2016 10:15:15 +0200 Subject: [PATCH 0093/1850] Updated typings of angular-toastr In toast options we can edit container config, so I edited IToastOptions interface --- angular-toastr/angular-toastr.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-toastr/angular-toastr.d.ts b/angular-toastr/angular-toastr.d.ts index 04e7714d33..e55e3b2dcf 100644 --- a/angular-toastr/angular-toastr.d.ts +++ b/angular-toastr/angular-toastr.d.ts @@ -70,7 +70,7 @@ declare namespace angular.toastr { toastId: number; } - interface IToastOptions extends IToastBaseConfig { + interface IToastOptions extends IToastBaseConfig, IToastContainerConfig { iconClass?: string; } From e42fc3e47141c1d94a7b776357f64940de33843e Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 30 Mar 2016 15:46:59 +0300 Subject: [PATCH 0094/1850] Updated react-router 2.0 Added onchange hook. Updated all hooks. Params changed from object to dictionary. Changed to use location descriptor. --- react-router/react-router.d.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index d42e7da468..357490e603 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -18,15 +18,23 @@ declare namespace ReactRouter { type Component = React.ReactType - type EnterHook = (nextState: RouterState, replaceState: RedirectFunction, callback?: Function) => any + type EnterHook = (nextState: RouterState, replace: RedirectFunction, callback?: Function) => void - type LeaveHook = () => any + type LeaveHook = () => void + + type ChangeHook = (prevState: RouterState, nextState: RouterState, replace: RedirectFunction, callback: Function) => void; - type Params = Object + type Params = { [param: string]: string } type ParseQueryString = (queryString: H.QueryString) => H.Query - type RedirectFunction = (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query) => void + interface RedirectFunction { + (location: H.LocationDescriptor): void; + /** + * @deprecated `replaceState(state, pathname, query) is deprecated; Use `replace(location)` with a location descriptor instead. http://tiny.cc/router-isActivedeprecated + */ + (state: H.LocationState, pathname: H.Pathname | H.Path, query?: H.Query): void; + } type RouteComponent = Component @@ -98,7 +106,7 @@ declare namespace ReactRouter { activeStyle?: React.CSSProperties activeClassName?: string onlyActiveOnIndex?: boolean - to: RoutePattern + to: RoutePattern | H.LocationDescriptor query?: H.Query state?: H.LocationState } @@ -138,6 +146,7 @@ declare namespace ReactRouter { getComponents?: (location: H.Location, cb: (error: any, components?: RouteComponents) => void) => void onEnter?: EnterHook onLeave?: LeaveHook + onChange?: ChangeHook getIndexRoute?: (location: H.Location, cb: (error: any, indexRoute: RouteConfig) => void) => void getChildRoutes?: (location: H.Location, cb: (error: any, childRoutes: RouteConfig) => void) => void } From 18fad79175c394c6adf19600a37ab4e12affb2eb Mon Sep 17 00:00:00 2001 From: Ryan Smith <0ryansmith1994@gmail.com> Date: Wed, 30 Mar 2016 15:05:16 +0100 Subject: [PATCH 0095/1850] Fixes for ES6. --- knex/knex.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 6f28a2f796..52740662c8 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -3,12 +3,12 @@ // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +// /// declare module "knex" { - import Promise = require("bluebird"); - import events = require("events"); + // import Promise = require("bluebird"); + import * as events from "events"; type Callback = Function; type Client = Function; From 117ecb86cfdea98012d4de67d0ccd6b36e62183c Mon Sep 17 00:00:00 2001 From: SereznoKot Date: Wed, 30 Mar 2016 17:28:19 +0300 Subject: [PATCH 0096/1850] Fix material and geometry types of Points - Set type for material according to docs - Make geometry parameter in constructor optional, because three.js provides a default value - Make geometry type in constructor match one of the class member --- threejs/three.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 14d2c0b4ea..e33b389ed5 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4539,18 +4539,18 @@ declare namespace THREE { export class Points extends Object3D { /** - * @param geometry An instance of Geometry. + * @param geometry An instance of Geometry or BufferGeometry. * @param material An instance of Material (optional). */ constructor( - geometry: Geometry | BufferGeometry, - material?: PointsMaterial | ShaderMaterial + geometry?: Geometry | BufferGeometry, + material?: Material ); /** - * An instance of Geometry, where each vertex designates the position of a particle in the system. + * An instance of Geometry or BufferGeometry, where each vertex designates the position of a particle in the system. */ - geometry: Geometry; + geometry: Geometry | BufferGeometry; /** * An instance of Material, defining the object's appearance. Default is a PointsMaterial with randomised colour. From eee669cc9cca1e1fc0f51c70bc17926610fc551e Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:25:48 +0900 Subject: [PATCH 0097/1850] Correct return values --- stacktrace-js/stacktrace-js.d.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index aebd6ddf80..045cf70104 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -49,18 +49,20 @@ declare namespace StackTrace { * * @param {Function} fn to be instrumented * @param {Function} callback function to call with a stack trace on invocation - * @param {Function} errorCallback optional function to call with error if unable to get stack trace. + * @param {Function} errback optional function to call with error if unable to get stack trace. * @param {Object} thisArg optional context object (e.g. window) + * @return {Function} instrumented function */ - export function instrument(fn:() => void, callback:(stackFrames:StackFrame[]) => void, errorCallback:(error:Error) => void, thisArg?:any): void; + export function instrument(fn: TFunc, callback: (stackFrames:StackFrame[]) => void, errback?: (error: Error) => void, thisArg?: any): TFunc; /** * Given a function that has been instrumented, * revert the function to it's original (non-instrumented) state. * * @param fn {Function} + * @return {Function} original function */ - export function deinstrument(fn:() => void): void; + export function deinstrument(fn: TFunc): TFunc; /** * Given an Array of StackFrames, serialize and POST to given URL. From ee10fc38b1acd26ec5f9f484ab11fe2eac1ebc61 Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:28:23 +0900 Subject: [PATCH 0098/1850] Correct return values --- stacktrace-js/stacktrace-js.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index 045cf70104..1bb55aa5a7 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -69,7 +69,7 @@ declare namespace StackTrace { * * @param stackframes - Array[StackFrame] * @param url - URL as String - * @return Promise + * @return Promise */ - export function report(stackframes: StackFrame[], url: string): Promise; + export function report(stackframes: StackFrame[], url: string): Promise; } From 371b6dfbf352740dd931d4b5ff95a24886074db5 Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:28:44 +0900 Subject: [PATCH 0099/1850] Define stacktrace-js module --- stacktrace-js/stacktrace-js.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index 1bb55aa5a7..c4ed865400 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -73,3 +73,7 @@ declare namespace StackTrace { */ export function report(stackframes: StackFrame[], url: string): Promise; } + +declare module "stacktrace-js" { + export = StackTrace; +} From 01fb3b9315ea18c22f61cd13ab56c60b9e99d415 Mon Sep 17 00:00:00 2001 From: Alex Pyzhianov Date: Wed, 30 Mar 2016 18:23:05 +0300 Subject: [PATCH 0100/1850] Fix EventDispatcher events, add Event interface - Remove target from dispatchEvent method, because only type is required to dispatch event and target field is inserted by three.js itself. https://github.com/mrdoob/three.js/blob/master/src/core/EventDispatcher.js - Add Event interface for callback argument in addEventListener, hasEventListener, removeEventListener --- threejs/three.d.ts | 69 +++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 14d2c0b4ea..04deadfb20 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -753,10 +753,10 @@ declare namespace THREE { dispose(): void; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; addIndex(index: any): void; // deprecated, use setIndex() addAttribute(name: any, array: any, itemSize: any): any; // deprecated @@ -860,10 +860,10 @@ declare namespace THREE { dispose(): void; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; } @@ -905,27 +905,32 @@ declare namespace THREE { * @param type The type of the listener that gets removed. * @param listener The listener function that gets removed. */ - addEventListener(type: string, listener: (event: any) => void ): void; + addEventListener(type: string, listener: (event: Event) => void ): void; /** * Adds a listener to an event type. * @param type The type of the listener that gets removed. * @param listener The listener function that gets removed. */ - hasEventListener(type: string, listener: (event: any) => void): void; + hasEventListener(type: string, listener: (event: Event) => void): void; /** * Removes a listener from an event type. * @param type The type of the listener that gets removed. * @param listener The listener function that gets removed. */ - removeEventListener(type: string, listener: (event: any) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; /** * Fire an event type. * @param type The type of event that gets fired. */ - dispatchEvent(event: { type: string; target: any; }): void; + dispatchEvent(event: { type: string; }): void; + } + + export interface Event { + type: string; + target: any; } /** @@ -1235,10 +1240,10 @@ declare namespace THREE { animations: AnimationClip[]; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; } export namespace GeometryUtils { // deprecated @@ -1611,10 +1616,10 @@ declare namespace THREE { copy(source: Object3D, recursive?: boolean): Object3D; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; getChildByName(name: string): Object3D; // deprecated, use getObjectByName() } @@ -2252,10 +2257,10 @@ declare namespace THREE { dispose(): void; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; } export interface LineBasicMaterialParameters extends MaterialParameters { @@ -4942,10 +4947,10 @@ declare namespace THREE { dispose(): void; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; } export class WebGLRenderTargetCube extends WebGLRenderTarget { @@ -5435,10 +5440,10 @@ declare namespace THREE { transformUv(uv: Vector): void; // EventDispatcher mixins - addEventListener(type: string, listener: (event: any) => void ): void; - hasEventListener(type: string, listener: (event: any) => void): void; - removeEventListener(type: string, listener: (event: any) => void): void; - dispatchEvent(event: { type: string; target: any; }): void; + addEventListener(type: string, listener: (event: Event) => void ): void; + hasEventListener(type: string, listener: (event: Event) => void): void; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; }): void; } export class CanvasTexture extends Texture { From e42a58381c705d7670176dbc0fac7728c5b3a681 Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:31:00 +0900 Subject: [PATCH 0101/1850] Correct definition for options --- stacktrace-js/stacktrace-js.d.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index c4ed865400..7bf7570fec 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -4,10 +4,21 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace StackTrace { + + export interface SourceCache { + [key: string]: string | Promise; + } + + /** + * Options for StackTrace + * @param filter Function(StackFrame => Boolean) - Only include stack entries matching for which filter returns true + * @param sourceCache Object (String URL => String Source) - Pre-populate source cache to avoid network requests + * @param offline Boolean (default: false) - Set to true to prevent all network requests + */ export interface StackTraceOptions { - filter?: (stackFrame:StackFrame) => boolean; - sourceCache?: { URL:string }; - offline?: boolean; + filter?: (stackFrame: StackFrame) => boolean; + sourceCache?: SourceCache; + offline?: boolean; } export interface StackFrame { From 48f9ebd33917a18720ce81cc2a90938b313e5f8f Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:31:23 +0900 Subject: [PATCH 0102/1850] Add methods for StackFrame --- stacktrace-js/stacktrace-js.d.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index 7bf7570fec..a682189c09 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -22,14 +22,17 @@ declare namespace StackTrace { } export interface StackFrame { - constructor(functionName:string, args:any, fileName:string, lineNumber:number, columnNumber:number): StackFrame; + constructor(functionName: string, args: any, fileName: string, lineNumber: number, columnNumber: number): StackFrame; - functionName?:string; - args?:any; - fileName?:string; - lineNumber?:number; - columnNumber?:number; - toString():string; + functionName: string; + args: any; + fileName: string; + lineNumber: number; + columnNumber: number; + source: string; + isEval: boolean; + isNative: boolean; + toString(): string; } /** From 6d023860d1253397311d708bce3df48d11b4ab2f Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:31:36 +0900 Subject: [PATCH 0103/1850] Fix typo --- stacktrace-js/stacktrace-js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index a682189c09..bc9571eb5a 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -48,7 +48,7 @@ declare namespace StackTrace { * @param options Object for options * @return Array[StackFrame] */ - export function fromError(error:Error, options?:StackTraceOptions): Promise; + export function fromError(error: Error, options?: StackTraceOptions): Promise; /** * Use StackGenerator to generate a backtrace. From b4542d0d5fc8bd5e8595084cacb08c651b7e8d9a Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:32:18 +0900 Subject: [PATCH 0104/1850] Add further tests --- stacktrace-js/stacktrace-js-tests.ts | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/stacktrace-js/stacktrace-js-tests.ts b/stacktrace-js/stacktrace-js-tests.ts index c4c9bcf879..04f92f7d2d 100644 --- a/stacktrace-js/stacktrace-js-tests.ts +++ b/stacktrace-js/stacktrace-js-tests.ts @@ -1,24 +1,36 @@ /// -function interestingFn() { +function interestingFn(): string { return 'https://github.com/exceptionless/Exceptionless'; } -var callback = function(stackframes:StackTrace.StackFrame[]) { - var stringifiedStack = stackframes.map(function(sf:StackTrace.StackFrame) { +const callback = (stackframes: StackTrace.StackFrame[]) => { + const stringifiedStack = stackframes.map((sf: StackTrace.StackFrame): string => { + console.log(sf.functionName); + console.log(sf.args); + console.log(sf.fileName); + console.log(sf.lineNumber); + console.log(sf.columnNumber); + console.log(sf.source); + console.log(sf.isEval); + console.log(sf.isNative); return sf.toString(); }).join('\n'); console.log(stringifiedStack); }; -var errorCallback = function(err:Error) { console.log(err.message); }; +const errorCallback = (err: Error) => console.log(err.message); +const logger = (stackframes: StackTrace.StackFrame[]) => console.log(stackframes); +const options: StackTrace.StackTraceOptions = { + filter: (stackframe: StackTrace.StackFrame) => true, + sourceCache: {}, + offline: false +}; +const error = new Error('BOOM!'); -StackTrace.get(); +StackTrace.get(options).then(logger); +StackTrace.fromError(error, options).then(logger); +StackTrace.generateArtificially(options).then(logger); -// Somewhere else... -var error = new Error('BOOM!'); -StackTrace.fromError(error); -StackTrace.generateArtificially(); - -StackTrace.instrument(interestingFn, callback, errorCallback); -StackTrace.deinstrument(interestingFn); +const instrumented: () => string = StackTrace.instrument(interestingFn, callback, errorCallback); +const original: () => string = StackTrace.deinstrument(interestingFn); From f9104f1e24c58134b99e03f3e28d71d1ca50fce4 Mon Sep 17 00:00:00 2001 From: delphinus Date: Thu, 31 Mar 2016 00:40:48 +0900 Subject: [PATCH 0105/1850] Fix typo --- stacktrace-js/stacktrace-js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stacktrace-js/stacktrace-js.d.ts b/stacktrace-js/stacktrace-js.d.ts index bc9571eb5a..4f0bac1635 100644 --- a/stacktrace-js/stacktrace-js.d.ts +++ b/stacktrace-js/stacktrace-js.d.ts @@ -67,7 +67,7 @@ declare namespace StackTrace { * @param {Object} thisArg optional context object (e.g. window) * @return {Function} instrumented function */ - export function instrument(fn: TFunc, callback: (stackFrames:StackFrame[]) => void, errback?: (error: Error) => void, thisArg?: any): TFunc; + export function instrument(fn: TFunc, callback: (stackFrames: StackFrame[]) => void, errback?: (error: Error) => void, thisArg?: any): TFunc; /** * Given a function that has been instrumented, From 5a66911a99a4c13ecf4f38c3f574e32339e24de9 Mon Sep 17 00:00:00 2001 From: kwiateusz Date: Wed, 30 Mar 2016 18:21:21 +0200 Subject: [PATCH 0106/1850] fixed interface inheritance --- angular-toastr/angular-toastr.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/angular-toastr/angular-toastr.d.ts b/angular-toastr/angular-toastr.d.ts index e55e3b2dcf..698ced16cc 100644 --- a/angular-toastr/angular-toastr.d.ts +++ b/angular-toastr/angular-toastr.d.ts @@ -70,8 +70,9 @@ declare namespace angular.toastr { toastId: number; } - interface IToastOptions extends IToastBaseConfig, IToastContainerConfig { + interface IToastOptions extends IToastBaseConfig { iconClass?: string; + target?: string; } interface IToastrService { From 7fb76f6e39135b7a3e7c3c384a9e28202b91a514 Mon Sep 17 00:00:00 2001 From: Ryan Smith <0ryansmith1994@gmail.com> Date: Wed, 30 Mar 2016 18:11:16 +0100 Subject: [PATCH 0107/1850] Fixes most TS2339 and all TS7006 errors. --- knex/knex-tests.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index 4078522df2..2113be68d7 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -329,11 +329,11 @@ knex.transaction(function(trx) { .insert({name: 'Old Books'}, 'id') .into('catalogues') .then(function(ids) { - return Promise.map(books, function(book) { + return Promise.all(books.map(function (book: any) { book.catalogue_id = ids[0]; // Some validation could take place here. return trx.insert(info).into('books'); - }); + })); }); }) .then(function(inserts) { @@ -359,13 +359,13 @@ knex.transaction(function(trx) { .into('catalogues') .transacting(trx) .then(function(ids) { - return Promise.map(books, function(book) { + return Promise.all(books.map(function(book: any) { book.catalogue_id = ids[0]; // Some validation could take place here. return knex.insert(info).into('books').transacting(trx); - }); + })); }) .then(trx.commit) .catch(trx.rollback); @@ -497,9 +497,9 @@ query.then(function(x: any) { knex.select('name').from('users').limit(10).map(function(row: any) { return row.name; -}).then(function(names) { +}).then(function(names: string) { console.log(names); -}).catch(function(e) { +}).catch(function(e: Error) { console.error(e); }); @@ -507,9 +507,9 @@ knex.select('name').from('users').limit(10).reduce(function(memo: any, row: any) memo.names.push(row.name); memo.count++; return memo; -}, {count: 0, names: []}).then(function(obj) { +}, {count: 0, names: []}).then(function(obj: any) { console.log(obj); -}).catch(function(e) { +}).catch(function(e: Error) { console.error(e); }); From 984183292fa6381742ac1676742fd8e220d92b82 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sat, 26 Mar 2016 20:11:47 +0100 Subject: [PATCH 0108/1850] Merge back into one file (typings is not following references) --- github-electron/github-electron.app.d.ts | 377 -- .../github-electron.auto-updater.d.ts | 51 - .../github-electron.browser-window.d.ts | 889 ---- .../github-electron.clipboard.d.ts | 76 - .../github-electron.content-tracing.d.ts | 91 - .../github-electron.crash-reporter.d.ts | 92 - github-electron/github-electron.d.ts | 3712 ++++++++++++++++- .../github-electron.desktop-capturer.d.ts | 55 - github-electron/github-electron.dialog.d.ts | 141 - github-electron/github-electron.dom.d.ts | 51 - .../github-electron.event-emitter.d.ts | 26 - .../github-electron.global-shortcut.d.ts | 38 - github-electron/github-electron.ipc-main.d.ts | 36 - .../github-electron.ipc-renderer.d.ts | 49 - .../github-electron.menu-item.d.ts | 130 - github-electron/github-electron.menu.d.ts | 63 - .../github-electron.native-image.d.ts | 59 - .../github-electron.power-monitor.d.ts | 32 - .../github-electron.power-save-blocker.d.ts | 29 - github-electron/github-electron.protocol.d.ts | 121 - github-electron/github-electron.remote.d.ts | 39 - github-electron/github-electron.screen.d.ts | 91 - github-electron/github-electron.session.d.ts | 318 -- github-electron/github-electron.shell.d.ts | 41 - github-electron/github-electron.tray.d.ts | 133 - .../github-electron.web-contents.d.ts | 748 ---- .../github-electron.web-frame.d.ts | 70 - 27 files changed, 3686 insertions(+), 3872 deletions(-) delete mode 100644 github-electron/github-electron.app.d.ts delete mode 100644 github-electron/github-electron.auto-updater.d.ts delete mode 100644 github-electron/github-electron.browser-window.d.ts delete mode 100644 github-electron/github-electron.clipboard.d.ts delete mode 100644 github-electron/github-electron.content-tracing.d.ts delete mode 100644 github-electron/github-electron.crash-reporter.d.ts delete mode 100644 github-electron/github-electron.desktop-capturer.d.ts delete mode 100644 github-electron/github-electron.dialog.d.ts delete mode 100644 github-electron/github-electron.dom.d.ts delete mode 100644 github-electron/github-electron.event-emitter.d.ts delete mode 100644 github-electron/github-electron.global-shortcut.d.ts delete mode 100644 github-electron/github-electron.ipc-main.d.ts delete mode 100644 github-electron/github-electron.ipc-renderer.d.ts delete mode 100644 github-electron/github-electron.menu-item.d.ts delete mode 100644 github-electron/github-electron.menu.d.ts delete mode 100644 github-electron/github-electron.native-image.d.ts delete mode 100644 github-electron/github-electron.power-monitor.d.ts delete mode 100644 github-electron/github-electron.power-save-blocker.d.ts delete mode 100644 github-electron/github-electron.protocol.d.ts delete mode 100644 github-electron/github-electron.remote.d.ts delete mode 100644 github-electron/github-electron.screen.d.ts delete mode 100644 github-electron/github-electron.session.d.ts delete mode 100644 github-electron/github-electron.shell.d.ts delete mode 100644 github-electron/github-electron.tray.d.ts delete mode 100644 github-electron/github-electron.web-contents.d.ts delete mode 100644 github-electron/github-electron.web-frame.d.ts diff --git a/github-electron/github-electron.app.d.ts b/github-electron/github-electron.app.d.ts deleted file mode 100644 index a47cd2cb07..0000000000 --- a/github-electron/github-electron.app.d.ts +++ /dev/null @@ -1,377 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// - -declare namespace Electron { - /** - * The app module is responsible for controlling the application's lifecycle. - */ - class App extends EventEmitter { - /** - * Emitted when the application has finished basic startup. - * On Windows and Linux, the will-finish-launching event - * is the same as the ready event; on OS X, this event represents - * the applicationWillFinishLaunching notification of NSApplication. - * You would usually set up listeners for the open-file and open-url events here, - * and start the crash reporter and auto updater. - * - * In most cases, you should just do everything in the ready event handler. - */ - on(event: 'will-finish-launching', listener: Function): this; - /** - * Emitted when Electron has finished initialization. - */ - on(event: 'ready', listener: Function): this; - /** - * Emitted when all windows have been closed. - * - * This event is only emitted when the application is not going to quit. - * If the user pressed Cmd + Q, or the developer called app.quit(), - * Electron will first try to close all the windows and then emit the will-quit event, - * and in this case the window-all-closed event would not be emitted. - */ - on(event: 'window-all-closed', listener: Function): this; - /** - * Emitted before the application starts closing its windows. - * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. - */ - on(event: 'before-quit', listener: (event: Event) => void): this; - /** - * Emitted when all windows have been closed and the application will quit. - * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. - */ - on(event: 'will-quit', listener: (event: Event) => void): this; - /** - * Emitted when the application is quitting. - */ - on(event: 'quit', listener: (event: Event, exitCode: number) => void): this; - /** - * Emitted when the user wants to open a file with the application. - * The open-file event is usually emitted when the application is already open - * and the OS wants to reuse the application to open the file. - * open-file is also emitted when a file is dropped onto the dock and the application - * is not yet running. Make sure to listen for the open-file event very early - * in your application startup to handle this case (even before the ready event is emitted). - * - * You should call event.preventDefault() if you want to handle this event. - * - * Note: This is only implemented on OS X. - */ - on(event: 'open-file', listener: (event: Event, url: string) => void): this; - /** - * Emitted when the user wants to open a URL with the application. - * The URL scheme must be registered to be opened by your application. - * - * You should call event.preventDefault() if you want to handle this event. - * - * Note: This is only implemented on OS X. - */ - on(event: 'open-url', listener: (event: Event, url: string) => void): this; - /** - * Emitted when the application is activated, which usually happens when clicks on the applications’s dock icon. - * Note: This is only implemented on OS X. - */ - on(event: 'activate', listener: Function): this; - /** - * Emitted when a browserWindow gets blurred. - */ - on(event: 'browser-window-blur', listener: (event: Event, browserWindow: BrowserWindow) => void): this; - /** - * Emitted when a browserWindow gets focused. - */ - on(event: 'browser-window-focus', listener: (event: Event, browserWindow: BrowserWindow) => void): this; - /** - * Emitted when a new browserWindow is created. - */ - on(event: 'browser-window-created', listener: (event: Event, browserWindow: BrowserWindow) => void): this; - /** - * Emitted when failed to verify the certificate for url, to trust the certificate - * you should prevent the default behavior with event.preventDefault() and call callback(true). - */ - on(event: 'certificate-error', listener: (event: Event, - webContents: WebContents, - url: string, - error: string, - certificate: Certificate, - callback: (trust: boolean) => void - ) => void): this; - /** - * Emitted when a client certificate is requested. - * - * The url corresponds to the navigation entry requesting the client certificate - * and callback needs to be called with an entry filtered from the list. - * Using event.preventDefault() prevents the application from using the first certificate from the store. - */ - on(event: 'select-client-certificate', listener: (event: Event, - webContents: WebContents, - url: string, - certificateList: Certificate[], - callback: (certificate: Certificate) => void - ) => void): this; - /** - * Emitted when webContents wants to do basic auth. - * - * The default behavior is to cancel all authentications, to override this - * you should prevent the default behavior with event.preventDefault() - * and call callback(username, password) with the credentials. - */ - on(event: 'login', listener: (event: Event, - webContents: WebContents, - request: LoginRequest, - authInfo: LoginAuthInfo, - callback: (username: string, password: string) => void - ) => void): this; - /** - * Emitted when the gpu process crashes. - */ - on(event: 'gpu-process-crashed', listener: Function): this; - /** - * Emitted when the system’s Dark Mode theme is toggled. - * Note: This is only implemented on OS X. - */ - on(event: 'platform-theme-changed', listener: Function): this; - on(event: string, listener: Function): this; - /** - * Try to close all windows. The before-quit event will first be emitted. - * If all windows are successfully closed, the will-quit event will be emitted - * and by default the application would be terminated. - * - * This method guarantees all beforeunload and unload handlers are correctly - * executed. It is possible that a window cancels the quitting by returning - * false in beforeunload handler. - */ - quit(): void; - /** - * Exits immediately with exitCode. - * All windows will be closed immediately without asking user - * and the before-quit and will-quit events will not be emitted. - */ - exit(exitCode: number): void; - /** - * On Linux, focuses on the first visible window. - * On OS X, makes the application the active app. - * On Windows, focuses on the application’s first window. - */ - focus(): void; - /** - * Hides all application windows without minimizing them. - * Note: This is only implemented on OS X. - */ - hide(): void; - /** - * Shows application windows after they were hidden. Does not automatically focus them. - * Note: This is only implemented on OS X. - */ - show(): void; - /** - * Returns the current application directory. - */ - getAppPath(): string; - /** - * @returns The path to a special directory or file associated with name. - * On failure an Error would throw. - */ - getPath(name: AppPathName): string; - /** - * Overrides the path to a special directory or file associated with name. - * If the path specifies a directory that does not exist, the directory will - * be created by this method. On failure an Error would throw. - * - * You can only override paths of names defined in app.getPath. - * - * By default web pages' cookies and caches will be stored under userData - * directory, if you want to change this location, you have to override the - * userData path before the ready event of app module gets emitted. - */ - setPath(name: AppPathName, path: string): void; - /** - * @returns The version of loaded application, if no version is found in - * application's package.json, the version of current bundle or executable. - */ - getVersion(): string; - /** - * - * @returns The current application's name, the name in package.json would be used. - * Usually the name field of package.json is a short lowercased name, according to - * the spec of npm modules. So usually you should also specify a productName field, - * which is your application's full capitalized name, and it will be preferred over - * name by Electron. - */ - getName(): string; - /** - * @returns The current application locale. - **/ - getLocale(): string; - /** - * Adds path to recent documents list. - * - * This list is managed by the system, on Windows you can visit the list from - * task bar, and on Mac you can visit it from dock menu. - * - * Note: This is only implemented on OS X and Windows. - */ - addRecentDocument(path: string): void; - /** - * Clears the recent documents list. - * - * Note: This is only implemented on OS X and Windows. - */ - clearRecentDocuments(): void; - /** - * Adds tasks to the Tasks category of JumpList on Windows. - * - * Note: This API is only available on Windows. - */ - setUserTasks(tasks: Task[]): void; - /** - * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication. - * Normally, Electron will only send NTLM/Kerberos credentials for URLs that fall under - * "Local Intranet" sites (i.e. are in the same domain as you). - * However, this detection often fails when corporate networks are badly configured, - * so this lets you co-opt this behavior and enable it for all URLs. - */ - allowNTLMCredentialsForAllDomains(allow: boolean): void; - /** - * This method makes your application a Single Instance Application instead of allowing - * multiple instances of your app to run, this will ensure that only a single instance - * of your app is running, and other instances signal this instance and exit. - */ - makeSingleInstance(callback: (args: string[], workingDirectory: string) => boolean): boolean; - /** - * Changes the Application User Model ID to id. - */ - setAppUserModelId(id: string): void; - /** - * This method returns true if DWM composition (Aero Glass) is enabled, - * and false otherwise. You can use it to determine if you should create - * a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled). - * - * Note: This is only implemented on Windows. - */ - isAeroGlassEnabled(): boolean; - /** - * @returns If the system is in Dark Mode. - * Note: This is only implemented on OS X. - */ - isDarkMode(): boolean; - commandLine: CommandLine; - /** - * Note: This API is only available on Mac. - */ - dock: Dock; - } - - type AppPathName = 'home'|'appData'|'userData'|'temp'|'exe'|'module'|'desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'; - - interface CommandLine { - /** - * Append a switch [with optional value] to Chromium's command line. - * - * Note: This will not affect process.argv, and is mainly used by developers - * to control some low-level Chromium behaviors. - */ - appendSwitch(_switch: string, value?: string|number): void; - /** - * Append an argument to Chromium's command line. The argument will quoted properly. - * - * Note: This will not affect process.argv. - */ - appendArgument(value: any): void; - } - - interface Dock { - /** - * When critical is passed, the dock icon will bounce until either the - * application becomes active or the request is canceled. - * - * When informational is passed, the dock icon will bounce for one second. - * However, the request remains active until either the application becomes - * active or the request is canceled. - * - * @param type The default is informational. - * @returns An ID representing the request. - */ - bounce(type?: 'critical' | 'informational'): number; - /** - * Cancel the bounce of id. - * - * Note: This API is only available on Mac. - */ - cancelBounce(id: number): void; - /** - * Sets the string to be displayed in the dock’s badging area. - * - * Note: This API is only available on Mac. - */ - setBadge(text: string): void; - /** - * Returns the badge string of the dock. - * - * Note: This API is only available on Mac. - */ - getBadge(): string; - /** - * Hides the dock icon. - * - * Note: This API is only available on Mac. - */ - hide(): void; - /** - * Shows the dock icon. - * - * Note: This API is only available on Mac. - */ - show(): void; - /** - * Sets the application dock menu. - * - * Note: This API is only available on Mac. - */ - setMenu(menu: Menu): void; - /** - * Sets the image associated with this dock icon. - * - * Note: This API is only available on Mac. - */ - setIcon(icon: NativeImage | string): void; - } - - interface Task { - /** - * Path of the program to execute, usually you should specify process.execPath - * which opens current program. - */ - program: string; - /** - * The arguments of command line when program is executed. - */ - arguments: string; - /** - * The string to be displayed in a JumpList. - */ - title: string; - /** - * Description of this task. - */ - description?: string; - /** - * The absolute path to an icon to be displayed in a JumpList, it can be - * arbitrary resource file that contains an icon, usually you can specify - * process.execPath to show the icon of the program. - */ - iconPath: string; - /** - * The icon index in the icon file. If an icon file consists of two or more - * icons, set this value to identify the icon. If an icon file consists of - * one icon, this value is 0. - */ - iconIndex?: number; - } -} diff --git a/github-electron/github-electron.auto-updater.d.ts b/github-electron/github-electron.auto-updater.d.ts deleted file mode 100644 index 48d4e22f4c..0000000000 --- a/github-electron/github-electron.auto-updater.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * This module provides an interface for the Squirrel auto-updater framework. - */ - class AutoUpdater extends EventEmitter { - /** - * Emitted when there is an error while updating. - */ - on(event: 'error', listener: (error: Error) => void): this; - /** - * Emitted when checking if an update has started. - */ - on(event: 'checking-for-update', listener: Function): this; - /** - * Emitted when there is an available update. The update is downloaded automatically. - */ - on(event: 'update-available', listener: Function): this; - /** - * Emitted when there is no available update. - */ - on(event: 'update-not-available', listener: Function): this; - /** - * Emitted when an update has been downloaded. - * Note: On Windows only releaseName is available. - */ - on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; - on(event: string, listener: Function): this; - /** - * Set the url and initialize the auto updater. - * The url cannot be changed once it is set. - */ - setFeedURL(url: string): void; - /** - * Ask the server whether there is an update, you have to call setFeedURL - * before using this API - */ - checkForUpdates(): any; - /** - * Restarts the app and installs the update after it has been downloaded. - * It should only be called after update-downloaded has been emitted. - */ - quitAndInstall(): void; - } -} diff --git a/github-electron/github-electron.browser-window.d.ts b/github-electron/github-electron.browser-window.d.ts deleted file mode 100644 index 35383a90af..0000000000 --- a/github-electron/github-electron.browser-window.d.ts +++ /dev/null @@ -1,889 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// -/// - -declare namespace Electron { - /** - * The BrowserWindow class gives you ability to create a browser window. - * You can also create a window without chrome by using Frameless Window API. - */ - class BrowserWindow extends EventEmitter { - /** - * Emitted when the document changed its title, - * calling event.preventDefault() would prevent the native window’s title to change. - */ - on(event: 'page-title-updated', listener: (event: Event) => void): this; - /** - * Emitted when the window is going to be closed. It’s emitted before the beforeunload - * and unload event of the DOM. Calling event.preventDefault() will cancel the close. - */ - on(event: 'close', listener: (event: Event) => void): this; - /** - * Emitted when the window is closed. After you have received this event - * you should remove the reference to the window and avoid using it anymore. - */ - on(event: 'closed', listener: Function): this; - /** - * Emitted when the web page becomes unresponsive. - */ - on(event: 'unresponsive', listener: Function): this; - /** - * Emitted when the unresponsive web page becomes responsive again. - */ - on(event: 'responsive', listener: Function): this; - /** - * Emitted when the window loses focus. - */ - on(event: 'blur', listener: Function): this; - /** - * Emitted when the window gains focus. - */ - on(event: 'focus', listener: Function): this; - /** - * Emitted when the window is shown. - */ - on(event: 'show', listener: Function): this; - /** - * Emitted when the window is hidden. - */ - on(event: 'hide', listener: Function): this; - /** - * Emitted when window is maximized. - */ - on(event: 'maximize', listener: Function): this; - /** - * Emitted when the window exits from maximized state. - */ - on(event: 'unmaximize', listener: Function): this; - /** - * Emitted when the window is minimized. - */ - on(event: 'minimize', listener: Function): this; - /** - * Emitted when the window is restored from minimized state. - */ - on(event: 'restore', listener: Function): this; - /** - * Emitted when the window is getting resized. - */ - on(event: 'resize', listener: Function): this; - /** - * Emitted when the window is getting moved to a new position. - */ - on(event: 'move', listener: Function): this; - /** - * Emitted when the window enters full screen state. - */ - on(event: 'enter-full-screen', listener: Function): this; - /** - * Emitted when the window leaves full screen state. - */ - on(event: 'leave-full-screen', listener: Function): this; - /** - * Emitted when the window enters full screen state triggered by HTML API. - */ - on(event: 'enter-html-full-screen', listener: Function): this; - /** - * Emitted when the window leaves full screen state triggered by HTML API. - */ - on(event: 'leave-html-full-screen', listener: Function): this; - /** - * Emitted when an App Command is invoked. These are typically related - * to keyboard media keys or browser commands, as well as the "Back" / - * "Forward" buttons built into some mice on Windows. - * Note: This is only implemented on Windows. - */ - on(event: 'app-command', listener: (event: Event, command: string) => void): this; - /** - * Emitted when scroll wheel event phase has begun. - * Note: This is only implemented on OS X. - */ - on(event: 'scroll-touch-begin', listener: Function): this; - /** - * Emitted when scroll wheel event phase has ended. - * Note: This is only implemented on OS X. - */ - on(event: 'scroll-touch-end', listener: Function): this; - on(event: string, listener: Function): this; - constructor(options?: BrowserWindowOptions); - /** - * @returns All opened browser windows. - */ - static getAllWindows(): BrowserWindow[]; - /** - * @returns The window that is focused in this application. - */ - static getFocusedWindow(): BrowserWindow; - /** - * Find a window according to the webContents it owns. - */ - static fromWebContents(webContents: WebContents): BrowserWindow; - /** - * Find a window according to its ID. - */ - static fromId(id: number): BrowserWindow; - /** - * Adds devtools extension located at path. The extension will be remembered - * so you only need to call this API once, this API is not for programming use. - * @returns The extension's name. - */ - static addDevToolsExtension(path: string): string; - /** - * Remove a devtools extension. - * @param name The name of the devtools extension to remove. - */ - static removeDevToolsExtension(name: string): void; - /** - * The WebContents object this window owns, all web page related events and - * operations would be done via it. - * Note: Users should never store this object because it may become null when - * the renderer process (web page) has crashed. - */ - webContents: WebContents; - /** - * Get the unique ID of this window. - */ - id: number; - /** - * Force closing the window, the unload and beforeunload event won't be emitted - * for the web page, and close event would also not be emitted for this window, - * but it would guarantee the closed event to be emitted. - * You should only use this method when the renderer process (web page) has crashed. - */ - destroy(): void; - /** - * Try to close the window, this has the same effect with user manually clicking - * the close button of the window. The web page may cancel the close though, - * see the close event. - */ - close(): void; - /** - * Focus on the window. - */ - focus(): void; - /** - * Remove focus on the window. - */ - blur(): void; - /** - * @returns Whether the window is focused. - */ - isFocused(): boolean; - /** - * Shows and gives focus to the window. - */ - show(): void; - /** - * Shows the window but doesn't focus on it. - */ - showInactive(): void; - /** - * Hides the window. - */ - hide(): void; - /** - * @returns Whether the window is visible to the user. - */ - isVisible(): boolean; - /** - * Maximizes the window. - */ - maximize(): void; - /** - * Unmaximizes the window. - */ - unmaximize(): void; - /** - * @returns Whether the window is maximized. - */ - isMaximized(): boolean; - /** - * Minimizes the window. On some platforms the minimized window will be - * shown in the Dock. - */ - minimize(): void; - /** - * Restores the window from minimized state to its previous state. - */ - restore(): void; - /** - * @returns Whether the window is minimized. - */ - isMinimized(): boolean; - /** - * Sets whether the window should be in fullscreen mode. - */ - setFullScreen(flag: boolean): void; - /** - * @returns Whether the window is in fullscreen mode. - */ - isFullScreen(): boolean; - /** - * This will have a window maintain an aspect ratio. - * The extra size allows a developer to have space, specified in pixels, - * not included within the aspect ratio calculations. - * This API already takes into account the difference between a window’s size and its content size. - * - * Note: This API is available only on OS X. - */ - setAspectRatio(aspectRatio: number, extraSize?: { - width: number, - height: number - }): void; - /** - * Resizes and moves the window to width, height, x, y. - */ - setBounds(options: Rectangle, animate?: boolean): void; - /** - * @returns The window's width, height, x and y values. - */ - getBounds(): Rectangle; - /** - * Resizes the window to width and height. - */ - setSize(width: number, height: number, animate?: boolean): void; - /** - * @returns The window's width and height. - */ - getSize(): number[]; - /** - * Resizes the window's client area (e.g. the web page) to width and height. - */ - setContentSize(width: number, height: number, animate?: boolean): void; - /** - * @returns The window's client area's width and height. - */ - getContentSize(): number[]; - /** - * Sets the minimum size of window to width and height. - */ - setMinimumSize(width: number, height: number): void; - /** - * @returns The window's minimum width and height. - */ - getMinimumSize(): number[]; - /** - * Sets the maximum size of window to width and height. - */ - setMaximumSize(width: number, height: number): void; - /** - * @returns The window's maximum width and height. - */ - getMaximumSize(): number[]; - /** - * Sets whether the window can be manually resized by user. - */ - setResizable(resizable: boolean): void; - /** - * @returns Whether the window can be manually resized by user. - */ - isResizable(): boolean; - /** - * Sets whether the window can be moved by user. On Linux does nothing. - * Note: This API is available only on OS X and Windows. - */ - setMovable(movable: boolean): void; - /** - * Note: This API is available only on OS X and Windows. - * @returns Whether the window can be moved by user. On Linux always returns true. - */ - isMovable(): boolean; - /** - * Sets whether the window can be manually minimized by user. On Linux does nothing. - * Note: This API is available only on OS X and Windows. - */ - setMinimizable(minimizable: boolean): void; - /** - * Note: This API is available only on OS X and Windows. - * @returns Whether the window can be manually minimized by user. On Linux always returns true. - */ - isMinimizable(): boolean; - /** - * Sets whether the window can be manually maximized by user. On Linux does nothing. - * Note: This API is available only on OS X and Windows. - */ - setMaximizable(maximizable: boolean): void; - /** - * Note: This API is available only on OS X and Windows. - * @returns Whether the window can be manually maximized by user. On Linux always returns true. - */ - isMaximizable(): boolean; - /** - * Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. - */ - setFullScreenable(fullscreenable: boolean): void; - /** - * @returns Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. - */ - isFullScreenable(): boolean; - /** - * Sets whether the window can be manually closed by user. On Linux does nothing. - * Note: This API is available only on OS X and Windows. - */ - setClosable(closable: boolean): void; - /** - * Note: This API is available only on OS X and Windows. - * @returns Whether the window can be manually closed by user. On Linux always returns true. - */ - isClosable(): boolean; - /** - * Sets whether the window should show always on top of other windows. After - * setting this, the window is still a normal window, not a toolbox window - * which can not be focused on. - */ - setAlwaysOnTop(flag: boolean): void; - /** - * @returns Whether the window is always on top of other windows. - */ - isAlwaysOnTop(): boolean; - /** - * Moves window to the center of the screen. - */ - center(): void; - /** - * Moves window to x and y. - */ - setPosition(x: number, y: number, animate?: boolean): void; - /** - * @returns The window's current position. - */ - getPosition(): number[]; - /** - * Changes the title of native window to title. - */ - setTitle(title: string): void; - /** - * Note: The title of web page can be different from the title of the native window. - * @returns The title of the native window. - */ - getTitle(): string; - /** - * Starts or stops flashing the window to attract user's attention. - */ - flashFrame(flag: boolean): void; - /** - * Makes the window do not show in Taskbar. - */ - setSkipTaskbar(skip: boolean): void; - /** - * Enters or leaves the kiosk mode. - */ - setKiosk(flag: boolean): void; - /** - * @returns Whether the window is in kiosk mode. - */ - isKiosk(): boolean; - /** - * The native type of the handle is HWND on Windows, NSView* on OS X, - * and Window (unsigned long) on Linux. - * @returns The platform-specific handle of the window as Buffer. - */ - getNativeWindowHandle(): Buffer; - /** - * Hooks a windows message. The callback is called when the message is received in the WndProc. - * Note: This API is available only on Windows. - */ - hookWindowMessage(message: number, callback: Function): void; - /** - * @returns Whether the message is hooked. - */ - isWindowMessageHooked(message: number): boolean; - /** - * Unhook the window message. - */ - unhookWindowMessage(message: number): void; - /** - * Unhooks all of the window messages. - */ - unhookAllWindowMessages(): void; - /** - * Sets the pathname of the file the window represents, and the icon of the - * file will show in window's title bar. - * Note: This API is available only on OS X. - */ - setRepresentedFilename(filename: string): void; - /** - * Note: This API is available only on OS X. - * @returns The pathname of the file the window represents. - */ - getRepresentedFilename(): string; - /** - * Specifies whether the window’s document has been edited, and the icon in - * title bar will become grey when set to true. - * Note: This API is available only on OS X. - */ - setDocumentEdited(edited: boolean): void; - /** - * Note: This API is available only on OS X. - * @returns Whether the window's document has been edited. - */ - isDocumentEdited(): boolean; - focusOnWebView(): void; - blurWebView(): void; - /** - * Captures the snapshot of page within rect, upon completion the callback - * will be called. Omitting the rect would capture the whole visible page. - * Note: Be sure to read documents on remote buffer in remote if you are going - * to use this API in renderer process. - * @param callback Supplies the image that stores data of the snapshot. - */ - capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; - capturePage(callback: (image: NativeImage) => void): void; - /** - * Same with webContents.print([options]) - */ - print(options?: { - silent?: boolean; - printBackground?: boolean; - }): void; - /** - * Same with webContents.printToPDF([options]) - */ - printToPDF(options: { - marginsType?: number; - pageSize?: string; - printBackground?: boolean; - printSelectionOnly?: boolean; - landscape?: boolean; - }, callback: (error: Error, data: Buffer) => void): void; - /** - * Same with webContents.loadURL(url). - */ - loadURL(url: string, options?: { - httpReferrer?: string; - userAgent?: string; - extraHeaders?: string; - }): void; - /** - * Same with webContents.reload. - */ - reload(): void; - /** - * Sets the menu as the window top menu. - * Note: This API is not available on OS X. - */ - setMenu(menu: Menu): void; - /** - * Sets the progress value in the progress bar. - * On Linux platform, only supports Unity desktop environment, you need to - * specify the *.desktop file name to desktopName field in package.json. - * By default, it will assume app.getName().desktop. - * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed. - * If greater than 0, it becomes indeterminate. - */ - setProgressBar(progress: number): void; - /** - * Sets a 16px overlay onto the current Taskbar icon, usually used to convey - * some sort of application status or to passively notify the user. - * Note: This API is only available on Windows 7 or above. - * @param overlay The icon to display on the bottom right corner of the Taskbar - * icon. If this parameter is null, the overlay is cleared - * @param description Provided to Accessibility screen readers. - */ - setOverlayIcon(overlay: NativeImage, description: string): void; - /** - * Sets whether the window should have a shadow. On Windows and Linux does nothing. - * Note: This API is available only on OS X. - */ - setHasShadow(hasShadow: boolean): void; - /** - * Note: This API is available only on OS X. - * @returns whether the window has a shadow. On Windows and Linux always returns true. - */ - hasShadow(): boolean; - /** - * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image - * of a window in a taskbar button layout. - * @returns Whether the thumbnail has been added successfully. - */ - setThumbarButtons(buttons: ThumbarButton[]): boolean; - /** - * Shows pop-up dictionary that searches the selected word on the page. - * Note: This API is available only on OS X. - */ - showDefinitionForSelection(): void; - /** - * Sets whether the window menu bar should hide itself automatically. Once set - * the menu bar will only show when users press the single Alt key. - * If the menu bar is already visible, calling setAutoHideMenuBar(true) won't - * hide it immediately. - */ - setAutoHideMenuBar(hide: boolean): void; - /** - * @returns Whether menu bar automatically hides itself. - */ - isMenuBarAutoHide(): boolean; - /** - * Sets whether the menu bar should be visible. If the menu bar is auto-hide, - * users can still bring up the menu bar by pressing the single Alt key. - */ - setMenuBarVisibility(visibile: boolean): void; - /** - * @returns Whether the menu bar is visible. - */ - isMenuBarVisible(): boolean; - /** - * Sets whether the window should be visible on all workspaces. - * Note: This API does nothing on Windows. - */ - setVisibleOnAllWorkspaces(visible: boolean): void; - /** - * Note: This API always returns false on Windows. - * @returns Whether the window is visible on all workspaces. - */ - isVisibleOnAllWorkspaces(): boolean; - /** - * Ignore all moused events that happened in the window. - * Note: This API is available only on OS X. - */ - setIgnoreMouseEvents(ignore: boolean): void; - } - - type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive'; - - interface ThumbarButton { - icon: NativeImage | string; - click: Function; - tooltip?: string; - flags?: ThumbarButtonFlags[]; - } - - interface WebPreferences { - /** - * Whether node integration is enabled. - * Default: true. - */ - nodeIntegration?: boolean; - /** - * Specifies a script that will be loaded before other scripts run in the page. - * This script will always have access to node APIs no matter whether node integration is turned on or off. - * The value should be the absolute file path to the script. - * When node integration is turned off, the preload script can reintroduce - * Node global symbols back to the global scope. - */ - preload?: string; - /** - * Sets the session used by the page. Instead of passing the Session object directly, - * you can also choose to use the partition option instead, which accepts a partition string. - * When both session and partition are provided, session would be preferred. - * Default: the default session. - */ - session?: Session; - /** - * Sets the session used by the page according to the session’s partition string. - * If partition starts with persist:, the page will use a persistent session available - * to all pages in the app with the same partition. if there is no persist: prefix, - * the page will use an in-memory session. By assigning the same partition, - * multiple pages can share the same session. - * Default: the default session. - */ - partition?: string; - /** - * The default zoom factor of the page, 3.0 represents 300%. - * Default: 1.0. - */ - zoomFactor?: number; - /** - * Enables JavaScript support. - * Default: true. - */ - javascript?: boolean; - /** - * When setting false, it will disable the same-origin policy (Usually using testing - * websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent - * to true if these two options are not set by user. - * Default: true. - */ - webSecurity?: boolean; - /** - * Allow an https page to display content like images from http URLs. - * Default: false. - */ - allowDisplayingInsecureContent?: boolean; - /** - * Allow a https page to run JavaScript, CSS or plugins from http URLs. - * Default: false. - */ - allowRunningInsecureContent?: boolean; - /** - * Enables image support. - * Default: true. - */ - images?: boolean; - /** - * Make TextArea elements resizable. - * Default: true. - */ - textAreasAreResizable?: boolean; - /** - * Enables WebGL support. - * Default: true. - */ - webgl?: boolean; - /** - * Enables WebAudio support. - * Default: true. - */ - webaudio?: boolean; - /** - * Whether plugins should be enabled. - * Default: false. - */ - plugins?: boolean; - /** - * Enables Chromium’s experimental features. - * Default: false. - */ - experimentalFeatures?: boolean; - /** - * Enables Chromium’s experimental canvas features. - * Default: false. - */ - experimentalCanvasFeatures?: boolean; - /** - * Enables DirectWrite font rendering system on Windows. - * Default: true. - */ - directWrite?: boolean; - /** - * A list of feature strings separated by ",". - */ - blinkFeatures?: string; - /** - * Sets the default font for the font-family. - */ - defaultFontFamily?: { - /** - * Default: Times New Roman. - */ - standard?: string; - /** - * Default: Times New Roman. - */ - serif?: string; - /** - * Default: Arial. - */ - sansSerif?: string; - /** - * Default: Courier New. - */ - monospace?: string; - }; - /** - * Default: 16. - */ - defaultFontSize?: number; - /** - * Default: 13. - */ - defaultMonospaceFontSize?: number; - /** - * Default: 0. - */ - minimumFontSize?: number; - /** - * Default: ISO-8859-1. - */ - defaultEncoding?: string; - } - - interface BrowserWindowOptions extends Rectangle { - /** - * Window’s width in pixels. - * Default: 800. - */ - width?: number; - /** - * Window’s height in pixels. - * Default: 600. - */ - height?: number; - /** - * Window’s left offset from screen. - * Default: center the window. - */ - x?: number; - /** - * Window’s top offset from screen. - * Default: center the window. - */ - y?: number; - /** - * The width and height would be used as web page’s size, which means - * the actual window’s size will include window frame’s size and be slightly larger. - * Default: false. */ - useContentSize?: boolean; - /** - * Show window in the center of the screen. - * Default: true - */ - center?: boolean; - /** - * Window’s minimum width. - * Default: 0. - */ - minWidth?: number; - /** - * Window’s minimum height. - * Default: 0. - */ - minHeight?: number; - /** - * Window’s maximum width. - * Default: no limit. - */ - maxWidth?: number; - /** - * Window’s maximum height. - * Default: no limit. - */ - maxHeight?: number; - /** - * Whether window is resizable. - * Default: true. - */ - resizable?: boolean; - /** - * Whether window is movable. - * Note: This is not implemented on Linux. - * Default: true. - */ - movable?: boolean; - /** - * Whether window is minimizable. - * Note: This is not implemented on Linux. - * Default: true. - */ - minimizable?: boolean; - /** - * Whether window is maximizable. - * Note: This is not implemented on Linux. - * Default: true. - */ - maximizable?: boolean; - /** - * Whether window is closable. - * Note: This is not implemented on Linux. - * Default: true. - */ - closable?: boolean; - /** - * Whether the window should always stay on top of other windows. - * Default: false. - */ - alwaysOnTop?: boolean; - /** - * Whether the window should show in fullscreen. - * When explicity set to false the fullscreen button will be hidden or disabled on OS X. - * Default: false. - */ - fullscreen?: boolean; - /** - * Whether the maximize/zoom button on OS X should toggle full screen mode or maximize window. - * Default: true. - */ - fullscreenable?: boolean; - /** - * Whether to show the window in taskbar. - * Default: false. - */ - skipTaskbar?: boolean; - /** - * The kiosk mode. - * Default: false. - */ - kiosk?: boolean; - /** - * Default window title. - * Default: "Electron". - */ - title?: string; - /** - *The window icon, when omitted on Windows the executable’s icon would be used as window icon. - */ - icon?: NativeImage|string; - /** - * Whether window should be shown when created. - * Default: true. - */ - show?: boolean; - /** - * Specify false to create a Frameless Window. - * Default: true. - */ - frame?: boolean; - /** - * Whether the web view accepts a single mouse-down event that simultaneously activates the window. - * Default: false. - */ - acceptFirstMouse?: boolean; - /** - * Whether to hide cursor when typing. - * Default: false. - */ - disableAutoHideCursor?: boolean; - /** - * Auto hide the menu bar unless the Alt key is pressed. - * Default: true. - */ - autoHideMenuBar?: boolean; - /** - * Enable the window to be resized larger than screen. - * Default: false. - */ - enableLargerThanScreen?: boolean; - /** - * Window’s background color as Hexadecimal value, like #66CD00 or #FFF or #80FFFFFF (alpha is supported). - * Default: #000 (black) for Linux and Windows, #FFF for Mac (or clear if transparent). - */ - backgroundColor?: string; - /** - * Whether window should have a shadow. - * Note: This is only implemented on OS X. - * Default: true. - */ - hasShadow?: boolean; - /** - * Forces using dark theme for the window. - * Note: Only works on some GTK+3 desktop environments. - * Default: false. - */ - darkTheme?: boolean; - /** - * Makes the window transparent. - * Default: false. - */ - transparent?: boolean; - /** - * The type of window, default is normal window. - */ - type?: BrowserWindowType; - /** - * The style of window title bar. - */ - titleBarStyle?: 'default' | 'hidden' | 'hidden-inset'; - /** - * Settings of web page’s features. - */ - webPreferences?: WebPreferences; - } - - type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac; - type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification'; - type BrowserWindowTypeMac = 'desktop' | 'textured'; - - interface Rectangle { - x?: number; - y?: number; - width?: number; - height?: number; - } -} diff --git a/github-electron/github-electron.clipboard.d.ts b/github-electron/github-electron.clipboard.d.ts deleted file mode 100644 index 5307a775d3..0000000000 --- a/github-electron/github-electron.clipboard.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The clipboard module provides methods to perform copy and paste operations. - */ - interface Clipboard { - /** - * @returns The contents of the clipboard as plain text. - */ - readText(type?: ClipboardType): string; - /** - * Writes the text into the clipboard as plain text. - */ - writeText(text: string, type?: ClipboardType): void; - /** - * @returns The contents of the clipboard as markup. - */ - readHtml(type?: ClipboardType): string; - /** - * Writes markup to the clipboard. - */ - writeHtml(markup: string, type?: ClipboardType): void; - /** - * @returns The contents of the clipboard as a NativeImage. - */ - readImage(type?: ClipboardType): NativeImage; - /** - * Writes the image into the clipboard. - */ - writeImage(image: NativeImage, type?: ClipboardType): void; - /** - * @returns The contents of the clipboard as RTF. - */ - readRtf(type?: ClipboardType): string; - /** - * Writes the text into the clipboard in RTF. - */ - writeRtf(text: string, type?: ClipboardType): void; - /** - * Clears everything in clipboard. - */ - clear(type?: ClipboardType): void; - /** - * @returns Array available formats for the clipboard type. - */ - availableFormats(type?: ClipboardType): string[]; - /** - * Returns whether the clipboard supports the format of specified data. - * Note: This API is experimental and could be removed in future. - * @returns Whether the clipboard has data in the specified format. - */ - has(format: string, type?: ClipboardType): boolean; - /** - * Reads the data in the clipboard of the specified format. - * Note: This API is experimental and could be removed in future. - */ - read(format: string, type?: ClipboardType): any; - /** - * Writes data to the clipboard. - */ - write(data: { - text?: string; - rtf?: string; - html?: string; - image?: NativeImage; - }, type?: ClipboardType): void; - } - - type ClipboardType = '' | 'selection'; -} diff --git a/github-electron/github-electron.content-tracing.d.ts b/github-electron/github-electron.content-tracing.d.ts deleted file mode 100644 index 01a5737442..0000000000 --- a/github-electron/github-electron.content-tracing.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The content-tracing module is used to collect tracing data generated by the underlying Chromium content module. - * This module does not include a web interface so you need to open chrome://tracing/ - * in a Chrome browser and load the generated file to view the result. - */ - interface ContentTracing { - /** - * Get a set of category groups. The category groups can change as new code paths are reached. - * @param callback Called once all child processes have acked to the getCategories request. - */ - getCategories(callback: (categoryGroups: any[]) => void): void; - /** - * Start recording on all processes. Recording begins immediately locally, and asynchronously - * on child processes as soon as they receive the EnableRecording request. - * @param categoryFilter A filter to control what category groups should be traced. - * A filter can have an optional "-" prefix to exclude category groups that contain - * a matching category. Having both included and excluded category patterns in the - * same list would not be supported. - * @param options controls what kind of tracing is enabled, it could be a OR-ed - * combination of tracing.DEFAULT_OPTIONS, tracing.ENABLE_SYSTRACE, tracing.ENABLE_SAMPLING - * and tracing.RECORD_CONTINUOUSLY. - * @param callback Called once all child processes have acked to the startRecording request. - */ - startRecording(categoryFilter: string, options: number, callback: Function): void; - /** - * Stop recording on all processes. Child processes typically are caching trace data and - * only rarely flush and send trace data back to the main process. That is because it may - * be an expensive operation to send the trace data over IPC, and we would like to avoid - * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all - * child processes to flush any pending trace data. - * @param resultFilePath Trace data will be written into this file if it is not empty, - * or into a temporary file. - * @param callback Called once all child processes have acked to the stopRecording request. - */ - stopRecording(resultFilePath: string, callback: - /** - * @param filePath A file that contains the traced data. - */ - (filePath: string) => void - ): void; - /** - * Start monitoring on all processes. Monitoring begins immediately locally, and asynchronously - * on child processes as soon as they receive the startMonitoring request. - * @param callback Called once all child processes have acked to the startMonitoring request. - */ - startMonitoring(categoryFilter: string, options: number, callback: Function): void; - /** - * Stop monitoring on all processes. - * @param callback Called once all child processes have acked to the stopMonitoring request. - */ - stopMonitoring(callback: Function): void; - /** - * Get the current monitoring traced data. Child processes typically are caching trace data - * and only rarely flush and send trace data back to the main process. That is because it may - * be an expensive operation to send the trace data over IPC, and we would like to avoid much - * runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child - * processes to flush any pending trace data. - * @param callback Called once all child processes have acked to the captureMonitoringSnapshot request. - */ - captureMonitoringSnapshot(resultFilePath: string, callback: - /** - * @param filePath A file that contains the traced data - * @returns {} - */ - (filePath: string) => void - ): void; - /** - * Get the maximum across processes of trace buffer percent full state. - * @param callback Called when the TraceBufferUsage value is determined. - */ - getTraceBufferUsage(callback: Function): void; - /** - * @param callback Called every time the given event occurs on any process. - */ - setWatchEvent(categoryName: string, eventName: string, callback: Function): void; - /** - * Cancel the watch event. If tracing is enabled, this may race with the watch event callback. - */ - cancelWatchEvent(): void; - DEFAULT_OPTIONS: number; - ENABLE_SYSTRACE: number; - ENABLE_SAMPLING: number; - RECORD_CONTINUOUSLY: number; - } -} diff --git a/github-electron/github-electron.crash-reporter.d.ts b/github-electron/github-electron.crash-reporter.d.ts deleted file mode 100644 index e26643938d..0000000000 --- a/github-electron/github-electron.crash-reporter.d.ts +++ /dev/null @@ -1,92 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The crash-reporter module enables sending your app's crash reports. - */ - interface CrashReporter { - /** - * You are required to call this method before using other crashReporter APIs. - */ - start(options: CrashReporterStartOptions): void; - /** - * @returns The date and ID of the last crash report. When there was no crash report - * sent or the crash reporter is not started, null will be returned. - */ - getLastCrashReport(): CrashReporterPayload; - /** - * @returns All uploaded crash reports. Each report contains the date and uploaded ID. - */ - getUploadedReports(): CrashReporterPayload[]; - } - - interface CrashReporterStartOptions { - /** - * Default: Electron - */ - productName?: string; - companyName: string; - /** - * URL that crash reports would be sent to as POST. - */ - submitURL: string; - /** - * Send the crash report without user interaction. - * Default: true. - */ - autoSubmit?: boolean; - /** - * Default: false. - */ - ignoreSystemCrashHandler?: boolean; - /** - * An object you can define which content will be send along with the report. - * Only string properties are send correctly. - * Nested objects are not supported. - */ - extra?: {[prop: string]: string}; - } - - interface CrashReporterPayload extends Object { - /** - * E.g., "electron-crash-service". - */ - rept: string; - /** - * The version of Electron. - */ - ver: string; - /** - * E.g., "win32". - */ - platform: string; - /** - * E.g., "renderer". - */ - process_type: string; - ptime: number; - /** - * The version in package.json. - */ - _version: string; - /** - * The product name in the crashReporter options object. - */ - _productName: string; - /** - * Name of the underlying product. In this case, Electron. - */ - prod: string; - /** - * The company name in the crashReporter options object. - */ - _companyName: string; - /** - * The crashreporter as a file. - */ - upload_file_minidump: File; - } -} diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index c70f20808f..34858aef12 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -4,35 +4,3676 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// declare namespace Electron { + class EventEmitter implements NodeJS.EventEmitter { + addListener(event: string, listener: Function): this; + on(event: string, listener: Function): this; + once(event: string, listener: Function): this; + removeListener(event: string, listener: Function): this; + removeAllListeners(event?: string): this; + setMaxListeners(n: number): this; + getMaxListeners(): number; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + listenerCount(type: string): number; + } + + interface Event { + preventDefault: Function; + sender: EventEmitter; + } + + // https://github.com/atom/electron/blob/master/docs/api/app.md + + /** + * The app module is responsible for controlling the application's lifecycle. + */ + class App extends EventEmitter { + /** + * Emitted when the application has finished basic startup. + * On Windows and Linux, the will-finish-launching event + * is the same as the ready event; on OS X, this event represents + * the applicationWillFinishLaunching notification of NSApplication. + * You would usually set up listeners for the open-file and open-url events here, + * and start the crash reporter and auto updater. + * + * In most cases, you should just do everything in the ready event handler. + */ + on(event: 'will-finish-launching', listener: Function): this; + /** + * Emitted when Electron has finished initialization. + */ + on(event: 'ready', listener: Function): this; + /** + * Emitted when all windows have been closed. + * + * This event is only emitted when the application is not going to quit. + * If the user pressed Cmd + Q, or the developer called app.quit(), + * Electron will first try to close all the windows and then emit the will-quit event, + * and in this case the window-all-closed event would not be emitted. + */ + on(event: 'window-all-closed', listener: Function): this; + /** + * Emitted before the application starts closing its windows. + * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. + */ + on(event: 'before-quit', listener: (event: Event) => void): this; + /** + * Emitted when all windows have been closed and the application will quit. + * Calling event.preventDefault() will prevent the default behaviour, which is terminating the application. + */ + on(event: 'will-quit', listener: (event: Event) => void): this; + /** + * Emitted when the application is quitting. + */ + on(event: 'quit', listener: (event: Event, exitCode: number) => void): this; + /** + * Emitted when the user wants to open a file with the application. + * The open-file event is usually emitted when the application is already open + * and the OS wants to reuse the application to open the file. + * open-file is also emitted when a file is dropped onto the dock and the application + * is not yet running. Make sure to listen for the open-file event very early + * in your application startup to handle this case (even before the ready event is emitted). + * + * You should call event.preventDefault() if you want to handle this event. + * + * Note: This is only implemented on OS X. + */ + on(event: 'open-file', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the user wants to open a URL with the application. + * The URL scheme must be registered to be opened by your application. + * + * You should call event.preventDefault() if you want to handle this event. + * + * Note: This is only implemented on OS X. + */ + on(event: 'open-url', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the application is activated, which usually happens when clicks on the applications’s dock icon. + * Note: This is only implemented on OS X. + */ + on(event: 'activate', listener: Function): this; + /** + * Emitted when a browserWindow gets blurred. + */ + on(event: 'browser-window-blur', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when a browserWindow gets focused. + */ + on(event: 'browser-window-focus', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when a new browserWindow is created. + */ + on(event: 'browser-window-created', listener: (event: Event, browserWindow: BrowserWindow) => void): this; + /** + * Emitted when failed to verify the certificate for url, to trust the certificate + * you should prevent the default behavior with event.preventDefault() and call callback(true). + */ + on(event: 'certificate-error', listener: (event: Event, + webContents: WebContents, + url: string, + error: string, + certificate: Certificate, + callback: (trust: boolean) => void + ) => void): this; + /** + * Emitted when a client certificate is requested. + * + * The url corresponds to the navigation entry requesting the client certificate + * and callback needs to be called with an entry filtered from the list. + * Using event.preventDefault() prevents the application from using the first certificate from the store. + */ + on(event: 'select-client-certificate', listener: (event: Event, + webContents: WebContents, + url: string, + certificateList: Certificate[], + callback: (certificate: Certificate) => void + ) => void): this; + /** + * Emitted when webContents wants to do basic auth. + * + * The default behavior is to cancel all authentications, to override this + * you should prevent the default behavior with event.preventDefault() + * and call callback(username, password) with the credentials. + */ + on(event: 'login', listener: (event: Event, + webContents: WebContents, + request: LoginRequest, + authInfo: LoginAuthInfo, + callback: (username: string, password: string) => void + ) => void): this; + /** + * Emitted when the gpu process crashes. + */ + on(event: 'gpu-process-crashed', listener: Function): this; + /** + * Emitted when the system’s Dark Mode theme is toggled. + * Note: This is only implemented on OS X. + */ + on(event: 'platform-theme-changed', listener: Function): this; + on(event: string, listener: Function): this; + /** + * Try to close all windows. The before-quit event will first be emitted. + * If all windows are successfully closed, the will-quit event will be emitted + * and by default the application would be terminated. + * + * This method guarantees all beforeunload and unload handlers are correctly + * executed. It is possible that a window cancels the quitting by returning + * false in beforeunload handler. + */ + quit(): void; + /** + * Exits immediately with exitCode. + * All windows will be closed immediately without asking user + * and the before-quit and will-quit events will not be emitted. + */ + exit(exitCode: number): void; + /** + * On Linux, focuses on the first visible window. + * On OS X, makes the application the active app. + * On Windows, focuses on the application’s first window. + */ + focus(): void; + /** + * Hides all application windows without minimizing them. + * Note: This is only implemented on OS X. + */ + hide(): void; + /** + * Shows application windows after they were hidden. Does not automatically focus them. + * Note: This is only implemented on OS X. + */ + show(): void; + /** + * Returns the current application directory. + */ + getAppPath(): string; + /** + * @returns The path to a special directory or file associated with name. + * On failure an Error would throw. + */ + getPath(name: AppPathName): string; + /** + * Overrides the path to a special directory or file associated with name. + * If the path specifies a directory that does not exist, the directory will + * be created by this method. On failure an Error would throw. + * + * You can only override paths of names defined in app.getPath. + * + * By default web pages' cookies and caches will be stored under userData + * directory, if you want to change this location, you have to override the + * userData path before the ready event of app module gets emitted. + */ + setPath(name: AppPathName, path: string): void; + /** + * @returns The version of loaded application, if no version is found in + * application's package.json, the version of current bundle or executable. + */ + getVersion(): string; + /** + * + * @returns The current application's name, the name in package.json would be used. + * Usually the name field of package.json is a short lowercased name, according to + * the spec of npm modules. So usually you should also specify a productName field, + * which is your application's full capitalized name, and it will be preferred over + * name by Electron. + */ + getName(): string; + /** + * @returns The current application locale. + **/ + getLocale(): string; + /** + * Adds path to recent documents list. + * + * This list is managed by the system, on Windows you can visit the list from + * task bar, and on Mac you can visit it from dock menu. + * + * Note: This is only implemented on OS X and Windows. + */ + addRecentDocument(path: string): void; + /** + * Clears the recent documents list. + * + * Note: This is only implemented on OS X and Windows. + */ + clearRecentDocuments(): void; + /** + * Adds tasks to the Tasks category of JumpList on Windows. + * + * Note: This API is only available on Windows. + */ + setUserTasks(tasks: Task[]): void; + /** + * Dynamically sets whether to always send credentials for HTTP NTLM or Negotiate authentication. + * Normally, Electron will only send NTLM/Kerberos credentials for URLs that fall under + * "Local Intranet" sites (i.e. are in the same domain as you). + * However, this detection often fails when corporate networks are badly configured, + * so this lets you co-opt this behavior and enable it for all URLs. + */ + allowNTLMCredentialsForAllDomains(allow: boolean): void; + /** + * This method makes your application a Single Instance Application instead of allowing + * multiple instances of your app to run, this will ensure that only a single instance + * of your app is running, and other instances signal this instance and exit. + */ + makeSingleInstance(callback: (args: string[], workingDirectory: string) => boolean): boolean; + /** + * Changes the Application User Model ID to id. + */ + setAppUserModelId(id: string): void; + /** + * This method returns true if DWM composition (Aero Glass) is enabled, + * and false otherwise. You can use it to determine if you should create + * a transparent window or not (transparent windows won’t work correctly when DWM composition is disabled). + * + * Note: This is only implemented on Windows. + */ + isAeroGlassEnabled(): boolean; + /** + * @returns If the system is in Dark Mode. + * Note: This is only implemented on OS X. + */ + isDarkMode(): boolean; + commandLine: CommandLine; + /** + * Note: This API is only available on Mac. + */ + dock: Dock; + } + + type AppPathName = 'home'|'appData'|'userData'|'temp'|'exe'|'module'|'desktop'|'documents'|'downloads'|'music'|'pictures'|'videos'; + + interface CommandLine { + /** + * Append a switch [with optional value] to Chromium's command line. + * + * Note: This will not affect process.argv, and is mainly used by developers + * to control some low-level Chromium behaviors. + */ + appendSwitch(_switch: string, value?: string|number): void; + /** + * Append an argument to Chromium's command line. The argument will quoted properly. + * + * Note: This will not affect process.argv. + */ + appendArgument(value: any): void; + } + + interface Dock { + /** + * When critical is passed, the dock icon will bounce until either the + * application becomes active or the request is canceled. + * + * When informational is passed, the dock icon will bounce for one second. + * However, the request remains active until either the application becomes + * active or the request is canceled. + * + * @param type The default is informational. + * @returns An ID representing the request. + */ + bounce(type?: 'critical' | 'informational'): number; + /** + * Cancel the bounce of id. + * + * Note: This API is only available on Mac. + */ + cancelBounce(id: number): void; + /** + * Sets the string to be displayed in the dock’s badging area. + * + * Note: This API is only available on Mac. + */ + setBadge(text: string): void; + /** + * Returns the badge string of the dock. + * + * Note: This API is only available on Mac. + */ + getBadge(): string; + /** + * Hides the dock icon. + * + * Note: This API is only available on Mac. + */ + hide(): void; + /** + * Shows the dock icon. + * + * Note: This API is only available on Mac. + */ + show(): void; + /** + * Sets the application dock menu. + * + * Note: This API is only available on Mac. + */ + setMenu(menu: Menu): void; + /** + * Sets the image associated with this dock icon. + * + * Note: This API is only available on Mac. + */ + setIcon(icon: NativeImage | string): void; + } + + interface Task { + /** + * Path of the program to execute, usually you should specify process.execPath + * which opens current program. + */ + program: string; + /** + * The arguments of command line when program is executed. + */ + arguments: string; + /** + * The string to be displayed in a JumpList. + */ + title: string; + /** + * Description of this task. + */ + description?: string; + /** + * The absolute path to an icon to be displayed in a JumpList, it can be + * arbitrary resource file that contains an icon, usually you can specify + * process.execPath to show the icon of the program. + */ + iconPath: string; + /** + * The icon index in the icon file. If an icon file consists of two or more + * icons, set this value to identify the icon. If an icon file consists of + * one icon, this value is 0. + */ + iconIndex?: number; + } + + // https://github.com/atom/electron/blob/master/docs/api/auto-updater.md + + /** + * This module provides an interface for the Squirrel auto-updater framework. + */ + class AutoUpdater extends EventEmitter { + /** + * Emitted when there is an error while updating. + */ + on(event: 'error', listener: (error: Error) => void): this; + /** + * Emitted when checking if an update has started. + */ + on(event: 'checking-for-update', listener: Function): this; + /** + * Emitted when there is an available update. The update is downloaded automatically. + */ + on(event: 'update-available', listener: Function): this; + /** + * Emitted when there is no available update. + */ + on(event: 'update-not-available', listener: Function): this; + /** + * Emitted when an update has been downloaded. + * Note: On Windows only releaseName is available. + */ + on(event: 'update-downloaded', listener: (event: Event, releaseNotes: string, releaseName: string, releaseDate: Date, updateURL: string) => void): this; + on(event: string, listener: Function): this; + /** + * Set the url and initialize the auto updater. + * The url cannot be changed once it is set. + */ + setFeedURL(url: string): void; + /** + * Ask the server whether there is an update, you have to call setFeedURL + * before using this API + */ + checkForUpdates(): any; + /** + * Restarts the app and installs the update after it has been downloaded. + * It should only be called after update-downloaded has been emitted. + */ + quitAndInstall(): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/browser-window.md + + /** + * The BrowserWindow class gives you ability to create a browser window. + * You can also create a window without chrome by using Frameless Window API. + */ + class BrowserWindow extends EventEmitter { + /** + * Emitted when the document changed its title, + * calling event.preventDefault() would prevent the native window’s title to change. + */ + on(event: 'page-title-updated', listener: (event: Event) => void): this; + /** + * Emitted when the window is going to be closed. It’s emitted before the beforeunload + * and unload event of the DOM. Calling event.preventDefault() will cancel the close. + */ + on(event: 'close', listener: (event: Event) => void): this; + /** + * Emitted when the window is closed. After you have received this event + * you should remove the reference to the window and avoid using it anymore. + */ + on(event: 'closed', listener: Function): this; + /** + * Emitted when the web page becomes unresponsive. + */ + on(event: 'unresponsive', listener: Function): this; + /** + * Emitted when the unresponsive web page becomes responsive again. + */ + on(event: 'responsive', listener: Function): this; + /** + * Emitted when the window loses focus. + */ + on(event: 'blur', listener: Function): this; + /** + * Emitted when the window gains focus. + */ + on(event: 'focus', listener: Function): this; + /** + * Emitted when the window is shown. + */ + on(event: 'show', listener: Function): this; + /** + * Emitted when the window is hidden. + */ + on(event: 'hide', listener: Function): this; + /** + * Emitted when window is maximized. + */ + on(event: 'maximize', listener: Function): this; + /** + * Emitted when the window exits from maximized state. + */ + on(event: 'unmaximize', listener: Function): this; + /** + * Emitted when the window is minimized. + */ + on(event: 'minimize', listener: Function): this; + /** + * Emitted when the window is restored from minimized state. + */ + on(event: 'restore', listener: Function): this; + /** + * Emitted when the window is getting resized. + */ + on(event: 'resize', listener: Function): this; + /** + * Emitted when the window is getting moved to a new position. + */ + on(event: 'move', listener: Function): this; + /** + * Emitted when the window enters full screen state. + */ + on(event: 'enter-full-screen', listener: Function): this; + /** + * Emitted when the window leaves full screen state. + */ + on(event: 'leave-full-screen', listener: Function): this; + /** + * Emitted when the window enters full screen state triggered by HTML API. + */ + on(event: 'enter-html-full-screen', listener: Function): this; + /** + * Emitted when the window leaves full screen state triggered by HTML API. + */ + on(event: 'leave-html-full-screen', listener: Function): this; + /** + * Emitted when an App Command is invoked. These are typically related + * to keyboard media keys or browser commands, as well as the "Back" / + * "Forward" buttons built into some mice on Windows. + * Note: This is only implemented on Windows. + */ + on(event: 'app-command', listener: (event: Event, command: string) => void): this; + /** + * Emitted when scroll wheel event phase has begun. + * Note: This is only implemented on OS X. + */ + on(event: 'scroll-touch-begin', listener: Function): this; + /** + * Emitted when scroll wheel event phase has ended. + * Note: This is only implemented on OS X. + */ + on(event: 'scroll-touch-end', listener: Function): this; + on(event: string, listener: Function): this; + constructor(options?: BrowserWindowOptions); + /** + * @returns All opened browser windows. + */ + static getAllWindows(): BrowserWindow[]; + /** + * @returns The window that is focused in this application. + */ + static getFocusedWindow(): BrowserWindow; + /** + * Find a window according to the webContents it owns. + */ + static fromWebContents(webContents: WebContents): BrowserWindow; + /** + * Find a window according to its ID. + */ + static fromId(id: number): BrowserWindow; + /** + * Adds devtools extension located at path. The extension will be remembered + * so you only need to call this API once, this API is not for programming use. + * @returns The extension's name. + */ + static addDevToolsExtension(path: string): string; + /** + * Remove a devtools extension. + * @param name The name of the devtools extension to remove. + */ + static removeDevToolsExtension(name: string): void; + /** + * The WebContents object this window owns, all web page related events and + * operations would be done via it. + * Note: Users should never store this object because it may become null when + * the renderer process (web page) has crashed. + */ + webContents: WebContents; + /** + * Get the unique ID of this window. + */ + id: number; + /** + * Force closing the window, the unload and beforeunload event won't be emitted + * for the web page, and close event would also not be emitted for this window, + * but it would guarantee the closed event to be emitted. + * You should only use this method when the renderer process (web page) has crashed. + */ + destroy(): void; + /** + * Try to close the window, this has the same effect with user manually clicking + * the close button of the window. The web page may cancel the close though, + * see the close event. + */ + close(): void; + /** + * Focus on the window. + */ + focus(): void; + /** + * Remove focus on the window. + */ + blur(): void; + /** + * @returns Whether the window is focused. + */ + isFocused(): boolean; + /** + * Shows and gives focus to the window. + */ + show(): void; + /** + * Shows the window but doesn't focus on it. + */ + showInactive(): void; + /** + * Hides the window. + */ + hide(): void; + /** + * @returns Whether the window is visible to the user. + */ + isVisible(): boolean; + /** + * Maximizes the window. + */ + maximize(): void; + /** + * Unmaximizes the window. + */ + unmaximize(): void; + /** + * @returns Whether the window is maximized. + */ + isMaximized(): boolean; + /** + * Minimizes the window. On some platforms the minimized window will be + * shown in the Dock. + */ + minimize(): void; + /** + * Restores the window from minimized state to its previous state. + */ + restore(): void; + /** + * @returns Whether the window is minimized. + */ + isMinimized(): boolean; + /** + * Sets whether the window should be in fullscreen mode. + */ + setFullScreen(flag: boolean): void; + /** + * @returns Whether the window is in fullscreen mode. + */ + isFullScreen(): boolean; + /** + * This will have a window maintain an aspect ratio. + * The extra size allows a developer to have space, specified in pixels, + * not included within the aspect ratio calculations. + * This API already takes into account the difference between a window’s size and its content size. + * + * Note: This API is available only on OS X. + */ + setAspectRatio(aspectRatio: number, extraSize?: { + width: number, + height: number + }): void; + /** + * Resizes and moves the window to width, height, x, y. + */ + setBounds(options: Rectangle, animate?: boolean): void; + /** + * @returns The window's width, height, x and y values. + */ + getBounds(): Rectangle; + /** + * Resizes the window to width and height. + */ + setSize(width: number, height: number, animate?: boolean): void; + /** + * @returns The window's width and height. + */ + getSize(): number[]; + /** + * Resizes the window's client area (e.g. the web page) to width and height. + */ + setContentSize(width: number, height: number, animate?: boolean): void; + /** + * @returns The window's client area's width and height. + */ + getContentSize(): number[]; + /** + * Sets the minimum size of window to width and height. + */ + setMinimumSize(width: number, height: number): void; + /** + * @returns The window's minimum width and height. + */ + getMinimumSize(): number[]; + /** + * Sets the maximum size of window to width and height. + */ + setMaximumSize(width: number, height: number): void; + /** + * @returns The window's maximum width and height. + */ + getMaximumSize(): number[]; + /** + * Sets whether the window can be manually resized by user. + */ + setResizable(resizable: boolean): void; + /** + * @returns Whether the window can be manually resized by user. + */ + isResizable(): boolean; + /** + * Sets whether the window can be moved by user. On Linux does nothing. + * Note: This API is available only on OS X and Windows. + */ + setMovable(movable: boolean): void; + /** + * Note: This API is available only on OS X and Windows. + * @returns Whether the window can be moved by user. On Linux always returns true. + */ + isMovable(): boolean; + /** + * Sets whether the window can be manually minimized by user. On Linux does nothing. + * Note: This API is available only on OS X and Windows. + */ + setMinimizable(minimizable: boolean): void; + /** + * Note: This API is available only on OS X and Windows. + * @returns Whether the window can be manually minimized by user. On Linux always returns true. + */ + isMinimizable(): boolean; + /** + * Sets whether the window can be manually maximized by user. On Linux does nothing. + * Note: This API is available only on OS X and Windows. + */ + setMaximizable(maximizable: boolean): void; + /** + * Note: This API is available only on OS X and Windows. + * @returns Whether the window can be manually maximized by user. On Linux always returns true. + */ + isMaximizable(): boolean; + /** + * Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. + */ + setFullScreenable(fullscreenable: boolean): void; + /** + * @returns Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window. + */ + isFullScreenable(): boolean; + /** + * Sets whether the window can be manually closed by user. On Linux does nothing. + * Note: This API is available only on OS X and Windows. + */ + setClosable(closable: boolean): void; + /** + * Note: This API is available only on OS X and Windows. + * @returns Whether the window can be manually closed by user. On Linux always returns true. + */ + isClosable(): boolean; + /** + * Sets whether the window should show always on top of other windows. After + * setting this, the window is still a normal window, not a toolbox window + * which can not be focused on. + */ + setAlwaysOnTop(flag: boolean): void; + /** + * @returns Whether the window is always on top of other windows. + */ + isAlwaysOnTop(): boolean; + /** + * Moves window to the center of the screen. + */ + center(): void; + /** + * Moves window to x and y. + */ + setPosition(x: number, y: number, animate?: boolean): void; + /** + * @returns The window's current position. + */ + getPosition(): number[]; + /** + * Changes the title of native window to title. + */ + setTitle(title: string): void; + /** + * Note: The title of web page can be different from the title of the native window. + * @returns The title of the native window. + */ + getTitle(): string; + /** + * Starts or stops flashing the window to attract user's attention. + */ + flashFrame(flag: boolean): void; + /** + * Makes the window do not show in Taskbar. + */ + setSkipTaskbar(skip: boolean): void; + /** + * Enters or leaves the kiosk mode. + */ + setKiosk(flag: boolean): void; + /** + * @returns Whether the window is in kiosk mode. + */ + isKiosk(): boolean; + /** + * The native type of the handle is HWND on Windows, NSView* on OS X, + * and Window (unsigned long) on Linux. + * @returns The platform-specific handle of the window as Buffer. + */ + getNativeWindowHandle(): Buffer; + /** + * Hooks a windows message. The callback is called when the message is received in the WndProc. + * Note: This API is available only on Windows. + */ + hookWindowMessage(message: number, callback: Function): void; + /** + * @returns Whether the message is hooked. + */ + isWindowMessageHooked(message: number): boolean; + /** + * Unhook the window message. + */ + unhookWindowMessage(message: number): void; + /** + * Unhooks all of the window messages. + */ + unhookAllWindowMessages(): void; + /** + * Sets the pathname of the file the window represents, and the icon of the + * file will show in window's title bar. + * Note: This API is available only on OS X. + */ + setRepresentedFilename(filename: string): void; + /** + * Note: This API is available only on OS X. + * @returns The pathname of the file the window represents. + */ + getRepresentedFilename(): string; + /** + * Specifies whether the window’s document has been edited, and the icon in + * title bar will become grey when set to true. + * Note: This API is available only on OS X. + */ + setDocumentEdited(edited: boolean): void; + /** + * Note: This API is available only on OS X. + * @returns Whether the window's document has been edited. + */ + isDocumentEdited(): boolean; + focusOnWebView(): void; + blurWebView(): void; + /** + * Captures the snapshot of page within rect, upon completion the callback + * will be called. Omitting the rect would capture the whole visible page. + * Note: Be sure to read documents on remote buffer in remote if you are going + * to use this API in renderer process. + * @param callback Supplies the image that stores data of the snapshot. + */ + capturePage(rect: Rectangle, callback: (image: NativeImage) => void): void; + capturePage(callback: (image: NativeImage) => void): void; + /** + * Same with webContents.print([options]) + */ + print(options?: { + silent?: boolean; + printBackground?: boolean; + }): void; + /** + * Same with webContents.printToPDF([options]) + */ + printToPDF(options: { + marginsType?: number; + pageSize?: string; + printBackground?: boolean; + printSelectionOnly?: boolean; + landscape?: boolean; + }, callback: (error: Error, data: Buffer) => void): void; + /** + * Same with webContents.loadURL(url). + */ + loadURL(url: string, options?: { + httpReferrer?: string; + userAgent?: string; + extraHeaders?: string; + }): void; + /** + * Same with webContents.reload. + */ + reload(): void; + /** + * Sets the menu as the window top menu. + * Note: This API is not available on OS X. + */ + setMenu(menu: Menu): void; + /** + * Sets the progress value in the progress bar. + * On Linux platform, only supports Unity desktop environment, you need to + * specify the *.desktop file name to desktopName field in package.json. + * By default, it will assume app.getName().desktop. + * @param progress Valid range is [0, 1.0]. If < 0, the progress bar is removed. + * If greater than 0, it becomes indeterminate. + */ + setProgressBar(progress: number): void; + /** + * Sets a 16px overlay onto the current Taskbar icon, usually used to convey + * some sort of application status or to passively notify the user. + * Note: This API is only available on Windows 7 or above. + * @param overlay The icon to display on the bottom right corner of the Taskbar + * icon. If this parameter is null, the overlay is cleared + * @param description Provided to Accessibility screen readers. + */ + setOverlayIcon(overlay: NativeImage, description: string): void; + /** + * Sets whether the window should have a shadow. On Windows and Linux does nothing. + * Note: This API is available only on OS X. + */ + setHasShadow(hasShadow: boolean): void; + /** + * Note: This API is available only on OS X. + * @returns whether the window has a shadow. On Windows and Linux always returns true. + */ + hasShadow(): boolean; + /** + * Add a thumbnail toolbar with a specified set of buttons to the thumbnail image + * of a window in a taskbar button layout. + * @returns Whether the thumbnail has been added successfully. + */ + setThumbarButtons(buttons: ThumbarButton[]): boolean; + /** + * Shows pop-up dictionary that searches the selected word on the page. + * Note: This API is available only on OS X. + */ + showDefinitionForSelection(): void; + /** + * Sets whether the window menu bar should hide itself automatically. Once set + * the menu bar will only show when users press the single Alt key. + * If the menu bar is already visible, calling setAutoHideMenuBar(true) won't + * hide it immediately. + */ + setAutoHideMenuBar(hide: boolean): void; + /** + * @returns Whether menu bar automatically hides itself. + */ + isMenuBarAutoHide(): boolean; + /** + * Sets whether the menu bar should be visible. If the menu bar is auto-hide, + * users can still bring up the menu bar by pressing the single Alt key. + */ + setMenuBarVisibility(visibile: boolean): void; + /** + * @returns Whether the menu bar is visible. + */ + isMenuBarVisible(): boolean; + /** + * Sets whether the window should be visible on all workspaces. + * Note: This API does nothing on Windows. + */ + setVisibleOnAllWorkspaces(visible: boolean): void; + /** + * Note: This API always returns false on Windows. + * @returns Whether the window is visible on all workspaces. + */ + isVisibleOnAllWorkspaces(): boolean; + /** + * Ignore all moused events that happened in the window. + * Note: This API is available only on OS X. + */ + setIgnoreMouseEvents(ignore: boolean): void; + } + + type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive'; + + interface ThumbarButton { + icon: NativeImage | string; + click: Function; + tooltip?: string; + flags?: ThumbarButtonFlags[]; + } + + interface WebPreferences { + /** + * Whether node integration is enabled. + * Default: true. + */ + nodeIntegration?: boolean; + /** + * Specifies a script that will be loaded before other scripts run in the page. + * This script will always have access to node APIs no matter whether node integration is turned on or off. + * The value should be the absolute file path to the script. + * When node integration is turned off, the preload script can reintroduce + * Node global symbols back to the global scope. + */ + preload?: string; + /** + * Sets the session used by the page. Instead of passing the Session object directly, + * you can also choose to use the partition option instead, which accepts a partition string. + * When both session and partition are provided, session would be preferred. + * Default: the default session. + */ + session?: Session; + /** + * Sets the session used by the page according to the session’s partition string. + * If partition starts with persist:, the page will use a persistent session available + * to all pages in the app with the same partition. if there is no persist: prefix, + * the page will use an in-memory session. By assigning the same partition, + * multiple pages can share the same session. + * Default: the default session. + */ + partition?: string; + /** + * The default zoom factor of the page, 3.0 represents 300%. + * Default: 1.0. + */ + zoomFactor?: number; + /** + * Enables JavaScript support. + * Default: true. + */ + javascript?: boolean; + /** + * When setting false, it will disable the same-origin policy (Usually using testing + * websites by people), and set allowDisplayingInsecureContent and allowRunningInsecureContent + * to true if these two options are not set by user. + * Default: true. + */ + webSecurity?: boolean; + /** + * Allow an https page to display content like images from http URLs. + * Default: false. + */ + allowDisplayingInsecureContent?: boolean; + /** + * Allow a https page to run JavaScript, CSS or plugins from http URLs. + * Default: false. + */ + allowRunningInsecureContent?: boolean; + /** + * Enables image support. + * Default: true. + */ + images?: boolean; + /** + * Make TextArea elements resizable. + * Default: true. + */ + textAreasAreResizable?: boolean; + /** + * Enables WebGL support. + * Default: true. + */ + webgl?: boolean; + /** + * Enables WebAudio support. + * Default: true. + */ + webaudio?: boolean; + /** + * Whether plugins should be enabled. + * Default: false. + */ + plugins?: boolean; + /** + * Enables Chromium’s experimental features. + * Default: false. + */ + experimentalFeatures?: boolean; + /** + * Enables Chromium’s experimental canvas features. + * Default: false. + */ + experimentalCanvasFeatures?: boolean; + /** + * Enables DirectWrite font rendering system on Windows. + * Default: true. + */ + directWrite?: boolean; + /** + * A list of feature strings separated by ",". + */ + blinkFeatures?: string; + /** + * Sets the default font for the font-family. + */ + defaultFontFamily?: { + /** + * Default: Times New Roman. + */ + standard?: string; + /** + * Default: Times New Roman. + */ + serif?: string; + /** + * Default: Arial. + */ + sansSerif?: string; + /** + * Default: Courier New. + */ + monospace?: string; + }; + /** + * Default: 16. + */ + defaultFontSize?: number; + /** + * Default: 13. + */ + defaultMonospaceFontSize?: number; + /** + * Default: 0. + */ + minimumFontSize?: number; + /** + * Default: ISO-8859-1. + */ + defaultEncoding?: string; + } + + interface BrowserWindowOptions extends Rectangle { + /** + * Window’s width in pixels. + * Default: 800. + */ + width?: number; + /** + * Window’s height in pixels. + * Default: 600. + */ + height?: number; + /** + * Window’s left offset from screen. + * Default: center the window. + */ + x?: number; + /** + * Window’s top offset from screen. + * Default: center the window. + */ + y?: number; + /** + * The width and height would be used as web page’s size, which means + * the actual window’s size will include window frame’s size and be slightly larger. + * Default: false. */ + useContentSize?: boolean; + /** + * Show window in the center of the screen. + * Default: true + */ + center?: boolean; + /** + * Window’s minimum width. + * Default: 0. + */ + minWidth?: number; + /** + * Window’s minimum height. + * Default: 0. + */ + minHeight?: number; + /** + * Window’s maximum width. + * Default: no limit. + */ + maxWidth?: number; + /** + * Window’s maximum height. + * Default: no limit. + */ + maxHeight?: number; + /** + * Whether window is resizable. + * Default: true. + */ + resizable?: boolean; + /** + * Whether window is movable. + * Note: This is not implemented on Linux. + * Default: true. + */ + movable?: boolean; + /** + * Whether window is minimizable. + * Note: This is not implemented on Linux. + * Default: true. + */ + minimizable?: boolean; + /** + * Whether window is maximizable. + * Note: This is not implemented on Linux. + * Default: true. + */ + maximizable?: boolean; + /** + * Whether window is closable. + * Note: This is not implemented on Linux. + * Default: true. + */ + closable?: boolean; + /** + * Whether the window should always stay on top of other windows. + * Default: false. + */ + alwaysOnTop?: boolean; + /** + * Whether the window should show in fullscreen. + * When explicity set to false the fullscreen button will be hidden or disabled on OS X. + * Default: false. + */ + fullscreen?: boolean; + /** + * Whether the maximize/zoom button on OS X should toggle full screen mode or maximize window. + * Default: true. + */ + fullscreenable?: boolean; + /** + * Whether to show the window in taskbar. + * Default: false. + */ + skipTaskbar?: boolean; + /** + * The kiosk mode. + * Default: false. + */ + kiosk?: boolean; + /** + * Default window title. + * Default: "Electron". + */ + title?: string; + /** + *The window icon, when omitted on Windows the executable’s icon would be used as window icon. + */ + icon?: NativeImage|string; + /** + * Whether window should be shown when created. + * Default: true. + */ + show?: boolean; + /** + * Specify false to create a Frameless Window. + * Default: true. + */ + frame?: boolean; + /** + * Whether the web view accepts a single mouse-down event that simultaneously activates the window. + * Default: false. + */ + acceptFirstMouse?: boolean; + /** + * Whether to hide cursor when typing. + * Default: false. + */ + disableAutoHideCursor?: boolean; + /** + * Auto hide the menu bar unless the Alt key is pressed. + * Default: true. + */ + autoHideMenuBar?: boolean; + /** + * Enable the window to be resized larger than screen. + * Default: false. + */ + enableLargerThanScreen?: boolean; + /** + * Window’s background color as Hexadecimal value, like #66CD00 or #FFF or #80FFFFFF (alpha is supported). + * Default: #000 (black) for Linux and Windows, #FFF for Mac (or clear if transparent). + */ + backgroundColor?: string; + /** + * Whether window should have a shadow. + * Note: This is only implemented on OS X. + * Default: true. + */ + hasShadow?: boolean; + /** + * Forces using dark theme for the window. + * Note: Only works on some GTK+3 desktop environments. + * Default: false. + */ + darkTheme?: boolean; + /** + * Makes the window transparent. + * Default: false. + */ + transparent?: boolean; + /** + * The type of window, default is normal window. + */ + type?: BrowserWindowType; + /** + * The style of window title bar. + */ + titleBarStyle?: 'default' | 'hidden' | 'hidden-inset'; + /** + * Settings of web page’s features. + */ + webPreferences?: WebPreferences; + } + + type BrowserWindowType = BrowserWindowTypeLinux | BrowserWindowTypeMac; + type BrowserWindowTypeLinux = 'desktop' | 'dock' | 'toolbar' | 'splash' | 'notification'; + type BrowserWindowTypeMac = 'desktop' | 'textured'; + + interface Rectangle { + x?: number; + y?: number; + width?: number; + height?: number; + } + + // https://github.com/atom/electron/blob/master/docs/api/clipboard.md + + /** + * The clipboard module provides methods to perform copy and paste operations. + */ + interface Clipboard { + /** + * @returns The contents of the clipboard as plain text. + */ + readText(type?: ClipboardType): string; + /** + * Writes the text into the clipboard as plain text. + */ + writeText(text: string, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as markup. + */ + readHtml(type?: ClipboardType): string; + /** + * Writes markup to the clipboard. + */ + writeHtml(markup: string, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as a NativeImage. + */ + readImage(type?: ClipboardType): NativeImage; + /** + * Writes the image into the clipboard. + */ + writeImage(image: NativeImage, type?: ClipboardType): void; + /** + * @returns The contents of the clipboard as RTF. + */ + readRtf(type?: ClipboardType): string; + /** + * Writes the text into the clipboard in RTF. + */ + writeRtf(text: string, type?: ClipboardType): void; + /** + * Clears everything in clipboard. + */ + clear(type?: ClipboardType): void; + /** + * @returns Array available formats for the clipboard type. + */ + availableFormats(type?: ClipboardType): string[]; + /** + * Returns whether the clipboard supports the format of specified data. + * Note: This API is experimental and could be removed in future. + * @returns Whether the clipboard has data in the specified format. + */ + has(format: string, type?: ClipboardType): boolean; + /** + * Reads the data in the clipboard of the specified format. + * Note: This API is experimental and could be removed in future. + */ + read(format: string, type?: ClipboardType): any; + /** + * Writes data to the clipboard. + */ + write(data: { + text?: string; + rtf?: string; + html?: string; + image?: NativeImage; + }, type?: ClipboardType): void; + } + + type ClipboardType = '' | 'selection'; + + // https://github.com/atom/electron/blob/master/docs/api/content-tracing.md + + /** + * The content-tracing module is used to collect tracing data generated by the underlying Chromium content module. + * This module does not include a web interface so you need to open chrome://tracing/ + * in a Chrome browser and load the generated file to view the result. + */ + interface ContentTracing { + /** + * Get a set of category groups. The category groups can change as new code paths are reached. + * @param callback Called once all child processes have acked to the getCategories request. + */ + getCategories(callback: (categoryGroups: any[]) => void): void; + /** + * Start recording on all processes. Recording begins immediately locally, and asynchronously + * on child processes as soon as they receive the EnableRecording request. + * @param categoryFilter A filter to control what category groups should be traced. + * A filter can have an optional "-" prefix to exclude category groups that contain + * a matching category. Having both included and excluded category patterns in the + * same list would not be supported. + * @param options controls what kind of tracing is enabled, it could be a OR-ed + * combination of tracing.DEFAULT_OPTIONS, tracing.ENABLE_SYSTRACE, tracing.ENABLE_SAMPLING + * and tracing.RECORD_CONTINUOUSLY. + * @param callback Called once all child processes have acked to the startRecording request. + */ + startRecording(categoryFilter: string, options: number, callback: Function): void; + /** + * Stop recording on all processes. Child processes typically are caching trace data and + * only rarely flush and send trace data back to the main process. That is because it may + * be an expensive operation to send the trace data over IPC, and we would like to avoid + * much runtime overhead of tracing. So, to end tracing, we must asynchronously ask all + * child processes to flush any pending trace data. + * @param resultFilePath Trace data will be written into this file if it is not empty, + * or into a temporary file. + * @param callback Called once all child processes have acked to the stopRecording request. + */ + stopRecording(resultFilePath: string, callback: + /** + * @param filePath A file that contains the traced data. + */ + (filePath: string) => void + ): void; + /** + * Start monitoring on all processes. Monitoring begins immediately locally, and asynchronously + * on child processes as soon as they receive the startMonitoring request. + * @param callback Called once all child processes have acked to the startMonitoring request. + */ + startMonitoring(categoryFilter: string, options: number, callback: Function): void; + /** + * Stop monitoring on all processes. + * @param callback Called once all child processes have acked to the stopMonitoring request. + */ + stopMonitoring(callback: Function): void; + /** + * Get the current monitoring traced data. Child processes typically are caching trace data + * and only rarely flush and send trace data back to the main process. That is because it may + * be an expensive operation to send the trace data over IPC, and we would like to avoid much + * runtime overhead of tracing. So, to end tracing, we must asynchronously ask all child + * processes to flush any pending trace data. + * @param callback Called once all child processes have acked to the captureMonitoringSnapshot request. + */ + captureMonitoringSnapshot(resultFilePath: string, callback: + /** + * @param filePath A file that contains the traced data + * @returns {} + */ + (filePath: string) => void + ): void; + /** + * Get the maximum across processes of trace buffer percent full state. + * @param callback Called when the TraceBufferUsage value is determined. + */ + getTraceBufferUsage(callback: Function): void; + /** + * @param callback Called every time the given event occurs on any process. + */ + setWatchEvent(categoryName: string, eventName: string, callback: Function): void; + /** + * Cancel the watch event. If tracing is enabled, this may race with the watch event callback. + */ + cancelWatchEvent(): void; + DEFAULT_OPTIONS: number; + ENABLE_SYSTRACE: number; + ENABLE_SAMPLING: number; + RECORD_CONTINUOUSLY: number; + } + + // https://github.com/atom/electron/blob/master/docs/api/crash-reporter.md + + /** + * The crash-reporter module enables sending your app's crash reports. + */ + interface CrashReporter { + /** + * You are required to call this method before using other crashReporter APIs. + */ + start(options: CrashReporterStartOptions): void; + /** + * @returns The date and ID of the last crash report. When there was no crash report + * sent or the crash reporter is not started, null will be returned. + */ + getLastCrashReport(): CrashReporterPayload; + /** + * @returns All uploaded crash reports. Each report contains the date and uploaded ID. + */ + getUploadedReports(): CrashReporterPayload[]; + } + + interface CrashReporterStartOptions { + /** + * Default: Electron + */ + productName?: string; + companyName: string; + /** + * URL that crash reports would be sent to as POST. + */ + submitURL: string; + /** + * Send the crash report without user interaction. + * Default: true. + */ + autoSubmit?: boolean; + /** + * Default: false. + */ + ignoreSystemCrashHandler?: boolean; + /** + * An object you can define which content will be send along with the report. + * Only string properties are send correctly. + * Nested objects are not supported. + */ + extra?: {[prop: string]: string}; + } + + interface CrashReporterPayload extends Object { + /** + * E.g., "electron-crash-service". + */ + rept: string; + /** + * The version of Electron. + */ + ver: string; + /** + * E.g., "win32". + */ + platform: string; + /** + * E.g., "renderer". + */ + process_type: string; + ptime: number; + /** + * The version in package.json. + */ + _version: string; + /** + * The product name in the crashReporter options object. + */ + _productName: string; + /** + * Name of the underlying product. In this case, Electron. + */ + prod: string; + /** + * The company name in the crashReporter options object. + */ + _companyName: string; + /** + * The crashreporter as a file. + */ + upload_file_minidump: File; + } + + // https://github.com/atom/electron/blob/master/docs/api/desktop-capturer.md + + /** + * The desktopCapturer module can be used to get available sources + * that can be used to be captured with getUserMedia. + */ + interface DesktopCapturer { + /** + * Starts a request to get all desktop sources. + * + * Note: There is no guarantee that the size of source.thumbnail is always + * the same as the thumnbailSize in options. It also depends on the scale of the screen or window. + */ + getSources(options: any, callback: (error: Error, sources: DesktopCapturerSource[]) => any): void; + } + + interface DesktopCapturerOptions { + /** + * The types of desktop sources to be captured. + */ + types?: ('screen' | 'window')[]; + /** + * The suggested size that thumbnail should be scaled. + * Default: {width: 150, height: 150} + */ + thumbnailSize?: { + width: number; + height: number; + }; + } + + interface DesktopCapturerSource { + /** + * The id of the captured window or screen used in navigator.webkitGetUserMedia. + * The format looks like window:XX or screen:XX where XX is a random generated number. + */ + id: string; + /** + * The described name of the capturing screen or window. + * If the source is a screen, the name will be Entire Screen or Screen ; + * if it is a window, the name will be the window’s title. + */ + name: string; + /** + * A thumbnail image. + */ + thumbnail: NativeImage; + } + + // https://github.com/atom/electron/blob/master/docs/api/dialog.md + + /** + * The dialog module provides APIs to show native system dialogs, such as opening files or alerting, + * so web applications can deliver the same user experience as native applications. + */ + interface Dialog { + /** + * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, + * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. + * + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns an array of file paths chosen by the user, + * otherwise returns undefined. + */ + showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; + /** + * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, + * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. + * + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns an array of file paths chosen by the user, + * otherwise returns undefined. + */ + showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; + /** + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns the path of file chosen by the user, otherwise + * returns undefined. + */ + showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (fileName: string) => void): string; + /** + * @param callback If supplied, the API call will be asynchronous. + * @returns On success, returns the path of file chosen by the user, otherwise + * returns undefined. + */ + showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string; + /** + * Shows a message box. It will block until the message box is closed. + * @param callback If supplied, the API call will be asynchronous. + * @returns The index of the clicked button. + */ + showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: any) => void): number; + /** + * Shows a message box. It will block until the message box is closed. + * @param callback If supplied, the API call will be asynchronous. + * @returns The index of the clicked button. + */ + showMessageBox(options: ShowMessageBoxOptions, callback?: (response: any) => void): number; + /** + * Displays a modal dialog that shows an error message. + * + * This API can be called safely before the ready event the app module emits, + * it is usually used to report errors in early stage of startup. + * If called before the app readyevent on Linux, the message will be emitted to stderr, + * and no GUI dialog will appear. + */ + showErrorBox(title: string, content: string): void; + } + + interface OpenDialogOptions { + title?: string; + defaultPath?: string; + /** + * File types that can be displayed or selected. + */ + filters?: { + name: string; + /** + * Extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). + * To show all files, use the '*' wildcard (no other wildcard is supported). + */ + extensions: string[]; + }[]; + /** + * Contains which features the dialog should use. + */ + properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[]; + } + + interface SaveDialogOptions { + title?: string; + defaultPath?: string; + /** + * File types that can be displayed, see dialog.showOpenDialog for an example. + */ + filters?: { + name: string; + extensions: string[]; + }[]; + } + + interface ShowMessageBoxOptions { + /** + * On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option. + */ + type?: 'none' | 'info' | 'error' | 'question' | 'warning'; + /** + * Texts for buttons. + */ + buttons?: string[]; + /** + * Index of the button in the buttons array which will be selected by default when the message box opens. + */ + defaultId?: number; + /** + * Title of the message box (some platforms will not show it). + */ + title?: string; + /** + * Contents of the message box. + */ + message?: string; + /** + * Extra information of the message. + */ + detail?: string; + icon?: NativeImage; + /** + * The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog. + * By default it is the index of the buttons that have "cancel" or "no" as label, + * or 0 if there is no such buttons. On OS X and Windows the index of "Cancel" button + * will always be used as cancelId, not matter whether it is already specified. + */ + cancelId?: number; + /** + * On Windows Electron will try to figure out which one of the buttons are common buttons + * (like "Cancel" or "Yes"), and show the others as command links in the dialog. + * This can make the dialog appear in the style of modern Windows apps. + * If you don’t like this behavior, you can set noLink to true. + */ + noLink?: boolean; + } + + // https://github.com/atom/electron/blob/master/docs/api/download-item.md + + /** + * DownloadItem represents a download item in Electron. + */ + class DownloadItem extends EventEmitter { + /** + * Emits when the downloadItem gets updated. + */ + on(event: 'updated', listener: Function): this; + /** + * Emits when the download is in a terminal state. This includes a completed download, + * a cancelled download (via downloadItem.cancel()), and interrupted download that can’t be resumed. + */ + on(event: 'done', listener: (event: Event, state: 'completed' | 'cancelled' | 'interrupted') => void): this; + on(event: string, listener: Function): this; + /** + * Set the save file path of the download item. + * Note: The API is only available in session’s will-download callback function. + * If user doesn’t set the save path via the API, Electron will use the original + * routine to determine the save path (Usually prompts a save dialog). + */ + setSavePath(path: string): void; + /** + * Pauses the download. + */ + pause(): void; + /** + * Resumes the download that has been paused. + */ + resume(): void; + /** + * Cancels the download operation. + */ + cancel(): void; + /** + * @returns The origin url where the item is downloaded from. + */ + getURL(): string; + /** + * @returns The mime type. + */ + getMimeType(): string; + /** + * @returns Whether the download has user gesture. + */ + hasUserGesture(): boolean; + /** + * @returns The file name of the download item. + * Note: The file name is not always the same as the actual one saved in local disk. + * If user changes the file name in a prompted download saving dialog, + * the actual name of saved file will be different. + */ + getFilename(): string; + /** + * @returns The total size in bytes of the download item. If the size is unknown, it returns 0. + */ + getTotalBytes(): number; + /** + * @returns The received bytes of the download item. + */ + getReceivedBytes(): number; + /** + * @returns The Content-Disposition field from the response header. + */ + getContentDisposition(): string; + } + + // https://github.com/atom/electron/blob/master/docs/api/global-shortcut.md + + /** + * The globalShortcut module can register/unregister a global keyboard shortcut + * with the operating system so that you can customize the operations for various shortcuts. + * Note: The shortcut is global; it will work even if the app does not have the keyboard focus. + * You should not use this module until the ready event of the app module is emitted. + */ + interface GlobalShortcut { + /** + * Registers a global shortcut of accelerator. + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + * @param callback Called when the registered shortcut is pressed by the user. + */ + register(accelerator: string, callback: Function): void; + /** + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + * @returns Whether the accelerator is registered. + */ + isRegistered(accelerator: string): boolean; + /** + * Unregisters the global shortcut of keycode. + * @param accelerator Represents a keyboard shortcut. It can contain modifiers + * and key codes, combined by the "+" character. + */ + unregister(accelerator: string): void; + /** + * Unregisters all the global shortcuts. + */ + unregisterAll(): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/ipc-main.md + + /** + * The ipcMain module handles asynchronous and synchronous messages + * sent from a renderer process (web page). + * Messages sent from a renderer will be emitted to this module. + */ + class IpcMain extends EventEmitter { + addListener(channel: string, listener: IpcMainEventListener): this; + on(channel: string, listener: IpcMainEventListener): this; + once(channel: string, listener: IpcMainEventListener): this; + removeListener(channel: string, listener: IpcMainEventListener): this; + removeAllListeners(channel?: string): this; + } + + type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void; + + interface IpcMainEvent { + /** + * Set this to the value to be returned in a synchronous message. + */ + returnValue?: any; + /** + * Returns the webContents that sent the message, you can call sender.send + * to reply to the asynchronous message. + */ + sender: WebContents; + } + + // https://github.com/atom/electron/blob/master/docs/api/ipc-renderer.md + + /** + * The ipcRenderer module provides a few methods so you can send synchronous + * and asynchronous messages from the render process (web page) to the main process. + * You can also receive replies from the main process. + */ + class IpcRenderer extends EventEmitter { + addListener(channel: string, listener: IpcRendererEventListener): this; + on(channel: string, listener: IpcRendererEventListener): this; + once(channel: string, listener: IpcRendererEventListener): this; + removeListener(channel: string, listener: IpcRendererEventListener): this; + removeAllListeners(channel?: string): this; + /** + * Send ...args to the renderer via channel in asynchronous message, the main + * process can handle it by listening to the channel event of ipc module. + */ + send(channel: string, ...args: any[]): void; + /** + * Send ...args to the renderer via channel in synchronous message, and returns + * the result sent from main process. The main process can handle it by listening + * to the channel event of ipc module, and returns by setting event.returnValue. + * Note: Usually developers should never use this API, since sending synchronous + * message would block the whole renderer process. + * @returns The result sent from the main process. + */ + sendSync(channel: string, ...args: any[]): any; + /** + * Like ipc.send but the message will be sent to the host page instead of the main process. + * This is mainly used by the page in to communicate with host page. + */ + sendToHost(channel: string, ...args: any[]): void; + } + + type IpcRendererEventListener = (event: IpcRendererEvent, ...args: any[]) => void; + + interface IpcRendererEvent { + /** + * You can call sender.send to reply to the asynchronous message. + */ + sender: IpcRenderer; + } + + // https://github.com/atom/electron/blob/master/docs/api/menu-item.md + + /** + * The MenuItem allows you to add items to an application or context menu. + */ + class MenuItem { + /** + * Create a new menu item. + */ + constructor(options: MenuItemOptions); + + click: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; + /** + * Read-only property. + */ + type: MenuItemType; + /** + * Read-only property. + */ + role: MenuItemRole | MenuItemRoleMac; + /** + * Read-only property. + */ + accelerator: string; + /** + * Read-only property. + */ + icon: NativeImage | string; + /** + * Read-only property. + */ + submenu: Menu | MenuItemOptions[]; + + label: string; + sublabel: string; + enabled: boolean; + visible: boolean; + checked: boolean; + } + + type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; + type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectall' | 'minimize' | 'close'; + type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'window' | 'help' | 'services'; + + interface MenuItemOptions { + /** + * Callback when the menu item is clicked. + */ + click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; + /** + * Can be normal, separator, submenu, checkbox or radio. + */ + type?: MenuItemType; + label?: string; + sublabel?: string; + /** + * An accelerator is string that represents a keyboard shortcut, it can contain + * multiple modifiers and key codes, combined by the + character. + * + * Examples: + * Command+A + * Ctrl+Shift+Z + * + * Platform notice: On Linux and Windows, the Command key would not have any effect, + * you can use CommandOrControl which represents Command on OS X and Control on + * Linux and Windows to define some accelerators. + * + * Available modifiers: + * Command (or Cmd for short) + * Control (or Ctrl for short) + * CommandOrControl (or CmdOrCtrl for short) + * Alt + * Shift + * + * Available key codes: + * 0 to 9 + * A to Z + * F1 to F24 + * Punctuations like ~, !, @, #, $, etc. + * Plus + * Space + * Backspace + * Delete + * Insert + * Return (or Enter as alias) + * Up, Down, Left and Right + * Home and End + * PageUp and PageDown + * Escape (or Esc for short) + * VolumeUp, VolumeDown and VolumeMute + * MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause + */ + accelerator?: string; + /** + * In Electron for the APIs that take images, you can pass either file paths + * or NativeImage instances. When passing null, an empty image will be used. + */ + icon?: NativeImage|string; + enabled?: boolean; + visible?: boolean; + checked?: boolean; + /** + * Should be specified for submenu type menu item, when it's specified the + * type: 'submenu' can be omitted for the menu item + */ + submenu?: Menu|MenuItemOptions[]; + /** + * Unique within a single menu. If defined then it can be used as a reference + * to this item by the position attribute. + */ + id?: string; + /** + * This field allows fine-grained definition of the specific location within + * a given menu. + */ + position?: string; + /** + * Define the action of the menu item, when specified the click property will be ignored + */ + role?: MenuItemRole | MenuItemRoleMac; + } + + // https://github.com/atom/electron/blob/master/docs/api/menu.md + + /** + * The Menu class is used to create native menus that can be used as application + * menus and context menus. This module is a main process module which can be used + * in a render process via the remote module. + * + * Each menu consists of multiple menu items, and each menu item can have a submenu. + */ + class Menu extends EventEmitter { + /** + * Creates a new menu. + */ + constructor(); + /** + * Sets menu as the application menu on OS X. On Windows and Linux, the menu + * will be set as each window's top menu. + */ + static setApplicationMenu(menu: Menu): void; + /** + * Sends the action to the first responder of application. + * This is used for emulating default Cocoa menu behaviors, + * usually you would just use the role property of MenuItem. + * + * Note: This method is OS X only. + */ + static sendActionToFirstResponder(action: string): void; + /** + * @param template Generally, just an array of options for constructing MenuItem. + * You can also attach other fields to element of the template, and they will + * become properties of the constructed menu items. + */ + static buildFromTemplate(template: MenuItemOptions[]): Menu; + /** + * Popups this menu as a context menu in the browserWindow. You can optionally + * provide a (x,y) coordinate to place the menu at, otherwise it will be placed + * at the current mouse cursor position. + * @param x Horizontal coordinate where the menu will be placed. + * @param y Vertical coordinate where the menu will be placed. + */ + popup(browserWindow?: BrowserWindow, x?: number, y?: number): void; + /** + * Appends the menuItem to the menu. + */ + append(menuItem: MenuItem): void; + /** + * Inserts the menuItem to the pos position of the menu. + */ + insert(position: number, menuItem: MenuItem): void; + /** + * @returns an array containing the menu’s items. + */ + items: MenuItem[]; + } + + // https://github.com/atom/electron/blob/master/docs/api/native-image.md + + /** + * This class is used to represent an image. + */ + class NativeImage { + /** + * Creates an empty NativeImage instance. + */ + static createEmpty(): NativeImage; + /** + * Creates a new NativeImage instance from file located at path. + */ + static createFromPath(path: string): NativeImage; + /** + * Creates a new NativeImage instance from buffer. + * @param scaleFactor 1.0 by default. + */ + static createFromBuffer(buffer: Buffer, scaleFactor?: number): NativeImage; + /** + * Creates a new NativeImage instance from dataURL + */ + static createFromDataURL(dataURL: string): NativeImage; + /** + * @returns Buffer Contains the image's PNG encoded data. + */ + toPng(): Buffer; + /** + * @returns Buffer Contains the image's JPEG encoded data. + */ + toJpeg(quality: number): Buffer; + /** + * @returns string The data URL of the image. + */ + toDataURL(): string; + /** + * @returns boolean Whether the image is empty. + */ + isEmpty(): boolean; + /** + * @returns {} The size of the image. + */ + getSize(): any; + /** + * Marks the image as template image. + */ + setTemplateImage(option: boolean): void; + /** + * Returns a boolean whether the image is a template image. + */ + isTemplateImage(): boolean; + } + + // https://github.com/atom/electron/blob/master/docs/api/power-monitor.md + + /** + * The power-monitor module is used to monitor power state changes. + * You should not use this module until the ready event of the app module is emitted. + */ + interface PowerMonitor extends NodeJS.EventEmitter { + /** + * Emitted when the system is suspending. + */ + on(event: 'suspend', listener: Function): this; + /** + * Emitted when system is resuming. + */ + on(event: 'resume', listener: Function): this; + /** + * Emitted when the system changes to AC power. + */ + on(event: 'on-ac', listener: Function): this; + /** + * Emitted when system changes to battery power. + */ + on(event: 'on-battery', listener: Function): this; + on(event: string, listener: Function): this; + } + + // https://github.com/atom/electron/blob/master/docs/api/power-save-blocker.md + + /** + * The powerSaveBlocker module is used to block the system from entering + * low-power (sleep) mode and thus allowing the app to keep the system and screen active. + */ + interface PowerSaveBlocker { + /** + * Starts preventing the system from entering lower-power mode. + * @returns an integer identifying the power save blocker. + * Note: prevent-display-sleep has higher has precedence over prevent-app-suspension. + */ + start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number; + /** + * @param id The power save blocker id returned by powerSaveBlocker.start. + * Stops the specified power save blocker. + */ + stop(id: number): void; + /** + * @param id The power save blocker id returned by powerSaveBlocker.start. + * @returns a boolean whether the corresponding powerSaveBlocker has started. + */ + isStarted(id: number): boolean; + } + + // https://github.com/atom/electron/blob/master/docs/api/protocol.md + + /** + * The protocol module can register a custom protocol or intercept an existing protocol. + */ + interface Protocol { + /** + * Registers custom schemes as standard schemes. + */ + registerStandardSchemes(schemes: string[]): void; + /** + * Registers custom schemes to handle service workers. + */ + registerServiceWorkerSchemes(schemes: string[]): void; + /** + * Registers a protocol of scheme that will send the file as a response. + */ + registerFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send a Buffer as a response. + */ + registerBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send a String as a response. + */ + registerStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Registers a protocol of scheme that will send an HTTP request as a response. + */ + registerHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Unregisters the custom protocol of scheme. + */ + unregisterProtocol(scheme: string, completion?: (error: Error) => void): void; + /** + * The callback will be called with a boolean that indicates whether there is already a handler for scheme. + */ + isProtocolHandled(scheme: string, callback: (handled: boolean) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response. + */ + interceptFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response. + */ + interceptStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response. + */ + interceptBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response. + */ + interceptHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; + /** + * Remove the interceptor installed for scheme and restore its original handler. + */ + uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void; + } + + type ProtocolRequest = { + url: string; + referrer: string; + method: string; + uploadData?: { + bytes: Buffer, + file: string + }[]; + } + + interface ProtocolCallback { + (error: number): void; + (obj: { + error: number + }): void; + (): void; + } + + interface FileProtocolCallback extends ProtocolCallback { + (filePath: string): void; + (obj: { + path: string + }): void; + } + + interface BufferProtocolCallback extends ProtocolCallback { + (buffer: Buffer): void; + (obj: { + data: Buffer, + mimeType: string, + charset?: string + }): void; + } + + interface StringProtocolCallback extends ProtocolCallback { + (str: string): void; + (obj: { + data: Buffer, + mimeType: string, + charset?: string + }): void; + } + + interface HttpProtocolCallback extends ProtocolCallback { + (redirectRequest: { + url: string; + method: string; + session?: Object; + uploadData?: { + contentType: string; + data: string; + }; + }): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/remote.md + + /** + * The remote module provides a simple way to do inter-process communication (IPC) + * between the renderer process (web page) and the main process. + */ + interface Remote extends CommonElectron { + /** + * @returns The object returned by require(module) in the main process. + */ + require(module: string): any; + /** + * @returns The BrowserWindow object which this web page belongs to. + */ + getCurrentWindow(): BrowserWindow; + /** + * @returns The WebContents object of this web page. + */ + getCurrentWebContents(): WebContents; + /** + * @returns The global variable of name (e.g. global[name]) in the main process. + */ + getGlobal(name: string): any; + /** + * Returns the process object in the main process. This is the same as + * remote.getGlobal('process'), but gets cached. + */ + process: NodeJS.Process; + } + + // https://github.com/atom/electron/blob/master/docs/api/screen.md + + /** + * The Display object represents a physical display connected to the system. + * A fake Display may exist on a headless system, or a Display may correspond to a remote, virtual display. + */ + interface Display { + /** + * Unique identifier associated with the display. + */ + id: number; + bounds: Bounds; + workArea: Bounds; + size: Dimension; + workAreaSize: Dimension; + /** + * Output device’s pixel scale factor. + */ + scaleFactor: number; + /** + * Can be 0, 1, 2, 3, each represents screen rotation in clock-wise degrees of 0, 90, 180, 270. + */ + rotation: number; + touchSupport: 'available' | 'unavailable' | 'unknown'; + } + + interface Bounds { + x: number; + y: number; + width: number; + height: number; + } + + interface Dimension { + width: number; + height: number; + } + + interface Point { + x: number; + y: number; + } + + type DisplayMetrics = 'bounds' | 'workArea' | 'scaleFactor' | 'rotation'; + + /** + * The screen module retrieves information about screen size, displays, cursor position, etc. + * You should not use this module until the ready event of the app module is emitted. + */ + class Screen extends EventEmitter { + /** + * Emitted when newDisplay has been added. + */ + on(event: 'display-added', listener: (event: Event, newDisplay: Display) => void): this; + /** + * Emitted when oldDisplay has been removed. + */ + on(event: 'display-removed', listener: (event: Event, oldDisplay: Display) => void): this; + /** + * Emitted when one or more metrics change in a display. + */ + on(event: 'display-metrics-changed', listener: (event: Event, display: Display, changedMetrics: DisplayMetrics[]) => void): this; + on(event: string, listener: Function): this; + /** + * @returns The current absolute position of the mouse pointer. + */ + getCursorScreenPoint(): Point; + /** + * @returns The primary display. + */ + getPrimaryDisplay(): Display; + /** + * @returns An array of displays that are currently available. + */ + getAllDisplays(): Display[]; + /** + * @returns The display nearest the specified point. + */ + getDisplayNearestPoint(point: Point): Display; + /** + * @returns The display that most closely intersects the provided bounds. + */ + getDisplayMatching(rect: Bounds): Display; + } + + // https://github.com/atom/electron/blob/master/docs/api/session.md + + /** + * The session module can be used to create new Session objects. + * You can also access the session of existing pages by using + * the session property of webContents which is a property of BrowserWindow. + */ + class Session extends EventEmitter { + /** + * @returns a new Session instance from partition string. + */ + static fromPartition(partition: string): Session; + /** + * @returns the default session object of the app. + */ + static defaultSession: Session; + /** + * Emitted when Electron is about to download item in webContents. + * Calling event.preventDefault() will cancel the download + * and item will not be available from next tick of the process. + */ + on(event: 'will-download', listener: (event: Event, item: DownloadItem, webContents: WebContents) => void): this; + on(event: string, listener: Function): this; + /** + * The cookies gives you ability to query and modify cookies. + */ + cookies: SessionCookies; + /** + * @returns the session’s current cache size. + */ + getCacheSize(callback: (size: number) => void): void; + /** + * Clears the session’s HTTP cache. + */ + clearCache(callback: Function): void; + /** + * Clears the data of web storages. + */ + clearStorageData(callback: Function): void; + /** + * Clears the data of web storages. + */ + clearStorageData(options: ClearStorageDataOptions, callback: Function): void; + /** + * Writes any unwritten DOMStorage data to disk. + */ + flushStorageData(): void; + /** + * Sets the proxy settings. + */ + setProxy(config: string, callback: Function): void; + /** + * Resolves the proxy information for url. + */ + resolveProxy(url: URL, callback: (proxy: any) => any): void; + /** + * Sets download saving directory. + * By default, the download directory will be the Downloads under the respective app folder. + */ + setDownloadPath(path: string): void; + /** + * Emulates network with the given configuration for the session. + */ + enableNetworkEmulation(options: NetworkEmulationOptions): void; + /** + * Disables any network emulation already active for the session. + * Resets to the original network configuration. + */ + disableNetworkEmulation(): void; + /** + * Sets the certificate verify proc for session. + */ + setCertificateVerifyProc(proc: CertificateVerifyProc): void; + /** + * Clears the host resolver cache. + */ + clearHostResolverCache(callback: Function): void; + /** + * The webRequest API set allows to intercept and modify contents of a request at various stages of its lifetime. + */ + webRequest: any; + } + + interface ClearStorageDataOptions { + /** + * Should follow window.location.origin’s representation scheme://host:port. + */ + origin?: string; + /** + * The types of storages to clear. + */ + storages?: ('appcache' | 'cookies' | 'filesystem' | 'indexdb' | 'localstorage' | 'shadercache' | 'websql' | 'serviceworkers')[]; + /** + * The types of quotas to clear. + */ + quotas?: ('temporary' | 'persistent' | 'syncable')[]; + } + + interface NetworkEmulationOptions { + /** + * Whether to emulate network outage. + */ + offline?: boolean; + /** + * RTT in ms. + */ + latency?: number; + /** + * Download rate in Bps. + */ + downloadThroughput?: number; + /** + * Upload rate in Bps. + */ + uploadThroughput?: number; + } + + interface CertificateVerifyProc { + (hostname: string, cert: any, callback: (accepted: boolean) => any): any; + } + + interface CookieFilter { + /** + * Retrieves cookies which are associated with url. Empty implies retrieving cookies of all urls. + */ + url?: string; + /** + * Filters cookies by name. + */ + name?: string; + /** + * Retrieves cookies whose domains match or are subdomains of domains. + */ + domain?: string; + /** + * Retrieves cookies whose path matches path. + */ + path?: string; + /** + * Filters cookies by their Secure property. + */ + secure?: boolean; + /** + * Filters out session or persistent cookies. + */ + session?: boolean; + } + + interface Cookie { + /** + * The name of the cookie. + */ + name: string; + /** + * The value of the cookie. + */ + value: string; + /** + * The domain of the cookie. + */ + domain: string; + /** + * Whether the cookie is a host-only cookie. + */ + hostOnly: string; + /** + * The path of the cookie. + */ + path: string; + /** + * Whether the cookie is marked as secure. + */ + secure: boolean; + /** + * Whether the cookie is marked as HTTP only. + */ + httpOnly: boolean; + /** + * Whether the cookie is a session cookie or a persistent cookie with an expiration date. + */ + session: boolean; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. + * Not provided for session cookies. + */ + expirationDate?: number; + } + + interface CookieDetails { + /** + * The URL associated with the cookie. + */ + url: string; + /** + * The name of the cookie. + * Default: empty. + */ + name?: string; + /** + * The value of the cookie. + * Default: empty. + */ + value?: string; + /** + * The domain of the cookie. + * Default: empty. + */ + domain?: string; + /** + * The path of the cookie. + * Default: empty. + */ + path?: string; + /** + * Whether the cookie should be marked as secure. + * Default: false. + */ + secure?: boolean; + /** + * Whether the cookie should be marked as HTTP only. + * Default: false. + */ + httpOnly?: boolean; + /** + * The expiration date of the cookie as the number of seconds since the UNIX epoch. + * If omitted, the cookie becomes a session cookie. + */ + expirationDate?: number; + } + + interface SessionCookies { + /** + * Sends a request to get all cookies matching filter. + */ + get(filter: CookieFilter, callback: (error: Error, cookies: Cookie[]) => void): void; + /** + * Sets the cookie with details. + */ + set(details: CookieDetails, callback: (error: Error) => void): void; + /** + * Removes the cookies matching url and name. + */ + remove(url: string, name: string, callback: Function): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/shell.md + + /** + * The shell module provides functions related to desktop integration. + */ + interface Shell { + /** + * Show the given file in a file manager. If possible, select the file. + */ + showItemInFolder(fullPath: string): void; + /** + * Open the given file in the desktop's default manner. + */ + openItem(fullPath: string): void; + /** + * Open the given external protocol URL in the desktop's default manner + * (e.g., mailto: URLs in the default mail user agent). + * @returns true if an application was available to open the URL, false otherwise. + */ + openExternal(url: string, options?: { + /** + * Bring the opened application to the foreground. + * Default: true. + */ + activate: boolean; + }): boolean; + /** + * Move the given file to trash. + * @returns boolean status for the operation. + */ + moveItemToTrash(fullPath: string): boolean; + /** + * Play the beep sound. + */ + beep(): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/tray.md + + /** + * A Tray represents an icon in an operating system's notification area. + */ + class Tray extends EventEmitter { + /** + * Emitted when the tray icon is clicked. + * Note: The bounds payload is only implemented on OS X and Windows. + */ + on(event: 'click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray icon is right clicked. + * Note: This is only implemented on OS X and Windows. + */ + on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray icon is double clicked. + * Note: This is only implemented on OS X and Windows. + */ + on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; + /** + * Emitted when the tray balloon shows. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-show', listener: Function): this; + /** + * Emitted when the tray balloon is clicked. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-click', listener: Function): this; + /** + * Emitted when the tray balloon is closed because of timeout or user manually closes it. + * Note: This is only implemented on Windows. + */ + on(event: 'balloon-closed', listener: Function): this; + /** + * Emitted when any dragged items are dropped on the tray icon. + * Note: This is only implemented on OS X. + */ + on(event: 'drop', listener: Function): this; + /** + * Emitted when dragged files are dropped in the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this; + /** + * Emitted when a drag operation enters the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drag-enter', listener: Function): this; + /** + * Emitted when a drag operation exits the tray icon. + * Note: This is only implemented on OS X + */ + on(event: 'drag-leave', listener: Function): this; + /** + * Emitted when a drag operation ends on the tray or ends at another location. + * Note: This is only implemented on OS X + */ + on(event: 'drag-end', listener: Function): this; + on(event: string, listener: Function): this; + /** + * Creates a new tray icon associated with the image. + */ + constructor(image: NativeImage|string); + /** + * Destroys the tray icon immediately. + */ + destroy(): void; + /** + * Sets the image associated with this tray icon. + */ + setImage(image: NativeImage|string): void; + /** + * Sets the image associated with this tray icon when pressed. + */ + setPressedImage(image: NativeImage): void; + /** + * Sets the hover text for this tray icon. + */ + setToolTip(toolTip: string): void; + /** + * Sets the title displayed aside of the tray icon in the status bar. + * Note: This is only implemented on OS X. + */ + setTitle(title: string): void; + /** + * Sets whether the tray icon is highlighted when it is clicked. + * Note: This is only implemented on OS X. + */ + setHighlightMode(highlight: boolean): void; + /** + * Displays a tray balloon. + * Note: This is only implemented on Windows. + */ + displayBalloon(options?: { + icon?: NativeImage; + title?: string; + content?: string; + }): void; + /** + * Popups the context menu of tray icon. When menu is passed, + * the menu will showed instead of the tray's context menu. + * The position is only available on Windows, and it is (0, 0) by default. + * Note: This is only implemented on OS X and Windows. + */ + popUpContextMenu(menu?: Menu, position?: { + x: number; + y: number; + }): void; + /** + * Sets the context menu for this icon. + */ + setContextMenu(menu: Menu): void; + } + + interface Modifiers { + altKey: boolean; + shiftKey: boolean; + ctrlKey: boolean; + metaKey: boolean; + } + + // https://github.com/atom/electron/blob/master/docs/api/web-contents.md + + /** + * A WebContents is responsible for rendering and controlling a web page. + */ + class WebContents extends EventEmitter { + /** + * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning, + * and the onload event was dispatched. + */ + on(event: 'did-finish-load', listener: Function): this; + /** + * This event is like did-finish-load but emitted when the load failed or was cancelled, + * e.g. window.stop() is invoked. + */ + on(event: 'did-fail-load', listener: (event: Event, errorCode: number, errorDescription: string, validatedURL: string) => void): this; + /** + * Emitted when a frame has done navigation. + */ + on(event: 'did-frame-finish-load', listener: (event: Event, isMainFrame: boolean) => void): this; + /** + * Corresponds to the points in time when the spinner of the tab started spinning. + */ + on(event: 'did-start-loading', listener: Function): this; + /** + * Corresponds to the points in time when the spinner of the tab stopped spinning. + */ + on(event: 'did-stop-loading', listener: Function): this; + /** + * Emitted when details regarding a requested resource are available. + * status indicates the socket connection to download the resource. + */ + on(event: 'did-get-response-details', listener: (event: Event, + status: boolean, + newURL: string, + originalURL: string, + httpResponseCode: number, + requestMethod: string, + referrer: string, + headers: any + ) => void): this; + /** + * + */ + on(event: 'did-get-redirect-request', listener: (event: Event, + oldURL: string, + newURL: string, + isMainFrame: boolean, + httpResponseCode: number, + requestMethod: string, + referrer: string, + headers: any + ) => void): this; + /** + * Emitted when the document in the given frame is loaded. + */ + on(event: 'dom-ready', listener: (event: Event) => void): this; + /** + * Emitted when page receives favicon URLs. + */ + on(event: 'page-favicon-updated', listener: (event: Event, favicons: string[]) => void): this; + /** + * Emitted when the page requests to open a new window for a url. + * It could be requested by window.open or an external link like . + * + * By default a new BrowserWindow will be created for the url. + * + * Calling event.preventDefault() will prevent creating new windows. + */ + on(event: 'new-window', listener: (event: Event, + url: string, + frameName: string, + disposition: 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'other', + /** + * The options which will be used for creating the new BrowserWindow. + */ + options: any + ) => void): this; + /** + * Emitted when a user or the page wants to start navigation. + * It can happen when the window.location object is changed or a user clicks a link in the page. + * + * This event will not emit when the navigation is started programmatically with APIs like + * webContents.loadURL and webContents.back. + * + * It is also not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + * + * Calling event.preventDefault() will prevent the navigation. + */ + on(event: 'will-navigate', listener: (event: Event, url: string) => void): this; + /** + * Emitted when a navigation is done. + * + * This event is not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + */ + on(event: 'did-navigate', listener: (event: Event, url: string) => void): this; + /** + * Emitted when an in-page navigation happened. + * + * When in-page navigation happens, the page URL changes but does not cause + * navigation outside of the page. Examples of this occurring are when anchor links + * are clicked or when the DOM hashchange event is triggered. + */ + on(event: 'did-navigate-in-page', listener: (event: Event, url: string) => void): this; + /** + * Emitted when the renderer process has crashed. + */ + on(event: 'crashed', listener: Function): this; + /** + * Emitted when a plugin process has crashed. + */ + on(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this; + /** + * Emitted when webContents is destroyed. + */ + on(event: 'destroyed', listener: Function): this; + /** + * Emitted when DevTools is opened. + */ + on(event: 'devtools-opened', listener: Function): this; + /** + * Emitted when DevTools is closed. + */ + on(event: 'devtools-closed', listener: Function): this; + /** + * Emitted when DevTools is focused / opened. + */ + on(event: 'devtools-focused', listener: Function): this; + /** + * Emitted when failed to verify the certificate for url. + * The usage is the same with the "certificate-error" event of app. + */ + on(event: 'certificate-error', listener: (event: Event, + url: string, + error: string, + certificate: Certificate, + callback: (trust: boolean) => void + ) => void): this; + /** + * Emitted when a client certificate is requested. + * The usage is the same with the "select-client-certificate" event of app. + */ + on(event: 'select-client-certificate', listener: (event: Event, + url: string, + certificateList: Certificate[], + callback: (certificate: Certificate) => void + ) => void): this; + /** + * Emitted when webContents wants to do basic auth. + * The usage is the same with the "login" event of app. + */ + on(event: 'login', listener: (event: Event, + request: LoginRequest, + authInfo: LoginAuthInfo, + callback: (username: string, password: string) => void + ) => void): this; + /** + * Emitted when a result is available for webContents.findInPage request. + */ + on(event: 'found-in-page', listener: (event: Event, result: { + requestId: number; + /** + * ndicates if more responses are to follow. + */ + finalUpdate: boolean; + /** + * Position of the active match. + */ + activeMatchOrdinal?: number; + /** + * Number of Matches. + */ + matches?: number; + /** + * Coordinates of first match region. + */ + selectionArea?: any; + }) => void): this; + /** + * Emitted when media starts playing. + */ + on(event: 'media-started-playing', listener: Function): this; + /** + * Emitted when media is paused or done playing. + */ + on(event: 'media-paused', listener: Function): this; + /** + * Emitted when a page’s theme color changes. This is usually due to encountering a meta tag: + * + */ + on(event: 'did-change-theme-color', listener: Function): this; + /** + * Emitted when the cursor’s type changes. + * If the type parameter is custom, the image parameter will hold the custom cursor image + * in a NativeImage, and the scale will hold scaling information for the image. + */ + on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number) => void): this; + on(event: string, listener: Function): this; + /** + * Loads the url in the window. + * @param url Must contain the protocol prefix (e.g., the http:// or file://). + */ + loadURL(url: string, options?: { + httpReferrer?: string; + userAgent?: string; + extraHeaders?: string; + }): void; + /** + * Initiates a download of the resource at url without navigating. + * The will-download event of session will be triggered. + */ + downloadURL(url: string): void; + /** + * @returns The URL of current web page. + */ + getURL(): string; + /** + * @returns The title of web page. + */ + getTitle(): string; + /** + * @returns The favicon of the web page. + */ + getFavicon(): NativeImage; + /** + * @returns Whether web page is still loading resources. + */ + isLoading(): boolean; + /** + * @returns Whether web page is waiting for a first-response for the main + * resource of the page. + */ + isWaitingForResponse(): boolean; + /** + * Stops any pending navigation. + */ + stop(): void; + /** + * Reloads current page. + */ + reload(): void; + /** + * Reloads current page and ignores cache. + */ + reloadIgnoringCache(): void; + /** + * @returns Whether the web page can go back. + */ + canGoBack(): boolean; + /** + * @returns Whether the web page can go forward. + */ + canGoForward(): boolean; + /** + * @returns Whether the web page can go to offset. + */ + canGoToOffset(offset: number): boolean; + /** + * Clears the navigation history. + */ + clearHistory(): void; + /** + * Makes the web page go back. + */ + goBack(): void; + /** + * Makes the web page go forward. + */ + goForward(): void; + /** + * Navigates to the specified absolute index. + */ + goToIndex(index: number): void; + /** + * Navigates to the specified offset from the "current entry". + */ + goToOffset(offset: number): void; + /** + * @returns Whether the renderer process has crashed. + */ + isCrashed(): boolean; + /** + * Overrides the user agent for this page. + */ + setUserAgent(userAgent: string): void; + /** + * @returns The user agent for this web page. + */ + getUserAgent(): string; + /** + * Injects CSS into this page. + */ + insertCSS(css: string): void; + /** + * Evaluates code in page. + * @param code Code to evaluate. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + /** + * Mute the audio on the current web page. + */ + setAudioMuted(muted: boolean): void; + /** + * @returns Whether this page has been muted. + */ + isAudioMuted(): boolean; + /** + * Executes Edit -> Undo command in page. + */ + undo(): void; + /** + * Executes Edit -> Redo command in page. + */ + redo(): void; + /** + * Executes Edit -> Cut command in page. + */ + cut(): void; + /** + * Executes Edit -> Copy command in page. + */ + copy(): void; + /** + * Executes Edit -> Paste command in page. + */ + paste(): void; + /** + * Executes Edit -> Paste and Match Style in page. + */ + pasteAndMatchStyle(): void; + /** + * Executes Edit -> Delete command in page. + */ + delete(): void; + /** + * Executes Edit -> Select All command in page. + */ + selectAll(): void; + /** + * Executes Edit -> Unselect command in page. + */ + unselect(): void; + /** + * Executes Edit -> Replace command in page. + */ + replace(text: string): void; + /** + * Executes Edit -> Replace Misspelling command in page. + */ + replaceMisspelling(text: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Starts a request to find all matches for the text in the web page and + * returns an Integer representing the request id used for the request. + * The result of the request can be obtained by subscribing to + * found-in-page event. + */ + findInPage(text: string, options?: FindInPageOptions): void; + /** + * Stops any findInPage request for the webContents with the provided + * action. + * @param action Specifies the action to take place when ending webContents.findInPage request. + * 'clearSelection' - Translate the selection into a normal selection. + * 'keepSelection' - Clear the selection. + * 'activateSelection' - Focus and click the selection node. + */ + stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void; + /** + * Checks if any serviceworker is registered. + */ + hasServiceWorker(callback: (hasServiceWorker: boolean) => void): void; + /** + * Unregisters any serviceworker if present. + */ + unregisterServiceWorker(callback: + /** + * @param isFulfilled Whether the JS promise is fulfilled. + */ + (isFulfilled: boolean) => void): void; + /** + * + * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing. + * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}). + * Note: + * On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size. + */ + print(options?: { + /** + * Don't ask user for print settings, defaults to false + */ + silent?: boolean; + /** + * Also prints the background color and image of the web page, defaults to false. + */ + printBackground: boolean; + }): void; + /** + * Prints windows' web page as PDF with Chromium's preview printing custom settings. + */ + printToPDF(options: { + /** + * Specify the type of margins to use. Default is 0. + * 0 - default + * 1 - none + * 2 - minimum + */ + marginsType?: number; + /** + * String - Specify page size of the generated PDF. Default is A4. + * A4 + * A3 + * Legal + * Letter + * Tabloid + */ + pageSize?: string; + /** + * Whether to print CSS backgrounds. Default is false. + */ + printBackground?: boolean; + /** + * Whether to print selection only. Default is false. + */ + printSelectionOnly?: boolean; + /** + * true for landscape, false for portrait. Default is false. + */ + landscape?: boolean; + }, + /** + * Callback function on completed converting to PDF. + * error Error + * data Buffer - PDF file content + */ + callback: (error: Error, data: Buffer) => void): void; + /** + * Adds the specified path to DevTools workspace. + */ + addWorkSpace(path: string): void; + /** + * Removes the specified path from DevTools workspace. + */ + removeWorkSpace(path: string): void; + /** + * Opens the developer tools. + */ + openDevTools(options?: { + /** + * Opens devtools in a new window. + */ + detach?: boolean; + }): void; + /** + * Closes the developer tools. + */ + closeDevTools(): void; + /** + * Returns whether the developer tools are opened. + */ + isDevToolsOpened(): boolean; + /** + * Returns whether the developer tools are focussed. + */ + isDevToolsFocused(): boolean; + /** + * Toggle the developer tools. + */ + toggleDevTools(): void; + /** + * Starts inspecting element at position (x, y). + */ + inspectElement(x: number, y: number): void; + /** + * Opens the developer tools for the service worker context. + */ + inspectServiceWorker(): void; + /** + * Send args.. to the web page via channel in asynchronous message, the web page + * can handle it by listening to the channel event of ipc module. + * Note: + * 1. The IPC message handler in web pages do not have a event parameter, + * which is different from the handlers on the main process. + * 2. There is no way to send synchronous messages from the main process + * to a renderer process, because it would be very easy to cause dead locks. + */ + send(channel: string, ...args: any[]): void; + /** + * Enable device emulation with the given parameters. + */ + enableDeviceEmulation(parameters: DeviceEmulationParameters): void; + /** + * Disable device emulation. + */ + disableDeviceEmulation(): void; + /** + * Sends an input event to the page. + */ + sendInputEvent(event: SendInputEvent): void; + /** + * Begin subscribing for presentation events and captured frames, + * The callback will be called when there is a presentation event. + */ + beginFrameSubscription(callback: ( + /** + * The frameBuffer is a Buffer that contains raw pixel data. + * On most machines, the pixel data is effectively stored in 32bit BGRA format, + * but the actual representation depends on the endianness of the processor + * (most modern processors are little-endian, on machines with big-endian + * processors the data is in 32bit ARGB format). + */ + frameBuffer: Buffer + ) => void): void; + /** + * End subscribing for frame presentation events. + */ + endFrameSubscription(): void; + /** + * @returns If the process of saving page has been initiated successfully. + */ + savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback?: (eror: Error) => void): boolean; + /** + * @returns The session object used by this webContents. + */ + session: Session; + /** + * @returns The WebContents that might own this WebContents. + */ + hostWebContents: WebContents; + /** + * @returns The WebContents of DevTools for this WebContents. + * Note: Users should never store this object because it may become null + * when the DevTools has been closed. + */ + devToolsWebContents: WebContents; + /** + * @returns Debugger API + */ + debugger: Debugger; + } + + type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' |'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom'; + + interface Certificate { + /** + * PEM encoded data + */ + data: Buffer; + issuerName: string; + } + + interface LoginRequest { + method: string; + url: string; + referrer: string; + } + + interface LoginAuthInfo { + isProxy: boolean; + scheme: string; + host: string; + port: number; + realm: string; + } + + interface FindInPageOptions { + /** + * Whether to search forward or backward, defaults to true + */ + forward?: boolean; + /** + * Whether the operation is first request or a follow up, defaults to false. + */ + findNext?: boolean; + /** + * Whether search should be case-sensitive, defaults to false. + */ + matchCase?: boolean; + /** + * Whether to look only at the start of words. defaults to false. + */ + wordStart?: boolean; + /** + * When combined with wordStart, accepts a match in the middle of a word + * if the match begins with an uppercase letter followed by a lowercase + * or non-letter. Accepts several other intra-word matches, defaults to false. + */ + medialCapitalAsWordStart?: boolean; + } + + interface DeviceEmulationParameters { + /** + * Specify the screen type to emulated + * Default: desktop + */ + screenPosition?: 'desktop' | 'mobile'; + /** + * Set the emulated screen size (screenPosition == mobile) + */ + screenSize?: { + /** + * Set the emulated screen width + */ + width: number; + /** + * Set the emulated screen height + */ + height: number; + }; + /** + * Position the view on the screen (screenPosition == mobile) + * Default: {x: 0, y: 0} + */ + viewPosition?: { + /** + * Set the x axis offset from top left corner + */ + x: number; + /** + * Set the y axis offset from top left corner + */ + y: number; + }; + /** + * Set the device scale factor (if zero defaults to original device scale factor) + * Default: 0 + */ + deviceScaleFactor: number; + /** + * Set the emulated view size (empty means no override). + */ + viewSize?: { + /** + * Set the emulated view width + */ + width: number; + /** + * Set the emulated view height + */ + height: number; + }; + /** + * Whether emulated view should be scaled down if necessary to fit into available space + * Default: false + */ + fitToView?: boolean; + /** + * Offset of the emulated view inside available space (not in fit to view mode) + * Default: {x: 0, y: 0} + */ + offset?: { + /** + * Set the x axis offset from top left corner + */ + x: number; + /** + * Set the y axis offset from top left corner + */ + y: number; + }; + /** + * Scale of emulated view inside available space (not in fit to view mode) + * Default: 1 + */ + scale: number; + } + + interface SendInputEvent { + type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove' | 'keyDown' | 'keyUp' | 'char'; + modifiers: ('shift' | 'control' | 'alt' | 'meta' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right')[]; + } + + interface SendInputKeyboardEvent extends SendInputEvent { + keyCode: string; + } + + interface SendInputMouseEvent extends SendInputEvent { + x: number; + y: number; + button?: 'left' | 'middle' | 'right'; + globalX?: number; + globalY?: number; + movementX?: number; + movementY?: number; + clickCount?: number; + } + + interface SendInputMouseWheelEvent extends SendInputEvent { + deltaX?: number; + deltaY?: number; + wheelTicksX?: number; + wheelTicksY?: number; + accelerationRatioX?: number; + accelerationRatioY?: number; + hasPreciseScrollingDeltas?: number; + canScroll?: boolean; + } + + /** + * Debugger API serves as an alternate transport for remote debugging protocol. + */ + interface Debugger extends NodeJS.EventEmitter { + /** + * Attaches the debugger to the webContents. + * @param protocolVersion Requested debugging protocol version. + */ + attach(protocolVersion?: string): void; + /** + * @returns Whether a debugger is attached to the webContents. + */ + isAttached(): boolean; + /** + * Detaches the debugger from the webContents. + */ + detach(): void; + /** + * Send given command to the debugging target. + * @param method Method name, should be one of the methods defined by the remote debugging protocol. + * @param commandParams JSON object with request parameters. + * @param callback Response defined by the ‘returns’ attribute of the command description in the remote debugging protocol. + */ + sendCommand(method: string, commandParams?: any, callback?: (error: Error, result: any) => void): void; + /** + * Emitted when debugging session is terminated. This happens either when + * webContents is closed or devtools is invoked for the attached webContents. + */ + on(event: 'detach', listener: (event: Event, reason: string) => void): this; + /** + * Emitted whenever debugging target issues instrumentation event. + * Event parameters defined by the ‘parameters’ attribute in the remote debugging protocol. + */ + on(event: 'message', listener: (event: Event, method: string, params: any) => void): this; + on(event: string, listener: Function): this; + } + + // https://github.com/atom/electron/blob/master/docs/api/web-frame.md + + /** + * The web-frame module allows you to customize the rendering of the current web page. + */ + interface WebFrame { + /** + * Changes the zoom factor to the specified factor, zoom factor is + * zoom percent / 100, so 300% = 3.0. + */ + setZoomFactor(factor: number): void; + /** + * @returns The current zoom factor. + */ + getZoomFactor(): number; + /** + * Changes the zoom level to the specified level, 0 is "original size", and each + * increment above or below represents zooming 20% larger or smaller to default + * limits of 300% and 50% of original size, respectively. + */ + setZoomLevel(level: number): void; + /** + * @returns The current zoom level. + */ + getZoomLevel(): number; + /** + * Sets the maximum and minimum zoom level. + */ + setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; + /** + * Sets a provider for spell checking in input fields and text areas. + */ + setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: { + /** + * @returns Whether the word passed is correctly spelled. + */ + spellCheck: (text: string) => boolean; + }): void; + /** + * Sets the scheme as secure scheme. Secure schemes do not trigger mixed content + * warnings. For example, https and data are secure schemes because they cannot be + * corrupted by active network attackers. + */ + registerURLSchemeAsSecure(scheme: string): void; + /** + * Resources will be loaded from this scheme regardless of the current page’s Content Security Policy. + */ + registerURLSchemeAsBypassingCSP(scheme: string): void; + /** + * Registers the scheme as secure, bypasses content security policy for resources, + * allows registering ServiceWorker and supports fetch API. + */ + registerURLSchemeAsPrivileged(scheme: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Evaluates `code` in page. + * In the browser window some HTML APIs like `requestFullScreen` can only be + * invoked by a gesture from the user. Setting `userGesture` to `true` will remove + * this limitation. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + } + + /** + * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window. + */ + class BrowserWindowProxy { + /** + * Removes focus from the child window. + */ + blur(): void; + /** + * Forcefully closes the child window without calling its unload event. + */ + close(): void; + /** + * Set to true after the child window gets closed. + */ + closed: boolean; + /** + * Evaluates the code in the child window. + */ + eval(code: string): void; + /** + * Focuses the child window (brings the window to front). + */ + focus(): void; + /** + * Sends a message to the child window with the specified origin or * for no origin preference. + * In addition to these methods, the child window implements window.opener object with no + * properties and a single method. + */ + postMessage(message: string, targetOrigin: string): void; + } + + // https://github.com/atom/electron/blob/master/docs/api/synopsis.md + interface CommonElectron { clipboard: Electron.Clipboard; crashReporter: Electron.CrashReporter; @@ -65,6 +3706,25 @@ declare namespace Electron { } } +// https://github.com/atom/electron/blob/master/docs/api/window-open.md + +interface Window { + /** + * Creates a new window. + * @returns An instance of BrowserWindowProxy class. + */ + open(url: string, frameName?: string, features?: string): Electron.BrowserWindowProxy; +} + +// https://github.com/atom/electron/blob/master/docs/api/file-object.md + +interface File { + /** + * Exposes the real path of the filesystem. + */ + path: string; +} + declare module 'electron' { var electron: Electron.ElectronMainAndRenderer; export = electron; diff --git a/github-electron/github-electron.desktop-capturer.d.ts b/github-electron/github-electron.desktop-capturer.d.ts deleted file mode 100644 index d938a1ed03..0000000000 --- a/github-electron/github-electron.desktop-capturer.d.ts +++ /dev/null @@ -1,55 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The desktopCapturer module can be used to get available sources - * that can be used to be captured with getUserMedia. - */ - interface DesktopCapturer { - /** - * Starts a request to get all desktop sources. - * - * Note: There is no guarantee that the size of source.thumbnail is always - * the same as the thumnbailSize in options. It also depends on the scale of the screen or window. - */ - getSources(options: any, callback: (error: Error, sources: DesktopCapturerSource[]) => any): void; - } - - interface DesktopCapturerOptions { - /** - * The types of desktop sources to be captured. - */ - types?: ('screen' | 'window')[]; - /** - * The suggested size that thumbnail should be scaled. - * Default: {width: 150, height: 150} - */ - thumbnailSize?: { - width: number; - height: number; - }; - } - - interface DesktopCapturerSource { - /** - * The id of the captured window or screen used in navigator.webkitGetUserMedia. - * The format looks like window:XX or screen:XX where XX is a random generated number. - */ - id: string; - /** - * The described name of the capturing screen or window. - * If the source is a screen, the name will be Entire Screen or Screen ; - * if it is a window, the name will be the window’s title. - */ - name: string; - /** - * A thumbnail image. - */ - thumbnail: NativeImage; - } -} diff --git a/github-electron/github-electron.dialog.d.ts b/github-electron/github-electron.dialog.d.ts deleted file mode 100644 index aa1081e79b..0000000000 --- a/github-electron/github-electron.dialog.d.ts +++ /dev/null @@ -1,141 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Electron { - /** - * The dialog module provides APIs to show native system dialogs, such as opening files or alerting, - * so web applications can deliver the same user experience as native applications. - */ - interface Dialog { - /** - * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, - * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. - * - * @param callback If supplied, the API call will be asynchronous. - * @returns On success, returns an array of file paths chosen by the user, - * otherwise returns undefined. - */ - showOpenDialog(browserWindow: BrowserWindow, options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; - /** - * Note: On Windows and Linux an open dialog can not be both a file selector and a directory selector, - * so if you set properties to ['openFile', 'openDirectory'] on these platforms, a directory selector will be shown. - * - * @param callback If supplied, the API call will be asynchronous. - * @returns On success, returns an array of file paths chosen by the user, - * otherwise returns undefined. - */ - showOpenDialog(options: OpenDialogOptions, callback?: (fileNames: string[]) => void): string[]; - /** - * @param callback If supplied, the API call will be asynchronous. - * @returns On success, returns the path of file chosen by the user, otherwise - * returns undefined. - */ - showSaveDialog(browserWindow: BrowserWindow, options: SaveDialogOptions, callback?: (fileName: string) => void): string; - /** - * @param callback If supplied, the API call will be asynchronous. - * @returns On success, returns the path of file chosen by the user, otherwise - * returns undefined. - */ - showSaveDialog(options: SaveDialogOptions, callback?: (fileName: string) => void): string; - /** - * Shows a message box. It will block until the message box is closed. - * @param callback If supplied, the API call will be asynchronous. - * @returns The index of the clicked button. - */ - showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: any) => void): number; - /** - * Shows a message box. It will block until the message box is closed. - * @param callback If supplied, the API call will be asynchronous. - * @returns The index of the clicked button. - */ - showMessageBox(options: ShowMessageBoxOptions, callback?: (response: any) => void): number; - /** - * Displays a modal dialog that shows an error message. - * - * This API can be called safely before the ready event the app module emits, - * it is usually used to report errors in early stage of startup. - * If called before the app readyevent on Linux, the message will be emitted to stderr, - * and no GUI dialog will appear. - */ - showErrorBox(title: string, content: string): void; - } - - interface OpenDialogOptions { - title?: string; - defaultPath?: string; - /** - * File types that can be displayed or selected. - */ - filters?: { - name: string; - /** - * Extensions without wildcards or dots (e.g. 'png' is good but '.png' and '*.png' are bad). - * To show all files, use the '*' wildcard (no other wildcard is supported). - */ - extensions: string[]; - }[]; - /** - * Contains which features the dialog should use. - */ - properties?: ('openFile' | 'openDirectory' | 'multiSelections' | 'createDirectory')[]; - } - - interface SaveDialogOptions { - title?: string; - defaultPath?: string; - /** - * File types that can be displayed, see dialog.showOpenDialog for an example. - */ - filters?: { - name: string; - extensions: string[]; - }[]; - } - - interface ShowMessageBoxOptions { - /** - * On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option. - */ - type?: 'none' | 'info' | 'error' | 'question' | 'warning'; - /** - * Texts for buttons. - */ - buttons?: string[]; - /** - * Index of the button in the buttons array which will be selected by default when the message box opens. - */ - defaultId?: number; - /** - * Title of the message box (some platforms will not show it). - */ - title?: string; - /** - * Contents of the message box. - */ - message?: string; - /** - * Extra information of the message. - */ - detail?: string; - icon?: NativeImage; - /** - * The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog. - * By default it is the index of the buttons that have "cancel" or "no" as label, - * or 0 if there is no such buttons. On OS X and Windows the index of "Cancel" button - * will always be used as cancelId, not matter whether it is already specified. - */ - cancelId?: number; - /** - * On Windows Electron will try to figure out which one of the buttons are common buttons - * (like "Cancel" or "Yes"), and show the others as command links in the dialog. - * This can make the dialog appear in the style of modern Windows apps. - * If you don’t like this behavior, you can set noLink to true. - */ - noLink?: boolean; - } -} diff --git a/github-electron/github-electron.dom.d.ts b/github-electron/github-electron.dom.d.ts deleted file mode 100644 index ec69a4e736..0000000000 --- a/github-electron/github-electron.dom.d.ts +++ /dev/null @@ -1,51 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - - class BrowserWindowProxy { - /** - * Removes focus from the child window. - */ - blur(): void; - /** - * Forcefully closes the child window without calling its unload event. - */ - close(): void; - /** - * Set to true after the child window gets closed. - */ - closed: boolean; - /** - * Evaluates the code in the child window. - */ - eval(code: string): void; - /** - * Focuses the child window (brings the window to front). - */ - focus(): void; - /** - * Sends a message to the child window with the specified origin or * for no origin preference. - * In addition to these methods, the child window implements window.opener object with no - * properties and a single method. - */ - postMessage(message: string, targetOrigin: string): void; - } - - interface Window { - /** - * Creates a new window. - * @returns An instance of BrowserWindowProxy class. - */ - open(url: string, frameName?: string, features?: string): BrowserWindowProxy; - } - - interface File { - /** - * Exposes the real path of the filesystem. - */ - path: string; - } -} diff --git a/github-electron/github-electron.event-emitter.d.ts b/github-electron/github-electron.event-emitter.d.ts deleted file mode 100644 index d1aa1ff8a9..0000000000 --- a/github-electron/github-electron.event-emitter.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - class EventEmitter implements NodeJS.EventEmitter { - addListener(event: string, listener: Function): this; - on(event: string, listener: Function): this; - once(event: string, listener: Function): this; - removeListener(event: string, listener: Function): this; - removeAllListeners(event?: string): this; - setMaxListeners(n: number): this; - getMaxListeners(): number; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - listenerCount(type: string): number; - } - - interface Event { - preventDefault: Function; - sender: EventEmitter; - } -} diff --git a/github-electron/github-electron.global-shortcut.d.ts b/github-electron/github-electron.global-shortcut.d.ts deleted file mode 100644 index 6ea804b722..0000000000 --- a/github-electron/github-electron.global-shortcut.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The globalShortcut module can register/unregister a global keyboard shortcut - * with the operating system so that you can customize the operations for various shortcuts. - * Note: The shortcut is global; it will work even if the app does not have the keyboard focus. - * You should not use this module until the ready event of the app module is emitted. - */ - interface GlobalShortcut { - /** - * Registers a global shortcut of accelerator. - * @param accelerator Represents a keyboard shortcut. It can contain modifiers - * and key codes, combined by the "+" character. - * @param callback Called when the registered shortcut is pressed by the user. - */ - register(accelerator: string, callback: Function): void; - /** - * @param accelerator Represents a keyboard shortcut. It can contain modifiers - * and key codes, combined by the "+" character. - * @returns Whether the accelerator is registered. - */ - isRegistered(accelerator: string): boolean; - /** - * Unregisters the global shortcut of keycode. - * @param accelerator Represents a keyboard shortcut. It can contain modifiers - * and key codes, combined by the "+" character. - */ - unregister(accelerator: string): void; - /** - * Unregisters all the global shortcuts. - */ - unregisterAll(): void; - } -} diff --git a/github-electron/github-electron.ipc-main.d.ts b/github-electron/github-electron.ipc-main.d.ts deleted file mode 100644 index 200f1af150..0000000000 --- a/github-electron/github-electron.ipc-main.d.ts +++ /dev/null @@ -1,36 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Electron { - /** - * The ipcMain module handles asynchronous and synchronous messages - * sent from a renderer process (web page). - * Messages sent from a renderer will be emitted to this module. - */ - class IpcMain extends EventEmitter { - addListener(channel: string, listener: IpcMainEventListener): this; - on(channel: string, listener: IpcMainEventListener): this; - once(channel: string, listener: IpcMainEventListener): this; - removeListener(channel: string, listener: IpcMainEventListener): this; - removeAllListeners(channel?: string): this; - } - - type IpcMainEventListener = (event: IpcMainEvent, ...args: any[]) => void; - - interface IpcMainEvent { - /** - * Set this to the value to be returned in a synchronous message. - */ - returnValue?: any; - /** - * Returns the webContents that sent the message, you can call sender.send - * to reply to the asynchronous message. - */ - sender: WebContents; - } -} diff --git a/github-electron/github-electron.ipc-renderer.d.ts b/github-electron/github-electron.ipc-renderer.d.ts deleted file mode 100644 index 00f429eebe..0000000000 --- a/github-electron/github-electron.ipc-renderer.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The ipcRenderer module provides a few methods so you can send synchronous - * and asynchronous messages from the render process (web page) to the main process. - * You can also receive replies from the main process. - */ - class IpcRenderer extends EventEmitter { - addListener(channel: string, listener: IpcRendererEventListener): this; - on(channel: string, listener: IpcRendererEventListener): this; - once(channel: string, listener: IpcRendererEventListener): this; - removeListener(channel: string, listener: IpcRendererEventListener): this; - removeAllListeners(channel?: string): this; - /** - * Send ...args to the renderer via channel in asynchronous message, the main - * process can handle it by listening to the channel event of ipc module. - */ - send(channel: string, ...args: any[]): void; - /** - * Send ...args to the renderer via channel in synchronous message, and returns - * the result sent from main process. The main process can handle it by listening - * to the channel event of ipc module, and returns by setting event.returnValue. - * Note: Usually developers should never use this API, since sending synchronous - * message would block the whole renderer process. - * @returns The result sent from the main process. - */ - sendSync(channel: string, ...args: any[]): any; - /** - * Like ipc.send but the message will be sent to the host page instead of the main process. - * This is mainly used by the page in to communicate with host page. - */ - sendToHost(channel: string, ...args: any[]): void; - } - - type IpcRendererEventListener = (event: IpcRendererEvent, ...args: any[]) => void; - - interface IpcRendererEvent { - /** - * You can call sender.send to reply to the asynchronous message. - */ - sender: IpcRenderer; - } -} diff --git a/github-electron/github-electron.menu-item.d.ts b/github-electron/github-electron.menu-item.d.ts deleted file mode 100644 index 7280e37bc6..0000000000 --- a/github-electron/github-electron.menu-item.d.ts +++ /dev/null @@ -1,130 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// - -declare namespace Electron { - /** - * The MenuItem allows you to add items to an application or context menu. - */ - class MenuItem { - /** - * Create a new menu item. - */ - constructor(options: MenuItemOptions); - - click: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; - /** - * Read-only property. - */ - type: MenuItemType; - /** - * Read-only property. - */ - role: MenuItemRole | MenuItemRoleMac; - /** - * Read-only property. - */ - accelerator: string; - /** - * Read-only property. - */ - icon: NativeImage | string; - /** - * Read-only property. - */ - submenu: Menu | MenuItemOptions[]; - - label: string; - sublabel: string; - enabled: boolean; - visible: boolean; - checked: boolean; - } - - type MenuItemType = 'normal' | 'separator' | 'submenu' | 'checkbox' | 'radio'; - type MenuItemRole = 'undo' | 'redo' | 'cut' | 'copy' | 'paste' | 'selectall' | 'minimize' | 'close'; - type MenuItemRoleMac = 'about' | 'hide' | 'hideothers' | 'unhide' | 'front' | 'window' | 'help' | 'services'; - - interface MenuItemOptions { - /** - * Callback when the menu item is clicked. - */ - click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; - /** - * Can be normal, separator, submenu, checkbox or radio. - */ - type?: MenuItemType; - label?: string; - sublabel?: string; - /** - * An accelerator is string that represents a keyboard shortcut, it can contain - * multiple modifiers and key codes, combined by the + character. - * - * Examples: - * Command+A - * Ctrl+Shift+Z - * - * Platform notice: On Linux and Windows, the Command key would not have any effect, - * you can use CommandOrControl which represents Command on OS X and Control on - * Linux and Windows to define some accelerators. - * - * Available modifiers: - * Command (or Cmd for short) - * Control (or Ctrl for short) - * CommandOrControl (or CmdOrCtrl for short) - * Alt - * Shift - * - * Available key codes: - * 0 to 9 - * A to Z - * F1 to F24 - * Punctuations like ~, !, @, #, $, etc. - * Plus - * Space - * Backspace - * Delete - * Insert - * Return (or Enter as alias) - * Up, Down, Left and Right - * Home and End - * PageUp and PageDown - * Escape (or Esc for short) - * VolumeUp, VolumeDown and VolumeMute - * MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause - */ - accelerator?: string; - /** - * In Electron for the APIs that take images, you can pass either file paths - * or NativeImage instances. When passing null, an empty image will be used. - */ - icon?: NativeImage|string; - enabled?: boolean; - visible?: boolean; - checked?: boolean; - /** - * Should be specified for submenu type menu item, when it's specified the - * type: 'submenu' can be omitted for the menu item - */ - submenu?: Menu|MenuItemOptions[]; - /** - * Unique within a single menu. If defined then it can be used as a reference - * to this item by the position attribute. - */ - id?: string; - /** - * This field allows fine-grained definition of the specific location within - * a given menu. - */ - position?: string; - /** - * Define the action of the menu item, when specified the click property will be ignored - */ - role?: MenuItemRole | MenuItemRoleMac; - } -} diff --git a/github-electron/github-electron.menu.d.ts b/github-electron/github-electron.menu.d.ts deleted file mode 100644 index 6fa4941c11..0000000000 --- a/github-electron/github-electron.menu.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// - -declare namespace Electron { - /** - * The Menu class is used to create native menus that can be used as application - * menus and context menus. This module is a main process module which can be used - * in a render process via the remote module. - * - * Each menu consists of multiple menu items, and each menu item can have a submenu. - */ - class Menu extends EventEmitter { - /** - * Creates a new menu. - */ - constructor(); - /** - * Sets menu as the application menu on OS X. On Windows and Linux, the menu - * will be set as each window's top menu. - */ - static setApplicationMenu(menu: Menu): void; - /** - * Sends the action to the first responder of application. - * This is used for emulating default Cocoa menu behaviors, - * usually you would just use the role property of MenuItem. - * - * Note: This method is OS X only. - */ - static sendActionToFirstResponder(action: string): void; - /** - * @param template Generally, just an array of options for constructing MenuItem. - * You can also attach other fields to element of the template, and they will - * become properties of the constructed menu items. - */ - static buildFromTemplate(template: MenuItemOptions[]): Menu; - /** - * Popups this menu as a context menu in the browserWindow. You can optionally - * provide a (x,y) coordinate to place the menu at, otherwise it will be placed - * at the current mouse cursor position. - * @param x Horizontal coordinate where the menu will be placed. - * @param y Vertical coordinate where the menu will be placed. - */ - popup(browserWindow?: BrowserWindow, x?: number, y?: number): void; - /** - * Appends the menuItem to the menu. - */ - append(menuItem: MenuItem): void; - /** - * Inserts the menuItem to the pos position of the menu. - */ - insert(position: number, menuItem: MenuItem): void; - /** - * @returns an array containing the menu’s items. - */ - items: MenuItem[]; - } -} diff --git a/github-electron/github-electron.native-image.d.ts b/github-electron/github-electron.native-image.d.ts deleted file mode 100644 index f67d4afcd7..0000000000 --- a/github-electron/github-electron.native-image.d.ts +++ /dev/null @@ -1,59 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * This class is used to represent an image. - */ - class NativeImage { - /** - * Creates an empty NativeImage instance. - */ - static createEmpty(): NativeImage; - /** - * Creates a new NativeImage instance from file located at path. - */ - static createFromPath(path: string): NativeImage; - /** - * Creates a new NativeImage instance from buffer. - * @param scaleFactor 1.0 by default. - */ - static createFromBuffer(buffer: Buffer, scaleFactor?: number): NativeImage; - /** - * Creates a new NativeImage instance from dataURL - */ - static createFromDataURL(dataURL: string): NativeImage; - /** - * @returns Buffer Contains the image's PNG encoded data. - */ - toPng(): Buffer; - /** - * @returns Buffer Contains the image's JPEG encoded data. - */ - toJpeg(quality: number): Buffer; - /** - * @returns string The data URL of the image. - */ - toDataURL(): string; - /** - * @returns boolean Whether the image is empty. - */ - isEmpty(): boolean; - /** - * @returns {} The size of the image. - */ - getSize(): any; - /** - * Marks the image as template image. - */ - setTemplateImage(option: boolean): void; - /** - * Returns a boolean whether the image is a template image. - */ - isTemplateImage(): boolean; - } -} diff --git a/github-electron/github-electron.power-monitor.d.ts b/github-electron/github-electron.power-monitor.d.ts deleted file mode 100644 index a6eb577276..0000000000 --- a/github-electron/github-electron.power-monitor.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The power-monitor module is used to monitor power state changes. - * You should not use this module until the ready event of the app module is emitted. - */ - interface PowerMonitor extends NodeJS.EventEmitter { - /** - * Emitted when the system is suspending. - */ - on(event: 'suspend', listener: Function): this; - /** - * Emitted when system is resuming. - */ - on(event: 'resume', listener: Function): this; - /** - * Emitted when the system changes to AC power. - */ - on(event: 'on-ac', listener: Function): this; - /** - * Emitted when system changes to battery power. - */ - on(event: 'on-battery', listener: Function): this; - on(event: string, listener: Function): this; - } -} diff --git a/github-electron/github-electron.power-save-blocker.d.ts b/github-electron/github-electron.power-save-blocker.d.ts deleted file mode 100644 index 31135e4381..0000000000 --- a/github-electron/github-electron.power-save-blocker.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The powerSaveBlocker module is used to block the system from entering - * low-power (sleep) mode and thus allowing the app to keep the system and screen active. - */ - interface PowerSaveBlocker { - /** - * Starts preventing the system from entering lower-power mode. - * @returns an integer identifying the power save blocker. - * Note: prevent-display-sleep has higher has precedence over prevent-app-suspension. - */ - start(type: 'prevent-app-suspension' | 'prevent-display-sleep'): number; - /** - * @param id The power save blocker id returned by powerSaveBlocker.start. - * Stops the specified power save blocker. - */ - stop(id: number): void; - /** - * @param id The power save blocker id returned by powerSaveBlocker.start. - * @returns a boolean whether the corresponding powerSaveBlocker has started. - */ - isStarted(id: number): boolean; - } -} diff --git a/github-electron/github-electron.protocol.d.ts b/github-electron/github-electron.protocol.d.ts deleted file mode 100644 index f34de22e84..0000000000 --- a/github-electron/github-electron.protocol.d.ts +++ /dev/null @@ -1,121 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The protocol module can register a custom protocol or intercept an existing protocol. - */ - interface Protocol { - /** - * Registers custom schemes as standard schemes. - */ - registerStandardSchemes(schemes: string[]): void; - /** - * Registers custom schemes to handle service workers. - */ - registerServiceWorkerSchemes(schemes: string[]): void; - /** - * Registers a protocol of scheme that will send the file as a response. - */ - registerFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Registers a protocol of scheme that will send a Buffer as a response. - */ - registerBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Registers a protocol of scheme that will send a String as a response. - */ - registerStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Registers a protocol of scheme that will send an HTTP request as a response. - */ - registerHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Unregisters the custom protocol of scheme. - */ - unregisterProtocol(scheme: string, completion?: (error: Error) => void): void; - /** - * The callback will be called with a boolean that indicates whether there is already a handler for scheme. - */ - isProtocolHandled(scheme: string, callback: (handled: boolean) => void): void; - /** - * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a file as a response. - */ - interceptFileProtocol(scheme: string, handler: (request: ProtocolRequest, callback: FileProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a String as a response. - */ - interceptStringProtocol(scheme: string, handler: (request: ProtocolRequest, callback: BufferProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a Buffer as a response. - */ - interceptBufferProtocol(scheme: string, handler: (request: ProtocolRequest, callback: StringProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Intercepts scheme protocol and uses handler as the protocol’s new handler which sends a new HTTP request as a response. - */ - interceptHttpProtocol(scheme: string, handler: (request: ProtocolRequest, callback: HttpProtocolCallback) => void, completion?: (error: Error) => void): void; - /** - * Remove the interceptor installed for scheme and restore its original handler. - */ - uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void; - } - - type ProtocolRequest = { - url: string; - referrer: string; - method: string; - uploadData?: { - bytes: Buffer, - file: string - }[]; - } - - interface ProtocolCallback { - (error: number): void; - (obj: { - error: number - }): void; - (): void; - } - - interface FileProtocolCallback extends ProtocolCallback { - (filePath: string): void; - (obj: { - path: string - }): void; - } - - interface BufferProtocolCallback extends ProtocolCallback { - (buffer: Buffer): void; - (obj: { - data: Buffer, - mimeType: string, - charset?: string - }): void; - } - - interface StringProtocolCallback extends ProtocolCallback { - (str: string): void; - (obj: { - data: Buffer, - mimeType: string, - charset?: string - }): void; - } - - interface HttpProtocolCallback extends ProtocolCallback { - (redirectRequest: { - url: string; - method: string; - session?: Object; - uploadData?: { - contentType: string; - data: string; - }; - }): void; - } -} diff --git a/github-electron/github-electron.remote.d.ts b/github-electron/github-electron.remote.d.ts deleted file mode 100644 index 7888ee2ffd..0000000000 --- a/github-electron/github-electron.remote.d.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// - -declare namespace Electron { - /** - * The remote module provides a simple way to do inter-process communication (IPC) - * between the renderer process (web page) and the main process. - */ - interface Remote extends CommonElectron { - /** - * @returns The object returned by require(module) in the main process. - */ - require(module: string): any; - /** - * @returns The BrowserWindow object which this web page belongs to. - */ - getCurrentWindow(): BrowserWindow; - /** - * @returns The WebContents object of this web page. - */ - getCurrentWebContents(): WebContents; - /** - * @returns The global variable of name (e.g. global[name]) in the main process. - */ - getGlobal(name: string): any; - /** - * Returns the process object in the main process. This is the same as - * remote.getGlobal('process'), but gets cached. - */ - process: NodeJS.Process; - } -} diff --git a/github-electron/github-electron.screen.d.ts b/github-electron/github-electron.screen.d.ts deleted file mode 100644 index 93c854229b..0000000000 --- a/github-electron/github-electron.screen.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare namespace Electron { - /** - * The Display object represents a physical display connected to the system. - * A fake Display may exist on a headless system, or a Display may correspond to a remote, virtual display. - */ - interface Display { - /** - * Unique identifier associated with the display. - */ - id: number; - bounds: Bounds; - workArea: Bounds; - size: Dimension; - workAreaSize: Dimension; - /** - * Output device’s pixel scale factor. - */ - scaleFactor: number; - /** - * Can be 0, 1, 2, 3, each represents screen rotation in clock-wise degrees of 0, 90, 180, 270. - */ - rotation: number; - touchSupport: 'available' | 'unavailable' | 'unknown'; - } - - interface Bounds { - x: number; - y: number; - width: number; - height: number; - } - - interface Dimension { - width: number; - height: number; - } - - interface Point { - x: number; - y: number; - } - - type DisplayMetrics = 'bounds' | 'workArea' | 'scaleFactor' | 'rotation'; - - /** - * The screen module retrieves information about screen size, displays, cursor position, etc. - * You should not use this module until the ready event of the app module is emitted. - */ - class Screen extends EventEmitter { - /** - * Emitted when newDisplay has been added. - */ - on(event: 'display-added', listener: (event: Event, newDisplay: Display) => void): this; - /** - * Emitted when oldDisplay has been removed. - */ - on(event: 'display-removed', listener: (event: Event, oldDisplay: Display) => void): this; - /** - * Emitted when one or more metrics change in a display. - */ - on(event: 'display-metrics-changed', listener: (event: Event, display: Display, changedMetrics: DisplayMetrics[]) => void): this; - on(event: string, listener: Function): this; - /** - * @returns The current absolute position of the mouse pointer. - */ - getCursorScreenPoint(): Point; - /** - * @returns The primary display. - */ - getPrimaryDisplay(): Display; - /** - * @returns An array of displays that are currently available. - */ - getAllDisplays(): Display[]; - /** - * @returns The display nearest the specified point. - */ - getDisplayNearestPoint(point: Point): Display; - /** - * @returns The display that most closely intersects the provided bounds. - */ - getDisplayMatching(rect: Bounds): Display; - } -} diff --git a/github-electron/github-electron.session.d.ts b/github-electron/github-electron.session.d.ts deleted file mode 100644 index 523099b3c8..0000000000 --- a/github-electron/github-electron.session.d.ts +++ /dev/null @@ -1,318 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare namespace Electron { - /** - * The session module can be used to create new Session objects. - * You can also access the session of existing pages by using - * the session property of webContents which is a property of BrowserWindow. - */ - class Session extends EventEmitter { - /** - * @returns a new Session instance from partition string. - */ - static fromPartition(partition: string): Session; - /** - * @returns the default session object of the app. - */ - static defaultSession: Session; - /** - * Emitted when Electron is about to download item in webContents. - * Calling event.preventDefault() will cancel the download - * and item will not be available from next tick of the process. - */ - on(event: 'will-download', listener: (event: Event, item: DownloadItem, webContents: WebContents) => void): this; - on(event: string, listener: Function): this; - /** - * The cookies gives you ability to query and modify cookies. - */ - cookies: SessionCookies; - /** - * @returns the session’s current cache size. - */ - getCacheSize(callback: (size: number) => void): void; - /** - * Clears the session’s HTTP cache. - */ - clearCache(callback: Function): void; - /** - * Clears the data of web storages. - */ - clearStorageData(callback: Function): void; - /** - * Clears the data of web storages. - */ - clearStorageData(options: ClearStorageDataOptions, callback: Function): void; - /** - * Writes any unwritten DOMStorage data to disk. - */ - flushStorageData(): void; - /** - * Sets the proxy settings. - */ - setProxy(config: string, callback: Function): void; - /** - * Resolves the proxy information for url. - */ - resolveProxy(url: URL, callback: (proxy: any) => any): void; - /** - * Sets download saving directory. - * By default, the download directory will be the Downloads under the respective app folder. - */ - setDownloadPath(path: string): void; - /** - * Emulates network with the given configuration for the session. - */ - enableNetworkEmulation(options: NetworkEmulationOptions): void; - /** - * Disables any network emulation already active for the session. - * Resets to the original network configuration. - */ - disableNetworkEmulation(): void; - /** - * Sets the certificate verify proc for session. - */ - setCertificateVerifyProc(proc: CertificateVerifyProc): void; - /** - * Clears the host resolver cache. - */ - clearHostResolverCache(callback: Function): void; - /** - * The webRequest API set allows to intercept and modify contents of a request at various stages of its lifetime. - */ - webRequest: any; - } - - interface ClearStorageDataOptions { - /** - * Should follow window.location.origin’s representation scheme://host:port. - */ - origin?: string; - /** - * The types of storages to clear. - */ - storages?: ('appcache' | 'cookies' | 'filesystem' | 'indexdb' | 'localstorage' | 'shadercache' | 'websql' | 'serviceworkers')[]; - /** - * The types of quotas to clear. - */ - quotas?: ('temporary' | 'persistent' | 'syncable')[]; - } - - interface NetworkEmulationOptions { - /** - * Whether to emulate network outage. - */ - offline?: boolean; - /** - * RTT in ms. - */ - latency?: number; - /** - * Download rate in Bps. - */ - downloadThroughput?: number; - /** - * Upload rate in Bps. - */ - uploadThroughput?: number; - } - - interface CertificateVerifyProc { - (hostname: string, cert: any, callback: (accepted: boolean) => any): any; - } - - /** - * DownloadItem represents a download item in Electron. - */ - class DownloadItem extends EventEmitter { - /** - * Emits when the downloadItem gets updated. - */ - on(event: 'updated', listener: Function): this; - /** - * Emits when the download is in a terminal state. This includes a completed download, - * a cancelled download (via downloadItem.cancel()), and interrupted download that can’t be resumed. - */ - on(event: 'done', listener: (event: Event, state: 'completed' | 'cancelled' | 'interrupted') => void): this; - on(event: string, listener: Function): this; - /** - * Set the save file path of the download item. - * Note: The API is only available in session’s will-download callback function. - * If user doesn’t set the save path via the API, Electron will use the original - * routine to determine the save path (Usually prompts a save dialog). - */ - setSavePath(path: string): void; - /** - * Pauses the download. - */ - pause(): void; - /** - * Resumes the download that has been paused. - */ - resume(): void; - /** - * Cancels the download operation. - */ - cancel(): void; - /** - * @returns The origin url where the item is downloaded from. - */ - getURL(): string; - /** - * @returns The mime type. - */ - getMimeType(): string; - /** - * @returns Whether the download has user gesture. - */ - hasUserGesture(): boolean; - /** - * @returns The file name of the download item. - * Note: The file name is not always the same as the actual one saved in local disk. - * If user changes the file name in a prompted download saving dialog, - * the actual name of saved file will be different. - */ - getFilename(): string; - /** - * @returns The total size in bytes of the download item. If the size is unknown, it returns 0. - */ - getTotalBytes(): number; - /** - * @returns The received bytes of the download item. - */ - getReceivedBytes(): number; - /** - * @returns The Content-Disposition field from the response header. - */ - getContentDisposition(): string; - } - - interface CookieFilter { - /** - * Retrieves cookies which are associated with url. Empty implies retrieving cookies of all urls. - */ - url?: string; - /** - * Filters cookies by name. - */ - name?: string; - /** - * Retrieves cookies whose domains match or are subdomains of domains. - */ - domain?: string; - /** - * Retrieves cookies whose path matches path. - */ - path?: string; - /** - * Filters cookies by their Secure property. - */ - secure?: boolean; - /** - * Filters out session or persistent cookies. - */ - session?: boolean; - } - - interface Cookie { - /** - * The name of the cookie. - */ - name: string; - /** - * The value of the cookie. - */ - value: string; - /** - * The domain of the cookie. - */ - domain: string; - /** - * Whether the cookie is a host-only cookie. - */ - hostOnly: string; - /** - * The path of the cookie. - */ - path: string; - /** - * Whether the cookie is marked as secure. - */ - secure: boolean; - /** - * Whether the cookie is marked as HTTP only. - */ - httpOnly: boolean; - /** - * Whether the cookie is a session cookie or a persistent cookie with an expiration date. - */ - session: boolean; - /** - * The expiration date of the cookie as the number of seconds since the UNIX epoch. - * Not provided for session cookies. - */ - expirationDate?: number; - } - - interface CookieDetails { - /** - * The URL associated with the cookie. - */ - url: string; - /** - * The name of the cookie. - * Default: empty. - */ - name?: string; - /** - * The value of the cookie. - * Default: empty. - */ - value?: string; - /** - * The domain of the cookie. - * Default: empty. - */ - domain?: string; - /** - * The path of the cookie. - * Default: empty. - */ - path?: string; - /** - * Whether the cookie should be marked as secure. - * Default: false. - */ - secure?: boolean; - /** - * Whether the cookie should be marked as HTTP only. - * Default: false. - */ - httpOnly?: boolean; - /** - * The expiration date of the cookie as the number of seconds since the UNIX epoch. - * If omitted, the cookie becomes a session cookie. - */ - expirationDate?: number; - } - - interface SessionCookies { - /** - * Sends a request to get all cookies matching filter. - */ - get(filter: CookieFilter, callback: (error: Error, cookies: Cookie[]) => void): void; - /** - * Sets the cookie with details. - */ - set(details: CookieDetails, callback: (error: Error) => void): void; - /** - * Removes the cookies matching url and name. - */ - remove(url: string, name: string, callback: Function): void; - } -} diff --git a/github-electron/github-electron.shell.d.ts b/github-electron/github-electron.shell.d.ts deleted file mode 100644 index 34ddf21031..0000000000 --- a/github-electron/github-electron.shell.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The shell module provides functions related to desktop integration. - */ - interface Shell { - /** - * Show the given file in a file manager. If possible, select the file. - */ - showItemInFolder(fullPath: string): void; - /** - * Open the given file in the desktop's default manner. - */ - openItem(fullPath: string): void; - /** - * Open the given external protocol URL in the desktop's default manner - * (e.g., mailto: URLs in the default mail user agent). - * @returns true if an application was available to open the URL, false otherwise. - */ - openExternal(url: string, options?: { - /** - * Bring the opened application to the foreground. - * Default: true. - */ - activate: boolean; - }): boolean; - /** - * Move the given file to trash. - * @returns boolean status for the operation. - */ - moveItemToTrash(fullPath: string): boolean; - /** - * Play the beep sound. - */ - beep(): void; - } -} diff --git a/github-electron/github-electron.tray.d.ts b/github-electron/github-electron.tray.d.ts deleted file mode 100644 index 0cbad09a5e..0000000000 --- a/github-electron/github-electron.tray.d.ts +++ /dev/null @@ -1,133 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// - -declare namespace Electron { - /** - * A Tray represents an icon in an operating system's notification area. - */ - class Tray extends EventEmitter { - /** - * Emitted when the tray icon is clicked. - * Note: The bounds payload is only implemented on OS X and Windows. - */ - on(event: 'click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; - /** - * Emitted when the tray icon is right clicked. - * Note: This is only implemented on OS X and Windows. - */ - on(event: 'right-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; - /** - * Emitted when the tray icon is double clicked. - * Note: This is only implemented on OS X and Windows. - */ - on(event: 'double-click', listener: (modifiers: Modifiers, bounds: Bounds) => void): this; - /** - * Emitted when the tray balloon shows. - * Note: This is only implemented on Windows. - */ - on(event: 'balloon-show', listener: Function): this; - /** - * Emitted when the tray balloon is clicked. - * Note: This is only implemented on Windows. - */ - on(event: 'balloon-click', listener: Function): this; - /** - * Emitted when the tray balloon is closed because of timeout or user manually closes it. - * Note: This is only implemented on Windows. - */ - on(event: 'balloon-closed', listener: Function): this; - /** - * Emitted when any dragged items are dropped on the tray icon. - * Note: This is only implemented on OS X. - */ - on(event: 'drop', listener: Function): this; - /** - * Emitted when dragged files are dropped in the tray icon. - * Note: This is only implemented on OS X - */ - on(event: 'drop-files', listener: (event: Event, files: string[]) => void): this; - /** - * Emitted when a drag operation enters the tray icon. - * Note: This is only implemented on OS X - */ - on(event: 'drag-enter', listener: Function): this; - /** - * Emitted when a drag operation exits the tray icon. - * Note: This is only implemented on OS X - */ - on(event: 'drag-leave', listener: Function): this; - /** - * Emitted when a drag operation ends on the tray or ends at another location. - * Note: This is only implemented on OS X - */ - on(event: 'drag-end', listener: Function): this; - on(event: string, listener: Function): this; - /** - * Creates a new tray icon associated with the image. - */ - constructor(image: NativeImage|string); - /** - * Destroys the tray icon immediately. - */ - destroy(): void; - /** - * Sets the image associated with this tray icon. - */ - setImage(image: NativeImage|string): void; - /** - * Sets the image associated with this tray icon when pressed. - */ - setPressedImage(image: NativeImage): void; - /** - * Sets the hover text for this tray icon. - */ - setToolTip(toolTip: string): void; - /** - * Sets the title displayed aside of the tray icon in the status bar. - * Note: This is only implemented on OS X. - */ - setTitle(title: string): void; - /** - * Sets whether the tray icon is highlighted when it is clicked. - * Note: This is only implemented on OS X. - */ - setHighlightMode(highlight: boolean): void; - /** - * Displays a tray balloon. - * Note: This is only implemented on Windows. - */ - displayBalloon(options?: { - icon?: NativeImage; - title?: string; - content?: string; - }): void; - /** - * Popups the context menu of tray icon. When menu is passed, - * the menu will showed instead of the tray's context menu. - * The position is only available on Windows, and it is (0, 0) by default. - * Note: This is only implemented on OS X and Windows. - */ - popUpContextMenu(menu?: Menu, position?: { - x: number; - y: number; - }): void; - /** - * Sets the context menu for this icon. - */ - setContextMenu(menu: Menu): void; - } - - interface Modifiers { - altKey: boolean; - shiftKey: boolean; - ctrlKey: boolean; - metaKey: boolean; - } -} diff --git a/github-electron/github-electron.web-contents.d.ts b/github-electron/github-electron.web-contents.d.ts deleted file mode 100644 index 260bc04b52..0000000000 --- a/github-electron/github-electron.web-contents.d.ts +++ /dev/null @@ -1,748 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// -/// -/// - -declare namespace Electron { - /** - * A WebContents is responsible for rendering and controlling a web page. - */ - class WebContents extends EventEmitter { - /** - * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning, - * and the onload event was dispatched. - */ - on(event: 'did-finish-load', listener: Function): this; - /** - * This event is like did-finish-load but emitted when the load failed or was cancelled, - * e.g. window.stop() is invoked. - */ - on(event: 'did-fail-load', listener: (event: Event, errorCode: number, errorDescription: string, validatedURL: string) => void): this; - /** - * Emitted when a frame has done navigation. - */ - on(event: 'did-frame-finish-load', listener: (event: Event, isMainFrame: boolean) => void): this; - /** - * Corresponds to the points in time when the spinner of the tab started spinning. - */ - on(event: 'did-start-loading', listener: Function): this; - /** - * Corresponds to the points in time when the spinner of the tab stopped spinning. - */ - on(event: 'did-stop-loading', listener: Function): this; - /** - * Emitted when details regarding a requested resource are available. - * status indicates the socket connection to download the resource. - */ - on(event: 'did-get-response-details', listener: (event: Event, - status: boolean, - newURL: string, - originalURL: string, - httpResponseCode: number, - requestMethod: string, - referrer: string, - headers: any - ) => void): this; - /** - * - */ - on(event: 'did-get-redirect-request', listener: (event: Event, - oldURL: string, - newURL: string, - isMainFrame: boolean, - httpResponseCode: number, - requestMethod: string, - referrer: string, - headers: any - ) => void): this; - /** - * Emitted when the document in the given frame is loaded. - */ - on(event: 'dom-ready', listener: (event: Event) => void): this; - /** - * Emitted when page receives favicon URLs. - */ - on(event: 'page-favicon-updated', listener: (event: Event, favicons: string[]) => void): this; - /** - * Emitted when the page requests to open a new window for a url. - * It could be requested by window.open or an external link like . - * - * By default a new BrowserWindow will be created for the url. - * - * Calling event.preventDefault() will prevent creating new windows. - */ - on(event: 'new-window', listener: (event: Event, - url: string, - frameName: string, - disposition: 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'other', - /** - * The options which will be used for creating the new BrowserWindow. - */ - options: any - ) => void): this; - /** - * Emitted when a user or the page wants to start navigation. - * It can happen when the window.location object is changed or a user clicks a link in the page. - * - * This event will not emit when the navigation is started programmatically with APIs like - * webContents.loadURL and webContents.back. - * - * It is also not emitted for in-page navigations, such as clicking anchor links - * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. - * - * Calling event.preventDefault() will prevent the navigation. - */ - on(event: 'will-navigate', listener: (event: Event, url: string) => void): this; - /** - * Emitted when a navigation is done. - * - * This event is not emitted for in-page navigations, such as clicking anchor links - * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. - */ - on(event: 'did-navigate', listener: (event: Event, url: string) => void): this; - /** - * Emitted when an in-page navigation happened. - * - * When in-page navigation happens, the page URL changes but does not cause - * navigation outside of the page. Examples of this occurring are when anchor links - * are clicked or when the DOM hashchange event is triggered. - */ - on(event: 'did-navigate-in-page', listener: (event: Event, url: string) => void): this; - /** - * Emitted when the renderer process has crashed. - */ - on(event: 'crashed', listener: Function): this; - /** - * Emitted when a plugin process has crashed. - */ - on(event: 'plugin-crashed', listener: (event: Event, name: string, version: string) => void): this; - /** - * Emitted when webContents is destroyed. - */ - on(event: 'destroyed', listener: Function): this; - /** - * Emitted when DevTools is opened. - */ - on(event: 'devtools-opened', listener: Function): this; - /** - * Emitted when DevTools is closed. - */ - on(event: 'devtools-closed', listener: Function): this; - /** - * Emitted when DevTools is focused / opened. - */ - on(event: 'devtools-focused', listener: Function): this; - /** - * Emitted when failed to verify the certificate for url. - * The usage is the same with the "certificate-error" event of app. - */ - on(event: 'certificate-error', listener: (event: Event, - url: string, - error: string, - certificate: Certificate, - callback: (trust: boolean) => void - ) => void): this; - /** - * Emitted when a client certificate is requested. - * The usage is the same with the "select-client-certificate" event of app. - */ - on(event: 'select-client-certificate', listener: (event: Event, - url: string, - certificateList: Certificate[], - callback: (certificate: Certificate) => void - ) => void): this; - /** - * Emitted when webContents wants to do basic auth. - * The usage is the same with the "login" event of app. - */ - on(event: 'login', listener: (event: Event, - request: LoginRequest, - authInfo: LoginAuthInfo, - callback: (username: string, password: string) => void - ) => void): this; - /** - * Emitted when a result is available for webContents.findInPage request. - */ - on(event: 'found-in-page', listener: (event: Event, result: { - requestId: number; - /** - * ndicates if more responses are to follow. - */ - finalUpdate: boolean; - /** - * Position of the active match. - */ - activeMatchOrdinal?: number; - /** - * Number of Matches. - */ - matches?: number; - /** - * Coordinates of first match region. - */ - selectionArea?: any; - }) => void): this; - /** - * Emitted when media starts playing. - */ - on(event: 'media-started-playing', listener: Function): this; - /** - * Emitted when media is paused or done playing. - */ - on(event: 'media-paused', listener: Function): this; - /** - * Emitted when a page’s theme color changes. This is usually due to encountering a meta tag: - * - */ - on(event: 'did-change-theme-color', listener: Function): this; - /** - * Emitted when the cursor’s type changes. - * If the type parameter is custom, the image parameter will hold the custom cursor image - * in a NativeImage, and the scale will hold scaling information for the image. - */ - on(event: 'cursor-changed', listener: (event: Event, type: CursorType, image?: NativeImage, scale?: number) => void): this; - on(event: string, listener: Function): this; - /** - * Loads the url in the window. - * @param url Must contain the protocol prefix (e.g., the http:// or file://). - */ - loadURL(url: string, options?: { - httpReferrer?: string; - userAgent?: string; - extraHeaders?: string; - }): void; - /** - * Initiates a download of the resource at url without navigating. - * The will-download event of session will be triggered. - */ - downloadURL(url: string): void; - /** - * @returns The URL of current web page. - */ - getURL(): string; - /** - * @returns The title of web page. - */ - getTitle(): string; - /** - * @returns The favicon of the web page. - */ - getFavicon(): NativeImage; - /** - * @returns Whether web page is still loading resources. - */ - isLoading(): boolean; - /** - * @returns Whether web page is waiting for a first-response for the main - * resource of the page. - */ - isWaitingForResponse(): boolean; - /** - * Stops any pending navigation. - */ - stop(): void; - /** - * Reloads current page. - */ - reload(): void; - /** - * Reloads current page and ignores cache. - */ - reloadIgnoringCache(): void; - /** - * @returns Whether the web page can go back. - */ - canGoBack(): boolean; - /** - * @returns Whether the web page can go forward. - */ - canGoForward(): boolean; - /** - * @returns Whether the web page can go to offset. - */ - canGoToOffset(offset: number): boolean; - /** - * Clears the navigation history. - */ - clearHistory(): void; - /** - * Makes the web page go back. - */ - goBack(): void; - /** - * Makes the web page go forward. - */ - goForward(): void; - /** - * Navigates to the specified absolute index. - */ - goToIndex(index: number): void; - /** - * Navigates to the specified offset from the "current entry". - */ - goToOffset(offset: number): void; - /** - * @returns Whether the renderer process has crashed. - */ - isCrashed(): boolean; - /** - * Overrides the user agent for this page. - */ - setUserAgent(userAgent: string): void; - /** - * @returns The user agent for this web page. - */ - getUserAgent(): string; - /** - * Injects CSS into this page. - */ - insertCSS(css: string): void; - /** - * Evaluates code in page. - * @param code Code to evaluate. - */ - executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; - /** - * Mute the audio on the current web page. - */ - setAudioMuted(muted: boolean): void; - /** - * @returns Whether this page has been muted. - */ - isAudioMuted(): boolean; - /** - * Executes Edit -> Undo command in page. - */ - undo(): void; - /** - * Executes Edit -> Redo command in page. - */ - redo(): void; - /** - * Executes Edit -> Cut command in page. - */ - cut(): void; - /** - * Executes Edit -> Copy command in page. - */ - copy(): void; - /** - * Executes Edit -> Paste command in page. - */ - paste(): void; - /** - * Executes Edit -> Paste and Match Style in page. - */ - pasteAndMatchStyle(): void; - /** - * Executes Edit -> Delete command in page. - */ - delete(): void; - /** - * Executes Edit -> Select All command in page. - */ - selectAll(): void; - /** - * Executes Edit -> Unselect command in page. - */ - unselect(): void; - /** - * Executes Edit -> Replace command in page. - */ - replace(text: string): void; - /** - * Executes Edit -> Replace Misspelling command in page. - */ - replaceMisspelling(text: string): void; - /** - * Inserts text to the focused element. - */ - insertText(text: string): void; - /** - * Starts a request to find all matches for the text in the web page and - * returns an Integer representing the request id used for the request. - * The result of the request can be obtained by subscribing to - * found-in-page event. - */ - findInPage(text: string, options?: FindInPageOptions): void; - /** - * Stops any findInPage request for the webContents with the provided - * action. - * @param action Specifies the action to take place when ending webContents.findInPage request. - * 'clearSelection' - Translate the selection into a normal selection. - * 'keepSelection' - Clear the selection. - * 'activateSelection' - Focus and click the selection node. - */ - stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void; - /** - * Checks if any serviceworker is registered. - */ - hasServiceWorker(callback: (hasServiceWorker: boolean) => void): void; - /** - * Unregisters any serviceworker if present. - */ - unregisterServiceWorker(callback: - /** - * @param isFulfilled Whether the JS promise is fulfilled. - */ - (isFulfilled: boolean) => void): void; - /** - * - * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing. - * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}). - * Note: - * On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size. - */ - print(options?: { - /** - * Don't ask user for print settings, defaults to false - */ - silent?: boolean; - /** - * Also prints the background color and image of the web page, defaults to false. - */ - printBackground: boolean; - }): void; - /** - * Prints windows' web page as PDF with Chromium's preview printing custom settings. - */ - printToPDF(options: { - /** - * Specify the type of margins to use. Default is 0. - * 0 - default - * 1 - none - * 2 - minimum - */ - marginsType?: number; - /** - * String - Specify page size of the generated PDF. Default is A4. - * A4 - * A3 - * Legal - * Letter - * Tabloid - */ - pageSize?: string; - /** - * Whether to print CSS backgrounds. Default is false. - */ - printBackground?: boolean; - /** - * Whether to print selection only. Default is false. - */ - printSelectionOnly?: boolean; - /** - * true for landscape, false for portrait. Default is false. - */ - landscape?: boolean; - }, - /** - * Callback function on completed converting to PDF. - * error Error - * data Buffer - PDF file content - */ - callback: (error: Error, data: Buffer) => void): void; - /** - * Adds the specified path to DevTools workspace. - */ - addWorkSpace(path: string): void; - /** - * Removes the specified path from DevTools workspace. - */ - removeWorkSpace(path: string): void; - /** - * Opens the developer tools. - */ - openDevTools(options?: { - /** - * Opens devtools in a new window. - */ - detach?: boolean; - }): void; - /** - * Closes the developer tools. - */ - closeDevTools(): void; - /** - * Returns whether the developer tools are opened. - */ - isDevToolsOpened(): boolean; - /** - * Returns whether the developer tools are focussed. - */ - isDevToolsFocused(): boolean; - /** - * Toggle the developer tools. - */ - toggleDevTools(): void; - /** - * Starts inspecting element at position (x, y). - */ - inspectElement(x: number, y: number): void; - /** - * Opens the developer tools for the service worker context. - */ - inspectServiceWorker(): void; - /** - * Send args.. to the web page via channel in asynchronous message, the web page - * can handle it by listening to the channel event of ipc module. - * Note: - * 1. The IPC message handler in web pages do not have a event parameter, - * which is different from the handlers on the main process. - * 2. There is no way to send synchronous messages from the main process - * to a renderer process, because it would be very easy to cause dead locks. - */ - send(channel: string, ...args: any[]): void; - /** - * Enable device emulation with the given parameters. - */ - enableDeviceEmulation(parameters: DeviceEmulationParameters): void; - /** - * Disable device emulation. - */ - disableDeviceEmulation(): void; - /** - * Sends an input event to the page. - */ - sendInputEvent(event: SendInputEvent): void; - /** - * Begin subscribing for presentation events and captured frames, - * The callback will be called when there is a presentation event. - */ - beginFrameSubscription(callback: ( - /** - * The frameBuffer is a Buffer that contains raw pixel data. - * On most machines, the pixel data is effectively stored in 32bit BGRA format, - * but the actual representation depends on the endianness of the processor - * (most modern processors are little-endian, on machines with big-endian - * processors the data is in 32bit ARGB format). - */ - frameBuffer: Buffer - ) => void): void; - /** - * End subscribing for frame presentation events. - */ - endFrameSubscription(): void; - /** - * @returns If the process of saving page has been initiated successfully. - */ - savePage(fullPath: string, saveType: 'HTMLOnly' | 'HTMLComplete' | 'MHTML', callback?: (eror: Error) => void): boolean; - /** - * @returns The session object used by this webContents. - */ - session: Session; - /** - * @returns The WebContents that might own this WebContents. - */ - hostWebContents: WebContents; - /** - * @returns The WebContents of DevTools for this WebContents. - * Note: Users should never store this object because it may become null - * when the DevTools has been closed. - */ - devToolsWebContents: WebContents; - /** - * @returns Debugger API - */ - debugger: Debugger; - } - - type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' |'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom'; - - interface Certificate { - /** - * PEM encoded data - */ - data: Buffer; - issuerName: string; - } - - interface LoginRequest { - method: string; - url: string; - referrer: string; - } - - interface LoginAuthInfo { - isProxy: boolean; - scheme: string; - host: string; - port: number; - realm: string; - } - - interface FindInPageOptions { - /** - * Whether to search forward or backward, defaults to true - */ - forward?: boolean; - /** - * Whether the operation is first request or a follow up, defaults to false. - */ - findNext?: boolean; - /** - * Whether search should be case-sensitive, defaults to false. - */ - matchCase?: boolean; - /** - * Whether to look only at the start of words. defaults to false. - */ - wordStart?: boolean; - /** - * When combined with wordStart, accepts a match in the middle of a word - * if the match begins with an uppercase letter followed by a lowercase - * or non-letter. Accepts several other intra-word matches, defaults to false. - */ - medialCapitalAsWordStart?: boolean; - } - - interface DeviceEmulationParameters { - /** - * Specify the screen type to emulated - * Default: desktop - */ - screenPosition?: 'desktop' | 'mobile'; - /** - * Set the emulated screen size (screenPosition == mobile) - */ - screenSize?: { - /** - * Set the emulated screen width - */ - width: number; - /** - * Set the emulated screen height - */ - height: number; - }; - /** - * Position the view on the screen (screenPosition == mobile) - * Default: {x: 0, y: 0} - */ - viewPosition?: { - /** - * Set the x axis offset from top left corner - */ - x: number; - /** - * Set the y axis offset from top left corner - */ - y: number; - }; - /** - * Set the device scale factor (if zero defaults to original device scale factor) - * Default: 0 - */ - deviceScaleFactor: number; - /** - * Set the emulated view size (empty means no override). - */ - viewSize?: { - /** - * Set the emulated view width - */ - width: number; - /** - * Set the emulated view height - */ - height: number; - }; - /** - * Whether emulated view should be scaled down if necessary to fit into available space - * Default: false - */ - fitToView?: boolean; - /** - * Offset of the emulated view inside available space (not in fit to view mode) - * Default: {x: 0, y: 0} - */ - offset?: { - /** - * Set the x axis offset from top left corner - */ - x: number; - /** - * Set the y axis offset from top left corner - */ - y: number; - }; - /** - * Scale of emulated view inside available space (not in fit to view mode) - * Default: 1 - */ - scale: number; - } - - interface SendInputEvent { - type: 'mouseDown' | 'mouseUp' | 'mouseEnter' | 'mouseLeave' | 'contextMenu' | 'mouseWheel' | 'mouseMove' | 'keyDown' | 'keyUp' | 'char'; - modifiers: ('shift' | 'control' | 'alt' | 'meta' | 'isKeypad' | 'isAutoRepeat' | 'leftButtonDown' | 'middleButtonDown' | 'rightButtonDown' | 'capsLock' | 'numLock' | 'left' | 'right')[]; - } - - interface SendInputKeyboardEvent extends SendInputEvent { - keyCode: string; - } - - interface SendInputMouseEvent extends SendInputEvent { - x: number; - y: number; - button?: 'left' | 'middle' | 'right'; - globalX?: number; - globalY?: number; - movementX?: number; - movementY?: number; - clickCount?: number; - } - - interface SendInputMouseWheelEvent extends SendInputEvent { - deltaX?: number; - deltaY?: number; - wheelTicksX?: number; - wheelTicksY?: number; - accelerationRatioX?: number; - accelerationRatioY?: number; - hasPreciseScrollingDeltas?: number; - canScroll?: boolean; - } - - /** - * Debugger API serves as an alternate transport for remote debugging protocol. - */ - interface Debugger extends NodeJS.EventEmitter { - /** - * Attaches the debugger to the webContents. - * @param protocolVersion Requested debugging protocol version. - */ - attach(protocolVersion?: string): void; - /** - * @returns Whether a debugger is attached to the webContents. - */ - isAttached(): boolean; - /** - * Detaches the debugger from the webContents. - */ - detach(): void; - /** - * Send given command to the debugging target. - * @param method Method name, should be one of the methods defined by the remote debugging protocol. - * @param commandParams JSON object with request parameters. - * @param callback Response defined by the ‘returns’ attribute of the command description in the remote debugging protocol. - */ - sendCommand(method: string, commandParams?: any, callback?: (error: Error, result: any) => void): void; - /** - * Emitted when debugging session is terminated. This happens either when - * webContents is closed or devtools is invoked for the attached webContents. - */ - on(event: 'detach', listener: (event: Event, reason: string) => void): this; - /** - * Emitted whenever debugging target issues instrumentation event. - * Event parameters defined by the ‘parameters’ attribute in the remote debugging protocol. - */ - on(event: 'message', listener: (event: Event, method: string, params: any) => void): this; - on(event: string, listener: Function): this; - } -} diff --git a/github-electron/github-electron.web-frame.d.ts b/github-electron/github-electron.web-frame.d.ts deleted file mode 100644 index 4a0dd15d13..0000000000 --- a/github-electron/github-electron.web-frame.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -// Type definitions for Electron v0.37.2 -// Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace Electron { - /** - * The web-frame module allows you to customize the rendering of the current web page. - */ - interface WebFrame { - /** - * Changes the zoom factor to the specified factor, zoom factor is - * zoom percent / 100, so 300% = 3.0. - */ - setZoomFactor(factor: number): void; - /** - * @returns The current zoom factor. - */ - getZoomFactor(): number; - /** - * Changes the zoom level to the specified level, 0 is "original size", and each - * increment above or below represents zooming 20% larger or smaller to default - * limits of 300% and 50% of original size, respectively. - */ - setZoomLevel(level: number): void; - /** - * @returns The current zoom level. - */ - getZoomLevel(): number; - /** - * Sets the maximum and minimum zoom level. - */ - setZoomLevelLimits(minimumLevel: number, maximumLevel: number): void; - /** - * Sets a provider for spell checking in input fields and text areas. - */ - setSpellCheckProvider(language: string, autoCorrectWord: boolean, provider: { - /** - * @returns Whether the word passed is correctly spelled. - */ - spellCheck: (text: string) => boolean; - }): void; - /** - * Sets the scheme as secure scheme. Secure schemes do not trigger mixed content - * warnings. For example, https and data are secure schemes because they cannot be - * corrupted by active network attackers. - */ - registerURLSchemeAsSecure(scheme: string): void; - /** - * Resources will be loaded from this scheme regardless of the current page’s Content Security Policy. - */ - registerURLSchemeAsBypassingCSP(scheme: string): void; - /** - * Registers the scheme as secure, bypasses content security policy for resources, - * allows registering ServiceWorker and supports fetch API. - */ - registerURLSchemeAsPrivileged(scheme: string): void; - /** - * Inserts text to the focused element. - */ - insertText(text: string): void; - /** - * Evaluates `code` in page. - * In the browser window some HTML APIs like `requestFullScreen` can only be - * invoked by a gesture from the user. Setting `userGesture` to `true` will remove - * this limitation. - */ - executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; - } -} From 232f2a1e675fa65ffc76fccd313f636bd01a10f2 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sat, 26 Mar 2016 20:53:56 +0100 Subject: [PATCH 0109/1850] Add tests for File --- .../github-electron-renderer-tests.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index d995f49336..6d3fb338b0 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -135,6 +135,32 @@ function getUserMediaError(error: Error) { console.log('getUserMediaError', error); } +// File object +// https://github.com/atom/electron/blob/master/docs/api/file-object.md + +/* +
+ Drag your file here +
+*/ + +var holder = document.getElementById('holder'); + +holder.ondragover = function () { + return false; +}; + +holder.ondragleave = holder.ondragend = function () { + return false; +}; + +holder.ondrop = function (e) { + e.preventDefault(); + var file = e.dataTransfer.files[0]; + console.log('File you dragged here is', file.path); + return false; +}; + // nativeImage // https://github.com/atom/electron/blob/master/docs/api/native-image.md From 375d2e7f8a76149f420c36a65fe405a98baa31e8 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sat, 26 Mar 2016 21:59:39 +0100 Subject: [PATCH 0110/1850] Update header --- github-electron/github-electron.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 34858aef12..7a3a222145 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,6 +1,6 @@ // Type definitions for Electron v0.37.2 // Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd +// Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From b28a48961b0e13dda0c4613c54923ff1ea94768a Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sat, 26 Mar 2016 23:31:23 +0100 Subject: [PATCH 0111/1850] Cleanup + share common options --- github-electron/github-electron.d.ts | 235 +++++++++++---------------- 1 file changed, 92 insertions(+), 143 deletions(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7a3a222145..a0d4e9cb90 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -214,7 +214,6 @@ declare namespace Electron { */ getVersion(): string; /** - * * @returns The current application's name, the name in package.json would be used. * Usually the name field of package.json is a short lowercased name, according to * the spec of npm modules. So usually you should also specify a productName field, @@ -224,7 +223,7 @@ declare namespace Electron { getName(): string; /** * @returns The current application locale. - **/ + */ getLocale(): string; /** * Adds path to recent documents list. @@ -662,10 +661,7 @@ declare namespace Electron { * * Note: This API is available only on OS X. */ - setAspectRatio(aspectRatio: number, extraSize?: { - width: number, - height: number - }): void; + setAspectRatio(aspectRatio: number, extraSize?: Dimension): void; /** * Resizes and moves the window to width, height, x, y. */ @@ -868,28 +864,15 @@ declare namespace Electron { /** * Same with webContents.print([options]) */ - print(options?: { - silent?: boolean; - printBackground?: boolean; - }): void; + print(options?: PrintOptions): void; /** * Same with webContents.printToPDF([options]) */ - printToPDF(options: { - marginsType?: number; - pageSize?: string; - printBackground?: boolean; - printSelectionOnly?: boolean; - landscape?: boolean; - }, callback: (error: Error, data: Buffer) => void): void; + printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void; /** * Same with webContents.loadURL(url). */ - loadURL(url: string, options?: { - httpReferrer?: string; - userAgent?: string; - extraHeaders?: string; - }): void; + loadURL(url: string, options?: LoadURLOptions): void; /** * Same with webContents.reload. */ @@ -1148,7 +1131,8 @@ declare namespace Electron { /** * The width and height would be used as web page’s size, which means * the actual window’s size will include window frame’s size and be slightly larger. - * Default: false. */ + * Default: false. + */ useContentSize?: boolean; /** * Show window in the center of the screen. @@ -1236,7 +1220,7 @@ declare namespace Electron { */ title?: string; /** - *The window icon, when omitted on Windows the executable’s icon would be used as window icon. + * The window icon, when omitted on Windows the executable’s icon would be used as window icon. */ icon?: NativeImage|string; /** @@ -1586,10 +1570,7 @@ declare namespace Electron { * The suggested size that thumbnail should be scaled. * Default: {width: 150, height: 150} */ - thumbnailSize?: { - width: number; - height: number; - }; + thumbnailSize?: Dimension; } interface DesktopCapturerSource { @@ -2818,10 +2799,7 @@ declare namespace Electron { * The position is only available on Windows, and it is (0, 0) by default. * Note: This is only implemented on OS X and Windows. */ - popUpContextMenu(menu?: Menu, position?: { - x: number; - y: number; - }): void; + popUpContextMenu(menu?: Menu, position?: Point): void; /** * Sets the context menu for this icon. */ @@ -3039,11 +3017,7 @@ declare namespace Electron { * Loads the url in the window. * @param url Must contain the protocol prefix (e.g., the http:// or file://). */ - loadURL(url: string, options?: { - httpReferrer?: string; - userAgent?: string; - extraHeaders?: string; - }): void; + loadURL(url: string, options?: LoadURLOptions): void; /** * Initiates a download of the resource at url without navigating. * The will-download event of session will be triggered. @@ -3192,21 +3166,15 @@ declare namespace Electron { */ insertText(text: string): void; /** - * Starts a request to find all matches for the text in the web page and - * returns an Integer representing the request id used for the request. - * The result of the request can be obtained by subscribing to - * found-in-page event. + * Starts a request to find all matches for the text in the web page. + * The result of the request can be obtained by subscribing to found-in-page event. + * @returns The request id used for the request. */ - findInPage(text: string, options?: FindInPageOptions): void; + findInPage(text: string, options?: FindInPageOptions): number; /** - * Stops any findInPage request for the webContents with the provided - * action. - * @param action Specifies the action to take place when ending webContents.findInPage request. - * 'clearSelection' - Translate the selection into a normal selection. - * 'keepSelection' - Clear the selection. - * 'activateSelection' - Focus and click the selection node. + * Stops any findInPage request for the webContents with the provided action. */ - stopFindInPage(action: 'clearSelection' | 'keepSelection' | 'activateSelection'): void; + stopFindInPage(action: StopFindInPageAtion): void; /** * Checks if any serviceworker is registered. */ @@ -3214,67 +3182,17 @@ declare namespace Electron { /** * Unregisters any serviceworker if present. */ - unregisterServiceWorker(callback: - /** - * @param isFulfilled Whether the JS promise is fulfilled. - */ - (isFulfilled: boolean) => void): void; + unregisterServiceWorker(callback: (isFulfilled: boolean) => void): void; /** - * * Prints window's web page. When silent is set to false, Electron will pick up system's default printer and default settings for printing. * Calling window.print() in web page is equivalent to call WebContents.print({silent: false, printBackground: false}). - * Note: - * On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size. + * Note: On Windows, the print API relies on pdf.dll. If your application doesn't need print feature, you can safely remove pdf.dll in saving binary size. */ - print(options?: { - /** - * Don't ask user for print settings, defaults to false - */ - silent?: boolean; - /** - * Also prints the background color and image of the web page, defaults to false. - */ - printBackground: boolean; - }): void; + print(options?: PrintOptions): void; /** * Prints windows' web page as PDF with Chromium's preview printing custom settings. */ - printToPDF(options: { - /** - * Specify the type of margins to use. Default is 0. - * 0 - default - * 1 - none - * 2 - minimum - */ - marginsType?: number; - /** - * String - Specify page size of the generated PDF. Default is A4. - * A4 - * A3 - * Legal - * Letter - * Tabloid - */ - pageSize?: string; - /** - * Whether to print CSS backgrounds. Default is false. - */ - printBackground?: boolean; - /** - * Whether to print selection only. Default is false. - */ - printSelectionOnly?: boolean; - /** - * true for landscape, false for portrait. Default is false. - */ - landscape?: boolean; - }, - /** - * Callback function on completed converting to PDF. - * error Error - * data Buffer - PDF file content - */ - callback: (error: Error, data: Buffer) => void): void; + printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void; /** * Adds the specified path to DevTools workspace. */ @@ -3380,8 +3298,75 @@ declare namespace Electron { debugger: Debugger; } + /** + * Specifies the action to take place when ending webContents.findInPage request. + * 'clearSelection' - Translate the selection into a normal selection. + * 'keepSelection' - Clear the selection. + * 'activateSelection' - Focus and click the selection node. + */ + type StopFindInPageAtion = 'clearSelection' | 'keepSelection' | 'activateSelection'; + type CursorType = 'default' | 'crosshair' | 'pointer' | 'text' | 'wait' | 'help' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ns-resize' | 'ew-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'm-panning' | 'e-panning' | 'n-panning' | 'ne-panning' | 'nw-panning' | 's-panning' | 'se-panning' |'sw-panning' | 'w-panning' | 'move' | 'vertical-text' | 'cell' | 'context-menu' | 'alias' | 'progress' | 'nodrop' | 'copy' | 'none' | 'not-allowed' | 'zoom-in' | 'zoom-out' | 'grab' | 'grabbing' | 'custom'; + interface LoadURLOptions { + /** + * HTTP Referrer URL. + */ + httpReferrer?: string; + /** + * User agent originating the request. + */ + userAgent?: string; + /** + * Extra headers separated by "\n" + */ + extraHeaders?: string; + } + + interface PrintOptions { + /** + * Don't ask user for print settings. + * Defaults: false. + */ + silent?: boolean; + /** + * Also prints the background color and image of the web page. + * Defaults: false. + */ + printBackground?: boolean; + } + + interface PrintToPDFOptions { + /** + * Specify the type of margins to use. + * 0 - default + * 1 - none + * 2 - minimum + * Default: 0 + */ + marginsType?: number; + /** + * Specify page size of the generated PDF. + * Default: A4. + */ + pageSize?: 'A3' | 'A4' | 'A5' | 'Legal' | 'Letter' | 'Tabloid'; + /** + * Whether to print CSS backgrounds. + * Default: false. + */ + printBackground?: boolean; + /** + * Whether to print selection only. + * Default: false. + */ + printSelectionOnly?: boolean; + /** + * true for landscape, false for portrait. + * Default: false. + */ + landscape?: boolean; + } + interface Certificate { /** * PEM encoded data @@ -3438,30 +3423,12 @@ declare namespace Electron { /** * Set the emulated screen size (screenPosition == mobile) */ - screenSize?: { - /** - * Set the emulated screen width - */ - width: number; - /** - * Set the emulated screen height - */ - height: number; - }; + screenSize?: Dimension; /** * Position the view on the screen (screenPosition == mobile) * Default: {x: 0, y: 0} */ - viewPosition?: { - /** - * Set the x axis offset from top left corner - */ - x: number; - /** - * Set the y axis offset from top left corner - */ - y: number; - }; + viewPosition?: Point; /** * Set the device scale factor (if zero defaults to original device scale factor) * Default: 0 @@ -3470,16 +3437,7 @@ declare namespace Electron { /** * Set the emulated view size (empty means no override). */ - viewSize?: { - /** - * Set the emulated view width - */ - width: number; - /** - * Set the emulated view height - */ - height: number; - }; + viewSize?: Dimension; /** * Whether emulated view should be scaled down if necessary to fit into available space * Default: false @@ -3489,16 +3447,7 @@ declare namespace Electron { * Offset of the emulated view inside available space (not in fit to view mode) * Default: {x: 0, y: 0} */ - offset?: { - /** - * Set the x axis offset from top left corner - */ - x: number; - /** - * Set the y axis offset from top left corner - */ - y: number; - }; + offset?: Point; /** * Scale of emulated view inside available space (not in fit to view mode) * Default: 1 From 6f427acd995c45fc6ad13780803c12b26118a4f6 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sat, 26 Mar 2016 22:53:03 +0100 Subject: [PATCH 0112/1850] Add element --- .../github-electron-renderer-tests.ts | 37 ++ github-electron/github-electron.d.ts | 425 ++++++++++++++++++ 2 files changed, 462 insertions(+) diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index 6d3fb338b0..12eaf2f11f 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -205,3 +205,40 @@ app.on('ready', () => { // https://github.com/atom/electron/blob/master/docs/api/shell.md shell.openExternal('https://github.com'); + +// +// https://github.com/atom/electron/blob/master/docs/api/web-view-tag.md + +var webview = document.createElement('webview'); +webview.loadURL('https://github.com'); + +webview.addEventListener('console-message', function(e) { + console.log('Guest page logged a message:', e.message); +}); + +webview.addEventListener('found-in-page', function(e) { + if (e.result.finalUpdate) { + webview.stopFindInPage("keepSelection"); + } +}); + +var rquestId = webview.findInPage("test"); + +webview.addEventListener('new-window', function(e) { + require('electron').shell.openExternal(e.url); +}); + +webview.addEventListener('close', function() { + webview.src = 'about:blank'; +}); + +// In embedder page. +webview.addEventListener('ipc-message', function(event) { + console.log(event.channel); // Prints "pong" +}); +webview.send('ping'); + +// In guest page. +ipcRenderer.on('ping', function() { + ipcRenderer.sendToHost('pong'); +}); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index a0d4e9cb90..f96cc6fc97 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -3589,6 +3589,427 @@ declare namespace Electron { executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; } + // https://github.com/atom/electron/blob/master/docs/api/web-view-tag.md + + /** + * Use the webview tag to embed 'guest' content (such as web pages) in your Electron app. + * The guest content is contained within the webview container. + * An embedded page within your app controls how the guest content is laid out and rendered. + * + * Unlike an iframe, the webview runs in a separate process than your app. + * It doesn't have the same permissions as your web page and all interactions between your app + * and embedded content will be asynchronous. This keeps your app safe from the embedded content. + */ + interface WebViewElement extends HTMLElement { + /** + * Returns the visible URL. Writing to this attribute initiates top-level navigation. + * Assigning src its own value will reload the current page. + * The src attribute can also accept data URLs, such as data:text/plain,Hello, world!. + */ + src: string; + /** + * If "on", the webview container will automatically resize within the bounds specified + * by the attributes minwidth, minheight, maxwidth, and maxheight. + * These constraints do not impact the webview unless autosize is enabled. + * When autosize is enabled, the webview container size cannot be less than + * the minimum values or greater than the maximum. + */ + autosize: string; + /** + * If "on", the guest page in webview will have node integration and can use node APIs + * like require and process to access low level system resources. + */ + nodeintegration: string; + /** + * If "on", the guest page in webview will be able to use browser plugins. + */ + plugins: string; + /** + * Specifies a script that will be loaded before other scripts run in the guest page. + * The protocol of script's URL must be either file: or asar:, + * because it will be loaded by require in guest page under the hood. + * + * When the guest page doesn't have node integration this script will still have access to all Node APIs, + * but global objects injected by Node will be deleted after this script has finished executing. + */ + preload: string; + /** + * Sets the referrer URL for the guest page. + */ + httpreferrer: string; + /** + * Sets the user agent for the guest page before the page is navigated to. + * Once the page is loaded, use the setUserAgent method to change the user agent. + */ + useragent: string; + /** + * If "on", the guest page will have web security disabled. + */ + disablewebsecurity: string; + /** + * Sets the session used by the page. If partition starts with persist:, + * the page will use a persistent session available to all pages in the app with the same partition. + * If there is no persist: prefix, the page will use an in-memory session. + * By assigning the same partition, multiple pages can share the same session. + * If the partition is unset then default session of the app will be used. + * + * This value can only be modified before the first navigation, + * since the session of an active renderer process cannot change. + * Subsequent attempts to modify the value will fail with a DOM exception. + */ + partition: string; + /** + * If "on", the guest page will be allowed to open new windows. + */ + allowpopups: string; + /** + * A list of strings which specifies the blink features to be enabled separated by ,. + */ + blinkfeatures: string; + /** + * Loads the url in the webview, the url must contain the protocol prefix, e.g. the http:// or file://. + */ + loadURL(url: string, options?: LoadURLOptions): void; + /** + * @returns URL of guest page. + */ + getURL(): string; + /** + * @returns The title of guest page. + */ + getTitle(): string; + /** + * @returns Whether guest page is still loading resources. + */ + isLoading(): boolean; + /** + * Returns a boolean whether the guest page is waiting for a first-response for the main resource of the page. + */ + isWaitingForResponse(): boolean; + /** + * Stops any pending navigation. + */ + stop(): void; + /** + * Reloads the guest page. + */ + reload(): void; + /** + * Reloads the guest page and ignores cache. + */ + reloadIgnoringCache(): void; + /** + * @returns Whether the guest page can go back. + */ + canGoBack(): boolean; + /** + * @returns Whether the guest page can go forward. + */ + canGoForward(): boolean; + /** + * @returns Whether the guest page can go to offset. + */ + canGoToOffset(offset: number): boolean; + /** + * Clears the navigation history. + */ + clearHistory(): void; + /** + * Makes the guest page go back. + */ + goBack(): void; + /** + * Makes the guest page go forward. + */ + goForward(): void; + /** + * Navigates to the specified absolute index. + */ + goToIndex(index: number): void; + /** + * Navigates to the specified offset from the "current entry". + */ + goToOffset(offset: boolean): void; + /** + * @returns Whether the renderer process has crashed. + */ + isCrashed(): boolean; + /** + * Overrides the user agent for the guest page. + */ + setUserAgent(userAgent: string): void; + /** + * @returns The user agent for guest page. + */ + getUserAgent(): string; + /** + * Injects CSS into the guest page. + */ + insertCSS(css: string): void; + /** + * Evaluates code in page. If userGesture is set, it will create the user gesture context in the page. + * HTML APIs like requestFullScreen, which require user action, can take advantage of this option for automation. + */ + executeJavaScript(code: string, userGesture?: boolean, callback?: (result: any) => void): void; + /** + * Opens a DevTools window for guest page. + */ + openDevTools(): void; + /** + * Closes the DevTools window of guest page. + */ + closeDevTools(): void; + /** + * @returns Whether guest page has a DevTools window attached. + */ + isDevToolsOpened(): boolean; + /** + * @returns Whether DevTools window of guest page is focused. + */ + isDevToolsFocused(): boolean; + /** + * Starts inspecting element at position (x, y) of guest page. + */ + inspectElement(x: number, y: number): void; + /** + * Opens the DevTools for the service worker context present in the guest page. + */ + inspectServiceWorker(): void; + /** + * Set guest page muted. + */ + setAudioMuted(muted: boolean): void; + /** + * @returns Whether guest page has been muted. + */ + isAudioMuted(): boolean; + /** + * Executes editing command undo in page. + */ + undo(): void; + /** + * Executes editing command redo in page. + */ + redo(): void; + /** + * Executes editing command cut in page. + */ + cut(): void; + /** + * Executes editing command copy in page. + */ + copy(): void; + /** + * Executes editing command paste in page. + */ + paste(): void; + /** + * Executes editing command pasteAndMatchStyle in page. + */ + pasteAndMatchStyle(): void; + /** + * Executes editing command delete in page. + */ + delete(): void; + /** + * Executes editing command selectAll in page. + */ + selectAll(): void; + /** + * Executes editing command unselect in page. + */ + unselect(): void; + /** + * Executes editing command replace in page. + */ + replace(text: string): void; + /** + * Executes editing command replaceMisspelling in page. + */ + replaceMisspelling(text: string): void; + /** + * Inserts text to the focused element. + */ + insertText(text: string): void; + /** + * Starts a request to find all matches for the text in the web page. + * The result of the request can be obtained by subscribing to found-in-page event. + * @returns The request id used for the request. + */ + findInPage(text: string, options?: FindInPageOptions): number; + /** + * Stops any findInPage request for the webview with the provided action. + */ + stopFindInPage(action: StopFindInPageAtion): void; + /** + * Prints webview's web page. Same with webContents.print([options]). + */ + print(options?: PrintOptions): void; + /** + * Prints webview's web page as PDF, Same with webContents.printToPDF(options, callback) + */ + printToPDF(options: PrintToPDFOptions, callback: (error: Error, data: Buffer) => void): void; + /** + * Send an asynchronous message to renderer process via channel, you can also send arbitrary arguments. + * The renderer process can handle the message by listening to the channel event with the ipcRenderer module. + * See webContents.send for examples. + */ + send(channel: string, ...args: any[]): void; + /** + * Sends an input event to the page. + * See webContents.sendInputEvent for detailed description of event object. + */ + sendInputEvent(event: SendInputEvent): void + /** + * @returns The WebContents associated with this webview. + */ + getWebContents(): WebContents; + /** + * Fired when a load has committed. This includes navigation within the current document + * as well as subframe document-level loads, but does not include asynchronous resource loads. + */ + addEventListener(type: 'load-commit', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched. + */ + addEventListener(type: 'did-finish-load', listener: (event: any) => void, useCapture?: boolean): void; + /** + * This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked. + */ + addEventListener(type: 'did-fail-load', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when a frame has done navigation. + */ + addEventListener(type: 'did-frame-finish-load', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Corresponds to the points in time when the spinner of the tab starts spinning. + */ + addEventListener(type: 'did-start-loading', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Corresponds to the points in time when the spinner of the tab stops spinning. + */ + addEventListener(type: 'did-stop-loading', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when details regarding a requested resource is available. + * status indicates socket connection to download the resource. + */ + addEventListener(type: 'did-get-response-details', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when a redirect was received while requesting a resource. + */ + addEventListener(type: 'did-get-redirect-request', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when document in the given frame is loaded. + */ + addEventListener(type: 'dom-ready', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when page title is set during navigation. explicitSet is false when title is synthesized from file URL. + */ + addEventListener(type: 'page-title-updated', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when page receives favicon URLs. + */ + addEventListener(type: 'page-favicon-updated', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when page enters fullscreen triggered by HTML API. + */ + addEventListener(type: 'enter-html-full-screen', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when page leaves fullscreen triggered by HTML API. + */ + addEventListener(type: 'leave-html-full-screen', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the guest window logs a console message. + */ + addEventListener(type: 'console-message', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when a result is available for webview.findInPage request. + */ + addEventListener(type: 'found-in-page', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the guest page attempts to open a new browser window. + */ + addEventListener(type: 'new-window', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when a user or the page wants to start navigation. + * It can happen when the window.location object is changed or a user clicks a link in the page. + * + * This event will not emit when the navigation is started programmatically with APIs + * like .loadURL and .back. + * + * It is also not emitted during in-page navigation, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + * + * Calling event.preventDefault() does NOT have any effect. + */ + addEventListener(type: 'will-navigate', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when a navigation is done. + * + * This event is not emitted for in-page navigations, such as clicking anchor links + * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. + */ + addEventListener(type: 'did-navigate', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when an in-page navigation happened. + * + * When in-page navigation happens, the page URL changes but does not cause + * navigation outside of the page. Examples of this occurring are when anchor links + * are clicked or when the DOM hashchange event is triggered. + */ + addEventListener(type: 'did-navigate-in-page', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the guest page attempts to close itself. + */ + addEventListener(type: 'close', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the guest page has sent an asynchronous message to embedder page. + */ + addEventListener(type: 'ipc-message', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the renderer process is crashed. + */ + addEventListener(type: 'crashed', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the gpu process is crashed. + */ + addEventListener(type: 'gpu-crashed', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when a plugin process is crashed. + */ + addEventListener(type: 'plugin-crashed', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Fired when the WebContents is destroyed. + */ + addEventListener(type: 'destroyed', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when media starts playing. + */ + addEventListener(type: 'media-started-playing', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when media is paused or done playing. + */ + addEventListener(type: 'media-paused', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when a page's theme color changes. This is usually due to encountering a meta tag: + * + */ + addEventListener(type: 'did-change-theme-color', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is opened. + */ + addEventListener(type: 'devtools-opened', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is closed. + */ + addEventListener(type: 'devtools-closed', listener: (event: any) => void, useCapture?: boolean): void; + /** + * Emitted when DevTools is focused / opened. + */ + addEventListener(type: 'devtools-focused', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + } + /** * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window. */ @@ -3655,6 +4076,10 @@ declare namespace Electron { } } +interface Document { + createElement(tagName: 'webview'): Electron.WebViewElement; +} + // https://github.com/atom/electron/blob/master/docs/api/window-open.md interface Window { From 603ba383254fbd61705e906e3f57a0a662cd7b06 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 01:01:09 +0100 Subject: [PATCH 0113/1850] Update accelerator docs --- github-electron/github-electron.d.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index f96cc6fc97..cfaf95ecc0 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1962,16 +1962,22 @@ declare namespace Electron { * Command+A * Ctrl+Shift+Z * - * Platform notice: On Linux and Windows, the Command key would not have any effect, - * you can use CommandOrControl which represents Command on OS X and Control on - * Linux and Windows to define some accelerators. + * Platform notice: + * On Linux and Windows, the Command key would not have any effect, + * you can use CommandOrControl which represents Command on OS X and Control on + * Linux and Windows to define some accelerators. + * + * The Super key is mapped to the Windows key on Windows and Linux and Cmd on OS X. * * Available modifiers: * Command (or Cmd for short) * Control (or Ctrl for short) * CommandOrControl (or CmdOrCtrl for short) * Alt + * Option + * AltGr * Shift + * Super * * Available key codes: * 0 to 9 @@ -1990,6 +1996,7 @@ declare namespace Electron { * Escape (or Esc for short) * VolumeUp, VolumeDown and VolumeMute * MediaNextTrack, MediaPreviousTrack, MediaStop and MediaPlayPause + * PrintScreen */ accelerator?: string; /** From 338bead91cae2787d7995d3bd085da0464bc56e0 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 15:24:00 +0200 Subject: [PATCH 0114/1850] Use interface where appropriate to allow interface merging --- .../github-electron-renderer-tests.ts | 2 +- github-electron/github-electron.d.ts | 31 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/github-electron/github-electron-renderer-tests.ts b/github-electron/github-electron-renderer-tests.ts index 12eaf2f11f..37faae9dbb 100644 --- a/github-electron/github-electron-renderer-tests.ts +++ b/github-electron/github-electron-renderer-tests.ts @@ -164,7 +164,7 @@ holder.ondrop = function (e) { // nativeImage // https://github.com/atom/electron/blob/master/docs/api/native-image.md -var Tray: typeof Electron.Tray = remote.require('Tray'); +var Tray: Electron.Tray = remote.require('Tray'); var appIcon2 = new Tray('/Users/somebody/images/icon.png'); var window2 = new BrowserWindow({ icon: '/Users/somebody/images/window.png' }); var image = clipboard.readImage(); diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index cfaf95ecc0..ce473b8b76 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -30,7 +30,7 @@ declare namespace Electron { /** * The app module is responsible for controlling the application's lifecycle. */ - class App extends EventEmitter { + interface App extends NodeJS.EventEmitter { /** * Emitted when the application has finished basic startup. * On Windows and Linux, the will-finish-launching event @@ -396,7 +396,7 @@ declare namespace Electron { /** * This module provides an interface for the Squirrel auto-updater framework. */ - class AutoUpdater extends EventEmitter { + interface AutoUpdater extends NodeJS.EventEmitter { /** * Emitted when there is an error while updating. */ @@ -1730,7 +1730,7 @@ declare namespace Electron { /** * DownloadItem represents a download item in Electron. */ - class DownloadItem extends EventEmitter { + interface DownloadItem extends NodeJS.EventEmitter { /** * Emits when the downloadItem gets updated. */ @@ -1834,7 +1834,7 @@ declare namespace Electron { * sent from a renderer process (web page). * Messages sent from a renderer will be emitted to this module. */ - class IpcMain extends EventEmitter { + interface IpcMain extends NodeJS.EventEmitter { addListener(channel: string, listener: IpcMainEventListener): this; on(channel: string, listener: IpcMainEventListener): this; once(channel: string, listener: IpcMainEventListener): this; @@ -1863,7 +1863,7 @@ declare namespace Electron { * and asynchronous messages from the render process (web page) to the main process. * You can also receive replies from the main process. */ - class IpcRenderer extends EventEmitter { + interface IpcRenderer extends NodeJS.EventEmitter { addListener(channel: string, listener: IpcRendererEventListener): this; on(channel: string, listener: IpcRendererEventListener): this; once(channel: string, listener: IpcRendererEventListener): this; @@ -2247,7 +2247,7 @@ declare namespace Electron { uninterceptProtocol(scheme: string, completion?: (error: Error) => void): void; } - type ProtocolRequest = { + interface ProtocolRequest { url: string; referrer: string; method: string; @@ -2358,19 +2358,19 @@ declare namespace Electron { touchSupport: 'available' | 'unavailable' | 'unknown'; } - interface Bounds { + type Bounds = { x: number; y: number; width: number; height: number; } - interface Dimension { + type Dimension = { width: number; height: number; } - interface Point { + type Point = { x: number; y: number; } @@ -2381,7 +2381,7 @@ declare namespace Electron { * The screen module retrieves information about screen size, displays, cursor position, etc. * You should not use this module until the ready event of the app module is emitted. */ - class Screen extends EventEmitter { + interface Screen extends NodeJS.EventEmitter { /** * Emitted when newDisplay has been added. */ @@ -2704,7 +2704,7 @@ declare namespace Electron { /** * A Tray represents an icon in an operating system's notification area. */ - class Tray extends EventEmitter { + interface Tray extends NodeJS.EventEmitter { /** * Emitted when the tray icon is clicked. * Note: The bounds payload is only implemented on OS X and Windows. @@ -2764,7 +2764,7 @@ declare namespace Electron { /** * Creates a new tray icon associated with the image. */ - constructor(image: NativeImage|string); + new(image: NativeImage|string): Tray; /** * Destroys the tray icon immediately. */ @@ -2825,7 +2825,7 @@ declare namespace Electron { /** * A WebContents is responsible for rendering and controlling a web page. */ - class WebContents extends EventEmitter { + interface WebContents extends NodeJS.EventEmitter { /** * Emitted when the navigation is done, i.e. the spinner of the tab has stopped spinning, * and the onload event was dispatched. @@ -4020,7 +4020,7 @@ declare namespace Electron { /** * The BrowserWindowProxy object is returned from window.open and provides limited functionality with the child window. */ - class BrowserWindowProxy { + interface BrowserWindowProxy { /** * Removes focus from the child window. */ @@ -4071,7 +4071,7 @@ declare namespace Electron { protocol: Electron.Protocol; screen: Electron.Screen; session: typeof Electron.Session; - Tray: typeof Electron.Tray; + Tray: Electron.Tray; hideInternalModules(): void; } @@ -4092,7 +4092,6 @@ interface Document { interface Window { /** * Creates a new window. - * @returns An instance of BrowserWindowProxy class. */ open(url: string, frameName?: string, features?: string): Electron.BrowserWindowProxy; } From e20b68c99847f9d4784d745659820a088d7e917d Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 15:27:07 +0200 Subject: [PATCH 0115/1850] Add missing method documentation --- github-electron/github-electron.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index ce473b8b76..9cb67c7389 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -2862,7 +2862,7 @@ declare namespace Electron { headers: any ) => void): this; /** - * + * Emitted when a redirect is received while requesting a resource. */ on(event: 'did-get-redirect-request', listener: (event: Event, oldURL: string, From 6d31749557a9d72103947366b171fbae0482137f Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 16:02:05 +0200 Subject: [PATCH 0116/1850] Add proper types for events --- github-electron/github-electron.d.ts | 197 +++++++++++++++++++-------- 1 file changed, 141 insertions(+), 56 deletions(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 9cb67c7389..7ea5f335e2 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -2892,11 +2892,8 @@ declare namespace Electron { on(event: 'new-window', listener: (event: Event, url: string, frameName: string, - disposition: 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'other', - /** - * The options which will be used for creating the new BrowserWindow. - */ - options: any + disposition: NewWindowDisposition, + options: BrowserWindowOptions ) => void): this; /** * Emitted when a user or the page wants to start navigation. @@ -2981,25 +2978,7 @@ declare namespace Electron { /** * Emitted when a result is available for webContents.findInPage request. */ - on(event: 'found-in-page', listener: (event: Event, result: { - requestId: number; - /** - * ndicates if more responses are to follow. - */ - finalUpdate: boolean; - /** - * Position of the active match. - */ - activeMatchOrdinal?: number; - /** - * Number of Matches. - */ - matches?: number; - /** - * Coordinates of first match region. - */ - selectionArea?: any; - }) => void): this; + on(event: 'found-in-page', listener: (event: Event, result: FoundInPageResult) => void): this; /** * Emitted when media starts playing. */ @@ -3305,6 +3284,8 @@ declare namespace Electron { debugger: Debugger; } + type NewWindowDisposition = 'default' | 'foreground-tab' | 'background-tab' | 'new-window' | 'other'; + /** * Specifies the action to take place when ending webContents.findInPage request. * 'clearSelection' - Translate the selection into a normal selection. @@ -3421,6 +3402,26 @@ declare namespace Electron { medialCapitalAsWordStart?: boolean; } + interface FoundInPageResult { + requestId: number; + /** + * Indicates if more responses are to follow. + */ + finalUpdate: boolean; + /** + * Position of the active match. + */ + activeMatchOrdinal?: number; + /** + * Number of Matches. + */ + matches?: number; + /** + * Coordinates of first match region. + */ + selectionArea?: any; + } + interface DeviceEmulationParameters { /** * Specify the screen type to emulated @@ -3875,68 +3876,68 @@ declare namespace Electron { * Fired when a load has committed. This includes navigation within the current document * as well as subframe document-level loads, but does not include asynchronous resource loads. */ - addEventListener(type: 'load-commit', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'load-commit', listener: (event: WebViewElement.LoadCommitEvent) => void, useCapture?: boolean): void; /** * Fired when the navigation is done, i.e. the spinner of the tab will stop spinning, and the onload event is dispatched. */ - addEventListener(type: 'did-finish-load', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-finish-load', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * This event is like did-finish-load, but fired when the load failed or was cancelled, e.g. window.stop() is invoked. */ - addEventListener(type: 'did-fail-load', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-fail-load', listener: (event: WebViewElement.DidFailLoadEvent) => void, useCapture?: boolean): void; /** * Fired when a frame has done navigation. */ - addEventListener(type: 'did-frame-finish-load', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-frame-finish-load', listener: (event: WebViewElement.DidFrameFinishLoadEvent) => void, useCapture?: boolean): void; /** * Corresponds to the points in time when the spinner of the tab starts spinning. */ - addEventListener(type: 'did-start-loading', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-start-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Corresponds to the points in time when the spinner of the tab stops spinning. */ - addEventListener(type: 'did-stop-loading', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-stop-loading', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when details regarding a requested resource is available. * status indicates socket connection to download the resource. */ - addEventListener(type: 'did-get-response-details', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-get-response-details', listener: (event: WebViewElement.DidGetResponseRetails) => void, useCapture?: boolean): void; /** * Fired when a redirect was received while requesting a resource. */ - addEventListener(type: 'did-get-redirect-request', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-get-redirect-request', listener: (event: WebViewElement.DidGetRedirectRequestEvent) => void, useCapture?: boolean): void; /** * Fired when document in the given frame is loaded. */ - addEventListener(type: 'dom-ready', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'dom-ready', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when page title is set during navigation. explicitSet is false when title is synthesized from file URL. */ - addEventListener(type: 'page-title-updated', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'page-title-updated', listener: (event: WebViewElement.PageTitleUpdatedEvent) => void, useCapture?: boolean): void; /** * Fired when page receives favicon URLs. */ - addEventListener(type: 'page-favicon-updated', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'page-favicon-updated', listener: (event: WebViewElement.PageFaviconUpdatedEvent) => void, useCapture?: boolean): void; /** * Fired when page enters fullscreen triggered by HTML API. */ - addEventListener(type: 'enter-html-full-screen', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'enter-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when page leaves fullscreen triggered by HTML API. */ - addEventListener(type: 'leave-html-full-screen', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'leave-html-full-screen', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when the guest window logs a console message. */ - addEventListener(type: 'console-message', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'console-message', listener: (event: WebViewElement.ConsoleMessageEvent) => void, useCapture?: boolean): void; /** * Fired when a result is available for webview.findInPage request. */ - addEventListener(type: 'found-in-page', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'found-in-page', listener: (event: WebViewElement.FoundInPageEvent) => void, useCapture?: boolean): void; /** * Fired when the guest page attempts to open a new browser window. */ - addEventListener(type: 'new-window', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'new-window', listener: (event: WebViewElement.NewWindowEvent) => void, useCapture?: boolean): void; /** * Emitted when a user or the page wants to start navigation. * It can happen when the window.location object is changed or a user clicks a link in the page. @@ -3949,14 +3950,14 @@ declare namespace Electron { * * Calling event.preventDefault() does NOT have any effect. */ - addEventListener(type: 'will-navigate', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'will-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void; /** * Emitted when a navigation is done. * * This event is not emitted for in-page navigations, such as clicking anchor links * or updating the window.location.hash. Use did-navigate-in-page event for this purpose. */ - addEventListener(type: 'did-navigate', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-navigate', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void; /** * Emitted when an in-page navigation happened. * @@ -3964,57 +3965,137 @@ declare namespace Electron { * navigation outside of the page. Examples of this occurring are when anchor links * are clicked or when the DOM hashchange event is triggered. */ - addEventListener(type: 'did-navigate-in-page', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-navigate-in-page', listener: (event: WebViewElement.NavigateEvent) => void, useCapture?: boolean): void; /** * Fired when the guest page attempts to close itself. */ - addEventListener(type: 'close', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'close', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when the guest page has sent an asynchronous message to embedder page. */ - addEventListener(type: 'ipc-message', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'ipc-message', listener: (event: WebViewElement.IpcMessageEvent) => void, useCapture?: boolean): void; /** * Fired when the renderer process is crashed. */ - addEventListener(type: 'crashed', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when the gpu process is crashed. */ - addEventListener(type: 'gpu-crashed', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'gpu-crashed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Fired when a plugin process is crashed. */ - addEventListener(type: 'plugin-crashed', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'plugin-crashed', listener: (event: WebViewElement.PluginCrashedEvent) => void, useCapture?: boolean): void; /** * Fired when the WebContents is destroyed. */ - addEventListener(type: 'destroyed', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'destroyed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when media starts playing. */ - addEventListener(type: 'media-started-playing', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'media-started-playing', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when media is paused or done playing. */ - addEventListener(type: 'media-paused', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'media-paused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when a page's theme color changes. This is usually due to encountering a meta tag: * */ - addEventListener(type: 'did-change-theme-color', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'did-change-theme-color', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when DevTools is opened. */ - addEventListener(type: 'devtools-opened', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'devtools-opened', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when DevTools is closed. */ - addEventListener(type: 'devtools-closed', listener: (event: any) => void, useCapture?: boolean): void; + addEventListener(type: 'devtools-closed', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; /** * Emitted when DevTools is focused / opened. */ - addEventListener(type: 'devtools-focused', listener: (event: any) => void, useCapture?: boolean): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: 'devtools-focused', listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + addEventListener(type: string, listener: (event: WebViewElement.Event) => void, useCapture?: boolean): void; + } + + namespace WebViewElement { + type Event = ElectronPrivate.GlobalEvent; + + interface LoadCommitEvent extends Event { + url: string; + isMainFrame: string; + } + + interface DidFailLoadEvent extends Event { + errorCode: number; + errorDescription: string; + validatedURL: string; + } + + interface DidFrameFinishLoadEvent extends Event { + isMainFrame: boolean; + } + + interface DidGetResponseRetails extends Event { + status: boolean; + newURL: string; + originalURL: string; + httpResponseCode: number; + requestMethod: string; + referrer: string; + headers: any; + } + + interface DidGetRedirectRequestEvent extends Event { + oldURL: string; + newURL: string; + isMainFrame: boolean; + httpResponseCode: number; + requestMethod: string; + referrer: string; + headers: any; + } + + interface PageTitleUpdatedEvent extends Event { + title: string; + explicitSet: string; + } + + interface PageFaviconUpdatedEvent extends Event { + favicons: string[]; + } + + interface ConsoleMessageEvent extends Event { + level: number; + message: string; + line: number; + sourceId: string; + } + + interface FoundInPageEvent extends Event { + result: FoundInPageResult; + } + + interface NewWindowEvent extends Event { + url: string; + frameName: string; + disposition: NewWindowDisposition; + options: BrowserWindowOptions; + } + + interface NavigateEvent extends Event { + url: string; + } + + interface IpcMessageEvent extends Event { + channel: string; + args: any[]; + } + + interface PluginCrashedEvent extends Event { + name: string; + version: string; + } } /** @@ -4083,6 +4164,10 @@ declare namespace Electron { } } +declare namespace ElectronPrivate { + type GlobalEvent = Event; +} + interface Document { createElement(tagName: 'webview'): Electron.WebViewElement; } From 4f6eb3eb856da1ed6813fc6fd6db72e77e56eba4 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 16:27:23 +0200 Subject: [PATCH 0117/1850] Update to Electron 0.37.3 --- github-electron/github-electron.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 7ea5f335e2..1587a8420f 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v0.37.2 +// Type definitions for Electron v0.37.3 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -221,6 +221,10 @@ declare namespace Electron { * name by Electron. */ getName(): string; + /** + * Overrides the current application's name. + */ + setName(name: string): void; /** * @returns The current application locale. */ @@ -2118,6 +2122,12 @@ declare namespace Electron { * @returns string The data URL of the image. */ toDataURL(): string; + /** + * The native type of the handle is NSImage* on OS X. + * Note: This is only implemented on OS X. + * @returns The platform-specific handle of the image as Buffer. + */ + getNativeHandle(): Buffer; /** * @returns boolean Whether the image is empty. */ From f4c846d332e850d12f9ed8a7136014bb3658a5bd Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Sun, 27 Mar 2016 20:42:15 +0200 Subject: [PATCH 0118/1850] Add missing error argument in Session.cookies.remove callback --- github-electron/github-electron.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index 1587a8420f..ee223e5cd3 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -2669,7 +2669,7 @@ declare namespace Electron { /** * Removes the cookies matching url and name. */ - remove(url: string, name: string, callback: Function): void; + remove(url: string, name: string, callback: (error: Error) => void): void; } // https://github.com/atom/electron/blob/master/docs/api/shell.md From 905ee7e6f5a1971e3f8aef16ee789f4600ca5e51 Mon Sep 17 00:00:00 2001 From: Ryan Smith <0ryansmith1994@gmail.com> Date: Wed, 30 Mar 2016 18:18:16 +0100 Subject: [PATCH 0119/1850] Attempts to fix more TS2339 errors. ``` knex/knex-tests.ts(498,45): error TS2339: Property 'map' does not exist on type 'QueryBuilder'. knex/knex-tests.ts(506,45): error TS2339: Property 'reduce' does not exist on type 'QueryBuilder'. ``` https://travis-ci.org/DefinitelyTyped/DefinitelyTyped/builds/119590526 --- knex/knex-tests.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index 2113be68d7..c0483c5d97 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -495,19 +495,23 @@ query.then(function(x: any) { return x; }); -knex.select('name').from('users').limit(10).map(function(row: any) { - return row.name; +knex.select('name').from('users').limit(10).then(function (rows: any[]) { + return rows.map(function (row: string) { + return row.name; + }); }).then(function(names: string) { console.log(names); }).catch(function(e: Error) { console.error(e); }); -knex.select('name').from('users').limit(10).reduce(function(memo: any, row: any) { - memo.names.push(row.name); - memo.count++; - return memo; -}, {count: 0, names: []}).then(function(obj: any) { +knex.select('name').from('users').limit(10).then(function (rows: any[]) { + return rows.reduce(function(memo: any, row: any) { + memo.names.push(row.name); + memo.count++; + return memo; + }, {count: 0, names: []}) +}).then(function(obj: any) { console.log(obj); }).catch(function(e: Error) { console.error(e); From ff6d2d2b904d8b97b478385632f4b7841ecf2df3 Mon Sep 17 00:00:00 2001 From: Ryan Smith <0ryansmith1994@gmail.com> Date: Wed, 30 Mar 2016 18:22:39 +0100 Subject: [PATCH 0120/1850] Attempts to fix new errors. ``` knex/knex-tests.ts(500,16): error TS2339: Property 'name' does not exist on type 'string'. knex/knex-tests.ts(502,9): error TS2345: Argument of type '(names: string) => void' is not assignable to parameter of type '(value: any[]) => void | PromiseLike'. Types of parameters 'names' and 'value' are incompatible. Type 'string' is not assignable to type 'any[]'. ``` https://travis-ci.org/DefinitelyTyped/DefinitelyTyped/builds/119592117 --- knex/knex-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index c0483c5d97..cd67a08736 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -495,8 +495,8 @@ query.then(function(x: any) { return x; }); -knex.select('name').from('users').limit(10).then(function (rows: any[]) { - return rows.map(function (row: string) { +knex.select('name').from('users').limit(10).then(function (rows: any[]): string[] { + return rows.map(function (row: any): string { return row.name; }); }).then(function(names: string) { From 84ae09b62434e524ea043498fb2f7ea4f9744353 Mon Sep 17 00:00:00 2001 From: Ryan Smith <0ryansmith1994@gmail.com> Date: Wed, 30 Mar 2016 18:29:30 +0100 Subject: [PATCH 0121/1850] Attempts to fix remaining errors. ``` knex/knex-tests.ts(502,9): error TS2345: Argument of type '(names: string) => void' is not assignable to parameter of type '(value: string[]) => void | PromiseLike'. Types of parameters 'names' and 'value' are incompatible. Type 'string' is not assignable to type 'string[]'. knex/knex-tests.ts(522,4): error TS2339: Property 'bind' does not exist on type 'QueryBuilder'. knex/knex-tests.ts(533,35): error TS2339: Property 'return' does not exist on type 'QueryBuilder'. ``` https://travis-ci.org/DefinitelyTyped/DefinitelyTyped/builds/119593429 --- knex/knex-tests.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/knex/knex-tests.ts b/knex/knex-tests.ts index cd67a08736..e983ec1084 100644 --- a/knex/knex-tests.ts +++ b/knex/knex-tests.ts @@ -499,7 +499,7 @@ knex.select('name').from('users').limit(10).then(function (rows: any[]): string[ return rows.map(function (row: any): string { return row.name; }); -}).then(function(names: string) { +}).then(function(names: string[]) { console.log(names); }).catch(function(e: Error) { console.error(e); @@ -519,19 +519,16 @@ knex.select('name').from('users').limit(10).then(function (rows: any[]) { knex.select('name').from('users') .limit(10) - .bind(console) - .then(console.log) - .catch(console.error); + .then(console.log.bind(console)) + .catch(console.error.bind(console)); var values: any[]; -// Without return: + knex.insert(values).into('users') .then(function() { return {inserted: true}; }); -knex.insert(values).into('users').return({inserted: true}); - knex.select('name').from('users') .where('id', '>', 20) .andWhere('id', '<', 200) From 9c110cd0c3204fd62a4e9b1a52e4c0edf4bd201b Mon Sep 17 00:00:00 2001 From: Sam Verschueren Date: Wed, 30 Mar 2016 19:40:06 +0200 Subject: [PATCH 0122/1850] update query-string definition --- query-string/query-string-tests.ts | 1 + query-string/query-string.d.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/query-string/query-string-tests.ts b/query-string/query-string-tests.ts index 597d270f2e..e270786004 100644 --- a/query-string/query-string-tests.ts +++ b/query-string/query-string-tests.ts @@ -4,6 +4,7 @@ import qs = require('query-string'); qs.stringify({ foo: 'bar' }); qs.stringify({ foo: 'bar', bar: 'baz' }); +qs.stringify({ foo: 'bar' }, {strict: false}) qs.parse('?foo=bar'); qs.parse('#foo=bar'); diff --git a/query-string/query-string.d.ts b/query-string/query-string.d.ts index e4d76d0030..ebee7e81a4 100644 --- a/query-string/query-string.d.ts +++ b/query-string/query-string.d.ts @@ -16,7 +16,7 @@ declare module "query-string" { * * @param obj */ - export function stringify(obj: any): string; + export function stringify(obj: any, options?: {strict: boolean}): string; /** * Extract a query string from a URL that can be passed into .parse(). From 34c761bb51abe6a13ba7077664296660c9c72e29 Mon Sep 17 00:00:00 2001 From: Dave Allen Date: Wed, 30 Mar 2016 11:16:17 -0700 Subject: [PATCH 0123/1850] Updated for Meteor 1.3. Added more tests to verify recent updates to definitions. --- meteor/README.md | 105 ++++++------------------------- meteor/meteor-tests.ts | 63 +++++++++++++++++-- meteor/meteor.d.ts | 137 ++++++++++++++++++++++++++--------------- 3 files changed, 165 insertions(+), 140 deletions(-) diff --git a/meteor/README.md b/meteor/README.md index 500823745b..d9d7898ffb 100644 --- a/meteor/README.md +++ b/meteor/README.md @@ -1,52 +1,20 @@ # Meteor Type Definitions -These are the definitions for version 1.2.0.2 of Meteor. - -Although these definitions can be downloaded separately for use, the recommended way to use these definitions in a Meteor application is by installing the -[typescript-libs](https://atmospherejs.com/meteortypescript/typescript-libs) Meteor smart package from atmosphere. The smart package contains TypeScript -definitions forMeteor, common third-party libraries (e.g. jquery, underscore, d3 etc.), and common smart packages (e.g. iron-router, etc). - -From within any Meteor application that is version 0.9.0 or later, install this package in the standard manner: - - $ meteor add meteortypescript:typescript-libs - -These definitions were generated from the from the same [Meteor data.js file] (https://github.com/meteor/meteor/blob/devel/docs/client/data.js) that is used -to generate the official [Meteor docs] (http://docs.meteor.com/). +These are the definitions for version 1.3 of Meteor. These definitions were generated from the from the same [Meteor data.js file] (https://github.com/meteor/meteor/blob/devel/docs/client/data.js) that is used to generate the official [Meteor docs] (http://docs.meteor.com/). The code that generates these definitions can be found [here](https://github.com/meteor-typescript/meteor-typescript-libs/). -## Usage (OSX/Linux) +## Upcoming Meteor `typescript` package -1. Add a symbolic link to the definitions from within some directory within your project (e.g. ".typescript" or "lib"). The definitions can be found somewhere deep within `/.meteor/...`. The following will probably work: +There is currently an effort supported by the Meteor Development Group to create a TypeScript build compiler package, and an early version of the package can be tested using [`barbatus:typescript`](https://atmospherejs.com/barbatus/typescript). - $ ln -s ../.meteor/local/build/programs/server/assets/packages/meteortypescript_typescript-libs/definitions package_defs +From within any Meteor application that is version 1.2.1 or later, install this package in the standard manner: - If the definitions can't be found within the .meteor directory, you will have to manually pull down the definitions from github and add them to your project: - - + $ meteor add barbatus:typescript -2. Install the [Typescript compiler for Meteor](https://github.com/meteor-typescript/meteor-typescript-compiler) or an [IDE which can transpile TypeScript to JavaScript](#transpiling-typescript). -3. From the typescript files, add references. Reference the definition files with a single line: +This package will eventually incorporated as a Meteor core package (e.g. like the `coffeescript` package). It appears that the eventual recommended practice for adding definitions using that package will be to add them using the [`typings`](https://github.com/typings/typings) tool. - /// (substitute path in your project) +You can follow discussion about this effort [here](https://github.com/Urigo/angular2-meteor/issues/102#issuecomment-200915763). - Or you can reference definition files individually: - - /// (substitute path in your project) - /// - /// - - Meteor core definitions can be referenced in an "all-in-one" definition file ( *meteor.d.ts* ) or definition files specific to the locus of execution: - - - *meteor.d.ts*: all meteor core definitions - - *meteor.common.d.ts*: meteor core code running on both client and server - - *meteor.client.d.ts*: meteor core client-only code - - *meteor.server.d.ts*: meteor core server-only code - - *meteor.package.d.ts*: meteor core package-only code - - *meteor.build.d.ts*: meteor core build-only code - - *meteor.d.ts* contains all of the definitions found in *meteor.common.d.ts*, *meteor.client.d.ts*, *meteor.server.d.ts*, *meteor.package.d.ts*, and *meteor.build.d.ts* - -4. Be aware of differences in coding styles when using TypeScript (see below) ## TypeScript/Meteor coding style @@ -55,15 +23,14 @@ to generate the official [Meteor docs] (http://docs.meteor.com/). Meteor code can run on the client and the server, for this reason you should try to stay away from referencing *file.ts* directly: you may get unexpected results. -Rather generate a *file.d.ts* using `tsc --declaration file.ts`, and reference it in your file. - +Rather generate a *file.d.ts* using `tsc --declaration file.ts`, and reference it in your file. + Compilation will be much faster and code will be cleaner - it's always better to split definition from implementation anyways. ### Templates With the exception of the **body** and **head** templates, Meteor's Template dot notation cannot be used (ie. *Template.mytemplate*). Thanks to Typescript static typing checks, you will need to use the *bracket notation* to access the Template. - Template['myTemplateName'].helpers({ foo: function () { return Session.get("foo"); @@ -71,20 +38,27 @@ With the exception of the **body** and **head** templates, Meteor's Template dot }); Template['myTemplateName'].onRendered(function ( ) { ... }); - + + +The same is true for `Meteor.settings`: + + Meteor.settings.public[''] + ### Form fields Form fields typically need to be cast to ``. For instance to read a form field value, use `(evt.target).value`. + ### Global variables -Preface any global variable declarations with a TypeScript "declare var" statement (or place the statement in a definition file): +Preface any global variable declarations with a TypeScript `declare var` statement (or place the statement in a definition file): declare var NavbarHelpers; NavbarHelpers = {}; NavbarHelpers.someMethod = function() {...} + ### Collections The majority of extra work required to use TypeScript with Meteor is creating and maintaining the collection interfaces. However, doing so also provides the additional benefit of succinctly documenting collection schema definitions (that are actually enforced). @@ -106,46 +80,3 @@ Finally, any TypeScript file using collections will need to contain a reference /// /// - -### Creating definition files - -Here is a guide to creating definitions: - -If you have lots of custom definitions for a project, you can: - -- Create multiple definition files and include individual references to each definition file. -- Create one huge monolithic definition file so you only have to refer to that file. -- Create multiple definition files, and create a definition file with references to the other definitions files so that you only have to maintain one reference for all of you custom definitions. e.g. contents of ".typescript/custom_defs/custom-definitions.d.ts": - - /// - /// - /// - /// - - -## Transpiling TypeScript - -### Meteor plugin -One solution for transpiling typescript is to install the following meteor package: [https://github.com/meteor-typescript/meteor-typescript-compiler](https://github.com/meteor-typescript/meteor-typescript-compiler) - -### IDE/Editor Transpilation -WebStorm, SublimeText, Atom, and VisualStudio all support TypeScript. They can automatically transpile your TypeScript code into JavaScript every time you save a file. - -#### WebStorm #### -To support TypeScript in WebStorm on OSX, first install the TypeScript transpiler on your system: - - $ [sudo -H] npm install -g typescript - -On version 10 of WebStorm or later, got to Preferences -> Languages & Frameworks -> TypeScript and check "Enable TypeScript Compiler" - -On older versions of WebStorm (9 or earlier), go to Preferences -> File Watchers -> "+" symbol and add TypeScript. - -#### SublimeText, Atom, and VisualStudio #### -Please refer to the documentation for these editors. - -### Command line - -The last option is to compile code from the command line. With node and the TypeScript compiler installed: - - $ tsc *.ts - diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts index bd3b7156c2..044df149bf 100644 --- a/meteor/meteor-tests.ts +++ b/meteor/meteor-tests.ts @@ -131,12 +131,15 @@ Meteor.methods({ /** * From Methods, Meteor.Error section */ -throw new Meteor.Error("logged-out", - "The user must be logged in to post a comment."); - -throw new Meteor.Error(403, - "The user must be logged in to post a comment."); +function meteorErrorTestFunction1() { + throw new Meteor.Error("logged-out", + "The user must be logged in to post a comment."); +} +function meteorErrorTestFunction2() { + throw new Meteor.Error(403, + "The user must be logged in to post a comment."); +} Meteor.call("methodName", function (error: Meteor.Error) { if (error.error === "logged-out") { @@ -623,3 +626,53 @@ var reactiveVar2 = new ReactiveVar('test value', function(oldVal:any) { var varValue: string = reactiveVar1.get(); reactiveVar1.set('new value'); + +// Covers this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8233 +var isConfigured: boolean = Accounts.loginServicesConfigured(); +Accounts.onPageLoadLogin(function() { + // do something +}); + +// Covers this PR: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/8065 +var loginOpts: Meteor.LoginWithExternalServiceOptions = { + requestPermissions: ["a", "b"], + requestOfflineToken: true, + loginUrlParameters: {asdf: 1, qwer: "1234"}, + loginHint: "Help me", + loginStyle: "Bold and powerful", + redirectUrl: "popup", + profile: "asdfasdf", + email: "asdf@ASDf.com" +}; +Meteor.loginWithMeteorDeveloperAccount(loginOpts, function(error, result) {}); + +Accounts.emailTemplates.siteName = "AwesomeSite"; +Accounts.emailTemplates.from = "AwesomeSite Admin "; +Accounts.emailTemplates.headers = { asdf: 'asdf', qwer: 'qwer' }; + +Accounts.emailTemplates.enrollAccount.subject = function (user) { + return "Welcome to Awesome Town, " + user.profile.name; +}; +Accounts.emailTemplates.enrollAccount.html = function (user, url) { + return "

Some html here

"; +}; +Accounts.emailTemplates.enrollAccount.from = function() { + return "asdf@asdf.com"; +}; +Accounts.emailTemplates.enrollAccount.text = function (user, url) { + return "You have been selected to participate in building a better future!" + + " To activate your account, simply click the link below:\n\n" + + url; +}; + +var handle = Accounts.validateLoginAttempt(function(attemptInfoObject: Accounts.IValidateLoginAttemptCbOpts) { + var type: string = attemptInfoObject.type; + var allowed: boolean = attemptInfoObject.allowed; + var error: Meteor.Error = attemptInfoObject.error; + var user: Meteor.User = attemptInfoObject.user; + var connection: Meteor.Connection = attemptInfoObject.connection; + var methodName: string = attemptInfoObject.methodName; + var methodArguments: any[] = attemptInfoObject.methodArguments; + return true; +}); +handle.stop(); diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts index c86b4dd03c..fb0ff4819f 100644 --- a/meteor/meteor.d.ts +++ b/meteor/meteor.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Meteor 1.2.0.2 +// Type definitions for Meteor 1.3 // Project: http://www.meteor.com/ // Definitions by: Dave Allen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -15,7 +15,7 @@ interface JSONable { } interface EJSON extends EJSONable {} -declare namespace Match { +declare module Match { var Any: any; var String: any; var Integer: any; @@ -29,7 +29,7 @@ declare namespace Match { function Where(condition: any): any; } -declare namespace Meteor { +declare module Meteor { interface UserEmail { address:string; verified:boolean; @@ -57,7 +57,7 @@ declare namespace Meteor { } } -declare namespace DDP { +declare module DDP { interface DDPStatic { subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle; call(method: string, ...parameters: any[]):void; @@ -79,7 +79,7 @@ declare namespace DDP { } } -declare namespace Mongo { +declare module Mongo { interface Selector { [key: string]:any; } @@ -91,7 +91,7 @@ declare namespace Mongo { } } -declare namespace HTTP { +declare module HTTP { interface HTTPRequest { content?:string; @@ -118,7 +118,7 @@ declare namespace HTTP { function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; } -declare namespace Random { +declare module Random { function id(numberOfChars?: number): string; function secret(numberOfChars?: number): string; function fraction():number; @@ -127,13 +127,18 @@ declare namespace Random { function choice(str:string):string; // @param str, @return a random char in str } +declare module Accounts { + function loginServicesConfigured(): boolean; + + function onPageLoadLogin(func: Function): void; +} /** * These are the client modules and interfaces that can't be automatically generated from the Meteor data.js file */ -declare namespace Meteor { +declare module Meteor { /** Start definitions for Template **/ - interface Event { + export interface Event { type:string; target:HTMLElement; currentTarget:HTMLElement; @@ -157,10 +162,13 @@ declare namespace Meteor { interface LoginWithExternalServiceOptions { requestPermissions?: string[]; - requestOfflineToken?: Boolean; - forceApprovalPrompt?: Boolean; - userEmail?: string; + requestOfflineToken?: boolean; + loginUrlParameters?: {[param: string]: any} + loginHint?: string; loginStyle?: string; + redirectUrl?: "popup" | "redirect"; + profile?: any; + email?: string; } function loginWithMeteorDeveloperAccount(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; @@ -170,6 +178,7 @@ declare namespace Meteor { function loginWithMeetup(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; function loginWithTwitter(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; function loginWithWeibo(options?: Meteor.LoginWithExternalServiceOptions, callback?: Function): void; + function _sleepForMs(milliseconds: number): void; interface SubscriptionHandle { stop(): void; @@ -177,7 +186,7 @@ declare namespace Meteor { } } -declare namespace Blaze { +declare module Blaze { interface View { name: string; parentView: Blaze.View; @@ -201,7 +210,7 @@ declare namespace Blaze { } } -declare namespace BrowserPolicy { +declare module BrowserPolicy { interface framing { disallow():void; @@ -242,18 +251,21 @@ declare namespace BrowserPolicy { * These are the server modules and interfaces that can't be automatically generated from the Meteor data.js file */ -declare namespace Meteor { +declare module Meteor { interface EmailFields { - subject?: Function; - text?: Function; + from?: () => string; + subject?: (user: Meteor.User) => string; + text?: (user: Meteor.User, url: string) => string; + html?: (user: Meteor.User, url: string) => string; } interface EmailTemplates { - from: string; - siteName: string; - resetPassword: Meteor.EmailFields; - enrollAccount: Meteor.EmailFields; - verifyEmail: Meteor.EmailFields; + from?: string; + siteName?: string; + headers?: { [id: string]: string }; // TODO: should define IHeaders interface + resetPassword?: Meteor.EmailFields; + enrollAccount?: Meteor.EmailFields; + verifyEmail?: Meteor.EmailFields; } interface Connection { @@ -263,9 +275,19 @@ declare namespace Meteor { clientAddress: string; httpHeaders: Object; } + + interface IValidateLoginAttemptCbOpts { + type: string; + allowed: boolean; + error: Error; + user: Meteor.User; + connection: Meteor.Connection; + methodName: string; + methodArguments: any[]; + } } -declare namespace Mongo { +declare module Mongo { interface AllowDenyOptions { insert?: (userId: string, doc: any) => boolean; update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean; @@ -275,6 +297,18 @@ declare namespace Mongo { } } +declare module Accounts { + interface IValidateLoginAttemptCbOpts { + type?: string; + allowed?: boolean; + error?: Meteor.Error; + user?: Meteor.User; + connection?: Meteor.Connection; + methodName?: string; + methodArguments?: any[]; + } +} + interface MailComposerOptions { escapeSMTP: boolean; encoding: string; @@ -328,20 +362,20 @@ interface ITinytestAssertions { _stringEqual(actual: string, expected: string, msg?: string): void; } -declare namespace Tinytest { +declare module Tinytest { function add(description : string , func : (test : ITinytestAssertions) => void) : void; function addAsync(description : string , func : (test : ITinytestAssertions) => void) : void; } // Kept in for backwards compatibility -declare namespace Meteor { +declare module Meteor { interface Tinytest { add(description : string , func : (test : ITinytestAssertions) => void) : void; addAsync(description : string , func : (test : ITinytestAssertions) => void) : void; } } -declare namespace Accounts { +declare module Accounts { function addEmail(userId: string, newEmail: string, verified?: boolean): void; function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; function createUser(options: { @@ -392,14 +426,13 @@ declare namespace Accounts { function logout(callback?: Function): void; function logoutOtherClients(callback?: Function): void; function onCreateUser(func: Function): void; - function validateLoginAttempt(func: Function): { stop: () => void }; + function validateLoginAttempt(cb: (params: Accounts.IValidateLoginAttemptCbOpts) => boolean): { stop: () => void }; function validateNewUser(func: Function): boolean; - function loginServicesConfigured(): boolean; - function onPageLoadLogin(func: Function): void; } -declare namespace App { - function accessRule(domainRule: string, options?: { +declare module App { + function accessRule(pattern: string, options?: { + type?: string; launchExternal?: boolean; }): void; function configurePlugin(id: string, config: Object): void; @@ -417,12 +450,12 @@ declare namespace App { function setPreference(name: string, value: string, platform?: string): void; } -declare namespace Assets { +declare module Assets { function getBinary(assetPath: string, asyncCallback?: Function): EJSON; function getText(assetPath: string, asyncCallback?: Function): string; } -declare namespace Blaze { +declare module Blaze { function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; function Let(bindings: Function, contentFunc: Function): Blaze.View; @@ -476,20 +509,20 @@ declare namespace Blaze { function toHTMLWithData(templateOrView: Template | Blaze.View, data: Object | Function): string; } -declare namespace Cordova { +declare module Cordova { function depends(dependencies:{[id:string]:string}): void; } -declare namespace DDP { +declare module DDP { function connect(url: string): DDP.DDPStatic; } -declare namespace DDPCommon { +declare module DDPCommon { function MethodInvocation(options: { }): any; } -declare namespace EJSON { +declare module EJSON { var CustomType: CustomTypeStatic; interface CustomTypeStatic { new(): CustomType; @@ -517,11 +550,11 @@ declare namespace EJSON { function toJSONValue(val: EJSON): JSONable; } -declare namespace Match { +declare module Match { function test(value: any, pattern: any): boolean; } -declare namespace Meteor { +declare module Meteor { var Error: ErrorStatic; interface ErrorStatic { new(error: string | number, reason?: string, details?: string): Error; @@ -546,13 +579,15 @@ declare namespace Meteor { function disconnect(): void; var isClient: boolean; var isCordova: boolean; + var isDevelopment: boolean; + var isProduction: boolean; var isServer: boolean; function loggingIn(): boolean; function loginWith(options?: { requestPermissions?: string[]; requestOfflineToken?: boolean; loginUrlParameters?: Object; - userEmail?: string; + loginHint?: string; loginStyle?: string; redirectUrl?: string; }, callback?: Function): void; @@ -566,7 +601,7 @@ declare namespace Meteor { var release: string; function setInterval(func: Function, delay: number): number; function setTimeout(func: Function, delay: number): number; - var settings: {[id:string]: any}; + var settings: { public: {[id:string]: any}, private: {[id:string]: any}, [id:string]: any}; function startup(func: Function): void; function status(): Meteor.StatusEnum; function subscribe(name: string, ...args: any[]): Meteor.SubscriptionHandle; @@ -576,7 +611,7 @@ declare namespace Meteor { function wrapAsync(func: Function, context?: Object): any; } -declare namespace Mongo { +declare module Mongo { var Collection: CollectionStatic; interface CollectionStatic { new(name: string, options?: { @@ -607,6 +642,9 @@ declare namespace Mongo { fields?: Mongo.FieldSpecifier; reactive?: boolean; transform?: Function; + disableOplog?: boolean; + pollingIntervalMs?: number; + pollingThrottleMs?: number; }): Mongo.Cursor; findOne(selector?: Mongo.Selector | Mongo.ObjectID | string, options?: { sort?: Mongo.SortSpecifier; @@ -651,12 +689,12 @@ declare namespace Mongo { } -declare namespace Npm { +declare module Npm { function depends(dependencies:{[id:string]:string}): void; function require(name: string): any; } -declare namespace Package { +declare module Package { function describe(options: { summary?: string; version?: string; @@ -665,6 +703,7 @@ declare namespace Package { documentation?: string; debugOnly?: boolean; prodOnly?: boolean; + testOnly?: boolean; }): void; function onTest(func: Function): void; function onUse(func: Function): void; @@ -676,7 +715,7 @@ declare namespace Package { }): void; } -declare namespace Tracker { +declare module Tracker { function Computation(): void; interface Computation { firstRun: boolean; @@ -709,14 +748,14 @@ declare namespace Tracker { function onInvalidate(callback: Function): void; } -declare namespace Session { +declare module Session { function equals(key: string, value: string | number | boolean | any /** Null **/ | any /** Undefined **/): boolean; function get(key: string): any; function set(key: string, value: EJSONable | any /** Undefined **/): void; function setDefault(key: string, value: EJSONable | any /** Undefined **/): void; } -declare namespace HTTP { +declare module HTTP { function call(method: string, url: string, options?: { content?: string; data?: Object; @@ -731,11 +770,12 @@ declare namespace HTTP { }, asyncCallback?: Function): HTTP.HTTPResponse; function del(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; function get(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; + function patch(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; function post(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; function put(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; } -declare namespace Email { +declare module Email { function send(options: { from?: string; to?: string | string[]; @@ -837,6 +877,7 @@ interface TemplateStatic { $:any; body: Template; currentData(): {}; + deregisterHelper(name: string): void; instance(): Blaze.TemplateInstance; parentData(numLevels?: number): {}; registerHelper(name: string, helperFunction: Function): void; From 74e0e7b605037af5fb239acbb2bc019e8459f9ce Mon Sep 17 00:00:00 2001 From: Markus Wagner Date: Wed, 30 Mar 2016 20:44:45 +0200 Subject: [PATCH 0124/1850] Definitions for https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin added --- .../cordova-plugin-x-socialsharing-tests.ts | 62 +++++++++++++++++++ .../cordova-plugin-x-socialsharing.d.ts | 50 +++++++++++++++ 2 files changed, 112 insertions(+) create mode 100755 cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts create mode 100755 cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing.d.ts diff --git a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts new file mode 100755 index 0000000000..6112e46066 --- /dev/null +++ b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts @@ -0,0 +1,62 @@ +/// + +window.plugins.socialsharing.iPadPopupCoordinates = function () { + return "100,100,200,300"; +}; + +window.plugins.socialsharing.setIPadPopupCoordinates("100,100,200,300"); + +window.plugins.socialsharing.available(function (isAvailable) { + if (isAvailable) { + // now use any of the share() functions + } +}); + +window.plugins.socialsharing.share("Message only"); +window.plugins.socialsharing.share("Message and subject", "The subject"); +window.plugins.socialsharing.share(null, null, null, "http://www.x-services.nl"); +window.plugins.socialsharing.share("Message and link", null, null, "http://www.x-services.nl"); +window.plugins.socialsharing.share(null, null, "https://www.google.nl/images/srpr/logo4w.png", null); +window.plugins.socialsharing.share(null, "Android filename", "data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7", null); +window.plugins.socialsharing.share("Message and image", null, "https://www.google.nl/images/srpr/logo4w.png", null); +window.plugins.socialsharing.share("Message, image and link", null, "https://www.google.nl/images/srpr/logo4w.png", "http://www.x-services.nl"); +window.plugins.socialsharing.share("Message, subject, image and link", "The subject", "https://www.google.nl/images/srpr/logo4w.png", "http://www.x-services.nl"); + +window.plugins.socialsharing.shareViaTwitter("Message via Twitter"); +window.plugins.socialsharing.shareViaTwitter("Message and link via Twitter", null, "http://www.x-services.nl"); + +window.plugins.socialsharing.shareViaFacebook("Message via Facebook", null, null, function () { console.log("share ok") }, function (errormsg) { alert(errormsg) }); +window.plugins.socialsharing.shareViaFacebookWithPasteMessageHint("Message via Facebook", null, null, "Paste it dude!", function () { console.log("share ok") }, function (errormsg) { alert(errormsg) }); + +window.plugins.socialsharing.shareViaInstagram("Message via Instagram", "https://www.google.nl/images/srpr/logo4w.png", function () { console.log("share ok") }, function (errormsg) { alert(errormsg) }); + +window.plugins.socialsharing.shareViaWhatsApp("Message via WhatsApp", null, null, function () { console.log("share ok") }, function (errormsg) { alert(errormsg) }); + +window.plugins.socialsharing.shareViaSMS("My cool message", null, function (msg) { console.log("ok: " + msg) }, function (msg) { alert("error: " + msg) }); +window.plugins.socialsharing.shareViaSMS("My cool message", "0612345678,0687654321", function (msg) { console.log("ok: " + msg) }, function (msg) { alert("error: " + msg) }); +window.plugins.socialsharing.shareViaSMS({ "message": "My cool message", "subject": "The subject", "image": "https://www.google.nl/images/srpr/logo4w.png" }, "0612345678,0687654321", function (msg) { console.log("ok: " + msg) }, function (msg) { alert("error: " + msg) }); + +window.plugins.socialsharing.shareViaEmail("Message", "Subject", ["to@person1.com", "to@person2.com"], ["cc@person1.com"], null, ["https://www.google.nl/images/srpr/logo4w.png", "www/localimage.png"], function () { console.log("share ok") }, function (errormsg) { alert(errormsg) }); + +window.plugins.socialsharing.shareVia("com.apple.social.facebook", "Message via FB", null, null, null, function () { console.log("share ok") }, function (msg) { alert("error: " + msg) }); +window.plugins.socialsharing.shareVia("facebook", "Message via FB", null, null, null, function () { console.log("share ok") }, function (msg) { alert("error: " + msg) }); +window.plugins.socialsharing.shareVia("com.apple.social.twitter", "Message via Twitter", null, null, "http://www.x-services.nl", function () { console.log("share ok") }, function (msg) { alert("error: " + msg) }); +window.plugins.socialsharing.shareVia("bogus_app", "Message via Bogus App", null, null, null, function () { console.log("share ok") }, function (msg) { alert("error: " + msg) }); + +window.plugins.socialsharing.canShareVia("com.tencent.mm/com.tencent.mm.ui.tools.ShareToTimeLineUI", "msg", null, "img", null, function (e) { alert(e) }, function (e) { alert(e) }); +window.plugins.socialsharing.canShareVia("com.apple.social.facebook", "msg", null, null, null, function (e) { alert(e) }, function (e) { alert(e) }); +window.plugins.socialsharing.canShareVia("whatsapp", "msg", null, null, null, function (e) { alert(e) }, function (e) { alert(e) }); +window.plugins.socialsharing.canShareVia("sms", "msg", null, null, null, function (e) { alert(e) }, function (e) { alert(e) }); +window.plugins.socialsharing.canShareVia("instagram", "msg", null, null, null, function (e) { alert(e) }, function (e) { alert(e) }); +window.plugins.socialsharing.canShareViaEmail(function (e) { alert(e) }, function (e) { alert(e) }); + +window.plugins.socialsharing.share(null, null, "www/image.gif", null); +window.plugins.socialsharing.share(null, null, "/Users/username/Library/Application Support/iPhone/6.1/Applications/25A1E7CF-079F-438D-823B-55C6F8CD2DC0/Documents/.nl.x-services.appname/pics/img.jpg"); +window.plugins.socialsharing.share(null, null, "file:///Users/username/Library/Application Support/iPhone/6.1/Applications/25A1E7CF-079F-438D-823B-55C6F8CD2DC0/Documents/.nl.x-services.appname/pics/img.jpg"); +window.plugins.socialsharing.share(null, null, "file:///storage/emulated/0/nl.xservices.testapp/5359/Photos/16832/Thumb.jpg"); +window.plugins.socialsharing.share(null, null, "http://domain.com/image.jpg"); + +window.plugins.socialsharing.shareViaFacebook("Optional message, may be ignored by Facebook app", ["https://www.google.nl/images/srpr/logo4w.png", "www/image.gif"], null); +window.plugins.socialsharing.share("Optional message", "Optional title", ["www/manual.pdf", "https://www.google.nl/images/srpr/logo4w.png"], "http://www.myurl.com"); + +window.plugins.socialsharing.saveToPhotoAlbum(["https://www.google.nl/images/srpr/logo4w.png", "www/image.gif"], function () { console.log("share ok") }, function (msg) { alert("error: " + msg) }); diff --git a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing.d.ts b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing.d.ts new file mode 100755 index 0000000000..a8dd93c586 --- /dev/null +++ b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing.d.ts @@ -0,0 +1,50 @@ +// Type definitions for SocialSharing-PhoneGap-Plugin v5.0.12 +// Project: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin +// Definitions by: Markus Wagner +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Plugins { + socialsharing: SocialSharingPlugin.SocialSharing; +} + +declare module SocialSharingPlugin { + + export interface SocialSharing { + + /** + * Override this method (after deviceready) to set the location where you want the iPad popup arrow to appear. + * If not overridden with different values, the popup is not used. + */ + iPadPopupCoordinates: () => string; + + setIPadPopupCoordinates(coords: string): void; + + available(callback: (isAvailable: boolean) => void): void; + + share(message: string, subject?: string, fileOrFileArray?: string | string[], url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaTwitter(message: string, file?: string, url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaFacebook(message: string, fileOrFileArray?: string | string[], url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaFacebookWithPasteMessageHint(message: string, fileOrFileArray: string | string[], url: string, pasteMessageHint: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaWhatsApp(message: string, fileOrFileArray?: string | string[], url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaWhatsAppToReceiver(receiver: string, message: string, fileOrFileArray?: string | string[], url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaSMS(options: string | { message: string; subject: string; image: string; }, phonenumbers: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareViaEmail(message: string, subject: string, toArray?: string[], ccArray?: string[], bccArray?: string[], fileOrFileArray?: string | string[], successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + canShareVia(via: string, message: string, subject?: string, fileOrFileArray?: string | string[], url?: string, successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + canShareViaEmail(successCallback: (succeeded: boolean) => void, errorCallback: (errormsd: string) => void): void; + + shareViaInstagram(message: string, fileOrFileArray: string | string[], successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + shareVia(via: string, message: string, subject: string, fileOrFileArray: string | string[], url: string, successCallback: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + + saveToPhotoAlbum(fileOrFileArray: string | string[], successCallback?: (succeeded: boolean) => void, errorCallback?: (errormsg: string) => void): void; + } +} \ No newline at end of file From 196a892e6edb5218b0ff8697c721b6fb046d6d5a Mon Sep 17 00:00:00 2001 From: Dave Allen Date: Wed, 30 Mar 2016 11:45:35 -0700 Subject: [PATCH 0125/1850] Reverted module declarations back to namespace declarations. --- meteor/meteor-tests.ts | 2 +- meteor/meteor.d.ts | 74 ++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/meteor/meteor-tests.ts b/meteor/meteor-tests.ts index 044df149bf..bc877bdea0 100644 --- a/meteor/meteor-tests.ts +++ b/meteor/meteor-tests.ts @@ -644,7 +644,7 @@ var loginOpts: Meteor.LoginWithExternalServiceOptions = { profile: "asdfasdf", email: "asdf@ASDf.com" }; -Meteor.loginWithMeteorDeveloperAccount(loginOpts, function(error, result) {}); +Meteor.loginWithMeteorDeveloperAccount(loginOpts, function(error: Meteor.Error) {}); Accounts.emailTemplates.siteName = "AwesomeSite"; Accounts.emailTemplates.from = "AwesomeSite Admin "; diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts index fb0ff4819f..f7ac5828a3 100644 --- a/meteor/meteor.d.ts +++ b/meteor/meteor.d.ts @@ -2,6 +2,16 @@ // Project: http://www.meteor.com/ // Definitions by: Dave Allen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/** + * Meteor definitions for TypeScript + * author - Olivier Refalo - orefalo@yahoo.com + * author - David Allen - dave@fullflavedave.com + * + * Thanks to Sam Hatoum for the base code for auto-generating this file. + * + * supports Meteor 1.3 + */ + /** * These are the common (for client and server) modules and interfaces that can't be automatically generated from the Meteor data.js file @@ -15,7 +25,7 @@ interface JSONable { } interface EJSON extends EJSONable {} -declare module Match { +declare namespace Match { var Any: any; var String: any; var Integer: any; @@ -29,7 +39,7 @@ declare module Match { function Where(condition: any): any; } -declare module Meteor { +declare namespace Meteor { interface UserEmail { address:string; verified:boolean; @@ -57,7 +67,7 @@ declare module Meteor { } } -declare module DDP { +declare namespace DDP { interface DDPStatic { subscribe(name: string, ...rest: any[]): Meteor.SubscriptionHandle; call(method: string, ...parameters: any[]):void; @@ -79,7 +89,7 @@ declare module DDP { } } -declare module Mongo { +declare namespace Mongo { interface Selector { [key: string]:any; } @@ -91,7 +101,7 @@ declare module Mongo { } } -declare module HTTP { +declare namespace HTTP { interface HTTPRequest { content?:string; @@ -118,7 +128,7 @@ declare module HTTP { function put(url: string, callOptions?: HTTP.HTTPRequest, asyncCallback?: Function): HTTP.HTTPResponse; } -declare module Random { +declare namespace Random { function id(numberOfChars?: number): string; function secret(numberOfChars?: number): string; function fraction():number; @@ -127,7 +137,7 @@ declare module Random { function choice(str:string):string; // @param str, @return a random char in str } -declare module Accounts { +declare namespace Accounts { function loginServicesConfigured(): boolean; function onPageLoadLogin(func: Function): void; @@ -136,7 +146,7 @@ declare module Accounts { * These are the client modules and interfaces that can't be automatically generated from the Meteor data.js file */ -declare module Meteor { +declare namespace Meteor { /** Start definitions for Template **/ export interface Event { type:string; @@ -186,7 +196,7 @@ declare module Meteor { } } -declare module Blaze { +declare namespace Blaze { interface View { name: string; parentView: Blaze.View; @@ -210,7 +220,7 @@ declare module Blaze { } } -declare module BrowserPolicy { +declare namespace BrowserPolicy { interface framing { disallow():void; @@ -251,7 +261,7 @@ declare module BrowserPolicy { * These are the server modules and interfaces that can't be automatically generated from the Meteor data.js file */ -declare module Meteor { +declare namespace Meteor { interface EmailFields { from?: () => string; subject?: (user: Meteor.User) => string; @@ -287,7 +297,7 @@ declare module Meteor { } } -declare module Mongo { +declare namespace Mongo { interface AllowDenyOptions { insert?: (userId: string, doc: any) => boolean; update?: (userId: string, doc: any, fieldNames: string[], modifier: any) => boolean; @@ -297,7 +307,7 @@ declare module Mongo { } } -declare module Accounts { +declare namespace Accounts { interface IValidateLoginAttemptCbOpts { type?: string; allowed?: boolean; @@ -362,20 +372,20 @@ interface ITinytestAssertions { _stringEqual(actual: string, expected: string, msg?: string): void; } -declare module Tinytest { +declare namespace Tinytest { function add(description : string , func : (test : ITinytestAssertions) => void) : void; function addAsync(description : string , func : (test : ITinytestAssertions) => void) : void; } // Kept in for backwards compatibility -declare module Meteor { +declare namespace Meteor { interface Tinytest { add(description : string , func : (test : ITinytestAssertions) => void) : void; addAsync(description : string , func : (test : ITinytestAssertions) => void) : void; } } -declare module Accounts { +declare namespace Accounts { function addEmail(userId: string, newEmail: string, verified?: boolean): void; function changePassword(oldPassword: string, newPassword: string, callback?: Function): void; function createUser(options: { @@ -430,7 +440,7 @@ declare module Accounts { function validateNewUser(func: Function): boolean; } -declare module App { +declare namespace App { function accessRule(pattern: string, options?: { type?: string; launchExternal?: boolean; @@ -450,12 +460,12 @@ declare module App { function setPreference(name: string, value: string, platform?: string): void; } -declare module Assets { +declare namespace Assets { function getBinary(assetPath: string, asyncCallback?: Function): EJSON; function getText(assetPath: string, asyncCallback?: Function): string; } -declare module Blaze { +declare namespace Blaze { function Each(argFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; function If(conditionFunc: Function, contentFunc: Function, elseFunc?: Function): Blaze.View; function Let(bindings: Function, contentFunc: Function): Blaze.View; @@ -509,20 +519,20 @@ declare module Blaze { function toHTMLWithData(templateOrView: Template | Blaze.View, data: Object | Function): string; } -declare module Cordova { +declare namespace Cordova { function depends(dependencies:{[id:string]:string}): void; } -declare module DDP { +declare namespace DDP { function connect(url: string): DDP.DDPStatic; } -declare module DDPCommon { +declare namespace DDPCommon { function MethodInvocation(options: { }): any; } -declare module EJSON { +declare namespace EJSON { var CustomType: CustomTypeStatic; interface CustomTypeStatic { new(): CustomType; @@ -550,11 +560,11 @@ declare module EJSON { function toJSONValue(val: EJSON): JSONable; } -declare module Match { +declare namespace Match { function test(value: any, pattern: any): boolean; } -declare module Meteor { +declare namespace Meteor { var Error: ErrorStatic; interface ErrorStatic { new(error: string | number, reason?: string, details?: string): Error; @@ -611,7 +621,7 @@ declare module Meteor { function wrapAsync(func: Function, context?: Object): any; } -declare module Mongo { +declare namespace Mongo { var Collection: CollectionStatic; interface CollectionStatic { new(name: string, options?: { @@ -689,12 +699,12 @@ declare module Mongo { } -declare module Npm { +declare namespace Npm { function depends(dependencies:{[id:string]:string}): void; function require(name: string): any; } -declare module Package { +declare namespace Package { function describe(options: { summary?: string; version?: string; @@ -715,7 +725,7 @@ declare module Package { }): void; } -declare module Tracker { +declare namespace Tracker { function Computation(): void; interface Computation { firstRun: boolean; @@ -748,14 +758,14 @@ declare module Tracker { function onInvalidate(callback: Function): void; } -declare module Session { +declare namespace Session { function equals(key: string, value: string | number | boolean | any /** Null **/ | any /** Undefined **/): boolean; function get(key: string): any; function set(key: string, value: EJSONable | any /** Undefined **/): void; function setDefault(key: string, value: EJSONable | any /** Undefined **/): void; } -declare module HTTP { +declare namespace HTTP { function call(method: string, url: string, options?: { content?: string; data?: Object; @@ -775,7 +785,7 @@ declare module HTTP { function put(url: string, callOptions?: Object, asyncCallback?: Function): HTTP.HTTPResponse; } -declare module Email { +declare namespace Email { function send(options: { from?: string; to?: string | string[]; From 402a133aabff8d763589770594ddcdebf2b63cc5 Mon Sep 17 00:00:00 2001 From: Dave Allen Date: Wed, 30 Mar 2016 11:51:32 -0700 Subject: [PATCH 0126/1850] Fixed header --- meteor/meteor.d.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts index f7ac5828a3..fc89e8b4a4 100644 --- a/meteor/meteor.d.ts +++ b/meteor/meteor.d.ts @@ -2,16 +2,6 @@ // Project: http://www.meteor.com/ // Definitions by: Dave Allen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** - * Meteor definitions for TypeScript - * author - Olivier Refalo - orefalo@yahoo.com - * author - David Allen - dave@fullflavedave.com - * - * Thanks to Sam Hatoum for the base code for auto-generating this file. - * - * supports Meteor 1.3 - */ - /** * These are the common (for client and server) modules and interfaces that can't be automatically generated from the Meteor data.js file From a44332a250f703db51a79b2befd635ca9f38b15c Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Wed, 30 Mar 2016 20:47:41 -0700 Subject: [PATCH 0127/1850] Added ensureDirSync --- fs-extra-promise/fs-extra-promise.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs-extra-promise/fs-extra-promise.d.ts b/fs-extra-promise/fs-extra-promise.d.ts index 77de929345..2243a4d1c5 100644 --- a/fs-extra-promise/fs-extra-promise.d.ts +++ b/fs-extra-promise/fs-extra-promise.d.ts @@ -166,7 +166,8 @@ declare module "fs-extra-promise" { export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; export function exists(path: string, callback?: (exists: boolean) => void): void; export function existsSync(path: string): boolean; - export function ensureDir(path: string, cb: (err: Error) => void): void; + export function ensureDir(path: string, cb: (err: Error) => void): void; + export function ensureDirSync(path: string): void; export interface OpenOptions { encoding?: string; From 34b5b27cda503628e0016abe9573d3c0ce73f4d7 Mon Sep 17 00:00:00 2001 From: Alex Pyzhianov Date: Thu, 31 Mar 2016 12:45:11 +0300 Subject: [PATCH 0128/1850] Fix dispatchEvent parameter Fix dispatchEvent not alowing to add additional properties to event object (as shown in usage example) https://github.com/mrdoob/eventdispatcher.js --- threejs/three.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index abfa5feb25..be2e3c2e5c 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -756,7 +756,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; addIndex(index: any): void; // deprecated, use setIndex() addAttribute(name: any, array: any, itemSize: any): any; // deprecated @@ -863,7 +863,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } @@ -925,7 +925,7 @@ declare namespace THREE { * Fire an event type. * @param type The type of event that gets fired. */ - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } export interface Event { @@ -1243,7 +1243,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } export namespace GeometryUtils { // deprecated @@ -1619,7 +1619,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; getChildByName(name: string): Object3D; // deprecated, use getObjectByName() } @@ -2260,7 +2260,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } export interface LineBasicMaterialParameters extends MaterialParameters { @@ -4950,7 +4950,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } export class WebGLRenderTargetCube extends WebGLRenderTarget { @@ -5443,7 +5443,7 @@ declare namespace THREE { addEventListener(type: string, listener: (event: Event) => void ): void; hasEventListener(type: string, listener: (event: Event) => void): void; removeEventListener(type: string, listener: (event: Event) => void): void; - dispatchEvent(event: { type: string; }): void; + dispatchEvent(event: { type: string; [attachment: string]: any; }): void; } export class CanvasTexture extends Texture { From 8cdbc77ff354d32f41ed0582095cbefb3b70086b Mon Sep 17 00:00:00 2001 From: Stefan Profanter Date: Thu, 31 Mar 2016 17:02:48 +0200 Subject: [PATCH 0129/1850] added missing member --- threejs/three-orthographictrackballcontrols.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/threejs/three-orthographictrackballcontrols.d.ts b/threejs/three-orthographictrackballcontrols.d.ts index ff40a132a0..259b51e7cc 100644 --- a/threejs/three-orthographictrackballcontrols.d.ts +++ b/threejs/three-orthographictrackballcontrols.d.ts @@ -27,6 +27,8 @@ declare module THREE { dynamicDampingFactor:number; keys:number[]; + target: THREE.Vector3; + position0: THREE.Vector3; target0: THREE.Vector3; up0: THREE.Vector3; From 92356221c80151eb6ff87aacf1f8999f782448a1 Mon Sep 17 00:00:00 2001 From: springbov Date: Thu, 31 Mar 2016 11:32:49 -0600 Subject: [PATCH 0130/1850] Added missing typedefs to bingmaps --- bingmaps/Microsoft.Maps.d.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/bingmaps/Microsoft.Maps.d.ts b/bingmaps/Microsoft.Maps.d.ts index 48edfcc2c4..c558c7a64b 100644 --- a/bingmaps/Microsoft.Maps.d.ts +++ b/bingmaps/Microsoft.Maps.d.ts @@ -505,10 +505,21 @@ declare namespace Microsoft.Maps { export interface PositionOptionsErrorCallbackResult { internalError: PositionError; errorCode:number; -} + } + + export interface PositionOptionsSuccessCallbackResult { + center: Location; + position: Position; + } + export interface PositionOptions { enableHighAccuracy?: boolean; - errorCallback?:(result:PositionOptionsErrorCallbackResult)=>void; + errorCallback?: (result: PositionOptionsErrorCallbackResult) => void; + showAccuracyCircle?: boolean; + timeout?: number; + updateMapView?: boolean; + maximumAge?: number; + successCallback?: (result: PositionOptionsSuccessCallbackResult) => void; } export interface PositionCircleOptions { From 6694581d3ed54e9009b2b95f555e6b61f0e0a897 Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Thu, 31 Mar 2016 10:39:04 -0700 Subject: [PATCH 0131/1850] react-redux: remove React.Props references because it is deprecated. --- react-redux/react-redux.d.ts | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts index 89d33cf6db..ec1bded479 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -7,10 +7,10 @@ /// declare module "react-redux" { - import { ComponentClass, Component, StatelessComponent, Props, ReactNode } from 'react'; + import { ComponentClass, Component, StatelessComponent, ReactNode } from 'react'; import { Store, Dispatch, ActionCreator } from 'redux'; - interface ComponentDecorator, TOwnProps extends Props> { + interface ComponentDecorator { (component: ComponentClass): ComponentClass; } @@ -43,19 +43,13 @@ declare module "react-redux" { * @param options */ export function connect(): InferableComponentDecorator; - export function connect< - TStateProps extends Props, - TDispatchProps extends Props, - TOwnProps extends Props - >( + + export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps?: MapDispatchToPropsFunction|MapDispatchToPropsObject ): ComponentDecorator; - export function connect< - TStateProps extends Props, - TDispatchProps extends Props, - TOwnProps extends Props - >( + + export function connect( mapStateToProps: MapStateToProps, mapDispatchToProps: MapDispatchToPropsFunction|MapDispatchToPropsObject, mergeProps: MergeProps, @@ -89,7 +83,7 @@ declare module "react-redux" { pure: boolean; } - export interface ProviderProps extends Props { + export interface ProviderProps { /** * The single Redux store in your application. */ From d84301a90466d9f57f77012209c6e9a5ef678fd9 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Thu, 31 Mar 2016 10:56:28 -0700 Subject: [PATCH 0132/1850] Create index.d.ts --- resolve-from/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 resolve-from/index.d.ts diff --git a/resolve-from/index.d.ts b/resolve-from/index.d.ts new file mode 100644 index 0000000000..a760d6ddd5 --- /dev/null +++ b/resolve-from/index.d.ts @@ -0,0 +1,5 @@ +declare function resolveFrom(fromDir: string, moduleId: string): string; + +declare module "resolve-from" { + export = resolveFrom; +} From 9ded06a23374dea70089ab4535a05b383f1595ab Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Thu, 31 Mar 2016 10:59:22 -0700 Subject: [PATCH 0133/1850] Update index.d.ts --- resolve-from/index.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/resolve-from/index.d.ts b/resolve-from/index.d.ts index a760d6ddd5..a8d0441136 100644 --- a/resolve-from/index.d.ts +++ b/resolve-from/index.d.ts @@ -1,3 +1,7 @@ +// Type definitions for resolve-from +// Project: https://github.com/sindresorhus/resolve-from +// Definitions by: unional +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare function resolveFrom(fromDir: string, moduleId: string): string; declare module "resolve-from" { From da656da2633630e81f506aa8d28a4f6359e5c18e Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Thu, 31 Mar 2016 10:59:47 -0700 Subject: [PATCH 0134/1850] Add a test for the issue discussed in #8787. --- react-redux/react-redux-tests.tsx | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 2ffb30169e..22fb59a968 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -284,3 +284,47 @@ function HelloMessage(props: HelloMessageProps) { let ConnectedHelloMessage = connect()(HelloMessage); ReactDOM.render(, document.getElementById('content')); ReactDOM.render(, document.getElementById('content')); + +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/8787 +namespace TestTOwnPropsInference { + interface OwnProps { + own: string; + } + + interface StateProps { + state: string; + } + + class OwnPropsComponent extends React.Component { + render() { + return null; + } + } + + function mapStateToPropsWithoutOwnProps(state: any): StateProps { + return { state: 'string' }; + } + + function mapStateToPropsWithOwnProps(state: any, ownProps: OwnProps): StateProps { + return { state: 'string' }; + } + + const ConnectedWithoutOwnProps = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); + const ConnectedWithOwnProps = connect(mapStateToPropsWithOwnProps)(OwnPropsComponent); + const ConnectedWithTypeHint = connect(mapStateToPropsWithoutOwnProps)(OwnPropsComponent); + + // This compiles, which is bad. + React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' }); + + // This compiles, as expected. + React.createElement(ConnectedWithOwnProps, { own: 'string' }); + + // This should not compile, which is good. + // React.createElement(ConnectedWithOwnProps, { missingOwn: true }); + + // This compiles, as expected. + React.createElement(ConnectedWithTypeHint, { own: 'string' }); + + // This should not compile, which is good. + // React.createElement(ConnectedWithTypeHint, { missingOwn: true }); +} From 231f8eadc168da7e698e360a7199c29a9335a8f1 Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Thu, 31 Mar 2016 11:01:07 -0700 Subject: [PATCH 0135/1850] react-redux: add myself as maintainer cause I've been noodling this stuff a lot --- react-redux/react-redux.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts index ec1bded479..0e7810e352 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-redux 4.4.0 // Project: https://github.com/rackt/react-redux -// Definitions by: Qubo +// Definitions by: Qubo , Sean Kelley // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 445892fe0ab24c55f31e52d1bcad545a126c48e2 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Thu, 31 Mar 2016 11:03:12 -0700 Subject: [PATCH 0136/1850] Create index-test.ts --- resolve-from/index-test.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 resolve-from/index-test.ts diff --git a/resolve-from/index-test.ts b/resolve-from/index-test.ts new file mode 100644 index 0000000000..6333f14503 --- /dev/null +++ b/resolve-from/index-test.ts @@ -0,0 +1,5 @@ +// Much better testing in https://github.com/typed-typings/typed-resolve-from + +import resolveFrom = require('resolve-from'); + +console.log(typeof resolveFrom === 'function'); From 9468e5badc628b6b806198b19a760aa1df29ec18 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Thu, 31 Mar 2016 11:04:48 -0700 Subject: [PATCH 0137/1850] Rename index-test.ts to index-tests.ts --- resolve-from/{index-test.ts => index-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resolve-from/{index-test.ts => index-tests.ts} (100%) diff --git a/resolve-from/index-test.ts b/resolve-from/index-tests.ts similarity index 100% rename from resolve-from/index-test.ts rename to resolve-from/index-tests.ts From 8a7d208e0dcb37d4f62588eeef2cd71b5b8bff98 Mon Sep 17 00:00:00 2001 From: Sean Kelley Date: Thu, 31 Mar 2016 11:06:38 -0700 Subject: [PATCH 0138/1850] react-redux: Fix compilation error for dumb reason. --- react-redux/react-redux-tests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 22fb59a968..4158a035ed 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -297,7 +297,7 @@ namespace TestTOwnPropsInference { class OwnPropsComponent extends React.Component { render() { - return null; + return
; } } From 37ade3080e6305ee5e329230044ea0167a937e34 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Thu, 31 Mar 2016 11:15:48 -0700 Subject: [PATCH 0139/1850] Update index-tests.ts --- resolve-from/index-tests.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/resolve-from/index-tests.ts b/resolve-from/index-tests.ts index 6333f14503..a1f5480ffc 100644 --- a/resolve-from/index-tests.ts +++ b/resolve-from/index-tests.ts @@ -1,5 +1,6 @@ +/// + // Much better testing in https://github.com/typed-typings/typed-resolve-from - -import resolveFrom = require('resolve-from'); - -console.log(typeof resolveFrom === 'function'); +if (typeof resolveFrom !== 'function') { + throw new Error('resolveFrom is not a function'); +} From 988dbadb806743fc3ce6bb4d1eeca50bf0adb0bf Mon Sep 17 00:00:00 2001 From: Xavier Stouder Date: Thu, 31 Mar 2016 22:09:31 +0200 Subject: [PATCH 0140/1850] Update express-session.d.ts These functions still exist on the documentation and in the code. --- express-session/express-session.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/express-session/express-session.d.ts b/express-session/express-session.d.ts index 5b9ec634ae..156e9404fc 100644 --- a/express-session/express-session.d.ts +++ b/express-session/express-session.d.ts @@ -69,6 +69,13 @@ declare module "express-session" { regenerate (req: express.Request, fn: (err: any) => any): void; load (sid: string, fn: (err: any, session: Express.Session) => any): void; createSession (req: express.Request, sess: Express.Session): void; + + get: (sid: string, callback: (err: any, session: Express.Session) => void) => void; + set: (sid: string, session: Express.Session, callback: (err: any) => void) => void; + destroy: (sid: string, callback: (err: any) => void) => void; + all: (callback: (err: any, obj: { [sid: string]: Express.Session; }) => void) => void; + length: (callback: (err: any, length: number) => void) => void; + clear: (callback: (err: any) => void) => void; } export class MemoryStore implements BaseMemoryStore { From 25a7d33576c46a2a44a765f181024b073cc76262 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 31 Mar 2016 22:30:33 +0200 Subject: [PATCH 0141/1850] Initial Commit --- socket.io-redis/socket.io-redis-tests.ts | 1 + socket.io-redis/socket.io-redis.d.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 socket.io-redis/socket.io-redis-tests.ts create mode 100644 socket.io-redis/socket.io-redis.d.ts diff --git a/socket.io-redis/socket.io-redis-tests.ts b/socket.io-redis/socket.io-redis-tests.ts new file mode 100644 index 0000000000..a417be85f9 --- /dev/null +++ b/socket.io-redis/socket.io-redis-tests.ts @@ -0,0 +1 @@ +/// diff --git a/socket.io-redis/socket.io-redis.d.ts b/socket.io-redis/socket.io-redis.d.ts new file mode 100644 index 0000000000..38c12b305d --- /dev/null +++ b/socket.io-redis/socket.io-redis.d.ts @@ -0,0 +1,14 @@ +// Type definitions for socket.io-redis 1. +// Project: http://socket.io/ +// Definitions by: PROGRE , Damian Connolly , Florent Poujol +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var io: SocketIORedisStatic; + +declare module 'socket.io-redis' { + export = io; +} + +interface SocketIORedisStatic { + +} From abbb918134829d7fe3c2d012aa6f058f8a1e32da Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 31 Mar 2016 23:23:49 +0200 Subject: [PATCH 0142/1850] socket.io-redis - Interfaces ready - still tests to do --- socket.io-redis/socket.io-redis-tests.ts | 35 ++++++++ socket.io-redis/socket.io-redis.d.ts | 107 ++++++++++++++++++++++- 2 files changed, 138 insertions(+), 4 deletions(-) diff --git a/socket.io-redis/socket.io-redis-tests.ts b/socket.io-redis/socket.io-redis-tests.ts index a417be85f9..0ab6974c7a 100644 --- a/socket.io-redis/socket.io-redis-tests.ts +++ b/socket.io-redis/socket.io-redis-tests.ts @@ -1 +1,36 @@ +/// +/// /// + +import socketIO = require('socket.io'); +import ioRedis = require('socket.io-redis'); + +function testUsingWithNodeHTTPServer() { + var io = socketIO(3000); + var adapter = ioRedis({ host: 'localhost', port: 6379 }); + io.adapter(adapter); +} + +function testRestrictingYourselfToANamespace() { + var io = socketIO.listen(80); + var adapter = ioRedis({ host: 'localhost', port: 6379 }); + io.adapter(adapter); + var chat = io + .of('/chat') + .on('connection', function (socket) { + socket.emit('a message', { + that: 'only' + , '/chat': 'will get' + }); + chat.emit('a message', { + everyone: 'in' + , '/chat': 'will get' + }); + }); + + var news = io + .of('/news') + .on('connection', function (socket) { + socket.emit('item', { news: 'item' }); + }); +} diff --git a/socket.io-redis/socket.io-redis.d.ts b/socket.io-redis/socket.io-redis.d.ts index 38c12b305d..fd5713853d 100644 --- a/socket.io-redis/socket.io-redis.d.ts +++ b/socket.io-redis/socket.io-redis.d.ts @@ -1,14 +1,113 @@ // Type definitions for socket.io-redis 1. -// Project: http://socket.io/ -// Definitions by: PROGRE , Damian Connolly , Florent Poujol +// Project: https://github.com/socketio/socket.io-redis +// Definitions by: Philipp Holzer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare var io: SocketIORedisStatic; +/// +/// + +import { RedisClient } from "redis"; declare module 'socket.io-redis' { + var io: SocketIORedisStatic; + export = io; } interface SocketIORedisStatic { - + /** + * Creates a new Redis Adapter + * @param uri Is a string like localhost:6379 where your redis server is located. + * @param opts An optional parameters object + */ + (uri: string, opts?: SocketIORedis.SocketIORedisOptions): SocketIORedis.RedisAdapter; + + /** + * Creates a new Redis Adapter + * @param opts A parameters object + */ + (opts: SocketIORedis.SocketIORedisOptions): SocketIORedis.RedisAdapter; +} + +declare namespace SocketIORedis { + /** + * Options to pass to the redis server when creating it + */ + interface SocketIORedisOptions { + + /** + * The optional name of the key to pub/sub events on as prefix + * @default socket.io + */ + key?: string; + + /** + * The optional host to connect to redis on + * @default localhost + */ + host?: string; + + /** + * The optional port to connect to redis on + * @default 6379 + */ + port?: string; + + /** + * The optional redis client to publish events on + */ + pubClient?: RedisClient; + + /** + * The optional redis client to subscribe to events on + */ + subClient?: RedisClient; + } + + interface RedisAdapter extends SocketIO.Adapter { + + /** + * This servers key + */ + uid: string; + + /** + * The prefix of pub/sub events + */ + prefix: string; + + /** + * Optional, the redis client to publish events on + */ + pubClient?: RedisClient; + + /** + * Optional, the redis client to subscribe to events on + */ + subClient?: RedisClient; + + /** + * Broadcasts a packet + * @param packet The packet to broadcast + * @param opts Any options to send along: + * - rooms: An optional list of rooms to broadcast to. If empty, the packet is broadcast to all sockets + * - except: A list of Socket IDs to exclude + * - flags: Any flags that we want to send along ('json', 'volatile', 'broadcast') + * @param remote The optional flag, whether the packet came from another node + */ + broadcast: { + (packet: any, opts: { rooms?: string[]; except?: string[]; flags?: {[flag: string]: boolean} }): void; + (packet: any, opts: { rooms?: string[]; except?: string[]; flags?: {[flag: string]: boolean} }, remote?: boolean): void; + }; + + /** + * Removes a socket from all the rooms that it's joined + * @param id The ID of the socket that we're removing + * @param callback An optional callback to call when the socket has been + */ + delAll: { + ( id: string ): void; + ( id: string, callback?: ( err?: any ) => void ): void; + }; + } } From 73ad2ba6f16a2f175d6031b6d82e5a19d84a4f35 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 31 Mar 2016 23:29:00 +0200 Subject: [PATCH 0143/1850] - some fixes --- socket.io-redis/socket.io-redis.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socket.io-redis/socket.io-redis.d.ts b/socket.io-redis/socket.io-redis.d.ts index fd5713853d..f40647624b 100644 --- a/socket.io-redis/socket.io-redis.d.ts +++ b/socket.io-redis/socket.io-redis.d.ts @@ -1,4 +1,4 @@ -// Type definitions for socket.io-redis 1. +// Type definitions for socket.io-redis 1.0.0 // Project: https://github.com/socketio/socket.io-redis // Definitions by: Philipp Holzer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -6,7 +6,7 @@ /// /// -import { RedisClient } from "redis"; +import { RedisClient } from 'redis'; declare module 'socket.io-redis' { var io: SocketIORedisStatic; From 326b6bbed4b58e217015a0820fe0cee4e554c948 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Thu, 31 Mar 2016 23:33:45 +0200 Subject: [PATCH 0144/1850] - ReferencePath to socket.io --- socket.io-redis/socket.io-redis.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/socket.io-redis/socket.io-redis.d.ts b/socket.io-redis/socket.io-redis.d.ts index f40647624b..658ea25999 100644 --- a/socket.io-redis/socket.io-redis.d.ts +++ b/socket.io-redis/socket.io-redis.d.ts @@ -5,8 +5,7 @@ /// /// - -import { RedisClient } from 'redis'; +/// declare module 'socket.io-redis' { var io: SocketIORedisStatic; @@ -14,6 +13,8 @@ declare module 'socket.io-redis' { export = io; } +import { RedisClient } from 'redis'; + interface SocketIORedisStatic { /** * Creates a new Redis Adapter From ffaaf5d5d5b8a0c79e00c173b1168757a8442b34 Mon Sep 17 00:00:00 2001 From: Troy McKinnon Date: Thu, 31 Mar 2016 19:45:21 -0500 Subject: [PATCH 0145/1850] allow importing raphael as a module --- raphael/raphael.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/raphael/raphael.d.ts b/raphael/raphael.d.ts index 54cdc35146..fe5778ff46 100644 --- a/raphael/raphael.d.ts +++ b/raphael/raphael.d.ts @@ -294,3 +294,6 @@ interface RaphaelStatic { } declare var Raphael: RaphaelStatic; +declare module "raphael" { + export = Raphael; +} From f712b237abbcb0cb6ff6861cb23fdadd77856415 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Fri, 1 Apr 2016 06:54:12 +0200 Subject: [PATCH 0146/1850] Pull Request ready (no errors) --- socket.io-redis/socket.io-redis-tests.ts | 34 +++++++++++++++--------- socket.io-redis/socket.io-redis.d.ts | 34 ++++++++++++++---------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/socket.io-redis/socket.io-redis-tests.ts b/socket.io-redis/socket.io-redis-tests.ts index 0ab6974c7a..2ce2be1bd6 100644 --- a/socket.io-redis/socket.io-redis-tests.ts +++ b/socket.io-redis/socket.io-redis-tests.ts @@ -1,20 +1,16 @@ -/// /// +/// /// import socketIO = require('socket.io'); import ioRedis = require('socket.io-redis'); +import redis = require('redis'); function testUsingWithNodeHTTPServer() { var io = socketIO(3000); - var adapter = ioRedis({ host: 'localhost', port: 6379 }); + var adapter = ioRedis("http://localhost"); io.adapter(adapter); -} -function testRestrictingYourselfToANamespace() { - var io = socketIO.listen(80); - var adapter = ioRedis({ host: 'localhost', port: 6379 }); - io.adapter(adapter); var chat = io .of('/chat') .on('connection', function (socket) { @@ -27,10 +23,24 @@ function testRestrictingYourselfToANamespace() { , '/chat': 'will get' }); }); +} - var news = io - .of('/news') - .on('connection', function (socket) { - socket.emit('item', { news: 'item' }); - }); +function testErrorHandling() { + var io = socketIO.listen(80); + var adapter = ioRedis("http://localhost"); + adapter.pubClient.on('error', function () { + console.log('pubClient error'); + }); + adapter.subClient.on('error', function() { + console.log('subClient error'); + }); + io.adapter(adapter); +} + +function testCustomClientAuth() { + var io = socketIO.listen(80); + var pub: redis.RedisClient = redis.createClient(8080, 'localhost', { auth_pass: 'pwd' }); + var sub: redis.RedisClient = redis.createClient(8081, 'localhost', { return_buffers: true, auth_pass: 'pwd' }); + var adapter = ioRedis({ pubClient: pub, subClient: sub }); + io.adapter(adapter); } diff --git a/socket.io-redis/socket.io-redis.d.ts b/socket.io-redis/socket.io-redis.d.ts index 658ea25999..b3eb44e5ec 100644 --- a/socket.io-redis/socket.io-redis.d.ts +++ b/socket.io-redis/socket.io-redis.d.ts @@ -3,19 +3,21 @@ // Definitions by: Philipp Holzer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// /// declare module 'socket.io-redis' { - var io: SocketIORedisStatic; + var redis: SocketIORedisStatic; - export = io; + export = redis; } -import { RedisClient } from 'redis'; - interface SocketIORedisStatic { + /** + * Default Redis Adapter constructor + */ + (): SocketIORedis.RedisAdapter; + /** * Creates a new Redis Adapter * @param uri Is a string like localhost:6379 where your redis server is located. @@ -30,6 +32,10 @@ interface SocketIORedisStatic { (opts: SocketIORedis.SocketIORedisOptions): SocketIORedis.RedisAdapter; } +/** + * TODO: return Value for pubClient and subClient is RedisClient, but the im port throws errors because of "invalid module name in augmenatition" + * + */ declare namespace SocketIORedis { /** * Options to pass to the redis server when creating it @@ -57,12 +63,12 @@ declare namespace SocketIORedis { /** * The optional redis client to publish events on */ - pubClient?: RedisClient; + pubClient?: any; /** * The optional redis client to subscribe to events on */ - subClient?: RedisClient; + subClient?: any; } interface RedisAdapter extends SocketIO.Adapter { @@ -80,20 +86,20 @@ declare namespace SocketIORedis { /** * Optional, the redis client to publish events on */ - pubClient?: RedisClient; + pubClient?: any; /** * Optional, the redis client to subscribe to events on */ - subClient?: RedisClient; + subClient?: any; /** * Broadcasts a packet * @param packet The packet to broadcast * @param opts Any options to send along: - * - rooms: An optional list of rooms to broadcast to. If empty, the packet is broadcast to all sockets - * - except: A list of Socket IDs to exclude - * - flags: Any flags that we want to send along ('json', 'volatile', 'broadcast') + * - rooms: An optional list of rooms to broadcast to. If empty, the packet is broadcast to all sockets + * - except: A list of Socket IDs to exclude + * - flags: Any flags that we want to send along ('json', 'volatile', 'broadcast') * @param remote The optional flag, whether the packet came from another node */ broadcast: { @@ -107,8 +113,8 @@ declare namespace SocketIORedis { * @param callback An optional callback to call when the socket has been */ delAll: { - ( id: string ): void; - ( id: string, callback?: ( err?: any ) => void ): void; + (id: string): void; + (id: string, callback?: (err?: any) => void): void; }; } } From 3b2eb4d8fb435bea1f0a172e1923db0ad2fc5ac9 Mon Sep 17 00:00:00 2001 From: Noctis Hsu Date: Fri, 1 Apr 2016 13:01:08 +0800 Subject: [PATCH 0147/1850] Add Facebook pixel tag api definitely typed --- facebook-pixel/facebook-pixel-tests.ts | 41 +++++++++ facebook-pixel/facebook-pixel.d.ts | 123 +++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 facebook-pixel/facebook-pixel-tests.ts create mode 100644 facebook-pixel/facebook-pixel.d.ts diff --git a/facebook-pixel/facebook-pixel-tests.ts b/facebook-pixel/facebook-pixel-tests.ts new file mode 100644 index 0000000000..d4de318e78 --- /dev/null +++ b/facebook-pixel/facebook-pixel-tests.ts @@ -0,0 +1,41 @@ +/// + +fbq('init', ''); +fbq('track', 'PageView'); + +// Standard event (can be used for conversion tracking +// and optimizing in addition to audience building) +var purchaseParam:facebook.Pixel.PurchaseParameters = {currency: 'EUR', value: 15.23}; +purchaseParam["Test"] = 44; // add custom parameter +fbq('track', 'Purchase', purchaseParam); + +// Legacy conversion event (can only be used for conversion +// tracking and optimizing) + +// Custom event (can only be used for audience building) + +var custom_params:any = {custom_param: 'custom_value'}; +fbq('trackCustom', 'MyCustomEvent', custom_params); + +// Reach customers that viewed a product in the 'Shoes' category +// with a price greater than $100 +fbq('track', 'ViewContent', { + content_name: 'Really Fast Running Shoes', + content_category: 'Apparel & Accessories > Shoes', + content_ids: ['1234'], + content_type: 'product', + value: 0.50, + currency: 'USD' +}); + +// Multiple events can also be added to each page. Ex: Reach visitors +// based on information about them and how they got to the page +// that Registered in the last n days +fbq('track', 'ViewContent', { + content_name: 'The Avengers Trailer', + content_category: 'Entertainment', + value: 1.50, + currency: 'USD', +}); + +fbq('track', 'CompleteRegistration', {currency: 'USD', value: 0.75}); diff --git a/facebook-pixel/facebook-pixel.d.ts b/facebook-pixel/facebook-pixel.d.ts new file mode 100644 index 0000000000..d5c9b88a41 --- /dev/null +++ b/facebook-pixel/facebook-pixel.d.ts @@ -0,0 +1,123 @@ +// Type definitions for the Facebook Pixel Tag API +// Project: https://developers.facebook.com/docs/ads-for-websites/tag-api/ +// Definitions by: Noctis Hsu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare var fbq:facebook.Pixel.Event; + + +declare module facebook.Pixel { + interface Event { + (eventType:string, InitialAppId:string):void; + (eventType:string, eventName:string):void; + (eventType:string, eventName:string, parameters:facebook.Pixel.ViewContentParameters):void; + (eventType:string, eventName:string, parameters:ViewContentParameters):void; + (eventType:string, eventName:string, parameters:SearchParameters):void; + (eventType:string, eventName:string, parameters:AddToCartParameters):void; + (eventType:string, eventName:string, parameters:AddToWishlistParameters):void; + (eventType:string, eventName:string, parameters:InitiateCheckoutParameters):void; + (eventType:string, eventName:string, parameters:AddPaymentInfoParameters):void; + (eventType:string, eventName:string, parameters:PurchaseParameters):void; + (eventType:string, eventName:string, parameters:LeadParameters):void; + (eventType:string, eventName:string, parameters:CompleteRegistrationParameters):void; + + (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.AddToCartParameters):void; + (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.PurchaseParameters):void; + (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.ViewContentParameters):void; + + // custom event + //(eventType:string, eventName:string, parameters:any):void; + } + + + interface ViewContentParameters { + value?:number; + currency?:string; + content_name?:string; + content_type?:string; + content_ids?:string[]; + content_category?:string; + } + + interface SearchParameters { + value?:number; + currency?:string; + content_category?:string; + content_ids?:string[]; + search_string?:string; + } + + interface AddToCartParameters { + value?:number; + currency?:string; + content_name?:string; + content_type?:string; + content_ids?:string[]; + } + + interface AddToWishlistParameters { + value?:number; + currency?:string; + content_name?:string; + content_category?:string; + content_ids?:string[]; + } + + interface InitiateCheckoutParameters { + value?:number; + currency?:string; + content_name?:string; + content_category?:string; + content_ids?:string[]; + num_items?:number; + } + + interface AddPaymentInfoParameters { + value?:number; + currency?:string; + content_category?:string; + content_ids?:string[]; + } + + interface PurchaseParameters { + value:number; + currency:string; + content_name?:string; + content_type?:string; + content_ids?:string[]; + num_items?:number; + order_id?:string; + } + + interface LeadParameters { + value?:number; + currency?:string; + content_name?:string; + content_category?:string; + } + + interface CompleteRegistrationParameters { + value?:number; + currency?:string; + content_name?:string; + status?:string; + } +} + +// For Facebook Tag API using Dynamic Product Ads +declare module facebook.Pixel.DPA { + + interface ViewContentParameters extends facebook.Pixel.ViewContentParameters { + content_type:string; + content_ids:string[]; + } + + interface AddToCartParameters extends facebook.Pixel.AddToCartParameters { + content_type:string; + content_ids:string[]; + } + + interface PurchaseParameters extends facebook.Pixel.PurchaseParameters { + content_type:string; + content_ids:string[]; + } +} From aec655aedee5dcf5fbaa0ce4f2f11b75c52b1378 Mon Sep 17 00:00:00 2001 From: Noctis Hsu Date: Fri, 1 Apr 2016 14:26:07 +0800 Subject: [PATCH 0148/1850] Fix reference path --- facebook-pixel/facebook-pixel-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facebook-pixel/facebook-pixel-tests.ts b/facebook-pixel/facebook-pixel-tests.ts index d4de318e78..e29190d232 100644 --- a/facebook-pixel/facebook-pixel-tests.ts +++ b/facebook-pixel/facebook-pixel-tests.ts @@ -1,4 +1,4 @@ -/// +/// fbq('init', ''); fbq('track', 'PageView'); From 5701e952cb716715755108c694703d94314b74ca Mon Sep 17 00:00:00 2001 From: Noctis Hsu Date: Fri, 1 Apr 2016 14:28:42 +0800 Subject: [PATCH 0149/1850] remove unused code --- facebook-pixel/facebook-pixel.d.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/facebook-pixel/facebook-pixel.d.ts b/facebook-pixel/facebook-pixel.d.ts index d5c9b88a41..ff01fb0ddc 100644 --- a/facebook-pixel/facebook-pixel.d.ts +++ b/facebook-pixel/facebook-pixel.d.ts @@ -23,9 +23,6 @@ declare module facebook.Pixel { (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.AddToCartParameters):void; (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.PurchaseParameters):void; (eventType:string, eventName:string, parameters:facebook.Pixel.DPA.ViewContentParameters):void; - - // custom event - //(eventType:string, eventName:string, parameters:any):void; } From d9af8cb1913172e2138852c37b6869b7e41cbc92 Mon Sep 17 00:00:00 2001 From: Noctis Hsu Date: Fri, 1 Apr 2016 14:31:21 +0800 Subject: [PATCH 0150/1850] fix error 'Index signature of object type implicitly has an 'any' type.' --- facebook-pixel/facebook-pixel-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facebook-pixel/facebook-pixel-tests.ts b/facebook-pixel/facebook-pixel-tests.ts index e29190d232..94e2b50b53 100644 --- a/facebook-pixel/facebook-pixel-tests.ts +++ b/facebook-pixel/facebook-pixel-tests.ts @@ -14,7 +14,7 @@ fbq('track', 'Purchase', purchaseParam); // Custom event (can only be used for audience building) -var custom_params:any = {custom_param: 'custom_value'}; +var custom_params = {custom_param: 'custom_value'}; fbq('trackCustom', 'MyCustomEvent', custom_params); // Reach customers that viewed a product in the 'Shoes' category From 003090b8cce144edd995660206c040f78b6f5333 Mon Sep 17 00:00:00 2001 From: Noctis Hsu Date: Fri, 1 Apr 2016 14:33:26 +0800 Subject: [PATCH 0151/1850] fix error 'Index signature of object type implicitly has an 'any' type.' --- facebook-pixel/facebook-pixel-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/facebook-pixel/facebook-pixel-tests.ts b/facebook-pixel/facebook-pixel-tests.ts index 94e2b50b53..718a972c23 100644 --- a/facebook-pixel/facebook-pixel-tests.ts +++ b/facebook-pixel/facebook-pixel-tests.ts @@ -6,7 +6,6 @@ fbq('track', 'PageView'); // Standard event (can be used for conversion tracking // and optimizing in addition to audience building) var purchaseParam:facebook.Pixel.PurchaseParameters = {currency: 'EUR', value: 15.23}; -purchaseParam["Test"] = 44; // add custom parameter fbq('track', 'Purchase', purchaseParam); // Legacy conversion event (can only be used for conversion From 921f3276fe2b2c19f5c6491ec5d7096212cd809b Mon Sep 17 00:00:00 2001 From: hellopao Date: Fri, 1 Apr 2016 15:34:54 +0800 Subject: [PATCH 0152/1850] add definitions for koa-static --- koa-static/koa-static-tests.ts | 11 ++++++++ koa-static/koa-static.d.ts | 51 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 koa-static/koa-static-tests.ts create mode 100644 koa-static/koa-static.d.ts diff --git a/koa-static/koa-static-tests.ts b/koa-static/koa-static-tests.ts new file mode 100644 index 0000000000..bc77286fee --- /dev/null +++ b/koa-static/koa-static-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import * as Koa from "koa"; +import serve = require("koa-static"); + +const app = new Koa(); + +app.use(serve('.',{index:false,defer:false})); + +app.listen(80) \ No newline at end of file diff --git a/koa-static/koa-static.d.ts b/koa-static/koa-static.d.ts new file mode 100644 index 0000000000..4b95eca3be --- /dev/null +++ b/koa-static/koa-static.d.ts @@ -0,0 +1,51 @@ +// Type definitions for koa-static v2.x +// Project: https://github.com/koajs/static +// Definitions by: Jerry Chin +// Definitions: https://github.com/hellopao/DefinitelyTyped + +/* =================== USAGE =================== + + import serve = require("koa-static"); + var Koa = require('koa'); + + var app = new Koa(); + app.use(serve(".")); + + =============================================== */ + +/// + +declare module "koa-static" { + + import * as Koa from "koa"; + + function serve(root: string, opts?: { + + /** + * Default file name, defaults to 'index.html' + */ + index?: boolean | string; + + /** + * If true, serves after return next(),allowing any downstream middleware to respond first. + */ + defer?: boolean; + + /** + * Browser cache max-age in milliseconds. defaults to 0 + */ + maxage?: number; + + /** + * Allow transfer of hidden files. defaults to false + */ + hidden?: boolean; + + /** + * Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested file with .gz extension exists. defaults to true. + */ + gzip?: boolean; + }): { (ctx: Koa.Context, next?: () => any): any }; + + export = serve; +} From cca2d5741dd8e75a401a2c60e06838f40a4f904c Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Fri, 1 Apr 2016 00:56:00 -0700 Subject: [PATCH 0153/1850] Update and rename index-tests.ts to resolve-from-tests.ts --- resolve-from/{index-tests.ts => resolve-from-tests.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename resolve-from/{index-tests.ts => resolve-from-tests.ts} (80%) diff --git a/resolve-from/index-tests.ts b/resolve-from/resolve-from-tests.ts similarity index 80% rename from resolve-from/index-tests.ts rename to resolve-from/resolve-from-tests.ts index a1f5480ffc..840a19b861 100644 --- a/resolve-from/index-tests.ts +++ b/resolve-from/resolve-from-tests.ts @@ -1,4 +1,4 @@ -/// +/// // Much better testing in https://github.com/typed-typings/typed-resolve-from if (typeof resolveFrom !== 'function') { From 2a9c63cdd4bf7ae31be876771501b98ea3c2c16c Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Fri, 1 Apr 2016 00:56:20 -0700 Subject: [PATCH 0154/1850] Rename index.d.ts to resolve-from.d.ts --- resolve-from/{index.d.ts => resolve-from.d.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename resolve-from/{index.d.ts => resolve-from.d.ts} (100%) diff --git a/resolve-from/index.d.ts b/resolve-from/resolve-from.d.ts similarity index 100% rename from resolve-from/index.d.ts rename to resolve-from/resolve-from.d.ts From 6324ded3309992b0205fe585f73eaac38eb97b07 Mon Sep 17 00:00:00 2001 From: Gael Magnan de bornier Date: Fri, 1 Apr 2016 11:52:15 +0200 Subject: [PATCH 0155/1850] Update jwt-simple.d.ts --- jwt-simple/jwt-simple.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jwt-simple/jwt-simple.d.ts b/jwt-simple/jwt-simple.d.ts index 54e41c360e..ea78b13e88 100644 --- a/jwt-simple/jwt-simple.d.ts +++ b/jwt-simple/jwt-simple.d.ts @@ -1,6 +1,6 @@ // Type definitions for jwt-simple v0.5.0 // Project: https://github.com/hokaccha/node-jwt-simple -// Definitions by: Gael Magnan +// Definitions by: Ken Fukuyama , Gael Magnan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "jwt-simple" { /** From b7531163db5658688e338ae6354a790ea753c4cf Mon Sep 17 00:00:00 2001 From: yu-i9 Date: Fri, 1 Apr 2016 20:12:28 +0900 Subject: [PATCH 0156/1850] Added definitions for react-tabs --- react-tabs/react-tabs-tests.ts | 27 +++++++++++++++ react-tabs/react-tabs.d.ts | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 react-tabs/react-tabs-tests.ts create mode 100644 react-tabs/react-tabs.d.ts diff --git a/react-tabs/react-tabs-tests.ts b/react-tabs/react-tabs-tests.ts new file mode 100644 index 0000000000..f953b5001b --- /dev/null +++ b/react-tabs/react-tabs-tests.ts @@ -0,0 +1,27 @@ +/// +/// +/// + +import React = require("react"); +import ReactDOM = require("react-dom"); +import { Tabs, TabList, Tab, TabPanel } from "react-tabs"; + +class TestApp extends React.Component<{}, {}> { + onSelect = (index: number, last: number) => { + console.log("selected tab: " + index.toString()); + console.log("last tab: " + last.toString()); + } + + render() { + return React.createElement(Tabs, {onSelect: this.onSelect, selectedIndex: 1}, + React.createElement(TabList, {className: "test-class"}, + React.createElement(Tab, {}, "Tab1"), + React.createElement(Tab, {}, "Tab2"), + React.createElement(Tab, {}, "Tab3")), + React.createElement(TabPanel, {}, React.createElement("h2", {}, "Content1")), + React.createElement(TabPanel, {}, React.createElement("h2", {}, "Content2")), + React.createElement(TabPanel, {}, React.createElement("h2", {}, "Content3"))); + } +} + +ReactDOM.render(React.createElement(TestApp, {}), document.getElementById("test-app")); diff --git a/react-tabs/react-tabs.d.ts b/react-tabs/react-tabs.d.ts new file mode 100644 index 0000000000..cb292a8f72 --- /dev/null +++ b/react-tabs/react-tabs.d.ts @@ -0,0 +1,61 @@ +// Type definitions for react-tabs 0.5.3 +// Project: https://github.com/reactjs/react-tabs/ +// Definitions by: Yuu Igarashi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace ReactTabs { + + interface TabsProps { + className?: string; + selectedIndex?: number; + focus?: boolean; + forceRenderTabPanel?: boolean; + onSelect?: (index: number, last: number) => void; + } + + interface Tabs extends __React.ComponentClass {} + + interface TabListProps { + className?: string; + } + + interface TabList extends __React.ComponentClass {} + + interface TabProps { + className?: string; + focus?: boolean; + selected?: boolean; + id?: string; + panelId?: string; + } + + interface Tab extends __React.ComponentClass {} + + interface TabPanelProps { + className?: string; + selected?: boolean; + id?: string; + tabId?: string; + } + + interface TabPanel extends __React.ComponentClass {} +} + + +declare module "react-tabs" { + + var Tabs: ReactTabs.Tabs; + var TabList: ReactTabs.TabList; + var Tab: ReactTabs.Tab; + var TabPanel: ReactTabs.TabPanel; + + export { + Tabs, + TabList, + Tab, + TabPanel + } + +} From a89a7df160b720d59ffe7f56d13005e8a0cfebe0 Mon Sep 17 00:00:00 2001 From: Alex Pyzhianov Date: Fri, 1 Apr 2016 17:38:50 +0300 Subject: [PATCH 0157/1850] Fix CircleBufferGeometry inheriting from Geometry --- threejs/three.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index abfa5feb25..593c751006 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -5928,7 +5928,7 @@ declare namespace THREE { }; } - export class CircleBufferGeometry extends Geometry { + export class CircleBufferGeometry extends BufferGeometry { constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); parameters: { From a9a77535de002706e1f1106391f1c3df15896dac Mon Sep 17 00:00:00 2001 From: CheCoxshall Date: Fri, 1 Apr 2016 21:41:56 +0100 Subject: [PATCH 0158/1850] Added type definitions for bootstrap-fileinput --- bootstrap-fileinput/bootstrap-fileinput.d.ts | 1029 ++++++++++++++++++ 1 file changed, 1029 insertions(+) create mode 100644 bootstrap-fileinput/bootstrap-fileinput.d.ts diff --git a/bootstrap-fileinput/bootstrap-fileinput.d.ts b/bootstrap-fileinput/bootstrap-fileinput.d.ts new file mode 100644 index 0000000000..e517ae8d75 --- /dev/null +++ b/bootstrap-fileinput/bootstrap-fileinput.d.ts @@ -0,0 +1,1029 @@ +interface JQuery { + fileinput: (options?: FileInputOptions) => JQuery; +} + +interface FileInputOptions { + /** + Language configuration for the plugin to enable the plugin to display messages for your locale (you must set the ISO code for the language). + You can have multiple language widgets on the same page. + The locale JS file for the language code must be defined as mentioned in the translations section: http://plugins.krajee.com/file-input#translations + */ + language?: string; + /** + Whether to display the file caption. + Defaults to true. + */ + showCaption?: boolean; + /** + Whether to display the file preview. + Defaults to true. + */ + showPreview?: boolean; + /** + Whether to display the file remove/clear button. + Defaults to true. + */ + showRemove?: boolean; + /** + Whether to display the file upload button. + Defaults to true. + This will default to a form submit button, unless the uploadUrl is specified. + */ + showUpload?: boolean; + /** + Whether to display the file upload cancel button. + Defaults to true. + This will be only enabled and displayed when an AJAX upload is in process. + */ + showCancel?: boolean; + /** + Whether to display the close icon in the preview. + Defaults to true. + This will be only parsed when showPreview is true or when you are using the {close} tag in your preview templates. + */ + showClose?: boolean; + /** + Whether to persist display of the uploaded file thumbnails in the preview window (for ajax uploads) until the remove/clear button is pressed. + Defaults to true. + When set to false, a next batch of files selected for upload will clear these thumbnails from preview. + */ + showUploadedThumbs?: boolean; + /** + Whether to automatically replace the files in the preview after the maxFileCount limit is reached and a new set of file(s) is/are selected. + This will only work if a valid maxFileCount is set. + Defaults to false. + */ + autoReplace?: boolean; + /** + Any additional CSS class to append to the caption container. + */ + captionClass?: string; + /** + Any additional CSS class to append to the preview container. + */ + previewClass?: string; + /** + Any additional CSS class to append to the main plugin container. + */ + mainClass?: string; + /** + The initial preview content to be displayed. + You can pass the minimal HTML markup for displaying your image, text, or file. + If set as a string, this will display a single file in the initial preview if there is no delimiter. You can set a delimiter (as defined in initialDelimiter) to show multiple files in initial preview. + If set as an array, it will display all files in the array as an initial preview (useful for multiple file upload scenarios). + The following CSS classes will need to be added for displaying each file type as per the plugin style theme: + image files: Include CSS class file-preview-image + text files: Include CSS class file-preview-text + other files: Include CSS class file-preview-other + */ + initialPreview?: string | any[]; + /** + the count of initial preview items that will be added to the count of files selected in preview. This is applicable when displaying the right caption, when overwriteInitial is set to false. + */ + initialPreviewCount?: number; + /** + the delimiter to be used for splitting the initial preview content as individual file thumbnails (applicable only if initialPreview is passed as a string instead of array). Defaults to *$$*. + */ + initialPreviewDelimiter?: string; + /** + the configuration for setting up important properties for each initialPreview item (that is setup as part of initialPreview). + */ + initialPreviewConfig?: IFileUploadPreviewConfig[]; + /** + whether the delete button will be displayed for each thumbnail that has been created with initialPreview. + */ + initialPreviewShowDelete?: boolean; + /** + whether the file thumbnail should be removed from preview on error. Defaults to false. + */ + removeFromPreviewOnError?: boolean; + /** + this will be a list of tags used in thumbnail templates that will be replaced dynamically within the thumbnail markup, when the thumbnail is rendered. + */ + previewThumbTags?: { [key: string]: string; } + /** + this is an extension of previewThumbTags specifically for initial preview content - but will be configured as an array of objects corresponding to each initial preview thumbnail. The initial preview thumbnails set via initialPreview will read this configuration for replacing tags. + */ + initialPreviewThumbTags?: { [key: string]: string; } + /** + the extra data that will be passed as data to the initial preview delete url/AJAX server call via POST. + This will be overridden by the initialPreviewConfig['extra'] property. + This property is only applicable for ajax deletions in initial preview and when you have set a value for initialPreviewConfig['url'] or deleteUrl. + This can be setup either as an object (associative array of keys and values) or as a function callback. + Note + The ajax delete action will send the following data to server via POST: + key: the key setting as setup in initialPreviewConfig['key'] + any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. + */ + deleteExtraData?: {} | { (): {} }; + /** + the URL for deleting the image/content in the initial preview via AJAX post response. This will be overridden by the initialPreviewConfig['url'] property. + Note + The ajax delete action will send the following data to server via POST: + key: the key setting as setup in initialPreviewConfig['key'] + any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. + */ + deleteUrl?: string; + /** + the initial preview caption text to be displayed. + If you do not set a value here and initialPreview is set to true this will default to "{preview-file-count} files selected", where {preview-file-count} is the count of the files passed in initialPreview. + */ + initialCaption?: string; + /** + whether you wish to overwrite the initial preview content and caption setup. + This defaults to true, whereby, any initialPreview content set will be overwritten, when new file is uploaded or when files are cleared. + Setting it to false will help displaying a saved image or file from database always - useful especially when using the multiple file upload feature. + */ + overwriteInitial?: boolean; + /** + the templates configuration for rendering each part of the layout. + */ + layoutTemplates?: IFileUploadLayoutTemplates; + /** + the templates configuration for rendering each preview file type. + */ + previewTemplates?: IFileUploadPreviewTemplates; + /** + the list of allowed file types for upload. + This by default is set to null which means the plugin supports all file types for upload. + If an invalid file type is found, then a validation error message as set in msgInvalidFileType will be raised. + Note: + You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). + */ + allowedFileTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; + /** + the list of allowed file extensions for upload. + This by default is set to null which means the plugin supports all file extensions for upload. + If an invalid file extension is found, then a validation error message as set in msgInvalidFileExtension will be raised. + Note: + You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). + */ + allowedFileExtensions?: string[]; + /** + the list of allowed preview types for your widget. + This by default supports all file types for preview. + The plugin by default treats each file as an object if it does not match any of the previous types. + To disable this behavior, you can remove object from the list of allowedPreviewTypes OR fine tune it through allowedPreviewMimeTypes. + To disable content preview for all file-types and show the previewIcon instead as a thumbnail, set this to null, empty, or false. + */ + allowedPreviewTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; + /** + the list of allowed mime types for preview. + This is set to null by default which means all possible mime types are allowed. + This setting works in combination with allowedPreviewTypes to filter only the needed file types allowed for preview. + */ + allowedPreviewMimeTypes?: string[]; + /** + the default content / markup to show by default in the preview window whenever the files are cleared or the input is cleared. + This can be useful for use cases like showing the default user profile picture or profile image before upload to overwrite. + This is a bit different from initialPreview in the sense, that the initialPreview content will always be displayed unless it is deleted or overwritten based on overwriteInitial. + The defaultPreviewContent on the other hand will only be shown ONLY on initialization OR whenever you clear the preview. + At other times when files have been selected this will be overwritten temporarily until file(s) selected is/are cleared. + This property can be useful to display for example a default user profile picture (or saved picture) in the preview window unless the user selects a picture. + */ + defaultPreviewContent?: string; + /** + the list of additional custom tags that will be replaced in the layout templates. + */ + customLayoutTags?: {}; + /** + the list of additional custom tags that will be replaced in the preview templates. + */ + customPreviewTags?: {}; + /** + the format settings (width and height) for rendering each preview file type. + */ + previewSettings?: IFileUploadPreviewSettings; + /** + the settings to validate and identify each file type when a file is selected for upload. + This is a list of callbacks, which accepts the file mime type and file name as a parameter. + */ + fileTypeSettings?: IFileUploadFileTypeSettings; + /** + the icon to be shown in each preview file thumbnail when an unreadable file type for preview is detected. Defaults to  . + */ + previewFileIcon?: string; + /** + the CSS class to be applied to the preview file icon container. Defaults to file-icon-4x. + */ + previewFileIconClass?: string; + /** + the preview icon markup settings for each file extension (type). + You need to set this as key: value pairs, where the key corresponds to a file extension (e.g. doc, docx, xls etc.), and the value corresponds to the markup of the icon to be rendered. + If this is not set OR a file extension is not set here, the preview will default to previewFileIcon. + Note that displaying the icons instead of file content is controlled via allowedPreviewTypes and allowedPreviewMimeTypes + */ + previewFileIconSettings?: IFileUploadPreviewFileIconSettings; + /** + the extensions to be auto derived for each file extension (type). + This is useful if you want to set the same icon for multiple file extension types. + You need to set this as `key: value` pairs, where the key corresponds to a file extension as set in previewFileIconSettings (e.g. doc, docx, xls etc.). + The value will be a function callback that accepts the following parameter: + ext: string, the file extension (without the . [dot]) of the file currently selected in the preview. + You can configure the callback to match the set of file extensions (via regex or similar) for each `key` and return a boolean output if the file extension matches. + */ + previewFileExtSettings?: IFileUploadPreviewFileExtSettings; + /** + the CSS class for the each of the button labels for browse, remove, upload, and cancel. + Defaults to hidden-xs, which automatically hides the button labels for small screen devices and renders as smaller iconic buttons to fit to the screen. + */ + buttonLabelClass?: string; + /** + the label to display for the file picker/browse button. Defaults to Browse …. + */ + browseLabel?: string; + /** + the icon to display before the label for the file picker/browse button. Defaults to  . + */ + browseIcon?: string; + /** + the CSS class for the file picker/browse button. Defaults to btn btn-primary. + */ + browseClass?: string; + /** + the label to display for the file remove button. Defaults to Remove. + */ + removeLabel?: string; + /** + the icon to display before the label for the file picker/remove button. Defaults to  . + */ + removeIcon?: string; + /** + the CSS class for the file remove button. Defaults to btn btn-default. + */ + removeClass?: string; + /** + the title to display on hover for the file remove button. Defaults to Clear selected files. + */ + removeTitle?: string; + /** + the label to display for the file upload button. Defaults to Upload. + */ + uploadLabel?: string; + /** + the icon to display before the label for the file upload button. Defaults to  . + */ + uploadIcon?: string; + /** + the CSS class for the file upload button. Defaults to btn btn-default. + */ + uploadClass?: string; + /** + the title to display on hover for the file remove button. + Defaults to Upload selected files. + */ + uploadTitle?: string; + /** + the URL for the upload processing action (typically for ajax based processing). + Defaults to null. + If this is not set or null, then the upload button action will default to form submission. + NOTE: + This is MANDATORY if you want to use advanced features like drag & drop, append/remove files, selectively upload files via ajax etc. + The plugin automatically send $_FILES data to the server with the input `name` attribute as the key if provided. + If input name is not set, the key defaults to file-data. + */ + uploadUrl?: string; + /** + whether the batch upload of multiple files will be asynchronous/in parallel. + Defaults to true. + */ + uploadAsync?: boolean; + /** + the extra data that will be passed as data to the url/AJAX server call via POST. + This property is only applicable for ajax uploads and when you have set a value for uploadUrl. + This can be setup either as an object (associative array of keys and values) or as a function callback. + As an object, it can be set for example as: + { id: 100, value: '100 Details' } + Note that for uploading individual file via thumbnail, the function callback can also receive the thumbnail previewId and index as parameters. These are described below: + previewId: the identifier for the preview file container (only available when uploading each thumbnail file) + index: the zero-based sequential index of the loaded file in the preview list (only available when uploading each thumbnail file) + */ + uploadExtraData?: {} | ((previewId?: string, index?: number) => {}); + /** + the minimum allowed image height in px if you are uploading image files. + Defaults to null which means no limit on image height. + */ + minImageHeight?: number; + /** + the maximum allowed image width in px if you are uploading image files. + Defaults to null which means no limit on image width. + Note that if you set resizeImage property to true, then the entire image will be resized within this width (depending on resizePreference). + */ + maxImageWidth?: number; + /** + the maximum allowed image height in px if you are uploading image files. + Defaults to null which means no limit on image height. + Note that if you set resizeImage property to true, then the entire image will be resized within this height (depending on resizePreference). + */ + maxImageHeight?: number; + /** + whether to add ability to resize uploaded images. Defaults to false. + Note that resizing images requires HTML5 canvas support which is supported on most modern browsers. + In addition, you must include the JavaScript-Canvas-to-Blob plugin by blueimp by including canvas-to-blob.js in your application. + This JS file must be loaded before fileinput.js on the page. + The JavaScript-Canvas-to-Blob source files are available in js/plugins folder of bootstrap-fileinput project page. + The canvas-to-blob.js plugin is a polyfill for canvas.toBlob method and is needed for allowing the resized image files via HTML5 canvas to be returned as a blob + */ + resizeImage?: boolean; + /** + preference to resize the image based on width or height. + Defaults to width. + This property is parsed only when resizeImage is true. + If set to width, the maxImageWidth property is first tested and if image size is greater than this, then the image is resized to maxImageWidth. + The image height is resized and adjusted in the same ratio as width. + In case, the image width is already less than maxImageWidth then the maxImageHeight property is used to resize and width is adjusted in same ratio. + This will behave conversely, when resizePreference is set to height - the maxImageHeight will be first tested against image height and then the rest of steps will be similarly parsed with preference given to height instead of width as before. + */ + resizePreference?: "width" | "height"; + /** + the quality of the resized image. This must be a decimal number between 0.00 to 1.00. + Defaults to 0.92. + */ + resizeImageQuality?: number; + /** + the default image mime type of the converted image after resize. + Defaults to image/jpeg. + */ + resizeDefaultImageType?: string; + /** + the maximum file size for upload in KB. + If set to 0, it means size allowed is unlimited. + Defaults to 0. + */ + maxFileSize?: number; + /** + the minimum number of files allowed for each multiple upload. + If set to 0, it means number of files are optional. + Defaults to 0. + */ + minFileCount?: number; + /** + the maximum number of files allowed for each multiple upload. + If set to 0, it means number of files allowed is unlimited. + Defaults to 0. + */ + maxFileCount?: number; + /** + whether to include initial preview file count (server uploaded files) in validating minFileCount and maxFileCount. + Defaults to false. + */ + validateInitialCount?: boolean; + /** + the message that will be displayed when ZERO files are found. + Defaults to No. + */ + msgNo?: string; + /** + the message that will be displayed within the progress bar when file upload is aborted or cancelled. + Defaults to Cancelled. + */ + msgCancelled?: string; + /** + the title displayed (before the file name) on hover of the zoom button for zooming the file content in a modal window. + This is currently applicable only for text file previews. + Defaults to View details. + */ + msgZoomTitle?: string; + /** + the heading of the modal dialog that displays the zoomed file content. + This is currently applicable only for text file previews. + Defaults to Detailed Preview. + */ + msgZoomModalHeading?: string; + /** + the message to be displayed when the file size exceeds maximum size. + Defaults to: + File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB. Please retry your upload! + where: + {name}: will be replaced by the file name being uploaded + {size}: will be replaced by the uploaded file size + {maxSize}: will be replaced by the maxFileSize parameter. + */ + msgSizeTooLarge?: string; + /** + message to be displayed when the file count is less than the minimum count as set in minFileCount. + Defaults to: + You must select at least {n} {files} to upload. Please retry your upload! + where: + {n}: will be replaced by the allowed minimum files as set in minFileCount. + {files}: will be replaced with fileSingle or filePlural properties in locale file depending on the minFileCount. + */ + msgFilesTooLess?: string; + /** + the message to be displayed when the file count exceeds maximum count as set in maxFileCount. + Defaults to: + Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}. Please retry your upload! + where: + {n}: will be replaced by number of files selected for upload + {m}: will be replaced by the allowed maximum files as set in maxFileCount + */ + msgFilesTooMany?: string; + /** + the exception message to be displayed when the file selected is not found by the FileReader. + Defaults to: + File "{name}" not found! + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileNotFound?: string; + /** + the exception message to be displayed when the file selected is not allowed to be accessed due to a security exception. + Defaults to: + Security restrictions prevent reading the file "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileSecured?: string; + /** + the exception message to be displayed when the file selected is not readable by the FileReader API. + Defaults to: + File "{name}" is not readable. + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileNotReadable?: string; + /** + the exception message to be displayed when the file preview upload is aborted. + Defaults to: + File preview aborted for "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFilePreviewAborted?: string; + /** + the exception message to be displayed for any other error when previewing the file. + Defaults to: + An error occurred while reading the file "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFilePreviewError?: string; + /** + the message to be displayed when the file type is not in one of the file types set in allowedFileTypes. + Defaults to: + Invalid type for file "{name}". Only "{types}" files are supported. + where: + {name}: will be replaced by the file name being uploaded + {types}: will be replaced by the comma separated list of types defined in allowedFileTypes. + */ + msgInvalidFileType?: string; + /** + the message to be displayed when the file type is not in one of the file extensions set in allowedFileExtensions. + Defaults to: + Invalid extension for file "{name}". Only "{extensions}" files are supported. + where: + {name}: will be replaced by the file name being uploaded + {extensions}: will be replaced by the comma separated list of extensions defined in allowedFileExtensions. + */ + msgInvalidFileExtension?: string; + /** + the message to be displayed when an ongoing ajax file upload is aborted by pressing the Cancel button. + Defaults to The file upload was aborted. + If this is set to null or empty, the internal ajax error message will be displayed - Defaults to File Upload Error. + */ + msgUploadAborted?: string; + /** + the exception message to be displayed within the caption container (instead of msgFilesSelected), when a validation error is encountered. + Defaults to File Upload Error. + */ + msgValidationError?: string; + /** + the css class for the validation error message displayed in the caption container. + Defaults to text-danger. + */ + msgValidationErrorClass?: string; + /** + the icon to be displayed before the validation error in the caption container. + Defaults to + */ + msgValidationErrorIcon?: string; + /** + the css class for the error message to be displayed in the preview window when the file size exceeds maxSize. + Defaults to file-error-message. + */ + msgErrorClass?: string; + /** + the message displayed when the files are getting read and loaded for preview. + Defaults to + Loading file {index} of {files} … + The following special variables will be replaced: + {index}: the sequence number of the current file being loaded. + {files}: the total number of files selected for upload. + */ + msgLoading?: string; + /** + the progress message displayed as each file is loaded for preview. + Defaults to: + Loading file {index} of {files} - {name} - {percent}% completed. + The following variables will be replaced: + {index}: the sequence number of the current file being loaded. + {files}: the total number of files selected for upload. + {percent}: the percentage of file read and loaded. + {name}: the name of the current file being loaded. + */ + msgProgress?: string; + /** + the progress message displayed in caption window when multiple (more than one) files are selected. + Defaults to: + {n} files selected. + The following variables will be replaced: + {n}: the number of files selected. + */ + msgSelected?: string; + /** + the message displayed when a folder has been dragged to the drop zone. + Defaults to: + Drag & drop files only! {n} folder(s) dropped were skipped. + The following variables will be replaced: + {n}: the number of folders dropped. + */ + msgFoldersNotAllowed?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its width is less than the minImageWidth setting. + Defaults to: + Width of image file "{name}" must be at least {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the minImageWidth setting. + */ + msgImageWidthSmall?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its height is less than the minImageHeight setting. + Defaults to: + Height of image file "{name}" must be at least {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the minImageHeight setting. + */ + msgImageHeightSmall?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its width exceeds the maxImageWidth setting. + Defaults to: + Width of image file "{name}" cannot exceed {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the maxImageWidth setting. + */ + msgImageWidthLarge?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its height exceeds the maxImageHeight setting. + Defaults to: + Height of image file "{name}" cannot exceed {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the maxImageHeight setting. + */ + msgImageHeightLarge?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). + Defaults to progress-bar progress-bar-success progress-bar-striped active. + */ + progressClass?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). + Defaults to progress-bar progress-bar-success progress-bar-striped active. + */ + progressCompleteClass?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is cancelled or aborted. + Defaults to progress-bar progress-bar-danger. + */ + progressErrorClass?: string; + /** + the type of files that are to be displayed in the preview window. + Defaults to image. + Can be one of the following: + image: Only image type files will be shown in preview. + text: Only text type files will be shown in preview. + any: Both image and text files content will be shown in preview. + Files other than image or text will be displayed as a thumbnail with the filename in the preview window. + */ + previewFileType?: "image" | "text" | "any"; + /** + the icon for zooming the file content in a new modal dialog. + This is currently applicable only for text file previews. + Defaults to + */ + zoomIndicator?: string; + /** + the identifier for the container element displaying the error (e.g. '#id'). + If not set, will default to the container with CSS class kv-fileinput-error inside the preview container (identified by elPreviewContainer). + The msgErrorClass will be automatically appended to this container before displaying the error. + */ + elErrorContainer?: string; + /** + the identifier for the container element containing the caption (e.g. '#id'). + If not set, will default to the container with CSS class file-caption inside the main plugin container. + */ + elCaptionContainer?: string; + /** + the identifier for the container element containing the caption text (e.g. '#id'). + If not set, will default to the container with CSS class file-caption-name inside the main plugin container. + */ + elCaptionText?: string; + /** + the identifier for the container element containing the preview (e.g. '#id'). + If not set, will default to the container with CSS class file-preview inside the main plugin container. + */ + elPreviewContainer?: string; + /** + the identifier for the element containing the preview image thumbnails (e.g. '#id'). + If not set, will default to the container with CSS class file-preview-thumbnails inside the main plugin container. + */ + elPreviewImage?: string; + /** + the identifier for the element containing the preview progress status (e.g. '#id'). + If not set, will default to the container with CSS class file-preview-status inside the main plugin container. + */ + elPreviewStatus?: string; + /** + a callback to convert the filename as a slug string eliminating special characters. + If not set, it will use the plugin's own internal slugDefault method. + This callback function includes the filename as parameter and must return a converted filename string. + */ + slugCallback?: (filename: string) => string; + /** + whether to enable a drag and drop zone for dragging and dropping files to. + This is available only for ajax based uploads. + Defaults to true. + */ + dropZoneEnabled?: boolean; + /** + title to be displayed in the drag and drop zone. + This is available only for ajax based uploads. + Defaults to: + Drag & drop files here …. + */ + dropZoneTitle?: string; + /** + CSS class for the drag & drop zone title. + Defaults to file-drop-zone-title. + */ + dropZoneTitleClass?: string; + /** + configuration for setting up file actions for newly selected file thumbnails in the preview window. + */ + fileActionsettings?: IFileUploadFileActionSettings; + /** + markup for additional action buttons to display within the initial preview thumbnails (for example displaying an image edit button). + The following tag can be used in the markup and will be automatically replaced: + {dataKey}: Will be replaced with the key set within initialPreviewConfig. + */ + otherActionButtons?: string; + /** + the encoding to be used while reading a text file. + Applicable only for previewing text files. + Defaults to UTF-8. + */ + textEncoding?: string; + /** + additional ajax settings to pass to the plugin before submitting the ajax request for upload. + Applicable only for ajax uploads. + This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. + Refer the jQuery ajax documentation for the various settings you can configure. + */ + ajaxSettings?: JQueryAjaxSettings; + /** + additional ajax settings to pass to the plugin before submitting the delete ajax request in each initial preview thumbnail. + Applicable only for ajax uploads. + This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. + Refer the jQuery ajax documentation for the various settings you can configure. + */ + ajaxDeleteSettings?: JQueryAjaxSettings; + /** + whether to show details of the error stack from the server log when an error is encountered via ajax response. + Defaults to true. + */ + showAjaxErrorDetails?: boolean; +} + +interface IFileUploadPreviewConfig { + /** + the caption or filename to display for each initial preview item content. + */ + caption: string; + /** + the CSS width of the image/ content displayed. + */ + width: string; + /** + the URL for deleting the image/ content in the initial preview via AJAX post response.This will default to deleteUrl if not set. + */ + url: string; + /** + the key that will be passed as data to the url via AJAX POST. + */ + key: string | {}; + /** + the additional frame css class to set for the file's thumbnail frame. + */ + frameClass: string; + /** + the HTML attribute settings (set as key:value pairs) for the thumbnail frame. + */ + frameAttr: {}; + /** + the extra data that will be passed as data to the initial preview delete url / AJAX server call via POST.This will default to deleteExtraData if not set. + */ + extra: {} | Function; +} + +interface IFileUploadLayoutTemplates { + /** + the template for rendering the widget with caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the mainClass property. + {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. + {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. + {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. + {remove}: the file remove/clear button and will be displayed only if showRemove is true. + {upload}: the file upload button and will be displayed only if showUpload is true. + {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. + {browse}: the main file browse button to select your files for input. + */ + main1?: string; + /** + the template for rendering the widget without caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the mainClass property. + {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. + {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. + {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. + {remove}: the file remove/clear button and will be displayed only if showRemove is true. + {upload}: the file upload button and will be displayed only if showUpload is true. + {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. + {browse}: the main file browse button to select your files for input. + */ + main2?: string; + /** + the template for rendering the preview. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the previewClass property. + */ + preview?: string; + /** + the icon to render before the caption text. + */ + icon?: string; + /** + the template for rendering the caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the captionClass property. + */ + caption?: string; + /** + the template for rendering the modal (for text file preview zooming). + */ + modal?: string; + /** + the template for the progress bar when upload is in progress (for batch/mass uploads and within each preview thumbnail for async/single uploads). + The upload progress bar when displayed within each thumbnail will be wrapped inside a container having a CSS class of `file-thumb-progress`. + The following tags will be parsed and replaced automatically: + {percent}: will be replaced with the upload progress percentage. + */ + progress?: string; + /** + the template for the footer section of each file preview thumbnail. + The following tags will be parsed and replaced automatically: + {actions}: will be replaced with the output of the actions template. + {class}: the CSS class as set in the progressClass or progressCompleteClass property (depending on the progress percentage). + */ + footer?: string; + /** + the template for the file action buttons to be displayed within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {upload}: will be replaced with the output of the actionUpload template. + {delete}: will be replaced with the output of the actionDelete template. + */ + actions?: string; + /** + the template for the file delete action button within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {removeClass}: the css class for the remove button. Will be replaced with the removeClass set within fileActionSettings. + {removeIcon}: the icon for the remove button. Will be replaced with the removeIcon set within fileActionSettings. + {removeTitle}: the title to display on hover for the remove button. Will be replaced with the removeTitle set within fileActionSettings. + {dataUrl}: the URL for deleting the file thumbnail for initialPreview content only. Will be replaced with the url set within initialPreviewConfig. + {dataKey}: the key (additional data) that will be passed to the URL above via POST to the AJAX call. Will be replaced with the key set within initialPreviewConfig. + */ + actionDelete?: string; + /** + the template for the file upload action button within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {uploadClass}: the css class for the upload button. Will be replaced with the uploadClass set within fileActionSettings. + {uploadIcon}: the icon for the upload button. Will be replaced with the uploadIcon set within fileActionSettings. + {uploadTitle}: the title to display on hover for the upload button. Will be replaced with the uploadTitle set within fileActionSettings. + */ + actionUpload?: string; + /** + The template for upload, remove, and cancel buttons. + The following tags will be parsed and replaced automatically: + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for uploadClass or removeClass or cancelClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by uploadIcon or removeIcon or cancelIcon. + {label}: the button label as identified by uploadLabel or removeLabel or cancelLabel. + */ + btnDefault?: string; + /** + The template for upload button when used with ajax (i.e. when uploadUrl is set). + The following tags will be parsed and replaced automatically: + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for uploadClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by uploadIcon. + {label}: the button label as identified by uploadLabel. + {href}: applicable only for Upload button for ajax uploads and will be replaced with the uploadUrl property. + */ + btnLink?: string; + /** + The template for the browse button. + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for browseClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by browseIcon. + {label}: the button label as identified by browseLabel. + */ + btnBrowse?: string; +} + +interface IFileUploadPreviewTemplates { + /** + the preview template for image files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + image?: string; + /** + the preview template for text files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + {dialog}: Will be replaced with the JS code to launch the modal dialog. + {zoomTitle}: This will be replaced with the msgZoomTitle property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). + {zoomInd}: This will be replaced with the zoomIndicator property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). + {heading}: This represents the modal dialog heading title. This will be replaced with the msgZoomModalHeading property. + */ + text?: string; + /** + the preview template for html files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + html?: string; + /** + the preview template for video files (supported by HTML 5 video tag). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + video?: string; + /** + the preview template for audio files (supported by HTML 5 audio tag). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + audio?: string; + /** + the preview template for flash files (supported currently on webkit browsers). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + flash?: string; + /** + the preview template for all other files - by default treated as object. To disable this behavior, configure the allowedPreviewTypes property. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + object?: string; + /** + this template is used ONLY for rendering the initialPreview markup content passed directly as a raw format. + The following tags will be parsed and replaced automatically: + {content}: will be replaced with the raw HTML markup as set in initialPreview.. + */ + generic?: string; +} + +interface IFileUploadPreviewSettings { + image?: { width?: string; height?: string; }; + html?: { width?: string; height?: string; }; + text?: { width?: string; height?: string; }; + video?: { width?: string; height?: string; }; + audio?: { width?: string; height?: string; }; + flash?: { width?: string; height?: string; }; + object?: { width?: string; height?: string; }; + other?: { width?: string; height?: string; }; +} + +interface IFileUploadFileTypeSettings { + image: (vType: string, vName: string) => boolean; + html: (vType: string, vName: string) => boolean; + text: (vType: string, vName: string) => boolean; + video: (vType: string, vName: string) => boolean; + audio: (vType: string, vName: string) => boolean; + flash: (vType: string, vName: string) => boolean; + object: (vType: string, vName: string) => boolean; + other: (vType: string, vName: string) => boolean; +} + +interface IFileUploadPreviewFileIconSettings { + [key: string]: string; +} + +interface IFileUploadPreviewFileExtSettings { + [key: string]: (ext: string) => boolean; +} + +interface IFileUploadFileActionSettings { + /** + icon for remove button to be displayed in each file thumbnail. + */ + removeIcon: string; + /** + CSS class for the remove button in each file thumbnail. + */ + removeClass: string; + /** + title for remove button in each file thumbnail. + */ + removeTitle: string; + /** + icon for upload button to be displayed in each file thumbnail. + */ + uploadIcon: string; + /** + CSS class for the remove button in each file thumbnail. + */ + uploadClass: string; + /** + title for remove button in each file thumbnail. + */ + uploadTitle: string; + /** + an indicator (HTML markup) for new pending upload displayed in each file thumbnail. + */ + indicatorNew: string; + /** + an indicator (HTML markup) for successful upload displayed in each file thumbnail. + */ + indicatorSuccess: string; + /** + an indicator (HTML markup) for error in upload displayed in each file thumbnail. + */ + indicatorError: string; + /** + an indicator (HTML markup) for ongoing upload displayed in each file thumbnail. + */ + indicatorLoading: string; + /** + title to display on hover of indicator for new pending upload in each file thumbnail. + */ + indicatorNewTitle: string; + /** + title to display on hover of indicator for successful in each file thumbnail. + */ + indicatorSuccessTitle: string; + /** + title to display on hover of indicator for error in upload in each file thumbnail. + */ + indicatorErrorTitle: string; + /** + title to display on hover of indicator for ongoing upload in each file thumbnail. + */ + indicatorLoadingTitle: string; +} \ No newline at end of file From bc04f6857c435a46f44aec8395b7b5ea05461261 Mon Sep 17 00:00:00 2001 From: Roman Golovanov Date: Sat, 2 Apr 2016 00:25:23 +0300 Subject: [PATCH 0159/1850] added definitions for windows-1251 --- windows-1251/windows-1251-tests.ts | 21 +++++++++++++++++++++ windows-1251/windows-1251.d.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 windows-1251/windows-1251-tests.ts create mode 100644 windows-1251/windows-1251.d.ts diff --git a/windows-1251/windows-1251-tests.ts b/windows-1251/windows-1251-tests.ts new file mode 100644 index 0000000000..ec231c6ef2 --- /dev/null +++ b/windows-1251/windows-1251-tests.ts @@ -0,0 +1,21 @@ +/// + +import * as windows1251 from 'windows-1251'; + +var text:string = "some text", byteString:string, decodedText:string; + +var version:string = windows1251.version; + +var labels:string[] = windows1251.labels; + +byteString = windows1251.encode(text); +byteString = windows1251.encode(text, { mode: 'html' }); +byteString = windows1251.encode(text, { mode: 'fatal' }); + +decodedText = windows1251.decode(byteString); +decodedText = windows1251.decode(byteString, { mode: 'fatal' }); +decodedText = windows1251.decode(byteString, { mode: 'replacement' }); + + + + diff --git a/windows-1251/windows-1251.d.ts b/windows-1251/windows-1251.d.ts new file mode 100644 index 0000000000..48883637bd --- /dev/null +++ b/windows-1251/windows-1251.d.ts @@ -0,0 +1,26 @@ +// Type definitions for windows-1251 v0.1.2 +// Project: https://github.com/mathiasbynens/windows-1251 +// Definitions by: RomanGolovanov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare namespace windows1251 { + + type EncoderMode = 'fatal' | 'html'; + type DecoderMode = 'replacement' | 'fatal'; + + interface windows1251 { + encode(input:string, options?:{ mode?: EncoderMode }):string; + decode(text: string, options?:{ mode?: DecoderMode }): string; + } + +} + +declare module 'windows-1251' { + var windows1251: { + encode(input:string, options?:{ mode?: windows1251.EncoderMode }):string; + decode(text: string, options?:{ mode?: windows1251.DecoderMode }): string; + version: string; + labels: string[]; + } + + export = windows1251; +} From 325de0ff3bdd5dcad22f77a563ebbe533283478e Mon Sep 17 00:00:00 2001 From: CheCoxshall Date: Fri, 1 Apr 2016 22:27:19 +0100 Subject: [PATCH 0160/1850] Fixed header and Namespacing Also improved interface names. --- bootstrap-fileinput/bootstrap-fileinput.d.ts | 2044 +++++++++--------- 1 file changed, 1026 insertions(+), 1018 deletions(-) diff --git a/bootstrap-fileinput/bootstrap-fileinput.d.ts b/bootstrap-fileinput/bootstrap-fileinput.d.ts index e517ae8d75..e9d6f0e0d3 100644 --- a/bootstrap-fileinput/bootstrap-fileinput.d.ts +++ b/bootstrap-fileinput/bootstrap-fileinput.d.ts @@ -1,1029 +1,1037 @@ -interface JQuery { - fileinput: (options?: FileInputOptions) => JQuery; +// Type definitions for bootstrap-fileinput +// Project: https://github.com/kartik-v/bootstrap-fileinput +// Definitions by: Ché Coxshall +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface JQuery { + fileinput: (options?: BootstrapFileInput.FileInputOptions) => JQuery; } -interface FileInputOptions { - /** - Language configuration for the plugin to enable the plugin to display messages for your locale (you must set the ISO code for the language). - You can have multiple language widgets on the same page. - The locale JS file for the language code must be defined as mentioned in the translations section: http://plugins.krajee.com/file-input#translations - */ - language?: string; - /** - Whether to display the file caption. - Defaults to true. - */ - showCaption?: boolean; - /** - Whether to display the file preview. - Defaults to true. - */ - showPreview?: boolean; - /** - Whether to display the file remove/clear button. - Defaults to true. - */ - showRemove?: boolean; - /** - Whether to display the file upload button. - Defaults to true. - This will default to a form submit button, unless the uploadUrl is specified. - */ - showUpload?: boolean; - /** - Whether to display the file upload cancel button. - Defaults to true. - This will be only enabled and displayed when an AJAX upload is in process. - */ - showCancel?: boolean; - /** - Whether to display the close icon in the preview. - Defaults to true. - This will be only parsed when showPreview is true or when you are using the {close} tag in your preview templates. - */ - showClose?: boolean; - /** - Whether to persist display of the uploaded file thumbnails in the preview window (for ajax uploads) until the remove/clear button is pressed. - Defaults to true. - When set to false, a next batch of files selected for upload will clear these thumbnails from preview. - */ - showUploadedThumbs?: boolean; - /** - Whether to automatically replace the files in the preview after the maxFileCount limit is reached and a new set of file(s) is/are selected. - This will only work if a valid maxFileCount is set. - Defaults to false. - */ - autoReplace?: boolean; - /** - Any additional CSS class to append to the caption container. - */ - captionClass?: string; - /** - Any additional CSS class to append to the preview container. - */ - previewClass?: string; - /** - Any additional CSS class to append to the main plugin container. - */ - mainClass?: string; - /** - The initial preview content to be displayed. - You can pass the minimal HTML markup for displaying your image, text, or file. - If set as a string, this will display a single file in the initial preview if there is no delimiter. You can set a delimiter (as defined in initialDelimiter) to show multiple files in initial preview. - If set as an array, it will display all files in the array as an initial preview (useful for multiple file upload scenarios). - The following CSS classes will need to be added for displaying each file type as per the plugin style theme: - image files: Include CSS class file-preview-image - text files: Include CSS class file-preview-text - other files: Include CSS class file-preview-other - */ - initialPreview?: string | any[]; - /** - the count of initial preview items that will be added to the count of files selected in preview. This is applicable when displaying the right caption, when overwriteInitial is set to false. - */ - initialPreviewCount?: number; - /** - the delimiter to be used for splitting the initial preview content as individual file thumbnails (applicable only if initialPreview is passed as a string instead of array). Defaults to *$$*. - */ - initialPreviewDelimiter?: string; - /** - the configuration for setting up important properties for each initialPreview item (that is setup as part of initialPreview). - */ - initialPreviewConfig?: IFileUploadPreviewConfig[]; - /** - whether the delete button will be displayed for each thumbnail that has been created with initialPreview. - */ - initialPreviewShowDelete?: boolean; - /** - whether the file thumbnail should be removed from preview on error. Defaults to false. - */ - removeFromPreviewOnError?: boolean; - /** - this will be a list of tags used in thumbnail templates that will be replaced dynamically within the thumbnail markup, when the thumbnail is rendered. - */ - previewThumbTags?: { [key: string]: string; } - /** - this is an extension of previewThumbTags specifically for initial preview content - but will be configured as an array of objects corresponding to each initial preview thumbnail. The initial preview thumbnails set via initialPreview will read this configuration for replacing tags. - */ - initialPreviewThumbTags?: { [key: string]: string; } - /** - the extra data that will be passed as data to the initial preview delete url/AJAX server call via POST. - This will be overridden by the initialPreviewConfig['extra'] property. - This property is only applicable for ajax deletions in initial preview and when you have set a value for initialPreviewConfig['url'] or deleteUrl. - This can be setup either as an object (associative array of keys and values) or as a function callback. - Note - The ajax delete action will send the following data to server via POST: - key: the key setting as setup in initialPreviewConfig['key'] - any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. - */ - deleteExtraData?: {} | { (): {} }; - /** - the URL for deleting the image/content in the initial preview via AJAX post response. This will be overridden by the initialPreviewConfig['url'] property. - Note - The ajax delete action will send the following data to server via POST: - key: the key setting as setup in initialPreviewConfig['key'] - any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. - */ - deleteUrl?: string; - /** - the initial preview caption text to be displayed. - If you do not set a value here and initialPreview is set to true this will default to "{preview-file-count} files selected", where {preview-file-count} is the count of the files passed in initialPreview. - */ - initialCaption?: string; - /** - whether you wish to overwrite the initial preview content and caption setup. - This defaults to true, whereby, any initialPreview content set will be overwritten, when new file is uploaded or when files are cleared. - Setting it to false will help displaying a saved image or file from database always - useful especially when using the multiple file upload feature. - */ - overwriteInitial?: boolean; - /** - the templates configuration for rendering each part of the layout. - */ - layoutTemplates?: IFileUploadLayoutTemplates; - /** - the templates configuration for rendering each preview file type. - */ - previewTemplates?: IFileUploadPreviewTemplates; - /** - the list of allowed file types for upload. - This by default is set to null which means the plugin supports all file types for upload. - If an invalid file type is found, then a validation error message as set in msgInvalidFileType will be raised. - Note: - You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). - */ - allowedFileTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; - /** - the list of allowed file extensions for upload. - This by default is set to null which means the plugin supports all file extensions for upload. - If an invalid file extension is found, then a validation error message as set in msgInvalidFileExtension will be raised. - Note: - You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). - */ - allowedFileExtensions?: string[]; - /** - the list of allowed preview types for your widget. - This by default supports all file types for preview. - The plugin by default treats each file as an object if it does not match any of the previous types. - To disable this behavior, you can remove object from the list of allowedPreviewTypes OR fine tune it through allowedPreviewMimeTypes. - To disable content preview for all file-types and show the previewIcon instead as a thumbnail, set this to null, empty, or false. - */ - allowedPreviewTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; - /** - the list of allowed mime types for preview. - This is set to null by default which means all possible mime types are allowed. - This setting works in combination with allowedPreviewTypes to filter only the needed file types allowed for preview. - */ - allowedPreviewMimeTypes?: string[]; - /** - the default content / markup to show by default in the preview window whenever the files are cleared or the input is cleared. - This can be useful for use cases like showing the default user profile picture or profile image before upload to overwrite. - This is a bit different from initialPreview in the sense, that the initialPreview content will always be displayed unless it is deleted or overwritten based on overwriteInitial. - The defaultPreviewContent on the other hand will only be shown ONLY on initialization OR whenever you clear the preview. - At other times when files have been selected this will be overwritten temporarily until file(s) selected is/are cleared. - This property can be useful to display for example a default user profile picture (or saved picture) in the preview window unless the user selects a picture. - */ - defaultPreviewContent?: string; - /** - the list of additional custom tags that will be replaced in the layout templates. - */ - customLayoutTags?: {}; - /** - the list of additional custom tags that will be replaced in the preview templates. - */ - customPreviewTags?: {}; - /** - the format settings (width and height) for rendering each preview file type. - */ - previewSettings?: IFileUploadPreviewSettings; - /** - the settings to validate and identify each file type when a file is selected for upload. - This is a list of callbacks, which accepts the file mime type and file name as a parameter. - */ - fileTypeSettings?: IFileUploadFileTypeSettings; - /** - the icon to be shown in each preview file thumbnail when an unreadable file type for preview is detected. Defaults to  . - */ - previewFileIcon?: string; - /** - the CSS class to be applied to the preview file icon container. Defaults to file-icon-4x. - */ - previewFileIconClass?: string; - /** - the preview icon markup settings for each file extension (type). - You need to set this as key: value pairs, where the key corresponds to a file extension (e.g. doc, docx, xls etc.), and the value corresponds to the markup of the icon to be rendered. - If this is not set OR a file extension is not set here, the preview will default to previewFileIcon. - Note that displaying the icons instead of file content is controlled via allowedPreviewTypes and allowedPreviewMimeTypes - */ - previewFileIconSettings?: IFileUploadPreviewFileIconSettings; - /** - the extensions to be auto derived for each file extension (type). - This is useful if you want to set the same icon for multiple file extension types. - You need to set this as `key: value` pairs, where the key corresponds to a file extension as set in previewFileIconSettings (e.g. doc, docx, xls etc.). - The value will be a function callback that accepts the following parameter: - ext: string, the file extension (without the . [dot]) of the file currently selected in the preview. - You can configure the callback to match the set of file extensions (via regex or similar) for each `key` and return a boolean output if the file extension matches. - */ - previewFileExtSettings?: IFileUploadPreviewFileExtSettings; - /** - the CSS class for the each of the button labels for browse, remove, upload, and cancel. - Defaults to hidden-xs, which automatically hides the button labels for small screen devices and renders as smaller iconic buttons to fit to the screen. - */ - buttonLabelClass?: string; - /** - the label to display for the file picker/browse button. Defaults to Browse …. - */ - browseLabel?: string; - /** - the icon to display before the label for the file picker/browse button. Defaults to  . - */ - browseIcon?: string; - /** - the CSS class for the file picker/browse button. Defaults to btn btn-primary. - */ - browseClass?: string; - /** - the label to display for the file remove button. Defaults to Remove. - */ - removeLabel?: string; - /** - the icon to display before the label for the file picker/remove button. Defaults to  . - */ - removeIcon?: string; - /** - the CSS class for the file remove button. Defaults to btn btn-default. - */ - removeClass?: string; - /** - the title to display on hover for the file remove button. Defaults to Clear selected files. - */ - removeTitle?: string; - /** - the label to display for the file upload button. Defaults to Upload. - */ - uploadLabel?: string; - /** - the icon to display before the label for the file upload button. Defaults to  . - */ - uploadIcon?: string; - /** - the CSS class for the file upload button. Defaults to btn btn-default. - */ - uploadClass?: string; - /** - the title to display on hover for the file remove button. - Defaults to Upload selected files. - */ - uploadTitle?: string; - /** - the URL for the upload processing action (typically for ajax based processing). - Defaults to null. - If this is not set or null, then the upload button action will default to form submission. - NOTE: - This is MANDATORY if you want to use advanced features like drag & drop, append/remove files, selectively upload files via ajax etc. - The plugin automatically send $_FILES data to the server with the input `name` attribute as the key if provided. - If input name is not set, the key defaults to file-data. - */ - uploadUrl?: string; - /** - whether the batch upload of multiple files will be asynchronous/in parallel. - Defaults to true. - */ - uploadAsync?: boolean; - /** - the extra data that will be passed as data to the url/AJAX server call via POST. - This property is only applicable for ajax uploads and when you have set a value for uploadUrl. - This can be setup either as an object (associative array of keys and values) or as a function callback. - As an object, it can be set for example as: - { id: 100, value: '100 Details' } - Note that for uploading individual file via thumbnail, the function callback can also receive the thumbnail previewId and index as parameters. These are described below: - previewId: the identifier for the preview file container (only available when uploading each thumbnail file) - index: the zero-based sequential index of the loaded file in the preview list (only available when uploading each thumbnail file) - */ - uploadExtraData?: {} | ((previewId?: string, index?: number) => {}); - /** - the minimum allowed image height in px if you are uploading image files. - Defaults to null which means no limit on image height. - */ - minImageHeight?: number; - /** - the maximum allowed image width in px if you are uploading image files. - Defaults to null which means no limit on image width. - Note that if you set resizeImage property to true, then the entire image will be resized within this width (depending on resizePreference). - */ - maxImageWidth?: number; - /** - the maximum allowed image height in px if you are uploading image files. - Defaults to null which means no limit on image height. - Note that if you set resizeImage property to true, then the entire image will be resized within this height (depending on resizePreference). - */ - maxImageHeight?: number; - /** - whether to add ability to resize uploaded images. Defaults to false. - Note that resizing images requires HTML5 canvas support which is supported on most modern browsers. - In addition, you must include the JavaScript-Canvas-to-Blob plugin by blueimp by including canvas-to-blob.js in your application. - This JS file must be loaded before fileinput.js on the page. - The JavaScript-Canvas-to-Blob source files are available in js/plugins folder of bootstrap-fileinput project page. - The canvas-to-blob.js plugin is a polyfill for canvas.toBlob method and is needed for allowing the resized image files via HTML5 canvas to be returned as a blob - */ - resizeImage?: boolean; - /** - preference to resize the image based on width or height. - Defaults to width. - This property is parsed only when resizeImage is true. - If set to width, the maxImageWidth property is first tested and if image size is greater than this, then the image is resized to maxImageWidth. - The image height is resized and adjusted in the same ratio as width. - In case, the image width is already less than maxImageWidth then the maxImageHeight property is used to resize and width is adjusted in same ratio. - This will behave conversely, when resizePreference is set to height - the maxImageHeight will be first tested against image height and then the rest of steps will be similarly parsed with preference given to height instead of width as before. - */ - resizePreference?: "width" | "height"; - /** - the quality of the resized image. This must be a decimal number between 0.00 to 1.00. - Defaults to 0.92. - */ - resizeImageQuality?: number; - /** - the default image mime type of the converted image after resize. - Defaults to image/jpeg. - */ - resizeDefaultImageType?: string; - /** - the maximum file size for upload in KB. - If set to 0, it means size allowed is unlimited. - Defaults to 0. - */ - maxFileSize?: number; - /** - the minimum number of files allowed for each multiple upload. - If set to 0, it means number of files are optional. - Defaults to 0. - */ - minFileCount?: number; - /** - the maximum number of files allowed for each multiple upload. - If set to 0, it means number of files allowed is unlimited. - Defaults to 0. - */ - maxFileCount?: number; - /** - whether to include initial preview file count (server uploaded files) in validating minFileCount and maxFileCount. - Defaults to false. - */ - validateInitialCount?: boolean; - /** - the message that will be displayed when ZERO files are found. - Defaults to No. - */ - msgNo?: string; - /** - the message that will be displayed within the progress bar when file upload is aborted or cancelled. - Defaults to Cancelled. - */ - msgCancelled?: string; - /** - the title displayed (before the file name) on hover of the zoom button for zooming the file content in a modal window. - This is currently applicable only for text file previews. - Defaults to View details. - */ - msgZoomTitle?: string; - /** - the heading of the modal dialog that displays the zoomed file content. - This is currently applicable only for text file previews. - Defaults to Detailed Preview. - */ - msgZoomModalHeading?: string; - /** - the message to be displayed when the file size exceeds maximum size. - Defaults to: - File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB. Please retry your upload! - where: - {name}: will be replaced by the file name being uploaded - {size}: will be replaced by the uploaded file size - {maxSize}: will be replaced by the maxFileSize parameter. - */ - msgSizeTooLarge?: string; - /** - message to be displayed when the file count is less than the minimum count as set in minFileCount. - Defaults to: - You must select at least {n} {files} to upload. Please retry your upload! - where: - {n}: will be replaced by the allowed minimum files as set in minFileCount. - {files}: will be replaced with fileSingle or filePlural properties in locale file depending on the minFileCount. - */ - msgFilesTooLess?: string; - /** - the message to be displayed when the file count exceeds maximum count as set in maxFileCount. - Defaults to: - Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}. Please retry your upload! - where: - {n}: will be replaced by number of files selected for upload - {m}: will be replaced by the allowed maximum files as set in maxFileCount - */ - msgFilesTooMany?: string; - /** - the exception message to be displayed when the file selected is not found by the FileReader. - Defaults to: - File "{name}" not found! - where: - {name}: will be replaced by the file name being uploaded - */ - msgFileNotFound?: string; - /** - the exception message to be displayed when the file selected is not allowed to be accessed due to a security exception. - Defaults to: - Security restrictions prevent reading the file "{name}". - where: - {name}: will be replaced by the file name being uploaded - */ - msgFileSecured?: string; - /** - the exception message to be displayed when the file selected is not readable by the FileReader API. - Defaults to: - File "{name}" is not readable. - where: - {name}: will be replaced by the file name being uploaded - */ - msgFileNotReadable?: string; - /** - the exception message to be displayed when the file preview upload is aborted. - Defaults to: - File preview aborted for "{name}". - where: - {name}: will be replaced by the file name being uploaded - */ - msgFilePreviewAborted?: string; - /** - the exception message to be displayed for any other error when previewing the file. - Defaults to: - An error occurred while reading the file "{name}". - where: - {name}: will be replaced by the file name being uploaded - */ - msgFilePreviewError?: string; - /** - the message to be displayed when the file type is not in one of the file types set in allowedFileTypes. - Defaults to: - Invalid type for file "{name}". Only "{types}" files are supported. - where: - {name}: will be replaced by the file name being uploaded - {types}: will be replaced by the comma separated list of types defined in allowedFileTypes. - */ - msgInvalidFileType?: string; - /** - the message to be displayed when the file type is not in one of the file extensions set in allowedFileExtensions. - Defaults to: - Invalid extension for file "{name}". Only "{extensions}" files are supported. - where: - {name}: will be replaced by the file name being uploaded - {extensions}: will be replaced by the comma separated list of extensions defined in allowedFileExtensions. - */ - msgInvalidFileExtension?: string; - /** - the message to be displayed when an ongoing ajax file upload is aborted by pressing the Cancel button. - Defaults to The file upload was aborted. - If this is set to null or empty, the internal ajax error message will be displayed - Defaults to File Upload Error. - */ - msgUploadAborted?: string; - /** - the exception message to be displayed within the caption container (instead of msgFilesSelected), when a validation error is encountered. - Defaults to File Upload Error. - */ - msgValidationError?: string; - /** - the css class for the validation error message displayed in the caption container. - Defaults to text-danger. - */ - msgValidationErrorClass?: string; - /** - the icon to be displayed before the validation error in the caption container. - Defaults to - */ - msgValidationErrorIcon?: string; - /** - the css class for the error message to be displayed in the preview window when the file size exceeds maxSize. - Defaults to file-error-message. - */ - msgErrorClass?: string; - /** - the message displayed when the files are getting read and loaded for preview. - Defaults to - Loading file {index} of {files} … - The following special variables will be replaced: - {index}: the sequence number of the current file being loaded. - {files}: the total number of files selected for upload. - */ - msgLoading?: string; - /** - the progress message displayed as each file is loaded for preview. - Defaults to: - Loading file {index} of {files} - {name} - {percent}% completed. - The following variables will be replaced: - {index}: the sequence number of the current file being loaded. - {files}: the total number of files selected for upload. - {percent}: the percentage of file read and loaded. - {name}: the name of the current file being loaded. - */ - msgProgress?: string; - /** - the progress message displayed in caption window when multiple (more than one) files are selected. - Defaults to: - {n} files selected. - The following variables will be replaced: - {n}: the number of files selected. - */ - msgSelected?: string; - /** - the message displayed when a folder has been dragged to the drop zone. - Defaults to: - Drag & drop files only! {n} folder(s) dropped were skipped. - The following variables will be replaced: - {n}: the number of folders dropped. - */ - msgFoldersNotAllowed?: string; - /** - the exception message to be displayed when the file selected for preview is an image and its width is less than the minImageWidth setting. - Defaults to: - Width of image file "{name}" must be at least {size} px. - where: - {name}: will be replaced by the file name being uploaded. - {size}: will be replaced by the minImageWidth setting. - */ - msgImageWidthSmall?: string; - /** - the exception message to be displayed when the file selected for preview is an image and its height is less than the minImageHeight setting. - Defaults to: - Height of image file "{name}" must be at least {size} px. - where: - {name}: will be replaced by the file name being uploaded. - {size}: will be replaced by the minImageHeight setting. - */ - msgImageHeightSmall?: string; - /** - the exception message to be displayed when the file selected for preview is an image and its width exceeds the maxImageWidth setting. - Defaults to: - Width of image file "{name}" cannot exceed {size} px. - where: - {name}: will be replaced by the file name being uploaded. - {size}: will be replaced by the maxImageWidth setting. - */ - msgImageWidthLarge?: string; - /** - the exception message to be displayed when the file selected for preview is an image and its height exceeds the maxImageHeight setting. - Defaults to: - Height of image file "{name}" cannot exceed {size} px. - where: - {name}: will be replaced by the file name being uploaded. - {size}: will be replaced by the maxImageHeight setting. - */ - msgImageHeightLarge?: string; - /** - the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). - Defaults to progress-bar progress-bar-success progress-bar-striped active. - */ - progressClass?: string; - /** - the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). - Defaults to progress-bar progress-bar-success progress-bar-striped active. - */ - progressCompleteClass?: string; - /** - the upload progress bar CSS class to be applied when AJAX upload is cancelled or aborted. - Defaults to progress-bar progress-bar-danger. - */ - progressErrorClass?: string; - /** - the type of files that are to be displayed in the preview window. - Defaults to image. - Can be one of the following: - image: Only image type files will be shown in preview. - text: Only text type files will be shown in preview. - any: Both image and text files content will be shown in preview. - Files other than image or text will be displayed as a thumbnail with the filename in the preview window. - */ - previewFileType?: "image" | "text" | "any"; - /** - the icon for zooming the file content in a new modal dialog. - This is currently applicable only for text file previews. - Defaults to - */ - zoomIndicator?: string; - /** - the identifier for the container element displaying the error (e.g. '#id'). - If not set, will default to the container with CSS class kv-fileinput-error inside the preview container (identified by elPreviewContainer). - The msgErrorClass will be automatically appended to this container before displaying the error. - */ - elErrorContainer?: string; - /** - the identifier for the container element containing the caption (e.g. '#id'). - If not set, will default to the container with CSS class file-caption inside the main plugin container. - */ - elCaptionContainer?: string; - /** - the identifier for the container element containing the caption text (e.g. '#id'). - If not set, will default to the container with CSS class file-caption-name inside the main plugin container. - */ - elCaptionText?: string; - /** - the identifier for the container element containing the preview (e.g. '#id'). - If not set, will default to the container with CSS class file-preview inside the main plugin container. - */ - elPreviewContainer?: string; - /** - the identifier for the element containing the preview image thumbnails (e.g. '#id'). - If not set, will default to the container with CSS class file-preview-thumbnails inside the main plugin container. - */ - elPreviewImage?: string; - /** - the identifier for the element containing the preview progress status (e.g. '#id'). - If not set, will default to the container with CSS class file-preview-status inside the main plugin container. - */ - elPreviewStatus?: string; - /** - a callback to convert the filename as a slug string eliminating special characters. - If not set, it will use the plugin's own internal slugDefault method. - This callback function includes the filename as parameter and must return a converted filename string. - */ - slugCallback?: (filename: string) => string; - /** - whether to enable a drag and drop zone for dragging and dropping files to. - This is available only for ajax based uploads. - Defaults to true. - */ - dropZoneEnabled?: boolean; - /** - title to be displayed in the drag and drop zone. - This is available only for ajax based uploads. - Defaults to: - Drag & drop files here …. - */ - dropZoneTitle?: string; - /** - CSS class for the drag & drop zone title. - Defaults to file-drop-zone-title. - */ - dropZoneTitleClass?: string; - /** - configuration for setting up file actions for newly selected file thumbnails in the preview window. - */ - fileActionsettings?: IFileUploadFileActionSettings; - /** - markup for additional action buttons to display within the initial preview thumbnails (for example displaying an image edit button). - The following tag can be used in the markup and will be automatically replaced: - {dataKey}: Will be replaced with the key set within initialPreviewConfig. - */ - otherActionButtons?: string; - /** - the encoding to be used while reading a text file. - Applicable only for previewing text files. - Defaults to UTF-8. - */ - textEncoding?: string; - /** - additional ajax settings to pass to the plugin before submitting the ajax request for upload. - Applicable only for ajax uploads. - This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. - Refer the jQuery ajax documentation for the various settings you can configure. - */ - ajaxSettings?: JQueryAjaxSettings; - /** - additional ajax settings to pass to the plugin before submitting the delete ajax request in each initial preview thumbnail. - Applicable only for ajax uploads. - This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. - Refer the jQuery ajax documentation for the various settings you can configure. - */ - ajaxDeleteSettings?: JQueryAjaxSettings; - /** - whether to show details of the error stack from the server log when an error is encountered via ajax response. - Defaults to true. - */ - showAjaxErrorDetails?: boolean; -} -interface IFileUploadPreviewConfig { - /** - the caption or filename to display for each initial preview item content. - */ - caption: string; - /** - the CSS width of the image/ content displayed. - */ - width: string; - /** - the URL for deleting the image/ content in the initial preview via AJAX post response.This will default to deleteUrl if not set. - */ - url: string; - /** - the key that will be passed as data to the url via AJAX POST. - */ - key: string | {}; - /** - the additional frame css class to set for the file's thumbnail frame. - */ - frameClass: string; - /** - the HTML attribute settings (set as key:value pairs) for the thumbnail frame. - */ - frameAttr: {}; - /** - the extra data that will be passed as data to the initial preview delete url / AJAX server call via POST.This will default to deleteExtraData if not set. - */ - extra: {} | Function; -} +declare module BootstrapFileInput { + interface FileInputOptions { + /** + Language configuration for the plugin to enable the plugin to display messages for your locale (you must set the ISO code for the language). + You can have multiple language widgets on the same page. + The locale JS file for the language code must be defined as mentioned in the translations section: http://plugins.krajee.com/file-input#translations + */ + language?: string; + /** + Whether to display the file caption. + Defaults to true. + */ + showCaption?: boolean; + /** + Whether to display the file preview. + Defaults to true. + */ + showPreview?: boolean; + /** + Whether to display the file remove/clear button. + Defaults to true. + */ + showRemove?: boolean; + /** + Whether to display the file upload button. + Defaults to true. + This will default to a form submit button, unless the uploadUrl is specified. + */ + showUpload?: boolean; + /** + Whether to display the file upload cancel button. + Defaults to true. + This will be only enabled and displayed when an AJAX upload is in process. + */ + showCancel?: boolean; + /** + Whether to display the close icon in the preview. + Defaults to true. + This will be only parsed when showPreview is true or when you are using the {close} tag in your preview templates. + */ + showClose?: boolean; + /** + Whether to persist display of the uploaded file thumbnails in the preview window (for ajax uploads) until the remove/clear button is pressed. + Defaults to true. + When set to false, a next batch of files selected for upload will clear these thumbnails from preview. + */ + showUploadedThumbs?: boolean; + /** + Whether to automatically replace the files in the preview after the maxFileCount limit is reached and a new set of file(s) is/are selected. + This will only work if a valid maxFileCount is set. + Defaults to false. + */ + autoReplace?: boolean; + /** + Any additional CSS class to append to the caption container. + */ + captionClass?: string; + /** + Any additional CSS class to append to the preview container. + */ + previewClass?: string; + /** + Any additional CSS class to append to the main plugin container. + */ + mainClass?: string; + /** + The initial preview content to be displayed. + You can pass the minimal HTML markup for displaying your image, text, or file. + If set as a string, this will display a single file in the initial preview if there is no delimiter. You can set a delimiter (as defined in initialDelimiter) to show multiple files in initial preview. + If set as an array, it will display all files in the array as an initial preview (useful for multiple file upload scenarios). + The following CSS classes will need to be added for displaying each file type as per the plugin style theme: + image files: Include CSS class file-preview-image + text files: Include CSS class file-preview-text + other files: Include CSS class file-preview-other + */ + initialPreview?: string | any[]; + /** + the count of initial preview items that will be added to the count of files selected in preview. This is applicable when displaying the right caption, when overwriteInitial is set to false. + */ + initialPreviewCount?: number; + /** + the delimiter to be used for splitting the initial preview content as individual file thumbnails (applicable only if initialPreview is passed as a string instead of array). Defaults to *$$*. + */ + initialPreviewDelimiter?: string; + /** + the configuration for setting up important properties for each initialPreview item (that is setup as part of initialPreview). + */ + initialPreviewConfig?: PreviewConfig[]; + /** + whether the delete button will be displayed for each thumbnail that has been created with initialPreview. + */ + initialPreviewShowDelete?: boolean; + /** + whether the file thumbnail should be removed from preview on error. Defaults to false. + */ + removeFromPreviewOnError?: boolean; + /** + this will be a list of tags used in thumbnail templates that will be replaced dynamically within the thumbnail markup, when the thumbnail is rendered. + */ + previewThumbTags?: { [key: string]: string; } + /** + this is an extension of previewThumbTags specifically for initial preview content - but will be configured as an array of objects corresponding to each initial preview thumbnail. The initial preview thumbnails set via initialPreview will read this configuration for replacing tags. + */ + initialPreviewThumbTags?: { [key: string]: string; } + /** + the extra data that will be passed as data to the initial preview delete url/AJAX server call via POST. + This will be overridden by the initialPreviewConfig['extra'] property. + This property is only applicable for ajax deletions in initial preview and when you have set a value for initialPreviewConfig['url'] or deleteUrl. + This can be setup either as an object (associative array of keys and values) or as a function callback. + Note + The ajax delete action will send the following data to server via POST: + key: the key setting as setup in initialPreviewConfig['key'] + any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. + */ + deleteExtraData?: {} | { (): {} }; + /** + the URL for deleting the image/content in the initial preview via AJAX post response. This will be overridden by the initialPreviewConfig['url'] property. + Note + The ajax delete action will send the following data to server via POST: + key: the key setting as setup in initialPreviewConfig['key'] + any other extra data passed as key: value pairs either via initialPreviewConfig['extra'] OR deleteExtraData if former is not set. + */ + deleteUrl?: string; + /** + the initial preview caption text to be displayed. + If you do not set a value here and initialPreview is set to true this will default to "{preview-file-count} files selected", where {preview-file-count} is the count of the files passed in initialPreview. + */ + initialCaption?: string; + /** + whether you wish to overwrite the initial preview content and caption setup. + This defaults to true, whereby, any initialPreview content set will be overwritten, when new file is uploaded or when files are cleared. + Setting it to false will help displaying a saved image or file from database always - useful especially when using the multiple file upload feature. + */ + overwriteInitial?: boolean; + /** + the templates configuration for rendering each part of the layout. + */ + layoutTemplates?: LayoutTemplates; + /** + the templates configuration for rendering each preview file type. + */ + previewTemplates?: PreviewTemplates; + /** + the list of allowed file types for upload. + This by default is set to null which means the plugin supports all file types for upload. + If an invalid file type is found, then a validation error message as set in msgInvalidFileType will be raised. + Note: + You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). + */ + allowedFileTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; + /** + the list of allowed file extensions for upload. + This by default is set to null which means the plugin supports all file extensions for upload. + If an invalid file extension is found, then a validation error message as set in msgInvalidFileExtension will be raised. + Note: + You need to be careful in case you are setting both allowedFileTypes and allowedFileExtensions. In this case, the allowedFileTypes property is validated first and generally precedes the allowedFileExtensions setting (and the latter validation maybe skipped). + */ + allowedFileExtensions?: string[]; + /** + the list of allowed preview types for your widget. + This by default supports all file types for preview. + The plugin by default treats each file as an object if it does not match any of the previous types. + To disable this behavior, you can remove object from the list of allowedPreviewTypes OR fine tune it through allowedPreviewMimeTypes. + To disable content preview for all file-types and show the previewIcon instead as a thumbnail, set this to null, empty, or false. + */ + allowedPreviewTypes?: ("image" | "html" | "text" | "video" | "audio" | "flash" | "object")[]; + /** + the list of allowed mime types for preview. + This is set to null by default which means all possible mime types are allowed. + This setting works in combination with allowedPreviewTypes to filter only the needed file types allowed for preview. + */ + allowedPreviewMimeTypes?: string[]; + /** + the default content / markup to show by default in the preview window whenever the files are cleared or the input is cleared. + This can be useful for use cases like showing the default user profile picture or profile image before upload to overwrite. + This is a bit different from initialPreview in the sense, that the initialPreview content will always be displayed unless it is deleted or overwritten based on overwriteInitial. + The defaultPreviewContent on the other hand will only be shown ONLY on initialization OR whenever you clear the preview. + At other times when files have been selected this will be overwritten temporarily until file(s) selected is/are cleared. + This property can be useful to display for example a default user profile picture (or saved picture) in the preview window unless the user selects a picture. + */ + defaultPreviewContent?: string; + /** + the list of additional custom tags that will be replaced in the layout templates. + */ + customLayoutTags?: {}; + /** + the list of additional custom tags that will be replaced in the preview templates. + */ + customPreviewTags?: {}; + /** + the format settings (width and height) for rendering each preview file type. + */ + previewSettings?: PreviewSettings; + /** + the settings to validate and identify each file type when a file is selected for upload. + This is a list of callbacks, which accepts the file mime type and file name as a parameter. + */ + fileTypeSettings?: FileTypeSettings; + /** + the icon to be shown in each preview file thumbnail when an unreadable file type for preview is detected. Defaults to  . + */ + previewFileIcon?: string; + /** + the CSS class to be applied to the preview file icon container. Defaults to file-icon-4x. + */ + previewFileIconClass?: string; + /** + the preview icon markup settings for each file extension (type). + You need to set this as key: value pairs, where the key corresponds to a file extension (e.g. doc, docx, xls etc.), and the value corresponds to the markup of the icon to be rendered. + If this is not set OR a file extension is not set here, the preview will default to previewFileIcon. + Note that displaying the icons instead of file content is controlled via allowedPreviewTypes and allowedPreviewMimeTypes + */ + previewFileIconSettings?: PreviewFileIconSettings; + /** + the extensions to be auto derived for each file extension (type). + This is useful if you want to set the same icon for multiple file extension types. + You need to set this as `key: value` pairs, where the key corresponds to a file extension as set in previewFileIconSettings (e.g. doc, docx, xls etc.). + The value will be a function callback that accepts the following parameter: + ext: string, the file extension (without the . [dot]) of the file currently selected in the preview. + You can configure the callback to match the set of file extensions (via regex or similar) for each `key` and return a boolean output if the file extension matches. + */ + previewFileExtSettings?: PreviewFileExtSettings; + /** + the CSS class for the each of the button labels for browse, remove, upload, and cancel. + Defaults to hidden-xs, which automatically hides the button labels for small screen devices and renders as smaller iconic buttons to fit to the screen. + */ + buttonLabelClass?: string; + /** + the label to display for the file picker/browse button. Defaults to Browse …. + */ + browseLabel?: string; + /** + the icon to display before the label for the file picker/browse button. Defaults to  . + */ + browseIcon?: string; + /** + the CSS class for the file picker/browse button. Defaults to btn btn-primary. + */ + browseClass?: string; + /** + the label to display for the file remove button. Defaults to Remove. + */ + removeLabel?: string; + /** + the icon to display before the label for the file picker/remove button. Defaults to  . + */ + removeIcon?: string; + /** + the CSS class for the file remove button. Defaults to btn btn-default. + */ + removeClass?: string; + /** + the title to display on hover for the file remove button. Defaults to Clear selected files. + */ + removeTitle?: string; + /** + the label to display for the file upload button. Defaults to Upload. + */ + uploadLabel?: string; + /** + the icon to display before the label for the file upload button. Defaults to  . + */ + uploadIcon?: string; + /** + the CSS class for the file upload button. Defaults to btn btn-default. + */ + uploadClass?: string; + /** + the title to display on hover for the file remove button. + Defaults to Upload selected files. + */ + uploadTitle?: string; + /** + the URL for the upload processing action (typically for ajax based processing). + Defaults to null. + If this is not set or null, then the upload button action will default to form submission. + NOTE: + This is MANDATORY if you want to use advanced features like drag & drop, append/remove files, selectively upload files via ajax etc. + The plugin automatically send $_FILES data to the server with the input `name` attribute as the key if provided. + If input name is not set, the key defaults to file-data. + */ + uploadUrl?: string; + /** + whether the batch upload of multiple files will be asynchronous/in parallel. + Defaults to true. + */ + uploadAsync?: boolean; + /** + the extra data that will be passed as data to the url/AJAX server call via POST. + This property is only applicable for ajax uploads and when you have set a value for uploadUrl. + This can be setup either as an object (associative array of keys and values) or as a function callback. + As an object, it can be set for example as: + { id: 100, value: '100 Details' } + Note that for uploading individual file via thumbnail, the function callback can also receive the thumbnail previewId and index as parameters. These are described below: + previewId: the identifier for the preview file container (only available when uploading each thumbnail file) + index: the zero-based sequential index of the loaded file in the preview list (only available when uploading each thumbnail file) + */ + uploadExtraData?: {} | ((previewId?: string, index?: number) => {}); + /** + the minimum allowed image height in px if you are uploading image files. + Defaults to null which means no limit on image height. + */ + minImageHeight?: number; + /** + the maximum allowed image width in px if you are uploading image files. + Defaults to null which means no limit on image width. + Note that if you set resizeImage property to true, then the entire image will be resized within this width (depending on resizePreference). + */ + maxImageWidth?: number; + /** + the maximum allowed image height in px if you are uploading image files. + Defaults to null which means no limit on image height. + Note that if you set resizeImage property to true, then the entire image will be resized within this height (depending on resizePreference). + */ + maxImageHeight?: number; + /** + whether to add ability to resize uploaded images. Defaults to false. + Note that resizing images requires HTML5 canvas support which is supported on most modern browsers. + In addition, you must include the JavaScript-Canvas-to-Blob plugin by blueimp by including canvas-to-blob.js in your application. + This JS file must be loaded before fileinput.js on the page. + The JavaScript-Canvas-to-Blob source files are available in js/plugins folder of bootstrap-fileinput project page. + The canvas-to-blob.js plugin is a polyfill for canvas.toBlob method and is needed for allowing the resized image files via HTML5 canvas to be returned as a blob + */ + resizeImage?: boolean; + /** + preference to resize the image based on width or height. + Defaults to width. + This property is parsed only when resizeImage is true. + If set to width, the maxImageWidth property is first tested and if image size is greater than this, then the image is resized to maxImageWidth. + The image height is resized and adjusted in the same ratio as width. + In case, the image width is already less than maxImageWidth then the maxImageHeight property is used to resize and width is adjusted in same ratio. + This will behave conversely, when resizePreference is set to height - the maxImageHeight will be first tested against image height and then the rest of steps will be similarly parsed with preference given to height instead of width as before. + */ + resizePreference?: "width" | "height"; + /** + the quality of the resized image. This must be a decimal number between 0.00 to 1.00. + Defaults to 0.92. + */ + resizeImageQuality?: number; + /** + the default image mime type of the converted image after resize. + Defaults to image/jpeg. + */ + resizeDefaultImageType?: string; + /** + the maximum file size for upload in KB. + If set to 0, it means size allowed is unlimited. + Defaults to 0. + */ + maxFileSize?: number; + /** + the minimum number of files allowed for each multiple upload. + If set to 0, it means number of files are optional. + Defaults to 0. + */ + minFileCount?: number; + /** + the maximum number of files allowed for each multiple upload. + If set to 0, it means number of files allowed is unlimited. + Defaults to 0. + */ + maxFileCount?: number; + /** + whether to include initial preview file count (server uploaded files) in validating minFileCount and maxFileCount. + Defaults to false. + */ + validateInitialCount?: boolean; + /** + the message that will be displayed when ZERO files are found. + Defaults to No. + */ + msgNo?: string; + /** + the message that will be displayed within the progress bar when file upload is aborted or cancelled. + Defaults to Cancelled. + */ + msgCancelled?: string; + /** + the title displayed (before the file name) on hover of the zoom button for zooming the file content in a modal window. + This is currently applicable only for text file previews. + Defaults to View details. + */ + msgZoomTitle?: string; + /** + the heading of the modal dialog that displays the zoomed file content. + This is currently applicable only for text file previews. + Defaults to Detailed Preview. + */ + msgZoomModalHeading?: string; + /** + the message to be displayed when the file size exceeds maximum size. + Defaults to: + File "{name}" ({size} KB) exceeds maximum allowed upload size of {maxSize} KB. Please retry your upload! + where: + {name}: will be replaced by the file name being uploaded + {size}: will be replaced by the uploaded file size + {maxSize}: will be replaced by the maxFileSize parameter. + */ + msgSizeTooLarge?: string; + /** + message to be displayed when the file count is less than the minimum count as set in minFileCount. + Defaults to: + You must select at least {n} {files} to upload. Please retry your upload! + where: + {n}: will be replaced by the allowed minimum files as set in minFileCount. + {files}: will be replaced with fileSingle or filePlural properties in locale file depending on the minFileCount. + */ + msgFilesTooLess?: string; + /** + the message to be displayed when the file count exceeds maximum count as set in maxFileCount. + Defaults to: + Number of files selected for upload ({n}) exceeds maximum allowed limit of {m}. Please retry your upload! + where: + {n}: will be replaced by number of files selected for upload + {m}: will be replaced by the allowed maximum files as set in maxFileCount + */ + msgFilesTooMany?: string; + /** + the exception message to be displayed when the file selected is not found by the FileReader. + Defaults to: + File "{name}" not found! + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileNotFound?: string; + /** + the exception message to be displayed when the file selected is not allowed to be accessed due to a security exception. + Defaults to: + Security restrictions prevent reading the file "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileSecured?: string; + /** + the exception message to be displayed when the file selected is not readable by the FileReader API. + Defaults to: + File "{name}" is not readable. + where: + {name}: will be replaced by the file name being uploaded + */ + msgFileNotReadable?: string; + /** + the exception message to be displayed when the file preview upload is aborted. + Defaults to: + File preview aborted for "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFilePreviewAborted?: string; + /** + the exception message to be displayed for any other error when previewing the file. + Defaults to: + An error occurred while reading the file "{name}". + where: + {name}: will be replaced by the file name being uploaded + */ + msgFilePreviewError?: string; + /** + the message to be displayed when the file type is not in one of the file types set in allowedFileTypes. + Defaults to: + Invalid type for file "{name}". Only "{types}" files are supported. + where: + {name}: will be replaced by the file name being uploaded + {types}: will be replaced by the comma separated list of types defined in allowedFileTypes. + */ + msgInvalidFileType?: string; + /** + the message to be displayed when the file type is not in one of the file extensions set in allowedFileExtensions. + Defaults to: + Invalid extension for file "{name}". Only "{extensions}" files are supported. + where: + {name}: will be replaced by the file name being uploaded + {extensions}: will be replaced by the comma separated list of extensions defined in allowedFileExtensions. + */ + msgInvalidFileExtension?: string; + /** + the message to be displayed when an ongoing ajax file upload is aborted by pressing the Cancel button. + Defaults to The file upload was aborted. + If this is set to null or empty, the internal ajax error message will be displayed - Defaults to File Upload Error. + */ + msgUploadAborted?: string; + /** + the exception message to be displayed within the caption container (instead of msgFilesSelected), when a validation error is encountered. + Defaults to File Upload Error. + */ + msgValidationError?: string; + /** + the css class for the validation error message displayed in the caption container. + Defaults to text-danger. + */ + msgValidationErrorClass?: string; + /** + the icon to be displayed before the validation error in the caption container. + Defaults to + */ + msgValidationErrorIcon?: string; + /** + the css class for the error message to be displayed in the preview window when the file size exceeds maxSize. + Defaults to file-error-message. + */ + msgErrorClass?: string; + /** + the message displayed when the files are getting read and loaded for preview. + Defaults to + Loading file {index} of {files} … + The following special variables will be replaced: + {index}: the sequence number of the current file being loaded. + {files}: the total number of files selected for upload. + */ + msgLoading?: string; + /** + the progress message displayed as each file is loaded for preview. + Defaults to: + Loading file {index} of {files} - {name} - {percent}% completed. + The following variables will be replaced: + {index}: the sequence number of the current file being loaded. + {files}: the total number of files selected for upload. + {percent}: the percentage of file read and loaded. + {name}: the name of the current file being loaded. + */ + msgProgress?: string; + /** + the progress message displayed in caption window when multiple (more than one) files are selected. + Defaults to: + {n} files selected. + The following variables will be replaced: + {n}: the number of files selected. + */ + msgSelected?: string; + /** + the message displayed when a folder has been dragged to the drop zone. + Defaults to: + Drag & drop files only! {n} folder(s) dropped were skipped. + The following variables will be replaced: + {n}: the number of folders dropped. + */ + msgFoldersNotAllowed?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its width is less than the minImageWidth setting. + Defaults to: + Width of image file "{name}" must be at least {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the minImageWidth setting. + */ + msgImageWidthSmall?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its height is less than the minImageHeight setting. + Defaults to: + Height of image file "{name}" must be at least {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the minImageHeight setting. + */ + msgImageHeightSmall?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its width exceeds the maxImageWidth setting. + Defaults to: + Width of image file "{name}" cannot exceed {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the maxImageWidth setting. + */ + msgImageWidthLarge?: string; + /** + the exception message to be displayed when the file selected for preview is an image and its height exceeds the maxImageHeight setting. + Defaults to: + Height of image file "{name}" cannot exceed {size} px. + where: + {name}: will be replaced by the file name being uploaded. + {size}: will be replaced by the maxImageHeight setting. + */ + msgImageHeightLarge?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). + Defaults to progress-bar progress-bar-success progress-bar-striped active. + */ + progressClass?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is in process (applicable only for ajax uploads). + Defaults to progress-bar progress-bar-success progress-bar-striped active. + */ + progressCompleteClass?: string; + /** + the upload progress bar CSS class to be applied when AJAX upload is cancelled or aborted. + Defaults to progress-bar progress-bar-danger. + */ + progressErrorClass?: string; + /** + the type of files that are to be displayed in the preview window. + Defaults to image. + Can be one of the following: + image: Only image type files will be shown in preview. + text: Only text type files will be shown in preview. + any: Both image and text files content will be shown in preview. + Files other than image or text will be displayed as a thumbnail with the filename in the preview window. + */ + previewFileType?: "image" | "text" | "any"; + /** + the icon for zooming the file content in a new modal dialog. + This is currently applicable only for text file previews. + Defaults to + */ + zoomIndicator?: string; + /** + the identifier for the container element displaying the error (e.g. '#id'). + If not set, will default to the container with CSS class kv-fileinput-error inside the preview container (identified by elPreviewContainer). + The msgErrorClass will be automatically appended to this container before displaying the error. + */ + elErrorContainer?: string; + /** + the identifier for the container element containing the caption (e.g. '#id'). + If not set, will default to the container with CSS class file-caption inside the main plugin container. + */ + elCaptionContainer?: string; + /** + the identifier for the container element containing the caption text (e.g. '#id'). + If not set, will default to the container with CSS class file-caption-name inside the main plugin container. + */ + elCaptionText?: string; + /** + the identifier for the container element containing the preview (e.g. '#id'). + If not set, will default to the container with CSS class file-preview inside the main plugin container. + */ + elPreviewContainer?: string; + /** + the identifier for the element containing the preview image thumbnails (e.g. '#id'). + If not set, will default to the container with CSS class file-preview-thumbnails inside the main plugin container. + */ + elPreviewImage?: string; + /** + the identifier for the element containing the preview progress status (e.g. '#id'). + If not set, will default to the container with CSS class file-preview-status inside the main plugin container. + */ + elPreviewStatus?: string; + /** + a callback to convert the filename as a slug string eliminating special characters. + If not set, it will use the plugin's own internal slugDefault method. + This callback function includes the filename as parameter and must return a converted filename string. + */ + slugCallback?: (filename: string) => string; + /** + whether to enable a drag and drop zone for dragging and dropping files to. + This is available only for ajax based uploads. + Defaults to true. + */ + dropZoneEnabled?: boolean; + /** + title to be displayed in the drag and drop zone. + This is available only for ajax based uploads. + Defaults to: + Drag & drop files here …. + */ + dropZoneTitle?: string; + /** + CSS class for the drag & drop zone title. + Defaults to file-drop-zone-title. + */ + dropZoneTitleClass?: string; + /** + configuration for setting up file actions for newly selected file thumbnails in the preview window. + */ + fileActionsettings?: FileActionSettings; + /** + markup for additional action buttons to display within the initial preview thumbnails (for example displaying an image edit button). + The following tag can be used in the markup and will be automatically replaced: + {dataKey}: Will be replaced with the key set within initialPreviewConfig. + */ + otherActionButtons?: string; + /** + the encoding to be used while reading a text file. + Applicable only for previewing text files. + Defaults to UTF-8. + */ + textEncoding?: string; + /** + additional ajax settings to pass to the plugin before submitting the ajax request for upload. + Applicable only for ajax uploads. + This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. + Refer the jQuery ajax documentation for the various settings you can configure. + */ + ajaxSettings?: JQueryAjaxSettings; + /** + additional ajax settings to pass to the plugin before submitting the delete ajax request in each initial preview thumbnail. + Applicable only for ajax uploads. + This can be useful to pass additional tokens to headers or one can use it for setting other ajax options for advanced cases. + Refer the jQuery ajax documentation for the various settings you can configure. + */ + ajaxDeleteSettings?: JQueryAjaxSettings; + /** + whether to show details of the error stack from the server log when an error is encountered via ajax response. + Defaults to true. + */ + showAjaxErrorDetails?: boolean; + } -interface IFileUploadLayoutTemplates { - /** - the template for rendering the widget with caption. - The following tags will be parsed and replaced automatically: - {class}: the CSS class as set in the mainClass property. - {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. - {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. - {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. - {remove}: the file remove/clear button and will be displayed only if showRemove is true. - {upload}: the file upload button and will be displayed only if showUpload is true. - {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. - {browse}: the main file browse button to select your files for input. - */ - main1?: string; - /** - the template for rendering the widget without caption. - The following tags will be parsed and replaced automatically: - {class}: the CSS class as set in the mainClass property. - {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. - {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. - {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. - {remove}: the file remove/clear button and will be displayed only if showRemove is true. - {upload}: the file upload button and will be displayed only if showUpload is true. - {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. - {browse}: the main file browse button to select your files for input. - */ - main2?: string; - /** - the template for rendering the preview. - The following tags will be parsed and replaced automatically: - {class}: the CSS class as set in the previewClass property. - */ - preview?: string; - /** - the icon to render before the caption text. - */ - icon?: string; - /** - the template for rendering the caption. - The following tags will be parsed and replaced automatically: - {class}: the CSS class as set in the captionClass property. - */ - caption?: string; - /** - the template for rendering the modal (for text file preview zooming). - */ - modal?: string; - /** - the template for the progress bar when upload is in progress (for batch/mass uploads and within each preview thumbnail for async/single uploads). - The upload progress bar when displayed within each thumbnail will be wrapped inside a container having a CSS class of `file-thumb-progress`. - The following tags will be parsed and replaced automatically: - {percent}: will be replaced with the upload progress percentage. - */ - progress?: string; - /** - the template for the footer section of each file preview thumbnail. - The following tags will be parsed and replaced automatically: - {actions}: will be replaced with the output of the actions template. - {class}: the CSS class as set in the progressClass or progressCompleteClass property (depending on the progress percentage). - */ - footer?: string; - /** - the template for the file action buttons to be displayed within the thumbnail footer. - The following tags will be parsed and replaced automatically: - {upload}: will be replaced with the output of the actionUpload template. - {delete}: will be replaced with the output of the actionDelete template. - */ - actions?: string; - /** - the template for the file delete action button within the thumbnail footer. - The following tags will be parsed and replaced automatically: - {removeClass}: the css class for the remove button. Will be replaced with the removeClass set within fileActionSettings. - {removeIcon}: the icon for the remove button. Will be replaced with the removeIcon set within fileActionSettings. - {removeTitle}: the title to display on hover for the remove button. Will be replaced with the removeTitle set within fileActionSettings. - {dataUrl}: the URL for deleting the file thumbnail for initialPreview content only. Will be replaced with the url set within initialPreviewConfig. - {dataKey}: the key (additional data) that will be passed to the URL above via POST to the AJAX call. Will be replaced with the key set within initialPreviewConfig. - */ - actionDelete?: string; - /** - the template for the file upload action button within the thumbnail footer. - The following tags will be parsed and replaced automatically: - {uploadClass}: the css class for the upload button. Will be replaced with the uploadClass set within fileActionSettings. - {uploadIcon}: the icon for the upload button. Will be replaced with the uploadIcon set within fileActionSettings. - {uploadTitle}: the title to display on hover for the upload button. Will be replaced with the uploadTitle set within fileActionSettings. - */ - actionUpload?: string; - /** - The template for upload, remove, and cancel buttons. - The following tags will be parsed and replaced automatically: - {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. - {title}: the title to display on button hover. - {css}: the CSS class for the button. This is derived from settings for uploadClass or removeClass or cancelClass. - {status}: the disabled status for the button if available (else will be blank). - {icon}: the button icon as identified by uploadIcon or removeIcon or cancelIcon. - {label}: the button label as identified by uploadLabel or removeLabel or cancelLabel. - */ - btnDefault?: string; - /** - The template for upload button when used with ajax (i.e. when uploadUrl is set). - The following tags will be parsed and replaced automatically: - {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. - {title}: the title to display on button hover. - {css}: the CSS class for the button. This is derived from settings for uploadClass. - {status}: the disabled status for the button if available (else will be blank). - {icon}: the button icon as identified by uploadIcon. - {label}: the button label as identified by uploadLabel. - {href}: applicable only for Upload button for ajax uploads and will be replaced with the uploadUrl property. - */ - btnLink?: string; - /** - The template for the browse button. - {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. - {title}: the title to display on button hover. - {css}: the CSS class for the button. This is derived from settings for browseClass. - {status}: the disabled status for the button if available (else will be blank). - {icon}: the button icon as identified by browseIcon. - {label}: the button label as identified by browseLabel. - */ - btnBrowse?: string; -} + interface PreviewConfig { + /** + the caption or filename to display for each initial preview item content. + */ + caption: string; + /** + the CSS width of the image/ content displayed. + */ + width: string; + /** + the URL for deleting the image/ content in the initial preview via AJAX post response.This will default to deleteUrl if not set. + */ + url: string; + /** + the key that will be passed as data to the url via AJAX POST. + */ + key: string | {}; + /** + the additional frame css class to set for the file's thumbnail frame. + */ + frameClass: string; + /** + the HTML attribute settings (set as key:value pairs) for the thumbnail frame. + */ + frameAttr: {}; + /** + the extra data that will be passed as data to the initial preview delete url / AJAX server call via POST.This will default to deleteExtraData if not set. + */ + extra: {} | Function; + } -interface IFileUploadPreviewTemplates { - /** - the preview template for image files. - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - image?: string; - /** - the preview template for text files. - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - {dialog}: Will be replaced with the JS code to launch the modal dialog. - {zoomTitle}: This will be replaced with the msgZoomTitle property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). - {zoomInd}: This will be replaced with the zoomIndicator property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). - {heading}: This represents the modal dialog heading title. This will be replaced with the msgZoomModalHeading property. - */ - text?: string; - /** - the preview template for html files. - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - html?: string; - /** - the preview template for video files (supported by HTML 5 video tag). - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - video?: string; - /** - the preview template for audio files (supported by HTML 5 audio tag). - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - audio?: string; - /** - the preview template for flash files (supported currently on webkit browsers). - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - flash?: string; - /** - the preview template for all other files - by default treated as object. To disable this behavior, configure the allowedPreviewTypes property. - The following tags will be parsed and replaced automatically: - {previewId}: will be replaced with the generated identifier for the preview frame container. - {data}: will be replaced with the data source for each preview type. - {width}: will be replaced with the width for the file type as set in previewSettings. - {height}: will be replaced with the height for the file type as set in previewSettings. - {caption}: will be replaced with the file name. - {type}: will be replaced with the file type. - */ - object?: string; - /** - this template is used ONLY for rendering the initialPreview markup content passed directly as a raw format. - The following tags will be parsed and replaced automatically: - {content}: will be replaced with the raw HTML markup as set in initialPreview.. - */ - generic?: string; -} + interface LayoutTemplates { + /** + the template for rendering the widget with caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the mainClass property. + {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. + {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. + {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. + {remove}: the file remove/clear button and will be displayed only if showRemove is true. + {upload}: the file upload button and will be displayed only if showUpload is true. + {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. + {browse}: the main file browse button to select your files for input. + */ + main1?: string; + /** + the template for rendering the widget without caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the mainClass property. + {close}: will be replaced with the close (cross) icon (by default on top right of the preview window). The layout template to control this markup is layoutTemplates.close. + {preview}: the content parsed by the previewTemplate and will be displayed only if showPreview is true. + {caption}: the content parsed by the captionTemplate and will be displayed only if showCaption is true. + {remove}: the file remove/clear button and will be displayed only if showRemove is true. + {upload}: the file upload button and will be displayed only if showUpload is true. + {cancel}: the file upload cancel button that will be displayed when AJAX upload is in process to abort the AJAX upload. + {browse}: the main file browse button to select your files for input. + */ + main2?: string; + /** + the template for rendering the preview. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the previewClass property. + */ + preview?: string; + /** + the icon to render before the caption text. + */ + icon?: string; + /** + the template for rendering the caption. + The following tags will be parsed and replaced automatically: + {class}: the CSS class as set in the captionClass property. + */ + caption?: string; + /** + the template for rendering the modal (for text file preview zooming). + */ + modal?: string; + /** + the template for the progress bar when upload is in progress (for batch/mass uploads and within each preview thumbnail for async/single uploads). + The upload progress bar when displayed within each thumbnail will be wrapped inside a container having a CSS class of `file-thumb-progress`. + The following tags will be parsed and replaced automatically: + {percent}: will be replaced with the upload progress percentage. + */ + progress?: string; + /** + the template for the footer section of each file preview thumbnail. + The following tags will be parsed and replaced automatically: + {actions}: will be replaced with the output of the actions template. + {class}: the CSS class as set in the progressClass or progressCompleteClass property (depending on the progress percentage). + */ + footer?: string; + /** + the template for the file action buttons to be displayed within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {upload}: will be replaced with the output of the actionUpload template. + {delete}: will be replaced with the output of the actionDelete template. + */ + actions?: string; + /** + the template for the file delete action button within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {removeClass}: the css class for the remove button. Will be replaced with the removeClass set within fileActionSettings. + {removeIcon}: the icon for the remove button. Will be replaced with the removeIcon set within fileActionSettings. + {removeTitle}: the title to display on hover for the remove button. Will be replaced with the removeTitle set within fileActionSettings. + {dataUrl}: the URL for deleting the file thumbnail for initialPreview content only. Will be replaced with the url set within initialPreviewConfig. + {dataKey}: the key (additional data) that will be passed to the URL above via POST to the AJAX call. Will be replaced with the key set within initialPreviewConfig. + */ + actionDelete?: string; + /** + the template for the file upload action button within the thumbnail footer. + The following tags will be parsed and replaced automatically: + {uploadClass}: the css class for the upload button. Will be replaced with the uploadClass set within fileActionSettings. + {uploadIcon}: the icon for the upload button. Will be replaced with the uploadIcon set within fileActionSettings. + {uploadTitle}: the title to display on hover for the upload button. Will be replaced with the uploadTitle set within fileActionSettings. + */ + actionUpload?: string; + /** + The template for upload, remove, and cancel buttons. + The following tags will be parsed and replaced automatically: + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for uploadClass or removeClass or cancelClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by uploadIcon or removeIcon or cancelIcon. + {label}: the button label as identified by uploadLabel or removeLabel or cancelLabel. + */ + btnDefault?: string; + /** + The template for upload button when used with ajax (i.e. when uploadUrl is set). + The following tags will be parsed and replaced automatically: + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for uploadClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by uploadIcon. + {label}: the button label as identified by uploadLabel. + {href}: applicable only for Upload button for ajax uploads and will be replaced with the uploadUrl property. + */ + btnLink?: string; + /** + The template for the browse button. + {type}: the HTML button type, defaults to button for most buttons and submit for form based uploads. + {title}: the title to display on button hover. + {css}: the CSS class for the button. This is derived from settings for browseClass. + {status}: the disabled status for the button if available (else will be blank). + {icon}: the button icon as identified by browseIcon. + {label}: the button label as identified by browseLabel. + */ + btnBrowse?: string; + } -interface IFileUploadPreviewSettings { - image?: { width?: string; height?: string; }; - html?: { width?: string; height?: string; }; - text?: { width?: string; height?: string; }; - video?: { width?: string; height?: string; }; - audio?: { width?: string; height?: string; }; - flash?: { width?: string; height?: string; }; - object?: { width?: string; height?: string; }; - other?: { width?: string; height?: string; }; -} + interface PreviewTemplates { + /** + the preview template for image files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + image?: string; + /** + the preview template for text files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + {dialog}: Will be replaced with the JS code to launch the modal dialog. + {zoomTitle}: This will be replaced with the msgZoomTitle property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). + {zoomInd}: This will be replaced with the zoomIndicator property. This is the title that is displayed on hover of the zoom button (which on clicking will display the text file). + {heading}: This represents the modal dialog heading title. This will be replaced with the msgZoomModalHeading property. + */ + text?: string; + /** + the preview template for html files. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + html?: string; + /** + the preview template for video files (supported by HTML 5 video tag). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + video?: string; + /** + the preview template for audio files (supported by HTML 5 audio tag). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + audio?: string; + /** + the preview template for flash files (supported currently on webkit browsers). + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + flash?: string; + /** + the preview template for all other files - by default treated as object. To disable this behavior, configure the allowedPreviewTypes property. + The following tags will be parsed and replaced automatically: + {previewId}: will be replaced with the generated identifier for the preview frame container. + {data}: will be replaced with the data source for each preview type. + {width}: will be replaced with the width for the file type as set in previewSettings. + {height}: will be replaced with the height for the file type as set in previewSettings. + {caption}: will be replaced with the file name. + {type}: will be replaced with the file type. + */ + object?: string; + /** + this template is used ONLY for rendering the initialPreview markup content passed directly as a raw format. + The following tags will be parsed and replaced automatically: + {content}: will be replaced with the raw HTML markup as set in initialPreview.. + */ + generic?: string; + } -interface IFileUploadFileTypeSettings { - image: (vType: string, vName: string) => boolean; - html: (vType: string, vName: string) => boolean; - text: (vType: string, vName: string) => boolean; - video: (vType: string, vName: string) => boolean; - audio: (vType: string, vName: string) => boolean; - flash: (vType: string, vName: string) => boolean; - object: (vType: string, vName: string) => boolean; - other: (vType: string, vName: string) => boolean; -} + interface PreviewSettings { + image?: { width?: string; height?: string; }; + html?: { width?: string; height?: string; }; + text?: { width?: string; height?: string; }; + video?: { width?: string; height?: string; }; + audio?: { width?: string; height?: string; }; + flash?: { width?: string; height?: string; }; + object?: { width?: string; height?: string; }; + other?: { width?: string; height?: string; }; + } -interface IFileUploadPreviewFileIconSettings { - [key: string]: string; -} + interface FileTypeSettings { + image: (vType: string, vName: string) => boolean; + html: (vType: string, vName: string) => boolean; + text: (vType: string, vName: string) => boolean; + video: (vType: string, vName: string) => boolean; + audio: (vType: string, vName: string) => boolean; + flash: (vType: string, vName: string) => boolean; + object: (vType: string, vName: string) => boolean; + other: (vType: string, vName: string) => boolean; + } -interface IFileUploadPreviewFileExtSettings { - [key: string]: (ext: string) => boolean; -} + interface PreviewFileIconSettings { + [key: string]: string; + } -interface IFileUploadFileActionSettings { - /** - icon for remove button to be displayed in each file thumbnail. - */ - removeIcon: string; - /** - CSS class for the remove button in each file thumbnail. - */ - removeClass: string; - /** - title for remove button in each file thumbnail. - */ - removeTitle: string; - /** - icon for upload button to be displayed in each file thumbnail. - */ - uploadIcon: string; - /** - CSS class for the remove button in each file thumbnail. - */ - uploadClass: string; - /** - title for remove button in each file thumbnail. - */ - uploadTitle: string; - /** - an indicator (HTML markup) for new pending upload displayed in each file thumbnail. - */ - indicatorNew: string; - /** - an indicator (HTML markup) for successful upload displayed in each file thumbnail. - */ - indicatorSuccess: string; - /** - an indicator (HTML markup) for error in upload displayed in each file thumbnail. - */ - indicatorError: string; - /** - an indicator (HTML markup) for ongoing upload displayed in each file thumbnail. - */ - indicatorLoading: string; - /** - title to display on hover of indicator for new pending upload in each file thumbnail. - */ - indicatorNewTitle: string; - /** - title to display on hover of indicator for successful in each file thumbnail. - */ - indicatorSuccessTitle: string; - /** - title to display on hover of indicator for error in upload in each file thumbnail. - */ - indicatorErrorTitle: string; - /** - title to display on hover of indicator for ongoing upload in each file thumbnail. - */ - indicatorLoadingTitle: string; + interface PreviewFileExtSettings { + [key: string]: (ext: string) => boolean; + } + + interface FileActionSettings { + /** + icon for remove button to be displayed in each file thumbnail. + */ + removeIcon: string; + /** + CSS class for the remove button in each file thumbnail. + */ + removeClass: string; + /** + title for remove button in each file thumbnail. + */ + removeTitle: string; + /** + icon for upload button to be displayed in each file thumbnail. + */ + uploadIcon: string; + /** + CSS class for the remove button in each file thumbnail. + */ + uploadClass: string; + /** + title for remove button in each file thumbnail. + */ + uploadTitle: string; + /** + an indicator (HTML markup) for new pending upload displayed in each file thumbnail. + */ + indicatorNew: string; + /** + an indicator (HTML markup) for successful upload displayed in each file thumbnail. + */ + indicatorSuccess: string; + /** + an indicator (HTML markup) for error in upload displayed in each file thumbnail. + */ + indicatorError: string; + /** + an indicator (HTML markup) for ongoing upload displayed in each file thumbnail. + */ + indicatorLoading: string; + /** + title to display on hover of indicator for new pending upload in each file thumbnail. + */ + indicatorNewTitle: string; + /** + title to display on hover of indicator for successful in each file thumbnail. + */ + indicatorSuccessTitle: string; + /** + title to display on hover of indicator for error in upload in each file thumbnail. + */ + indicatorErrorTitle: string; + /** + title to display on hover of indicator for ongoing upload in each file thumbnail. + */ + indicatorLoadingTitle: string; + } } \ No newline at end of file From a1a15346625f2f8d009d6e468d3025b2813ddedd Mon Sep 17 00:00:00 2001 From: CheCoxshall Date: Fri, 1 Apr 2016 22:31:39 +0100 Subject: [PATCH 0161/1850] Added JQuery Reference --- bootstrap-fileinput/bootstrap-fileinput.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bootstrap-fileinput/bootstrap-fileinput.d.ts b/bootstrap-fileinput/bootstrap-fileinput.d.ts index e9d6f0e0d3..fadfadd612 100644 --- a/bootstrap-fileinput/bootstrap-fileinput.d.ts +++ b/bootstrap-fileinput/bootstrap-fileinput.d.ts @@ -3,6 +3,8 @@ // Definitions by: Ché Coxshall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + interface JQuery { fileinput: (options?: BootstrapFileInput.FileInputOptions) => JQuery; } From e626d8edbf41afb52335d64aa662092cd9e6518e Mon Sep 17 00:00:00 2001 From: Pavel Hlobil Date: Fri, 1 Apr 2016 20:43:35 -0400 Subject: [PATCH 0162/1850] Update google.maps.d.ts fix indentation update MapOptions interface --- googlemaps/google.maps.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 65776131d5..b77e665c28 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -30,7 +30,8 @@ THE SOFTWARE. declare namespace google.maps { /***** Map *****/ export class Map extends MVCObject { - constructor(mapDiv: Element, opts?: MapOptions);fitBounds(bounds: LatLngBounds): void; + constructor(mapDiv: Element, opts?: MapOptions); + fitBounds(bounds: LatLngBounds): void; getBounds(): LatLngBounds; getCenter(): LatLng; getDiv(): Element; @@ -58,7 +59,7 @@ declare namespace google.maps { export interface MapOptions { backgroundColor?: string; - center?: LatLng; + center?: LatLng|LatLngLiteral; disableDefaultUI?: boolean; disableDoubleClickZoom?: boolean; draggable?: boolean; From b194beaf9dace52cdb14e89698becf042808ec59 Mon Sep 17 00:00:00 2001 From: Eric Wendelin Date: Fri, 1 Apr 2016 18:52:47 -0700 Subject: [PATCH 0163/1850] Add definitions for error-stack-parser --- .../error-stack-parser-tests.ts | 3 +++ error-stack-parser/error-stack-parser.d.ts | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 error-stack-parser/error-stack-parser-tests.ts create mode 100644 error-stack-parser/error-stack-parser.d.ts diff --git a/error-stack-parser/error-stack-parser-tests.ts b/error-stack-parser/error-stack-parser-tests.ts new file mode 100644 index 0000000000..b0fa8e4cc3 --- /dev/null +++ b/error-stack-parser/error-stack-parser-tests.ts @@ -0,0 +1,3 @@ +/// + +ErrorStackParser.parse(new Error('Boom')); diff --git a/error-stack-parser/error-stack-parser.d.ts b/error-stack-parser/error-stack-parser.d.ts new file mode 100644 index 0000000000..ad722b0f2b --- /dev/null +++ b/error-stack-parser/error-stack-parser.d.ts @@ -0,0 +1,26 @@ +// Type definitions for ErrorStackParser v1.3.3 +// Project: https://github.com/stacktracejs/error-stack-parser +// Definitions by: Eric Wendelin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module ErrorStackParser { + export interface StackFrame { + constructor(functionName: string, args: any, fileName: string, lineNumber: number, columnNumber: number, source: string): StackFrame; + + functionName?: string; + args?: any[]; + fileName?: string; + lineNumber?: number; + columnNumber?: number; + source?: string; + toString(): string; + } + + /** + * Given an Error object, extract the most information from it. + * + * @param {Error} error object + * @return {Array} of StackFrames + */ + export function parse(error: Error): StackFrame[]; +} From f40e0562abcc25e51453ddbf1a6e7df251760265 Mon Sep 17 00:00:00 2001 From: Roman Golovanov Date: Sun, 3 Apr 2016 00:12:20 +0300 Subject: [PATCH 0164/1850] windows-1251 exports set as default --- windows-1251/windows-1251-tests.ts | 2 +- windows-1251/windows-1251.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/windows-1251/windows-1251-tests.ts b/windows-1251/windows-1251-tests.ts index ec231c6ef2..cb26957aed 100644 --- a/windows-1251/windows-1251-tests.ts +++ b/windows-1251/windows-1251-tests.ts @@ -1,6 +1,6 @@ /// -import * as windows1251 from 'windows-1251'; +import windows1251 from 'windows-1251'; var text:string = "some text", byteString:string, decodedText:string; diff --git a/windows-1251/windows-1251.d.ts b/windows-1251/windows-1251.d.ts index 48883637bd..a9e9c3656c 100644 --- a/windows-1251/windows-1251.d.ts +++ b/windows-1251/windows-1251.d.ts @@ -22,5 +22,5 @@ declare module 'windows-1251' { labels: string[]; } - export = windows1251; + export default windows1251; } From 70262bcb3e9d8b990d6f8b1d783ce66158cea760 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Sat, 2 Apr 2016 14:37:55 -0700 Subject: [PATCH 0165/1850] Improve Helmet's xssFilter options Made two improvements here: 1. `xssFilter` takes an object with a certain interface, not just any `Object`. 2. Changed the `@summary` documentation. --- helmet/helmet-tests.ts | 2 ++ helmet/helmet.d.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/helmet/helmet-tests.ts b/helmet/helmet-tests.ts index 83fd224a71..065d9bfa29 100644 --- a/helmet/helmet-tests.ts +++ b/helmet/helmet-tests.ts @@ -17,6 +17,8 @@ function helmetTest() { */ function xssFilterTest() { app.use(helmet.xssFilter()); + app.use(helmet.xssFilter({})); + app.use(helmet.xssFilter({ setOnOldIE: false })); app.use(helmet.xssFilter({ setOnOldIE: true })); } diff --git a/helmet/helmet.d.ts b/helmet/helmet.d.ts index 39f8311556..9e571ad246 100644 --- a/helmet/helmet.d.ts +++ b/helmet/helmet.d.ts @@ -24,7 +24,11 @@ declare module "helmet" { disableAndroid? : boolean; directives? : IHelmetCspDirectives } - + + interface IHelmetXssFilterConfiguration { + setOnOldIE? : boolean; + } + /** * @summary Interface for helmet class. * @interface @@ -82,11 +86,11 @@ declare module "helmet" { publicKeyPins(options ?: Object):express.RequestHandler; /** - * @summary Prevent Cross-site scripting attacks. + * @summary Mitigate cross-site scripting attacks with the "X-XSS-Protection" header. * @return {RequestHandler} The Request handler. * @param {Object} options The options. */ - xssFilter(options ?: Object):express.RequestHandler; + xssFilter(options ?: IHelmetXssFilterConfiguration):express.RequestHandler; /** * @summary Set policy around third-party content via headers From 71940aee07b2363bf6a042c4cf22daf091d05fde Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 00:57:03 +0300 Subject: [PATCH 0166/1850] added cropperjs definitions --- cropperjs/cropperjs.d.ts | 233 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 cropperjs/cropperjs.d.ts diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts new file mode 100644 index 0000000000..dedadc1a9f --- /dev/null +++ b/cropperjs/cropperjs.d.ts @@ -0,0 +1,233 @@ +// Type definitions for cropperjs +// Project: https://github.com/fengyuanchen/cropperjs +// Definitions by: https://github.com/stepancar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +declare module cropperjs { + export enum CropperViewMods { + CropBoxIsJustWithInTheContainer = 0, + CropBoxShouldBeWithInTheCanvas = 1, + CanvasShouldNotBeWithInTheContainer = 2, + ContainerSshouldBeWithInTheCanvas = 3 + } + export interface CropperOptions { + /** + * Define the view mode of the cropper. + * @default 0 + */ + viewMode?: CropperViewMods; + /** + * Define the dragging mode of the cropper. + * 'crop': create a new crop box + * 'move': move the canvas + * 'none': do nothing + */ + dragMode?: string; + /** + * Set the aspect ratio of the crop box. By default, the crop box is free ratio. + * @default Nan + */ + aspectRatio?: number; + /** + * The previous cropped data if you had stored, will be passed to setData method automatically. + * @default null + */ + data?: Object; + /** + * Add extra elements (containers) for previewing. + * Valid selector for Document.querySelectorAll + * @default '' + */ + preview?: string; + /** + * Rebuild the cropper when resize the window. + * @default true + */ + responsive?: boolean; + /** + * By default, the plugin will check the image origin, and if it is a cross-origin image, + * a crossOrigin attribute will be added to the image element and a timestamp will be added to the image url to reload the image for "getCroppedCanvas". + * By adding crossOrigin attribute to image will stop adding timestamp to image url, and stop reload of image. + * @default true + */ + checkCrossOrigin?: boolean; + /** + * Show the black modal above the image and under the crop box. + * @default true + */ + modal?: boolean; + /** + * Show the dashed lines above the crop box. + * @default true + */ + guides?: boolean; + /** + * Show the center indicator above the crop box. + * @default true + */ + center?: boolean; + /** + * Show the white modal above the crop box (highlight the crop box). + * @default true + */ + highlight?: boolean; + /** + * Show the grid background of the container. + * @default true + */ + background?: boolean; + /** + * Enable to crop the image automatically when initialize. + * @default true + */ + autoCrop?: boolean; + /** + * A number between 0 and 1. Define the automatic cropping area size (percentage). + * @default 0.8 (80% of the image) + */ + autoCropArea?: number; + /** + * Enable to move the image. + * @default true + */ + movable?: boolean; + /** + * Enable to rotate the image. + * @default true + */ + rotatable?: boolean; + /** + * Enable to scale the image. + * @default true + */ + scalable?: boolean; + /** + * Enable to zoom the image. + * @default true + */ + zoomable?: boolean; + /** + * Enable to zoom the image by dragging touch. + * @default true + */ + zoomOnTouch?: boolean; + /** + * Enable to zoom the image by wheeling mouse. + * @default true + */ + zoomOnWheel?: boolean; + /** + * Define zoom ratio when zoom the image by wheeling mouse. + * @default 0.1 + */ + wheelZoomRatio?: number; + /** + * Enable to move the crop box. + * @default true + */ + cropBoxMovable?: boolean; + /** + * Enable to resize the crop box. + * @default true + */ + cropBoxResizable?: boolean; + /** + * Enable to toggle drag mode between "crop" and "move" when click twice on the cropper. + * @default true + */ + toggleDragModeOnDblclick?: boolean; + /** + * The minimum width of the container + * @default 200 + */ + minContainerWidth?: number; + /** + * The minimum height of the container. + * @default 100 + */ + minContainerHeight?: number; + /** + * The minimum width of the canvas (image wrapper). + * @default 0 + */ + minCanvasWidth?: number; + /** + * The minimum height of the canvas (image wrapper). + * @default 0 + */ + minCanvasHeight?: number; + /** + * The minimum width of the crop box. + * @default 0 + */ + minCropBoxWidth?: number; + /** + * The minimum height of the crop box. + * @default 0 + */ + minCropBoxHeight?: number; + /** + * This function will be called when a cropper instance starts to load an image. + * Return false to prevent to build + * @default null + */ + build?: () => boolean; + /** + * This function will be called when a cropper instance has built completely. + * @default null + */ + built?: () => void; + } + export class Cropper { + constructor(element: HTMLImageElement, options: CropperOptions); + /** + * Show the crop box manually. + */ + crop(); + /** + * Clear the crop box. + */ + reset(); + /** + * Replace the image's src and rebuild the cropper. + * @param url A new image url + */ + replace(url: string); + /** + * Enable (unfreeze) the cropper. + */ + enable(); + /** + * Disable (freeze) the cropper + */ + disable(); + /** + * Destroy the cropper and remove the instance from the image. + */ + destroy(); + /** + * Move the canvas (image wrapper) with relative offsets. + * @param offsetX Moving size (px) in the horizontal direction. + * @param offsetY Moving size (px) in the vertical direction. + * If not present, its default value is offsetX. + */ + move(offsetX: number, offsetY?: number); + /** + * Move the canvas (image wrapper) to an absolute point. + * @param x The left value of the canvas + * @param y The top value of the canvas + * If not present, its default value is x. + */ + moveTo(x: number, y?: number); + /** + * Zoom the canvas (image wrapper) with a relative ratio. + * Zoom in: requires a positive number (ratio > 0) + * Zoom out: requires a negative number (ratio < 0) + */ + zoom(ratio: number); + + } +} +declare var Cropper: typeof cropperjs.Cropper; +declare module "cropperjs" { + export = Cropper; +} From 9e04937809c393e6269b919433c8ec497fc39419 Mon Sep 17 00:00:00 2001 From: Roman Golovanov Date: Sun, 3 Apr 2016 00:57:50 +0300 Subject: [PATCH 0167/1850] rollback last changes --- windows-1251/windows-1251-tests.ts | 2 +- windows-1251/windows-1251.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/windows-1251/windows-1251-tests.ts b/windows-1251/windows-1251-tests.ts index cb26957aed..ec231c6ef2 100644 --- a/windows-1251/windows-1251-tests.ts +++ b/windows-1251/windows-1251-tests.ts @@ -1,6 +1,6 @@ /// -import windows1251 from 'windows-1251'; +import * as windows1251 from 'windows-1251'; var text:string = "some text", byteString:string, decodedText:string; diff --git a/windows-1251/windows-1251.d.ts b/windows-1251/windows-1251.d.ts index a9e9c3656c..48883637bd 100644 --- a/windows-1251/windows-1251.d.ts +++ b/windows-1251/windows-1251.d.ts @@ -22,5 +22,5 @@ declare module 'windows-1251' { labels: string[]; } - export default windows1251; + export = windows1251; } From 9d69a75939c9c922faa6c887515663804a783cf8 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 01:01:49 +0300 Subject: [PATCH 0168/1850] added tests file --- cropperjs/cropperjs-tests.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 cropperjs/cropperjs-tests.ts diff --git a/cropperjs/cropperjs-tests.ts b/cropperjs/cropperjs-tests.ts new file mode 100644 index 0000000000..d328a12b4a --- /dev/null +++ b/cropperjs/cropperjs-tests.ts @@ -0,0 +1,2 @@ +/// +import * as Cropper from 'cropperjs'; From 27d93c4f10e7fecfd1f0d6b534a63dd73ae85495 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 01:09:13 +0300 Subject: [PATCH 0169/1850] minor fix --- cropperjs/cropperjs.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts index dedadc1a9f..641093773d 100644 --- a/cropperjs/cropperjs.d.ts +++ b/cropperjs/cropperjs.d.ts @@ -182,48 +182,48 @@ declare module cropperjs { /** * Show the crop box manually. */ - crop(); + crop(): void; /** * Clear the crop box. */ - reset(); + reset(): void; /** * Replace the image's src and rebuild the cropper. * @param url A new image url */ - replace(url: string); + replace(url: string): void; /** * Enable (unfreeze) the cropper. */ - enable(); + enable(): void; /** * Disable (freeze) the cropper */ - disable(); + disable(): void; /** * Destroy the cropper and remove the instance from the image. */ - destroy(); + destroy(): void; /** * Move the canvas (image wrapper) with relative offsets. * @param offsetX Moving size (px) in the horizontal direction. * @param offsetY Moving size (px) in the vertical direction. * If not present, its default value is offsetX. */ - move(offsetX: number, offsetY?: number); + move(offsetX: number, offsetY?: number): void; /** * Move the canvas (image wrapper) to an absolute point. * @param x The left value of the canvas * @param y The top value of the canvas * If not present, its default value is x. */ - moveTo(x: number, y?: number); + moveTo(x: number, y?: number): void; /** * Zoom the canvas (image wrapper) with a relative ratio. * Zoom in: requires a positive number (ratio > 0) * Zoom out: requires a negative number (ratio < 0) */ - zoom(ratio: number); + zoom(ratio: number): void; } } From b84efc26b4a84e16453b87007997e9c7ecdbb286 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 01:15:44 +0300 Subject: [PATCH 0170/1850] minor fix for header --- cropperjs/cropperjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts index 641093773d..f00c867f8e 100644 --- a/cropperjs/cropperjs.d.ts +++ b/cropperjs/cropperjs.d.ts @@ -1,6 +1,6 @@ // Type definitions for cropperjs // Project: https://github.com/fengyuanchen/cropperjs -// Definitions by: https://github.com/stepancar +// Definitions by: Stepan Mikhaylyuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module cropperjs { export enum CropperViewMods { From 5c80bce0dd1e1b7f3f5863e2bf8742b3aca05997 Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Sat, 2 Apr 2016 15:20:40 -0700 Subject: [PATCH 0171/1850] Improve Helmet contentSecurityPolicy definitions This change adds a number of additional options that `helmet.contentSecurityPolicy` can take. --- helmet/helmet-tests.ts | 61 +++++++++++++++++++++++++++--------------- helmet/helmet.d.ts | 29 +++++++++++++++----- 2 files changed, 62 insertions(+), 28 deletions(-) diff --git a/helmet/helmet-tests.ts b/helmet/helmet-tests.ts index 83fd224a71..48e4f2d9ae 100644 --- a/helmet/helmet-tests.ts +++ b/helmet/helmet-tests.ts @@ -21,37 +21,56 @@ function xssFilterTest() { } /** - * @summary Test for {@see helmet#csp} function + * @summary Test for {@see helmet#csp} function. */ function contentSecurityPolicyTest() { - - // taken directly from helmet-csp docs + const emptyArray: string[] = []; const config = { - // Specify directives as normal. directives: { - defaultSrc: ["'self'", 'default.com'], - scriptSrc: ["'self'", "'unsafe-inline'"], - styleSrc: ['style.com'], - imgSrc: ['img.com', 'data:'], - sandbox: ['allow-forms', 'allow-scripts'], - reportUri: '/report-violation', - - objectSrc: ["'self'"], // An empty array allows nothing through + baseUri: ['base.example.com'], + childSrc: ['child.example.com'], + connectSrc: ['connect.example.com'], + defaultSrc: ['*'], + fontSrc: ['font.example.com'], + formAction: ['formaction.example.com'], + frameAncestors: ["'none'"], + frameSrc: emptyArray, + imgSrc: ['images.example.com'], + mediaSrc: ['media.example.com'], + objectSrc: ['objects.example.com'], + pluginTypes: emptyArray, + reportUri: '/some-url', + sandbox: emptyArray, + scriptSrc: ['scripts.example.com', function (req: express.Request, res: express.Response) { + return "'nonce-abc123'"; + }], + styleSrc: ['css.example.com'] }, - - // Set to true if you only want browsers to report errors, not block them reportOnly: false, - - // Set to true if you want to blindly set all headers: Content-Security-Policy, - // X-WebKit-CSP, and X-Content-Security-Policy. setAllHeaders: false, - - // Set to true if you want to disable CSP on Android where it can be buggy. disableAndroid: false - } - app.use(helmet.csp()); + }; + + app.use(helmet.contentSecurityPolicy()); + app.use(helmet.contentSecurityPolicy({})); app.use(helmet.contentSecurityPolicy(config)); + app.use(helmet.contentSecurityPolicy({ + directives: { + defaultSrc: ["'self'"] + }, + setAllHeaders: true + })); + + app.use(helmet.csp()); + app.use(helmet.csp({})); + app.use(helmet.csp(config)); + app.use(helmet.csp({ + directives: { + defaultSrc: ["'self'"] + }, + setAllHeaders: true + })); } /** diff --git a/helmet/helmet.d.ts b/helmet/helmet.d.ts index 39f8311556..f209af0517 100644 --- a/helmet/helmet.d.ts +++ b/helmet/helmet.d.ts @@ -8,20 +8,35 @@ declare module "helmet" { import express = require("express"); + interface IHelmetCspDirectiveFunction { + (req: express.Request, res: express.Response): string; + } + type HelmetCspDirectiveValue = string | IHelmetCspDirectiveFunction; + interface IHelmetCspDirectives { - defaultSrc? : string[]; - scriptSrc? : string[]; - styleSrc? : string[]; - imgSrc? : string[]; - sandbox? : string[]; - reportUri? : string; - objectSrc? : string[]; + baseUri? : HelmetCspDirectiveValue[], + childSrc? : HelmetCspDirectiveValue[], + connectSrc? : HelmetCspDirectiveValue[], + defaultSrc? : HelmetCspDirectiveValue[], + fontSrc? : HelmetCspDirectiveValue[], + formAction? : HelmetCspDirectiveValue[], + frameAncestors? : HelmetCspDirectiveValue[], + frameSrc? : HelmetCspDirectiveValue[], + imgSrc? : HelmetCspDirectiveValue[], + mediaSrc? : HelmetCspDirectiveValue[], + objectSrc? : HelmetCspDirectiveValue[], + pluginTypes? : HelmetCspDirectiveValue[], + reportUri?: string, + sandbox? : HelmetCspDirectiveValue[], + scriptSrc? : HelmetCspDirectiveValue[], + styleSrc? : HelmetCspDirectiveValue[] } interface IHelmetCspConfiguration { reportOnly? : boolean; setAllHeaders? : boolean; disableAndroid? : boolean; + browserSniff?: boolean; directives? : IHelmetCspDirectives } From 9ce9c1b85ce3b36513876be392a6957b9745959d Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 03:44:10 +0300 Subject: [PATCH 0172/1850] added react-cropper definitions --- react-cropper/react-cropper.d.ts | 138 +++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 react-cropper/react-cropper.d.ts diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts new file mode 100644 index 0000000000..af62939c4d --- /dev/null +++ b/react-cropper/react-cropper.d.ts @@ -0,0 +1,138 @@ +// Type definitions for react-cropper +// Project: https://github.com/roadmanfong/react-cropper +// Definitions by: Stepan Mikhaylyuk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module 'react-cropper' { + const Cropper: typeof ReactCropper.ReactCropper; + export default Cropper; + export {Cropper}; +} + +declare namespace ReactCropper { + interface Data { + /** + * the offset left of the cropped area + */ + x: number; + /** + * the offset top of the cropped area + */ + y: number; + /** + * the width of the cropped area + */ + width: number; + /** + * the height of the cropped area + */ + height: number; + /** + * the rotated degrees of the image + */ + rotate: number; + /** + * the scaling factor to apply on the abscissa of the image + */ + scaleX: number; + /** + * the scaling factor to apply on the ordinate of the image + */ + scaleY: number; + } + export type Props = cropperjs.CropperOptions & __React.HTMLProps; + export class ReactCropper extends __React.Component { + /** + * Show the crop box manually. + */ + crop(): void; + /** + * Clear the crop box. + */ + reset(): void; + /** + * Replace the image's src and rebuild the cropper. + * @param url A new image url + */ + replace(url: string): void; + /** + * Enable (unfreeze) the cropper. + */ + enable(): void; + /** + * Disable (freeze) the cropper + */ + disable(): void; + /** + * Destroy the cropper and remove the instance from the image. + */ + destroy(): void; + /** + * Move the canvas (image wrapper) with relative offsets. + * @param offsetX Moving size (px) in the horizontal direction. + * @param offsetY Moving size (px) in the vertical direction. + * If not present, its default value is offsetX. + */ + move(offsetX: number, offsetY?: number): void; + /** + * Move the canvas (image wrapper) to an absolute point. + * @param x The left value of the canvas + * @param y The top value of the canvas + * If not present, its default value is x. + */ + moveTo(x: number, y?: number): void; + /** + * Zoom the canvas (image wrapper) with a relative ratio. + * Zoom in: requires a positive number (ratio > 0) + * Zoom out: requires a negative number (ratio < 0) + */ + zoom(ratio: number): void; + + /** + * Rotate the canvas (image wrapper) with a relative degree. + * Rotate right: requires a positive number (degree > 0) + * Rotate left: requires a negative number (degree < 0) + */ + rotate(degree: number): void; + + /** + * Clear the crop box. + */ + clear(): void; + + /** + * Output the cropped area position and size data (base on the original image). + */ + getData(rounded?: boolean): Data; + /** + * Change the cropped area position and size with new data (base on the original image). + */ + setData(data: Data): void; + /** + * + */ + getContainerData(): void; + + getImageData(): void; + + getCanvasData(): void; + + setCanvasData(data); + + getCropBoxData(): void; + + setCropBoxData(data): void; + + getCroppedCanvas(options?): void; + + setAspectRatio(aspectRatio): void; + + setDragMode(): void; + + on(eventname, callback): void; + } + +} From c41fbd4ccb33a3fdbfc08d85e40fadd782ab6d18 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 03:45:19 +0300 Subject: [PATCH 0173/1850] added react-croppper tests --- react-cropper/react-cropper-tests.tsx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 react-cropper/react-cropper-tests.tsx diff --git a/react-cropper/react-cropper-tests.tsx b/react-cropper/react-cropper-tests.tsx new file mode 100644 index 0000000000..05a11202c0 --- /dev/null +++ b/react-cropper/react-cropper-tests.tsx @@ -0,0 +1,25 @@ + +import * as React from 'react'; +import Cropper from 'react-cropper'; +// If you choose not to use import, you need to assign Cropper to default +// var Cropper = require('react-cropper').default + +class Demo extends React.Component<{}, {}> { + crop() { + // image in dataUrl + console.log((this.refs['cropper'] as any).getCroppedCanvas().toDataURL()); + } + + render() { + return ( + + ); + } +} From 0c69d72540de522af4a81a618bfbecc4b5b075db Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 03:49:06 +0300 Subject: [PATCH 0174/1850] Update react-cropper-tests.tsx --- react-cropper/react-cropper-tests.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/react-cropper/react-cropper-tests.tsx b/react-cropper/react-cropper-tests.tsx index 05a11202c0..4aef0fbefb 100644 --- a/react-cropper/react-cropper-tests.tsx +++ b/react-cropper/react-cropper-tests.tsx @@ -1,3 +1,6 @@ +/// +/// + import * as React from 'react'; import Cropper from 'react-cropper'; From 08715f48a7891ac36293d3632b1ee95c1a76afba Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 03:51:33 +0300 Subject: [PATCH 0175/1850] Update react-cropper.d.ts --- react-cropper/react-cropper.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts index af62939c4d..a10b82e6d1 100644 --- a/react-cropper/react-cropper.d.ts +++ b/react-cropper/react-cropper.d.ts @@ -120,19 +120,19 @@ declare namespace ReactCropper { getCanvasData(): void; - setCanvasData(data); + setCanvasData(data: any); getCropBoxData(): void; - setCropBoxData(data): void; + setCropBoxData(data: any): void; - getCroppedCanvas(options?): void; + getCroppedCanvas(options? any): void; - setAspectRatio(aspectRatio): void; + setAspectRatio(aspectRatio: number): void; setDragMode(): void; - on(eventname, callback): void; + on(eventname: string, callback: ()=> void): void; } } From dadc81ce91d8d9ebaf7660539b60def0e8f2546d Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 03:55:30 +0300 Subject: [PATCH 0176/1850] Update react-cropper.d.ts --- react-cropper/react-cropper.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts index a10b82e6d1..cc4b935bad 100644 --- a/react-cropper/react-cropper.d.ts +++ b/react-cropper/react-cropper.d.ts @@ -132,7 +132,7 @@ declare namespace ReactCropper { setDragMode(): void; - on(eventname: string, callback: ()=> void): void; + on(eventname: string, callback: (any?) => void): void; } } From 9b8a212bee798c2d9802f6f3ea72a6c2da0cf645 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 04:00:04 +0300 Subject: [PATCH 0177/1850] Update react-cropper.d.ts --- react-cropper/react-cropper.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts index cc4b935bad..58f7bd62f7 100644 --- a/react-cropper/react-cropper.d.ts +++ b/react-cropper/react-cropper.d.ts @@ -126,7 +126,7 @@ declare namespace ReactCropper { setCropBoxData(data: any): void; - getCroppedCanvas(options? any): void; + getCroppedCanvas(options?: any): void; setAspectRatio(aspectRatio: number): void; From 2f80f951163b54a33ac4ecd4a97ce729fb098382 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 04:03:59 +0300 Subject: [PATCH 0178/1850] Update react-cropper.d.ts --- react-cropper/react-cropper.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts index 58f7bd62f7..266794a2de 100644 --- a/react-cropper/react-cropper.d.ts +++ b/react-cropper/react-cropper.d.ts @@ -120,7 +120,7 @@ declare namespace ReactCropper { getCanvasData(): void; - setCanvasData(data: any); + setCanvasData(data: any): void; getCropBoxData(): void; @@ -132,7 +132,7 @@ declare namespace ReactCropper { setDragMode(): void; - on(eventname: string, callback: (any?) => void): void; + on(eventname: string, callback: () => void): void; } } From b505af545ad4bf6e97770396383bdee2ee5e7f9f Mon Sep 17 00:00:00 2001 From: Adam Goodwin Date: Sun, 3 Apr 2016 17:34:42 +1200 Subject: [PATCH 0179/1850] Changed the "series" property of the HighChartsNGConfig interface to be of type HighchartsIndividualSeriesOptions[]. --- highcharts-ng/highcharts-ng-tests.ts | 14 +++++++++++--- highcharts-ng/highcharts-ng.d.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/highcharts-ng/highcharts-ng-tests.ts b/highcharts-ng/highcharts-ng-tests.ts index 493d0f94ff..b781a5fb10 100644 --- a/highcharts-ng/highcharts-ng-tests.ts +++ b/highcharts-ng/highcharts-ng-tests.ts @@ -20,9 +20,17 @@ class AppController { }, plotOptions: {} }, - series: [{ - data: [10, 15, 12, 8, 7] - }], + series: [ + { + data: [10, 15, 12, 8, 7] + }, + { + data: [[0, 10], [1, 15], [2, 12], [3, 8], [4, 7]] + }, + { + data: [{ name: "A", y: 10 }, { name: "B", y: 15 }, { name: "C", y: 12 }, { name: "D", y: 8 }, { name: "E", y: 7 }] + } + ], title: { text: 'My Awesome Chart' }, diff --git a/highcharts-ng/highcharts-ng.d.ts b/highcharts-ng/highcharts-ng.d.ts index fc0d107b9c..e4440ea305 100644 --- a/highcharts-ng/highcharts-ng.d.ts +++ b/highcharts-ng/highcharts-ng.d.ts @@ -10,7 +10,7 @@ interface HighChartsNGConfig { //The below properties are watched separately for changes. //Series object (optional) - a list of series using normal highcharts series options. - series?: number[]|[number, number][]| HighchartsDataPoint[] | {data:number[];}[]; + series?: HighchartsIndividualSeriesOptions[]; //Title configuration (optional) title?: { text?: string; From 39264141f7878944174834bc614047cd288285f2 Mon Sep 17 00:00:00 2001 From: Arne Schubert Date: Sun, 3 Apr 2016 14:44:05 +0200 Subject: [PATCH 0180/1850] Add declaration for freeport --- freeport/freeport-tests.ts | 9 +++++++++ freeport/freeport.d.ts | 10 ++++++++++ 2 files changed, 19 insertions(+) create mode 100644 freeport/freeport-tests.ts create mode 100644 freeport/freeport.d.ts diff --git a/freeport/freeport-tests.ts b/freeport/freeport-tests.ts new file mode 100644 index 0000000000..fc53835a98 --- /dev/null +++ b/freeport/freeport-tests.ts @@ -0,0 +1,9 @@ +/// + +import freeport = require('freeport'); + +var num: number; + +freeport((err, made) => { + num = made; +}); diff --git a/freeport/freeport.d.ts b/freeport/freeport.d.ts new file mode 100644 index 0000000000..ced31149c1 --- /dev/null +++ b/freeport/freeport.d.ts @@ -0,0 +1,10 @@ +// Type definitions for freeport 1.0.5 +// Project: https://github.com/daaku/nodejs-freeport +// Definitions by: Arne Schubert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'freeport' { + function freeport(cb: (err: Error, port: number) => void): void; + + export = freeport; +} From 782fd9be1d1f7f4b8671b2a160acf845fd2bda2a Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 17:21:19 +0300 Subject: [PATCH 0181/1850] fixed inheritance structure --- react-cropper/react-cropper.d.ts | 109 ++++++++++++++++++------------- 1 file changed, 62 insertions(+), 47 deletions(-) diff --git a/react-cropper/react-cropper.d.ts b/react-cropper/react-cropper.d.ts index 266794a2de..11775d0187 100644 --- a/react-cropper/react-cropper.d.ts +++ b/react-cropper/react-cropper.d.ts @@ -7,69 +7,47 @@ /// declare module 'react-cropper' { - const Cropper: typeof ReactCropper.ReactCropper; - export default Cropper; - export {Cropper}; -} + import Data = cropperjs.Data; + import ContainerData = cropperjs.ContainerData; + import ImageData = cropperjs.ImageData; + import CanvasData = cropperjs.CanvasData; + import CropBoxData = cropperjs.CropBoxData; + import CroppedCanvasOptions = cropperjs.CroppedCanvasOptions; + type ReactCropperProps = cropperjs.CropperOptions & __React.HTMLProps; + + class ReactCropper extends __React.Component implements cropperjs.Cropper { -declare namespace ReactCropper { - interface Data { - /** - * the offset left of the cropped area - */ - x: number; - /** - * the offset top of the cropped area - */ - y: number; - /** - * the width of the cropped area - */ - width: number; - /** - * the height of the cropped area - */ - height: number; - /** - * the rotated degrees of the image - */ - rotate: number; - /** - * the scaling factor to apply on the abscissa of the image - */ - scaleX: number; - /** - * the scaling factor to apply on the ordinate of the image - */ - scaleY: number; - } - export type Props = cropperjs.CropperOptions & __React.HTMLProps; - export class ReactCropper extends __React.Component { /** * Show the crop box manually. */ crop(): void; + /** * Clear the crop box. */ reset(): void; + /** * Replace the image's src and rebuild the cropper. * @param url A new image url */ replace(url: string): void; + /** * Enable (unfreeze) the cropper. */ enable(): void; + /** * Disable (freeze) the cropper */ disable(): void; + /** * Destroy the cropper and remove the instance from the image. */ destroy(): void; + /** * Move the canvas (image wrapper) with relative offsets. * @param offsetX Moving size (px) in the horizontal direction. @@ -77,6 +55,7 @@ declare namespace ReactCropper { * If not present, its default value is offsetX. */ move(offsetX: number, offsetY?: number): void; + /** * Move the canvas (image wrapper) to an absolute point. * @param x The left value of the canvas @@ -84,6 +63,7 @@ declare namespace ReactCropper { * If not present, its default value is x. */ moveTo(x: number, y?: number): void; + /** * Zoom the canvas (image wrapper) with a relative ratio. * Zoom in: requires a positive number (ratio > 0) @@ -107,32 +87,67 @@ declare namespace ReactCropper { * Output the cropped area position and size data (base on the original image). */ getData(rounded?: boolean): Data; + /** * Change the cropped area position and size with new data (base on the original image). */ setData(data: Data): void; + /** - * + * Output the container size data. */ - getContainerData(): void; + getContainerData(): ContainerData; - getImageData(): void; + /** + * Output the image position, size and other related data. + */ + getImageData(): ImageData; - getCanvasData(): void; + /** + * Output the canvas (image wrapper) position and size data. + */ + getCanvasData(): CanvasData & { + /** + * the natural width of the canvas (read only) + */ + naturalWidth: number; + /** + * the natural height of the canvas (read only) + */ + naturalHeight: number; + }; - setCanvasData(data: any): void; + /** + * Change the canvas (image wrapper) position and size with new data. + */ + setCanvasData(data: CanvasData): void; - getCropBoxData(): void; + /** + * Output the crop box position and size data. + */ + getCropBoxData(): CropBoxData; - setCropBoxData(data: any): void; + /** + * Change the crop box position and size with new data. + */ + setCropBoxData(data: CropBoxData): void; - getCroppedCanvas(options?: any): void; + /** + * Get a canvas drawn the cropped image. + */ + getCroppedCanvas(options?: CroppedCanvasOptions): HTMLCanvasElement; + /** + * Change the aspect ratio of the crop box. + */ setAspectRatio(aspectRatio: number): void; - setDragMode(): void; + /** + * Change the drag mode. + */ + setDragMode(mode?: 'none' | 'crop' | 'move'): void; on(eventname: string, callback: () => void): void; } - + export default ReactCropper; } From 34496c7418accbfb6062e857cd0966bcd104b60a Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 17:22:13 +0300 Subject: [PATCH 0182/1850] fixed inheritance structure --- cropperjs/cropperjs.d.ts | 227 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 220 insertions(+), 7 deletions(-) diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts index f00c867f8e..2b8525c3d7 100644 --- a/cropperjs/cropperjs.d.ts +++ b/cropperjs/cropperjs.d.ts @@ -1,7 +1,3 @@ -// Type definitions for cropperjs -// Project: https://github.com/fengyuanchen/cropperjs -// Definitions by: Stepan Mikhaylyuk -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module cropperjs { export enum CropperViewMods { CropBoxIsJustWithInTheContainer = 0, @@ -177,33 +173,171 @@ declare module cropperjs { */ built?: () => void; } + interface Data { + /** + * the offset left of the cropped area + */ + x: number; + /** + * the offset top of the cropped area + */ + y: number; + /** + * the width of the cropped area + */ + width: number; + /** + * the height of the cropped area + */ + height: number; + /** + * the rotated degrees of the image + */ + rotate: number; + /** + * the scaling factor to apply on the abscissa of the image + */ + scaleX: number; + /** + * the scaling factor to apply on the ordinate of the image + */ + scaleY: number; + } + interface ContainerData { + /** + * The current width of the container + */ + width: number; + /** + * The current height of the container + */ + height: number; + } + interface CropBoxData { + /** + * the offset left of the crop box + */ + left: number; + /** + * the offset top of the crop box + */ + top: number; + /** + * the width of the crop box + */ + width: number; + /** + * the height of the crop box + */ + height: number; + } + interface CanvasData { + /** + * offset left of the canvas + */ + left: number; + /** + * new offset top of the canvas + */ + top: number; + /** + * new width of the canvas + */ + width: number; + /** + * new height of the canvas + */ + height: number; + } + interface ImageData { + /** + * the offset left of the image + */ + left: number; + /** + * the offset top of the image + */ + top: number; + /** + * the width of the image + */ + width: number; + /** + * the height of the image + */ + height: number; + /** + * the natural width of the image + */ + naturalWidth: number; + /** + * the natural height of the image + */ + naturalHeight: number; + /** + * the aspect ratio of the image + */ + aspectRatio: number; + /** + * the rotated degrees of the image if rotated + */ + rotate: number; + /** + * the scaling factor to apply on the abscissa of the image if scaled + */ + scaleX: number; + /** + * the scaling factor to apply on the ordinate of the image if scaled + */ + scaleY: number; + } + interface CroppedCanvasOptions { + /** + * the destination width of the output canvas + */ + width?: number; + /** + * the destination height of the output canvas + */ + height?: number; + /** + * a color to fill any alpha values in the output canvas + */ + fillColor?: string; + } export class Cropper { constructor(element: HTMLImageElement, options: CropperOptions); /** - * Show the crop box manually. - */ + * Show the crop box manually. + */ crop(): void; + /** * Clear the crop box. */ reset(): void; + /** * Replace the image's src and rebuild the cropper. * @param url A new image url */ replace(url: string): void; + /** * Enable (unfreeze) the cropper. */ enable(): void; + /** * Disable (freeze) the cropper */ disable(): void; + /** * Destroy the cropper and remove the instance from the image. */ destroy(): void; + /** * Move the canvas (image wrapper) with relative offsets. * @param offsetX Moving size (px) in the horizontal direction. @@ -211,6 +345,7 @@ declare module cropperjs { * If not present, its default value is offsetX. */ move(offsetX: number, offsetY?: number): void; + /** * Move the canvas (image wrapper) to an absolute point. * @param x The left value of the canvas @@ -218,6 +353,7 @@ declare module cropperjs { * If not present, its default value is x. */ moveTo(x: number, y?: number): void; + /** * Zoom the canvas (image wrapper) with a relative ratio. * Zoom in: requires a positive number (ratio > 0) @@ -225,9 +361,86 @@ declare module cropperjs { */ zoom(ratio: number): void; + /** + * Rotate the canvas (image wrapper) with a relative degree. + * Rotate right: requires a positive number (degree > 0) + * Rotate left: requires a negative number (degree < 0) + */ + rotate(degree: number): void; + + /** + * Clear the crop box. + */ + clear(): void; + + /** + * Output the cropped area position and size data (base on the original image). + */ + getData(rounded?: boolean): Data; + + /** + * Change the cropped area position and size with new data (base on the original image). + */ + setData(data: Data): void; + + /** + * Output the container size data. + */ + getContainerData(): ContainerData; + + /** + * Output the image position, size and other related data. + */ + getImageData(): ImageData; + + /** + * Output the canvas (image wrapper) position and size data. + */ + getCanvasData(): CanvasData & { + /** + * the natural width of the canvas (read only) + */ + naturalWidth: number; + /** + * the natural height of the canvas (read only) + */ + naturalHeight: number; + }; + + /** + * Change the canvas (image wrapper) position and size with new data. + */ + setCanvasData(data: CanvasData): void; + + /** + * Output the crop box position and size data. + */ + getCropBoxData(): CropBoxData; + + /** + * Change the crop box position and size with new data. + */ + setCropBoxData(data: CropBoxData): void; + + /** + * Get a canvas drawn the cropped image. + */ + getCroppedCanvas(options?: CroppedCanvasOptions): HTMLCanvasElement; + + /** + * Change the aspect ratio of the crop box. + */ + setAspectRatio(aspectRatio: number): void; + + /** + * Change the drag mode. + */ + setDragMode(mode?: 'none' | 'crop' | 'move'): void; + } } -declare var Cropper: typeof cropperjs.Cropper; + declare module "cropperjs" { + const Cropper: typeof cropperjs.Cropper; export = Cropper; } From 37789c1cc1d5cc5312853351bcf2c4bd18c00362 Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Sun, 3 Apr 2016 17:28:02 +0300 Subject: [PATCH 0183/1850] added header --- cropperjs/cropperjs.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cropperjs/cropperjs.d.ts b/cropperjs/cropperjs.d.ts index 2b8525c3d7..f2f8e861e5 100644 --- a/cropperjs/cropperjs.d.ts +++ b/cropperjs/cropperjs.d.ts @@ -1,3 +1,9 @@ +// Type definitions for cropperjs +// Project: https://github.com/fengyuanchen/cropperjs +// Definitions by: Stepan Mikhaylyuk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + declare module cropperjs { export enum CropperViewMods { CropBoxIsJustWithInTheContainer = 0, From de2bc3fcdb5ea5552c0ba700e48a6030cd08095b Mon Sep 17 00:00:00 2001 From: Markus Lanthaler Date: Sun, 3 Apr 2016 21:07:17 +0200 Subject: [PATCH 0184/1850] Fix incremental-dom typings --- incremental-dom/incremental-dom.d.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/incremental-dom/incremental-dom.d.ts b/incremental-dom/incremental-dom.d.ts index 57ff470cff..d463bce5a1 100644 --- a/incremental-dom/incremental-dom.d.ts +++ b/incremental-dom/incremental-dom.d.ts @@ -1,6 +1,6 @@ // Type definitions for Incremetal DOM // Project: https://github.com/google/incremental-dom -// Definitions by: Basarat Ali Syed +// Definitions by: Markus Lanthaler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "incremental-dom" { @@ -8,10 +8,11 @@ declare module "incremental-dom" { * Patches the document starting at el with the provided function. This function * may be called during an existing patch operation. * @param {!Element} el the element to patch - * @param {!function} fn A function containing elementOpen/elementClose/etc. + * @param {!function(T)} fn A function containing elementOpen/elementClose/etc. * calls that describe the DOM. + * @param {?T} data An argument passed to fn to represent DOM state. */ - export var patch: (el: Node, fn: Function) => void; + export var patch: (el: Node, fn: (data: T) => void, data?: T) => void; /** * Declares a virtual Element at the current location in the document. This From e094f3c7bc1c20021266c3f8d89ee6e77095abca Mon Sep 17 00:00:00 2001 From: Josh Olson Date: Sun, 3 Apr 2016 20:37:51 -0500 Subject: [PATCH 0185/1850] PIXI.Container#addChild() accepts rest parameter and returns first argument See implementation at https://github.com/pixijs/pixi.js/blob/master/src/core/display/Container.js#L112 --- pixi.js/pixi.js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixi.js/pixi.js.d.ts b/pixi.js/pixi.js.d.ts index 25df916052..179bf381ce 100644 --- a/pixi.js/pixi.js.d.ts +++ b/pixi.js/pixi.js.d.ts @@ -217,7 +217,7 @@ declare namespace PIXI { width: number; height: number; - addChild(child: DisplayObject): DisplayObject; + addChild(...child: DisplayObject[]): DisplayObject; addChildAt(child: DisplayObject, index: number): DisplayObject; swapChildren(child: DisplayObject, child2: DisplayObject): void; getChildIndex(child: DisplayObject): number; From ff0f1a4bd30f6070676e76a7b9c9adbc7bab57f9 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:34:53 +1000 Subject: [PATCH 0186/1850] added basic test file. --- revalidator/revalidator-test.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 revalidator/revalidator-test.ts diff --git a/revalidator/revalidator-test.ts b/revalidator/revalidator-test.ts new file mode 100644 index 0000000000..3ad56947dc --- /dev/null +++ b/revalidator/revalidator-test.ts @@ -0,0 +1,4 @@ + +import * as revalidator from 'revalidator'; + +// revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file From adcaa9534f785587096c787f98a990cb1bbb1072 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:35:41 +1000 Subject: [PATCH 0187/1850] Name update. --- revalidator/{revalidator-test.ts => revalidator-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename revalidator/{revalidator-test.ts => revalidator-tests.ts} (100%) diff --git a/revalidator/revalidator-test.ts b/revalidator/revalidator-tests.ts similarity index 100% rename from revalidator/revalidator-test.ts rename to revalidator/revalidator-tests.ts From e1b48ff99402b979d316472d1daeb2ce51061731 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:43:53 +1000 Subject: [PATCH 0188/1850] Update documentation spec. Update test to include ES5 typescript import. --- revalidator/revalidator-tests.ts | 3 +-- revalidator/revalidator.d.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/revalidator/revalidator-tests.ts b/revalidator/revalidator-tests.ts index 3ad56947dc..cc04ed882e 100644 --- a/revalidator/revalidator-tests.ts +++ b/revalidator/revalidator-tests.ts @@ -1,4 +1,3 @@ - -import * as revalidator from 'revalidator'; +/// // revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index b41e7cd03e..3d011f2f99 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,5 +1,5 @@ // Type definitions for revalidator 0.3.1 - +// Project: https://github.com/flatiron/revalidator // Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 177e37a21b894e7b84e480b1602e403de535b808 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:46:43 +1000 Subject: [PATCH 0189/1850] Removed white space in name. --- revalidator/revalidator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 3d011f2f99..93d2e105a5 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,6 +1,6 @@ // Type definitions for revalidator 0.3.1 // Project: https://github.com/flatiron/revalidator -// Definitions by: Jason Turner +// Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { From b171677b5a1d9090d6b39c602dcaf8ed5f44f4c4 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:49:00 +1000 Subject: [PATCH 0190/1850] whitespace fixup --- revalidator/revalidator.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 93d2e105a5..4b6511f959 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -1,6 +1,6 @@ // Type definitions for revalidator 0.3.1 // Project: https://github.com/flatiron/revalidator -// Definitions by: Jason Turner +// Definitions by: Jason Turner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module Revalidator { From 518321e8e56797447adcdae5942db0f3c3699030 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 12:59:02 +1000 Subject: [PATCH 0191/1850] Added basic schema information. --- revalidator/revalidator.d.ts | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index 4b6511f959..b06bf7cce9 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -5,7 +5,34 @@ declare module Revalidator { interface RevalidatorStatic { - validate(object: any, schema: any, options: any): any; + validate(object: any, schema: ISchema, options: any): IReturnMessage; + } + + interface IReturnMessage { + valid: boolean; + errors: string[]; + } + + interface ISchema { + required?: boolean; + type: string; + pattern?: any; + maxLength?: number; + minLength?: number; + minimum?: number; + maximum?: number; + allowEmpty: boolean; + exclusiveMinimum: number; + exclusiveMaximum?: number; + divisibleBy?: number; + minItems?: number; + maxItems?: number; + uniqueItems?: boolean; + enum?: any; + format?: string; + conform?: (data) => boolean; + depdendencies?: string; + } } From 2a6fd2e66684be68a5d0998829431c55e16a8c77 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 13:03:54 +1000 Subject: [PATCH 0192/1850] updated based on feedback. --- revalidator/revalidator-tests.ts | 2 +- revalidator/revalidator.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator-tests.ts b/revalidator/revalidator-tests.ts index cc04ed882e..b65c9f971b 100644 --- a/revalidator/revalidator-tests.ts +++ b/revalidator/revalidator-tests.ts @@ -1,3 +1,3 @@ /// -// revalidator.revalidate(values, this.state.validationSchema, null) \ No newline at end of file +revalidator.validate(null, null, null); \ No newline at end of file diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index b06bf7cce9..c1e03207b4 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -30,7 +30,7 @@ declare module Revalidator { uniqueItems?: boolean; enum?: any; format?: string; - conform?: (data) => boolean; + conform?: (data:any) => boolean; depdendencies?: string; } From 870676f6e21c10a2a23acfa285f79a66f7c74957 Mon Sep 17 00:00:00 2001 From: Bernd Paradies Date: Sun, 3 Apr 2016 20:32:13 -0700 Subject: [PATCH 0193/1850] Adding scrollTo to react-native's ScrollViewStatic --- react-native/react-native.d.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 617b9100a0..b7f19c4489 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -2768,7 +2768,21 @@ declare namespace __React { } interface ScrollViewStatic extends React.ComponentClass { - + /** + * Scrolls to a given x, y offset, either immediately or with a smooth animation. + * Syntax: + * + * scrollTo(options: {x: number = 0; y: number = 0; animated: boolean = true}) + * + * Note: The weird argument signature is due to the fact that, for historical reasons, + * the function also accepts separate arguments as as alternative to the options object. + * This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED. + */ + scrollTo( + y?: number | { x?: number, y?: number, animated?: boolean }, + x?: number, + animated?: boolean + ): void; } From 9a474d26f5dbed29d3ad93d80207356db090504a Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 4 Apr 2016 14:41:09 +1000 Subject: [PATCH 0194/1850] Updated error interface from simple strings. --- revalidator/revalidator.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/revalidator/revalidator.d.ts b/revalidator/revalidator.d.ts index c1e03207b4..63f492e9c3 100644 --- a/revalidator/revalidator.d.ts +++ b/revalidator/revalidator.d.ts @@ -8,9 +8,14 @@ declare module Revalidator { validate(object: any, schema: ISchema, options: any): IReturnMessage; } + interface IErrrorProperty { + property: string; + message: string; + } + interface IReturnMessage { valid: boolean; - errors: string[]; + errors: IErrrorProperty[]; } interface ISchema { @@ -40,4 +45,4 @@ declare var revalidator: Revalidator.RevalidatorStatic; declare module "revalidator" { export = revalidator; -} +} \ No newline at end of file From 194c294eaa059e773bd56e15dcaa70be6843c03a Mon Sep 17 00:00:00 2001 From: Emmanuel Surleau Date: Mon, 4 Apr 2016 09:26:34 +0200 Subject: [PATCH 0195/1850] [#8834] Several underscore "chain" methods return boolean values. They actually return _ChainSingle, not _Chain. --- underscore/underscore.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index ea32b7d948..7c88662149 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -5064,30 +5064,30 @@ interface _Chain { /** * @see _.all **/ - every(iterator?: _.ListIterator, context?: any): _Chain; + every(iterator?: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `any[]`. * @see _.any **/ - any(iterator?: _.ListIterator, context?: any): _Chain; + any(iterator?: _.ListIterator, context?: any): _ChainSingle; /** * @see _.any **/ - some(iterator?: _.ListIterator, context?: any): _Chain; + some(iterator?: _.ListIterator, context?: any): _ChainSingle; /** * Wrapped type `any[]`. * @see _.contains **/ - contains(value: T): _Chain; + contains(value: T): _ChainSingle; /** * Alias for 'contains'. * @see contains **/ - include(value: T): _Chain; + include(value: T): _ChainSingle; /** * Wrapped type `any[]`. From 1dd24c9c5cde4bb81a8404fea65ed0f3e8fff54e Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 4 Apr 2016 11:08:03 +0200 Subject: [PATCH 0196/1850] Update to Electron 0.37.4 --- github-electron/github-electron.d.ts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/github-electron/github-electron.d.ts b/github-electron/github-electron.d.ts index ee223e5cd3..9ae82d6988 100644 --- a/github-electron/github-electron.d.ts +++ b/github-electron/github-electron.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Electron v0.37.3 +// Type definitions for Electron v0.37.4 // Project: http://electron.atom.io/ // Definitions by: jedmao , rhysd , Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -244,6 +244,22 @@ declare namespace Electron { * Note: This is only implemented on OS X and Windows. */ clearRecentDocuments(): void; + /** + * Sets the current executable as the default handler for a protocol (aka URI scheme). + * Once registered, all links with your-protocol:// will be openend with the current executable. + * The whole link, including protocol, will be passed to your application as a parameter. + * + * Note: This is only implemented on OS X and Windows. + * On OS X, you can only register protocols that have been added to your app's info.plist. + */ + setAsDefaultProtocolClient(protocol: string): void; + /** + * Removes the current executable as the default handler for a protocol (aka URI scheme). + * + * Note: This API is only available on Windows. + * On OS X, removing the app will automatically remove the app as the default protocol handler. + */ + removeAsDefaultProtocolClient(protocol: string): void; /** * Adds tasks to the Tasks category of JumpList on Windows. * @@ -543,6 +559,11 @@ declare namespace Electron { * Note: This is only implemented on OS X. */ on(event: 'scroll-touch-end', listener: Function): this; + /** + * Emitted on 3-finger swipe. + * Note: This is only implemented on OS X. + */ + on(event: 'swipe', listener: (event: Event, direction: SwipeDirection) => void): this; on(event: string, listener: Function): this; constructor(options?: BrowserWindowOptions); /** @@ -962,6 +983,8 @@ declare namespace Electron { setIgnoreMouseEvents(ignore: boolean): void; } + type SwipeDirection = 'up' | 'right' | 'down' | 'left'; + type ThumbarButtonFlags = 'enabled' | 'disabled' | 'dismissonclick' | 'nobackground' | 'hidden' | 'noninteractive'; interface ThumbarButton { From bbdb88fc944bbfab85a67dc6c57701d59655bd3f Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Mon, 4 Apr 2016 13:45:53 +0200 Subject: [PATCH 0197/1850] Update polymer-ts to 0.1.25 Updated definitions for polymer-ts to latest 0.1.25 --- polymer-ts/polymer-ts.d.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/polymer-ts/polymer-ts.d.ts b/polymer-ts/polymer-ts.d.ts index 26ace2ac90..b14ff58c4c 100644 --- a/polymer-ts/polymer-ts.d.ts +++ b/polymer-ts/polymer-ts.d.ts @@ -1,4 +1,4 @@ -// Type definitions for PolymerTS 0.1.19 +// Type definitions for PolymerTS 0.1.25 // Project: https://github.com/nippur72/PolymerTS // Definitions by: Louis Grignon // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -20,7 +20,7 @@ declare namespace polymer { cancelAsync(handle: number): void; cancelDebouncer(jobName: string): void; classFollows(name: string, toElement: HTMLElement, fromElement: HTMLElement): void; - create(tag: string, props: Object): any; + create(tag: string, props?: Object): HTMLElement; debounce(jobName: string, callback: Function, wait?: number): void; deserialize(value: string, type: any): any; distributeContent(): void; @@ -33,13 +33,20 @@ declare namespace polymer { getContentChildren(slctr: string): any; getNativePrototype(tag: string): any; getPropertyInfo(property: string): any; - importHref(href: string, onload?: Function, onerror?: Function): any; + importHref(href: string, onload?: Function, onerror?: Function, optAsync?: boolean): any; instanceTemplate(template: any): any; isDebouncerActive(jobName: string): any; linkPaths(to: string, from: string): void; listen(node: Element, eventName: string, methodName: string): void; mixin(target: Object, source: Object): void; notifyPath(path: string, value: any, fromAbove?: any): void; + notifySplices(path: string, splices: { + index: number; + removed: Array; + addedCount: number; + object: Array; + type: "splice"; + }): void; pop(path: string): any; push(path: string, value: any): any; reflectPropertyToAttribute(name: string): void; @@ -47,10 +54,10 @@ declare namespace polymer { scopeSubtree(container: Element, shouldObserve: boolean): void; serialize(value: string): any; serializeValueToAttribute(value: any, attribute: string, node: Element): void; - set(path: string, value: any, root?: Object): any; + set(path: string | Array, value: any, root?: Object): any; setScrollDirection(direction: string, node: HTMLElement): void; shift(path: string, value: any): any; - splice(path: string, start: number, deleteCount: number): any; + splice(path: string, start: number, deleteCount: number, ...items: any[]): any; toggleAttribute(name: string, bool: boolean, node?: HTMLElement): void; toggleClass(name: string, bool: boolean, node?: HTMLElement): void; transform(transform: string, node?: HTMLElement): void; From 71cd74b4abdfd05254a751ae1cc855dbf232257f Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Mon, 4 Apr 2016 17:24:21 +0300 Subject: [PATCH 0198/1850] Added source in ConnectionError. --- signalr/signalr.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 9b0131f6cb..6fe6b87896 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -180,6 +180,7 @@ declare namespace SignalR { interface ConnectionError extends Error { context: ConnectionErrorContext; transport?: string; + source?: string; } interface Connection { From a43a091139ec5ea466b0ee5e86a36712dc827d80 Mon Sep 17 00:00:00 2001 From: Graham Mendick Date: Mon, 4 Apr 2016 15:46:40 +0100 Subject: [PATCH 0199/1850] Updated typings and tests for Navigation 2.0.0 --- navigation/navigation-tests.ts | 207 ++--- navigation/navigation.d.ts | 1405 +++++++++----------------------- 2 files changed, 477 insertions(+), 1135 deletions(-) diff --git a/navigation/navigation-tests.ts b/navigation/navigation-tests.ts index ae03d46ca4..7d78cbe5ba 100644 --- a/navigation/navigation-tests.ts +++ b/navigation/navigation-tests.ts @@ -3,155 +3,88 @@ namespace NavigationTests { // History Manager class LogHistoryManager extends Navigation.HashHistoryManager { - addHistory(state: Navigation.State, url: string) { + addHistory(url: string) { console.log('add history'); - super.addHistory(state, url); + super.addHistory(url, false); } } - - // Crumb Trail Persister - class LogCrumbTrailPersister extends Navigation.CrumbTrailPersister { - load(crumbTrail: string): string { - console.log('load'); - return crumbTrail; - } - - save(crumbTrail: string): string { - console.log('save'); - return crumbTrail; - } - } - - // State Router - class LogStateRouter extends Navigation.StateRouter { - getData(route: string): { state: Navigation.State; data: any } { - console.log('get data'); - return super.getData(route); - } - } - - // Settings - Navigation.settings.router = new LogStateRouter(); - Navigation.settings.historyManager = new LogHistoryManager(); - Navigation.settings.crumbTrailPersister = new LogCrumbTrailPersister(); - Navigation.settings.stateIdKey = 'state'; - + // Configuration - Navigation.StateInfoConfig.build([ - { key: 'home', initial: 'page', help: 'home.htm', states: [ - { key: 'page', route: '', help: 'page.htm' } - ]}, - { key: 'person', initial: 'list', states: [ - { key: 'list', route: ['people/{page}', 'people/{page}/sort/{sort}'], transitions: [ - { key: 'select', to: 'details' } - ], defaults: { page: 1 }, trackCrumbTrail: false }, - { key: 'details', route: 'person/{id}', trackTypes: false, defaultTypes: { id: 'number' } } - ]} - ]); - - // StateInfo - var dialogs = Navigation.StateInfoConfig.dialogs; - var home = dialogs['home']; - var homePage = home.states['page']; - var homeKey = home.key; - var homePageKey = homePage.key; - homePage = home.initial; - var person = dialogs['person']; - var personList = person.states['list']; - var personDetails = person.states['details']; - var personListSelect = personList.transitions['select']; - personList = personListSelect.parent; - personDetails = personListSelect.to; - var pageDefault = personList.defaults.page; - var idDefaultType = personDetails.defaultTypes.id; - - // StateNavigator - personList.dispose = () => {}; - personList.navigating = (data, url, navigate) => { + var config = [ + { key: 'people', route: ['people/{page}', 'people/{page}/sort/{sort}'], defaults: { page: 1 }, help: 'people.htm' }, + { key: 'person', route: 'person/{id}', trackTypes: false, defaultTypes: { id: 'number' }, trackCrumbTrail: true } + ]; + var stateNavigator = new Navigation.StateNavigator(config); + stateNavigator.configure(config, new LogHistoryManager()); + + // States + var states = stateNavigator.states; + var people = states['people']; + var person = states['person']; + var help = people['help']; + var pageDefault = people.defaults.page; + var idDefaultType = person.defaultTypes.id; + + // State Controller + people.dispose = () => {}; + people.navigating = (data, url, navigate) => { navigate([]); }; - personList.navigated = (data, asyncData) => {}; - personDetails.navigating = (data, url, navigate) => { + people.navigated = (data, asyncData) => {}; + person.navigating = (data, url, navigate) => { navigate(); }; - personDetails.navigated = (data) => {}; - - // State Handler - class LogStateHandler extends Navigation.StateHandler { - getNavigationLink(state: Navigation.State, data: any): string { - console.log('get navigation link'); - return super.getNavigationLink(state, data, { ids: [] }); - } - getNavigationData(state: Navigation.State, url: string): any { - console.log('get navigation data'); - super.getNavigationData(state, url, {}); - } - urlEncode(state: Navigation.State, key: string, val: string, queryString: boolean): string { - return queryString ? val.replace(/\s/g, '+') : super.urlEncode(state, key, val, queryString); - } - urlDecode(state: Navigation.State, key: string, val: string, queryString: boolean): string { - return queryString ? val.replace(/\+/g, ' ') : super.urlDecode(state, key, val, queryString); - } - } - homePage.stateHandler = new LogStateHandler(); - personList.stateHandler = new LogStateHandler(); - personDetails.stateHandler = new LogStateHandler(); - + person.navigated = (data) => {}; + person.urlEncode = function urlEncode(state: Navigation.State, key: string, val: string, queryString: boolean): string { + return queryString ? val.replace(/\s/g, '+') : encodeURIComponent(val); + } + person.urlDecode = function urlDecode(state: Navigation.State, key: string, val: string, queryString: boolean): string { + return queryString ? val.replace(/\+/g, ' ') : decodeURIComponent(val); + } + // Navigation Event - var navigationListener = + var navigationListener = (oldState: Navigation.State, state: Navigation.State, data: any) => { - Navigation.StateController.offNavigate(navigationListener); + stateNavigator.offNavigate(navigationListener); }; - Navigation.StateController.onNavigate(navigationListener); - + stateNavigator.onNavigate(navigationListener); + // Navigation - Navigation.start('home'); - Navigation.StateController.navigate('person'); - Navigation.StateController.navigate('person', null, Navigation.HistoryAction.Add); - Navigation.StateController.refresh(); - Navigation.StateController.refresh({ page: 3 }); - Navigation.StateController.refresh({ page: 2 }, Navigation.HistoryAction.Replace); - Navigation.StateController.navigate('select', { id: 10 }); - var canGoBack: boolean = Navigation.StateController.canNavigateBack(1); - Navigation.StateController.navigateBack(1); - Navigation.StateController.clearStateContext(); - + stateNavigator.navigate('people'); + stateNavigator.navigate('people', null, 'add'); + stateNavigator.refresh(); + stateNavigator.refresh({ page: 3 }); + stateNavigator.refresh({ page: 2 }, 'replace'); + stateNavigator.navigate('person', { id: 10 }); + var canGoBack: boolean = stateNavigator.canNavigateBack(1); + stateNavigator.navigateBack(1); + stateNavigator.stateContext.clear(); + // Navigation Link - var link = Navigation.StateController.getNavigationLink('person'); - link = Navigation.StateController.getRefreshLink(); - link = Navigation.StateController.getRefreshLink({ page: 2 }); - Navigation.StateController.navigateLink(link); - link = Navigation.StateController.getNavigationLink('select', { id: 10 }); - var nextDialog = Navigation.StateController.getNextState('select').parent; - person = nextDialog; - Navigation.StateController.navigateLink(link, false); - link = Navigation.StateController.getNavigationBackLink(1); - var crumb = Navigation.StateController.crumbs[0]; - link = crumb.navigationLink; - Navigation.StateController.navigateLink(link, true, Navigation.HistoryAction.None); - - // StateContext - Navigation.StateController.navigate('home'); - Navigation.StateController.navigate('person'); - home = Navigation.StateContext.previousDialog; - homePage = Navigation.StateContext.previousState; - person === Navigation.StateContext.dialog; - personList === Navigation.StateContext.state; - var url: string = Navigation.StateContext.url; - var title: string = Navigation.StateContext.title; - var page: number = Navigation.StateContext.data.page; - Navigation.StateController.refresh({ page: 2 }); - person = Navigation.StateContext.oldDialog; - personList = Navigation.StateContext.oldState; - page = Navigation.StateContext.oldData.page; - page = Navigation.StateContext.previousData.page; - + var link = stateNavigator.getNavigationLink('people'); + link = stateNavigator.getRefreshLink(); + link = stateNavigator.getRefreshLink({ page: 2 }); + stateNavigator.navigateLink(link); + link = stateNavigator.getNavigationLink('person', { id: 10 }); + stateNavigator.navigateLink(link, 'replace'); + link = stateNavigator.getNavigationBackLink(1); + var crumb = stateNavigator.stateContext.crumbs[0]; + link = crumb.url; + stateNavigator.navigateLink(link, 'none', true); + + // State Context + var state: Navigation.State = stateNavigator.stateContext.state; + var url: string = stateNavigator.stateContext.url; + var title: string = stateNavigator.stateContext.title; + var page: number = stateNavigator.stateContext.data.page; + state = stateNavigator.stateContext.oldState; + page = stateNavigator.stateContext.oldData.page; + state = stateNavigator.stateContext.previousState; + page = stateNavigator.stateContext.previousData.page; + // Navigation Data - var data = Navigation.StateContext.includeCurrentData({ sort: 'name' }, ['page']); - Navigation.StateController.refresh(data); - Navigation.StateContext.clear('sort'); - var data = Navigation.StateContext.includeCurrentData({ pageSize: 10 }); - Navigation.StateController.refresh(data); - Navigation.StateContext.clear(); - Navigation.StateController.refresh(); + var data = stateNavigator.stateContext.includeCurrentData({ sort: 'name' }, ['page']); + stateNavigator.refresh(data); + var data = stateNavigator.stateContext.includeCurrentData({ pageSize: 10 }); + stateNavigator.refresh(data); } diff --git a/navigation/navigation.d.ts b/navigation/navigation.d.ts index 2d4f27bcf0..60ff423fab 100644 --- a/navigation/navigation.d.ts +++ b/navigation/navigation.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Navigation 1.3.0 +// Type definitions for Navigation 2.0.0 // Project: http://grahammendick.github.io/navigation/ // Definitions by: Graham Mendick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,48 +8,11 @@ declare module 'navigation' { declare namespace Navigation { /** - * Defines a contract a class must implement in order to represent a - * logical grouping of child State elements. Navigating across different - * dialogs will initialise the crumb trail + * Defines a contract a class must implement in order to configure a State */ - interface IDialog { + interface StateInfo { /** - * Gets the State children - */ - states: TStates; - /** - * Gets the state to navigate to if the Key is passed as an action - * parameter to the StateController - */ - initial: TState; - /** - * Gets the key, unique across dialogs, which is passed as the action - * parameter to the StateController when navigating - */ - key: string; - /** - * Gets the textual description of the dialog - */ - title?: string; - /** - * Gets the additional dialog attributes - */ - [extras: string]: any; - } - - /** - * Defines a contract a class must implement in order to configure state - * information. A child of a Dialog element, it represents the endpoint of - * a navigation - */ - interface IState { - /** - * Gets the Transition children - */ - transitions?: TTransitions; - /** - * Gets the key, unique within a Parent, used by Dialog and Transition - * elements to specify navigation configuration + * Gets the unique key */ key: string; /** @@ -67,13 +30,11 @@ declare namespace Navigation { /** * Gets the route Url patterns */ - route: string | string[]; + route?: string | string[]; /** - * Gets a value that indicates whether to maintain crumb trail - * information e.g PreviousState. This can be used together with Route - * to produce user friendly Urls + * Gets a value that indicates whether to maintain the crumb trail */ - trackCrumbTrail?: boolean; + trackCrumbTrail?: boolean | string; /** * Gets a value that indicates whether NavigationData Types are * preserved when navigating @@ -86,89 +47,11 @@ declare namespace Navigation { } /** - * Defines a contract a class must implement in order to configure - * transition information. A child of a State element it represents a - * possible navigation from its Parent to a sibling State + * Represents a view and is the destination of a navigation */ - interface ITransition { + class State implements StateInfo { /** - * Gets the state to navigate to if the Key is passed as an action - * parameter to the StateController - */ - to: TState; - /** - * Gets the key, unique within a Parent, which is passed as the action - * parameter to the StateController when navigating - */ - key: string; - } - - /** - * Configures dialog information. Represents a logical grouping of child - * State elements. Navigating across different dialogs will initialise the - * crumb trail - */ - class Dialog implements IDialog { - /** - * Gets the State children by index - */ - _states: State[]; - /** - * Gets the State children - */ - states: { - [index: string]: State; - }; - /** - * Gets the number of the dialog - */ - index: number; - /** - * Gets the state to navigate to if the Key is passed as an action - * parameter to the StateController - */ - initial: State; - /** - * Gets the key, unique across dialogs, which is passed as the action - * parameter to the StateController when navigating - */ - key: string; - /** - * Gets the textual description of the dialog - */ - title: string; - } - - /** - * Configures state information. A child of a Dialog element, it - * represents the endpoint of a navigation - */ - class State implements IState<{ [index: string]: Transition; }> { - /** - * Gets the Transition children by index - */ - _transitions: Transition[]; - /** - * Gets the Transition children - */ - transitions: { - [index: string]: Transition; - }; - /** - * Gets the parent Dialog configuration item - */ - parent: Dialog; - /** - * Gets the number of the state within its Parent - */ - index: number; - /** - * Gets the unique identifier for this State - */ - id: string; - /** - * Gets the key, unique within a Parent, used by Dialog and Transition - * elements to specify navigation configuration + * Gets the unique key */ key: string; /** @@ -183,6 +66,10 @@ declare namespace Navigation { * Gets the formatted default NavigationData for this State */ formattedDefaults: any; + /** + * Gets the formatted default array NavigationData for this State + */ + formattedArrayDefaults: { [index: string]: string[]; }; /** * Gets the textual description of the state */ @@ -192,24 +79,20 @@ declare namespace Navigation { */ route: string | string[]; /** - * Gets a value that indicates whether to maintain crumb trail - * information e.g PreviousState. This can be used together with Route - * to produce user friendly Urls + * Gets a value that indicates whether to maintain the crumb trail */ trackCrumbTrail: boolean; + /** + * Gets the crumb trail key + */ + crumbTrailKey: string; /** * Gets a value that indicates whether NavigationData Types are * preserved when navigating */ trackTypes: boolean; /** - * Gets or sets the IStateHandler responsible for building and parsing - * navigation links to this State - */ - stateHandler: IStateHandler; - /** - * Called on the old State (this is not the same as the previous - * State) before navigating to a different State + * Called on the old State before navigating to a different State * @param state The new State * @param data The new NavigationData * @param url The new target location @@ -218,8 +101,7 @@ declare namespace Navigation { */ unloading: (state: State, data: any, url: string, unload: () => void, history?: boolean) => void; /** - * Called on the old State (this is not the same as the previous - * State) after navigating to a different State + * Called on the old State after navigating to a different State */ dispose: () => void; /** @@ -235,757 +117,7 @@ declare namespace Navigation { * @param navigate The function to call to continue to navigate * @param history A value indicating whether browser history was used */ - navigating: (data: any, url: string, navigate: (asyncData?: any) => void, history?: boolean) => void; - } - - /** - * Configures transition information. A child of a State element it - * represents a possible navigation from its Parent to a sibling State - */ - class Transition implements ITransition { - /** - * Gets the state to navigate to if the Key is passed as an action - * parameter to the StateController - */ - to: State; - /** - * Gets the parent State configuration item - */ - parent: State; - /** - * Gets the number of the transition within its Parent - */ - index: number; - /** - * Gets the key, unique within a Parent, which is passed as the action - * parameter to the StateController when navigating - */ - key: string; - } - - /** - * Provides static access to the Dialog, State and Transition configuration - */ - class StateInfoConfig { - /** - * Gets a collection of Dialog information, by index, with their child - * State information and grandchild Transition information - */ - static _dialogs: Dialog[]; - /** - * Gets a collection of Dialog information with their child State - * information and grandchild Transition information - */ - static dialogs: { - [index: string]: Dialog; - }; - /** - * Builds the Dialog, State and Transition configuration - * @param dialogs A collection of Dialog information with their child - * State information and grandchild Transition information - */ - static build(dialogs: IDialog[]>[]>[]): void; - } - - /** - * Determines the effect on browser history after a successful navigation - */ - enum HistoryAction { - /** - * Creates a new browser history entry - */ - Add = 0, - /** - * Changes the current browser history entry - */ - Replace = 1, - /** - * Leaves browser history unchanged - */ - None = 2, - } - - /** - * Defines a contract a class must implement in order to manage the browser - * Url - */ - interface IHistoryManager { - /** - * Gets or sets a value indicating whether to disable browser history - */ - disabled: boolean; - /** - * Registers browser history event listeners - */ - init(): any; - /** - * Adds browser history - * @param state The State navigated to - * @param url The current url - */ - addHistory(state: State, url: string): void; - /** - * Adds browser history - * @param state The State navigated to - * @param url The current url - * @param replace A value indicating whether to replace the current - * browser history entry - */ - addHistory(state: State, url: string, replace: boolean): void; - /** - * Gets the current location - */ - getCurrentUrl(): string; - /** - * Gets an Href from the url - */ - getHref(url: string): string; - /** - * Gets a Url from the anchor - */ - getUrl(anchor: HTMLAnchorElement): string; - } - - /** - * Manages history using the browser Url's hash. If used in a browser - * without the hashchange event or outside of a browser environment, then - * history is disabled - */ - class HashHistoryManager implements IHistoryManager { - /** - * Gets or sets a value indicating whether to disable browser history. - * Set to true if used in a browser without the hashchange event or - * outside of a browser environment - */ - disabled: boolean; - /** - * Gets or sets a value indicating whether to use '#' in place of '?' - * in Urls. Set to true for Internet explorer 6 and 7 support - */ - replaceQueryIdentifier: boolean; - /** - * Registers a listener for the hashchange event - */ - init(): void; - /** - * Sets the browser Url's hash to the url - * @param state The State navigated to - * @param url The current url - */ - addHistory(state: State, url: string): void; - /** - * Sets the browser Url's hash to the url - * @param state The State navigated to - * @param url The current url - * @param replace A value indicating whether to replace the current - * browser history entry - */ - addHistory(state: State, url: string, replace: boolean): void; - /** - * Gets the current location - */ - getCurrentUrl(): string; - /** - * Gets an Href from the url - */ - getHref(url: string): string; - /** - * Gets a Url from the anchor - */ - getUrl(anchor: HTMLAnchorElement): string; - } - - /** - * Manages history using the HTML5 history api. If used in a browser - * without the HTML5 history api or outside of a browser environment, then - * history is disabled - */ - class HTML5HistoryManager implements IHistoryManager { - /** - * Gets or sets a value indicating whether to disable browser history. - * Set to true if used in a browser without the HTML5 history api or - * outside of a browser environment - */ - disabled: boolean; - /** - * Registers a listener for the popstate event - */ - init(): void; - /** - * Sets the browser Url to the url using pushState - * @param state The State navigated to - * @param url The current url - */ - addHistory(state: State, url: string): void; - /** - * Sets the browser Url to the url using pushState - * @param state The State navigated to - * @param url The current url - * @param replace A value indicating whether to replace the current - * browser history entry - */ - addHistory(state: State, url: string, replace: boolean): void; - /** - * Gets the current location - */ - getCurrentUrl(): string; - /** - * Gets an Href from the url - */ - getHref(url: string): string; - /** - * Gets a Url from the anchor - */ - getUrl(anchor: HTMLAnchorElement): string; - } - - /** - * Provides the base functionality for crumb trail persistence mechanisms - */ - class CrumbTrailPersister { - /** - * Overridden by derived classes to return the persisted crumb trail - * @param crumbTrail The key, returned from the save function, to - * identify the persisted crumb trail - * @returns The crumb trail holding navigation and data information - */ - load(crumbTrail: string): string; - /** - * Overridden by derived classes to persist the crumb trail - * @param crumbTrail The crumb trail holding navigation and data - * information - * @returns The key to be passed to load function for crumb trail - * retrieval - */ - save(crumbTrail: string): string; - } - - /** - * Persists crumb trails, over a specified length, in localStorage. - * Prevents the creation of unmanageably long Urls. If used in a browser - * without localStorage or outside of a browser environment, then in memory - * storage is used - */ - class StorageCrumbTrailPersister extends CrumbTrailPersister { - /** - * Initializes a new instance of the StorageCrumbTrailPersister class - * with a maxLength of 500, historySize of 100 and localStorage as the - * storage mechanism - */ - constructor(); - /** - * Initializes a new instance of the StorageCrumbTrailPersister class - * with a historySize of 100 and localStorage as the storage mechanism - * @param maxLength The length above which any crumb trail will be - * stored in localStorage - */ - constructor(maxLength: number); - /** - * Initializes a new instance of the StorageCrumbTrailPersister class - * with localStorage as the storage mechanism - * @param maxLength The length above which any crumb trail will be - * stored in localStorage - * @param historySize The maximum number of crumb trails that will be - * held at any one time in localStorage - */ - constructor(maxLength: number, historySize: number); - /** - * Initializes a new instance of the StorageCrumbTrailPersister class - * @param maxLength The length above which any crumb trail will be - * stored in the storage - * @param historySize The maximum number of crumb trails that will be - * held at any one time in the storage - * @param storage The storage mechanism - */ - constructor(maxLength: number, historySize: number, storage: Storage); - /** - * Uses the crumbTrail parameter to determine whether to retrieve the - * crumb trail from storage. If retrieved from storage it may be null - * @param Key generated by the save function - * @returns Either the crumbTrail or the one retrieved value from - * storage; can be null if retrieved from storage - */ - load(crumbTrail: string): string; - /** - * If the crumbTrail is not over the maxLength it is returned. - * Otherwise the crumbTrail is stored in storage using a short key, - * unique within a given storage session. Also expunges old items from - * storage, if the historySize is breached when a new item is added - * @param crumbTrail The crumb trail to persist - * @returns crumbTrail or short, generated key pointing at crumbTrail - */ - save(crumbTrail: string): string; - } - - /** - * Defines a contract a class must implement in order to build and parse - * navigation links - */ - interface IStateHandler { - /** - * Gets a link that navigates to the state passing the data - * @param state The State to navigate to - * @param data The data to pass when navigating - * @returns The navigation link - */ - getNavigationLink(state: State, data: any): string; - /** - * Gets a link that navigates to the state passing the data - * @param state The State to navigate to - * @param data The data to pass when navigating - * @param queryStringData The query string array data - * @returns The navigation link - */ - getNavigationLink(state: State, data: any, queryStringData: { [index: string]: string[]; }): string; - /** - * Navigates to the url - * @param oldState The current State - * @param state The State to navigate to - * @param url The target location - */ - navigateLink(oldState: State, state: State, url: string): void; - /** - * Gets the data parsed from the url - * @param state The State navigated to - * @param url The current url - * @returns The navigation data - */ - getNavigationData(state: State, url: string): any; - /** - * Gets the data parsed from the url - * @param state The State navigated to - * @param url The current url - * @param queryStringData Stores query string keys - * @returns The navigation data - */ - getNavigationData(state: State, url: string, queryStringData: any): any; - /** - * Encodes the Url value - * @param state The State navigated to - * @param key The key of the navigation data item - * @param val The Url value of the navigation data item - * @param queryString A value indicating the Url value's location - */ - urlEncode?(state: State, key: string, val: string, queryString: boolean): string; - /** - * Decodes the Url value - * @param state The State navigated to - * @param key The key of the navigation data item - * @param val The Url value of the navigation data item - * @param queryString A value indicating the Url value's location - */ - urlDecode?(state: State, key: string, val: string, queryString: boolean): string; - /** - * Truncates the crumb trail - * @param The State navigated to - * @param The Crumb collection representing the crumb trail - * @returns Truncated crumb trail - */ - truncateCrumbTrail(state: State, crumbs: Crumb[]): Crumb[]; - } - - /** - * Represents one piece of the crumb trail and holds the information need - * to return to and recreate the State as previously visited. In a single - * crumb trail no two crumbs can have the same State but all must have the - * same Dialog - */ - class Crumb { - /** - * Gets the Context Data held at the time of navigating away from this - * State - */ - data: any; - /** - * Gets the configuration information associated with this navigation - */ - state: State; - /** - * Gets a value indicating whether the Crumb is the last in the crumb - * trail - */ - last: boolean; - /** - * Gets the State Title - */ - title: string; - /** - * Gets the hyperlink navigation to return to the State and pass the - * associated Data - */ - navigationLink: string; - /** - * Initializes a new instance of the Crumb class - * @param data The Context Data held at the time of navigating away - * from this State - * @param state The configuration information associated with this - * navigation - * @param link The hyperlink navigation to return to the State and pass - * the associated Data - * @param last A value indicating whether the Crumb is the last in the - * crumb trail - */ - constructor(data: any, state: State, link: string, last: boolean); - } - - /** - * Provides access to the Navigation Settings configuration - */ - class NavigationSettings { - /** - * Gets or sets the builder and parser of State routes - */ - router: IRouter; - /** - * Gets or sets the manager of the browser Url - */ - historyManager: IHistoryManager; - /** - * Gets or sets the crumb trail persistence mechanism - */ - crumbTrailPersister: CrumbTrailPersister; - /** - * Gets or sets the key that identifies the StateId - */ - stateIdKey: string; - /** - * Gets or sets the key that identifies the PreviousStateId - */ - previousStateIdKey: string; - /** - * Gets or sets the key that identifies the ReturnData - */ - returnDataKey: string; - /** - * Gets or sets the key that identifies the CrumbTrail - */ - crumbTrailKey: string; - /** - * Gets or sets the application path - */ - applicationPath: string; - /** - * Gets or sets a value indicating whether the PreviousStateId and - * ReturnData should be part of the CrumbTrail - */ - combineCrumbTrail: boolean; - /** - * Gets or sets a value indicating whether to track PreviousData when - * navigating back or refreshing and combineCrumbTrail is false - */ - trackAllPreviousData: boolean; - /** - * Gets or sets a value indicating whether arrays should be stored in - * a single query string parameter - */ - combineArray: boolean; - } - - /** - * Provides static properties for accessing context sensitive navigation - * information. Holds the current State and NavigationData. Also holds the - * previous State (this is not the same as the previous Crumb) - */ - class StateContext { - /** - * Gets the last State displayed before the current State - */ - static oldState: State; - /** - * Gets the parent of the OldState property - */ - static oldDialog: Dialog; - /** - * Gets the NavigationData for the last displayed State - */ - static oldData: any; - /** - * Gets the State navigated away from to reach the current State - */ - static previousState: State; - /** - * Gets the parent of the PreviousState property - */ - static previousDialog: Dialog; - /** - * Gets the NavigationData for the navigated away from State - */ - static previousData: any; - /** - * Gets the current State - */ - static state: State; - /** - * Gets the parent of the State property - */ - static dialog: Dialog; - /** - * Gets the NavigationData for the current State - */ - static data: any; - /** - * Gets the current Url - */ - static url: string; - /** - * Gets or sets the current title - */ - static title: string; - /** - * Combines the data with all the current NavigationData - * @param The data to add to the current NavigationData - * @returns The combined data - */ - static includeCurrentData(data: any): any; - /** - * Combines the data with a subset of the current NavigationData - * @param The data to add to the current NavigationData - * @returns The combined data - */ - static includeCurrentData(data: any, keys: string[]): any; - /** - * Removes all items from the NavigationData - */ - static clear(): void; - /** - * Removes a single item from the NavigationData - * @param The key of the item to remove - */ - static clear(key: string): void; - } - - /** - * Manages all navigation. These can be forward using an action parameter; - * backward via a Crumb; or refreshing the current State - */ - class StateController { - /** - * Gets a Crumb collection representing the crumb trail, ordered oldest - * Crumb first - */ - static crumbs: Crumb[]; - /** - * Sets the Context Data with the data returned from the current - * State's IStateHandler - * @param state The current State - * @param url The current Url - */ - static setStateContext(state: State, url: string): void; - /** - * Clears the Context Data - */ - static clearStateContext(): void; - /** - * Registers a navigate event listener - * @param handler The navigate event listener - */ - static onNavigate(handler: (oldState: State, state: State, data: any) => void): void; - /** - * Unregisters a navigate event listener - * @param handler The navigate event listener - */ - static offNavigate(handler: (oldState: State, state: State, data: any) => void): void; - /** - * Navigates to a State. Depending on the action will either navigate - * to the 'to' State of a Transition or the 'initial' State of a - * Dialog. It passes no NavigationData - * @param action The key of a child Transition or the key of a Dialog - * @throws action does not match the key of a child Transition or the - * key of a Dialog; or there is NavigationData that cannot be converted - * to a String - * @throws A mandatory route parameter has not been supplied a value - */ - static navigate(action: string): void; - /** - * Navigates to a State. Depending on the action will either navigate - * to the 'to' State of a Transition or the 'initial' State of a - * Dialog - * @param action The key of a child Transition or the key of a Dialog - * @param toData The NavigationData to be passed to the next State and - * stored in the StateContext - * @throws action does not match the key of a child Transition or the - * key of a Dialog; or there is NavigationData that cannot be converted - * to a String - * @throws A mandatory route parameter has not been supplied a value - */ - static navigate(action: string, toData: any): void; - /** - * Navigates to a State. Depending on the action will either navigate - * to the 'to' State of a Transition or the 'initial' State of a - * Dialog - * @param action The key of a child Transition or the key of a Dialog - * @param toData The NavigationData to be passed to the next State and - * stored in the StateContext - * @param A value determining the effect on browser history - * @throws action does not match the key of a child Transition or the - * key of a Dialog; or there is NavigationData that cannot be converted - * to a String - * @throws A mandatory route parameter has not been supplied a value - */ - static navigate(action: string, toData: any, historyAction: HistoryAction): void; - /** - * Gets a Url to navigate to a State. Depending on the action will - * either navigate to the 'to' State of a Transition or the 'initial' - * State of a Dialog. It passes no NavigationData - * @param action The key of a child Transition or the key of a Dialog - * @returns Url that will navigate to State specified in the action - * @throws action does not match the key of a child Transition or the - * key of a Dialog; or there is NavigationData that cannot be converted - * to a String - */ - static getNavigationLink(action: string): string; - /** - * Gets a Url to navigate to a State. Depending on the action will - * either navigate to the 'to' State of a Transition or the 'initial' - * State of a Dialog - * @param action The key of a child Transition or the key of a Dialog - * @param toData The NavigationData to be passed to the next State and - * stored in the StateContext - * @returns Url that will navigate to State specified in the action - * @throws action does not match the key of a child Transition or the - * key of a Dialog; or there is NavigationData that cannot be converted - * to a String - */ - static getNavigationLink(action: string, toData: any): string; - /** - * Determines if the distance specified is within the bounds of the - * crumb trail represented by the Crumbs collection - */ - static canNavigateBack(distance: number): boolean; - /** - * Navigates back to the Crumb contained in the crumb trail, - * represented by the Crumbs collection, as specified by the distance. - * In the crumb trail no two crumbs can have the same State but all - * must have the same Dialog - * @param distance Starting at 1, the number of Crumb steps to go back - * @throws canNavigateBack returns false for this distance - * @throws A mandatory route parameter has not been supplied a value - */ - static navigateBack(distance: number): void; - /** - * Navigates back to the Crumb contained in the crumb trail, - * represented by the Crumbs collection, as specified by the distance. - * In the crumb trail no two crumbs can have the same State but all - * must have the same Dialog - * @param distance Starting at 1, the number of Crumb steps to go back - * @param A value determining the effect on browser history - * @throws canNavigateBack returns false for this distance - * @throws A mandatory route parameter has not been supplied a value - */ - static navigateBack(distance: number, historyAction: HistoryAction): void; - /** - * Gets a Url to navigate to a Crumb contained in the crumb trail, - * represented by the Crumbs collection, as specified by the distance. - * In the crumb trail no two crumbs can have the same State but all - * must have the same Dialog - * @param distance Starting at 1, the number of Crumb steps to go back - * @throws canNavigateBack returns false for this distance - */ - static getNavigationBackLink(distance: number): string; - /** - * Navigates to the current State passing no NavigationData - * @throws A mandatory route parameter has not been supplied a value - */ - static refresh(): void; - /** - * Navigates to the current State - * @param toData The NavigationData to be passed to the current State - * and stored in the StateContext - * @throws There is NavigationData that cannot be converted to a String - * @throws A mandatory route parameter has not been supplied a value - */ - static refresh(toData: any): void; - /** - * Navigates to the current State - * @param toData The NavigationData to be passed to the current State - * and stored in the StateContext - * @param A value determining the effect on browser history - * @throws There is NavigationData that cannot be converted to a String - * @throws A mandatory route parameter has not been supplied a value - */ - static refresh(toData: any, historyAction: HistoryAction): void; - /** - * Gets a Url to navigate to the current State passing no - * NavigationData - */ - static getRefreshLink(): string; - /** - * Gets a Url to navigate to the current State - * @param toData The NavigationData to be passed to the current State - * and stored in the StateContext - * @returns Url that will navigate to the current State - * @throws There is NavigationData that cannot be converted to a String - */ - static getRefreshLink(toData: any): string; - /** - * Navigates to the url - * @param url The target location - */ - static navigateLink(url: string): void; - /** - * Navigates to the url - * @param url The target location - * @param history A value indicating whether browser history was used - */ - static navigateLink(url: string, history: boolean): void; - /** - * Navigates to the url - * @param url The target location - * @param history A value indicating whether browser history was used - * @param A value determining the effect on browser history - */ - static navigateLink(url: string, history: boolean, historyAction: HistoryAction): void; - /** - * Gets the next State. Depending on the action will either return the - * 'to' State of a Transition or the 'initial' State of a Dialog - * @param action The key of a child Transition or the key of a Dialog - * @throws action does not match the key of a child Transition or the - * key of a Dialog - */ - static getNextState(action: string): State; - } - - /** - * Implementation of IStateHandler that builds and parses navigation links - */ - class StateHandler implements IStateHandler { - /** - * Gets a link that navigates to the state passing the data - * @param state The State to navigate to - * @param data The data to pass when navigating - * @returns The navigation link - */ - getNavigationLink(state: State, data: any): string; - /** - * Gets a link that navigates to the state passing the data - * @param state The State to navigate to - * @param data The data to pass when navigating - * @param queryStringData The query string array data - * @returns The navigation link - */ - getNavigationLink(state: State, data: any, queryStringData: { [index: string]: string[]; }): string; - /** - * Navigates to the url - * @param oldState The current State - * @param state The State to navigate to - * @param url The target location - */ - navigateLink(oldState: State, state: State, url: string): void; - /** - * Gets the data parsed from the url - * @param state The State navigated to - * @param url The current url - * @returns The navigation data - */ - getNavigationData(state: State, url: string): any; - /** - * Gets the data parsed from the url - * @param state The State navigated to - * @param url The current url - * @param queryStringData Stores query string keys - * @returns The navigation data - */ - getNavigationData(state: State, url: string, queryStringData: any): any; + navigating: (data: any, url: string, navigate: (asyncData?: any) => void, history: boolean) => void; /** * Encodes the Url value * @param state The State navigated to @@ -1013,178 +145,455 @@ declare namespace Navigation { } /** - * Defines a contract a class must implement in order build and parse - * State routes + * Defines a contract a class must implement in order to manage the browser + * Url */ - interface IRouter { + interface HistoryManager { /** - * Gets the matching State and data for the route - * @param route The route to match - * @returns The matched State and data + * Gets or sets a value indicating whether to disable browser history */ - getData(route: string): { state: State; data: any; }; + disabled: boolean; /** - * Gets the matching route and data for the state and data - * @param The state to match - * @param The data to match - * @returns The matched route and data + * Registers browser history event listeners + * @param navigateHistory The history navigation event handler */ - getRoute(state: State, data: any): { route: string; data: any; }; + init(navigateHistory: () => void): void; /** - * Gets or sets a value indicating whether the route matching supports - * default parameter values + * Adds browser history + * @param url The current url + * @param replace A value indicating whether to replace the current + * browser history entry */ - supportsDefaults: boolean; + addHistory(url: string, replace: boolean): void; /** - * Registers all route configuration information - * @param dialogs Collection of Dialogs with their child State route - * information + * Gets the current location */ - addRoutes(dialogs: Dialog[]): void; + getCurrentUrl(): string; + /** + * Gets an Href from the url + */ + getHref(url: string): string; + /** + * Gets a Url from the anchor + */ + getUrl(anchor: HTMLAnchorElement): string; + /** + * Removes browser history event listeners + */ + stop(): void; } /** - * Implementation of IRouter that builds and parses State routes using the - * Navigation Router + * Manages history using the browser Url's hash. If used in a browser + * without the hashchange event or outside of a browser environment, then + * history is disabled */ - class StateRouter implements IRouter { + class HashHistoryManager implements HistoryManager { /** - * Gets the underlying Navigation Router + * Gets or sets a value indicating whether to disable browser history. + * Set to true if used in a browser without the hashchange event or + * outside of a browser environment */ - router: Router; + disabled: boolean; /** - * Gets true, indicating the underlying Navigation Router supports - * defaults + * Initializes a new instance of the HashHistoryManager class */ - supportsDefaults: boolean; + constructor(); /** - * Gets the matching State and data for the route - * @param route The route to match - * @returns The matched State and data + * Initializes a new instance of the HashHistoryManager class + * @param replaceQueryIdentifier a value indicating whether to use '#' + * in place of '?'. Set to true for Internet explorer 6 and 7 support */ - getData(route: string): { state: State; data: any; }; + constructor(replaceQueryIdentifier: boolean); /** - * Gets the matching route and data for the state and data - * @param The state to match - * @param The data to match - * @returns The matched route and data + * Registers a listener for the hashchange event + * @param navigateHistory The history navigation event handler */ - getRoute(state: State, data: any): { route: string; data: any; }; + init(navigateHistory: any): void; /** - * Registers all route configuration information with the underlying - * Navigation Router - * @param dialogs Collection of Dialogs with their child State route - * information + * Sets the browser Url's hash to the url + * @param url The current url + * @param replace A value indicating whether to replace the current + * browser history entry */ - addRoutes(dialogs: Dialog[]): void; + addHistory(url: string, replace: boolean): void; + /** + * Gets the current location + */ + getCurrentUrl(): string; + /** + * Gets an Href from the url + */ + getHref(url: string): string; + /** + * Gets a Url from the anchor + */ + getUrl(anchor: HTMLAnchorElement): string; + /** + * Removes a listener for the hashchange event + */ + stop(): void; } /** - * Holds information about a route + * Manages history using the HTML5 history api. If used in a browser + * without the HTML5 history api or outside of a browser environment, then + * history is disabled */ - class Route { + class HTML5HistoryManager implements HistoryManager { /** - * Gets the path pattern of a route + * Gets or sets a value indicating whether to disable browser history. + * Set to true if used in a browser without the HTML5 history api or + * outside of a browser environment */ - path: string; + disabled: boolean; /** - * Gets the default parameter values + * Initializes a new instance of the HTML5HistoryManager class */ - defaults: any; + constructor(); /** - * Gets the list of parameters + * Initializes a new instance of the HTML5HistoryManager class + * @param applicationPath The application path */ - params: { name: string; optional: boolean; }[]; + constructor(applicationPath: string); /** - * Initializes a new instance of the Route class - * @param path The route pattern + * Registers a listener for the popstate event + * @param navigateHistory The history navigation event handler */ - constructor(path: string); + init(navigateHistory: () => void): void; /** - * Initializes a new instance of the Route class - * @param path The route pattern - * @param defaults The default parameter values + * Sets the browser Url to the url using pushState + * @param url The current url + * @param replace A value indicating whether to replace the current + * browser history entry */ - constructor(path: string, defaults: any); + addHistory(url: string, replace: boolean): void; /** - * Gets the matching data for the path - * @param path The path to match - * @returns The matched data or null if there's no match + * Gets the current location */ - match(path: string): any; + getCurrentUrl(): string; /** - * Gets the matching data for the path - * @param path The path to match - * @param urlDecode The function that decodes the Url value - * @returns The matched data or null if there's no match + * Gets an Href from the url */ - match(path: string, urlDecode: (route: Route, name: string, val: string) => string): any; + getHref(url: string): string; /** - * Gets the route populated with default values - * @returns The built route + * Gets a Url from the anchor */ - build(): string; + getUrl(anchor: HTMLAnchorElement): string; /** - * Gets the route populated with data and default values - * @param data The data for the route parameters - * @returns The built route + * Removes a listener for the popstate event */ - build(data: any): string; - /** - * Gets the route populated with data and default values - * @param data The data for the route parameters - * @param urlEncode The function that encodes the Url value - * @returns The built route - */ - build(data: any, urlEncode: (route: Route, name: string, val: string) => string): string; + stop(): void; } /** - * The default Navigation router implementation + * Represents one piece of the crumb trail and holds the information need + * to return to and recreate the State as previously visited */ - class Router { + class Crumb { /** - * Registers a route - * @param path The route path - * @returns The parsed Route + * Gets the Context Data held at the time of navigating away from this + * State */ - addRoute(path: string): Route; + data: any; /** - * Registers a route with default parameters - * @param path The route path - * @param defaults The route parameter defaults - * @returns The parsed Route + * Gets the configuration information associated with this navigation */ - addRoute(path: string, defaults: any): Route; + state: State; /** - * Gets the matching route and data for the path - * @param path The path to match - * @returns The matched route and data + * Gets a value indicating whether the Crumb is the last in the crumb + * trail */ - match(path: string): { route: Route; data: any; }; + last: boolean; /** - * Gets the matching route and data for the path - * @param path The path to match - * @param urlDecode The function that decodes the Url value - * @returns The matched route and data + * Gets the State Title */ - match(path: string, urlDecode: (route: Route, name: string, val: string) => string): { route: Route; data: any; }; + title: string; /** - * Sorts the routes by the comparer - * @param compare The route comparer function + * Gets the link navigation to return to the State and pass the + * associated Data */ - sort(compare: (routeA: Route, routeB: Route) => number): void; + url: string; + /** + * Gets the link navigation without crumb trail to return to the State + * and pass the associated Data + */ + crumblessUrl: string; + /** + * Initializes a new instance of the Crumb class + * @param data The Context Data held at the time of navigating away + * from this State + * @param state The configuration information associated with this + * navigation + * @param link The link navigation to return to the State and pass the + * associated Data + * @param crumblessLink The link navigation without crumb trail to + * return to the State and pass the associated Data + * @param last A value indicating whether the Crumb is the last in the + * crumb trail + */ + constructor(data: any, state: State, link: string, crumblessLink: string, last: boolean); } /** - * Gets the Navigation settings + * Provides properties for accessing context sensitive navigation + * information. Holds the current State and NavigationData */ - export var settings: NavigationSettings; + class StateContext { + /** + * Gets the last State displayed before the current State + */ + oldState: State; + /** + * Gets the NavigationData for the last displayed State + */ + oldData: any; + /** + * Gets the State of the last Crumb in the crumb trail + */ + previousState: State; + /** + * Gets the NavigationData of the last Crumb in the crumb trail + */ + previousData: any; + /** + * Gets the current State + */ + state: State; + /** + * Gets the NavigationData for the current State + */ + data: any; + /** + * Gets the current Url + */ + url: string; + /** + * Gets or sets the current title + */ + title: string; + /** + * Gets a Crumb collection representing the crumb trail, ordered oldest + * Crumb first + */ + crumbs: Crumb[]; + /** + * Gets the crumb trail + */ + crumbTrail: string[]; + /** + * Gets the next crumb + */ + nextCrumb: Crumb; + /** + * Clears the Context Data + */ + clear(): void; + /** + * Combines the data with all the current NavigationData + * @param The data to add to the current NavigationData + * @returns The combined data + */ + includeCurrentData(data: any): any; + /** + * Combines the data with a subset of the current NavigationData + * @param The data to add to the current NavigationData + * @returns The combined data + */ + includeCurrentData(data: any, keys: string[]): any; + } /** - * Initializes the history manager and navigates to the current location. - * If used outside of a browser environment, pass in the Url to navigate to - * @param url If used outside of a browser, the url to navigate to + * Manages all navigation. These can be forward, backward or refreshing the + * current State */ - export var start: (url?: string) => void; + class StateNavigator { + /** + * Provides access to context sensitive navigation information + */ + stateContext: StateContext; + /** + * Gets the browser Url manager + */ + historyManager: HistoryManager; + /** + * Gets a list of States + */ + states: { [index: string]: State; }; + /** + * Initializes a new instance of the StateNavigator class + */ + constructor(); + /** + * Initializes a new instance of the StateNavigator class + * @param states A collection of States + */ + constructor(states: StateInfo[]); + /** + * Initializes a new instance of the StateNavigator class + * @param states A collection of States + * @param historyManager The manager of the browser Url + */ + constructor(states: StateInfo[], historyManager: HistoryManager); + /** + * Configures the StateNavigator + * @param stateInfos A collection of State Infos + */ + configure(stateInfos: StateInfo[]): void; + /** + * Configures the StateNavigator + * @param stateInfos A collection of State Infos + * @param historyManager The manager of the browser Url + */ + configure(stateInfos: StateInfo[], historyManager: HistoryManager): void; + /** + * Registers a navigate event listener + * @param handler The navigate event listener + */ + onNavigate(handler: (oldState: State, state: State, data: any) => void): void; + /** + * Unregisters a navigate event listener + * @param handler The navigate event listener + */ + offNavigate(handler: (oldState: State, state: State, data: any) => void): void; + /** + * Navigates to a State + * @param stateKey The key of a State + * @throws state does not match the key of a State or there is + * NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + navigate(stateKey: string): void; + /** + * Navigates to a State + * @param stateKey The key of a State + * @param navigationData The NavigationData to be passed to the next + * State and stored in the StateContext + * @throws state does not match the key of a State or there is + * NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + navigate(stateKey: string, navigationData: any): void; + /** + * Navigates to a State + * @param stateKey The key of a State + * @param navigationData The NavigationData to be passed to the next + * State and stored in the StateContext + * @param A value determining the effect on browser history + * @throws state does not match the key of a State or there is + * NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + navigate(stateKey: string, navigationData: any, historyAction: 'add' | 'replace' | 'none'): void; + /** + * Gets a Url to navigate to a State + * @param stateKey The key of a State + * @returns Url that will navigate to State specified in the action + * @throws state does not match the key of a State or there is + * NavigationData that cannot be converted to a String + */ + getNavigationLink(stateKey: string): string; + /** + * Gets a Url to navigate to a State + * @param stateKey The key of a State + * @param navigationData The NavigationData to be passed to the next + * State and stored in the StateContext + * @returns Url that will navigate to State specified in the action + * @throws state does not match the key of a State or there is + * NavigationData that cannot be converted to a String + */ + getNavigationLink(stateKey: string, navigationData: any): string; + /** + * Determines if the distance specified is within the bounds of the + * crumb trail represented by the Crumbs collection + */ + canNavigateBack(distance: number): boolean; + /** + * Navigates back along the crumb trail + * @param distance Starting at 1, the number of Crumb steps to go back + * @throws canNavigateBack returns false for this distance + * @throws A mandatory route parameter has not been supplied a value + */ + navigateBack(distance: number): void; + /** + * Navigates back along the crumb trail + * @param distance Starting at 1, the number of Crumb steps to go back + * @param A value determining the effect on browser history + * @throws canNavigateBack returns false for this distance + * @throws A mandatory route parameter has not been supplied a value + */ + navigateBack(distance: number, historyAction: 'add' | 'replace' | 'none'): void; + /** + * Gets a Url to navigate back along the crumb trail + * @param distance Starting at 1, the number of Crumb steps to go back + * @throws canNavigateBack returns false for this distance + */ + getNavigationBackLink(distance: number): string; + /** + * Navigates to the current State passing no NavigationData + * @throws A mandatory route parameter has not been supplied a value + */ + refresh(): void; + /** + * Navigates to the current State + * @param navigationData The NavigationData to be passed to the current + * State and stored in the StateContext + * @throws There is NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + refresh(navigationData: any): void; + /** + * Navigates to the current State + * @param navigationData The NavigationData to be passed to the current + * State and stored in the StateContext + * @param A value determining the effect on browser history + * @throws There is NavigationData that cannot be converted to a String + * @throws A mandatory route parameter has not been supplied a value + */ + refresh(navigationData: any, historyAction: 'add' | 'replace' | 'none'): void; + /** + * Gets a Url to navigate to the current State + */ + getRefreshLink(): string; + /** + * Gets a Url to navigate to the current State + * @param navigationData The NavigationData to be passed to the current + * State and stored in the StateContext + * @returns Url that will navigate to the current State + * @throws There is NavigationData that cannot be converted to a String + */ + getRefreshLink(navigationData: any): string; + /** + * Navigates to the url + * @param url The target location + */ + navigateLink(url: string): void; + /** + * Navigates to the url + * @param url The target location + * @param A value determining the effect on browser history + */ + navigateLink(url: string, historyAction: 'add' | 'replace' | 'none'): void; + /** + * Navigates to the url + * @param url The target location + * @param A value determining the effect on browser history + * @param history A value indicating whether browser history was used + */ + navigateLink(url: string, historyAction: 'add' | 'replace' | 'none', history: boolean): void; + /** + * Parses the url out into State and Navigation Data + * @param url The url to parse + */ + parseLink(url: string): { state: State; data: any; }; + /** + * Navigates to the current location + */ + start(): void; + /** + * Navigates to the passed in url + * @param url The url to navigate to + */ + start(url: string): void; + } } From f1a78bf40f54d3eddffe6e4ffbc60c236dab0b73 Mon Sep 17 00:00:00 2001 From: Graham Mendick Date: Mon, 4 Apr 2016 15:58:07 +0100 Subject: [PATCH 0200/1850] Removed implicit any warning --- navigation/navigation.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/navigation/navigation.d.ts b/navigation/navigation.d.ts index 60ff423fab..79dc718c90 100644 --- a/navigation/navigation.d.ts +++ b/navigation/navigation.d.ts @@ -91,6 +91,10 @@ declare namespace Navigation { * preserved when navigating */ trackTypes: boolean; + /** + * Gets the additional state attributes + */ + [extras: string]: any; /** * Called on the old State before navigating to a different State * @param state The new State From 9cbb925f4c48418488b48a51e36c7981559efbef Mon Sep 17 00:00:00 2001 From: Markus Wagner Date: Mon, 4 Apr 2016 18:22:41 +0200 Subject: [PATCH 0201/1850] missing cordova reference added --- .../cordova-plugin-x-socialsharing-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts index 6112e46066..e85c1cfb23 100755 --- a/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts +++ b/cordova-plugin-x-socialsharing/cordova-plugin-x-socialsharing-tests.ts @@ -1,4 +1,5 @@ -/// +/// +/// window.plugins.socialsharing.iPadPopupCoordinates = function () { return "100,100,200,300"; From f95f3fbd9c07682579bbf49529227350858a6464 Mon Sep 17 00:00:00 2001 From: SammyG4Free Date: Mon, 4 Apr 2016 10:06:56 -0700 Subject: [PATCH 0202/1850] Added customize button definition --- datatables-buttons/datatables-buttons.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/datatables-buttons/datatables-buttons.d.ts b/datatables-buttons/datatables-buttons.d.ts index fd047f0a8a..8b68213234 100644 --- a/datatables-buttons/datatables-buttons.d.ts +++ b/datatables-buttons/datatables-buttons.d.ts @@ -82,6 +82,7 @@ declare module DataTables { exportOptions?: ButtonExportOptions; autoPrint?: boolean; + customize?: FunctionButtonCustomize; } export interface FunctionButtonAvailable { @@ -109,5 +110,9 @@ declare module DataTables { export interface FunctionButtonAction { (e: any, dt: DataTables.DataTable, node: JQuery, config: any): void } + + export interface FunctionButtonCustomize { + (win: Window): void + } //#endregion "button-settings } \ No newline at end of file From 6dff9058d3968f2f7eea6b336fd930a1c39da575 Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Mon, 4 Apr 2016 21:01:38 +0300 Subject: [PATCH 0203/1850] Updated level and position types. --- react-notification-system/react-notification-system.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-notification-system/react-notification-system.d.ts b/react-notification-system/react-notification-system.d.ts index 82d5e9aa2d..4f51314680 100644 --- a/react-notification-system/react-notification-system.d.ts +++ b/react-notification-system/react-notification-system.d.ts @@ -22,8 +22,8 @@ declare namespace NotificationSystem { export interface Notification { title?: string; message?: string; - level?: string; - position?: string; + level?: "error" | "warning" | "info" | "success"; + position?: "tr" | "tl" | "tc" | "br" | "bl" | "bc"; autoDismiss?: number; dismissible?: boolean; action?: ActionObject; From efeda855964208cd1d174ba432cf33cd812fb9d1 Mon Sep 17 00:00:00 2001 From: Markus Lanthaler Date: Mon, 4 Apr 2016 22:35:47 +0200 Subject: [PATCH 0204/1850] Update author list --- incremental-dom/incremental-dom.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incremental-dom/incremental-dom.d.ts b/incremental-dom/incremental-dom.d.ts index d463bce5a1..0ab8adde73 100644 --- a/incremental-dom/incremental-dom.d.ts +++ b/incremental-dom/incremental-dom.d.ts @@ -1,6 +1,6 @@ // Type definitions for Incremetal DOM // Project: https://github.com/google/incremental-dom -// Definitions by: Markus Lanthaler +// Definitions by: Definitions by: Basarat Ali Syed , Markus Lanthaler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "incremental-dom" { From f0a8d77e37c6de6e18686573d40e54f6da0af41e Mon Sep 17 00:00:00 2001 From: Markus Lanthaler Date: Mon, 4 Apr 2016 22:36:13 +0200 Subject: [PATCH 0205/1850] Update author list, again :-) --- incremental-dom/incremental-dom.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/incremental-dom/incremental-dom.d.ts b/incremental-dom/incremental-dom.d.ts index 0ab8adde73..56fd84542f 100644 --- a/incremental-dom/incremental-dom.d.ts +++ b/incremental-dom/incremental-dom.d.ts @@ -1,6 +1,6 @@ // Type definitions for Incremetal DOM // Project: https://github.com/google/incremental-dom -// Definitions by: Definitions by: Basarat Ali Syed , Markus Lanthaler +// Definitions by: Basarat Ali Syed , Markus Lanthaler // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "incremental-dom" { From 13be4bad06dacc4c4243a50ad383c2a9e68b6e50 Mon Sep 17 00:00:00 2001 From: Stefan Loikkanen Date: Tue, 5 Apr 2016 11:44:35 +0200 Subject: [PATCH 0206/1850] Added optional callback for close function --- ws/ws.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ws/ws.d.ts b/ws/ws.d.ts index 83ba9dec92..d9a1338d21 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -110,7 +110,7 @@ declare module "ws" { constructor(options?: IServerOptions, callback?: Function); - close(): void; + close(cb?: () => {}): void; handleUpgrade(request: http.ServerRequest, socket: net.Socket, upgradeHead: Buffer, callback: (client: WebSocket) => void): void; From 9636ae9d5edb445644c2eb0b47769346d19fbb41 Mon Sep 17 00:00:00 2001 From: Josh Olson Date: Tue, 5 Apr 2016 15:49:31 -0500 Subject: [PATCH 0207/1850] Fix definitions of #bind/#unbind, merge overloads See https://github.com/RobertWHurst/KeyboardJS/blob/master/lib/keyboard.js#L54 for bind() See https://github.com/RobertWHurst/KeyboardJS/blob/master/lib/keyboard.js#L84 for unbind() --- keyboardjs/keyboardjs.d.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/keyboardjs/keyboardjs.d.ts b/keyboardjs/keyboardjs.d.ts index eb7129996b..e4247234ea 100644 --- a/keyboardjs/keyboardjs.d.ts +++ b/keyboardjs/keyboardjs.d.ts @@ -39,21 +39,17 @@ declare namespace keyboardjs { * @param keyCombo String of keys to be pressed to execute callbacks. * @param pressed Callback that gets executed when the keyComboState is 'pressed', can be null. * @param released Callback that gets executed when the keyComboState is 'released' + * @param preventRepeatByDefault Whether or not to prevent repeat by default. Defaults to false. */ - export function bind(keyCombo: string, pressed: Callback, released: Callback): void; - /** - * Binds a keyCombo to specific callback functions. - * @param keyCombo String of keys to be pressed to execute callbacks. - * @param pressed Callback that gets executed when the keyComboState is 'pressed' - */ - export function bind(keyCombo: string, pressed: Callback): void; - + export function bind(keyCombo: string | string[], pressed: Callback, released?: Callback, preventRepeatByDefault?: boolean): void; /** - * Unbinds a keyCombo + * Unbinds a keyCombo completely or only specific pressed & released callback combos. * @param keyCombo String of keys to be pressed to execute callbacks. + * @param pressed Callback that gets executed when the keyComboState is 'pressed', can be null. + * @param released Callback that gets executed when the keyComboState is 'released', can be null. */ - export function unbind(keyCombo: string): void; + export function unbind(keyCombo: string | string[], pressed?: Callback, released?: Callback): void; // ---------- Context ---------- // From 1e2ac487809ebee9dbf534ecc7dc3fea0b97fc77 Mon Sep 17 00:00:00 2001 From: Josh Olson Date: Tue, 5 Apr 2016 15:59:51 -0500 Subject: [PATCH 0208/1850] Allow callbacks to ignore event object --- keyboardjs/keyboardjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboardjs/keyboardjs.d.ts b/keyboardjs/keyboardjs.d.ts index e4247234ea..820101dd67 100644 --- a/keyboardjs/keyboardjs.d.ts +++ b/keyboardjs/keyboardjs.d.ts @@ -29,7 +29,7 @@ declare namespace keyboardjs { /** * Keyevent */ - (e: KeyEvent): void; + (e?: KeyEvent): void; } // ---------- Key Binding ---------- // From 62e1efd40289dc0e43e48a8da3f7f67081aba509 Mon Sep 17 00:00:00 2001 From: hellopao Date: Wed, 6 Apr 2016 10:31:21 +0800 Subject: [PATCH 0209/1850] add definitions for koa-favicon --- koa-favicon/koa-favicon-tests.ts | 11 ++++++++++ koa-favicon/koa-favicon.d.ts | 35 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 koa-favicon/koa-favicon-tests.ts create mode 100644 koa-favicon/koa-favicon.d.ts diff --git a/koa-favicon/koa-favicon-tests.ts b/koa-favicon/koa-favicon-tests.ts new file mode 100644 index 0000000000..5f2e0ac3f0 --- /dev/null +++ b/koa-favicon/koa-favicon-tests.ts @@ -0,0 +1,11 @@ +/// +/// + +import * as Koa from "koa"; +import favicon = require("koa-favicon"); + +const app = new Koa(); + +app.use(favicon(__dirname + "/public/favicon.ico")); + +app.listen(80) \ No newline at end of file diff --git a/koa-favicon/koa-favicon.d.ts b/koa-favicon/koa-favicon.d.ts new file mode 100644 index 0000000000..618683fc76 --- /dev/null +++ b/koa-favicon/koa-favicon.d.ts @@ -0,0 +1,35 @@ +// Type definitions for koa-favicon v2.x +// Project: https://github.com/koajs/favicon +// Definitions by: Jerry Chin +// Definitions: https://github.com/hellopao/DefinitelyTyped + +/* =================== USAGE =================== + + import favicon = require("koa-favicon"); + var Koa = require('koa'); + + var app = new Koa(); + app.use(favicon(__dirname + '/public/favicon.ico')); + + =============================================== */ + +/// + +declare module "koa-favicon" { + + import * as Koa from "koa"; + + /** + * Returns a middleware serving the favicon found on the given path. + */ + function favicon(path: string, options?: { + + /** + * cache-control max-age directive in ms, defaulting to 1 day. + */ + maxage?: number; + + }): { (ctx: Koa.Context, next?: () => any): any }; + + export = favicon; +} From c0ae122b176e7c0e4006c9245fd10de406acc5d3 Mon Sep 17 00:00:00 2001 From: Abd ar-Rahman Hamidi Date: Wed, 6 Apr 2016 12:11:39 +0500 Subject: [PATCH 0210/1850] Add overloading to `get` method e.g. ```ts $("a[href]").map((index, element) => $(element).attr("href")).get(); ``` it returns an array of strings --- cheerio/cheerio.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cheerio/cheerio.d.ts b/cheerio/cheerio.d.ts index 0f3e4282e0..72d2c6a2c2 100644 --- a/cheerio/cheerio.d.ts +++ b/cheerio/cheerio.d.ts @@ -106,6 +106,7 @@ interface Cheerio { eq(index: number): Cheerio; + get(): string[]; get(): CheerioElement[]; get(index: number): CheerioElement; From 9ccdf351691ced3c05c53fac0f5e443267df1edd Mon Sep 17 00:00:00 2001 From: Giedrius Grabauskas Date: Wed, 6 Apr 2016 14:13:24 +0300 Subject: [PATCH 0211/1850] SignalR Updated: Added ConnectionState const enum. * Added ConnectionState const enum. * Enum casing changed to Pascal case. * Fixed mistype --- signalr/signalr.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 6fe6b87896..ea150d71f9 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -8,6 +8,13 @@ declare namespace SignalR { + + const enum ConnectionState { + Connecting = 0, + Connected = 1, + Reconnecting = 2, + Disconnected = 4 + } interface AvailableEvents { onStart: string; From 7b28209e09c95aa4b92b52ae3c0b91f64780ac26 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Wed, 6 Apr 2016 07:15:33 -0400 Subject: [PATCH 0212/1850] Angular ui bootstrap: Update IModalSettings controller and resolve properties to not be any type * Update resolve and controller from any to something more explicit that matches docs for invoke, ui-router resolve, and angular-ui-bootstrap modal settings. * Add comments to clarify structure of array. * Add object in the union type for values of resolve object. --- angular-ui-bootstrap/angular-ui-bootstrap.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts index 64518c0cd6..29ad03485b 100644 --- a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts +++ b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts @@ -308,8 +308,9 @@ declare namespace angular.ui.bootstrap { /** * a controller for a modal instance - it can initialize scope used by modal. * A controller can be injected with `$modalInstance` + * If value is an array, it must be in Inline Array Annotation format for injection (strings followed by factory method) */ - controller?: any; + controller?: string | Function | Array; /** * an alternative to the controller-as syntax, matching the API of directive definitions. @@ -326,8 +327,9 @@ declare namespace angular.ui.bootstrap { /** * members that will be resolved and passed to the controller as locals; it is equivalent of the `resolve` property for AngularJS routes + * If property value is an array, it must be in Inline Array Annotation format for injection (strings followed by factory method) */ - resolve?: any; + resolve?: { [ key: string ]: string | Function | Array | Object }; /** * Set to false to disable animations on new modal/backdrop. Does not toggle animations for modals/backdrops that are already displayed. From 5217b3c97257eecc724aac5872ecd76e9ad68252 Mon Sep 17 00:00:00 2001 From: Elliott Davis Date: Wed, 6 Apr 2016 06:16:03 -0500 Subject: [PATCH 0213/1850] updated faker lorem to return words as string instead of array --- faker/faker-tests.ts | 4 ++-- faker/faker.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/faker/faker-tests.ts b/faker/faker-tests.ts index db953fd831..77f3a2c2ca 100644 --- a/faker/faker-tests.ts +++ b/faker/faker-tests.ts @@ -123,8 +123,8 @@ resultStr = faker.internet.mac(); resultStr = faker.internet.password(); resultStr = faker.internet.password(0, false, '#', 'foo'); -resultStrArr = faker.lorem.words(); -resultStrArr = faker.lorem.words(0); +resultStr = faker.lorem.words(); +resultStr = faker.lorem.words(0); resultStr = faker.lorem.sentence(); resultStr = faker.lorem.sentence(0, 0); resultStr = faker.lorem.sentences(); diff --git a/faker/faker.d.ts b/faker/faker.d.ts index fad4e45b2d..7860a72745 100644 --- a/faker/faker.d.ts +++ b/faker/faker.d.ts @@ -135,7 +135,7 @@ declare namespace Faker { }; lorem: { - words(num?: number): string[]; + words(num?: number): string; sentence(wordCount?: number, range?: number): string; sentences(sentenceCount?: number): string; paragraph(sentenceCount?: number): string; From 6590dbdd158ae17688ca782170111b5dba1e5fcc Mon Sep 17 00:00:00 2001 From: Stepan Mikhaylyuk Date: Wed, 6 Apr 2016 15:53:20 +0400 Subject: [PATCH 0214/1850] Created defintions for react-motion * started react motion definitions implementation * added tests * test from repo * updated definitions * chenaged to tsx * Update react-motion-tests.tsx * Update react-motion-tests.tsx --- react-motion/react-motion-tests.tsx | 17 ++++++ react-motion/react-motion.d.ts | 87 +++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 react-motion/react-motion-tests.tsx create mode 100644 react-motion/react-motion.d.ts diff --git a/react-motion/react-motion-tests.tsx b/react-motion/react-motion-tests.tsx new file mode 100644 index 0000000000..0ff53dae4a --- /dev/null +++ b/react-motion/react-motion-tests.tsx @@ -0,0 +1,17 @@ + +/// +/// + +import * as React from 'react'; +import {Motion, spring} from 'react-motion'; + + +class Root extends React.Component<{}, {}> { + render() { + return ( + + {(value: any) =>
{ value.x }
} +
+ ); + } +} diff --git a/react-motion/react-motion.d.ts b/react-motion/react-motion.d.ts new file mode 100644 index 0000000000..f868d084d2 --- /dev/null +++ b/react-motion/react-motion.d.ts @@ -0,0 +1,87 @@ +// Type definitions for react-motion +// Project: https://github.com/chenglou/react-motion +// Definitions by: Stepan Mikhaylyuk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "react-motion" { + import { Component } from 'react'; + + // your typical style object given in props. Maps to a number or a spring config + export type Style = { [key: string]: number | OpaqueConfig }; + // the interpolating style object, with the same keys as the above Style object, + // with the values mapped to numbers, naturally + export type PlainStyle = { [key: string]: number }; + // internal velocity object. Similar to PlainStyle, but whose numbers represent + // speed. Might be exposed one day. + export type Velocity = { [key: string]: number }; + interface SpringHelperConfig { + stiffness: number; + damping: number; + /** + * Specifies both the rounding of the interpolated value and the speed (internal). + */ + precision?: number; + // TODO: add onRest. Not public yet + } + + export interface OpaqueConfig { + val: number; + stiffness: number; + damping: number; + precision: number; + // TODO: add onRest. Not public yet + } + + interface MotionProps { + defaultStyle?: any; + style: any; + } + + export class Motion extends Component { } + + // === TransitionMotion === + interface TransitionStyle { + key: any; // unique ID to identify component across render animations + data?: any; // optional data you want to carry along the style, e.g. itemText + style: Style; // actual style you're passing + } + interface TransitionPlainStyle { + key: any; + data?: any; + // same as TransitionStyle, passed as argument to style/children function + style: PlainStyle; + } + type InterpolateFunction = (previousInterpolatedStyles?: Array) => Array; + type Styles = Array | InterpolateFunction; + interface TransitionProps { + defaultStyles?: Array; + styles: Styles; + children: (interpolatedStyles: Array) => __React.ReactElement; + willEnter?: (styleThatEntered: TransitionStyle) => PlainStyle; + willLeave?: (styleThatLeft: TransitionStyle) => Style; + } + export class TransitionMotion extends Component { } + + interface StaggeredMotionProps { + defaultStyles?: Array; + styles: (previousInterpolatedStyles?: Array) => Array + +
+ ) + } +} + + +Radium.TestMode.enable(); diff --git a/radium/radium.d.ts b/radium/radium.d.ts index 2e931c6e01..1989156877 100644 --- a/radium/radium.d.ts +++ b/radium/radium.d.ts @@ -112,7 +112,7 @@ declare module 'radium' { } // @Radium decorator function Radium(component: TElement): TElement; - function Radium(config: Radium.RadiumConfig): (component?: TElement) => TElement; + function Radium(config: Radium.RadiumConfig): (component?: any) => any; export = Radium; } From 1a9041ce005862fc52306f32f13ff7191719077f Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Tue, 5 Jul 2016 15:43:36 -0700 Subject: [PATCH 1200/1850] Update for ArcGIS API for JavaScript version 3.17 --- arcgis-js-api/arcgis-js-api.d.ts | 206 ++++++++++++++++++++++++------- 1 file changed, 162 insertions(+), 44 deletions(-) diff --git a/arcgis-js-api/arcgis-js-api.d.ts b/arcgis-js-api/arcgis-js-api.d.ts index 01d8a02c12..65765fbb09 100644 --- a/arcgis-js-api/arcgis-js-api.d.ts +++ b/arcgis-js-api/arcgis-js-api.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ArcGIS API for JavaScript v3.16 +// Type definitions for ArcGIS API for JavaScript v3.17 // Project: http://js.arcgis.com // Definitions by: Esri // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -18,7 +18,6 @@ declare module "esri" { import BasemapLayer = require("esri/dijit/BasemapLayer"); import Symbol = require("esri/symbols/Symbol"); import BookmarkItem = require("esri/dijit/BookmarkItem"); - import Units = require("esri/units"); import Color = require("esri/Color"); import LocationProviderBase = require("esri/tasks/locationproviders/LocationProviderBase"); import PictureMarkerSymbol = require("esri/symbols/PictureMarkerSymbol"); @@ -45,6 +44,7 @@ declare module "esri" { import QueryTask = require("esri/tasks/QueryTask"); import TextSymbol = require("esri/symbols/TextSymbol"); import StandardGeographyQueryTask = require("esri/tasks/geoenrichment/StandardGeographyQueryTask"); + import WMSLayerInfo = require("esri/layers/WMSLayerInfo"); import WMTSLayerInfo = require("esri/layers/WMTSLayerInfo"); export interface AGSMouseEvent extends MouseEvent { @@ -354,7 +354,7 @@ declare module "esri" { /** Radius of the circle. */ radius?: number; /** Unit of the radius. */ - radiusUnit?: Units; + radiusUnit?: string; } export interface CircleOptions2 { /** The center point of the circle. */ @@ -366,7 +366,7 @@ declare module "esri" { /** The radius of the circle. */ radius?: number; /** Unit of the radius. */ - radiusUnit?: Units; + radiusUnit?: string; } export interface ClassedColorSliderOptions { /** Data map containing renderer information. */ @@ -643,6 +643,8 @@ declare module "esri" { minStops?: number; /** When true, stops on the route are re-ordered to provide an optimal route. */ optimalRoute?: boolean; + /** If specified, this specifies the portal where the produced route layers are going to be stored and accessed. */ + portalUrl?: string; /** URL link to a custom print page. */ printPage?: string; /** If available, this print task is used to display an overview map of the route on the directions print page (Added at v3.11). */ @@ -677,6 +679,8 @@ declare module "esri" { showReturnToStartOption?: boolean; /** Display the 'Show Reverse Stops' button. */ showReverseStopsButton?: boolean; + /** Applicable if the widget works with a Network Analyst Server federated with ArcGIS Online or Portal. */ + showSaveButton?: boolean; /** Highlight the route segment when a directions step is clicked. */ showSegmentHighlight?: boolean; /** Display a popup with segment details when a direction step is clicked. */ @@ -911,6 +915,8 @@ declare module "esri" { layer: FeatureLayer; } export interface FeatureTableOptions { + /** The number of features a service will try to fetch. */ + batchCount?: number; /** Object defining the date options specifically for formatting date and time editors. */ dateOptions?: any; /** Sets the editing state for the FeatureTable. */ @@ -931,12 +937,18 @@ declare module "esri" { menuFunctions?: any[]; /** Attribute fields to include in the FeatureTable. */ outFields?: string[]; + /** Displays or hides the attachment column. */ + showAttachments?: boolean; /** Displays the data type of the field right under the field label. */ showDataTypes?: boolean; + /** Displays or hides total number of features and selected number of features in the grid header. */ + showFeatureCount?: boolean; /** Displays or hides the FeatureTable header. */ showGridHeader?: boolean; /** Displays or hides 'Options' drop-down menu of the FeatureTable. */ showGridMenu?: boolean; + /** Displays or hides the 'Statistics' option in column menus for numeric fields. */ + showStatistics?: boolean; /** Enables an interaction between the map and the feature table. */ syncSelection?: boolean; /** Enables pan/zoom to selected features on the map when the table in 'sync selection' mode. */ @@ -1187,10 +1199,20 @@ declare module "esri" { gdbVersion?: string; } export interface ImageServiceMeasureOptions { + /** The angular unit in which directions of line segments will be calculated. */ + angularUnit?: string; + /** The area unit in which areas of polygons will be calculated. */ + areaUnit?: string; + /** Defines whether to show the widget result in a popup or in the widget's result area when the widget has 'toolbar' layout. */ + displayMeasureResultInPopup?: boolean; /** Symbol to be used when drawing a polygon or extent. */ fillSymbol?: SimpleFillSymbol; /** Image service layer with which the toolbar is associated. */ layer: ArcGISImageServiceLayer; + /** Defines the layout of the widget. */ + layout?: string; + /** The linear unit in which height, length, or perimeters will be calculated. */ + linearUnit?: string; /** Symbol to be used when drawing a line. */ lineSymbol?: SimpleLineSymbol; /** Map instance with which the toolbar is associate. */ @@ -1402,9 +1424,9 @@ declare module "esri" { /** Flag for showing full list of units in the Location tool. */ advancedLocationUnits?: boolean; /** The default area unit for the measure area tool. */ - defaultAreaUnit?: Units; + defaultAreaUnit?: string; /** The default length unit for the measure distance tool. */ - defaultLengthUnit?: Units; + defaultLengthUnit?: string; /** Allows the user to immediately measure previously-created geometry on dijit creation. */ geometry?: Point | Polyline | Polygon; /** Line symbol used to draw the lines for the measure line and measure distance tools. */ @@ -2190,6 +2212,28 @@ declare module "esri" { /** The well-known ID of the spatial reference used by the WFSLayer. */ wkid?: string; } + export interface WMSLayerInfoOptions { + /** All the bounding extents defined for this layer. */ + allExtents?: Extent[]; + /** A description of the WMS layer. */ + description?: string; + /** The extent of the WMS Layer. */ + extent?: Extent; + /** The URL to the legend image. */ + legendURL?: string; + /** The name of the WMS layer. */ + name: string; + /** Returns true if the layer can be queried and the service supports GetFeatureInfo with either text/html or text/plain formats. */ + queryable?: boolean; + /** Indicates if this layer should be included in the popup. */ + showPopup?: boolean; + /** All the spatial references defined for this layer. */ + spatialReferences?: SpatialReference[]; + /** WMSLayerInfos of the layer's sub layers. */ + subLayers?: WMSLayerInfo[]; + /** The title of the WMS layer. */ + title?: string; + } export interface WMSLayerOptions { /** Specify the map image format, valid options are png,jpg,bmp,gif,svg. */ format?: string; @@ -3732,6 +3776,8 @@ declare module "esri/dijit/Directions" { maxStopsReached: boolean; /** Read-only: The graphic for the calculated route. */ mergedRouteGraphic: Graphic; + /** If specified, this specifies the portal where the produced route layers are going to be stored and accessed. */ + portalUrl: string; /** Routing parameters for the widget. */ routeParams: RouteParameters; /** Routing task for the widget. */ @@ -3744,6 +3790,8 @@ declare module "esri/dijit/Directions" { showClearButton: boolean; /** If true, the toggle button group allowing user to choose between Miles and Kilometers is shown. */ showMilesKilometersOption: boolean; + /** Applicable if the widget works with a Network Analyst Server federated with ArcGIS Online or Portal. */ + showSaveButton: boolean; /** If true, and supported by the service, then two toggle button groups are shown: one to allow user to choose between driving a car, a truck, or walking, and one more group to choose between fastest or shortest routes. */ showTravelModesOption: boolean; /** An array of graphics that define the stop locations along the route. */ @@ -3792,6 +3840,11 @@ declare module "esri/dijit/Directions" { * @param index The index of the route segment to highlight. */ highlightSegment(index: number): void; + /** + * Loads a stored route layer from either ArcGIS Online or Portal + * @param itemId The itemId of the stored route layer from either ArcGIS Online or Portal. + */ + loadRoute(itemId: string): any; /** * Remove the stop at the specified index. * @param index The index of the stop to remove. @@ -3801,6 +3854,16 @@ declare module "esri/dijit/Directions" { removeStops(): any; /** Resets the directions widget removing any directions, stops and map graphics. */ reset(): any; + /** + * Specify the language used for the directions. + * @param locale The locale used for the directions. + */ + setDirectionsLanguage(locale: string): any; + /** + * Specify the length units used for the directions widget. + * @param units The length units used for the directions widget. + */ + setDirectionsLengthUnits(units: string): any; /** * If widget runs with Travel Modes enabled, call this method to switch to particular Travel mode programmatically. * @param travelModeName Travel mode. @@ -3843,10 +3906,16 @@ declare module "esri/dijit/Directions" { on(type: "directions-finish", listener: (event: { result: RouteResult; target: Directions }) => void): esri.Handle; /** Fires when the route services starts to calculate the route. */ on(type: "directions-start", listener: (event: { target: Directions }) => void): esri.Handle; + /** Fires after a user clicks the Save or Save as New button and subsequently does not have permission to create an item in ArcGIS Online or Portal. */ + on(type: "feature-collection-created", listener: (event: { target: Directions }) => void): esri.Handle; /** Fires when the directions widget has fully loaded. */ on(type: "load", listener: (event: { target: Directions }) => void): esri.Handle; /** Fires when the widget starts or stops listening for map clicks. */ on(type: "map-click-active", listener: (event: { mapClickActive: boolean; target: Directions }) => void): esri.Handle; + /** Fires after a user clicks the Save or Save as New button for the first time in order to store a new route in either ArcGIS Online or Portal. */ + on(type: "route-item-created", listener: (event: { target: Directions }) => void): esri.Handle; + /** Fires when a existing route layer item is successfully updated in ArcGIS Online or Portal after user clicks the Save button. */ + on(type: "route-item-updated", listener: (event: { target: Directions }) => void): esri.Handle; /** Fired when you hover over a route segment in the directions display. */ on(type: "segment-highlight", listener: (event: { graphic: Graphic; target: Directions }) => void): esri.Handle; /** Fires when a route segment is selected in the directions display. */ @@ -3901,6 +3970,8 @@ declare module "esri/dijit/FeatureTable" { /** Creates an instance of the FeatureTable widget within the provided DOM node. */ class FeatureTable { + /** The number of features a service will try to fetch. */ + batchCount: number; /** Read-only: A reference to the column objects and their parameters. */ columns: any[]; /** Read-only: Reference to the dataStore used by the dGrid. */ @@ -3909,6 +3980,8 @@ declare module "esri/dijit/FeatureTable" { dateOptions: any; /** Sets the editing state for the FeatureTable. */ editable: boolean; + /** Event trigger(s) used to display editing interface for an individual cell. */ + editOn: string | any; /** Read-only: Number of records displayed in FeatureTable. */ featureCount: number; /** The featureLayer that the table is associated with. */ @@ -3937,12 +4010,18 @@ declare module "esri/dijit/FeatureTable" { selectedRowIds: number[]; /** Read-only: Each element in the array is an object that contains name-value pair of fields and field values associated with the selected rows. */ selectedRows: any[]; - /** Displays the data type of the field right under the field label in the column header. */ + /** Displays or hides the attachment column. */ + showAttachments: boolean; + /** Displays or hides the data type of the field right under the field label in the column header. */ showDataTypes: boolean; + /** Displays or hides total number of features and selected number of features in the grid header. */ + showFeatureCount: boolean; /** Displays or hides the FeatureTable header. */ showGridHeader: boolean; /** Displays or hides 'Options' drop-down menu of the FeatureTable. */ showGridMenu: boolean; + /** Displays or hides the 'Statistics' option in column menus for numeric fields. */ + showStatistics: boolean; /** Enables an interaction between the map and the feature table. */ syncSelection: boolean; /** Enables pans to selected features on the map when the table in 'sync selection' mode. */ @@ -3953,6 +4032,29 @@ declare module "esri/dijit/FeatureTable" { * @param srcNodeRef Reference or id of a HTML element that this dijit is rendered into. */ constructor(params: esri.FeatureTableOptions, srcNodeRef: Node | string); + /** Removes all current selections including subsets from filterSelectedRecords(). */ + clearSelection(): void; + /** Destroys the FeatureTable widget. */ + destroy(): void; + /** + * Allows users to see the sub-set of currently selected records (uses dGrid.query). + * @param toggle When true only a subset of currently selected features will be displayed in the FeatureTable. + */ + filterSelectedRecords(toggle: boolean): void; + /** + * Queries and gets selected features from the FeatureLayer instead of the store. + * @param id Array of row ids + */ + getFeatureDataById(id: number[]): any; + /** + * Gets row object by the row ID. + * @param id row ID + */ + getRowDataById(id: number): any; + /** Refreshes the data in the grid. */ + refresh(): void; + /** Resizes the grid's container. */ + resize(): void; /** Finalizes the creation of the widget. */ startup(): void; /** Fires when the grid column is resized. */ @@ -4286,8 +4388,13 @@ declare module "esri/dijit/ImageServiceMeasure" { /** * Creates an instance of the ImageServiceMeasure widget. * @param params An Object containing constructor options. + * @param srcNode Reference or id of the HTML element where the widget should be rendered. */ - constructor(params: esri.ImageServiceMeasureOptions); + constructor(params: esri.ImageServiceMeasureOptions, srcNode: Node | string); + /** Destroys the ImageServiceMeasure widget. */ + destroy(): void; + /** Finalizes the creation of the widget. */ + startup(): void; } export = ImageServiceMeasure; } @@ -4528,9 +4635,14 @@ declare module "esri/dijit/LayerSwipe" { declare module "esri/dijit/Legend" { import esri = require("esri"); + import Map = require("esri/map"); /** The legend dijit displays a label and symbol for some or all of the layers in the map. */ class Legend { + /** Specify a subset of the layers in the map to display in the legend. */ + layerInfos: any[]; + /** Reference to the map. */ + map: Map; /** * Creates a new Legend dijit. * @param params Parameters used to configure the dijit. @@ -4555,7 +4667,7 @@ declare module "esri/dijit/LocateButton" { import Symbol = require("esri/symbols/Symbol"); import Graphic = require("esri/graphic"); - /** LocateButton provides a simple button to locate and zoom to the users current location. */ + /** LocateButton provides a simple button to locate and zoom to the user's location. */ class LocateButton { /** Centers the map to the location when a new position is returned. */ centerAt: boolean; @@ -6767,7 +6879,7 @@ declare module "esri/dijit/editing/Add" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Add operations when editing. */ class Add extends OperationBase { /** * Create a new Add operation. @@ -6810,7 +6922,7 @@ declare module "esri/dijit/editing/Cut" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Cut operations when editing. */ class Cut extends OperationBase { /** * Create a new Cut operation. @@ -6829,7 +6941,7 @@ declare module "esri/dijit/editing/Delete" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Delete operations when editing. */ class Delete extends OperationBase { /** * Create a new Delete operation. @@ -6929,7 +7041,7 @@ declare module "esri/dijit/editing/Union" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Union operations when editing. */ class Union extends OperationBase { /** * Create a new Union operation. @@ -6948,7 +7060,7 @@ declare module "esri/dijit/editing/Update" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Update operations when editing. */ class Update extends OperationBase { /** * Create a new Update operation. @@ -8353,8 +8465,9 @@ declare module "esri/geometry/webMercatorUtils" { /** * Converts geometry from Web Mercator units to geographic units. * @param geometry The geometry to convert. + * @param isLinear Indicates whether to work with linear values, i.e., do not normalize. */ - webMercatorToGeographic(geometry: Geometry): Geometry; + webMercatorToGeographic(geometry: Geometry, isLinear?: boolean): Geometry; /** * Translates the given Web Mercator coordinates to Longitude and Latitude. * @param x The x coordinate value to convert. @@ -10809,8 +10922,6 @@ declare module "esri/layers/VectorTileLayer" { initialExtent: Extent; /** The spatial reference of the layer. */ spatialReference: SpatialReference; - /** The style object of the service with fully qualified URLs for glyphs and sprite. */ - style: any; /** Contains information about the tiling scheme for the layer. */ tileInfo: TileInfo; /** The URL to the vector tile service or style JSON that will be used to draw the layer. */ @@ -10821,6 +10932,8 @@ declare module "esri/layers/VectorTileLayer" { * @param options Optional parameters. */ constructor(url: string | any, options?: esri.VectorTileLayerOptions); + /** Returns an object that contains the current style information for the layer. */ + getStyle(): any; /** * Changes the style properties used to render the layers. * @param styleUrl A url to a JSON file containing the stylesheet information to render the layer. @@ -10835,14 +10948,15 @@ declare module "esri/layers/VectorTileLayer" { declare module "esri/layers/WFSLayer" { import esri = require("esri"); + import GraphicsLayer = require("esri/layers/GraphicsLayer"); import Field = require("esri/layers/Field"); import Extent = require("esri/geometry/Extent"); import Graphic = require("esri/graphic"); import InfoTemplate = require("esri/InfoTemplate"); import Renderer = require("esri/renderers/Renderer"); - /** (Currently in beta) A layer for OGC Web Feature Services (WFS). */ - class WFSLayer { + /** (Currently in beta) A layer for OGC Web Feature Services (WFS). */ + class WFSLayer extends GraphicsLayer { /** An array of fields in the layer. */ fields: Field[]; /** The full extent of the layer. */ @@ -10864,17 +10978,11 @@ declare module "esri/layers/WFSLayer" { * @param options See options table below for full descriptions of the properties needed for this object. */ constructor(options: esri.WFSLayerOptions); - /** Creates the getFeature parameter based on the version, nsLayerName, nsGeometryFieldName, mode, wkid, inverseFilter, maxFeatures constructor parameters. */ - buildRequest(): string; /** - * Gets the WFS layer capabilities. - * @param callback An array of WFS layers in JSON format. + * Creates a WFSLayer using the provided JSON object. + * @param json The input JSON. */ - getCapabilities(callback?: Function): void; - /** Performs the getFeature request. */ - getFeature(): void; - /** Returns a JSON Object containing all of the WFS parameters. */ - getWFSParameters(): any; + fromJson(json: Object): void; /** Redraws all the graphics in the layer. */ redraw(): void; /** Refreshes the features in the WFS layer. */ @@ -10885,8 +10993,8 @@ declare module "esri/layers/WFSLayer" { setPointSymbol(): void; /** Sets the default polygon symbol to be used if no renderer is specified. */ setPolygonSymbol(): void; - /** Sets the WFS parameters using the provided JSON Object. */ - setWFSParameters(): void; + /** Converts the WFSLayer instance to a JSON object. */ + toJson(): any; } export = WFSLayer; } @@ -10952,6 +11060,7 @@ declare module "esri/layers/WMSLayer" { } declare module "esri/layers/WMSLayerInfo" { + import esri = require("esri"); import Extent = require("esri/geometry/Extent"); /** The WMSLayerInfo class defines and provides information about layers in a WMS service. */ @@ -10966,6 +11075,10 @@ declare module "esri/layers/WMSLayerInfo" { legendURL: string; /** The layer name. */ name: string; + /** Returns true if the layer can be queried and the service supports GetFeatureInfo with either text/html or text/plain formats */ + queryable: boolean; + /** Indicates if this layer should be included in the popup. */ + showPopup: boolean; /** An array of WKIDs of all spatial references defined for the layer. */ spatialReferences: number[]; /** WMSLayerInfos of the layer's sub layers. */ @@ -10974,9 +11087,9 @@ declare module "esri/layers/WMSLayerInfo" { title: string; /** * Creates a new WMSLayerInfo object. - * @param layer WMSLayerInfo layer object. + * @param options See options list for parameters. */ - constructor(layer: any); + constructor(options?: esri.WMSLayerInfoOptions); } export = WMSLayerInfo; } @@ -11584,7 +11697,7 @@ declare module "esri/opsdashboard/DataSourceProxy" { displayFieldName: string; /** Read-only: The collection of fields. */ fields: Field[]; - /** The geometry type. */ + /** Read-only: The geometry type. */ geometryType: string; /** Read-only: The id of the data source. */ id: string; @@ -11611,8 +11724,8 @@ declare module "esri/opsdashboard/DataSourceProxy" { executeQuery(query: Query): any; /** An object that contains service level metadata about whether or not the layer supports queries using statistics, order by fields, DISTINCT, pagination, query with distance, and returning queries with extents. */ getAdvancedQueryCapabilities(): any; - /** Retrieve the associated data source that supports selection. */ - getAssociatedSelectionDataSourceProxy(): any; + /** Retrieve the associated id of the data source that supports selection. */ + getAssociatedSelectionDataSourceId(): any; /** Get the associated popupInfo for the data source if any available. */ getPopupInfo(): any; /** Get the associated render object for the data source if any available. */ @@ -11666,12 +11779,17 @@ declare module "esri/opsdashboard/ExtensionBase" { static POLYLINE: any; /** Read-only: Indicates if the host application is the Windows Operations Dashboard. */ isNative: boolean; + /** Read Only: It will list all of the Portal helper services. */ + portalHelperServices: string; /** Read-only: The URL to the ArcGIS.com site or in-house portal that you are currently signed in to. */ portalUrl: string; /** Get the collection of data sources from the host application. */ getDataSourceProxies(): any; - /** Get the data source corresponding to the data source id from the host application. */ - getDataSourceProxy(): any; + /** + * Get the data source corresponding to the data source id from the host application. + * @param dataSourceId The data source id + */ + getDataSourceProxy(dataSourceId: string): any; /** Get the collection of map widgets from the host application. */ getMapWidgetProxies(): any; /** @@ -11791,7 +11909,7 @@ declare module "esri/opsdashboard/GraphicsLayerProxy" { minScale: number; /** Read-only: The current host graphics layer opacity ratio. */ opacity: number; - /** The current renderer used by the host graphics layer. */ + /** Read-only: The current renderer used by the host graphics layer. */ renderer: Renderer; /** Read-only: The current host graphics layer visibility. */ visible: boolean; @@ -11928,8 +12046,6 @@ declare module "esri/opsdashboard/MapWidgetProxy" { destroyGraphicsLayerProxy(graphicsLayerProxy: GraphicsLayerProxy): void; /** Gets the current host map extent. */ getMapExtent(): any; - /** Called by the host application when the extent of the host map has changed. */ - mapExtentChanged(): void; /** * Pans the map to a new location. * @param mapPoint A new location with the same spatial reference as the host map. @@ -14088,7 +14204,7 @@ declare module "esri/tasks/FindTask" { url: string; /** * Creates a new FindTask object. - * @param url URL to the ArcGIS Server REST resource that represents a layer in a service. + * @param url URL to the ArcGIS Server REST resource that represents a map service. * @param options Optional parameters. */ constructor(url: string, options?: esri.FindTaskOptions); @@ -15343,6 +15459,8 @@ declare module "esri/tasks/RouteParameters" { startTimeIsUTC: boolean; /** The set of stops loaded as network locations during analysis. */ stops: any; + /** If true , the TimeWindowStart and TimeWindowEnd attributes of a stop are in UTC time (milliseconds). */ + timeWindowsAreUTC: boolean; /** Travel modes define how a pedestrian, car, truck or other medium of transportation moves through the street network. */ travelMode: any; /** If true, the hierarchy attribute for the network should be used in analysis. */ @@ -16696,7 +16814,7 @@ declare module "esri/tasks/query" { static SPATIAL_REL_TOUCHES: any; /** The feature from feature class 1 is completely enclosed by the feature from feature class 2. */ static SPATIAL_REL_WITHIN: any; - /** Distance to buffer input geometry. */ + /** Buffer distance for input geometries. */ distance: number; /** The geometry to apply to the spatial filter. */ geometry: Geometry; @@ -16738,7 +16856,7 @@ declare module "esri/tasks/query" { text: string; /** Specify a time extent for the query. */ timeExtent: TimeExtent; - /** Distance unit. */ + /** The unit for calculating the buffer distance. */ units: string; /** A where clause for the query. */ where: string; @@ -17055,7 +17173,7 @@ declare module "esri/toolbars/navigation" { * @param symbol The SimpleFillSymbol used for the rubber band zoom. */ setZoomSymbol(symbol: Symbol): void; - /** Zoom to full extent of base layer. */ + /** Zoom to initial extent of base layer. */ zoomToFullExtent(): void; /** Zoom to next extent in extent history. */ zoomToNextExtent(): void; From fee05fe77c32aabd3f7dea136796d6dfb2284bfb Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 6 Jul 2016 01:01:17 +0200 Subject: [PATCH 1201/1850] Chai-enzyme --- chai-enzyme/chai-enzyme-tests.tsx | 45 +++++++++ chai-enzyme/chai-enzyme.d.ts | 153 ++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 chai-enzyme/chai-enzyme-tests.tsx create mode 100644 chai-enzyme/chai-enzyme.d.ts diff --git a/chai-enzyme/chai-enzyme-tests.tsx b/chai-enzyme/chai-enzyme-tests.tsx new file mode 100644 index 0000000000..f85320cee0 --- /dev/null +++ b/chai-enzyme/chai-enzyme-tests.tsx @@ -0,0 +1,45 @@ +/// +/// +/// +/// + +import * as React from "react"; +import * as chaiEnzyme from "chai-enzyme"; +import { expect } from "chai"; +import { shallow } from "enzyme"; + +const Test = () =>
; + +class Test2 extends React.Component<{}, {}> { + render() { + return
; + } +} + +chai.use(chaiEnzyme()); + +const wrapper = shallow(); + +expect(wrapper).to.be.checked(); +expect(wrapper).to.have.className("test"); +expect(wrapper).to.have.descendants({ a: "b" }); +expect(wrapper).to.have.descendants(Test); +expect(wrapper).to.have.exactly(1).descendants(Test2); +expect(wrapper).to.have.descendants("div"); +expect(wrapper).to.be.disabled(); +expect(wrapper).to.be.blank(); +expect(wrapper).to.be.present(); +expect(wrapper).to.have.html("
"); +expect(wrapper).to.have.id("test"); +expect(wrapper).to.have.ref("test"); +expect(wrapper).to.be.selected(); +expect(wrapper).to.have.tagName("div"); +expect(wrapper).to.have.text(""); +expect(wrapper).to.have.value("test"); +expect(wrapper).to.have.attr("test", "test"); +expect(wrapper).to.have.data("test", "Test"); +expect(wrapper).to.have.style("background", "green"); +expect(wrapper).to.have.state("test", "test"); +expect(wrapper).to.have.prop("test", 5); +expect(wrapper).to.contain(); +expect(wrapper).to.match(); diff --git a/chai-enzyme/chai-enzyme.d.ts b/chai-enzyme/chai-enzyme.d.ts new file mode 100644 index 0000000000..21e463dac5 --- /dev/null +++ b/chai-enzyme/chai-enzyme.d.ts @@ -0,0 +1,153 @@ +// Type definitions for chai-enzyme 0.5.0 +// Project: https://github.com/producthunt/chai-enzyme +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +/// +/// +/// + +declare namespace Chai { + type EnzymeSelector = string | __React.StatelessComponent | __React.ComponentClass | { [key: string]: any }; + + interface Match { + /** + * Assert that the wrapper matches given selector: + * @param selector + */ + (selector: EnzymeSelector): Assertion; + } + interface Include { + /** + * Assert that the wrapper contains a given node: + * @param code + */ + (selector: EnzymeSelector): Assertion; + } + interface Assertion { + /** + * Assert that the given wrapper is checked: + */ + checked(): Assertion; + + /** + * Assert that the wrapper has a given class: + * @param name + */ + className(name: string): Assertion; + + /** + * Assert that the wrapper contains a descendant matching the given selector: + * @param selector + */ + descendants(selector?: EnzymeSelector): Assertion; + + /** + * Assert that the wrapper contains an exact amount of descendants matching the given selector: + */ + exactly(count?: number): Assertion; + + /** + * Assert that the given wrapper is disabled: + */ + disabled(): Assertion; + + /** + * Assert that the given wrapper is empty: + */ + blank(): Assertion; + + /** + * Assert that the given wrapper exists: + */ + present(): Assertion; + + /** + * Assert that the wrapper has given html: + * @param str + */ + html(str?: string): Assertion; + + /** + * Assert that the wrapper has given ID attribute: + * @param str + */ + id(str: string): Assertion; + + /** + * Assert that the wrapper has a given ref + * @param key + */ + ref(key: string): Assertion; + + /** + * Assert that the given wrapper is selected: + */ + selected(): Assertion; + + /** + * Assert that the given wrapper has the tag name: + * @param str + */ + tagName(str: string): Assertion; + + /** + * Assert that the given wrapper has the supplied text: + * @param str + */ + text(str?: string): Assertion; + + /** + * Assert that the given wrapper has given value: + * @param str + */ + value(str: string): Assertion; + + /** + * Assert that the wrapper has given attribute [with value]: + * @param key + * @param val + */ + attr(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has a given data attribute [with value]: + * @param key + * @param val + */ + data(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has given style: + * @param key + * @param val + */ + style(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has given state [with value]: + * @param key + * @param val + */ + state(key: string, val?: any): Assertion; + + /** + * Assert that the wrapper has given prop [with value]: + * @param key + * @param val + */ + prop(key: string, val?: any): Assertion; + } +} + +declare module "chai-enzyme" { + import { ShallowWrapper, ReactWrapper, CheerioWrapper } from "enzyme"; + + type DebugWrapper = ShallowWrapper | CheerioWrapper | ReactWrapper; + function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): (chai: any) => void; + + module chaiEnzyMe { + } + export = chaiEnzyMe; +} From b09f8bf76eaea1503df5b50480a0228adeb26fe8 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 6 Jul 2016 01:09:51 +0200 Subject: [PATCH 1202/1850] react-textarea-autosize --- .../react-textarea-autosize-tests.tsx | 17 ++++++ .../react-textarea-autosize.d.ts | 58 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 react-textarea-autosize/react-textarea-autosize-tests.tsx create mode 100644 react-textarea-autosize/react-textarea-autosize.d.ts diff --git a/react-textarea-autosize/react-textarea-autosize-tests.tsx b/react-textarea-autosize/react-textarea-autosize-tests.tsx new file mode 100644 index 0000000000..d87117fa44 --- /dev/null +++ b/react-textarea-autosize/react-textarea-autosize-tests.tsx @@ -0,0 +1,17 @@ +/// +/// + +import * as React from "react"; +import Textarea from "react-textarea-autosize"; + +class Test extends React.Component<{}, {}> { + public render() { + return ( +