Skip to content

Commit

Permalink
Copy layout for melange-* packages
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Jun 27, 2023
1 parent e104647 commit c9afa90
Show file tree
Hide file tree
Showing 189 changed files with 3,261 additions and 2,224 deletions.
32 changes: 0 additions & 32 deletions lib/belt/LICENSE.md

This file was deleted.

25 changes: 0 additions & 25 deletions lib/js/LICENSE.md

This file was deleted.

1 change: 1 addition & 0 deletions lib/melange-fetch
Submodule melange-fetch added at bb426e
File renamed without changes.
16 changes: 15 additions & 1 deletion lib/js/js.ml → lib/melange-js/js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2383,9 +2383,12 @@ If [n] is greater than the length of [str], then [sliceToEnd] returns the empty
*)
end

module Promise = Promise
module Promise = struct
include Promise
end

module Date = struct
type t
(** Provide bindings for JS Date *)
end

Expand Down Expand Up @@ -2426,6 +2429,17 @@ end

module Typed_array = struct
(** Provide bindings for JS typed array *)
module Uint16Array = struct
type t
end

module Uint8ClampedArray = struct
type t
end

module Float32Array = struct
type t
end
end

module TypedArray2 = struct
Expand Down
21 changes: 19 additions & 2 deletions lib/js/js.mli → lib/melange-js/js.mli
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,10 @@ module String2 : sig
end

module Promise : sig end
module Date : sig end

module Date : sig
type t
end

module Dict : sig
type 'a t
Expand Down Expand Up @@ -677,7 +680,21 @@ module Global : sig end
module Json : sig end
module Math : sig end
module Obj : sig end
module Typed_array : sig end

module Typed_array : sig
module Uint16Array : sig
type t
end

module Uint8ClampedArray : sig
type t
end

module Float32Array : sig
type t
end
end

module TypedArray2 : sig end

module Types : sig
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions lib/melange-runtime
Submodule melange-runtime added at bb426e
13 changes: 9 additions & 4 deletions lib/webapi/Webapi.re → lib/melange-webapi/src/Webapi.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ module File = Webapi__File;
[Webapi.Dom.HtmlFormElement.data].
@since 0.18.0 */
/* module FormData = Fetch.FormData; */
module FormData = Fetch.FormData;

/** Re-export from [bs-fetch] for convenience. See also
{!module:FormData}.
@since 0.18.0 */
/* module Iterator = FormData.Iterator; */
module Iterator = FormData.Iterator;

module Performance = Webapi__Performance;

/** @since 0.19.0 */
Expand All @@ -29,8 +31,11 @@ module Url = Webapi__Url;

type rafId;

[@bs.val] external requestAnimationFrame: (float => unit) => unit;
[@bs.val]
external requestAnimationFrame: (float => unit) => unit =
"requestAnimationFrame";
[@bs.val]
external requestCancellableAnimationFrame: (float => unit) => rafId =
"requestAnimationFrame";
[@bs.val] external cancelAnimationFrame: rafId => unit;
[@bs.val]
external cancelAnimationFrame: rafId => unit = "cancelAnimationFrame";
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ type style(_) =
| Pattern: style(pattern);

/* 2d Canvas API, following https://simon.html5.org/dump/html5-canvas-cheat-sheet.html */
[@bs.send.pipe: t] external save: unit;
[@bs.send.pipe: t] external restore: unit;
[@bs.send.pipe: t] external save: unit = "save";
[@bs.send.pipe: t] external restore: unit = "restore";

/* Transformation */
[@bs.send.pipe: t] external scale: (~x: float, ~y: float) => unit;
[@bs.send.pipe: t] external rotate: float => unit;
[@bs.send.pipe: t] external translate: (~x: float, ~y: float) => unit;
[@bs.send.pipe: t] external scale: (~x: float, ~y: float) => unit = "scale";
[@bs.send.pipe: t] external rotate: float => unit = "rotate";
[@bs.send.pipe: t]
external translate: (~x: float, ~y: float) => unit = "translate";
[@bs.send.pipe: t]
external transform:
(
Expand All @@ -95,7 +96,8 @@ external transform:
~dx: float,
~dy: float
) =>
unit;
unit =
"transform";
[@bs.send.pipe: t]
external setTransform:
(
Expand All @@ -106,17 +108,20 @@ external setTransform:
~dx: float,
~dy: float
) =>
unit;
unit =
"setTransform";

/* Compositing */
[@bs.set] external globalAlpha: (t, float) => unit;
[@bs.set] external globalCompositeOperation: (t, Composite.t) => unit;
[@bs.set] external globalAlpha: (t, float) => unit = "globalAlpha";
[@bs.set]
external globalCompositeOperation: (t, Composite.t) => unit =
"globalCompositeOperation";

/* Line Styles */
[@bs.set] external lineWidth: (t, float) => unit;
[@bs.set] external lineCap: (t, LineCap.t) => unit;
[@bs.set] external lineJoin: (t, LineJoin.t) => unit;
[@bs.set] external miterLimit: (t, float) => unit;
[@bs.set] external lineWidth: (t, float) => unit = "lineWidth";
[@bs.set] external lineCap: (t, LineCap.t) => unit = "lineCap";
[@bs.set] external lineJoin: (t, LineJoin.t) => unit = "lineJoin";
[@bs.set] external miterLimit: (t, float) => unit = "miterLimit";

/* Colors, Styles, and Shadows */
[@bs.set] external setFillStyle: (t, 'a) => unit = "fillStyle";
Expand Down Expand Up @@ -160,27 +165,30 @@ let reifyStyle = (type a, x: 'a): (style(a), a) => {
);
};

[@bs.get] external fillStyle: t => 'a;
[@bs.get] external strokeStyle: t => 'a;
[@bs.get] external fillStyle: t => 'a = "fillStyle";
[@bs.get] external strokeStyle: t => 'a = "strokeStyle";

let fillStyle = (ctx: t) => ctx |> fillStyle |> reifyStyle;

let strokeStyle = (ctx: t) => ctx |> strokeStyle |> reifyStyle;

[@bs.set] external shadowOffsetX: (t, float) => unit;
[@bs.set] external shadowOffsetY: (t, float) => unit;
[@bs.set] external shadowBlur: (t, float) => unit;
[@bs.set] external shadowColor: (t, string) => unit;
[@bs.set] external shadowOffsetX: (t, float) => unit = "shadowOffsetX";
[@bs.set] external shadowOffsetY: (t, float) => unit = "shadowOffsetY";
[@bs.set] external shadowBlur: (t, float) => unit = "shadowBlur";
[@bs.set] external shadowColor: (t, string) => unit = "shadowColor";

/* Gradients */
[@bs.send.pipe: t]
external createLinearGradient:
(~x0: float, ~y0: float, ~x1: float, ~y1: float) => gradient;
(~x0: float, ~y0: float, ~x1: float, ~y1: float) => gradient =
"createLinearGradient";
[@bs.send.pipe: t]
external createRadialGradient:
(~x0: float, ~y0: float, ~x1: float, ~y1: float, ~r0: float, ~r1: float) =>
gradient;
[@bs.send.pipe: gradient] external addColorStop: (float, string) => unit;
gradient =
"createRadialGradient";
[@bs.send.pipe: gradient]
external addColorStop: (float, string) => unit = "addColorStop";
[@bs.val]
external createPattern:
(
Expand All @@ -193,19 +201,21 @@ external createPattern:
| [@bs.as "no-repeat"] `noRepeat
]
) =>
pattern;
pattern =
"createPattern";

/* Paths */
[@bs.send.pipe: t] external beginPath: unit;
[@bs.send.pipe: t] external closePath: unit;
[@bs.send.pipe: t] external fill: unit;
[@bs.send.pipe: t] external stroke: unit;
[@bs.send.pipe: t] external clip: unit;
[@bs.send.pipe: t] external moveTo: (~x: float, ~y: float) => unit;
[@bs.send.pipe: t] external lineTo: (~x: float, ~y: float) => unit;
[@bs.send.pipe: t] external beginPath: unit = "beginPath";
[@bs.send.pipe: t] external closePath: unit = "closePath";
[@bs.send.pipe: t] external fill: unit = "fill";
[@bs.send.pipe: t] external stroke: unit = "stroke";
[@bs.send.pipe: t] external clip: unit = "clip";
[@bs.send.pipe: t] external moveTo: (~x: float, ~y: float) => unit = "moveTo";
[@bs.send.pipe: t] external lineTo: (~x: float, ~y: float) => unit = "lineTo";
[@bs.send.pipe: t]
external quadraticCurveTo:
(~cp1x: float, ~cp1y: float, ~x: float, ~y: float) => unit;
(~cp1x: float, ~cp1y: float, ~x: float, ~y: float) => unit =
"quadraticCurveTo";
[@bs.send.pipe: t]
external bezierCurveTo:
(
Expand All @@ -216,10 +226,12 @@ external bezierCurveTo:
~x: float,
~y: float
) =>
unit;
unit =
"bezierCurveTo";
[@bs.send.pipe: t]
external arcTo:
(~x1: float, ~y1: float, ~x2: float, ~y2: float, ~r: float) => unit;
(~x1: float, ~y1: float, ~x2: float, ~y2: float, ~r: float) => unit =
"arcTo";
[@bs.send.pipe: t]
external arc:
(
Expand All @@ -230,30 +242,36 @@ external arc:
~endAngle: float,
~anticw: bool
) =>
unit;
unit =
"arc";
[@bs.send.pipe: t]
external rect: (~x: float, ~y: float, ~w: float, ~h: float) => unit = "rect";
[@bs.send.pipe: t]
external rect: (~x: float, ~y: float, ~w: float, ~h: float) => unit;
[@bs.send.pipe: t] external isPointInPath: (~x: float, ~y: float) => bool;
external isPointInPath: (~x: float, ~y: float) => bool = "isPointInPath";

/* Text */
[@bs.set] external font: (t, string) => unit;
[@bs.set] external textAlign: (t, string) => unit;
[@bs.set] external textBaseline: (t, string) => unit;
[@bs.set] external font: (t, string) => unit = "font";
[@bs.set] external textAlign: (t, string) => unit = "textAlign";
[@bs.set] external textBaseline: (t, string) => unit = "textBaseline";
[@bs.send.pipe: t]
external fillText: (string, ~x: float, ~y: float, ~maxWidth: float=?) => unit;
external fillText: (string, ~x: float, ~y: float, ~maxWidth: float=?) => unit =
"fillText";
[@bs.send.pipe: t]
external strokeText:
(string, ~x: float, ~y: float, ~maxWidth: float=?) => unit;
[@bs.send.pipe: t] external measureText: string => measureText;
[@bs.get] external width: measureText => float;
external strokeText: (string, ~x: float, ~y: float, ~maxWidth: float=?) => unit =
"strokeText";
[@bs.send.pipe: t] external measureText: string => measureText = "measureText";
[@bs.get] external width: measureText => float = "width";

/* Rectangles */
[@bs.send.pipe: t]
external fillRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit;
external fillRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit =
"fillRect";
[@bs.send.pipe: t]
external strokeRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit;
external strokeRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit =
"strokeRect";
[@bs.send.pipe: t]
external clearRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit;
external clearRect: (~x: float, ~y: float, ~w: float, ~h: float) => unit =
"clearRect";

[@bs.send]
external createImageDataCoords:
Expand All @@ -266,11 +284,13 @@ external createImageDataFromImage:

[@bs.send]
external getImageData:
(t, ~sx: float, ~sy: float, ~sw: float, ~sh: float) => Webapi__Dom__Image.t;
(t, ~sx: float, ~sy: float, ~sw: float, ~sh: float) => Webapi__Dom__Image.t =
"getImageData";

[@bs.send]
external putImageData:
(t, ~imageData: Webapi__Dom__Image.t, ~dx: float, ~dy: float) => unit;
(t, ~imageData: Webapi__Dom__Image.t, ~dx: float, ~dy: float) => unit =
"putImageData";

[@bs.send]
external putImageDataWithDirtyRect:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ external clearColor: (glT, float, float, float, float) => unit = "clearColor";
[@bs.send] external createBuffer: glT => bufferT = "createBuffer";
[@bs.send] external deleteBuffer: (glT, bufferT) => unit = "deleteBuffer";
[@bs.send] external bindBuffer: (glT, int, bufferT) => unit = "bindBuffer";
/* [@bs.send]
external bufferData: (glT, int, Js.Typed_array.Uint16Array.t, int) => unit =
"bufferData"; */
/* [@bs.send]
external bufferFloatData:
(glT, int, Js.Typed_array.Float32Array.t, int) => unit =
"bufferData"; */
[@bs.send]
external bufferData: (glT, int, Js.Typed_array.Uint16Array.t, int) => unit =
"bufferData";
[@bs.send]
external bufferFloatData:
(glT, int, Js.Typed_array.Float32Array.t, int) => unit =
"bufferData";
[@bs.send] external createProgram: glT => programT = "createProgram";
[@bs.send] external linkProgram: (glT, programT) => unit = "linkProgram";
[@bs.send] external useProgram: (glT, programT) => unit = "useProgram";
Expand Down
Loading

0 comments on commit c9afa90

Please sign in to comment.