WorkerGlobalScope.hx 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package js.html;
  23. import js.lib.Promise;
  24. /**
  25. The `WorkerGlobalScope` interface of the Web Workers API is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by `Window` objects — in this case event handlers, the console or the associated `WorkerNavigator` object. Each `WorkerGlobalScope` has its own event loop.
  26. Documentation [WorkerGlobalScope](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  27. @see <https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope>
  28. **/
  29. @:native("WorkerGlobalScope")
  30. extern class WorkerGlobalScope extends EventTarget {
  31. /**
  32. Returns a reference to the `WorkerGlobalScope` itself. Most of the time it is a specific scope like `DedicatedWorkerGlobalScope`,  `SharedWorkerGlobalScope` or `ServiceWorkerGlobalScope`.
  33. **/
  34. var self(default,null) : WorkerGlobalScope;
  35. /**
  36. Returns the `WorkerLocation` associated with the worker. It is a specific location object, mostly a subset of the `Location` for browsing scopes, but adapted to workers.
  37. **/
  38. var location(default,null) : WorkerLocation;
  39. var navigator(default,null) : WorkerNavigator;
  40. /**
  41. Is an `EventHandler` representing the code to be called when the `error` event is raised.
  42. **/
  43. var onerror : haxe.extern.EitherType<Event,String> -> String -> Int -> Int -> Dynamic -> Dynamic;
  44. /**
  45. Is an `EventHandler` representing the code to be called when the `offline` event is raised.
  46. **/
  47. var onoffline : haxe.Constraints.Function;
  48. /**
  49. Is an `EventHandler` representing the code to be called when the `online` event is raised.
  50. **/
  51. var ononline : haxe.Constraints.Function;
  52. /**
  53. Returns the `Performance` associated with the worker. It is a regular performance object, except that only a subset of its property and methods are available to workers.
  54. **/
  55. var performance(default,null) : Performance;
  56. var crypto(default,null) : Crypto;
  57. var origin(default,null) : String;
  58. var isSecureContext(default,null) : Bool;
  59. var indexedDB(default,null) : js.html.idb.Factory;
  60. var caches(default,null) : CacheStorage;
  61. /**
  62. Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example:` importScripts('foo.js', 'bar.js');`
  63. @throws DOMError
  64. **/
  65. function importScripts( urls : haxe.extern.Rest<String> ) : Void;
  66. /**
  67. Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's `window.dump`, but for workers.
  68. **/
  69. function dump( ?str : String ) : Void;
  70. /**
  71. Creates a deep clone of a given value using the structured clone algorithm.
  72. **/
  73. function structuredClone<T>(value: T, ?options: {transfer: Array<Any>}): T;
  74. /** @throws DOMError */
  75. function btoa( btoa : String ) : String;
  76. /** @throws DOMError */
  77. function atob( atob : String ) : String;
  78. /** @throws DOMError */
  79. @:overload( function( handler : haxe.Constraints.Function, timeout : Int = 0, arguments : haxe.extern.Rest<Dynamic> ) : Int {} )
  80. function setTimeout( handler : String, timeout : Int = 0, unused : haxe.extern.Rest<Dynamic> ) : Int;
  81. function clearTimeout( handle : Int = 0 ) : Void;
  82. /** @throws DOMError */
  83. @:overload( function( handler : haxe.Constraints.Function, timeout : Int = 0, arguments : haxe.extern.Rest<Dynamic> ) : Int {} )
  84. function setInterval( handler : String, timeout : Int = 0, unused : haxe.extern.Rest<Dynamic> ) : Int;
  85. function clearInterval( handle : Int = 0 ) : Void;
  86. /** @throws DOMError */
  87. @:overload( function( aImage : VideoElement) : Promise<ImageBitmap> {} )
  88. @:overload( function( aImage : CanvasElement) : Promise<ImageBitmap> {} )
  89. @:overload( function( aImage : Blob) : Promise<ImageBitmap> {} )
  90. @:overload( function( aImage : ImageData) : Promise<ImageBitmap> {} )
  91. @:overload( function( aImage : CanvasRenderingContext2D) : Promise<ImageBitmap> {} )
  92. @:overload( function( aImage : ImageBitmap) : Promise<ImageBitmap> {} )
  93. @:overload( function( aImage : js.lib.ArrayBufferView) : Promise<ImageBitmap> {} )
  94. @:overload( function( aImage : js.lib.ArrayBuffer) : Promise<ImageBitmap> {} )
  95. @:overload( function( aImage : VideoElement, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  96. @:overload( function( aImage : CanvasElement, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  97. @:overload( function( aImage : Blob, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  98. @:overload( function( aImage : ImageData, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  99. @:overload( function( aImage : CanvasRenderingContext2D, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  100. @:overload( function( aImage : ImageBitmap, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  101. @:overload( function( aImage : js.lib.ArrayBufferView, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  102. @:overload( function( aImage : js.lib.ArrayBuffer, aSx : Int, aSy : Int, aSw : Int, aSh : Int) : Promise<ImageBitmap> {} )
  103. @:overload( function( aImage : VideoElement, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  104. @:overload( function( aImage : CanvasElement, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  105. @:overload( function( aImage : Blob, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  106. @:overload( function( aImage : ImageData, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  107. @:overload( function( aImage : CanvasRenderingContext2D, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  108. @:overload( function( aImage : ImageBitmap, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  109. @:overload( function( aImage : js.lib.ArrayBufferView, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  110. @:overload( function( aImage : js.lib.ArrayBuffer, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout>) : Promise<ImageBitmap> {} )
  111. @:overload( function( aImage : ImageElement ) : Promise<ImageBitmap> {} )
  112. @:overload( function( aImage : ImageElement, aSx : Int, aSy : Int, aSw : Int, aSh : Int ) : Promise<ImageBitmap> {} )
  113. function createImageBitmap( aImage : ImageElement, aOffset : Int, aLength : Int, aFormat : ImageBitmapFormat, aLayout : Array<ChannelPixelLayout> ) : Promise<ImageBitmap>;
  114. @:overload( function( input : String, ?init : RequestInit) : Promise<Response> {} )
  115. function fetch( input : Request, ?init : RequestInit ) : Promise<Response>;
  116. }