@rescript/webapi 0.1.0-experimental-cd67e9b → 0.1.0-experimental-d3d4b5f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ open Prelude
2
+ open CanvasAPI
3
+ open DOMAPI
4
+
5
+ external fromString: string => fillStyle = "%identity"
6
+ external fromCanvasGradient: canvasGradient => fillStyle = "%identity"
7
+ external fromCanvasPattern: canvasGradient => fillStyle = "%identity"
8
+
9
+ type decoded =
10
+ | String(string)
11
+ | CanvasGradient(canvasGradient)
12
+ | CanvasPattern(canvasPattern)
13
+
14
+ let decode = (t: fillStyle): decoded => {
15
+ if CanvasGradient.isInstanceOf(t) {
16
+ CanvasGradient(unsafeConversation(t))
17
+ } else if CanvasPattern.isInstanceOf(t) {
18
+ CanvasPattern(unsafeConversation(t))
19
+ } else {
20
+ String(unsafeConversation(t))
21
+ }
22
+ }
@@ -694,17 +694,54 @@ external hidePopover: htmlCanvasElement => unit = "hidePopover"
694
694
  @send
695
695
  external togglePopover: (htmlCanvasElement, ~force: bool=?) => bool = "togglePopover"
696
696
 
697
+ /**
698
+ Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
699
+ Creates a CanvasRenderingContext2D object representing a two-dimensional rendering context.
700
+
701
+ [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#2d)
702
+ */
703
+ @send
704
+ external getContext_2D: (
705
+ htmlCanvasElement,
706
+ @as("2d") _,
707
+ ~options: canvasRenderingContext2DSettings=?,
708
+ ) => canvasRenderingContext2D = "getContext"
709
+
710
+ /**
711
+ Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
712
+ @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl");
713
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
714
+ */
715
+ @send
716
+ external getContext_WebGL: (
717
+ htmlCanvasElement,
718
+ @as("webgl") _,
719
+ ~options: webGLContextAttributes=?,
720
+ ) => webGLRenderingContext = "getContext"
721
+
722
+ /**
723
+ Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
724
+ @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl");
725
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
726
+ */
727
+ @send
728
+ external getContext_WebGL2: (
729
+ htmlCanvasElement,
730
+ @as("webgl2") _,
731
+ ~options: webGLContextAttributes=?,
732
+ ) => webGL2RenderingContext = "getContext"
733
+
697
734
  /**
698
735
  Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
699
736
  @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl");
700
737
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement/getContext)
701
738
  */
702
739
  @send
703
- external getContext: (
740
+ external getContext_BitmapRenderer: (
704
741
  htmlCanvasElement,
705
- ~contextId: string,
706
- ~options: JSON.t=?,
707
- ) => renderingContext = "getContext"
742
+ @as("bitmaprenderer") _,
743
+ ~options: imageBitmapRenderingContextSettings=?,
744
+ ) => imageBitmapRenderingContext = "getContext"
708
745
 
709
746
  /**
710
747
  Returns the content of the current canvas as an image that you can use as a source for another canvas or an HTML element.
package/src/DOMAPI.res CHANGED
@@ -201,6 +201,8 @@ type shareData = {
201
201
  mutable url?: string,
202
202
  }
203
203
 
204
+ type fillStyle
205
+
204
206
  /**
205
207
  The location (URL) of the object it is linked to. Changes done on it are reflected on the object it relates to. Both the Document and Window interface have such a linked Location, accessible via Document.location and Window.location respectively.
206
208
  [See Location on MDN](https://developer.mozilla.org/docs/Web/API/Location)
@@ -9354,6 +9356,131 @@ type domPoint = {
9354
9356
  ...domPointReadOnly,
9355
9357
  }
9356
9358
 
9359
+ /**
9360
+ [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext#contextattributes)
9361
+ */
9362
+ type canvasContext2DAttributes = {
9363
+ alpha: bool,
9364
+ colorspace?: predefinedColorSpace,
9365
+ desynchronized: bool,
9366
+ willReadFrequently: bool,
9367
+ }
9368
+
9369
+ /**
9370
+ The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects.
9371
+ [See CanvasRenderingContext2D on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D)
9372
+ */
9373
+ type canvasRenderingContext2D = {
9374
+ /**
9375
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/canvas)
9376
+ */
9377
+ canvas: htmlCanvasElement,
9378
+ /**
9379
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalAlpha)
9380
+ */
9381
+ mutable globalAlpha: float,
9382
+ /**
9383
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation)
9384
+ */
9385
+ mutable globalCompositeOperation: globalCompositeOperation,
9386
+ /**
9387
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled)
9388
+ */
9389
+ mutable imageSmoothingEnabled: bool,
9390
+ /**
9391
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/imageSmoothingQuality)
9392
+ */
9393
+ mutable imageSmoothingQuality: imageSmoothingQuality,
9394
+ /**
9395
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/strokeStyle)
9396
+ */
9397
+ mutable strokeStyle: unknown,
9398
+ /**
9399
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fillStyle)
9400
+ */
9401
+ mutable fillStyle: fillStyle,
9402
+ /**
9403
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetX)
9404
+ */
9405
+ mutable shadowOffsetX: float,
9406
+ /**
9407
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowOffsetY)
9408
+ */
9409
+ mutable shadowOffsetY: float,
9410
+ /**
9411
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowBlur)
9412
+ */
9413
+ mutable shadowBlur: float,
9414
+ /**
9415
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/shadowColor)
9416
+ */
9417
+ mutable shadowColor: string,
9418
+ /**
9419
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/filter)
9420
+ */
9421
+ mutable filter: string,
9422
+ /**
9423
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineWidth)
9424
+ */
9425
+ mutable lineWidth: float,
9426
+ /**
9427
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineCap)
9428
+ */
9429
+ mutable lineCap: canvasLineCap,
9430
+ /**
9431
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineJoin)
9432
+ */
9433
+ mutable lineJoin: canvasLineJoin,
9434
+ /**
9435
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/miterLimit)
9436
+ */
9437
+ mutable miterLimit: float,
9438
+ /**
9439
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/lineDashOffset)
9440
+ */
9441
+ mutable lineDashOffset: float,
9442
+ /**
9443
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/font)
9444
+ */
9445
+ mutable font: string,
9446
+ /**
9447
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textAlign)
9448
+ */
9449
+ mutable textAlign: canvasTextAlign,
9450
+ /**
9451
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textBaseline)
9452
+ */
9453
+ mutable textBaseline: canvasTextBaseline,
9454
+ /**
9455
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/direction)
9456
+ */
9457
+ mutable direction: canvasDirection,
9458
+ /**
9459
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/letterSpacing)
9460
+ */
9461
+ mutable letterSpacing: string,
9462
+ /**
9463
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontKerning)
9464
+ */
9465
+ mutable fontKerning: canvasFontKerning,
9466
+ /**
9467
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontStretch)
9468
+ */
9469
+ mutable fontStretch: canvasFontStretch,
9470
+ /**
9471
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/fontVariantCaps)
9472
+ */
9473
+ mutable fontVariantCaps: canvasFontVariantCaps,
9474
+ /**
9475
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/textRendering)
9476
+ */
9477
+ mutable textRendering: canvasTextRendering,
9478
+ /**
9479
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/wordSpacing)
9480
+ */
9481
+ mutable wordSpacing: string,
9482
+ }
9483
+
9357
9484
  /**
9358
9485
  [See Animation on MDN](https://developer.mozilla.org/docs/Web/API/Animation)
9359
9486
  */
@@ -31,7 +31,13 @@ external delete: (formData, string) => unit = "delete"
31
31
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/get)
32
32
  */
33
33
  @send
34
- external get: (formData, string) => formDataEntryValue = "get"
34
+ external get: (formData, string) => file = "get"
35
+
36
+ /**
37
+ [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/get)
38
+ */
39
+ @send
40
+ external get2: (formData, string) => string = "get"
35
41
 
36
42
  /**
37
43
  [Read more on MDN](https://developer.mozilla.org/docs/Web/API/FormData/getAll)