Skip to content

Rescript 11 (WIP) #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "rescript-webapi",
"bsc-flags": ["-bs-no-version-header"],
"bsc-flags": [
"-bs-no-version-header"
],
"sources": [
{
"dir": "src",
Expand All @@ -13,13 +15,15 @@
},
{
"dir": "examples",
"type": "dev"
"type": "dev",
"subdirs": true
}
],
"warnings": {
"number": "+A",
"error": "+A"
},
"uncurried": false,
"bs-dev-dependencies": [
"@ryyppy/rescript-promise"
]
Expand Down
3 changes: 0 additions & 3 deletions lib/js/examples/dom_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ Belt_Option.map(Belt_Option.flatMap(Webapi__Dom__Document.asHtmlDocument(documen
return Caml_option.nullable_to_opt(prim.body);
})), (function (body) {
body.appendChild(el);

}));

document.createElement("div").addEventListener("mousemove", (function (e) {
console.log([
e.screenX,
e.screenY
]);

}));

function handleClick(param) {
console.log("clicked");

}

window.addEventListener("click", handleClick);
Expand Down
6 changes: 3 additions & 3 deletions lib/js/examples/fetch_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fetch("/api/hellos/1").then(function (prim) {
return Promise.resolve((console.log(text), undefined));
});

fetch("/api/hello", Webapi__Fetch.RequestInit.make(/* Post */2, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined)).then(function (prim) {
fetch("/api/hello", Webapi__Fetch.RequestInit.make("Post", undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined)).then(function (prim) {
return prim.text();
}).then(function (text) {
return Promise.resolve((console.log(text), undefined));
Expand All @@ -33,7 +33,7 @@ var payload = {};

payload["hello"] = "world";

fetch("/api/hello", Webapi__Fetch.RequestInit.make(/* Post */2, {
fetch("/api/hello", Webapi__Fetch.RequestInit.make("Post", {
"Content-Type": "application/json"
}, Caml_option.some(JSON.stringify(payload)), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined)).then(function (prim) {
return prim.json();
Expand All @@ -47,7 +47,7 @@ formData.append("image0", {
name: "image0.jpg"
}, undefined);

fetch("/api/upload", Webapi__Fetch.RequestInit.make(/* Post */2, {
fetch("/api/upload", Webapi__Fetch.RequestInit.make("Post", {
Accept: "*"
}, Caml_option.some(formData), undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined)).then(function (prim) {
return prim.json();
Expand Down
6 changes: 2 additions & 4 deletions lib/js/examples/image_examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ function processImage(url) {
var maybeImg = Curry._1(Webapi__Dom__HtmlImageElement.ofElement, e);
maybeImg.src = url;
maybeImg.addEventListener("load", (function ($$event) {
return resolve($$event);
resolve($$event);
}));
maybeImg.addEventListener("error", (function (error) {
return reject(error);
reject(error);
}));
var body = Belt_Option.flatMap(Webapi__Dom__Document.asHtmlDocument(document), (function (prim) {
return Caml_option.nullable_to_opt(prim.body);
}));
body.appendChild(maybeImg);
body.removeChild(maybeImg);

}));
}

Expand All @@ -33,7 +32,6 @@ var test = processImage(url).then(function ($$event) {
var width = img.naturalWidth;
var height = img.naturalHeight;
console.log("width", width, "height", height);

});

exports.url = url;
Expand Down
2 changes: 0 additions & 2 deletions lib/js/examples/webapi_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ var socket = new WebSocket("ws://localhost:8080");

socket.addEventListener("open", (function (param) {
socket.send("Hello Server!");

}));

socket.addEventListener("message", (function ($$event) {
console.log("Message from server ", $$event.data);

}));

/* socket Not a pure module */
12 changes: 6 additions & 6 deletions lib/js/tests/Webapi/Canvas/Webapi__Canvas__Canvas2d__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ ctx.fillStyle = "red";
var match = Webapi__Canvas__Canvas2d.fillStyle(ctx);

switch (match[0]) {
case /* String */0 :
case "String" :
console.log(match[1]);
break;
case /* Gradient */1 :
case "Gradient" :
match[1].addColorStop(0.0, "red");
break;
case /* Pattern */2 :
case "Pattern" :
break;

}

var match$1 = Webapi__Canvas__Canvas2d.strokeStyle(ctx);

switch (match$1[0]) {
case /* String */0 :
case "String" :
console.log(match$1[1]);
break;
case /* Gradient */1 :
case "Gradient" :
match$1[1].addColorStop(1.2, "blue");
break;
case /* Pattern */2 :
case "Pattern" :
break;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tlist.contains("my-class");

tlist.forEach(function (item, param) {
console.log(item);

});

tlist.remove("my-class");
Expand Down
2 changes: 1 addition & 1 deletion lib/js/tests/Webapi/Dom/Webapi__Dom__DragEvent__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $$event.stopImmediatePropagation();

$$event.stopPropagation();

Curry._2(Webapi__Dom__DragEvent.getModifierState, $$event, /* Alt */0);
Curry._2(Webapi__Dom__DragEvent.getModifierState, $$event, "Alt");

exports.$$event = $$event;
/* event Not a pure module */
6 changes: 3 additions & 3 deletions lib/js/tests/Webapi/Dom/Webapi__Dom__Element__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ el.hasAttributeNS("http://...", "foo");

el.hasAttributes();

Webapi__Dom__Element.insertAdjacentElement(el, /* BeforeBegin */0, el2);
Webapi__Dom__Element.insertAdjacentElement(el, "BeforeBegin", el2);

Webapi__Dom__Element.insertAdjacentHTML(el, /* AfterBegin */1, "<strong>text</strong>");
Webapi__Dom__Element.insertAdjacentHTML(el, "AfterBegin", "<strong>text</strong>");

Webapi__Dom__Element.insertAdjacentText(el, /* AfterEnd */3, "text");
Webapi__Dom__Element.insertAdjacentText(el, "AfterEnd", "text");

el.matches("input");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ var $$event = new Event("my-event");

function handleClick(param) {
console.log("asd");

}

target.addEventListener("click", handleClick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var Webapi__Dom__HtmlElement = require("../../../src/Webapi/Dom/Webapi__Dom__Htm

function handleSelection(param) {
console.log("change");

}

var elm = document.createElement("strong");
Expand Down
4 changes: 2 additions & 2 deletions lib/js/tests/Webapi/Dom/Webapi__Dom__HtmlDocument__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ htmlDocument.cookie = "foo=bar;reason=ml";

Webapi__Dom__HtmlDocument.designMode(htmlDocument);

Webapi__Dom__HtmlDocument.setDesignMode(htmlDocument, /* On */0);
Webapi__Dom__HtmlDocument.setDesignMode(htmlDocument, "On");

Webapi__Dom__HtmlDocument.dir(htmlDocument);

Webapi__Dom__HtmlDocument.setDir(htmlDocument, /* Ltr */0);
Webapi__Dom__HtmlDocument.setDir(htmlDocument, "Ltr");

htmlDocument.domain = "reason.ml";

Expand Down
4 changes: 2 additions & 2 deletions lib/js/tests/Webapi/Dom/Webapi__Dom__HtmlElement__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ el.accessKey = "";

Webapi__Dom__HtmlElement.contentEditable(el);

Webapi__Dom__HtmlElement.setContentEditable(el, /* Inherit */2);
Webapi__Dom__HtmlElement.setContentEditable(el, "Inherit");

el.contextMenu = el2;

Webapi__Dom__HtmlElement.dir(el);

Webapi__Dom__HtmlElement.setDir(el, /* Rtl */1);
Webapi__Dom__HtmlElement.setDir(el, "Rtl");

el.draggable = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ console.assert(Belt_Option.isSome(radioNodeList$2), "namedItem 'radiogroup' exis

var radioNodeList$3 = TestHelpers.unsafelyUnwrapOption(radioNodeList$2);

if (radioNodeList$3.TAG === /* RadioNodeList */0) {
if (radioNodeList$3.TAG === "RadioNodeList") {
var radioNodeList$4 = radioNodeList$3._0;
console.log("RadioNodeList.value", radioNodeList$4.value);
console.assert(radioNodeList$4.value === "one", "RadioNodeList.value is one");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $$event.stopImmediatePropagation();

$$event.stopPropagation();

Webapi__Dom__KeyboardEvent.getModifierState($$event, /* Alt */0);
Webapi__Dom__KeyboardEvent.getModifierState($$event, "Alt");

exports.$$event = $$event;
/* event Not a pure module */
2 changes: 1 addition & 1 deletion lib/js/tests/Webapi/Dom/Webapi__Dom__MouseEvent__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $$event.stopImmediatePropagation();

$$event.stopPropagation();

Webapi__Dom__MouseEvent.getModifierState($$event, /* Alt */0);
Webapi__Dom__MouseEvent.getModifierState($$event, "Alt");

exports.$$event = $$event;
/* event Not a pure module */
1 change: 0 additions & 1 deletion lib/js/tests/Webapi/Dom/Webapi__Dom__NodeList__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var items = document.querySelectorAll(".item");

items.forEach(function (item, param) {
console.log(item);

});

exports.items = items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $$event.stopImmediatePropagation();

$$event.stopPropagation();

Curry._2(Webapi__Dom__PointerEvent.getModifierState, $$event, /* Alt */0);
Curry._2(Webapi__Dom__PointerEvent.getModifierState, $$event, "Alt");

Webapi__Dom__PointerEvent.pointerType($$event);

Expand Down
2 changes: 0 additions & 2 deletions lib/js/tests/Webapi/Dom/Webapi__Dom__Window__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var $$event = document.createEvent("my-event");

function handleClick(param) {
console.log("asd");

}

window.location = "http://reason.ml";
Expand Down Expand Up @@ -82,7 +81,6 @@ window.stop();

window.onload = (function (param) {
console.log("load");

});

exports.el = el;
Expand Down
3 changes: 0 additions & 3 deletions lib/js/tests/Webapi/Webapi__Blob__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ function test_arrayBuffer(blob) {

function test_size(blob) {
console.log(blob.size);

}

function test_slice(blob) {
var blob$1 = blob.slice(0, undefined, undefined);
console.log(blob$1.size);

}

function test_stream(blob) {
Expand All @@ -30,7 +28,6 @@ function test_text(blob) {

function test_type(blob) {
console.log(blob.type);

}

var test_blobPropertyBag = {
Expand Down
2 changes: 0 additions & 2 deletions lib/js/tests/Webapi/Webapi__File__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

function test_lastModified(file) {
console.log(file.lastModified);

}

function test_name(file) {
console.log(file.name);

}

var test_filePropertyBag = {
Expand Down
21 changes: 10 additions & 11 deletions lib/js/tests/Webapi/Webapi__IntersectionObserver__test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

var Js_array = require("rescript/lib/js/js_array.js");
var Belt_Option = require("rescript/lib/js/belt_Option.js");
var Caml_option = require("rescript/lib/js/caml_option.js");
var TestHelpers = require("../testHelpers.js");
Expand All @@ -18,18 +19,16 @@ el.setAttribute("style", "margin-top: 800px; margin-bottom: 800px");
body.appendChild(el);

function handler(entries, observer) {
entries.forEach(function (entry) {
console.log(entry.time);
console.log(entry.rootBounds);
console.log(entry.boundingClientRect);
console.log(entry.intersectionRect);
console.log(entry.isIntersecting);
console.log(entry.intersectionRatio);
console.log(entry.target);

});
Js_array.forEach((function (entry) {
console.log(entry.time);
console.log(entry.rootBounds);
console.log(entry.boundingClientRect);
console.log(entry.intersectionRect);
console.log(entry.isIntersecting);
console.log(entry.intersectionRatio);
console.log(entry.target);
}), entries);
observer.unobserve(el);

}

var observer = new IntersectionObserver(handler);
Expand Down
3 changes: 0 additions & 3 deletions lib/js/tests/Webapi/Webapi__ReadableStream__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ function test_cancelWith(reader) {

function test_releaseLock(reader) {
reader.releaseLock();

}

function test_read(reader) {
return reader.read().then(function (next) {
var __x = next.value;
return Promise.resolve(Belt_Option.forEach((__x == null) ? undefined : Caml_option.some(__x), (function (prim) {
console.log(prim);

})));
});
}
Expand Down Expand Up @@ -66,7 +64,6 @@ function test_tee(stream) {
var match = stream.tee();
match[0].cancel();
match[1].cancel();

}

exports.DefaultReader__test = DefaultReader__test;
Expand Down
1 change: 0 additions & 1 deletion lib/js/tests/Webapi/Webapi__ResizeObserver__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ var el = document.createElement("strong");

function handler(entries) {
Caml_array.get(entries, 0);

}

var observer = new ResizeObserver(handler);
Expand Down
1 change: 0 additions & 1 deletion lib/js/tests/Webapi/Webapi__Url__test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ var params = new URLSearchParams("key1=value1&key2=value2");

params.forEach(function (prim0, prim1) {
console.log(prim0, prim1);

});

function test_entries(params) {
Expand Down
Loading