@types/chrome 0.0.36 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
chrome/README.md CHANGED
@@ -5,13 +5,12 @@
5
5
  This package contains type definitions for Chrome extension development (http://developer.chrome.com/extensions/).
6
6
 
7
7
  # Details
8
- Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/chrome
8
+ Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/chrome
9
9
 
10
10
  Additional Details
11
- * Last updated: Mon, 12 Dec 2016 22:50:15 GMT
12
- * Library Dependencies: filesystem
13
- * Module Dependencies: none
11
+ * Last updated: Fri, 10 Feb 2017 23:02:30 GMT
12
+ * Dependencies: filesystem
14
13
  * Global values: chrome
15
14
 
16
15
  # Credits
17
- These definitions were written by Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://github.com/couven92>, RReverser <https://github.com/rreverser>.
16
+ These definitions were written by Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>, couven92 <https://github.com/couven92>, RReverser <https://github.com/rreverser>, sreimer15 <https://github.com/sreimer15>.
chrome/chrome-app.d.ts CHANGED
@@ -355,6 +355,14 @@ declare namespace chrome.sockets.tcp {
355
355
  var onReceiveError: chrome.events.Event<(args: ReceiveErrorEventArgs) => void>;
356
356
  }
357
357
 
358
+ /**
359
+ * Use the chrome.sockets.udp API to send and receive data over the network
360
+ * using UDP connections. This API supersedes the UDP functionality previously
361
+ * found in the "socket" API.
362
+ *
363
+ * @since Chrome 33
364
+ * @see https://developer.chrome.com/apps/sockets_udp
365
+ */
358
366
  declare namespace chrome.sockets.udp {
359
367
  interface CreateInfo {
360
368
  socketId: number;
@@ -377,43 +385,278 @@ declare namespace chrome.sockets.udp {
377
385
  resultCode: number;
378
386
  }
379
387
 
388
+ /**
389
+ * @see https://developer.chrome.com/apps/sockets_udp#type-SocketProperties
390
+ */
380
391
  interface SocketProperties {
392
+ /**
393
+ * Flag indicating if the socket is left open when the event page of the
394
+ * application is unloaded. The default value is "false." When the
395
+ * application is loaded, any sockets previously opened with
396
+ * persistent=true can be fetched with getSockets.
397
+ * @see http://developer.chrome.com/apps/app_lifecycle.html
398
+ */
381
399
  persistent?: boolean;
400
+
401
+ /** An application-defined string associated with the socket. */
382
402
  name?: string;
403
+
404
+ /**
405
+ * The size of the buffer used to receive data. If the buffer is too
406
+ * small to receive the UDP packet, data is lost. The default value is
407
+ * 4096.
408
+ */
383
409
  bufferSize?: number;
384
410
  }
385
411
 
412
+ /**
413
+ * @see https://developer.chrome.com/apps/sockets_udp#type-SocketInfo
414
+ */
386
415
  interface SocketInfo {
416
+ /** The socket identifier. */
387
417
  socketId: number;
418
+
419
+ /**
420
+ * Flag indicating whether the socket is left open when the application
421
+ * is suspended (see SocketProperties.persistent).
422
+ */
388
423
  persistent: boolean;
424
+
425
+ /** Application-defined string associated with the socket. */
389
426
  name?: string;
427
+
428
+ /**
429
+ * The size of the buffer used to receive data. If no buffer size ha
430
+ * been specified explictly, the value is not provided.
431
+ */
390
432
  bufferSize?: number;
433
+
434
+ /**
435
+ * Flag indicating whether the socket is blocked from firing onReceive
436
+ * events.
437
+ */
391
438
  paused: boolean;
439
+
440
+ /**
441
+ * If the underlying socket is bound, contains its local IPv4/6 address.
442
+ */
392
443
  localAddress?: string;
444
+
445
+ /**
446
+ * If the underlying socket is bound, contains its local port.
447
+ */
393
448
  localPort?: number;
394
449
  }
395
450
 
451
+ /**
452
+ * Creates a UDP socket with default properties.
453
+ *
454
+ * @see https://developer.chrome.com/apps/sockets_udp#method-create
455
+ * @param createInfo.socketId The ID of the newly created socket.
456
+ */
396
457
  export function create(callback: (createInfo: CreateInfo) => void): void;
397
- export function create(properties: SocketProperties,
398
- callback: (createInfo: CreateInfo) => void): void;
399
458
 
459
+ /**
460
+ * Creates a UDP socket with the given properties.
461
+ *
462
+ * @see https://developer.chrome.com/apps/sockets_udp#method-create
463
+ * @param properties The socket properties.
464
+ * @param createInfo.socketId The ID of the newly created socket.
465
+ */
466
+ export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
467
+
468
+ /**
469
+ * Updates the socket properties.
470
+ *
471
+ * @see https://developer.chrome.com/apps/sockets_udp#method-update
472
+ * @param socketId The socket ID.
473
+ * @param properties The properties to update.
474
+ * @param callback Called when the properties are updated.
475
+ */
400
476
  export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
477
+
478
+ /**
479
+ * Pauses or unpauses a socket. A paused socket is blocked from firing
480
+ * onReceive events.
481
+ *
482
+ * @see https://developer.chrome.com/apps/sockets_udp#method-setPaused
483
+ * @param socketId The socket ID.
484
+ * @param paused Flag to indicate whether to pause or unpause.
485
+ * @param callback Called when the socket has been successfully paused or
486
+ * unpaused.
487
+ */
401
488
  export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
489
+
490
+ /**
491
+ * Binds the local address and port for the socket. For a client socket, it
492
+ * is recommended to use port 0 to let the platform pick a free port.
493
+ *
494
+ * Once the bind operation completes successfully, onReceive events are
495
+ * raised when UDP packets arrive on the address/port specified -- unless
496
+ * the socket is paused.
497
+ *
498
+ * @see https://developer.chrome.com/apps/sockets_udp#method-bind
499
+ * @param socketId The socket ID.
500
+ * @param address The address of the local machine. DNS name, IPv4 and IPv6
501
+ * formats are supported. Use "0.0.0.0" to accept packets
502
+ * from all local available network interfaces.
503
+ * @param port The port of the local machine. Use "0" to bind to a free
504
+ * port.
505
+ * @param callback Called when the bind operation completes.
506
+ */
402
507
  export function bind(socketId: number, address: string, port: number, callback: (result: number) => void): void;
508
+
509
+ /**
510
+ * Sends data on the given socket to the given address and port. The socket
511
+ * must be bound to a local port before calling this method.
512
+ *
513
+ * @see https://developer.chrome.com/apps/sockets_udp#method-send
514
+ * @param socketId The socket ID.
515
+ * @param data The data to send.
516
+ * @param address The address of the remote machine.
517
+ * @param port The port of the remote machine.
518
+ * @param callback Called when the send operation completes.
519
+ */
403
520
  export function send(socketId: number, data: ArrayBuffer, address: string, port: number, callback: (sendInfo: SendInfo) => void): void;
521
+
522
+ /**
523
+ * Closes the socket and releases the address/port the socket is bound to.
524
+ * Each socket created should be closed after use. The socket id is no
525
+ * longer valid as soon at the function is called. However, the socket is
526
+ * guaranteed to be closed only when the callback is invoked.
527
+ *
528
+ * @see https://developer.chrome.com/apps/sockets_udp#method-close
529
+ * @param socketId The socket ID.
530
+ * @param callback Called when the close operation completes.
531
+ */
404
532
  export function close(socketId: number, callback?: () => void): void;
533
+
534
+ /**
535
+ * Retrieves the state of the given socket.
536
+ *
537
+ * @see https://developer.chrome.com/apps/sockets_udp#method-getInfo
538
+ * @param socketId The socket ID.
539
+ * @param callback Called when the socket state is available.
540
+ */
405
541
  export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
542
+
543
+ /**
544
+ * Retrieves the list of currently opened sockets owned by the application.
545
+ *
546
+ * @see https://developer.chrome.com/apps/sockets_udp#method-getSockets
547
+ * @param callback Called when the list of sockets is available.
548
+ */
406
549
  export function getSockets(callback: (socketInfos: SocketInfo[]) => void): void;
550
+
551
+ /**
552
+ * Joins the multicast group and starts to receive packets from that group.
553
+ * The socket must be bound to a local port before calling this method.
554
+ *
555
+ * @see https://developer.chrome.com/apps/sockets_udp#method-joinGroup
556
+ * @param socketId The socket ID.
557
+ * @param address The group address to join. Domain names are not supported.
558
+ * @param callback Called when the joinGroup operation completes.
559
+ */
407
560
  export function joinGroup(socketId: number, address: string, callback: (result: number) => void): void;
561
+
562
+ /**
563
+ * Leaves the multicast group previously joined using joinGroup. This is
564
+ * only necessary to call if you plan to keep using the socket afterwards,
565
+ * since it will be done automatically by the OS when the socket is closed.
566
+ *
567
+ * Leaving the group will prevent the router from sending multicast
568
+ * datagrams to the local host, presuming no other process on the host is
569
+ * still joined to the group.
570
+ *
571
+ * @see https://developer.chrome.com/apps/sockets_udp#method-leaveGroup
572
+ * @param socketId The socket ID.
573
+ * @param address The group address to leave. Domain names are not
574
+ * supported.
575
+ * @param callback Called when the leaveGroup operation completes.
576
+ */
408
577
  export function leaveGroup(socketId: number, address: string, callback: (result: number) => void): void;
578
+
579
+ /**
580
+ * Sets the time-to-live of multicast packets sent to the multicast group.
581
+ *
582
+ * Calling this method does not require multicast permissions.
583
+ *
584
+ * @see https://developer.chrome.com/apps/sockets_udp#method-setMulticastTimeToLive
585
+ * @param socketId The socket ID.
586
+ * @param ttl The time-to-live value.
587
+ * @param callback Called when the configuration operation completes.
588
+ */
409
589
  export function setMulticastTimeToLive(socketId: number, ttl: number, callback: (result: number) => void): void;
590
+
591
+ /**
592
+ * Sets whether multicast packets sent from the host to the multicast group
593
+ * will be looped back to the host.
594
+ *
595
+ * Note: the behavior of setMulticastLoopbackMode is slightly different
596
+ * between Windows and Unix-like systems. The inconsistency happens only
597
+ * when there is more than one application on the same host joined to the
598
+ * same multicast group while having different settings on multicast
599
+ * loopback mode. On Windows, the applications with loopback off will not
600
+ * RECEIVE the loopback packets; while on Unix-like systems, the
601
+ * applications with loopback off will not SEND the loopback packets to
602
+ * other applications on the same host.
603
+ * @see MSDN: http://goo.gl/6vqbj
604
+ *
605
+ * Calling this method does not require multicast permissions.
606
+ *
607
+ * @see https://developer.chrome.com/apps/sockets_udp#method-setMulticastLoopbackMode
608
+ * @param socketId The socket ID.
609
+ * @param enabled Indicate whether to enable loopback mode.
610
+ * @param callback Called when the configuration operation completes.
611
+ */
410
612
  export function setMulticastLoopbackMode(socketId: number, enabled: boolean, callback: (result: number) => void): void;
613
+
614
+ /**
615
+ * Gets the multicast group addresses the socket is currently joined to.
616
+ *
617
+ * @see https://developer.chrome.com/apps/sockets_udp#method-getJoinedGroups
618
+ * @param socketId The socket ID.
619
+ * @param callback Called with an array of strings of the result.
620
+ */
411
621
  export function getJoinedGroups(socketId: number, callback: (groups: string[]) => void): void;
412
622
 
623
+ /**
624
+ * Enables or disables broadcast packets on this socket.
625
+ *
626
+ * @since Chrome 44
627
+ * @see https://developer.chrome.com/apps/sockets_udp#method-setBroadcast
628
+ * @param socketId The socket ID.
629
+ * @param enabled true to enable broadcast packets, false to disable them.
630
+ * @param callback Callback from the setBroadcast method.
631
+ */
632
+ export function setBroadcast(socketId: number, enabled: boolean, callback?: (result: number) => void): void;
633
+
634
+ /**
635
+ * Event raised when a UDP packet has been received for the given socket.
636
+ *
637
+ * @see https://developer.chrome.com/apps/sockets_udp#event-onReceive
638
+ */
413
639
  var onReceive: chrome.events.Event<(args: ReceiveEventArgs) => void>;
640
+
641
+ /**
642
+ * Event raised when a network error occured while the runtime was waiting
643
+ * for data on the socket address and port. Once this event is raised, the
644
+ * socket is paused and no more onReceive events will be raised for this
645
+ * socket until the socket is resumed.
646
+ *
647
+ * @see https://developer.chrome.com/apps/sockets_udp#event-onReceiveError
648
+ */
414
649
  var onReceiveError: chrome.events.Event<(args: ReceiveErrorEventArgs) => void>;
415
650
  }
416
651
 
652
+ /**
653
+ * Use the chrome.sockets.tcpServer API to create server applications using TCP
654
+ * connections. This API supersedes the TCP functionality previously found in
655
+ * the chrome.socket API.
656
+ *
657
+ * @since Chrome 33
658
+ * @see https://developer.chrome.com/apps/sockets_tcpServer
659
+ */
417
660
  declare namespace chrome.sockets.tcpServer {
418
661
  interface CreateInfo {
419
662
  socketId: number;
@@ -429,36 +672,180 @@ declare namespace chrome.sockets.tcpServer {
429
672
  resultCode: number;
430
673
  }
431
674
 
675
+ /**
676
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#type-SocketProperties
677
+ */
432
678
  interface SocketProperties {
679
+ /**
680
+ * Flag indicating if the socket remains open when the event page of the
681
+ * application is unloaded. The default value is "false." When the
682
+ * application is loaded, any sockets previously opened with
683
+ * persistent=true can be fetched with getSockets.
684
+ *
685
+ * @see http://developer.chrome.com/apps/app_lifecycle.html
686
+ */
433
687
  persistent?: boolean;
688
+
689
+ /** An application-defined string associated with the socket. */
434
690
  name?: string;
435
691
  }
436
692
 
693
+ /**
694
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#type-SocketInfo
695
+ */
437
696
  interface SocketInfo {
697
+ /** The socket identifier. */
438
698
  socketId: number;
699
+
700
+ /**
701
+ * Flag indicating if the socket remains open when the event page of the
702
+ * application is unloaded (see SocketProperties.persistent). The
703
+ * default value is "false".
704
+ */
439
705
  persistent: boolean;
706
+
707
+ /** Application-defined string associated with the socket. */
440
708
  name?: string;
709
+
710
+ /**
711
+ * Flag indicating whether connection requests on a listening socket are
712
+ * dispatched through the onAccept event or queued up in the listen
713
+ * queue backlog. See setPaused. The default value is "false"
714
+ */
441
715
  paused: boolean;
716
+
717
+ /** If the socket is listening, contains its local IPv4/6 address. */
442
718
  localAddress?: string;
719
+
720
+ /** If the socket is listening, contains its local port. */
443
721
  localPort?: number;
444
722
  }
445
723
 
724
+ /**
725
+ * Creates a TCP server socket.
726
+ *
727
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-create
728
+ * @param callback Called when the socket has been created.
729
+ */
446
730
  export function create(callback: (createInfo: CreateInfo) => void): void;
731
+
732
+ /**
733
+ * Creates a TCP server socket.
734
+ *
735
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-create
736
+ * @param properties The socket properties.
737
+ * @param callback Called when the socket has been created.
738
+ */
447
739
  export function create(properties: SocketProperties, callback: (createInfo: CreateInfo) => void): void;
448
740
 
741
+ /**
742
+ * Updates the socket properties.
743
+ *
744
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-update
745
+ * @param socketId The socket identifier.
746
+ * @param properties The properties to update.
747
+ * @param callback Called when the properties are updated.
748
+ */
449
749
  export function update(socketId: number, properties: SocketProperties, callback?: () => void): void;
450
- export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
451
750
 
452
- export function listen(socketId: number, address: string,
453
- port: number, backlog: number, callback: (result: number) => void): void;
454
- export function listen(socketId: number, address: string,
455
- port: number, callback: (result: number) => void): void;
751
+ /**
752
+ * Enables or disables a listening socket from accepting new connections.
753
+ * When paused, a listening socket accepts new connections until its backlog
754
+ * (see listen function) is full then refuses additional connection
755
+ * requests. onAccept events are raised only when the socket is un-paused.
756
+ *
757
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-setPaused
758
+ * @param callback Callback from the setPaused method.
759
+ */
760
+ export function setPaused(socketId: number, paused: boolean, callback?: () => void): void;
456
761
 
762
+ /**
763
+ * Listens for connections on the specified port and address. If the
764
+ * port/address is in use, the callback indicates a failure.
765
+ *
766
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-listen
767
+ * @param socketId The socket identifier.
768
+ * @param address The address of the local machine.
769
+ * @param port The port of the local machine. When set to 0, a free port
770
+ * is chosen dynamically. The dynamically allocated port can
771
+ * be found by calling getInfo.
772
+ * @param backlog Length of the socket's listen queue. The default value
773
+ * depends on the Operating System (SOMAXCONN), which
774
+ * ensures a reasonable queue length for most applications.
775
+ * @param callback Called when listen operation completes.
776
+ */
777
+ export function listen(socketId: number, address: string, port: number, backlog: number, callback: (result: number) => void): void;
778
+
779
+ /**
780
+ * Listens for connections on the specified port and address. If the
781
+ * port/address is in use, the callback indicates a failure.
782
+ *
783
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-listen
784
+ * @param socketId The socket identifier.
785
+ * @param address The address of the local machine.
786
+ * @param port The port of the local machine. When set to 0, a free port
787
+ * is chosen dynamically. The dynamically allocated port can
788
+ * be found by calling getInfo.
789
+ * @param callback Called when listen operation completes.
790
+ */
791
+ export function listen(socketId: number, address: string, port: number, callback: (result: number) => void): void;
792
+
793
+ /**
794
+ * Disconnects the listening socket, i.e. stops accepting new connections
795
+ * and releases the address/port the socket is bound to. The socket
796
+ * identifier remains valid, e.g. it can be used with listen to accept
797
+ * connections on a new port and address.
798
+ *
799
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-disconnect
800
+ * @param socketId The socket identifier.
801
+ * @param callback Called when the disconnect attempt is complete.
802
+ */
457
803
  export function disconnect(socketId: number, callback?: () => void): void;
804
+
805
+ /**
806
+ * Disconnects and destroys the socket. Each socket created should be closed
807
+ * after use. The socket id is no longer valid as soon at the function is
808
+ * called. However, the socket is guaranteed to be closed only when the
809
+ * callback is invoked.
810
+ *
811
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-close
812
+ * @param socketId The socket identifier.
813
+ * @param callback Called when the close operation completes.
814
+ */
458
815
  export function close(socketId: number, callback?: () => void): void;
459
- export function getInfo(socketId: number, callback: (socketInfos: SocketInfo[]) => void): void;
460
816
 
817
+ /**
818
+ * Retrieves the state of the given socket.
819
+ *
820
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-getInfo
821
+ * @param socketId The socket identifier.
822
+ * @param callback Called when the socket state is available.
823
+ */
824
+ export function getInfo(socketId: number, callback: (socketInfo: SocketInfo) => void): void;
825
+
826
+ /**
827
+ * Retrieves the list of currently opened sockets owned by the application.
828
+ *
829
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#method-getSockets
830
+ * @param callback Called when the list of sockets is available.
831
+ */
832
+ export function getSockets(callback: (socketInfos: SocketInfo[]) => void): void;
833
+
834
+ /**
835
+ * Event raised when a connection has been made to the server socket.
836
+ *
837
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#event-onAccept
838
+ */
461
839
  var onAccept: chrome.events.Event<(args: AcceptEventArgs) => void>;
840
+
841
+ /**
842
+ * Event raised when a network error occured while the runtime was waiting
843
+ * for new connections on the socket address and port. Once this event is
844
+ * raised, the socket is set to paused and no more onAccept events are
845
+ * raised for this socket until the socket is resumed.
846
+ *
847
+ * @see https://developer.chrome.com/apps/sockets_tcpServer#event-onAcceptError
848
+ */
462
849
  var onAcceptError: chrome.events.Event<(args: AcceptErrorEventArgs) => void>;
463
850
  }
464
851