diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..3f6aab2 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,28 @@ +version: 2.1 + +orbs: + node: circleci/node@4.7 + +jobs: + # Below is the definition of your job to build and test your app, you can rename and customize it as you want. + build-and-test: + docker: + - image: cimg/node:14.17.0 + + steps: + - checkout + # Next, the node orb's install-packages step will install the dependencies from a package.json. + # The orb install-packages step will also automatically cache them for faster future runs. + - node/install-packages: + # If you are using yarn, change the line below from "npm" to "yarn" + pkg-manager: npm + + - run: npm install + - run: npm run build + +workflows: + sample: + jobs: + - build-and-test + # For running simple node tests, you could optionally use the node/test job from the orb to replicate and replace the job above in fewer lines. + # - node/test diff --git a/bsconfig.json b/bsconfig.json index 1c93e1b..06c690c 100644 --- a/bsconfig.json +++ b/bsconfig.json @@ -1,15 +1,16 @@ { - "name": "bucklescript-tea", + "name": "rescript-tea", "version": "0.15.0", "bsc-flags": ["-bs-cross-module-opt"], "package-specs": ["commonjs"], "sources": [ - "src-ocaml", + "src", { - "dir": "test-ocaml", + "dir": "test", "type": "dev" } ], + "bs-dependencies": ["rescript-webapi", "@glennsl/rescript-json-combinators"], "warnings": { "error" : true } diff --git a/lib/js/src-ocaml/tea.js b/lib/js/src-ocaml/tea.js deleted file mode 100644 index 33adc84..0000000 --- a/lib/js/src-ocaml/tea.js +++ /dev/null @@ -1,59 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -var Result = /* alias */0; - -var Cmd = /* alias */0; - -var Sub = /* alias */0; - -var App = /* alias */0; - -var Debug = /* alias */0; - -var Html = /* alias */0; - -var Html2 = /* alias */0; - -var Svg = /* alias */0; - -var Task = /* alias */0; - -var Program = /* alias */0; - -var Time = /* alias */0; - -var Json = /* alias */0; - -var Navigation = /* alias */0; - -var Random = /* alias */0; - -var AnimationFrame = /* alias */0; - -var Mouse = /* alias */0; - -var Http = /* alias */0; - -var Ex = /* alias */0; - -exports.Result = Result; -exports.Cmd = Cmd; -exports.Sub = Sub; -exports.App = App; -exports.Debug = Debug; -exports.Html = Html; -exports.Html2 = Html2; -exports.Svg = Svg; -exports.Task = Task; -exports.Program = Program; -exports.Time = Time; -exports.Json = Json; -exports.Navigation = Navigation; -exports.Random = Random; -exports.AnimationFrame = AnimationFrame; -exports.Mouse = Mouse; -exports.Http = Http; -exports.Ex = Ex; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_animationframe.js b/lib/js/src-ocaml/tea_animationframe.js deleted file mode 100644 index 2355e7f..0000000 --- a/lib/js/src-ocaml/tea_animationframe.js +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_sub = require("./tea_sub.js"); - -function every($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var enableCall = function (callbacks) { - var lastTime = { - contents: Date.now() - }; - var id = { - contents: undefined - }; - var onFrame = function (_time) { - var time = Date.now(); - var match = id.contents; - if (match !== undefined) { - var ret_delta = time < lastTime.contents ? 0.0 : time - lastTime.contents; - var ret = { - time: time, - delta: ret_delta - }; - lastTime.contents = time; - Curry._1(callbacks.enqueue, Curry._1(tagger, ret)); - var match$1 = id.contents; - if (match$1 !== undefined) { - id.contents = window.requestAnimationFrame(onFrame); - return /* () */0; - } else { - return /* () */0; - } - } else { - return /* () */0; - } - }; - id.contents = window.requestAnimationFrame(onFrame); - return (function (param) { - var match = id.contents; - if (match !== undefined) { - window.cancelAnimationFrame(match); - id.contents = undefined; - return /* () */0; - } else { - return /* () */0; - } - }); - }; - return Tea_sub.registration(key, enableCall); -} - -function times($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return every(undefined, (function (ev) { - return Curry._2(tagger, key, ev.time); - })); -} - -function diffs($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return every(undefined, (function (ev) { - return Curry._2(tagger, key, ev.delta); - })); -} - -exports.every = every; -exports.times = times; -exports.diffs = diffs; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_app.js b/lib/js/src-ocaml/tea_app.js deleted file mode 100644 index 3e21bb8..0000000 --- a/lib/js/src-ocaml/tea_app.js +++ /dev/null @@ -1,294 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Web = require("./web.js"); -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_cmd = require("./tea_cmd.js"); -var Tea_sub = require("./tea_sub.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function programStateWrapper(initModel, pump, shutdown) { - var model = { - contents: initModel - }; - var callbacks = { - contents: { - enqueue: (function (_msg) { - console.log("INVALID enqueue CALL!"); - return /* () */0; - }), - on: (function (param) { - return /* () */0; - }) - } - }; - var pumperInterface = Curry._1(pump, callbacks); - var pending = { - contents: undefined - }; - var handler = function (msg) { - var match = pending.contents; - if (match !== undefined) { - pending.contents = /* :: */[ - msg, - match - ]; - return /* () */0; - } else { - pending.contents = /* [] */0; - var newModel = Curry._2(pumperInterface.handleMsg, model.contents, msg); - model.contents = newModel; - var match$1 = pending.contents; - if (match$1 !== undefined) { - var msgs = match$1; - if (msgs) { - pending.contents = undefined; - return List.iter(handler, List.rev(msgs)); - } else { - pending.contents = undefined; - return /* () */0; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "INVALID message queue state, should never be None during message processing!" - ]; - } - } - }; - var render_events = { - contents: /* [] */0 - }; - var finalizedCBs_enqueue = handler; - var finalizedCBs_on = function (param) { - if (typeof param === "number") { - return List.iter(handler, render_events.contents); - } else if (param.tag) { - var msg = param[0]; - render_events.contents = List.filter((function (mg) { - return msg !== mg; - }))(render_events.contents); - return /* () */0; - } else { - render_events.contents = List.append(render_events.contents, /* :: */[ - param[0], - /* [] */0 - ]); - return /* () */0; - } - }; - var finalizedCBs = { - enqueue: finalizedCBs_enqueue, - on: finalizedCBs_on - }; - callbacks.contents = finalizedCBs; - var pi_requestShutdown = function (param) { - callbacks.contents = { - enqueue: (function (_msg) { - console.log("INVALID message enqueued when shut down"); - return /* () */0; - }), - on: (function (param) { - return /* () */0; - }) - }; - var cmd = Curry._1(shutdown, model.contents); - Curry._1(pumperInterface.shutdown, cmd); - return /* () */0; - }; - var render_string = function (param) { - return Curry._1(pumperInterface.render_string, model.contents); - }; - Curry._1(pumperInterface.startup, /* () */0); - return { - pushMsg: handler, - shutdown: pi_requestShutdown, - getHtmlString: render_string - }; -} - -function programLoop(update, view, subscriptions, initModel, initCmd, param) { - if (param !== undefined) { - var parentNode = Caml_option.valFromOption(param); - return (function (callbacks) { - var priorRenderedVdom = { - contents: /* [] */0 - }; - var latestModel = { - contents: initModel - }; - var nextFrameID = { - contents: undefined - }; - var doRender = function (_delta) { - var match = nextFrameID.contents; - if (match !== undefined) { - var newVdom_000 = Curry._1(view, latestModel.contents); - var newVdom = /* :: */[ - newVdom_000, - /* [] */0 - ]; - var justRenderedVdom = Vdom.patchVNodesIntoElement(callbacks, parentNode, priorRenderedVdom.contents, newVdom); - priorRenderedVdom.contents = justRenderedVdom; - Curry._1(callbacks.contents.on, /* Render */0); - nextFrameID.contents = undefined; - return /* () */0; - } else { - return /* () */0; - } - }; - var scheduleRender = function (param) { - var match = nextFrameID.contents; - if (match !== undefined) { - return /* () */0; - } else { - var id = window.requestAnimationFrame(doRender); - nextFrameID.contents = id; - return /* () */0; - } - }; - var clearPnode = function (param) { - while(parentNode.childNodes.length > 0) { - var match = parentNode.firstChild; - if (match !== null) { - parentNode.removeChild(match); - } - - }; - return /* () */0; - }; - var oldSub = { - contents: /* NoSub */0 - }; - var handleSubscriptionChange = function (model) { - var newSub = Curry._1(subscriptions, model); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); - return /* () */0; - }; - var handlerStartup = function (param) { - clearPnode(/* () */0); - Tea_cmd.run(callbacks, initCmd); - handleSubscriptionChange(latestModel.contents); - nextFrameID.contents = -1; - doRender(16); - return /* () */0; - }; - var render_string = function (model) { - return Vdom.renderToHtmlString(Curry._1(view, model)); - }; - var handler = function (model, msg) { - var match = Curry._2(update, model, msg); - var newModel = match[0]; - latestModel.contents = newModel; - Tea_cmd.run(callbacks, match[1]); - scheduleRender(/* () */0); - handleSubscriptionChange(newModel); - return newModel; - }; - var handlerShutdown = function (cmd) { - nextFrameID.contents = undefined; - Tea_cmd.run(callbacks, cmd); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); - priorRenderedVdom.contents = /* [] */0; - clearPnode(/* () */0); - return /* () */0; - }; - return { - startup: handlerStartup, - render_string: render_string, - handleMsg: handler, - shutdown: handlerShutdown - }; - }); - } else { - return (function (callbacks) { - var oldSub = { - contents: /* NoSub */0 - }; - var handleSubscriptionChange = function (model) { - var newSub = Curry._1(subscriptions, model); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); - return /* () */0; - }; - return { - startup: (function (param) { - Tea_cmd.run(callbacks, initCmd); - handleSubscriptionChange(initModel); - return /* () */0; - }), - render_string: (function (model) { - return Vdom.renderToHtmlString(Curry._1(view, model)); - }), - handleMsg: (function (model, msg) { - var match = Curry._2(update, model, msg); - var newModel = match[0]; - Tea_cmd.run(callbacks, match[1]); - handleSubscriptionChange(newModel); - return newModel; - }), - shutdown: (function (cmd) { - Tea_cmd.run(callbacks, cmd); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); - return /* () */0; - }) - }; - }); - } -} - -function program(param, pnode, flags) { - Web.polyfills(/* () */0); - var match = Curry._1(param.init, flags); - var initModel = match[0]; - var opnode = (pnode == null) ? undefined : Caml_option.some(pnode); - var pumpInterface = programLoop(param.update, param.view, param.subscriptions, initModel, match[1], opnode); - return programStateWrapper(initModel, pumpInterface, param.shutdown); -} - -function standardProgram(param, pnode, args) { - return program({ - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }, pnode, args); -} - -function beginnerProgram(param, pnode, param$1) { - var update = param.update; - var model = param.model; - return standardProgram({ - init: (function (param) { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - }), - update: (function (model, msg) { - return /* tuple */[ - Curry._2(update, model, msg), - /* NoCmd */0 - ]; - }), - view: param.view, - subscriptions: (function (_model) { - return /* NoSub */0; - }) - }, pnode, /* () */0); -} - -var map = Vdom.map; - -exports.programStateWrapper = programStateWrapper; -exports.programLoop = programLoop; -exports.program = program; -exports.standardProgram = standardProgram; -exports.beginnerProgram = beginnerProgram; -exports.map = map; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_cmd.js b/lib/js/src-ocaml/tea_cmd.js deleted file mode 100644 index 32da92f..0000000 --- a/lib/js/src-ocaml/tea_cmd.js +++ /dev/null @@ -1,75 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); - -function batch(cmds) { - return /* Batch */Block.__(1, [cmds]); -} - -function call(call$1) { - return /* EnqueueCall */Block.__(2, [call$1]); -} - -function fnMsg(fnMsg$1) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(callbacks.contents.enqueue, Curry._1(fnMsg$1, /* () */0)); - })]); -} - -function msg(msg$1) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(callbacks.contents.enqueue, msg$1); - })]); -} - -function run(_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Mapper */0 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - case /* Batch */1 : - return List.fold_left((function(callbacks){ - return function (param, cmd) { - return run(callbacks, cmd); - } - }(callbacks)), /* () */0, param[0]); - case /* EnqueueCall */2 : - return Curry._1(param[0], callbacks); - - } - } - }; -} - -function map(func, cmd) { - var mapper = function (param) { - return Vdom.wrapCallbacks(func, param); - }; - return /* Mapper */Block.__(0, [ - mapper, - cmd - ]); -} - -var none = /* NoCmd */0; - -exports.none = none; -exports.batch = batch; -exports.call = call; -exports.fnMsg = fnMsg; -exports.msg = msg; -exports.run = run; -exports.map = map; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_debug.js b/lib/js/src-ocaml/tea_debug.js deleted file mode 100644 index 03e2221..0000000 --- a/lib/js/src-ocaml/tea_debug.js +++ /dev/null @@ -1,1005 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Printf = require("bs-platform/lib/js/printf.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_cmd = require("./tea_cmd.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_html2 = require("./tea_html2.js"); -var Tea_navigation = require("./tea_navigation.js"); - -function client_msg(msg) { - return /* ClientMsg */Block.__(0, [msg]); -} - -function debug(string_of_msg, update, view, subscriptions, shutdown) { - var init_debug = function (param) { - return /* tuple */[ - { - history: /* :: */[ - /* tuple */[ - "_init_", - param[0] - ], - /* [] */0 - ], - state: /* Running */0, - show_details: false - }, - Tea_cmd.map(client_msg, param[1]) - ]; - }; - var update$prime = function (model, param) { - if (typeof param === "number") { - if (param === /* TogglePaused */0) { - var match = model.state; - if (match) { - return /* tuple */[ - { - history: model.history, - state: /* Running */0, - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } else { - return /* tuple */[ - { - history: model.history, - state: /* Paused */[0], - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } - } else { - return /* tuple */[ - { - history: model.history, - state: model.state, - show_details: !model.show_details - }, - /* NoCmd */0 - ]; - } - } else if (param.tag) { - return /* tuple */[ - { - history: model.history, - state: /* Paused */[param[0]], - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } else if (model.state === /* Running */0) { - var msg = param[0]; - var match$1 = List.hd(model.history); - var match$2 = Curry._2(update, match$1[1], msg); - var dmodel$prime_history = /* :: */[ - /* tuple */[ - Curry._1(string_of_msg, msg), - match$2[0] - ], - model.history - ]; - var dmodel$prime_state = model.state; - var dmodel$prime_show_details = model.show_details; - var dmodel$prime = { - history: dmodel$prime_history, - state: dmodel$prime_state, - show_details: dmodel$prime_show_details - }; - return /* tuple */[ - dmodel$prime, - Tea_cmd.map(client_msg, match$2[1]) - ]; - } else { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - } - }; - var view_styles = function (param) { - var rule = function (selector, properties) { - return /* Text */Block.__(1, [Curry._2(Printf.sprintf(/* Format */[ - /* String */Block.__(2, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " {", - /* String */Block.__(2, [ - /* No_padding */0, - /* Char_literal */Block.__(12, [ - /* "}" */125, - /* End_of_format */0 - ]) - ]) - ]) - ]), - "%s {%s}" - ]), selector, $$String.concat(";", List.map((function (param) { - return param[0] + (":" + param[1]); - }), properties)))]); - }; - return Tea_html2.node(undefined, "style", undefined, undefined, /* [] */0, /* :: */[ - rule("#debug.paused", /* :: */[ - /* tuple */[ - "position", - "fixed" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "left", - "0" - ], - /* :: */[ - /* tuple */[ - "width", - "100%" - ], - /* :: */[ - /* tuple */[ - "height", - "100%" - ], - /* :: */[ - /* tuple */[ - "pointer-events", - "all" - ], - /* :: */[ - /* tuple */[ - "background-color", - "rgba(0,0,0,.1)" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "inset 0 0 10px #333" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav", /* :: */[ - /* tuple */[ - "position", - "fixed" - ], - /* :: */[ - /* tuple */[ - "max-width", - "50%" - ], - /* :: */[ - /* tuple */[ - "bottom", - "0" - ], - /* :: */[ - /* tuple */[ - "right", - "6px" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* :: */[ - /* tuple */[ - "background-color", - "#444" - ], - /* :: */[ - /* tuple */[ - "color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "font-family", - "monospace" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "0 0 10px #333" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug.paused nav", /* :: */[ - /* tuple */[ - "height", - "50%" - ], - /* :: */[ - /* tuple */[ - "padding-bottom", - "2em" - ], - /* [] */0 - ] - ]), - /* :: */[ - rule("#debug nav .toggle", /* :: */[ - /* tuple */[ - "padding", - "6px" - ], - /* :: */[ - /* tuple */[ - "padding-left", - "9px" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "min-width", - "24ch" - ], - /* :: */[ - /* tuple */[ - "text-align", - "center" - ], - /* :: */[ - /* tuple */[ - "border-left", - "3px solid #333" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .toggle:before", /* :: */[ - /* tuple */[ - "content", - "' '" - ], - /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "left", - "0" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "width", - ".5ch" - ], - /* :: */[ - /* tuple */[ - "height", - "1.8ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "1.2ch" - ], - /* :: */[ - /* tuple */[ - "border", - "solid #fff" - ], - /* :: */[ - /* tuple */[ - "border-width", - "0 .5ch" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug.paused nav .toggle:before", /* :: */[ - /* tuple */[ - "border-color", - "transparent" - ], - /* :: */[ - /* tuple */[ - "border-left-color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "border-width", - "1ch" - ], - /* :: */[ - /* tuple */[ - "width", - "0" - ], - /* :: */[ - /* tuple */[ - "height", - "0" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history", /* :: */[ - /* tuple */[ - "margin", - "0" - ], - /* :: */[ - /* tuple */[ - "padding", - "0" - ], - /* :: */[ - /* tuple */[ - "height", - "100%" - ], - /* :: */[ - /* tuple */[ - "overflow-y", - "auto" - ], - /* :: */[ - /* tuple */[ - "list-style", - "none" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li", /* :: */[ - /* tuple */[ - "margin", - "0" - ], - /* :: */[ - /* tuple */[ - "padding", - "0.2ch" - ], - /* :: */[ - /* tuple */[ - "border-left", - "3px solid #333" - ], - /* [] */0 - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li.selected", /* :: */[ - /* tuple */[ - "background-color", - "#333" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history span.details", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "width", - "1ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "0 1ch" - ], - /* :: */[ - /* tuple */[ - "vertical-align", - "super" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li.selected span.details:after", /* :: */[ - /* tuple */[ - "content", - "'\\2026'" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history li.selected.show", /* :: */[ - /* tuple */[ - "border-left", - "3px solid white" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history span.message", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "white-space", - "nowrap" - ], - /* :: */[ - /* tuple */[ - "overflow", - "hidden" - ], - /* :: */[ - /* tuple */[ - "text-overflow", - "ellipsis" - ], - /* :: */[ - /* tuple */[ - "width", - "calc(100% - 75px)" - ], - /* [] */0 - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history span.index", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "min-width", - "3ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "0 1ch" - ], - /* :: */[ - /* tuple */[ - "color", - "#aaa" - ], - /* :: */[ - /* tuple */[ - "text-align", - "right" - ], - /* :: */[ - /* tuple */[ - "float", - "right" - ], - /* [] */0 - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug aside.details", /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "width", - "40ch" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "bottom", - "0" - ], - /* :: */[ - /* tuple */[ - "right", - "100%" - ], - /* :: */[ - /* tuple */[ - "margin-right", - "1.5ch" - ], - /* :: */[ - /* tuple */[ - "overflow", - "scroll" - ], - /* :: */[ - /* tuple */[ - "background-color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "color", - "#000" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "0 0 10px #333" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* :: */[ - /* tuple */[ - "border", - "2px solid #333" - ], - /* :: */[ - /* tuple */[ - "padding", - "1ch" - ], - /* :: */[ - /* tuple */[ - "white-space", - "pre" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]); - }; - var view_details = function (model) { - var format = (function (v) { - var formatRecord = function (data, labels) { - return data.reduce( - function (acc, cur, index) { - acc[labels[index]] = formatValue(cur) - return acc - }, {}) - } - var listToArray = function (data) { - var result = [] - var cur = data - while (typeof cur !== "number") { - result.push(formatValue(cur[0])) - cur = cur[1] - } - return result - } - var formatVariant = function (data, recordVariant) { - if (recordVariant === "::") { - return listToArray(data) - } - else { - return formatRecord(data, [recordVariant]) - } - } - var formatValue = function (x) { - var recordLabels, recordVariant, recordModule, recordPolyVar - if (x == null) { - return null - } - else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { - return formatRecord(x, recordLabels) - } - else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { - return formatRecord(x, recordModule) - } - else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { - return formatVariant(x, recordVariant) - } - else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { - return x[1] - } - else if (Array.isArray(x)) { - // tuple - return x.map(formatValue) - } - else { - // scalar - return x - } - } - return JSON.stringify(formatValue(v), null, 2); - }); - return Tea_html2.aside(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("details"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [format(model)]), - /* [] */0 - ]); - }; - var view_history = function (model, selected_index) { - var count = List.length(model.history); - return Tea_html2.ul(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("history"), - /* [] */0 - ], List.mapi((function (i, param) { - var selected = i === selected_index; - return Tea_html2.li(undefined, undefined, /* :: */[ - Tea_html2.Events.onClick(/* SelectHistoryItem */Block.__(1, [i])), - /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "selected", - selected - ], - /* :: */[ - /* tuple */[ - "show", - selected && model.show_details - ], - /* [] */0 - ] - ]), - /* [] */0 - ] - ], /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "details", - true - ], - /* :: */[ - /* tuple */[ - "show", - true - ], - /* [] */0 - ] - ]), - selected ? /* :: */[ - Tea_html2.Events.onClick(/* ToggleDetails */1), - /* :: */[ - Tea_html2.Attributes.title("toggle details"), - /* [] */0 - ] - ] : /* :: */[ - Tea_html2.Attributes.noProp, - /* :: */[ - Tea_html2.Attributes.noProp, - /* [] */0 - ] - ] - ], /* :: */[ - selected && model.show_details ? view_details(param[1]) : Tea_html2.noNode, - /* [] */0 - ]), - /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("message"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [param[0]]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("index"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(count - i | 0)]), - /* [] */0 - ]), - /* [] */0 - ] - ] - ]); - }), model.history)); - }; - var view$prime = function (model) { - var match = model.state; - var match$1; - if (match) { - var index = match[0]; - match$1 = /* tuple */[ - index, - List.nth(model.history, index)[1], - true - ]; - } else { - match$1 = /* tuple */[ - 0, - List.hd(model.history)[1], - false - ]; - } - var paused = match$1[2]; - var history_count = List.length(model.history); - var vnode = Curry._1(view, match$1[1]); - return Tea_html2.div(undefined, undefined, /* [] */0, /* :: */[ - Vdom.map(client_msg, vnode), - /* :: */[ - Tea_html2.div(undefined, undefined, /* :: */[ - Tea_html2.Attributes.id("debug"), - /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "paused", - paused - ], - /* [] */0 - ]), - /* [] */0 - ] - ], /* :: */[ - view_styles(/* () */0), - /* :: */[ - Tea_html2.nav(undefined, undefined, /* [] */0, /* :: */[ - Tea_html2.div(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("toggle"), - /* :: */[ - Tea_html2.Events.onClick(/* TogglePaused */0), - /* :: */[ - paused ? Tea_html2.Attributes.title("click to resume") : Tea_html2.Attributes.title("click to pause"), - /* [] */0 - ] - ] - ], /* :: */[ - /* Text */Block.__(1, [Curry._1(Printf.sprintf(/* Format */[ - /* String_literal */Block.__(11, [ - "Explore History (", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* Char_literal */Block.__(12, [ - /* ")" */41, - /* End_of_format */0 - ]) - ]) - ]), - "Explore History (%d)" - ]), history_count)]), - /* [] */0 - ]), - /* :: */[ - paused ? view_history(model, match$1[0]) : Tea_html2.noNode, - /* [] */0 - ] - ]), - /* [] */0 - ] - ]), - /* [] */0 - ] - ]); - }; - var subscriptions$prime = function (model) { - return Tea_sub.map(client_msg, Curry._1(subscriptions, List.hd(model.history)[1])); - }; - var shutdown$prime = function (model) { - return Tea_cmd.map(client_msg, Curry._1(shutdown, List.hd(model.history)[1])); - }; - return /* tuple */[ - init_debug, - update$prime, - view$prime, - subscriptions$prime, - shutdown$prime - ]; -} - -function debug_program(string_of_msg, param) { - var init = param.init; - var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); - var init_debug = match[0]; - return { - init: (function (flags) { - return Curry._1(init_debug, Curry._1(init, flags)); - }), - update: match[1], - view: match[2], - subscriptions: match[3], - shutdown: match[4] - }; -} - -function debug_navigation_program(string_of_msg, param) { - var init = param.init; - var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); - var init_debug = match[0]; - return { - init: (function (flags, $$location) { - return Curry._1(init_debug, Curry._2(init, flags, $$location)); - }), - update: match[1], - view: match[2], - subscriptions: match[3], - shutdown: match[4] - }; -} - -function beginnerProgram(param, string_of_msg, pnode, flags) { - var update = param.update; - var model = param.model; - var debugged = debug_program(string_of_msg, { - init: (function (param) { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - }), - update: (function (model, msg) { - return /* tuple */[ - Curry._2(update, model, msg), - /* NoCmd */0 - ]; - }), - view: param.view, - subscriptions: (function (_model) { - return /* NoSub */0; - }), - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }); - return Tea_app.program(debugged, pnode, flags); -} - -function standardProgram(param, string_of_msg, pnode, flags) { - var debugged = debug_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }); - return Tea_app.program(debugged, pnode, flags); -} - -function program(param, string_of_msg, pnode, flags) { - var debugged = debug_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: param.shutdown - }); - return Tea_app.program(debugged, pnode, flags); -} - -function navigationProgram(location_to_msg, param, string_of_msg, pnode, flags) { - var $$location = function ($$location$1) { - return /* ClientMsg */Block.__(0, [Curry._1(location_to_msg, $$location$1)]); - }; - var debugged = debug_navigation_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: param.shutdown - }); - return Tea_navigation.navigationProgram($$location, debugged)(pnode, flags); -} - -exports.client_msg = client_msg; -exports.debug = debug; -exports.debug_program = debug_program; -exports.debug_navigation_program = debug_navigation_program; -exports.beginnerProgram = beginnerProgram; -exports.standardProgram = standardProgram; -exports.program = program; -exports.navigationProgram = navigationProgram; -/* Tea_html2 Not a pure module */ diff --git a/lib/js/src-ocaml/tea_ex.js b/lib/js/src-ocaml/tea_ex.js deleted file mode 100644 index 1b09519..0000000 --- a/lib/js/src-ocaml/tea_ex.js +++ /dev/null @@ -1,115 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_task = require("./tea_task.js"); -var Web_window_localstorage = require("./web_window_localstorage.js"); - -function render_event($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var enableCall = function (callbacks) { - Curry._1(callbacks.on, /* AddRenderMsg */Block.__(0, [msg])); - return (function (param) { - return Curry._1(callbacks.on, /* RemoveRenderMsg */Block.__(1, [msg])); - }); - }; - return Tea_sub.registration(key, enableCall); -} - -var length = /* Task */[(function (cb) { - var match = Web_window_localstorage.length(window); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; - -var clear = /* Task */[(function (cb) { - var match = Web_window_localstorage.clear(window); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; - -function clearCmd(param) { - return Tea_task.attemptOpt((function (param) { - return ; - }), clear); -} - -function key(idx) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.key(window, idx); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function getItem(key) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.getItem(window, key); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function removeItem(key) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.removeItem(window, key); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function removeItemCmd(key) { - return Tea_task.attemptOpt((function (param) { - return ; - }), removeItem(key)); -} - -function setItem(key, value) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.setItem(window, key, value); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [/* () */0])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function setItemCmd(key, value) { - return Tea_task.attemptOpt((function (param) { - return ; - }), setItem(key, value)); -} - -var LocalStorage = { - length: length, - clear: clear, - clearCmd: clearCmd, - key: key, - getItem: getItem, - removeItem: removeItem, - removeItemCmd: removeItemCmd, - setItem: setItem, - setItemCmd: setItemCmd -}; - -exports.render_event = render_event; -exports.LocalStorage = LocalStorage; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_html.js b/lib/js/src-ocaml/tea_html.js deleted file mode 100644 index 30942ec..0000000 --- a/lib/js/src-ocaml/tea_html.js +++ /dev/null @@ -1,1113 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_json = require("./tea_json.js"); -var Tea_result = require("./tea_result.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function text(str) { - return /* Text */Block.__(1, [str]); -} - -var lazy1 = Vdom.lazyGen; - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, nodes) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return Vdom.fullnode(namespace, tagName, key, unique, props, nodes); -} - -function br(props) { - return Vdom.fullnode("", "br", "br", "br", props, /* [] */0); -} - -function br$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "br", key, unique, props, nodes); -} - -function div($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "div", key, unique, props, nodes); -} - -function span($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "span", key, unique, props, nodes); -} - -function p($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "p", key, unique, props, nodes); -} - -function pre($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "pre", key, unique, props, nodes); -} - -function a($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "a", key, unique, props, nodes); -} - -function section($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "section", key, unique, props, nodes); -} - -function header($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "header", key, unique, props, nodes); -} - -function footer($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "footer", key, unique, props, nodes); -} - -function h1($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h1", key, unique, props, nodes); -} - -function h2($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h2", key, unique, props, nodes); -} - -function h3($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h3", key, unique, props, nodes); -} - -function h4($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h4", key, unique, props, nodes); -} - -function h5($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h5", key, unique, props, nodes); -} - -function h6($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h6", key, unique, props, nodes); -} - -function i($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "i", key, unique, props, nodes); -} - -function strong($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "strong", key, unique, props, nodes); -} - -function button($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "button", key, unique, props, nodes); -} - -function input$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "input", key, unique, props, nodes); -} - -function textarea($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "textarea", key, unique, props, nodes); -} - -function label($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "label", key, unique, props, nodes); -} - -function ul($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ul", key, unique, props, nodes); -} - -function ol($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ol", key, unique, props, nodes); -} - -function li($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "li", key, unique, props, nodes); -} - -function table($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "table", key, unique, props, nodes); -} - -function thead($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "thead", key, unique, props, nodes); -} - -function tfoot($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tfoot", key, unique, props, nodes); -} - -function tbody($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tbody", key, unique, props, nodes); -} - -function th($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "th", key, unique, props, nodes); -} - -function tr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tr", key, unique, props, nodes); -} - -function td($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "td", key, unique, props, nodes); -} - -function progress($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "progress", key, unique, props, nodes); -} - -function img($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "img", key, unique, props, nodes); -} - -function select($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "select", key, unique, props, nodes); -} - -function option$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "option", key, unique, props, nodes); -} - -function form($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "form", key, unique, props, nodes); -} - -function nav($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "nav", key, unique, props, nodes); -} - -function main($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "main", key, unique, props, nodes); -} - -function aside($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "aside", key, unique, props, nodes); -} - -function article($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "article", key, unique, props, nodes); -} - -function details($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "details", key, unique, props, nodes); -} - -function figcaption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figcaption", key, unique, props, nodes); -} - -function figure($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figure", key, unique, props, nodes); -} - -function mark($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "mark", key, unique, props, nodes); -} - -function summary($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "summary", key, unique, props, nodes); -} - -function time($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "time", key, unique, props, nodes); -} - -function hr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "hr", key, unique, props, nodes); -} - -function blockquote($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "blockquote", key, unique, props, nodes); -} - -function code($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "code", key, unique, props, nodes); -} - -function em($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "em", key, unique, props, nodes); -} - -function b($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "b", key, unique, props, nodes); -} - -function u($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "u", key, unique, props, nodes); -} - -function sub($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sub", key, unique, props, nodes); -} - -function sup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sup", key, unique, props, nodes); -} - -function dl($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dl", key, unique, props, nodes); -} - -function dt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dt", key, unique, props, nodes); -} - -function dd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dd", key, unique, props, nodes); -} - -function iframe($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "iframe", key, unique, props, nodes); -} - -function canvas($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "canvas", key, unique, props, nodes); -} - -function address($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "address", key, unique, props, nodes); -} - -function caption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "caption", key, unique, props, nodes); -} - -function colgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "colgroup", key, unique, props, nodes); -} - -function col($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "col", key, unique, props, nodes); -} - -function fieldset($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "fieldset", key, unique, props, nodes); -} - -function legend($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "legend", key, unique, props, nodes); -} - -function datalist($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "datalist", key, unique, props, nodes); -} - -function optgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "optgroup", key, unique, props, nodes); -} - -function output($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "output", key, unique, props, nodes); -} - -function meter($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meter", key, unique, props, nodes); -} - -function audio($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "audio", key, unique, props, nodes); -} - -function video($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "video", key, unique, props, nodes); -} - -function source($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "source", key, unique, props, nodes); -} - -function track($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "track", key, unique, props, nodes); -} - -function embed($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "embed", key, unique, props, nodes); -} - -function object$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "object", key, unique, props, nodes); -} - -function param($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "param", key, unique, props, nodes); -} - -function ins($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ins", key, unique, props, nodes); -} - -function del($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "del", key, unique, props, nodes); -} - -function small($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "small", key, unique, props, nodes); -} - -function cite($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "cite", key, unique, props, nodes); -} - -function dfn($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dfn", key, unique, props, nodes); -} - -function abbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "abbr", key, unique, props, nodes); -} - -function var$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "var", key, unique, props, nodes); -} - -function samp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "samp", key, unique, props, nodes); -} - -function kbd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "kbd", key, unique, props, nodes); -} - -function s($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "s", key, unique, props, nodes); -} - -function q($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "q", key, unique, props, nodes); -} - -function rt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rt", key, unique, props, nodes); -} - -function bdi($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdi", key, unique, props, nodes); -} - -function bdo($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdo", key, unique, props, nodes); -} - -function wbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "wbr", key, unique, props, nodes); -} - -function menuitem($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menuitem", key, unique, props, nodes); -} - -function menu($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menu", key, unique, props, nodes); -} - -function id(str) { - return /* RawProp */Block.__(0, [ - "id", - str - ]); -} - -function href(str) { - return /* Attribute */Block.__(1, [ - "", - "href", - str - ]); -} - -function src(str) { - return /* Attribute */Block.__(1, [ - "", - "src", - str - ]); -} - -function title(str) { - return /* Attribute */Block.__(1, [ - "", - "title", - str - ]); -} - -function class$prime(name) { - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function classList(classes) { - var name = $$String.concat(" ", List.map((function (param) { - return param[0]; - }), List.filter((function (param) { - return param[1]; - }))(classes))); - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function type$prime(typ) { - return /* RawProp */Block.__(0, [ - "type", - typ - ]); -} - -var style = Vdom.style; - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function placeholder(str) { - return /* RawProp */Block.__(0, [ - "placeholder", - str - ]); -} - -function autofocus(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autofocus", - "autofocus" - ]); - } else { - return /* NoProp */0; - } -} - -function value(str) { - return /* RawProp */Block.__(0, [ - "value", - str - ]); -} - -function name(str) { - return /* RawProp */Block.__(0, [ - "name", - str - ]); -} - -function checked(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "checked", - "checked" - ]); - } else { - return /* NoProp */0; - } -} - -function for$prime(str) { - return /* RawProp */Block.__(0, [ - "htmlFor", - str - ]); -} - -function hidden(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "hidden", - "hidden" - ]); - } else { - return /* NoProp */0; - } -} - -function target(t) { - return /* RawProp */Block.__(0, [ - "target", - t - ]); -} - -function action(a) { - return /* RawProp */Block.__(0, [ - "action", - a - ]); -} - -function method$prime(m) { - return /* RawProp */Block.__(0, [ - "method", - m - ]); -} - -var onCB = Vdom.onCB; - -var onMsg = Vdom.onMsg; - -function onInputOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("input", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onInput($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onInputOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onChangeOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onChange($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onChangeOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onClick(msg) { - return Vdom.onMsg("click", msg); -} - -function onDoubleClick(msg) { - return Vdom.onMsg("dblclick", msg); -} - -function onBlur(msg) { - return Vdom.onMsg("blur", msg); -} - -function onFocus(msg) { - return Vdom.onMsg("focus", msg); -} - -function onCheckOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.checked; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onCheck($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onCheckOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onMouseDown(msg) { - return Vdom.onMsg("mousedown", msg); -} - -function onMouseUp(msg) { - return Vdom.onMsg("mouseup", msg); -} - -function onMouseEnter(msg) { - return Vdom.onMsg("mouseenter", msg); -} - -function onMouseLeave(msg) { - return Vdom.onMsg("mouseleave", msg); -} - -function onMouseOver(msg) { - return Vdom.onMsg("mouseover", msg); -} - -function onMouseOut(msg) { - return Vdom.onMsg("mouseout", msg); -} - -var defaultOptions = { - stopPropagation: false, - preventDefault: false -}; - -function onWithOptions(key, eventName, options, decoder) { - return Vdom.onCB(eventName, key, (function ($$event) { - if (options.stopPropagation) { - $$event.stopPropagation(); - } - if (options.preventDefault) { - $$event.preventDefault(); - } - return Tea_result.result_to_option(Tea_json.Decoder.decodeEvent(decoder, $$event)); - })); -} - -function on(key, eventName, decoder) { - return onWithOptions(key, eventName, defaultOptions, decoder); -} - -var targetValue = Tea_json.Decoder.at(/* :: */[ - "target", - /* :: */[ - "value", - /* [] */0 - ] - ], Tea_json.Decoder.string); - -var targetChecked = Tea_json.Decoder.at(/* :: */[ - "target", - /* :: */[ - "checked", - /* [] */0 - ] - ], Tea_json.Decoder.bool); - -var keyCode = Tea_json.Decoder.field("keyCode", Tea_json.Decoder.$$int); - -function max(value) { - return /* Attribute */Block.__(1, [ - "", - "max", - value - ]); -} - -function min(value) { - return /* Attribute */Block.__(1, [ - "", - "min", - value - ]); -} - -function step(value) { - return /* Attribute */Block.__(1, [ - "", - "step", - value - ]); -} - -function disabled(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "disabled", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function selected(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "selected", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function acceptCharset(c) { - return /* Attribute */Block.__(1, [ - "", - "accept-charset", - c - ]); -} - -function rel(value) { - return /* Attribute */Block.__(1, [ - "", - "rel", - value - ]); -} - -var Attributes = { - max: max, - min: min, - step: step, - disabled: disabled, - selected: selected, - acceptCharset: acceptCharset, - rel: rel -}; - -var Cmds = /* alias */0; - -var map = Tea_app.map; - -var noNode = Vdom.noNode; - -var noProp = /* NoProp */0; - -exports.Cmds = Cmds; -exports.map = map; -exports.noNode = noNode; -exports.text = text; -exports.lazy1 = lazy1; -exports.node = node; -exports.br = br; -exports.br$prime = br$prime; -exports.div = div; -exports.span = span; -exports.p = p; -exports.pre = pre; -exports.a = a; -exports.section = section; -exports.header = header; -exports.footer = footer; -exports.h1 = h1; -exports.h2 = h2; -exports.h3 = h3; -exports.h4 = h4; -exports.h5 = h5; -exports.h6 = h6; -exports.i = i; -exports.strong = strong; -exports.button = button; -exports.input$prime = input$prime; -exports.textarea = textarea; -exports.label = label; -exports.ul = ul; -exports.ol = ol; -exports.li = li; -exports.table = table; -exports.thead = thead; -exports.tfoot = tfoot; -exports.tbody = tbody; -exports.th = th; -exports.tr = tr; -exports.td = td; -exports.progress = progress; -exports.img = img; -exports.select = select; -exports.option$prime = option$prime; -exports.form = form; -exports.nav = nav; -exports.main = main; -exports.aside = aside; -exports.article = article; -exports.details = details; -exports.figcaption = figcaption; -exports.figure = figure; -exports.mark = mark; -exports.summary = summary; -exports.time = time; -exports.hr = hr; -exports.blockquote = blockquote; -exports.code = code; -exports.em = em; -exports.b = b; -exports.u = u; -exports.sub = sub; -exports.sup = sup; -exports.dl = dl; -exports.dt = dt; -exports.dd = dd; -exports.iframe = iframe; -exports.canvas = canvas; -exports.address = address; -exports.caption = caption; -exports.colgroup = colgroup; -exports.col = col; -exports.fieldset = fieldset; -exports.legend = legend; -exports.datalist = datalist; -exports.optgroup = optgroup; -exports.output = output; -exports.meter = meter; -exports.audio = audio; -exports.video = video; -exports.source = source; -exports.track = track; -exports.embed = embed; -exports.object$prime = object$prime; -exports.param = param; -exports.ins = ins; -exports.del = del; -exports.small = small; -exports.cite = cite; -exports.dfn = dfn; -exports.abbr = abbr; -exports.var$prime = var$prime; -exports.samp = samp; -exports.kbd = kbd; -exports.s = s; -exports.q = q; -exports.rt = rt; -exports.bdi = bdi; -exports.bdo = bdo; -exports.wbr = wbr; -exports.menuitem = menuitem; -exports.menu = menu; -exports.noProp = noProp; -exports.id = id; -exports.href = href; -exports.src = src; -exports.title = title; -exports.class$prime = class$prime; -exports.classList = classList; -exports.type$prime = type$prime; -exports.style = style; -exports.styles = styles; -exports.placeholder = placeholder; -exports.autofocus = autofocus; -exports.value = value; -exports.name = name; -exports.checked = checked; -exports.for$prime = for$prime; -exports.hidden = hidden; -exports.target = target; -exports.action = action; -exports.method$prime = method$prime; -exports.onCB = onCB; -exports.onMsg = onMsg; -exports.onInputOpt = onInputOpt; -exports.onInput = onInput; -exports.onChangeOpt = onChangeOpt; -exports.onChange = onChange; -exports.onClick = onClick; -exports.onDoubleClick = onDoubleClick; -exports.onBlur = onBlur; -exports.onFocus = onFocus; -exports.onCheckOpt = onCheckOpt; -exports.onCheck = onCheck; -exports.onMouseDown = onMouseDown; -exports.onMouseUp = onMouseUp; -exports.onMouseEnter = onMouseEnter; -exports.onMouseLeave = onMouseLeave; -exports.onMouseOver = onMouseOver; -exports.onMouseOut = onMouseOut; -exports.defaultOptions = defaultOptions; -exports.onWithOptions = onWithOptions; -exports.on = on; -exports.targetValue = targetValue; -exports.targetChecked = targetChecked; -exports.keyCode = keyCode; -exports.Attributes = Attributes; -/* targetValue Not a pure module */ diff --git a/lib/js/src-ocaml/tea_html2.js b/lib/js/src-ocaml/tea_html2.js deleted file mode 100644 index 4a875d9..0000000 --- a/lib/js/src-ocaml/tea_html2.js +++ /dev/null @@ -1,1820 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Bytes = require("bs-platform/lib/js/bytes.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_html = require("./tea_html.js"); -var Tea_json = require("./tea_json.js"); -var Caml_bytes = require("bs-platform/lib/js/caml_bytes.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function text(str) { - return /* Text */Block.__(1, [str]); -} - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, nodes) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return Vdom.fullnode(namespace, tagName, key, unique, props, nodes); -} - -var lazy1 = Vdom.lazyGen; - -function h1($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h1", key, unique, props, nodes); -} - -function h2($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h2", key, unique, props, nodes); -} - -function h3($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h3", key, unique, props, nodes); -} - -function h4($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h4", key, unique, props, nodes); -} - -function h5($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h5", key, unique, props, nodes); -} - -function h6($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h6", key, unique, props, nodes); -} - -function div($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "div", key, unique, props, nodes); -} - -function p($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "p", key, unique, props, nodes); -} - -function hr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "hr", key, unique, props, nodes); -} - -function pre($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "pre", key, unique, props, nodes); -} - -function blockquote($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "blockquote", key, unique, props, nodes); -} - -function span($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "span", key, unique, props, nodes); -} - -function a($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "a", key, unique, props, nodes); -} - -function code($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "code", key, unique, props, nodes); -} - -function em($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "em", key, unique, props, nodes); -} - -function strong($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "strong", key, unique, props, nodes); -} - -function i($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "i", key, unique, props, nodes); -} - -function b($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "b", key, unique, props, nodes); -} - -function u($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "u", key, unique, props, nodes); -} - -function sub($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sub", key, unique, props, nodes); -} - -function sup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sup", key, unique, props, nodes); -} - -function br(props) { - return Vdom.fullnode("", "br", "br", "br", props, /* [] */0); -} - -function br$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "br", key, unique, props, nodes); -} - -function ol($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ol", key, unique, props, nodes); -} - -function ul($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ul", key, unique, props, nodes); -} - -function li($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "li", key, unique, props, nodes); -} - -function dl($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dl", key, unique, props, nodes); -} - -function dt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dt", key, unique, props, nodes); -} - -function dd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dd", key, unique, props, nodes); -} - -function img($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "img", key, unique, props, nodes); -} - -function iframe($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "iframe", key, unique, props, nodes); -} - -function canvas($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "canvas", key, unique, props, nodes); -} - -function math($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "math", key, unique, props, nodes); -} - -function form($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "form", key, unique, props, nodes); -} - -function input$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "input", key, unique, props, nodes); -} - -function textarea($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "textarea", key, unique, props, nodes); -} - -function button($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "button", key, unique, props, nodes); -} - -function select($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "select", key, unique, props, nodes); -} - -function option$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "option", key, unique, props, nodes); -} - -function optgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "optgroup", key, unique, props, nodes); -} - -function label($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "label", key, unique, props, nodes); -} - -function fieldset($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "fieldset", key, unique, props, nodes); -} - -function legend($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "legend", key, unique, props, nodes); -} - -function section($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "section", key, unique, props, nodes); -} - -function nav($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "nav", key, unique, props, nodes); -} - -function article($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "article", key, unique, props, nodes); -} - -function aside($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "aside", key, unique, props, nodes); -} - -function header($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "header", key, unique, props, nodes); -} - -function footer($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "footer", key, unique, props, nodes); -} - -function address($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "address", key, unique, props, nodes); -} - -function main($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "main", key, unique, props, nodes); -} - -function body($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "body", key, unique, props, nodes); -} - -function figure($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figure", key, unique, props, nodes); -} - -function figcaption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figcaption", key, unique, props, nodes); -} - -function table($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "table", key, unique, props, nodes); -} - -function caption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "caption", key, unique, props, nodes); -} - -function colgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "colgroup", key, unique, props, nodes); -} - -function col($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "col", key, unique, props, nodes); -} - -function tbody($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tbody", key, unique, props, nodes); -} - -function thead($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "thead", key, unique, props, nodes); -} - -function tfoot($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tfoot", key, unique, props, nodes); -} - -function tr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tr", key, unique, props, nodes); -} - -function th($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "th", key, unique, props, nodes); -} - -function td($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "td", key, unique, props, nodes); -} - -function datalist($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "datalist", key, unique, props, nodes); -} - -function keygen($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "keygen", key, unique, props, nodes); -} - -function output($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "output", key, unique, props, nodes); -} - -function progress($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "progress", key, unique, props, nodes); -} - -function meter($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meter", key, unique, props, nodes); -} - -function audio($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "audio", key, unique, props, nodes); -} - -function video($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "video", key, unique, props, nodes); -} - -function source($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "source", key, unique, props, nodes); -} - -function track($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "track", key, unique, props, nodes); -} - -function embed($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "embed", key, unique, props, nodes); -} - -function object$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "object", key, unique, props, nodes); -} - -function param($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "param", key, unique, props, nodes); -} - -function ins($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ins", key, unique, props, nodes); -} - -function del($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "del", key, unique, props, nodes); -} - -function small($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "small", key, unique, props, nodes); -} - -function cite($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "cite", key, unique, props, nodes); -} - -function dfn($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dfn", key, unique, props, nodes); -} - -function abbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "abbr", key, unique, props, nodes); -} - -function time($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "time", key, unique, props, nodes); -} - -function var$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "var", key, unique, props, nodes); -} - -function samp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "samp", key, unique, props, nodes); -} - -function kbd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "kbd", key, unique, props, nodes); -} - -function s($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "s", key, unique, props, nodes); -} - -function q($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "q", key, unique, props, nodes); -} - -function mark($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "mark", key, unique, props, nodes); -} - -function ruby($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ruby", key, unique, props, nodes); -} - -function rt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rt", key, unique, props, nodes); -} - -function rp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rp", key, unique, props, nodes); -} - -function bdi($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdi", key, unique, props, nodes); -} - -function bdo($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdo", key, unique, props, nodes); -} - -function wbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "wbr", key, unique, props, nodes); -} - -function details($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "details", key, unique, props, nodes); -} - -function summary($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "summary", key, unique, props, nodes); -} - -function menuitem($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menuitem", key, unique, props, nodes); -} - -function menu($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menu", key, unique, props, nodes); -} - -function meta($staropt$star, $staropt$star$1, props) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meta", key, unique, props, /* [] */0); -} - -function style($staropt$star, $staropt$star$1, props, content) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "style", key, unique, props, /* :: */[ - /* Text */Block.__(1, [content]), - /* [] */0 - ]); -} - -function title($staropt$star, $staropt$star$1, props, content) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "title", key, unique, props, /* :: */[ - /* Text */Block.__(1, [content]), - /* [] */0 - ]); -} - -function link($staropt$star, $staropt$star$1, props) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "link", key, unique, props, /* [] */0); -} - -var style$1 = Vdom.style; - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function class$prime(name) { - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function classList(classes) { - var name = $$String.concat(" ", List.map((function (param) { - return param[0]; - }), List.filter((function (param) { - return param[1]; - }))(classes))); - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function id(str) { - return /* RawProp */Block.__(0, [ - "id", - str - ]); -} - -function title$1(str) { - return /* Attribute */Block.__(1, [ - "", - "title", - str - ]); -} - -function hidden(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "hidden", - "hidden" - ]); - } else { - return /* NoProp */0; - } -} - -function type$prime(typ) { - return /* RawProp */Block.__(0, [ - "type", - typ - ]); -} - -function value(str) { - return /* RawProp */Block.__(0, [ - "value", - str - ]); -} - -function defaultValue(str) { - return /* RawProp */Block.__(0, [ - "defaultValue", - str - ]); -} - -function checked(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "checked", - "checked" - ]); - } else { - return /* NoProp */0; - } -} - -function placeholder(str) { - return /* RawProp */Block.__(0, [ - "placeholder", - str - ]); -} - -function selected(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "selected", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function accept(c) { - return /* Attribute */Block.__(1, [ - "", - "accept", - c - ]); -} - -function acceptCharset(c) { - return /* Attribute */Block.__(1, [ - "", - "accept-charset", - c - ]); -} - -function action(a) { - return /* RawProp */Block.__(0, [ - "action", - a - ]); -} - -function autocomplete(b) { - return /* RawProp */Block.__(0, [ - "autocomplete", - b ? "on" : "off" - ]); -} - -function autofocus(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autofocus", - "autofocus" - ]); - } else { - return /* NoProp */0; - } -} - -function disabled(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "disabled", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function enctype(encoding) { - return /* Attribute */Block.__(1, [ - "", - "enctype", - encoding - ]); -} - -function formaction(url) { - return /* Attribute */Block.__(1, [ - "", - "formaction", - url - ]); -} - -function list(value) { - return /* Attribute */Block.__(1, [ - "", - "list", - value - ]); -} - -function minlength(n) { - return /* Attribute */Block.__(1, [ - "", - "minlength", - String(n) - ]); -} - -function maxlength(n) { - return /* Attribute */Block.__(1, [ - "", - "maxlength", - String(n) - ]); -} - -function method$prime(m) { - return /* RawProp */Block.__(0, [ - "method", - m - ]); -} - -function multiple(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "multiple", - "multiple" - ]); - } else { - return /* NoProp */0; - } -} - -function name(str) { - return /* RawProp */Block.__(0, [ - "name", - str - ]); -} - -function novalidate(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "novalidate", - "novalidate" - ]); - } else { - return /* NoProp */0; - } -} - -function pattern(p) { - return /* RawProp */Block.__(0, [ - "pattern", - p - ]); -} - -function readonly(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "readonly", - "readonly" - ]); - } else { - return /* NoProp */0; - } -} - -function required(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "required", - "required" - ]); - } else { - return /* NoProp */0; - } -} - -function size(n) { - return /* Attribute */Block.__(1, [ - "", - "size", - String(n) - ]); -} - -function for$prime(str) { - return /* RawProp */Block.__(0, [ - "htmlFor", - str - ]); -} - -function form$1(value) { - return /* Attribute */Block.__(1, [ - "", - "form", - value - ]); -} - -function max(value) { - return /* Attribute */Block.__(1, [ - "", - "max", - value - ]); -} - -function min(value) { - return /* Attribute */Block.__(1, [ - "", - "min", - value - ]); -} - -function step(value) { - return /* Attribute */Block.__(1, [ - "", - "step", - value - ]); -} - -function cols(n) { - return /* Attribute */Block.__(1, [ - "", - "cols", - String(n) - ]); -} - -function rows(n) { - return /* Attribute */Block.__(1, [ - "", - "rows", - String(n) - ]); -} - -function wrap(value) { - return /* RawProp */Block.__(0, [ - "wrap", - value - ]); -} - -function href(str) { - return /* Attribute */Block.__(1, [ - "", - "href", - str - ]); -} - -function target(t) { - return /* RawProp */Block.__(0, [ - "target", - t - ]); -} - -function download(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "download", - "" - ]); - } else { - return /* NoProp */0; - } -} - -function downloadAs(name) { - return /* RawProp */Block.__(0, [ - "download", - name - ]); -} - -function hreflang(code) { - return /* RawProp */Block.__(0, [ - "hreflang", - code - ]); -} - -function media(value) { - return /* Attribute */Block.__(1, [ - "", - "media", - value - ]); -} - -function ping(url) { - return /* RawProp */Block.__(0, [ - "ping", - url - ]); -} - -function rel(value) { - return /* Attribute */Block.__(1, [ - "", - "rel", - value - ]); -} - -function ismap(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "ismap", - "ismap" - ]); - } else { - return /* NoProp */0; - } -} - -function usemap(name) { - return /* RawProp */Block.__(0, [ - "usemap", - name - ]); -} - -function shape(value) { - return /* RawProp */Block.__(0, [ - "shape", - value - ]); -} - -function coords(value) { - return /* RawProp */Block.__(0, [ - "coords", - value - ]); -} - -function src(str) { - return /* Attribute */Block.__(1, [ - "", - "src", - str - ]); -} - -function height(n) { - return /* Attribute */Block.__(1, [ - "", - "height", - String(n) - ]); -} - -function width(n) { - return /* Attribute */Block.__(1, [ - "", - "width", - String(n) - ]); -} - -function alt(value) { - return /* RawProp */Block.__(0, [ - "alt", - value - ]); -} - -function autoplay(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autoplay", - "autoplay" - ]); - } else { - return /* NoProp */0; - } -} - -function controls(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "controls", - "controls" - ]); - } else { - return /* NoProp */0; - } -} - -function loop(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "loop", - "loop" - ]); - } else { - return /* NoProp */0; - } -} - -function preload(value) { - return /* RawProp */Block.__(0, [ - "preload", - value - ]); -} - -function poster(url) { - return /* RawProp */Block.__(0, [ - "poster", - url - ]); -} - -function $$default(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "default", - "default" - ]); - } else { - return /* NoProp */0; - } -} - -function kind(value) { - return /* RawProp */Block.__(0, [ - "kind", - value - ]); -} - -function srclang(code) { - return /* RawProp */Block.__(0, [ - "srclang", - code - ]); -} - -function sandbox(value) { - return /* RawProp */Block.__(0, [ - "sandbox", - value - ]); -} - -function seamless(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "seamless", - "seamless" - ]); - } else { - return /* NoProp */0; - } -} - -function srcdoc(value) { - return /* RawProp */Block.__(0, [ - "srcdoc", - value - ]); -} - -function reversed(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "reversed", - "reversed" - ]); - } else { - return /* NoProp */0; - } -} - -function start(n) { - return /* RawProp */Block.__(0, [ - "start", - String(n) - ]); -} - -function colspan(n) { - return /* Attribute */Block.__(1, [ - "", - "colspan", - String(n) - ]); -} - -function rowspan(n) { - return /* Attribute */Block.__(1, [ - "", - "rowspan", - String(n) - ]); -} - -function headers(value) { - return /* RawProp */Block.__(0, [ - "headers", - value - ]); -} - -function scope(value) { - return /* RawProp */Block.__(0, [ - "scope", - value - ]); -} - -function align(value) { - return /* RawProp */Block.__(0, [ - "align", - value - ]); -} - -function async(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "async", - "async" - ]); - } else { - return /* NoProp */0; - } -} - -function charset(value) { - return /* Attribute */Block.__(1, [ - "", - "charset", - value - ]); -} - -function content(value) { - return /* Attribute */Block.__(1, [ - "", - "content", - value - ]); -} - -function defer(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "defer", - "defer" - ]); - } else { - return /* NoProp */0; - } -} - -function httpEquiv(value) { - return /* RawProp */Block.__(0, [ - "http-equiv", - value - ]); -} - -function language(value) { - return /* RawProp */Block.__(0, [ - "language", - value - ]); -} - -function scoped(value) { - return /* RawProp */Block.__(0, [ - "scoped", - value - ]); -} - -function accesskey(ch) { - return /* RawProp */Block.__(0, [ - "accesskey", - Caml_bytes.bytes_to_string(Bytes.make(1, ch)) - ]); -} - -function contenteditable(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "contenteditable", - "contenteditable" - ]); - } else { - return /* NoProp */0; - } -} - -function contextmenu(id) { - return /* Attribute */Block.__(1, [ - "", - "contextmenu", - id - ]); -} - -function dir(value) { - return /* RawProp */Block.__(0, [ - "dir", - value - ]); -} - -function draggable(value) { - return /* Attribute */Block.__(1, [ - "", - "draggable", - value - ]); -} - -function dropzone(value) { - return /* RawProp */Block.__(0, [ - "dropzone", - value - ]); -} - -function itemprop(value) { - return /* Attribute */Block.__(1, [ - "", - "itemprop", - value - ]); -} - -function lang(code) { - return /* RawProp */Block.__(0, [ - "lang", - code - ]); -} - -function spellcheck(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "spellcheck", - "spellcheck" - ]); - } else { - return /* NoProp */0; - } -} - -function tabindex(n) { - return /* Attribute */Block.__(1, [ - "", - "tabindex", - String(n) - ]); -} - -function challenge(value) { - return /* Attribute */Block.__(1, [ - "", - "challenge", - value - ]); -} - -function keytype(value) { - return /* RawProp */Block.__(0, [ - "keytype", - value - ]); -} - -function cite$1(url) { - return /* RawProp */Block.__(0, [ - "cite", - url - ]); -} - -function datetime(value) { - return /* Attribute */Block.__(1, [ - "", - "datetime", - value - ]); -} - -function pubdate(value) { - return /* Attribute */Block.__(1, [ - "", - "pubdate", - value - ]); -} - -function manifest(value) { - return /* Attribute */Block.__(1, [ - "", - "manifest", - value - ]); -} - -var Attributes = { - noProp: /* NoProp */0, - style: style$1, - styles: styles, - class$prime: class$prime, - classList: classList, - id: id, - title: title$1, - hidden: hidden, - type$prime: type$prime, - value: value, - defaultValue: defaultValue, - checked: checked, - placeholder: placeholder, - selected: selected, - accept: accept, - acceptCharset: acceptCharset, - action: action, - autocomplete: autocomplete, - autofocus: autofocus, - disabled: disabled, - enctype: enctype, - formaction: formaction, - list: list, - minlength: minlength, - maxlength: maxlength, - method$prime: method$prime, - multiple: multiple, - name: name, - novalidate: novalidate, - pattern: pattern, - readonly: readonly, - required: required, - size: size, - for$prime: for$prime, - form: form$1, - max: max, - min: min, - step: step, - cols: cols, - rows: rows, - wrap: wrap, - href: href, - target: target, - download: download, - downloadAs: downloadAs, - hreflang: hreflang, - media: media, - ping: ping, - rel: rel, - ismap: ismap, - usemap: usemap, - shape: shape, - coords: coords, - src: src, - height: height, - width: width, - alt: alt, - autoplay: autoplay, - controls: controls, - loop: loop, - preload: preload, - poster: poster, - $$default: $$default, - kind: kind, - srclang: srclang, - sandbox: sandbox, - seamless: seamless, - srcdoc: srcdoc, - reversed: reversed, - start: start, - colspan: colspan, - rowspan: rowspan, - headers: headers, - scope: scope, - align: align, - async: async, - charset: charset, - content: content, - defer: defer, - httpEquiv: httpEquiv, - language: language, - scoped: scoped, - accesskey: accesskey, - contenteditable: contenteditable, - contextmenu: contextmenu, - dir: dir, - draggable: draggable, - dropzone: dropzone, - itemprop: itemprop, - lang: lang, - spellcheck: spellcheck, - tabindex: tabindex, - challenge: challenge, - keytype: keytype, - cite: cite$1, - datetime: datetime, - pubdate: pubdate, - manifest: manifest -}; - -var onCB = Vdom.onCB; - -var onMsg = Vdom.onMsg; - -function preventDefaultOn($staropt$star, eventName, decoder) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Tea_html.onWithOptions(key, eventName, { - stopPropagation: Tea_html.defaultOptions.stopPropagation, - preventDefault: true - }, decoder); -} - -function onClick(msg) { - return Vdom.onMsg("click", msg); -} - -function onDoubleClick(msg) { - return Vdom.onMsg("dblclick", msg); -} - -function onMouseDown(msg) { - return Vdom.onMsg("mousedown", msg); -} - -function onMouseUp(msg) { - return Vdom.onMsg("mouseup", msg); -} - -function onMouseEnter(msg) { - return Vdom.onMsg("mouseenter", msg); -} - -function onMouseLeave(msg) { - return Vdom.onMsg("mouseleave", msg); -} - -function onMouseOver(msg) { - return Vdom.onMsg("mouseover", msg); -} - -function onMouseOut(msg) { - return Vdom.onMsg("mouseout", msg); -} - -function onInputOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("input", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onInput($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onInputOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onCheckOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.checked; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onCheck($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onCheckOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onChangeOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onChange($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onChangeOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onSubmit(msg) { - return preventDefaultOn(undefined, "submit", Tea_json.Decoder.succeed(msg)); -} - -function onBlur(msg) { - return Vdom.onMsg("blur", msg); -} - -function onFocus(msg) { - return Vdom.onMsg("focus", msg); -} - -var Events = { - onCB: onCB, - onMsg: onMsg, - on: Tea_html.on, - onWithOptions: Tea_html.onWithOptions, - defaultOptions: Tea_html.defaultOptions, - targetValue: Tea_html.targetValue, - targetChecked: Tea_html.targetChecked, - keyCode: Tea_html.keyCode, - preventDefaultOn: preventDefaultOn, - onClick: onClick, - onDoubleClick: onDoubleClick, - onMouseDown: onMouseDown, - onMouseUp: onMouseUp, - onMouseEnter: onMouseEnter, - onMouseLeave: onMouseLeave, - onMouseOver: onMouseOver, - onMouseOut: onMouseOut, - onInputOpt: onInputOpt, - onInput: onInput, - onCheckOpt: onCheckOpt, - onCheck: onCheck, - onChangeOpt: onChangeOpt, - onChange: onChange, - onSubmit: onSubmit, - onBlur: onBlur, - onFocus: onFocus -}; - -var Cmds = /* alias */0; - -var map = Tea_app.map; - -var noNode = Vdom.noNode; - -exports.Cmds = Cmds; -exports.map = map; -exports.text = text; -exports.node = node; -exports.noNode = noNode; -exports.lazy1 = lazy1; -exports.h1 = h1; -exports.h2 = h2; -exports.h3 = h3; -exports.h4 = h4; -exports.h5 = h5; -exports.h6 = h6; -exports.div = div; -exports.p = p; -exports.hr = hr; -exports.pre = pre; -exports.blockquote = blockquote; -exports.span = span; -exports.a = a; -exports.code = code; -exports.em = em; -exports.strong = strong; -exports.i = i; -exports.b = b; -exports.u = u; -exports.sub = sub; -exports.sup = sup; -exports.br = br; -exports.br$prime = br$prime; -exports.ol = ol; -exports.ul = ul; -exports.li = li; -exports.dl = dl; -exports.dt = dt; -exports.dd = dd; -exports.img = img; -exports.iframe = iframe; -exports.canvas = canvas; -exports.math = math; -exports.form = form; -exports.input$prime = input$prime; -exports.textarea = textarea; -exports.button = button; -exports.select = select; -exports.option$prime = option$prime; -exports.optgroup = optgroup; -exports.label = label; -exports.fieldset = fieldset; -exports.legend = legend; -exports.section = section; -exports.nav = nav; -exports.article = article; -exports.aside = aside; -exports.header = header; -exports.footer = footer; -exports.address = address; -exports.main = main; -exports.body = body; -exports.figure = figure; -exports.figcaption = figcaption; -exports.table = table; -exports.caption = caption; -exports.colgroup = colgroup; -exports.col = col; -exports.tbody = tbody; -exports.thead = thead; -exports.tfoot = tfoot; -exports.tr = tr; -exports.th = th; -exports.td = td; -exports.datalist = datalist; -exports.keygen = keygen; -exports.output = output; -exports.progress = progress; -exports.meter = meter; -exports.audio = audio; -exports.video = video; -exports.source = source; -exports.track = track; -exports.embed = embed; -exports.object$prime = object$prime; -exports.param = param; -exports.ins = ins; -exports.del = del; -exports.small = small; -exports.cite = cite; -exports.dfn = dfn; -exports.abbr = abbr; -exports.time = time; -exports.var$prime = var$prime; -exports.samp = samp; -exports.kbd = kbd; -exports.s = s; -exports.q = q; -exports.mark = mark; -exports.ruby = ruby; -exports.rt = rt; -exports.rp = rp; -exports.bdi = bdi; -exports.bdo = bdo; -exports.wbr = wbr; -exports.details = details; -exports.summary = summary; -exports.menuitem = menuitem; -exports.menu = menu; -exports.meta = meta; -exports.style = style; -exports.title = title; -exports.link = link; -exports.Attributes = Attributes; -exports.Events = Events; -/* Tea_html Not a pure module */ diff --git a/lib/js/src-ocaml/tea_html_cmds.js b/lib/js/src-ocaml/tea_html_cmds.js deleted file mode 100644 index d395c2b..0000000 --- a/lib/js/src-ocaml/tea_html_cmds.js +++ /dev/null @@ -1,30 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); - -function focus(id) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - var ecb = function (param) { - var match = document.getElementById(id); - if (match == null) { - console.log(/* tuple */[ - "Attempted to focus a non-existant element of: ", - id - ]); - return /* () */0; - } else { - return match.focus(); - } - }; - var cb = function (param) { - window.requestAnimationFrame(ecb); - return /* () */0; - }; - window.requestAnimationFrame(cb); - return /* () */0; - })]); -} - -exports.focus = focus; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_http.js b/lib/js/src-ocaml/tea_http.js deleted file mode 100644 index 652fb76..0000000 --- a/lib/js/src-ocaml/tea_http.js +++ /dev/null @@ -1,1497 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_json = require("./tea_json.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Web_xmlhttprequest = require("./web_xmlhttprequest.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function string_of_error(param) { - if (typeof param === "number") { - switch (param) { - case /* Timeout */0 : - return "Timeout"; - case /* NetworkError */1 : - return "Unknown network error"; - case /* Aborted */2 : - return "Request aborted"; - - } - } else { - switch (param.tag | 0) { - case /* BadUrl */0 : - return "Bad Url: " + param[0]; - case /* BadStatus */1 : - return "Bad Status: " + param[0].url; - case /* BadPayload */2 : - return "Bad Payload: " + param[1].url; - - } - } -} - -var emptyRequestEvents = { - onreadystatechange: undefined, - onprogress: undefined -}; - -function expectStringResponse(func) { - return /* Expect */[ - /* TextResponseType */5, - (function (param) { - var body = param.body; - if (typeof body === "number" || body.tag !== /* TextResponse */5) { - return /* Error */Block.__(1, ["Non-text response returned"]); - } else { - return Curry._1(func, body[0]); - } - }) - ]; -} - -var expectString = expectStringResponse((function (resString) { - return /* Ok */Block.__(0, [resString]); - })); - -function request(rawRequest) { - return /* Request */[ - rawRequest, - undefined - ]; -} - -function getString(url) { - return /* Request */[ - { - "method'": "GET", - headers: /* [] */0, - url: url, - body: /* EmptyBody */0, - expect: expectString, - timeout: undefined, - withCredentials: false - }, - undefined - ]; -} - -function toTask(param) { - var request = param[0]; - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var expect = request.expect; - var responseToResult = expect[1]; - var typ = expect[0]; - var withCredentials = request.withCredentials; - var timeout = request.timeout; - var body = request.body; - var url = request.url; - var headers = request.headers; - var method$prime = request["method'"]; - return /* Task */[(function (cb) { - var enqResError = function (result) { - var partial_arg = /* Error */Block.__(1, [result]); - return (function (param) { - return Curry._1(cb, partial_arg); - }); - }; - var enqResOk = function (result) { - var partial_arg = /* Ok */Block.__(0, [result]); - return (function (param) { - return Curry._1(cb, partial_arg); - }); - }; - var xhr = new XMLHttpRequest(); - var partial_arg = /* Error */Block.__(1, [/* NetworkError */1]); - var cb$1 = function (param) { - return Curry._1(cb, partial_arg); - }; - xhr.onerror = cb$1; - var partial_arg$1 = /* Error */Block.__(1, [/* Timeout */0]); - var cb$2 = function (param) { - return Curry._1(cb, partial_arg$1); - }; - xhr.ontimeout = cb$2; - var partial_arg$2 = /* Error */Block.__(1, [/* Aborted */2]); - var cb$3 = function (param) { - return Curry._1(cb, partial_arg$2); - }; - xhr.onabort = cb$3; - var cb$4 = function (_ev) { - var match = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); - var headers; - headers = match.tag ? /* Empty */0 : match[0]; - var response_url = xhr.responseURL; - var response_status = { - code: xhr.status, - message: xhr.statusText - }; - var response_body = Web_xmlhttprequest.get_response(xhr); - var response = { - url: response_url, - status: response_status, - headers: headers, - body: response_body - }; - if (response_status.code < 200 || 300 <= response_status.code) { - return enqResError(/* BadStatus */Block.__(1, [response]))(/* () */0); - } else { - var match$1 = Curry._1(responseToResult, response); - if (match$1.tag) { - return enqResError(/* BadPayload */Block.__(2, [ - match$1[0], - response - ]))(/* () */0); - } else { - return enqResOk(match$1[0])(/* () */0); - } - } - }; - xhr.onload = cb$4; - try { - Web_xmlhttprequest.open_(method$prime, url, undefined, undefined, undefined, xhr); - } - catch (exn){ - enqResError(/* BadUrl */Block.__(0, [url]))(/* () */0); - } - var setHeader = function (param) { - return Web_xmlhttprequest.setRequestHeader(param[0], param[1], xhr); - }; - List.iter(setHeader, headers); - Web_xmlhttprequest.set_responseType(typ, xhr); - if (timeout !== undefined) { - xhr.timeout = timeout; - } - xhr.withCredentials = withCredentials; - Web_xmlhttprequest.send(body, xhr); - return /* () */0; - })]; -} - -function send(resultToMessage, param) { - var maybeEvents = param[1]; - var request = param[0]; - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var expect = request.expect; - var responseToResult = expect[1]; - var typ = expect[0]; - var withCredentials = request.withCredentials; - var timeout = request.timeout; - var body = request.body; - var url = request.url; - var headers = request.headers; - var method$prime = request["method'"]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - var enqRes = function (result, _ev) { - return Curry._1(callbacks.contents.enqueue, Curry._1(resultToMessage, result)); - }; - var enqResError = function (result) { - var partial_arg = /* Error */Block.__(1, [result]); - return (function (param) { - return enqRes(partial_arg, param); - }); - }; - var enqResOk = function (result) { - var partial_arg = /* Ok */Block.__(0, [result]); - return (function (param) { - return enqRes(partial_arg, param); - }); - }; - var xhr = new XMLHttpRequest(); - if (maybeEvents !== undefined) { - var match = maybeEvents; - var mayCB = function (thenDo, param) { - if (param !== undefined) { - return Curry._1(thenDo, Curry._1(param, callbacks)); - } else { - return /* () */0; - } - }; - mayCB((function (param) { - xhr.onreadystatechange = param; - return /* () */0; - }), match.onreadystatechange); - mayCB((function (param) { - xhr.onprogress = param; - return /* () */0; - }), match.onprogress); - } - var partial_arg = /* Error */Block.__(1, [/* NetworkError */1]); - var cb = function (param) { - return enqRes(partial_arg, param); - }; - xhr.onerror = cb; - var partial_arg$1 = /* Error */Block.__(1, [/* Timeout */0]); - var cb$1 = function (param) { - return enqRes(partial_arg$1, param); - }; - xhr.ontimeout = cb$1; - var partial_arg$2 = /* Error */Block.__(1, [/* Aborted */2]); - var cb$2 = function (param) { - return enqRes(partial_arg$2, param); - }; - xhr.onabort = cb$2; - var cb$3 = function (_ev) { - var match = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); - var headers; - headers = match.tag ? /* Empty */0 : match[0]; - var response_url = xhr.responseURL; - var response_status = { - code: xhr.status, - message: xhr.statusText - }; - var response_body = Web_xmlhttprequest.get_response(xhr); - var response = { - url: response_url, - status: response_status, - headers: headers, - body: response_body - }; - if (response_status.code < 200 || 300 <= response_status.code) { - return enqResError(/* BadStatus */Block.__(1, [response]))(/* () */0); - } else { - var match$1 = Curry._1(responseToResult, response); - if (match$1.tag) { - return enqResError(/* BadPayload */Block.__(2, [ - match$1[0], - response - ]))(/* () */0); - } else { - return enqResOk(match$1[0])(/* () */0); - } - } - }; - xhr.onload = cb$3; - try { - Web_xmlhttprequest.open_(method$prime, url, undefined, undefined, undefined, xhr); - } - catch (exn){ - enqResError(/* BadUrl */Block.__(0, [url]))(/* () */0); - } - var setHeader = function (param) { - return Web_xmlhttprequest.setRequestHeader(param[0], param[1], xhr); - }; - List.iter(setHeader, headers); - Web_xmlhttprequest.set_responseType(typ, xhr); - if (timeout !== undefined) { - xhr.timeout = timeout; - } - xhr.withCredentials = withCredentials; - Web_xmlhttprequest.send(body, xhr); - return /* () */0; - })]); -} - -function encodeUri(str) { - return encodeURIComponent(str); -} - -function decodeUri(str) { - try { - return decodeURIComponent(str); - } - catch (exn){ - return ; - } -} - -function track(toMessage, param) { - var events = param[1]; - var onprogress = (function (callbacks, ev) { - var match = Tea_json.Decoder.decodeValue(Tea_json.Decoder.field("lengthComputable", Tea_json.Decoder.bool), ev); - var lengthComputable; - lengthComputable = match.tag ? false : match[0]; - if (lengthComputable) { - var decoder = Tea_json.Decoder.map2((function (bytes, bytesExpected) { - return { - bytes: bytes, - bytesExpected: bytesExpected - }; - }), Tea_json.Decoder.field("loaded", Tea_json.Decoder.$$int), Tea_json.Decoder.field("total", Tea_json.Decoder.$$int)); - var match$1 = Tea_json.Decoder.decodeValue(decoder, ev); - if (match$1.tag) { - return /* () */0; - } else { - return Curry._1(callbacks.contents.enqueue, Curry._1(toMessage, match$1[0])); - } - } else { - return 0; - } - }); - var events$1 = events !== undefined ? events : emptyRequestEvents; - return /* Request */[ - param[0], - { - onreadystatechange: events$1.onreadystatechange, - onprogress: onprogress - } - ]; -} - -var Progress_emptyProgress = { - bytes: 0, - bytesExpected: 0 -}; - -var Progress = { - emptyProgress: Progress_emptyProgress, - track: track -}; - -exports.string_of_error = string_of_error; -exports.emptyRequestEvents = emptyRequestEvents; -exports.expectStringResponse = expectStringResponse; -exports.expectString = expectString; -exports.request = request; -exports.getString = getString; -exports.toTask = toTask; -exports.send = send; -exports.encodeUri = encodeUri; -exports.decodeUri = decodeUri; -exports.Progress = Progress; -/* expectString Not a pure module */ diff --git a/lib/js/src-ocaml/tea_json.js b/lib/js/src-ocaml/tea_json.js deleted file mode 100644 index 18e194e..0000000 --- a/lib/js/src-ocaml/tea_json.js +++ /dev/null @@ -1,1693 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var $$Array = require("bs-platform/lib/js/array.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Js_dict = require("bs-platform/lib/js/js_dict.js"); -var Web_json = require("./web_json.js"); -var Caml_array = require("bs-platform/lib/js/caml_array.js"); -var Pervasives = require("bs-platform/lib/js/pervasives.js"); -var Tea_result = require("./tea_result.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Caml_exceptions = require("bs-platform/lib/js/caml_exceptions.js"); -var Caml_js_exceptions = require("bs-platform/lib/js/caml_js_exceptions.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function height(param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } -} - -function create(l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; -} - -function singleton(x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; -} - -function bal(l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } -} - -function is_empty(param) { - if (param) { - return false; - } else { - return true; - } -} - -function add(x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } -} - -function find(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return param[/* d */2]; - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_first(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* l */0]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* l */0]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* r */3]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_first_opt(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* l */0]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* l */0]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* r */3]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return ; - } - }; -} - -function find_last(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* r */3]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* r */3]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* l */0]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* l */0]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_last_opt(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* r */3]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* r */3]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* l */0]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* l */0]; - continue ; - } - } else { - return ; - } - }; -} - -function find_opt(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return Caml_option.some(param[/* d */2]); - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - return ; - } - }; -} - -function mem(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return true; - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - return false; - } - }; -} - -function min_binding(_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function min_binding_opt(_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - return ; - } - }; -} - -function max_binding(_param) { - while(true) { - var param = _param; - if (param) { - var r = param[/* r */3]; - if (r) { - _param = r; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function max_binding_opt(_param) { - while(true) { - var param = _param; - if (param) { - var r = param[/* r */3]; - if (r) { - _param = r; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - return ; - } - }; -} - -function remove_min_binding(param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } -} - -function merge(t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } -} - -function remove(x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } -} - -function update(x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } -} - -function iter(f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; -} - -function map(f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } -} - -function mapi(f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } -} - -function fold(f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; -} - -function for_all(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; -} - -function exists(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; -} - -function add_min_binding(k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } -} - -function add_max_binding(k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } -} - -function join(l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } -} - -function concat(t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } -} - -function concat_or_join(t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } -} - -function split(x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } -} - -function merge$1(f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } -} - -function union(f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } -} - -function filter(p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } -} - -function partition(p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } -} - -function cons_enum(_m, _e) { - while(true) { - var e = _e; - var m = _m; - if (m) { - _e = /* More */[ - m[/* v */1], - m[/* d */2], - m[/* r */3], - e - ]; - _m = m[/* l */0]; - continue ; - } else { - return e; - } - }; -} - -function compare(cmp, m1, m2) { - var _e1 = cons_enum(m1, /* End */0); - var _e2 = cons_enum(m2, /* End */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (e1) { - if (e2) { - var c = Caml_primitive.caml_string_compare(e1[0], e2[0]); - if (c !== 0) { - return c; - } else { - var c$1 = Curry._2(cmp, e1[1], e2[1]); - if (c$1 !== 0) { - return c$1; - } else { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); - continue ; - } - } - } else { - return 1; - } - } else if (e2) { - return -1; - } else { - return 0; - } - }; -} - -function equal(cmp, m1, m2) { - var _e1 = cons_enum(m1, /* End */0); - var _e2 = cons_enum(m2, /* End */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (e1) { - if (e2 && Caml_primitive.caml_string_compare(e1[0], e2[0]) === 0 && Curry._2(cmp, e1[1], e2[1])) { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); - continue ; - } else { - return false; - } - } else if (e2) { - return false; - } else { - return true; - } - }; -} - -function cardinal(param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } -} - -function bindings_aux(_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; -} - -function bindings(s) { - return bindings_aux(/* [] */0, s); -} - -var ObjectDict = { - empty: /* Empty */0, - is_empty: is_empty, - mem: mem, - add: add, - update: update, - singleton: singleton, - remove: remove, - merge: merge$1, - union: union, - compare: compare, - equal: equal, - iter: iter, - fold: fold, - for_all: for_all, - exists: exists, - filter: filter, - partition: partition, - cardinal: cardinal, - bindings: bindings, - min_binding: min_binding, - min_binding_opt: min_binding_opt, - max_binding: max_binding, - max_binding_opt: max_binding_opt, - choose: min_binding, - choose_opt: min_binding_opt, - split: split, - find: find, - find_opt: find_opt, - find_first: find_first, - find_first_opt: find_first_opt, - find_last: find_last, - find_last_opt: find_last_opt, - map: map, - mapi: mapi -}; - -var ParseFail = Caml_exceptions.create("Tea_json.Decoder.ParseFail"); - -var string = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag) { - return /* Error */Block.__(1, ["Non-string value"]); - } else { - return /* Ok */Block.__(0, [match[0]]); - } - })]; - -var $$int = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONNumber */1) { - return /* Error */Block.__(1, ["Non-int value"]); - } else { - var n = match[0]; - if (n > Pervasives.min_int && n < Pervasives.max_int) { - return /* Ok */Block.__(0, [n | 0]); - } else { - return /* Error */Block.__(1, ["number out of int range"]); - } - } - })]; - -var $$float = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONNumber */1) { - return /* Error */Block.__(1, ["Non-float-value"]); - } else { - return /* Ok */Block.__(0, [match[0]]); - } - })]; - -var bool = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number") { - switch (match) { - case /* JSONFalse */0 : - return /* Ok */Block.__(0, [false]); - case /* JSONTrue */1 : - return /* Ok */Block.__(0, [true]); - case /* JSONNull */2 : - return /* Error */Block.__(1, ["Non-boolean value"]); - - } - } else { - return /* Error */Block.__(1, ["Non-boolean value"]); - } - })]; - -function $$null(v) { - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" && match >= 2) { - return /* Ok */Block.__(0, [v]); - } else { - return /* Error */Block.__(1, ["Non-null value"]); - } - })]; -} - -function list(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-list value"]); - } else { - var parse = function (v) { - var match = Curry._1(decoder, v); - if (match.tag) { - throw [ - ParseFail, - match[0] - ]; - } else { - return match[0]; - } - }; - try { - return /* Ok */Block.__(0, [List.map(parse, $$Array.to_list(match[0]))]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["list -> " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function array(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-array value"]); - } else { - var parse = function (v) { - var match = Curry._1(decoder, v); - if (match.tag) { - throw [ - ParseFail, - match[0] - ]; - } else { - return match[0]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.map(parse, match[0])]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["array -> " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function keyValuePairs(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-keyValuePair value"]); - } else { - var o = match[0]; - var keys = Object.keys(o); - var parse = function (k, l) { - var match = Js_dict.get(o, k); - if (match !== undefined) { - var match$1 = Curry._1(decoder, Caml_option.valFromOption(match)); - if (match$1.tag) { - throw [ - ParseFail, - match$1[0] - ]; - } else { - return /* :: */[ - /* tuple */[ - k, - match$1[0] - ], - l - ]; - } - } else { - throw [ - ParseFail, - "Key is undefined: " + k - ]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.fold_right(parse, keys, /* [] */0)]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["Invalid keyValuePair parsing: " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function dict(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-dict value"]); - } else { - var o = match[0]; - var keys = Object.keys(o); - var parse = function (k, d) { - var match = Js_dict.get(o, k); - if (match !== undefined) { - var match$1 = Curry._1(decoder, Caml_option.valFromOption(match)); - if (match$1.tag) { - throw [ - ParseFail, - match$1[0] - ]; - } else { - return add(k, match$1[0], d); - } - } else { - throw [ - ParseFail, - "Key is undefined: " + k - ]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.fold_right(parse, keys, /* Empty */0)]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["Invalid dict parsing: " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function field(key, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-fieldable value"]); - } else { - var match$1 = Js_dict.get(match[0], key); - if (match$1 !== undefined) { - var o = Curry._1(decoder, Caml_option.valFromOption(match$1)); - if (o.tag) { - return /* Error */Block.__(1, ["field `" + (key + ("` -> " + o[0]))]); - } else { - return o; - } - } else { - return /* Error */Block.__(1, ["Field Value is undefined: " + key]); - } - } - })]; -} - -function at(fields, dec) { - return List.fold_right(field, fields, dec); -} - -function index(idx, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-array value"]); - } else { - var a = match[0]; - if (idx < 0 || idx > a.length) { - return /* Error */Block.__(1, ["Array index out of range: " + String(idx)]); - } else { - return Curry._1(decoder, Caml_array.caml_array_get(a, idx)); - } - } - })]; -} - -function maybe(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder, value); - if (match.tag) { - return /* Ok */Block.__(0, [undefined]); - } else { - return /* Ok */Block.__(0, [Caml_option.some(match[0])]); - } - })]; -} - -function oneOf(decoders) { - return /* Decoder */[(function (value) { - var parse = function (v, _param) { - while(true) { - var param = _param; - if (param) { - var rest = param[1]; - try { - var ok = Curry._1(param[0][0], v); - if (ok.tag) { - return parse(v, rest); - } else { - return ok; - } - } - catch (exn){ - _param = rest; - continue ; - } - } else { - return /* Error */Block.__(1, ["No one-of's matched"]); - } - }; - }; - return parse(value, decoders); - })]; -} - -function map$1(mapper, param) { - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - if (match.tag) { - return /* Error */Block.__(1, ["map " + match[0]]); - } else { - return /* Ok */Block.__(0, [Curry._1(mapper, match[0])]); - } - })]; -} - -function map2(mapper, param, param$1) { - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - if (!match.tag && !match$1.tag) { - return /* Ok */Block.__(0, [Curry._2(mapper, match[0], match$1[0])]); - } - var match$2 = Tea_result.error_of_first(match, match$1); - if (match$2 !== undefined) { - return /* Error */Block.__(1, ["map2 -> " + match$2]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map3(mapper, param, param$1, param$2) { - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - if (!match.tag && !match$1.tag && !match$2.tag) { - return /* Ok */Block.__(0, [Curry._3(mapper, match[0], match$1[0], match$2[0])]); - } - var match$3 = Tea_result.first(match$2, Tea_result.first(match$1, match)); - if (match$3.tag) { - return /* Error */Block.__(1, ["map3 -> " + match$3[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map4(mapper, param, param$1, param$2, param$3) { - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag) { - return /* Ok */Block.__(0, [Curry._4(mapper, match[0], match$1[0], match$2[0], match$3[0])]); - } - var match$4 = Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))); - if (match$4.tag) { - return /* Error */Block.__(1, ["map4 -> " + match$4[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map5(mapper, param, param$1, param$2, param$3, param$4) { - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag) { - return /* Ok */Block.__(0, [Curry._5(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0])]); - } - var match$5 = Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match)))); - if (match$5.tag) { - return /* Error */Block.__(1, ["map5 -> " + match$5[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map6(mapper, param, param$1, param$2, param$3, param$4, param$5) { - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag) { - return /* Ok */Block.__(0, [Curry._6(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0])]); - } - var match$6 = Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))))); - if (match$6.tag) { - return /* Error */Block.__(1, ["map6 -> " + match$6[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map7(mapper, param, param$1, param$2, param$3, param$4, param$5, param$6) { - var decoder7 = param$6[0]; - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - var match$6 = Curry._1(decoder7, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag && !match$6.tag) { - return /* Ok */Block.__(0, [Curry._7(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0], match$6[0])]); - } - var match$7 = Tea_result.first(match$6, Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match)))))); - if (match$7.tag) { - return /* Error */Block.__(1, ["map7 -> " + match$7[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map8(mapper, param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) { - var decoder8 = param$7[0]; - var decoder7 = param$6[0]; - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - var match$6 = Curry._1(decoder7, value); - var match$7 = Curry._1(decoder8, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag && !match$6.tag && !match$7.tag) { - return /* Ok */Block.__(0, [Curry._8(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0], match$6[0], match$7[0])]); - } - var match$8 = Tea_result.first(match$7, Tea_result.first(match$6, Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))))))); - if (match$8.tag) { - return /* Error */Block.__(1, ["map8 -> " + match$8[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function succeed(v) { - return /* Decoder */[(function (_value) { - return /* Ok */Block.__(0, [v]); - })]; -} - -function fail(e) { - return /* Decoder */[(function (_value) { - return /* Error */Block.__(1, [e]); - })]; -} - -var value = /* Decoder */[(function (value) { - return /* Ok */Block.__(0, [value]); - })]; - -function andThen(func, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var err = Curry._1(decoder, value); - if (err.tag) { - return err; - } else { - var match = Curry._1(func, err[0]); - return Curry._1(match[0], value); - } - })]; -} - -function lazy_(func) { - return andThen(func, /* Decoder */[(function (_value) { - return /* Ok */Block.__(0, [/* () */0]); - })]); -} - -function nullable(decoder) { - return oneOf(/* :: */[ - $$null(undefined), - /* :: */[ - map$1((function (v) { - return Caml_option.some(v); - }), decoder), - /* [] */0 - ] - ]); -} - -function decodeValue(param, value) { - try { - return Curry._1(param[0], value); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, [exn[1]]); - } else { - return /* Error */Block.__(1, ["Unknown JSON parsing error"]); - } - } -} - -function decodeEvent(param, value) { - try { - return Curry._1(param[0], value); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, [exn[1]]); - } else { - return /* Error */Block.__(1, ["Unknown JSON parsing error"]); - } - } -} - -function decodeString(decoder, string) { - try { - var value = JSON.parse(string); - return decodeValue(decoder, value); - } - catch (exn){ - return /* Error */Block.__(1, ["Invalid JSON string"]); - } -} - -var Decoder = { - ObjectDict: ObjectDict, - ParseFail: ParseFail, - string: string, - $$int: $$int, - $$float: $$float, - bool: bool, - $$null: $$null, - list: list, - array: array, - keyValuePairs: keyValuePairs, - dict: dict, - field: field, - at: at, - index: index, - maybe: maybe, - oneOf: oneOf, - map: map$1, - map2: map2, - map3: map3, - map4: map4, - map5: map5, - map6: map6, - map7: map7, - map8: map8, - succeed: succeed, - fail: fail, - value: value, - andThen: andThen, - lazy_: lazy_, - nullable: nullable, - decodeValue: decodeValue, - decodeEvent: decodeEvent, - decodeString: decodeString -}; - -function encode(indentLevel, value) { - return Web_json.string_of_json(indentLevel, value); -} - -function string$1(v) { - return v; -} - -function $$int$1(v) { - return v; -} - -function $$float$1(v) { - return v; -} - -function bool$1(v) { - return v; -} - -function object_(v) { - var aux = function (o, param) { - o[param[0]] = param[1]; - return o; - }; - return List.fold_left(aux, { }, v); -} - -function array$1(v) { - return v; -} - -var list$1 = $$Array.of_list; - -var Encoder = { - encode: encode, - string: string$1, - $$int: $$int$1, - $$float: $$float$1, - bool: bool$1, - $$null: Web_json.$$null, - object_: object_, - array: array$1, - list: list$1 -}; - -exports.Decoder = Decoder; -exports.Encoder = Encoder; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_mouse.js b/lib/js/src-ocaml/tea_mouse.js deleted file mode 100644 index 61be8f0..0000000 --- a/lib/js/src-ocaml/tea_mouse.js +++ /dev/null @@ -1,71 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_json = require("./tea_json.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -var position = Tea_json.Decoder.map2((function (x, y) { - return { - x: x, - y: y - }; - }), Tea_json.Decoder.field("pageX", Tea_json.Decoder.$$int), Tea_json.Decoder.field("pageY", Tea_json.Decoder.$$int)); - -function registerGlobal(name, key, tagger) { - var enableCall = function (callbacks_base) { - var callbacks = { - contents: callbacks_base - }; - var fn = function (ev) { - var match = Tea_json.Decoder.decodeEvent(position, ev); - if (match.tag) { - return ; - } else { - return Caml_option.some(Curry._1(tagger, match[0])); - } - }; - var handler = /* EventHandlerCallback */Block.__(0, [ - key, - fn - ]); - var elem = document; - var cache = Vdom.eventHandler_Register(callbacks, elem, name, handler); - return (function (param) { - Vdom.eventHandler_Unregister(elem, name, cache); - return /* () */0; - }); - }; - return Tea_sub.registration(key, enableCall); -} - -function clicks($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("click", key, tagger); -} - -function moves($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mousemove", key, tagger); -} - -function downs($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mousedown", key, tagger); -} - -function ups($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mouseup", key, tagger); -} - -exports.position = position; -exports.registerGlobal = registerGlobal; -exports.clicks = clicks; -exports.moves = moves; -exports.downs = downs; -exports.ups = ups; -/* position Not a pure module */ diff --git a/lib/js/src-ocaml/tea_program.js b/lib/js/src-ocaml/tea_program.js deleted file mode 100644 index 49778a8..0000000 --- a/lib/js/src-ocaml/tea_program.js +++ /dev/null @@ -1,33 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function spawn(initState, update, shutdown) { - var state = { - contents: Caml_option.some(initState) - }; - return (function (procMsg) { - var match = state.contents; - if (match !== undefined) { - var model = Caml_option.valFromOption(match); - if (procMsg) { - state.contents = Curry._2(update, model, procMsg[0]); - return /* () */0; - } else { - Curry._1(shutdown, model); - state.contents = undefined; - return /* () */0; - } - } else { - return /* () */0; - } - }); -} - -var testing1 = 42; - -exports.spawn = spawn; -exports.testing1 = testing1; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_promise.js b/lib/js/src-ocaml/tea_promise.js deleted file mode 100644 index 5940085..0000000 --- a/lib/js/src-ocaml/tea_promise.js +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function cmd(promise, tagger) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - promise.then((function (res) { - var match = Curry._1(tagger, res); - if (match !== undefined) { - Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - return Promise.resolve(/* () */0); - } else { - return Promise.resolve(/* () */0); - } - })); - return /* () */0; - })]); -} - -function result(promise, msg) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - var enq = function (result) { - return Curry._1(callbacks.contents.enqueue, Curry._1(msg, result)); - }; - promise.then((function (res) { - return Promise.resolve(enq(/* Ok */Block.__(0, [res]))); - })).catch((function (err) { - var err_to_string = function (err) { - return "" + (String(err) + ""); - }; - return Promise.resolve(enq(/* Error */Block.__(1, [err_to_string(err)]))); - })); - return /* () */0; - })]); -} - -exports.cmd = cmd; -exports.result = result; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_random.js b/lib/js/src-ocaml/tea_random.js deleted file mode 100644 index e6548ed..0000000 --- a/lib/js/src-ocaml/tea_random.js +++ /dev/null @@ -1,184 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Random = require("bs-platform/lib/js/random.js"); -var Pervasives = require("bs-platform/lib/js/pervasives.js"); - -Random.self_init(/* () */0); - -var bool = /* Generator */[(function (state) { - return Random.State.bool(state); - })]; - -function $$int(min, max) { - var match = min < max ? /* tuple */[ - min, - max - ] : /* tuple */[ - max, - min - ]; - var max$1 = match[1]; - var min$1 = match[0]; - return /* Generator */[(function (state) { - return min$1 + Random.State.$$int(state, (max$1 - min$1 | 0) + 1 | 0) | 0; - })]; -} - -function $$float(min, max) { - return /* Generator */[(function (state) { - return min + Random.State.$$float(state, max - min); - })]; -} - -function list(count, param) { - var genCmd = param[0]; - return /* Generator */[(function (state) { - var state$1 = state; - var _i = count; - var _acc = /* [] */0; - while(true) { - var acc = _acc; - var i = _i; - if (i > 0) { - _acc = /* :: */[ - Curry._1(genCmd, state$1), - acc - ]; - _i = i - 1 | 0; - continue ; - } else { - return acc; - } - }; - })]; -} - -function map(func, param) { - var genCmd = param[0]; - return /* Generator */[(function (state) { - return Curry._1(func, Curry._1(genCmd, state)); - })]; -} - -function map2(func, param, param$1) { - var genCmd2 = param$1[0]; - var genCmd1 = param[0]; - return /* Generator */[(function (state) { - var res1 = Curry._1(genCmd1, state); - var res2 = Curry._1(genCmd2, state); - return Curry._2(func, res1, res2); - })]; -} - -function map3(func, param, param$1, param$2) { - var genCmd3 = param$2[0]; - var genCmd2 = param$1[0]; - var genCmd1 = param[0]; - return /* Generator */[(function (state) { - var res1 = Curry._1(genCmd1, state); - var res2 = Curry._1(genCmd2, state); - var res3 = Curry._1(genCmd3, state); - return Curry._3(func, res1, res2, res3); - })]; -} - -function map4(func, param, param$1, param$2, param$3) { - var genCmd4 = param$3[0]; - var genCmd3 = param$2[0]; - var genCmd2 = param$1[0]; - var genCmd1 = param[0]; - return /* Generator */[(function (state) { - var res1 = Curry._1(genCmd1, state); - var res2 = Curry._1(genCmd2, state); - var res3 = Curry._1(genCmd3, state); - var res4 = Curry._1(genCmd4, state); - return Curry._4(func, res1, res2, res3, res4); - })]; -} - -function map5(func, param, param$1, param$2, param$3, param$4) { - var genCmd5 = param$4[0]; - var genCmd4 = param$3[0]; - var genCmd3 = param$2[0]; - var genCmd2 = param$1[0]; - var genCmd1 = param[0]; - return /* Generator */[(function (state) { - var res1 = Curry._1(genCmd1, state); - var res2 = Curry._1(genCmd2, state); - var res3 = Curry._1(genCmd3, state); - var res4 = Curry._1(genCmd4, state); - var res5 = Curry._1(genCmd5, state); - return Curry._5(func, res1, res2, res3, res4, res5); - })]; -} - -function andThen(func, param) { - var genCmd = param[0]; - return /* Generator */[(function (state) { - var res = Curry._1(genCmd, state); - var match = Curry._1(func, res); - return Curry._1(match[0], state); - })]; -} - -function pair(gen1, gen2) { - return map2((function (a, b) { - return /* tuple */[ - a, - b - ]; - }), gen1, gen2); -} - -function generate(tagger, param) { - var genCmd = param[0]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - var state = Random.get_state(/* () */0); - var genValue = Curry._1(genCmd, state); - Random.set_state(state); - return Curry._1(callbacks.contents.enqueue, Curry._1(tagger, genValue)); - })]); -} - -function step(param, param$1) { - var newState = Random.State.copy(param$1[0]); - return /* tuple */[ - Curry._1(param[0], newState), - /* Seed */[newState] - ]; -} - -function initialSeed(seed) { - return /* Seed */[Random.State.make([seed])]; -} - -var minInt = Pervasives.min_int; - -var maxInt = Pervasives.max_int; - -var minFloat = Pervasives.min_float; - -var maxFloat = Pervasives.max_float; - -exports.minInt = minInt; -exports.maxInt = maxInt; -exports.minFloat = minFloat; -exports.maxFloat = maxFloat; -exports.bool = bool; -exports.$$int = $$int; -exports.$$float = $$float; -exports.list = list; -exports.map = map; -exports.map2 = map2; -exports.map3 = map3; -exports.map4 = map4; -exports.map5 = map5; -exports.andThen = andThen; -exports.pair = pair; -exports.generate = generate; -exports.step = step; -exports.initialSeed = initialSeed; -/* Not a pure module */ diff --git a/lib/js/src-ocaml/tea_result.js b/lib/js/src-ocaml/tea_result.js deleted file mode 100644 index 7acfd4f..0000000 --- a/lib/js/src-ocaml/tea_result.js +++ /dev/null @@ -1,133 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function result_to_option(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function option_of_result(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function ok(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function error(param) { - if (param.tag) { - return Caml_option.some(param[0]); - } - -} - -function last_of(_param) { - while(true) { - var param = _param; - if (param) { - var tl = param[1]; - var last = param[0]; - if (tl && !last.tag) { - _param = tl; - continue ; - } else { - return last; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "`Tea.Result.do` must never be passed the empty list" - ]; - } - }; -} - -function accumulate(param) { - if (param) { - var tl = param[1]; - var last = param[0]; - if (tl) { - if (last.tag) { - return last; - } else { - var e = accumulate(tl); - if (e.tag) { - return e; - } else { - return /* Ok */Block.__(0, [/* :: */[ - last[0], - e[0] - ]]); - } - } - } else if (last.tag) { - return last; - } else { - return /* Ok */Block.__(0, [/* :: */[ - last[0], - /* [] */0 - ]]); - } - } else { - return /* Ok */Block.__(0, [/* [] */0]); - } -} - -function first(fst, e) { - if (e.tag) { - return e; - } else { - return fst; - } -} - -function error_of_any(_param) { - while(true) { - var param = _param; - if (param) { - var hd = param[0]; - if (hd.tag) { - return Caml_option.some(hd[0]); - } else { - _param = param[1]; - continue ; - } - } else { - return ; - } - }; -} - -function error_of_first(fst, param) { - if (param.tag) { - return Caml_option.some(param[0]); - } else { - return error(fst); - } -} - -exports.result_to_option = result_to_option; -exports.option_of_result = option_of_result; -exports.ok = ok; -exports.error = error; -exports.last_of = last_of; -exports.accumulate = accumulate; -exports.first = first; -exports.error_of_any = error_of_any; -exports.error_of_first = error_of_first; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_sub.js b/lib/js/src-ocaml/tea_sub.js deleted file mode 100644 index 6ed1873..0000000 --- a/lib/js/src-ocaml/tea_sub.js +++ /dev/null @@ -1,184 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); - -function batch(subs) { - return /* Batch */Block.__(0, [subs]); -} - -function registration(key, enableCall) { - return /* Registration */Block.__(1, [ - key, - (function (callbacks) { - return Curry._1(enableCall, callbacks.contents); - }), - { - contents: undefined - } - ]); -} - -function map(msgMapper, sub) { - var func = function (callbacks) { - return Vdom.wrapCallbacks(msgMapper, callbacks); - }; - return /* Mapper */Block.__(2, [ - func, - sub - ]); -} - -function mapFunc(func, sub) { - return /* Mapper */Block.__(2, [ - func, - sub - ]); -} - -function run(oldCallbacks, newCallbacks, oldSub, newSub) { - var enable = function (_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Batch */0 : - var subs = param[0]; - if (subs) { - return List.iter((function(callbacks){ - return function (param) { - return enable(callbacks, param); - } - }(callbacks)), subs); - } else { - return /* () */0; - } - case /* Registration */1 : - param[2].contents = Curry._1(param[1], callbacks); - return /* () */0; - case /* Mapper */2 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - - } - } - }; - }; - var disable = function (_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Batch */0 : - var subs = param[0]; - if (subs) { - return List.iter((function(callbacks){ - return function (param) { - return disable(callbacks, param); - } - }(callbacks)), subs); - } else { - return /* () */0; - } - case /* Registration */1 : - var diCB = param[2]; - var match = diCB.contents; - if (match !== undefined) { - diCB.contents = undefined; - return Curry._1(match, /* () */0); - } else { - return /* () */0; - } - case /* Mapper */2 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - - } - } - }; - }; - if (typeof oldSub === "number") { - if (typeof newSub === "number") { - return newSub; - } - - } else { - switch (oldSub.tag | 0) { - case /* Batch */0 : - if (typeof newSub !== "number" && !newSub.tag) { - var aux = function (_oldList, _newList) { - while(true) { - var newList = _newList; - var oldList = _oldList; - if (oldList) { - var oldRest = oldList[1]; - var oldSubSub = oldList[0]; - if (newList) { - run(oldCallbacks, newCallbacks, oldSubSub, newList[0]); - _newList = newList[1]; - _oldList = oldRest; - continue ; - } else { - disable(oldCallbacks, oldSubSub); - _newList = /* [] */0; - _oldList = oldRest; - continue ; - } - } else if (newList) { - enable(newCallbacks, newList[0]); - _newList = newList[1]; - _oldList = /* [] */0; - continue ; - } else { - return /* () */0; - } - }; - }; - aux(oldSub[0], newSub[0]); - return newSub; - } - break; - case /* Registration */1 : - if (typeof newSub !== "number" && newSub.tag === /* Registration */1 && oldSub[0] === newSub[0]) { - newSub[2].contents = oldSub[2].contents; - return newSub; - } - break; - case /* Mapper */2 : - if (typeof newSub !== "number" && newSub.tag === /* Mapper */2) { - var olderCallbacks = Curry._1(oldSub[0], oldCallbacks); - var newerCallbacks = Curry._1(newSub[0], newCallbacks); - run(olderCallbacks, newerCallbacks, oldSub[1], newSub[1]); - return newSub; - } - break; - - } - } - disable(oldCallbacks, oldSub); - enable(newCallbacks, newSub); - return newSub; -} - -var none = /* NoSub */0; - -exports.none = none; -exports.batch = batch; -exports.registration = registration; -exports.map = map; -exports.mapFunc = mapFunc; -exports.run = run; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_svg.js b/lib/js/src-ocaml/tea_svg.js deleted file mode 100644 index 4211013..0000000 --- a/lib/js/src-ocaml/tea_svg.js +++ /dev/null @@ -1,597 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); - -var svgNamespace = "http://www.w3.org/2000/svg"; - -function text(str) { - return /* Text */Block.__(1, [str]); -} - -var lazy1 = Vdom.lazyGen; - -function node(tagName, $staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, tagName, key, unique, props, nodes); -} - -function svg($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "svg", key, unique, props, nodes); -} - -function foreignObject($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "foreignObject", key, unique, props, nodes); -} - -function animate($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "animate", key, unique, props, nodes); -} - -function animateColor($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "animateColor", key, unique, props, nodes); -} - -function animateMotion($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "animateMotion", key, unique, props, nodes); -} - -function animateTransform($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "animateTransform", key, unique, props, nodes); -} - -function mpath($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "mpath", key, unique, props, nodes); -} - -function set($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "set", key, unique, props, nodes); -} - -function a($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "a", key, unique, props, nodes); -} - -function defs($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "defs", key, unique, props, nodes); -} - -function g($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "g", key, unique, props, nodes); -} - -function marker($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "marker", key, unique, props, nodes); -} - -function mask($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "mask", key, unique, props, nodes); -} - -function missingGlyph($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "missingGlyph", key, unique, props, nodes); -} - -function pattern($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "pattern", key, unique, props, nodes); -} - -function $$switch($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "switch", key, unique, props, nodes); -} - -function symbol($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "symbol", key, unique, props, nodes); -} - -function desc($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "desc", key, unique, props, nodes); -} - -function metadata($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "metadata", key, unique, props, nodes); -} - -function title($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "title", key, unique, props, nodes); -} - -function feBlend($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feBlend", key, unique, props, nodes); -} - -function feColorMatrix($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feColorMatrix", key, unique, props, nodes); -} - -function feComponentTransfer($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feComponentTransfer", key, unique, props, nodes); -} - -function feComposite($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feComposite", key, unique, props, nodes); -} - -function feConvolveMatrix($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feConvolveMatrix", key, unique, props, nodes); -} - -function feDiffuseLighting($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feDiffuseLighting", key, unique, props, nodes); -} - -function feDisplacementMap($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feDisplacementMap", key, unique, props, nodes); -} - -function feFlood($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feFlood", key, unique, props, nodes); -} - -function feFuncA($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feFuncA", key, unique, props, nodes); -} - -function feFuncB($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feFuncB", key, unique, props, nodes); -} - -function feFuncG($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feFuncG", key, unique, props, nodes); -} - -function feFuncR($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feFuncR", key, unique, props, nodes); -} - -function feGaussianBlur($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feGaussianBlur", key, unique, props, nodes); -} - -function feImage($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feImage", key, unique, props, nodes); -} - -function feMerge($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feMerge", key, unique, props, nodes); -} - -function feMergeNode($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feMergeNode", key, unique, props, nodes); -} - -function feMorphology($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feMorphology", key, unique, props, nodes); -} - -function feOffset($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feOffset", key, unique, props, nodes); -} - -function feSpecularLighting($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feSpecularLighting", key, unique, props, nodes); -} - -function feTile($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feTile", key, unique, props, nodes); -} - -function feTurbulence($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feTurbulence", key, unique, props, nodes); -} - -function font($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "font", key, unique, props, nodes); -} - -function fontFace($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fontFace", key, unique, props, nodes); -} - -function fontFaceFormat($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fontFaceFormat", key, unique, props, nodes); -} - -function fontFaceName($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fontFaceName", key, unique, props, nodes); -} - -function fontFaceSrc($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fontFaceSrc", key, unique, props, nodes); -} - -function fontFaceUri($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fontFaceUri", key, unique, props, nodes); -} - -function hkern($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "hkern", key, unique, props, nodes); -} - -function vkern($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "vkern", key, unique, props, nodes); -} - -function linearGradient($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "linearGradient", key, unique, props, nodes); -} - -function radialGradient($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "radialGradient", key, unique, props, nodes); -} - -function stop($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "stop", key, unique, props, nodes); -} - -function circle($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "circle", key, unique, props, nodes); -} - -function ellipse($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "ellipse", key, unique, props, nodes); -} - -function svgimage($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "image", key, unique, props, nodes); -} - -function line($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "line", key, unique, props, nodes); -} - -function path($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "path", key, unique, props, nodes); -} - -function polygon($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "polygon", key, unique, props, nodes); -} - -function polyline($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "polyline", key, unique, props, nodes); -} - -function rect($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "rect", key, unique, props, nodes); -} - -function use($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "use", key, unique, props, nodes); -} - -function feDistantLight($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feDistantLight", key, unique, props, nodes); -} - -function fePointLight($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "fePointLight", key, unique, props, nodes); -} - -function feSpotLight($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "feSpotLight", key, unique, props, nodes); -} - -function altGlyph($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "altGlyph", key, unique, props, nodes); -} - -function altGlyphDef($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "altGlyphDef", key, unique, props, nodes); -} - -function altGlyphItem($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "altGlyphItem", key, unique, props, nodes); -} - -function glyph($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "glyph", key, unique, props, nodes); -} - -function glyphRef($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "glyphRef", key, unique, props, nodes); -} - -function textPath($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "textPath", key, unique, props, nodes); -} - -function text$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "text", key, unique, props, nodes); -} - -function tref($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "tref", key, unique, props, nodes); -} - -function tspan($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "tspan", key, unique, props, nodes); -} - -function clipPath($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "clipPath", key, unique, props, nodes); -} - -function svgcolorProfile($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "colorProfile", key, unique, props, nodes); -} - -function cursor($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "cursor", key, unique, props, nodes); -} - -function filter($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "filter", key, unique, props, nodes); -} - -function script($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "script", key, unique, props, nodes); -} - -function style($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "style", key, unique, props, nodes); -} - -function view($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode(svgNamespace, "view", key, unique, props, nodes); -} - -var Cmds = /* alias */0; - -var Attributes = /* alias */0; - -var Events = /* alias */0; - -var noNode = Vdom.noNode; - -exports.Cmds = Cmds; -exports.Attributes = Attributes; -exports.Events = Events; -exports.svgNamespace = svgNamespace; -exports.noNode = noNode; -exports.text = text; -exports.lazy1 = lazy1; -exports.node = node; -exports.svg = svg; -exports.foreignObject = foreignObject; -exports.animate = animate; -exports.animateColor = animateColor; -exports.animateMotion = animateMotion; -exports.animateTransform = animateTransform; -exports.mpath = mpath; -exports.set = set; -exports.a = a; -exports.defs = defs; -exports.g = g; -exports.marker = marker; -exports.mask = mask; -exports.missingGlyph = missingGlyph; -exports.pattern = pattern; -exports.$$switch = $$switch; -exports.symbol = symbol; -exports.desc = desc; -exports.metadata = metadata; -exports.title = title; -exports.feBlend = feBlend; -exports.feColorMatrix = feColorMatrix; -exports.feComponentTransfer = feComponentTransfer; -exports.feComposite = feComposite; -exports.feConvolveMatrix = feConvolveMatrix; -exports.feDiffuseLighting = feDiffuseLighting; -exports.feDisplacementMap = feDisplacementMap; -exports.feFlood = feFlood; -exports.feFuncA = feFuncA; -exports.feFuncB = feFuncB; -exports.feFuncG = feFuncG; -exports.feFuncR = feFuncR; -exports.feGaussianBlur = feGaussianBlur; -exports.feImage = feImage; -exports.feMerge = feMerge; -exports.feMergeNode = feMergeNode; -exports.feMorphology = feMorphology; -exports.feOffset = feOffset; -exports.feSpecularLighting = feSpecularLighting; -exports.feTile = feTile; -exports.feTurbulence = feTurbulence; -exports.font = font; -exports.fontFace = fontFace; -exports.fontFaceFormat = fontFaceFormat; -exports.fontFaceName = fontFaceName; -exports.fontFaceSrc = fontFaceSrc; -exports.fontFaceUri = fontFaceUri; -exports.hkern = hkern; -exports.vkern = vkern; -exports.linearGradient = linearGradient; -exports.radialGradient = radialGradient; -exports.stop = stop; -exports.circle = circle; -exports.ellipse = ellipse; -exports.svgimage = svgimage; -exports.line = line; -exports.path = path; -exports.polygon = polygon; -exports.polyline = polyline; -exports.rect = rect; -exports.use = use; -exports.feDistantLight = feDistantLight; -exports.fePointLight = fePointLight; -exports.feSpotLight = feSpotLight; -exports.altGlyph = altGlyph; -exports.altGlyphDef = altGlyphDef; -exports.altGlyphItem = altGlyphItem; -exports.glyph = glyph; -exports.glyphRef = glyphRef; -exports.textPath = textPath; -exports.text$prime = text$prime; -exports.tref = tref; -exports.tspan = tspan; -exports.clipPath = clipPath; -exports.svgcolorProfile = svgcolorProfile; -exports.cursor = cursor; -exports.filter = filter; -exports.script = script; -exports.style = style; -exports.view = view; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_svg_attributes.js b/lib/js/src-ocaml/tea_svg_attributes.js deleted file mode 100644 index 4eb30c3..0000000 --- a/lib/js/src-ocaml/tea_svg_attributes.js +++ /dev/null @@ -1,2283 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); - -function accentHeight(v) { - return /* Attribute */Block.__(1, [ - "", - "accent-height", - v - ]); -} - -function accelerate(v) { - return /* Attribute */Block.__(1, [ - "", - "accelerate", - v - ]); -} - -function accumulate(v) { - return /* Attribute */Block.__(1, [ - "", - "accumulate", - v - ]); -} - -function additive(v) { - return /* Attribute */Block.__(1, [ - "", - "additive", - v - ]); -} - -function alphabetic(v) { - return /* Attribute */Block.__(1, [ - "", - "alphabetic", - v - ]); -} - -function allowReorder(v) { - return /* Attribute */Block.__(1, [ - "", - "allowReorder", - v - ]); -} - -function amplitude(v) { - return /* Attribute */Block.__(1, [ - "", - "amplitude", - v - ]); -} - -function arabicForm(v) { - return /* Attribute */Block.__(1, [ - "", - "arabic-form", - v - ]); -} - -function ascent(v) { - return /* Attribute */Block.__(1, [ - "", - "ascent", - v - ]); -} - -function attributeName(v) { - return /* Attribute */Block.__(1, [ - "", - "attributeName", - v - ]); -} - -function attributeType(v) { - return /* Attribute */Block.__(1, [ - "", - "attributeType", - v - ]); -} - -function autoReverse(v) { - return /* Attribute */Block.__(1, [ - "", - "autoReverse", - v - ]); -} - -function azimuth(v) { - return /* Attribute */Block.__(1, [ - "", - "azimuth", - v - ]); -} - -function baseFrequency(v) { - return /* Attribute */Block.__(1, [ - "", - "baseFrequency", - v - ]); -} - -function baseProfile(v) { - return /* Attribute */Block.__(1, [ - "", - "baseProfile", - v - ]); -} - -function bbox(v) { - return /* Attribute */Block.__(1, [ - "", - "bbox", - v - ]); -} - -function begin$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "begin", - v - ]); -} - -function bias(v) { - return /* Attribute */Block.__(1, [ - "", - "bias", - v - ]); -} - -function by(v) { - return /* Attribute */Block.__(1, [ - "", - "by", - v - ]); -} - -function calcMode(v) { - return /* Attribute */Block.__(1, [ - "", - "calcMode", - v - ]); -} - -function capHeight(v) { - return /* Attribute */Block.__(1, [ - "", - "cap-height", - v - ]); -} - -function class$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "class", - v - ]); -} - -function clipPathUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "clipPathUnits", - v - ]); -} - -function contentScriptType(v) { - return /* Attribute */Block.__(1, [ - "", - "contentScriptType", - v - ]); -} - -function contentStyleType(v) { - return /* Attribute */Block.__(1, [ - "", - "contentStyleType", - v - ]); -} - -function cx(v) { - return /* Attribute */Block.__(1, [ - "", - "cx", - v - ]); -} - -function cy(v) { - return /* Attribute */Block.__(1, [ - "", - "cy", - v - ]); -} - -function d(v) { - return /* Attribute */Block.__(1, [ - "", - "d", - v - ]); -} - -function decelerate(v) { - return /* Attribute */Block.__(1, [ - "", - "decelerate", - v - ]); -} - -function descent(v) { - return /* Attribute */Block.__(1, [ - "", - "descent", - v - ]); -} - -function diffuseConstant(v) { - return /* Attribute */Block.__(1, [ - "", - "diffuseConstant", - v - ]); -} - -function divisor(v) { - return /* Attribute */Block.__(1, [ - "", - "divisor", - v - ]); -} - -function dur(v) { - return /* Attribute */Block.__(1, [ - "", - "dur", - v - ]); -} - -function dx(v) { - return /* Attribute */Block.__(1, [ - "", - "dx", - v - ]); -} - -function dy(v) { - return /* Attribute */Block.__(1, [ - "", - "dy", - v - ]); -} - -function edgeMode(v) { - return /* Attribute */Block.__(1, [ - "", - "edgeMode", - v - ]); -} - -function elevation(v) { - return /* Attribute */Block.__(1, [ - "", - "elevation", - v - ]); -} - -function end$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "end", - v - ]); -} - -function exponent(v) { - return /* Attribute */Block.__(1, [ - "", - "exponent", - v - ]); -} - -function externalResourcesRequired(v) { - return /* Attribute */Block.__(1, [ - "", - "externalResourcesRequired", - v - ]); -} - -function filterRes(v) { - return /* Attribute */Block.__(1, [ - "", - "filterRes", - v - ]); -} - -function filterUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "filterUnits", - v - ]); -} - -function format(v) { - return /* Attribute */Block.__(1, [ - "", - "format", - v - ]); -} - -function from(v) { - return /* Attribute */Block.__(1, [ - "", - "from", - v - ]); -} - -function fx(v) { - return /* Attribute */Block.__(1, [ - "", - "fx", - v - ]); -} - -function fy(v) { - return /* Attribute */Block.__(1, [ - "", - "fy", - v - ]); -} - -function g1(v) { - return /* Attribute */Block.__(1, [ - "", - "g1", - v - ]); -} - -function g2(v) { - return /* Attribute */Block.__(1, [ - "", - "g2", - v - ]); -} - -function glyphName(v) { - return /* Attribute */Block.__(1, [ - "", - "glyph-name", - v - ]); -} - -function glyphRef(v) { - return /* Attribute */Block.__(1, [ - "", - "glyphRef", - v - ]); -} - -function gradientTransform(v) { - return /* Attribute */Block.__(1, [ - "", - "gradientTransform", - v - ]); -} - -function gradientUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "gradientUnits", - v - ]); -} - -function hanging(v) { - return /* Attribute */Block.__(1, [ - "", - "hanging", - v - ]); -} - -function height(v) { - return /* Attribute */Block.__(1, [ - "", - "height", - v - ]); -} - -function horizAdvX(v) { - return /* Attribute */Block.__(1, [ - "", - "horiz-adv-x", - v - ]); -} - -function horizOriginX(v) { - return /* Attribute */Block.__(1, [ - "", - "horiz-origin-x", - v - ]); -} - -function horizOriginY(v) { - return /* Attribute */Block.__(1, [ - "", - "horiz-origin-y", - v - ]); -} - -function id(v) { - return /* Attribute */Block.__(1, [ - "", - "id", - v - ]); -} - -function ideographic(v) { - return /* Attribute */Block.__(1, [ - "", - "ideographic", - v - ]); -} - -function in$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "in", - v - ]); -} - -function in2(v) { - return /* Attribute */Block.__(1, [ - "", - "in2", - v - ]); -} - -function intercept(v) { - return /* Attribute */Block.__(1, [ - "", - "intercept", - v - ]); -} - -function k(v) { - return /* Attribute */Block.__(1, [ - "", - "k", - v - ]); -} - -function k1(v) { - return /* Attribute */Block.__(1, [ - "", - "k1", - v - ]); -} - -function k2(v) { - return /* Attribute */Block.__(1, [ - "", - "k2", - v - ]); -} - -function k3(v) { - return /* Attribute */Block.__(1, [ - "", - "k3", - v - ]); -} - -function k4(v) { - return /* Attribute */Block.__(1, [ - "", - "k4", - v - ]); -} - -function kernelMatrix(v) { - return /* Attribute */Block.__(1, [ - "", - "kernelMatrix", - v - ]); -} - -function kernelUnitLength(v) { - return /* Attribute */Block.__(1, [ - "", - "kernelUnitLength", - v - ]); -} - -function keyPoints(v) { - return /* Attribute */Block.__(1, [ - "", - "keyPoints", - v - ]); -} - -function keySplines(v) { - return /* Attribute */Block.__(1, [ - "", - "keySplines", - v - ]); -} - -function keyTimes(v) { - return /* Attribute */Block.__(1, [ - "", - "keyTimes", - v - ]); -} - -function lang(v) { - return /* Attribute */Block.__(1, [ - "", - "lang", - v - ]); -} - -function lengthAdjust(v) { - return /* Attribute */Block.__(1, [ - "", - "lengthAdjust", - v - ]); -} - -function limitingConeAngle(v) { - return /* Attribute */Block.__(1, [ - "", - "limitingConeAngle", - v - ]); -} - -function local(v) { - return /* Attribute */Block.__(1, [ - "", - "local", - v - ]); -} - -function markerHeight(v) { - return /* Attribute */Block.__(1, [ - "", - "markerHeight", - v - ]); -} - -function markerUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "markerUnits", - v - ]); -} - -function markerWidth(v) { - return /* Attribute */Block.__(1, [ - "", - "markerWidth", - v - ]); -} - -function maskContentUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "maskContentUnits", - v - ]); -} - -function maskUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "maskUnits", - v - ]); -} - -function mathematical(v) { - return /* Attribute */Block.__(1, [ - "", - "mathematical", - v - ]); -} - -function max(v) { - return /* Attribute */Block.__(1, [ - "", - "max", - v - ]); -} - -function media(v) { - return /* Attribute */Block.__(1, [ - "", - "media", - v - ]); -} - -function method$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "method", - v - ]); -} - -function min(v) { - return /* Attribute */Block.__(1, [ - "", - "min", - v - ]); -} - -function mode(v) { - return /* Attribute */Block.__(1, [ - "", - "mode", - v - ]); -} - -function name(v) { - return /* Attribute */Block.__(1, [ - "", - "name", - v - ]); -} - -function numOctaves(v) { - return /* Attribute */Block.__(1, [ - "", - "numOctaves", - v - ]); -} - -function offset(v) { - return /* Attribute */Block.__(1, [ - "", - "offset", - v - ]); -} - -function operator(v) { - return /* Attribute */Block.__(1, [ - "", - "operator", - v - ]); -} - -function order(v) { - return /* Attribute */Block.__(1, [ - "", - "order", - v - ]); -} - -function orient(v) { - return /* Attribute */Block.__(1, [ - "", - "orient", - v - ]); -} - -function orientation(v) { - return /* Attribute */Block.__(1, [ - "", - "orientation", - v - ]); -} - -function origin(v) { - return /* Attribute */Block.__(1, [ - "", - "origin", - v - ]); -} - -function overlinePosition(v) { - return /* Attribute */Block.__(1, [ - "", - "overline-position", - v - ]); -} - -function overlineThickness(v) { - return /* Attribute */Block.__(1, [ - "", - "overline-thickness", - v - ]); -} - -function panose1(v) { - return /* Attribute */Block.__(1, [ - "", - "panose-1", - v - ]); -} - -function path(v) { - return /* Attribute */Block.__(1, [ - "", - "path", - v - ]); -} - -function pathLength(v) { - return /* Attribute */Block.__(1, [ - "", - "pathLength", - v - ]); -} - -function patternContentUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "patternContentUnits", - v - ]); -} - -function patternTransform(v) { - return /* Attribute */Block.__(1, [ - "", - "patternTransform", - v - ]); -} - -function patternUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "patternUnits", - v - ]); -} - -function pointOrder(v) { - return /* Attribute */Block.__(1, [ - "", - "point-order", - v - ]); -} - -function points(v) { - return /* Attribute */Block.__(1, [ - "", - "points", - v - ]); -} - -function pointsAtX(v) { - return /* Attribute */Block.__(1, [ - "", - "pointsAtX", - v - ]); -} - -function pointsAtY(v) { - return /* Attribute */Block.__(1, [ - "", - "pointsAtY", - v - ]); -} - -function pointsAtZ(v) { - return /* Attribute */Block.__(1, [ - "", - "pointsAtZ", - v - ]); -} - -function preserveAlpha(v) { - return /* Attribute */Block.__(1, [ - "", - "preserveAlpha", - v - ]); -} - -function preserveAspectRatio(v) { - return /* Attribute */Block.__(1, [ - "", - "preserveAspectRatio", - v - ]); -} - -function primitiveUnits(v) { - return /* Attribute */Block.__(1, [ - "", - "primitiveUnits", - v - ]); -} - -function r(v) { - return /* Attribute */Block.__(1, [ - "", - "r", - v - ]); -} - -function radius(v) { - return /* Attribute */Block.__(1, [ - "", - "radius", - v - ]); -} - -function refX(v) { - return /* Attribute */Block.__(1, [ - "", - "refX", - v - ]); -} - -function refY(v) { - return /* Attribute */Block.__(1, [ - "", - "refY", - v - ]); -} - -function renderingIntent(v) { - return /* Attribute */Block.__(1, [ - "", - "rendering-intent", - v - ]); -} - -function repeatCount(v) { - return /* Attribute */Block.__(1, [ - "", - "repeatCount", - v - ]); -} - -function repeatDur(v) { - return /* Attribute */Block.__(1, [ - "", - "repeatDur", - v - ]); -} - -function requiredExtensions(v) { - return /* Attribute */Block.__(1, [ - "", - "requiredExtensions", - v - ]); -} - -function requiredFeatures(v) { - return /* Attribute */Block.__(1, [ - "", - "requiredFeatures", - v - ]); -} - -function restart(v) { - return /* Attribute */Block.__(1, [ - "", - "restart", - v - ]); -} - -function result(v) { - return /* Attribute */Block.__(1, [ - "", - "result", - v - ]); -} - -function rotate(v) { - return /* Attribute */Block.__(1, [ - "", - "rotate", - v - ]); -} - -function rx(v) { - return /* Attribute */Block.__(1, [ - "", - "rx", - v - ]); -} - -function ry(v) { - return /* Attribute */Block.__(1, [ - "", - "ry", - v - ]); -} - -function scale(v) { - return /* Attribute */Block.__(1, [ - "", - "scale", - v - ]); -} - -function seed(v) { - return /* Attribute */Block.__(1, [ - "", - "seed", - v - ]); -} - -function slope(v) { - return /* Attribute */Block.__(1, [ - "", - "slope", - v - ]); -} - -function spacing(v) { - return /* Attribute */Block.__(1, [ - "", - "spacing", - v - ]); -} - -function specularConstant(v) { - return /* Attribute */Block.__(1, [ - "", - "specularConstant", - v - ]); -} - -function specularExponent(v) { - return /* Attribute */Block.__(1, [ - "", - "specularExponent", - v - ]); -} - -function speed(v) { - return /* Attribute */Block.__(1, [ - "", - "speed", - v - ]); -} - -function spreadMethod(v) { - return /* Attribute */Block.__(1, [ - "", - "spreadMethod", - v - ]); -} - -function startOffset(v) { - return /* Attribute */Block.__(1, [ - "", - "startOffset", - v - ]); -} - -function stdDeviation(v) { - return /* Attribute */Block.__(1, [ - "", - "stdDeviation", - v - ]); -} - -function stemh(v) { - return /* Attribute */Block.__(1, [ - "", - "stemh", - v - ]); -} - -function stemv(v) { - return /* Attribute */Block.__(1, [ - "", - "stemv", - v - ]); -} - -function stitchTiles(v) { - return /* Attribute */Block.__(1, [ - "", - "stitchTiles", - v - ]); -} - -function strikethroughPosition(v) { - return /* Attribute */Block.__(1, [ - "", - "strikethrough-position", - v - ]); -} - -function strikethroughThickness(v) { - return /* Attribute */Block.__(1, [ - "", - "strikethrough-thickness", - v - ]); -} - -function string(v) { - return /* Attribute */Block.__(1, [ - "", - "string", - v - ]); -} - -function style(v) { - return /* Attribute */Block.__(1, [ - "", - "style", - v - ]); -} - -function surfaceScale(v) { - return /* Attribute */Block.__(1, [ - "", - "surfaceScale", - v - ]); -} - -function systemLanguage(v) { - return /* Attribute */Block.__(1, [ - "", - "systemLanguage", - v - ]); -} - -function tableValues(v) { - return /* Attribute */Block.__(1, [ - "", - "tableValues", - v - ]); -} - -function target(v) { - return /* Attribute */Block.__(1, [ - "", - "target", - v - ]); -} - -function targetX(v) { - return /* Attribute */Block.__(1, [ - "", - "targetX", - v - ]); -} - -function targetY(v) { - return /* Attribute */Block.__(1, [ - "", - "targetY", - v - ]); -} - -function textLength(v) { - return /* Attribute */Block.__(1, [ - "", - "textLength", - v - ]); -} - -function title(v) { - return /* Attribute */Block.__(1, [ - "", - "title", - v - ]); -} - -function to$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "to", - v - ]); -} - -function transform(v) { - return /* Attribute */Block.__(1, [ - "", - "transform", - v - ]); -} - -function type$prime(v) { - return /* Attribute */Block.__(1, [ - "", - "type", - v - ]); -} - -function u1(v) { - return /* Attribute */Block.__(1, [ - "", - "u1", - v - ]); -} - -function u2(v) { - return /* Attribute */Block.__(1, [ - "", - "u2", - v - ]); -} - -function underlinePosition(v) { - return /* Attribute */Block.__(1, [ - "", - "underline-position", - v - ]); -} - -function underlineThickness(v) { - return /* Attribute */Block.__(1, [ - "", - "underline-thickness", - v - ]); -} - -function unicode(v) { - return /* Attribute */Block.__(1, [ - "", - "unicode", - v - ]); -} - -function unicodeRange(v) { - return /* Attribute */Block.__(1, [ - "", - "unicode-range", - v - ]); -} - -function unitsPerEm(v) { - return /* Attribute */Block.__(1, [ - "", - "units-per-em", - v - ]); -} - -function vAlphabetic(v) { - return /* Attribute */Block.__(1, [ - "", - "v-alphabetic", - v - ]); -} - -function vHanging(v) { - return /* Attribute */Block.__(1, [ - "", - "v-hanging", - v - ]); -} - -function vIdeographic(v) { - return /* Attribute */Block.__(1, [ - "", - "v-ideographic", - v - ]); -} - -function vMathematical(v) { - return /* Attribute */Block.__(1, [ - "", - "v-mathematical", - v - ]); -} - -function values(v) { - return /* Attribute */Block.__(1, [ - "", - "values", - v - ]); -} - -function version(v) { - return /* Attribute */Block.__(1, [ - "", - "version", - v - ]); -} - -function vertAdvY(v) { - return /* Attribute */Block.__(1, [ - "", - "vert-adv-y", - v - ]); -} - -function vertOriginX(v) { - return /* Attribute */Block.__(1, [ - "", - "vert-origin-x", - v - ]); -} - -function vertOriginY(v) { - return /* Attribute */Block.__(1, [ - "", - "vert-origin-y", - v - ]); -} - -function viewBox(v) { - return /* Attribute */Block.__(1, [ - "", - "viewBox", - v - ]); -} - -function viewTarget(v) { - return /* Attribute */Block.__(1, [ - "", - "viewTarget", - v - ]); -} - -function width(v) { - return /* Attribute */Block.__(1, [ - "", - "width", - v - ]); -} - -function widths(v) { - return /* Attribute */Block.__(1, [ - "", - "widths", - v - ]); -} - -function x(v) { - return /* Attribute */Block.__(1, [ - "", - "x", - v - ]); -} - -function xHeight(v) { - return /* Attribute */Block.__(1, [ - "", - "x-height", - v - ]); -} - -function x1(v) { - return /* Attribute */Block.__(1, [ - "", - "x1", - v - ]); -} - -function x2(v) { - return /* Attribute */Block.__(1, [ - "", - "x2", - v - ]); -} - -function xChannelSelector(v) { - return /* Attribute */Block.__(1, [ - "", - "xChannelSelector", - v - ]); -} - -function xlinkActuate(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:actuate", - v - ]); -} - -function xlinkArcrole(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:arcrole", - v - ]); -} - -function xlinkHref(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:href", - v - ]); -} - -function xlinkRole(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:role", - v - ]); -} - -function xlinkShow(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:show", - v - ]); -} - -function xlinkTitle(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:title", - v - ]); -} - -function xlinkType(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/1999/xlink", - "xlink:type", - v - ]); -} - -function xmlBase(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/XML/1998/namespace", - "xml:base", - v - ]); -} - -function xmlLang(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/XML/1998/namespace", - "xml:lang", - v - ]); -} - -function xmlSpace(v) { - return /* Attribute */Block.__(1, [ - "http://www.w3.org/XML/1998/namespace", - "xml:space", - v - ]); -} - -function y(v) { - return /* Attribute */Block.__(1, [ - "", - "y", - v - ]); -} - -function y1(v) { - return /* Attribute */Block.__(1, [ - "", - "y1", - v - ]); -} - -function y2(v) { - return /* Attribute */Block.__(1, [ - "", - "y2", - v - ]); -} - -function yChannelSelector(v) { - return /* Attribute */Block.__(1, [ - "", - "yChannelSelector", - v - ]); -} - -function z(v) { - return /* Attribute */Block.__(1, [ - "", - "z", - v - ]); -} - -function zoomAndPan(v) { - return /* Attribute */Block.__(1, [ - "", - "zoomAndPan", - v - ]); -} - -function alignmentBaseline(v) { - return /* Attribute */Block.__(1, [ - "", - "alignment-baseline", - v - ]); -} - -function baselineShift(v) { - return /* Attribute */Block.__(1, [ - "", - "baseline-shift", - v - ]); -} - -function clipPath(v) { - return /* Attribute */Block.__(1, [ - "", - "clip-path", - v - ]); -} - -function clipRule(v) { - return /* Attribute */Block.__(1, [ - "", - "clip-rule", - v - ]); -} - -function clip(v) { - return /* Attribute */Block.__(1, [ - "", - "clip", - v - ]); -} - -function colorInterpolationFilters(v) { - return /* Attribute */Block.__(1, [ - "", - "color-interpolation-filters", - v - ]); -} - -function colorInterpolation(v) { - return /* Attribute */Block.__(1, [ - "", - "color-interpolation", - v - ]); -} - -function colorProfile(v) { - return /* Attribute */Block.__(1, [ - "", - "color-profile", - v - ]); -} - -function colorRendering(v) { - return /* Attribute */Block.__(1, [ - "", - "color-rendering", - v - ]); -} - -function color(v) { - return /* Attribute */Block.__(1, [ - "", - "color", - v - ]); -} - -function cursor(v) { - return /* Attribute */Block.__(1, [ - "", - "cursor", - v - ]); -} - -function direction(v) { - return /* Attribute */Block.__(1, [ - "", - "direction", - v - ]); -} - -function display(v) { - return /* Attribute */Block.__(1, [ - "", - "display", - v - ]); -} - -function dominantBaseline(v) { - return /* Attribute */Block.__(1, [ - "", - "dominant-baseline", - v - ]); -} - -function enableBackground(v) { - return /* Attribute */Block.__(1, [ - "", - "enable-background", - v - ]); -} - -function fillOpacity(v) { - return /* Attribute */Block.__(1, [ - "", - "fill-opacity", - v - ]); -} - -function fillRule(v) { - return /* Attribute */Block.__(1, [ - "", - "fill-rule", - v - ]); -} - -function fill(v) { - return /* Attribute */Block.__(1, [ - "", - "fill", - v - ]); -} - -function filter(v) { - return /* Attribute */Block.__(1, [ - "", - "filter", - v - ]); -} - -function floodColor(v) { - return /* Attribute */Block.__(1, [ - "", - "flood-color", - v - ]); -} - -function floodOpacity(v) { - return /* Attribute */Block.__(1, [ - "", - "flood-opacity", - v - ]); -} - -function fontFamily(v) { - return /* Attribute */Block.__(1, [ - "", - "font-family", - v - ]); -} - -function fontSizeAdjust(v) { - return /* Attribute */Block.__(1, [ - "", - "font-size-adjust", - v - ]); -} - -function fontSize(v) { - return /* Attribute */Block.__(1, [ - "", - "font-size", - v - ]); -} - -function fontStretch(v) { - return /* Attribute */Block.__(1, [ - "", - "font-stretch", - v - ]); -} - -function fontStyle(v) { - return /* Attribute */Block.__(1, [ - "", - "font-style", - v - ]); -} - -function fontVariant(v) { - return /* Attribute */Block.__(1, [ - "", - "font-variant", - v - ]); -} - -function fontWeight(v) { - return /* Attribute */Block.__(1, [ - "", - "font-weight", - v - ]); -} - -function glyphOrientationHorizontal(v) { - return /* Attribute */Block.__(1, [ - "", - "glyph-orientation-horizontal", - v - ]); -} - -function glyphOrientationVertical(v) { - return /* Attribute */Block.__(1, [ - "", - "glyph-orientation-vertical", - v - ]); -} - -function imageRendering(v) { - return /* Attribute */Block.__(1, [ - "", - "image-rendering", - v - ]); -} - -function kerning(v) { - return /* Attribute */Block.__(1, [ - "", - "kerning", - v - ]); -} - -function letterSpacing(v) { - return /* Attribute */Block.__(1, [ - "", - "letter-spacing", - v - ]); -} - -function lightingColor(v) { - return /* Attribute */Block.__(1, [ - "", - "lighting-color", - v - ]); -} - -function markerEnd(v) { - return /* Attribute */Block.__(1, [ - "", - "marker-end", - v - ]); -} - -function markerMid(v) { - return /* Attribute */Block.__(1, [ - "", - "marker-mid", - v - ]); -} - -function markerStart(v) { - return /* Attribute */Block.__(1, [ - "", - "marker-start", - v - ]); -} - -function mask(v) { - return /* Attribute */Block.__(1, [ - "", - "mask", - v - ]); -} - -function opacity(v) { - return /* Attribute */Block.__(1, [ - "", - "opacity", - v - ]); -} - -function overflow(v) { - return /* Attribute */Block.__(1, [ - "", - "overflow", - v - ]); -} - -function pointerEvents(v) { - return /* Attribute */Block.__(1, [ - "", - "pointer-events", - v - ]); -} - -function shapeRendering(v) { - return /* Attribute */Block.__(1, [ - "", - "shape-rendering", - v - ]); -} - -function stopColor(v) { - return /* Attribute */Block.__(1, [ - "", - "stop-color", - v - ]); -} - -function stopOpacity(v) { - return /* Attribute */Block.__(1, [ - "", - "stop-opacity", - v - ]); -} - -function strokeDasharray(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-dasharray", - v - ]); -} - -function strokeDashoffset(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-dashoffset", - v - ]); -} - -function strokeLinecap(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-linecap", - v - ]); -} - -function strokeLinejoin(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-linejoin", - v - ]); -} - -function strokeMiterlimit(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-miterlimit", - v - ]); -} - -function strokeOpacity(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-opacity", - v - ]); -} - -function strokeWidth(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke-width", - v - ]); -} - -function stroke(v) { - return /* Attribute */Block.__(1, [ - "", - "stroke", - v - ]); -} - -function textAnchor(v) { - return /* Attribute */Block.__(1, [ - "", - "text-anchor", - v - ]); -} - -function textDecoration(v) { - return /* Attribute */Block.__(1, [ - "", - "text-decoration", - v - ]); -} - -function textRendering(v) { - return /* Attribute */Block.__(1, [ - "", - "text-rendering", - v - ]); -} - -function unicodeBidi(v) { - return /* Attribute */Block.__(1, [ - "", - "unicode-bidi", - v - ]); -} - -function visibility(v) { - return /* Attribute */Block.__(1, [ - "", - "visibility", - v - ]); -} - -function wordSpacing(v) { - return /* Attribute */Block.__(1, [ - "", - "word-spacing", - v - ]); -} - -function writingMode(v) { - return /* Attribute */Block.__(1, [ - "", - "writing-mode", - v - ]); -} - -exports.accentHeight = accentHeight; -exports.accelerate = accelerate; -exports.accumulate = accumulate; -exports.additive = additive; -exports.alphabetic = alphabetic; -exports.allowReorder = allowReorder; -exports.amplitude = amplitude; -exports.arabicForm = arabicForm; -exports.ascent = ascent; -exports.attributeName = attributeName; -exports.attributeType = attributeType; -exports.autoReverse = autoReverse; -exports.azimuth = azimuth; -exports.baseFrequency = baseFrequency; -exports.baseProfile = baseProfile; -exports.bbox = bbox; -exports.begin$prime = begin$prime; -exports.bias = bias; -exports.by = by; -exports.calcMode = calcMode; -exports.capHeight = capHeight; -exports.class$prime = class$prime; -exports.clipPathUnits = clipPathUnits; -exports.contentScriptType = contentScriptType; -exports.contentStyleType = contentStyleType; -exports.cx = cx; -exports.cy = cy; -exports.d = d; -exports.decelerate = decelerate; -exports.descent = descent; -exports.diffuseConstant = diffuseConstant; -exports.divisor = divisor; -exports.dur = dur; -exports.dx = dx; -exports.dy = dy; -exports.edgeMode = edgeMode; -exports.elevation = elevation; -exports.end$prime = end$prime; -exports.exponent = exponent; -exports.externalResourcesRequired = externalResourcesRequired; -exports.filterRes = filterRes; -exports.filterUnits = filterUnits; -exports.format = format; -exports.from = from; -exports.fx = fx; -exports.fy = fy; -exports.g1 = g1; -exports.g2 = g2; -exports.glyphName = glyphName; -exports.glyphRef = glyphRef; -exports.gradientTransform = gradientTransform; -exports.gradientUnits = gradientUnits; -exports.hanging = hanging; -exports.height = height; -exports.horizAdvX = horizAdvX; -exports.horizOriginX = horizOriginX; -exports.horizOriginY = horizOriginY; -exports.id = id; -exports.ideographic = ideographic; -exports.in$prime = in$prime; -exports.in2 = in2; -exports.intercept = intercept; -exports.k = k; -exports.k1 = k1; -exports.k2 = k2; -exports.k3 = k3; -exports.k4 = k4; -exports.kernelMatrix = kernelMatrix; -exports.kernelUnitLength = kernelUnitLength; -exports.keyPoints = keyPoints; -exports.keySplines = keySplines; -exports.keyTimes = keyTimes; -exports.lang = lang; -exports.lengthAdjust = lengthAdjust; -exports.limitingConeAngle = limitingConeAngle; -exports.local = local; -exports.markerHeight = markerHeight; -exports.markerUnits = markerUnits; -exports.markerWidth = markerWidth; -exports.maskContentUnits = maskContentUnits; -exports.maskUnits = maskUnits; -exports.mathematical = mathematical; -exports.max = max; -exports.media = media; -exports.method$prime = method$prime; -exports.min = min; -exports.mode = mode; -exports.name = name; -exports.numOctaves = numOctaves; -exports.offset = offset; -exports.operator = operator; -exports.order = order; -exports.orient = orient; -exports.orientation = orientation; -exports.origin = origin; -exports.overlinePosition = overlinePosition; -exports.overlineThickness = overlineThickness; -exports.panose1 = panose1; -exports.path = path; -exports.pathLength = pathLength; -exports.patternContentUnits = patternContentUnits; -exports.patternTransform = patternTransform; -exports.patternUnits = patternUnits; -exports.pointOrder = pointOrder; -exports.points = points; -exports.pointsAtX = pointsAtX; -exports.pointsAtY = pointsAtY; -exports.pointsAtZ = pointsAtZ; -exports.preserveAlpha = preserveAlpha; -exports.preserveAspectRatio = preserveAspectRatio; -exports.primitiveUnits = primitiveUnits; -exports.r = r; -exports.radius = radius; -exports.refX = refX; -exports.refY = refY; -exports.renderingIntent = renderingIntent; -exports.repeatCount = repeatCount; -exports.repeatDur = repeatDur; -exports.requiredExtensions = requiredExtensions; -exports.requiredFeatures = requiredFeatures; -exports.restart = restart; -exports.result = result; -exports.rotate = rotate; -exports.rx = rx; -exports.ry = ry; -exports.scale = scale; -exports.seed = seed; -exports.slope = slope; -exports.spacing = spacing; -exports.specularConstant = specularConstant; -exports.specularExponent = specularExponent; -exports.speed = speed; -exports.spreadMethod = spreadMethod; -exports.startOffset = startOffset; -exports.stdDeviation = stdDeviation; -exports.stemh = stemh; -exports.stemv = stemv; -exports.stitchTiles = stitchTiles; -exports.strikethroughPosition = strikethroughPosition; -exports.strikethroughThickness = strikethroughThickness; -exports.string = string; -exports.style = style; -exports.surfaceScale = surfaceScale; -exports.systemLanguage = systemLanguage; -exports.tableValues = tableValues; -exports.target = target; -exports.targetX = targetX; -exports.targetY = targetY; -exports.textLength = textLength; -exports.title = title; -exports.to$prime = to$prime; -exports.transform = transform; -exports.type$prime = type$prime; -exports.u1 = u1; -exports.u2 = u2; -exports.underlinePosition = underlinePosition; -exports.underlineThickness = underlineThickness; -exports.unicode = unicode; -exports.unicodeRange = unicodeRange; -exports.unitsPerEm = unitsPerEm; -exports.vAlphabetic = vAlphabetic; -exports.vHanging = vHanging; -exports.vIdeographic = vIdeographic; -exports.vMathematical = vMathematical; -exports.values = values; -exports.version = version; -exports.vertAdvY = vertAdvY; -exports.vertOriginX = vertOriginX; -exports.vertOriginY = vertOriginY; -exports.viewBox = viewBox; -exports.viewTarget = viewTarget; -exports.width = width; -exports.widths = widths; -exports.x = x; -exports.xHeight = xHeight; -exports.x1 = x1; -exports.x2 = x2; -exports.xChannelSelector = xChannelSelector; -exports.xlinkActuate = xlinkActuate; -exports.xlinkArcrole = xlinkArcrole; -exports.xlinkHref = xlinkHref; -exports.xlinkRole = xlinkRole; -exports.xlinkShow = xlinkShow; -exports.xlinkTitle = xlinkTitle; -exports.xlinkType = xlinkType; -exports.xmlBase = xmlBase; -exports.xmlLang = xmlLang; -exports.xmlSpace = xmlSpace; -exports.y = y; -exports.y1 = y1; -exports.y2 = y2; -exports.yChannelSelector = yChannelSelector; -exports.z = z; -exports.zoomAndPan = zoomAndPan; -exports.alignmentBaseline = alignmentBaseline; -exports.baselineShift = baselineShift; -exports.clipPath = clipPath; -exports.clipRule = clipRule; -exports.clip = clip; -exports.colorInterpolationFilters = colorInterpolationFilters; -exports.colorInterpolation = colorInterpolation; -exports.colorProfile = colorProfile; -exports.colorRendering = colorRendering; -exports.color = color; -exports.cursor = cursor; -exports.direction = direction; -exports.display = display; -exports.dominantBaseline = dominantBaseline; -exports.enableBackground = enableBackground; -exports.fillOpacity = fillOpacity; -exports.fillRule = fillRule; -exports.fill = fill; -exports.filter = filter; -exports.floodColor = floodColor; -exports.floodOpacity = floodOpacity; -exports.fontFamily = fontFamily; -exports.fontSizeAdjust = fontSizeAdjust; -exports.fontSize = fontSize; -exports.fontStretch = fontStretch; -exports.fontStyle = fontStyle; -exports.fontVariant = fontVariant; -exports.fontWeight = fontWeight; -exports.glyphOrientationHorizontal = glyphOrientationHorizontal; -exports.glyphOrientationVertical = glyphOrientationVertical; -exports.imageRendering = imageRendering; -exports.kerning = kerning; -exports.letterSpacing = letterSpacing; -exports.lightingColor = lightingColor; -exports.markerEnd = markerEnd; -exports.markerMid = markerMid; -exports.markerStart = markerStart; -exports.mask = mask; -exports.opacity = opacity; -exports.overflow = overflow; -exports.pointerEvents = pointerEvents; -exports.shapeRendering = shapeRendering; -exports.stopColor = stopColor; -exports.stopOpacity = stopOpacity; -exports.strokeDasharray = strokeDasharray; -exports.strokeDashoffset = strokeDashoffset; -exports.strokeLinecap = strokeLinecap; -exports.strokeLinejoin = strokeLinejoin; -exports.strokeMiterlimit = strokeMiterlimit; -exports.strokeOpacity = strokeOpacity; -exports.strokeWidth = strokeWidth; -exports.stroke = stroke; -exports.textAnchor = textAnchor; -exports.textDecoration = textDecoration; -exports.textRendering = textRendering; -exports.unicodeBidi = unicodeBidi; -exports.visibility = visibility; -exports.wordSpacing = wordSpacing; -exports.writingMode = writingMode; -/* No side effect */ diff --git a/lib/js/src-ocaml/tea_task.js b/lib/js/src-ocaml/tea_task.js deleted file mode 100644 index 73b8222..0000000 --- a/lib/js/src-ocaml/tea_task.js +++ /dev/null @@ -1,475 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_obj = require("bs-platform/lib/js/caml_obj.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function nothing(param) { - return /* () */0; -} - -function performOpt(toOptionalMessage, param) { - var task = param[0]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(task, (function (param) { - if (param.tag) { - throw [ - Caml_builtin_exceptions.failure, - "ERROR: Task perfom returned error of never! Should not happen!" - ]; - } else { - var match = Curry._1(toOptionalMessage, param[0]); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - } - })); - })]); -} - -function perform(toMessage, task) { - return performOpt((function (v) { - return Caml_option.some(Curry._1(toMessage, v)); - }), task); -} - -function attemptOpt(resultToOptionalMessage, param) { - var task = param[0]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(task, (function (value) { - var match = Curry._1(resultToOptionalMessage, value); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - })); - })]); -} - -function attempt(resultToMessage, task) { - return attemptOpt((function (v) { - return Caml_option.some(Curry._1(resultToMessage, v)); - }), task); -} - -function ignore(task) { - return attemptOpt((function (param) { - return ; - }), task); -} - -function succeed(value) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; -} - -function fail(value) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; -} - -function nativeBinding(func) { - return /* Task */[func]; -} - -function andThen(fn, param) { - var task = param[0]; - return /* Task */[(function (cb) { - return Curry._1(task, (function (err) { - if (err.tag) { - return Curry._1(cb, err); - } else { - var match = Curry._1(fn, err[0]); - return Curry._1(match[0], cb); - } - })); - })]; -} - -function onError(fn, param) { - var task = param[0]; - return /* Task */[(function (cb) { - return Curry._1(task, (function (ok) { - if (ok.tag) { - var match = Curry._1(fn, ok[0]); - return Curry._1(match[0], cb); - } else { - return Curry._1(cb, ok); - } - })); - })]; -} - -function fromResult(param) { - if (param.tag) { - var value = param[0]; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; - } else { - var value$1 = param[0]; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value$1])); - })]; - } -} - -function mapError(func, task) { - return onError((function (e) { - var value = Curry._1(func, e); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; - }), task); -} - -function toOption(task) { - return onError((function (param) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [undefined])); - })]; - }), andThen((function (v) { - var value = Caml_option.some(v); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task)); -} - -function map(func, task1) { - return andThen((function (v1) { - var value = Curry._1(func, v1); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task1); -} - -function map2(func, task1, task2) { - return andThen((function (v1) { - return andThen((function (v2) { - var value = Curry._2(func, v1, v2); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task2); - }), task1); -} - -function map3(func, task1, task2, task3) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - var value = Curry._3(func, v1, v2, v3); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task3); - }), task2); - }), task1); -} - -function map4(func, task1, task2, task3, task4) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - var value = Curry._4(func, v1, v2, v3, v4); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task4); - }), task3); - }), task2); - }), task1); -} - -function map5(func, task1, task2, task3, task4, task5) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - return andThen((function (v5) { - var value = Curry._5(func, v1, v2, v3, v4, v5); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task5); - }), task4); - }), task3); - }), task2); - }), task1); -} - -function map6(func, task1, task2, task3, task4, task5, task6) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - return andThen((function (v5) { - return andThen((function (v6) { - var value = Curry._6(func, v1, v2, v3, v4, v5, v6); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task6); - }), task5); - }), task4); - }), task3); - }), task2); - }), task1); -} - -function sequence(param) { - if (param) { - return map2((function (l, r) { - return /* :: */[ - l, - r - ]; - }), param[0], sequence(param[1])); - } else { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [/* [] */0])); - })]; - } -} - -var testing_deop = { - contents: true -}; - -function testing(param) { - var doTest = function (expected, param) { - return Curry._1(param[0], (function (v) { - if (Caml_obj.caml_equal(v, expected)) { - console.log(/* tuple */[ - "Passed:", - expected, - v - ]); - return /* () */0; - } else { - console.log(/* tuple */[ - "FAILED:", - expected, - v - ]); - return /* () */0; - } - })); - }; - var s = /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - doTest(/* Ok */Block.__(0, [42]), s); - var f = /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [86])); - })]; - doTest(/* Error */Block.__(1, [86]), f); - var r = function (param) { - if (testing_deop.contents) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - } else { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]; - } - }; - var a1 = andThen((function (n) { - var value = n + 2 | 0; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]); - doTest(/* Ok */Block.__(0, [4]), a1); - var a2 = andThen((function (n) { - var value = String(n); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]); - doTest(/* Ok */Block.__(0, ["2"]), a2); - var m1 = map((function (prim) { - return Math.sqrt(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })]); - doTest(/* Ok */Block.__(0, [3]), m1); - var m2 = map2((function (prim, prim$1) { - return prim + prim$1 | 0; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })], /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [3])); - })]); - doTest(/* Ok */Block.__(0, [12]), m2); - var m3 = map((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })]); - doTest(/* Ok */Block.__(0, ["9"]), m3); - var s0 = sequence(/* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })], - /* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })], - /* [] */0 - ] - ]); - doTest(/* Ok */Block.__(0, [/* :: */[ - 1, - /* :: */[ - 2, - /* [] */0 - ] - ]]), s0); - var s1 = sequence(/* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })], - /* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [2.7])); - })], - /* :: */[ - r(/* () */0), - /* [] */0 - ] - ] - ]); - doTest(/* Error */Block.__(1, [2.7]), s1); - var e0 = onError((function (_msg) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["file not found"])); - })]); - doTest(/* Ok */Block.__(0, [42]), e0); - var e1 = onError((function (_msg) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [42])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["file not found"])); - })]); - doTest(/* Error */Block.__(1, [42]), e1); - var n0 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [42])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]), - /* [] */0 - ] - ]); - doTest(/* Error */Block.__(1, ["42"]), n0); - var n1 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]), - /* [] */0 - ] - ]); - doTest(/* Error */Block.__(1, ["3.14"]), n1); - var n2 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]), - /* [] */0 - ] - ]); - doTest(/* Ok */Block.__(0, [/* :: */[ - 1, - /* :: */[ - 2, - /* [] */0 - ] - ]]), n2); - perform((function (param) { - return 42; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [18])); - })]); - var value = 42; - doTest(/* Ok */Block.__(0, [42]), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]); - var value$1 = "failure"; - doTest(/* Error */Block.__(1, ["failure"]), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value$1])); - })]); - doTest(/* Ok */Block.__(0, [undefined]), toOption(/* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["for some reason"])); - })])); - doTest(/* Ok */Block.__(0, [42]), toOption(/* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })])); - return /* () */0; -} - -exports.nothing = nothing; -exports.performOpt = performOpt; -exports.perform = perform; -exports.attemptOpt = attemptOpt; -exports.attempt = attempt; -exports.ignore = ignore; -exports.succeed = succeed; -exports.fail = fail; -exports.nativeBinding = nativeBinding; -exports.andThen = andThen; -exports.onError = onError; -exports.fromResult = fromResult; -exports.mapError = mapError; -exports.toOption = toOption; -exports.map = map; -exports.map2 = map2; -exports.map3 = map3; -exports.map4 = map4; -exports.map5 = map5; -exports.map6 = map6; -exports.sequence = sequence; -exports.testing_deop = testing_deop; -exports.testing = testing; -/* No side effect */ diff --git a/lib/js/src-ocaml/vdom.js b/lib/js/src-ocaml/vdom.js deleted file mode 100644 index 087e49a..0000000 --- a/lib/js/src-ocaml/vdom.js +++ /dev/null @@ -1,1084 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Caml_obj = require("bs-platform/lib/js/caml_obj.js"); -var Web_node = require("./web_node.js"); -var Caml_array = require("bs-platform/lib/js/caml_array.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Web_document = require("./web_document.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -var noNode = /* CommentNode */Block.__(0, [""]); - -function comment(s) { - return /* CommentNode */Block.__(0, [s]); -} - -function text(s) { - return /* Text */Block.__(1, [s]); -} - -function fullnode(namespace, tagName, key, unique, props, vdoms) { - return /* Node */Block.__(2, [ - namespace, - tagName, - key, - unique, - props, - vdoms - ]); -} - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, vdoms) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return fullnode(namespace, tagName, key, unique, props, vdoms); -} - -function lazyGen(key, fn) { - return /* LazyGen */Block.__(3, [ - key, - fn, - { - contents: noNode - } - ]); -} - -function prop(key, value) { - return /* RawProp */Block.__(0, [ - key, - value - ]); -} - -function onCB(name, key, cb) { - return /* Event */Block.__(3, [ - name, - /* EventHandlerCallback */Block.__(0, [ - key, - cb - ]), - { - contents: undefined - } - ]); -} - -function onMsg(name, msg) { - return /* Event */Block.__(3, [ - name, - /* EventHandlerMsg */Block.__(1, [msg]), - { - contents: undefined - } - ]); -} - -function attribute(namespace, key, value) { - return /* Attribute */Block.__(1, [ - namespace, - key, - value - ]); -} - -function data(key, value) { - return /* Data */Block.__(2, [ - key, - value - ]); -} - -function style(key, value) { - return /* Style */Block.__(4, [/* :: */[ - /* tuple */[ - key, - value - ], - /* [] */0 - ]]); -} - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function renderToHtmlString(_param) { - while(true) { - var param = _param; - switch (param.tag | 0) { - case /* CommentNode */0 : - return ""); - case /* Text */1 : - return param[0]; - case /* Node */2 : - var tagName = param[1]; - var namespace = param[0]; - return $$String.concat("", /* :: */[ - "<", - /* :: */[ - namespace, - /* :: */[ - namespace === "" ? "" : ":", - /* :: */[ - tagName, - /* :: */[ - $$String.concat("", List.map((function (p) { - var param = p; - if (typeof param === "number") { - return ""; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - return $$String.concat("", /* :: */[ - " ", - /* :: */[ - param[0], - /* :: */[ - "=\"", - /* :: */[ - param[1], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Attribute */1 : - return $$String.concat("", /* :: */[ - " ", - /* :: */[ - param[1], - /* :: */[ - "=\"", - /* :: */[ - param[2], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Data */2 : - return $$String.concat("", /* :: */[ - " data-", - /* :: */[ - param[0], - /* :: */[ - "=\"", - /* :: */[ - param[1], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Event */3 : - return ""; - case /* Style */4 : - return $$String.concat("", /* :: */[ - " style=\"", - /* :: */[ - $$String.concat(";", List.map((function (param) { - return $$String.concat("", /* :: */[ - param[0], - /* :: */[ - ":", - /* :: */[ - param[1], - /* :: */[ - ";", - /* [] */0 - ] - ] - ] - ]); - }), param[0])), - /* :: */[ - "\"", - /* [] */0 - ] - ] - ]); - - } - } - }), param[4])), - /* :: */[ - ">", - /* :: */[ - $$String.concat("", List.map(renderToHtmlString, param[5])), - /* :: */[ - "", - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]); - case /* LazyGen */3 : - _param = Curry._1(param[1], /* () */0); - continue ; - case /* Tagger */4 : - _param = param[1]; - continue ; - - } - }; -} - -function emptyEventHandler(_ev) { - return /* () */0; -} - -function emptyEventCB(_ev) { - return ; -} - -function eventHandler(callbacks, cb) { - return (function (ev) { - var match = Curry._1(cb.contents, ev); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - }); -} - -function eventHandler_GetCB(param) { - if (param.tag) { - var msg = param[0]; - return (function (_ev) { - return Caml_option.some(msg); - }); - } else { - return param[1]; - } -} - -function compareEventHandlerTypes(left, param) { - if (param.tag) { - if (left.tag && Caml_obj.caml_equal(param[0], left[0])) { - return true; - } else { - return false; - } - } else if (left.tag) { - return false; - } else { - return param[0] === left[0]; - } -} - -function eventHandler_Register(callbacks, elem, name, handlerType) { - var cb = { - contents: eventHandler_GetCB(handlerType) - }; - var handler = eventHandler(callbacks, cb); - Web_node.addEventListener(elem, name, handler, false); - return { - handler: handler, - cb: cb - }; -} - -function eventHandler_Unregister(elem, name, param) { - if (param !== undefined) { - Web_node.removeEventListener(elem, name, param.handler, false); - return ; - } - -} - -function eventHandler_Mutate(callbacks, elem, oldName, newName, oldHandlerType, newHandlerType, oldCache, newCache) { - var match = oldCache.contents; - if (match !== undefined) { - if (oldName === newName) { - newCache.contents = oldCache.contents; - if (compareEventHandlerTypes(oldHandlerType, newHandlerType)) { - return /* () */0; - } else { - var cb = eventHandler_GetCB(newHandlerType); - match.cb.contents = cb; - return /* () */0; - } - } else { - oldCache.contents = eventHandler_Unregister(elem, oldName, oldCache.contents); - newCache.contents = eventHandler_Register(callbacks, elem, newName, newHandlerType); - return /* () */0; - } - } else { - newCache.contents = eventHandler_Register(callbacks, elem, newName, newHandlerType); - return /* () */0; - } -} - -function patchVNodesOnElems_PropertiesApply_Add(callbacks, elem, _idx, param) { - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - elem[param[0]] = param[1]; - return /* () */0; - case /* Attribute */1 : - return Web_node.setAttributeNsOptional(elem, param[0], param[1], param[2]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Add Data Unhandled", - param[0], - param[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Add Data Unhandled" - ]; - case /* Event */3 : - param[2].contents = eventHandler_Register(callbacks, elem, param[0], param[1]); - return /* () */0; - case /* Style */4 : - return List.fold_left((function (param, param$1) { - return Web_node.setStyleProperty(elem, undefined, param$1[0], param$1[1]); - }), /* () */0, param[0]); - - } - } -} - -function patchVNodesOnElems_PropertiesApply_Remove(_callbacks, elem, _idx, param) { - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - elem[param[0]] = undefined; - return /* () */0; - case /* Attribute */1 : - return Web_node.removeAttributeNsOptional(elem, param[0], param[1]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Remove Data Unhandled", - param[0], - param[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Remove Data Unhandled" - ]; - case /* Event */3 : - var cache = param[2]; - cache.contents = eventHandler_Unregister(elem, param[0], cache.contents); - return /* () */0; - case /* Style */4 : - return List.fold_left((function (param, param$1) { - return Web_node.setStyleProperty(elem, undefined, param$1[0], null); - }), /* () */0, param[0]); - - } - } -} - -function patchVNodesOnElems_PropertiesApply_RemoveAdd(callbacks, elem, idx, oldProp, newProp) { - patchVNodesOnElems_PropertiesApply_Remove(callbacks, elem, idx, oldProp); - patchVNodesOnElems_PropertiesApply_Add(callbacks, elem, idx, newProp); - return /* () */0; -} - -function patchVNodesOnElems_PropertiesApply_Mutate(_callbacks, elem, _idx, oldProp, _newProp) { - if (typeof _newProp === "number") { - throw [ - Caml_builtin_exceptions.failure, - "This should never be called as all entries through NoProp are gated." - ]; - } else { - switch (_newProp.tag | 0) { - case /* RawProp */0 : - elem[_newProp[0]] = _newProp[1]; - return /* () */0; - case /* Attribute */1 : - return Web_node.setAttributeNsOptional(elem, _newProp[0], _newProp[1], _newProp[2]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Mutate Data Unhandled", - _newProp[0], - _newProp[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Mutate Data Unhandled" - ]; - case /* Event */3 : - throw [ - Caml_builtin_exceptions.failure, - "This will never be called because it is gated" - ]; - case /* Style */4 : - if (typeof oldProp === "number") { - throw [ - Caml_builtin_exceptions.failure, - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!" - ]; - } else if (oldProp.tag === /* Style */4) { - return List.fold_left2((function (param, param$1, param$2) { - var nv = param$2[1]; - var nk = param$2[0]; - var ok = param$1[0]; - if (ok === nk) { - if (param$1[1] === nv) { - return /* () */0; - } else { - return Web_node.setStyleProperty(elem, undefined, nk, nv); - } - } else { - Web_node.setStyleProperty(elem, undefined, ok, null); - return Web_node.setStyleProperty(elem, undefined, nk, nv); - } - }), /* () */0, oldProp[0], _newProp[0]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!" - ]; - } - - } - } -} - -function patchVNodesOnElems_PropertiesApply(callbacks, elem, _idx, _oldProperties, _newProperties) { - while(true) { - var newProperties = _newProperties; - var oldProperties = _oldProperties; - var idx = _idx; - if (oldProperties) { - var _oldProp = oldProperties[0]; - if (newProperties) { - if (typeof _oldProp === "number") { - if (typeof newProperties[0] === "number") { - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - - } else { - switch (_oldProp.tag | 0) { - case /* RawProp */0 : - var newProp = newProperties[0]; - if (typeof newProp !== "number" && !newProp.tag) { - if (!(_oldProp[0] === newProp[0] && _oldProp[1] === newProp[1])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Attribute */1 : - var newProp$1 = newProperties[0]; - if (typeof newProp$1 !== "number" && newProp$1.tag === /* Attribute */1) { - if (!(_oldProp[0] === newProp$1[0] && _oldProp[1] === newProp$1[1] && _oldProp[2] === newProp$1[2])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$1); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Data */2 : - var newProp$2 = newProperties[0]; - if (typeof newProp$2 !== "number" && newProp$2.tag === /* Data */2) { - if (!(_oldProp[0] === newProp$2[0] && _oldProp[1] === newProp$2[1])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$2); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Event */3 : - var _newProp = newProperties[0]; - if (typeof _newProp !== "number" && _newProp.tag === /* Event */3) { - eventHandler_Mutate(callbacks, elem, _oldProp[0], _newProp[0], _oldProp[1], _newProp[1], _oldProp[2], _newProp[2]); - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Style */4 : - var newProp$3 = newProperties[0]; - if (typeof newProp$3 !== "number" && newProp$3.tag === /* Style */4) { - if (!Caml_obj.caml_equal(_oldProp[0], newProp$3[0])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$3); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - - } - } - } else { - return false; - } - patchVNodesOnElems_PropertiesApply_RemoveAdd(callbacks, elem, idx, _oldProp, newProperties[0]); - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } else if (newProperties) { - return false; - } else { - return true; - } - }; -} - -function patchVNodesOnElems_Properties(callbacks, elem, oldProperties, newProperties) { - return patchVNodesOnElems_PropertiesApply(callbacks, elem, 0, oldProperties, newProperties); -} - -function genEmptyProps(length) { - var _lst = /* [] */0; - var _len = length; - while(true) { - var len = _len; - var lst = _lst; - if (len !== 0) { - _len = len - 1 | 0; - _lst = /* :: */[ - /* NoProp */0, - lst - ]; - continue ; - } else { - return lst; - } - }; -} - -function mapEmptyProps(props) { - return List.map((function (param) { - return /* NoProp */0; - }), props); -} - -function patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, param) { - if (param.tag === /* Node */2) { - var newProperties = param[4]; - var oldChild = Caml_array.caml_array_get(elems, idx); - var newChild = Web_document.createElementNsOptional(param[0], param[1]); - var match = patchVNodesOnElems_Properties(callbacks, newChild, List.map((function (param) { - return /* NoProp */0; - }), newProperties), newProperties); - if (match) { - var childChildren = newChild.childNodes; - patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, param[5]); - Web_node.insertBefore(elem, newChild, oldChild); - elem.removeChild(oldChild); - return /* () */0; - } else { - throw [ - Caml_builtin_exceptions.match_failure, - /* tuple */[ - "vdom.ml", - 343, - 13 - ] - ]; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Node replacement should never be passed anything but a node itself" - ]; - } -} - -function patchVNodesOnElems_CreateElement(_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - switch (param.tag | 0) { - case /* CommentNode */0 : - var text = param[0]; - return document.createComment(text); - case /* Text */1 : - var text$1 = param[0]; - return document.createTextNode(text$1); - case /* Node */2 : - var newProperties = param[4]; - var newChild = Web_document.createElementNsOptional(param[0], param[1]); - var match = patchVNodesOnElems_Properties(callbacks, newChild, List.map((function (param) { - return /* NoProp */0; - }), newProperties), newProperties); - if (match) { - var childChildren = newChild.childNodes; - patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, param[5]); - return newChild; - } else { - throw [ - Caml_builtin_exceptions.match_failure, - /* tuple */[ - "vdom.ml", - 368, - 11 - ] - ]; - } - case /* LazyGen */3 : - var vdom = Curry._1(param[1], /* () */0); - param[2].contents = vdom; - _param = vdom; - continue ; - case /* Tagger */4 : - _param = param[1]; - _callbacks = Curry._1(param[0], callbacks); - continue ; - - } - }; -} - -function patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode) { - if (oldNode.tag === /* Node */2) { - if (newNode.tag === /* Node */2) { - if (oldNode[3] !== newNode[3] || oldNode[1] !== newNode[1]) { - return patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, newNode); - } else { - var child = Caml_array.caml_array_get(elems, idx); - var childChildren = child.childNodes; - if (!patchVNodesOnElems_Properties(callbacks, child, oldNode[4], newNode[4])) { - console.log("VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved."); - patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, newNode); - } - return patchVNodesOnElems(callbacks, child, childChildren, 0, oldNode[5], newNode[5]); - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Non-node passed to patchVNodesOnElems_MutateNode" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Non-node passed to patchVNodesOnElems_MutateNode" - ]; - } -} - -function patchVNodesOnElems(callbacks, elem, elems, _idx, _oldVNodes, _newVNodes) { - while(true) { - var newVNodes = _newVNodes; - var oldVNodes = _oldVNodes; - var idx = _idx; - if (oldVNodes) { - var oldNode = oldVNodes[0]; - switch (oldNode.tag | 0) { - case /* CommentNode */0 : - if (newVNodes) { - var match = newVNodes[0]; - if (!match.tag && oldNode[0] === match[0]) { - _newVNodes = newVNodes[1]; - _oldVNodes = oldVNodes[1]; - _idx = idx + 1 | 0; - continue ; - } - - } - break; - case /* Text */1 : - if (newVNodes) { - var match$1 = newVNodes[0]; - if (match$1.tag === /* Text */1) { - var newText = match$1[0]; - if (oldNode[0] !== newText) { - var child = Caml_array.caml_array_get(elems, idx); - child.nodeValue = newText; - } - _newVNodes = newVNodes[1]; - _oldVNodes = oldVNodes[1]; - _idx = idx + 1 | 0; - continue ; - } - - } - break; - case /* Node */2 : - if (newVNodes) { - var newNode = newVNodes[0]; - if (newNode.tag === /* Node */2) { - var newRest = newVNodes[1]; - var newKey = newNode[2]; - var newTagName = newNode[1]; - var newNamespace = newNode[0]; - var oldRest = oldVNodes[1]; - var oldKey = oldNode[2]; - var oldTagName = oldNode[1]; - var oldNamespace = oldNode[0]; - if (oldKey === newKey && oldKey !== "") { - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } else if (oldKey === "" || newKey === "") { - patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode); - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } else { - var exit = 0; - var exit$1 = 0; - if (oldRest) { - var match$2 = oldRest[0]; - if (match$2.tag === /* Node */2) { - var olderRest = oldRest[1]; - var olderKey = match$2[2]; - var olderTagName = match$2[1]; - var olderNamespace = match$2[0]; - var exit$2 = 0; - if (newRest) { - var match$3 = newRest[0]; - if (match$3.tag === /* Node */2 && olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey && oldNamespace === match$3[0] && oldTagName === match$3[1] && oldKey === match$3[2]) { - var firstChild = Caml_array.caml_array_get(elems, idx); - var secondChild = Caml_array.caml_array_get(elems, idx + 1 | 0); - elem.removeChild(secondChild); - Web_node.insertBefore(elem, secondChild, firstChild); - _newVNodes = newRest[1]; - _oldVNodes = olderRest; - _idx = idx + 2 | 0; - continue ; - } else { - exit$2 = 4; - } - } else { - exit$2 = 4; - } - if (exit$2 === 4) { - if (olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey) { - var oldChild = Caml_array.caml_array_get(elems, idx); - elem.removeChild(oldChild); - _newVNodes = newRest; - _oldVNodes = olderRest; - _idx = idx + 1 | 0; - continue ; - } else { - exit$1 = 3; - } - } - - } else { - exit$1 = 3; - } - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - if (newRest) { - var match$4 = newRest[0]; - if (match$4.tag === /* Node */2 && oldNamespace === match$4[0] && oldTagName === match$4[1] && oldKey === match$4[2]) { - var oldChild$1 = Caml_array.caml_array_get(elems, idx); - var newChild = patchVNodesOnElems_CreateElement(callbacks, newNode); - Web_node.insertBefore(elem, newChild, oldChild$1); - _newVNodes = newRest; - _idx = idx + 1 | 0; - continue ; - } else { - exit = 2; - } - } else { - exit = 2; - } - } - if (exit === 2) { - patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode); - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } - - } - } - - } - break; - case /* LazyGen */3 : - if (newVNodes) { - var match$5 = newVNodes[0]; - if (match$5.tag === /* LazyGen */3) { - var newRest$1 = newVNodes[1]; - var newCache = match$5[2]; - var newGen = match$5[1]; - var newKey$1 = match$5[0]; - var oldRest$1 = oldVNodes[1]; - var oldCache = oldNode[2]; - var oldKey$1 = oldNode[0]; - if (oldKey$1 === newKey$1) { - newCache.contents = oldCache.contents; - _newVNodes = newRest$1; - _oldVNodes = oldRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - var exit$3 = 0; - var exit$4 = 0; - if (oldRest$1) { - var match$6 = oldRest$1[0]; - if (match$6.tag === /* LazyGen */3) { - var olderRest$1 = oldRest$1[1]; - var olderKey$1 = match$6[0]; - var exit$5 = 0; - if (newRest$1) { - var match$7 = newRest$1[0]; - if (match$7.tag === /* LazyGen */3 && olderKey$1 === newKey$1 && oldKey$1 === match$7[0]) { - var firstChild$1 = Caml_array.caml_array_get(elems, idx); - var secondChild$1 = Caml_array.caml_array_get(elems, idx + 1 | 0); - elem.removeChild(secondChild$1); - Web_node.insertBefore(elem, secondChild$1, firstChild$1); - _newVNodes = newRest$1[1]; - _oldVNodes = olderRest$1; - _idx = idx + 2 | 0; - continue ; - } else { - exit$5 = 4; - } - } else { - exit$5 = 4; - } - if (exit$5 === 4) { - if (olderKey$1 === newKey$1) { - var oldChild$2 = Caml_array.caml_array_get(elems, idx); - elem.removeChild(oldChild$2); - var oldVdom = match$6[2].contents; - newCache.contents = oldVdom; - _newVNodes = newRest$1; - _oldVNodes = olderRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - exit$4 = 3; - } - } - - } else { - exit$4 = 3; - } - } else { - exit$4 = 3; - } - if (exit$4 === 3) { - if (newRest$1) { - var match$8 = newRest$1[0]; - if (match$8.tag === /* LazyGen */3 && match$8[0] === oldKey$1) { - var oldChild$3 = Caml_array.caml_array_get(elems, idx); - var newVdom = Curry._1(newGen, /* () */0); - newCache.contents = newVdom; - var newChild$1 = patchVNodesOnElems_CreateElement(callbacks, newVdom); - Web_node.insertBefore(elem, newChild$1, oldChild$3); - _newVNodes = newRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - exit$3 = 2; - } - } else { - exit$3 = 2; - } - } - if (exit$3 === 2) { - var oldVdom$1 = oldCache.contents; - var newVdom$1 = Curry._1(newGen, /* () */0); - newCache.contents = newVdom$1; - _newVNodes = /* :: */[ - newVdom$1, - newRest$1 - ]; - _oldVNodes = /* :: */[ - oldVdom$1, - oldRest$1 - ]; - continue ; - } - - } - } - - } - break; - case /* Tagger */4 : - _oldVNodes = /* :: */[ - oldNode[1], - oldVNodes[1] - ]; - continue ; - - } - var oldRest$2 = oldVNodes[1]; - if (newVNodes) { - var newNode$1 = newVNodes[0]; - if (newNode$1.tag === /* Tagger */4) { - patchVNodesOnElems(Curry._1(newNode$1[0], callbacks), elem, elems, idx, /* :: */[ - oldNode, - /* [] */0 - ], /* :: */[ - newNode$1[1], - /* [] */0 - ]); - _newVNodes = newVNodes[1]; - _oldVNodes = oldRest$2; - _idx = idx + 1 | 0; - continue ; - } else { - var oldChild$4 = Caml_array.caml_array_get(elems, idx); - var newChild$2 = patchVNodesOnElems_CreateElement(callbacks, newNode$1); - Web_node.insertBefore(elem, newChild$2, oldChild$4); - elem.removeChild(oldChild$4); - _newVNodes = newVNodes[1]; - _oldVNodes = oldRest$2; - _idx = idx + 1 | 0; - continue ; - } - } else { - var child$1 = Caml_array.caml_array_get(elems, idx); - elem.removeChild(child$1); - _newVNodes = /* [] */0; - _oldVNodes = oldRest$2; - continue ; - } - } else if (newVNodes) { - var newChild$3 = patchVNodesOnElems_CreateElement(callbacks, newVNodes[0]); - elem.appendChild(newChild$3); - _newVNodes = newVNodes[1]; - _oldVNodes = /* [] */0; - _idx = idx + 1 | 0; - continue ; - } else { - return /* () */0; - } - }; -} - -function patchVNodesIntoElement(callbacks, elem, oldVNodes, newVNodes) { - var elems = elem.childNodes; - patchVNodesOnElems(callbacks, elem, elems, 0, oldVNodes, newVNodes); - return newVNodes; -} - -function patchVNodeIntoElement(callbacks, elem, oldVNode, newVNode) { - return patchVNodesIntoElement(callbacks, elem, /* :: */[ - oldVNode, - /* [] */0 - ], /* :: */[ - newVNode, - /* [] */0 - ]); -} - -function wrapCallbacks_On(func, param) { - if (typeof param === "number") { - return /* Render */0; - } else if (param.tag) { - return /* RemoveRenderMsg */Block.__(1, [Curry._1(func, param[0])]); - } else { - return /* AddRenderMsg */Block.__(0, [Curry._1(func, param[0])]); - } -} - -function wrapCallbacks(func, callbacks) { - return { - contents: { - enqueue: (function (msg) { - return Curry._1(callbacks.contents.enqueue, Curry._1(func, msg)); - }), - on: (function (smsg) { - return Curry._1(callbacks.contents.on, wrapCallbacks_On(func, smsg)); - }) - } - }; -} - -function map(func, vdom) { - var tagger = function (param) { - return wrapCallbacks(func, param); - }; - return /* Tagger */Block.__(4, [ - tagger, - vdom - ]); -} - -var noProp = /* NoProp */0; - -exports.noNode = noNode; -exports.comment = comment; -exports.text = text; -exports.fullnode = fullnode; -exports.node = node; -exports.lazyGen = lazyGen; -exports.noProp = noProp; -exports.prop = prop; -exports.onCB = onCB; -exports.onMsg = onMsg; -exports.attribute = attribute; -exports.data = data; -exports.style = style; -exports.styles = styles; -exports.renderToHtmlString = renderToHtmlString; -exports.emptyEventHandler = emptyEventHandler; -exports.emptyEventCB = emptyEventCB; -exports.eventHandler = eventHandler; -exports.eventHandler_GetCB = eventHandler_GetCB; -exports.compareEventHandlerTypes = compareEventHandlerTypes; -exports.eventHandler_Register = eventHandler_Register; -exports.eventHandler_Unregister = eventHandler_Unregister; -exports.eventHandler_Mutate = eventHandler_Mutate; -exports.patchVNodesOnElems_PropertiesApply_Add = patchVNodesOnElems_PropertiesApply_Add; -exports.patchVNodesOnElems_PropertiesApply_Remove = patchVNodesOnElems_PropertiesApply_Remove; -exports.patchVNodesOnElems_PropertiesApply_RemoveAdd = patchVNodesOnElems_PropertiesApply_RemoveAdd; -exports.patchVNodesOnElems_PropertiesApply_Mutate = patchVNodesOnElems_PropertiesApply_Mutate; -exports.patchVNodesOnElems_PropertiesApply = patchVNodesOnElems_PropertiesApply; -exports.patchVNodesOnElems_Properties = patchVNodesOnElems_Properties; -exports.genEmptyProps = genEmptyProps; -exports.mapEmptyProps = mapEmptyProps; -exports.patchVNodesOnElems_ReplaceNode = patchVNodesOnElems_ReplaceNode; -exports.patchVNodesOnElems_CreateElement = patchVNodesOnElems_CreateElement; -exports.patchVNodesOnElems_MutateNode = patchVNodesOnElems_MutateNode; -exports.patchVNodesOnElems = patchVNodesOnElems; -exports.patchVNodesIntoElement = patchVNodesIntoElement; -exports.patchVNodeIntoElement = patchVNodeIntoElement; -exports.wrapCallbacks_On = wrapCallbacks_On; -exports.wrapCallbacks = wrapCallbacks; -exports.map = map; -/* No side effect */ diff --git a/lib/js/src-ocaml/web_window_history.js b/lib/js/src-ocaml/web_window_history.js deleted file mode 100644 index 9ca66a6..0000000 --- a/lib/js/src-ocaml/web_window_history.js +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function length($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.length; - } else { - return -1; - } -} - -function back($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.back; - } else { - return /* () */0; - } -} - -function forward($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.forward; - } else { - return /* () */0; - } -} - -function go($$window, to$prime) { - var match = $$window.history; - if (match !== undefined) { - return match.go(to$prime); - } else { - return /* () */0; - } -} - -function pushState($$window, state, title, url) { - var match = $$window.history; - if (match !== undefined) { - return match.pushState(state, title, url); - } else { - return /* () */0; - } -} - -function replaceState($$window, state, title, url) { - var match = $$window.history; - if (match !== undefined) { - return match.replaceState(state, title, url); - } else { - return /* () */0; - } -} - -function state($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.state; - } - -} - -exports.length = length; -exports.back = back; -exports.forward = forward; -exports.go = go; -exports.pushState = pushState; -exports.replaceState = replaceState; -exports.state = state; -/* No side effect */ diff --git a/lib/js/src-ocaml/web_window_localstorage.js b/lib/js/src-ocaml/web_window_localstorage.js deleted file mode 100644 index c2f3af1..0000000 --- a/lib/js/src-ocaml/web_window_localstorage.js +++ /dev/null @@ -1,65 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function length($$window) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.length); - } - -} - -function clear($$window) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.clear()); - } - -} - -function key($$window, idx) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.key(idx)); - } - -} - -function getItem($$window, key) { - var match = $$window.localStorage; - if (match !== undefined) { - try { - return Caml_option.some(match.getItem(key)); - } - catch (exn){ - return ; - } - } - -} - -function removeItem($$window, key) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.removeItem(key)); - } - -} - -function setItem($$window, key, value) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.setItem(key, value)); - } - -} - -exports.length = length; -exports.clear = clear; -exports.key = key; -exports.getItem = getItem; -exports.removeItem = removeItem; -exports.setItem = setItem; -/* No side effect */ diff --git a/lib/js/src-ocaml/web_xmlhttprequest.js b/lib/js/src-ocaml/web_xmlhttprequest.js deleted file mode 100644 index 00eebe4..0000000 --- a/lib/js/src-ocaml/web_xmlhttprequest.js +++ /dev/null @@ -1,924 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var $$Array = require("bs-platform/lib/js/array.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Web_formdata = require("./web_formdata.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function abort(x) { - return x.abort(); -} - -function getAllResponseHeaders(x) { - var match = x.getAllResponseHeaders(); - if (match !== null) { - if (match === "") { - return /* Error */Block.__(1, [/* NetworkError */1]); - } else { - return /* Ok */Block.__(0, [match]); - } - } else { - return /* Error */Block.__(1, [/* IncompleteResponse */0]); - } -} - -function getAllResponseHeadersAsList(x) { - var err = getAllResponseHeaders(x); - if (err.tag) { - return err; - } else { - return /* Ok */Block.__(0, [List.map((function (param) { - if (param.length !== 2) { - throw [ - Caml_builtin_exceptions.failure, - "Cannot happen, already checked length" - ]; - } - var key = param[0]; - var value = param[1]; - return /* tuple */[ - key, - value - ]; - }), List.filter((function (a) { - return a.length === 2; - }))($$Array.to_list($$Array.map((function (param) { - return param.split(": ", 2); - }), err[0].split("\r\n")))))]); - } -} - -function getAllResponseHeadersAsDict(x) { - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var err = getAllResponseHeadersAsList(x); - if (err.tag) { - return err; - } else { - var insert = function (d, param) { - return add(param[0], param[1], d); - }; - return /* Ok */Block.__(0, [List.fold_left(insert, /* Empty */0, err[0])]); - } -} - -function getResponseHeader(key, x) { - return Caml_option.null_to_opt(x.getResponse(key)); -} - -function open_(method$prime, url, $staropt$star, $staropt$star$1, $staropt$star$2, x) { - var async = $staropt$star !== undefined ? $staropt$star : true; - var user = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var password = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return x.open(method$prime, url, async, user, password); -} - -function overrideMimeType(mimetype, x) { - return x.overrideMimeType(mimetype); -} - -function send(body, x) { - if (typeof body === "number") { - if (body === /* EmptyBody */0) { - return x.send(); - } else { - return x.send(null); - } - } else { - switch (body.tag | 0) { - case /* FormListBody */2 : - var form = List.fold_left((function (f, param) { - Web_formdata.append(param[0], param[1], f); - return f; - }), new FormData(), body[0]); - return x.send(form); - case /* StringBody */0 : - case /* FormDataBody */1 : - case /* DocumentBody */3 : - return x.send(body[0]); - - } - } -} - -function setRequestHeader(header, value, x) { - return x.setRequestHeader(header, value); -} - -function set_onreadystatechange(cb, x) { - x.onreadystatechange = cb; - return /* () */0; -} - -function get_onreadystatechange(x) { - return x.onreadystatechange; -} - -function readyState(x) { - var i = x.readyState; - if (i > 4 || i < 0) { - var s = "Invalid return from 'readystate' of: " + String(i); - throw [ - Caml_builtin_exceptions.failure, - s - ]; - } else { - return i; - } -} - -function set_responseType(typ, x) { - if (typeof typ === "number") { - switch (typ) { - case /* StringResponseType */0 : - x.responseType = ""; - return /* () */0; - case /* ArrayBufferResponseType */1 : - x.responseType = "arraybuffer"; - return /* () */0; - case /* BlobResponseType */2 : - x.responseType = "blob"; - return /* () */0; - case /* DocumentResponseType */3 : - x.responseType = "document"; - return /* () */0; - case /* JsonResponseType */4 : - x.responseType = "json"; - return /* () */0; - case /* TextResponseType */5 : - x.responseType = "text"; - return /* () */0; - - } - } else { - x.responseType = typ[0]; - return /* () */0; - } -} - -function get_responseType(x) { - var s = x.responseType; - switch (s) { - case "" : - return /* StringResponseType */0; - case "arraybuffer" : - return /* ArrayBufferResponseType */1; - case "blob" : - return /* BlobResponseType */2; - case "document" : - return /* DocumentResponseType */3; - case "json" : - return /* JsonResponseType */4; - case "text" : - return /* TextResponseType */5; - default: - return /* RawResponseType */[s]; - } -} - -function get_response(x) { - var match = x.response; - if (match !== null) { - var match$1 = get_responseType(x); - if (typeof match$1 === "number") { - switch (match$1) { - case /* StringResponseType */0 : - return /* StringResponse */Block.__(0, [match]); - case /* ArrayBufferResponseType */1 : - return /* ArrayBufferResponse */Block.__(1, [match]); - case /* BlobResponseType */2 : - return /* BlobResponse */Block.__(2, [match]); - case /* DocumentResponseType */3 : - return /* DocumentResponse */Block.__(3, [match]); - case /* JsonResponseType */4 : - return /* JsonResponse */Block.__(4, [match]); - case /* TextResponseType */5 : - return /* TextResponse */Block.__(5, [match]); - - } - } else { - return /* RawResponse */Block.__(6, [ - match$1[0], - match - ]); - } - } else { - return /* NoResponse */0; - } -} - -function get_responseText(x) { - return x.responseText; -} - -function get_responseURL(x) { - return x.responseURL; -} - -function get_responseXML(x) { - return Caml_option.null_to_opt(x.responseXML); -} - -function get_status(x) { - return x.status; -} - -function get_statusText(x) { - return x.statusText; -} - -function set_timeout(t, x) { - x.timeout = t; - return /* () */0; -} - -function get_timeout(x) { - return x.timeout; -} - -function set_withCredentials(b, x) { - x.withCredentials = b; - return /* () */0; -} - -function get_withCredentials(x) { - return x.withCredentials; -} - -function set_onabort(cb, x) { - x.onabort = cb; - return /* () */0; -} - -function get_onabort(x) { - return x.onabort; -} - -function set_onerror(cb, x) { - x.onerror = cb; - return /* () */0; -} - -function get_onerror(x) { - return x.onerror; -} - -function set_onload(cb, x) { - x.onload = cb; - return /* () */0; -} - -function get_onload(x) { - return x.onload; -} - -function set_onloadstart(cb, x) { - x.onloadstart = cb; - return /* () */0; -} - -function get_onloadstart(x) { - return x.onloadstart; -} - -function set_onprogress(cb, x) { - x.onprogress = cb; - return /* () */0; -} - -function get_onprogress(x) { - return x.onprogress; -} - -function set_ontimeout(cb, x) { - x.ontimeout = cb; - return /* () */0; -} - -function get_ontimeout(x) { - return x.ontimeout; -} - -function set_onloadend(cb, x) { - x.onloadend = cb; - return /* () */0; -} - -function get_onloadend(x) { - return x.onloadend; -} - -exports.abort = abort; -exports.getAllResponseHeaders = getAllResponseHeaders; -exports.getAllResponseHeadersAsList = getAllResponseHeadersAsList; -exports.getAllResponseHeadersAsDict = getAllResponseHeadersAsDict; -exports.getResponseHeader = getResponseHeader; -exports.open_ = open_; -exports.overrideMimeType = overrideMimeType; -exports.send = send; -exports.setRequestHeader = setRequestHeader; -exports.set_onreadystatechange = set_onreadystatechange; -exports.get_onreadystatechange = get_onreadystatechange; -exports.readyState = readyState; -exports.set_responseType = set_responseType; -exports.get_responseType = get_responseType; -exports.get_response = get_response; -exports.get_responseText = get_responseText; -exports.get_responseURL = get_responseURL; -exports.get_responseXML = get_responseXML; -exports.get_status = get_status; -exports.get_statusText = get_statusText; -exports.set_timeout = set_timeout; -exports.get_timeout = get_timeout; -exports.set_withCredentials = set_withCredentials; -exports.get_withCredentials = get_withCredentials; -exports.set_onabort = set_onabort; -exports.get_onabort = get_onabort; -exports.set_onerror = set_onerror; -exports.get_onerror = get_onerror; -exports.set_onload = set_onload; -exports.get_onload = get_onload; -exports.set_onloadstart = set_onloadstart; -exports.get_onloadstart = get_onloadstart; -exports.set_onprogress = set_onprogress; -exports.get_onprogress = get_onprogress; -exports.set_ontimeout = set_ontimeout; -exports.get_ontimeout = get_ontimeout; -exports.set_onloadend = set_onloadend; -exports.get_onloadend = get_onloadend; -/* No side effect */ diff --git a/lib/js/src/rescript_json_combinators_extended.js b/lib/js/src/rescript_json_combinators_extended.js new file mode 100644 index 0000000..5a1b12b --- /dev/null +++ b/lib/js/src/rescript_json_combinators_extended.js @@ -0,0 +1,51 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Json$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json.js"); +var Json_Decode$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json_Decode.js"); + +function at(key_path, decoder) { + if (key_path) { + var rest = key_path.tl; + var key = key_path.hd; + if (rest) { + return Json_Decode$JsonCombinators.field(key, at(rest, decoder)); + } else { + return Json_Decode$JsonCombinators.field(key, decoder); + } + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Expected key_path to contain at least one element", + Error: new Error() + }; +} + +function decodeString(decoder, string) { + try { + var value = JSON.parse(string); + return Json_Decode$JsonCombinators.decode(value, decoder); + } + catch (exn){ + return { + TAG: /* Error */1, + _0: "Invalid JSON string" + }; + } +} + +function succeed(v) { + return Json_Decode$JsonCombinators.custom(function (_value) { + return v; + }); +} + +function decodeEvent(decoder, value) { + return Json$JsonCombinators.decode(value, decoder); +} + +exports.at = at; +exports.decodeString = decodeString; +exports.succeed = succeed; +exports.decodeEvent = decodeEvent; +/* No side effect */ diff --git a/lib/js/src/tea.js b/lib/js/src/tea.js new file mode 100644 index 0000000..6e4d0cf --- /dev/null +++ b/lib/js/src/tea.js @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + + +var Cmd; + +var Sub; + +var App; + +var Debug; + +var Html; + +var Svg; + +var Task; + +var Program; + +var Time; + +var Navigation; + +var Random; + +var AnimationFrame; + +var Mouse; + +var Http; + +var Ex; + +exports.Cmd = Cmd; +exports.Sub = Sub; +exports.App = App; +exports.Debug = Debug; +exports.Html = Html; +exports.Svg = Svg; +exports.Task = Task; +exports.Program = Program; +exports.Time = Time; +exports.Navigation = Navigation; +exports.Random = Random; +exports.AnimationFrame = AnimationFrame; +exports.Mouse = Mouse; +exports.Http = Http; +exports.Ex = Ex; +/* No side effect */ diff --git a/lib/js/src/tea_animationframe.js b/lib/js/src/tea_animationframe.js new file mode 100644 index 0000000..c041924 --- /dev/null +++ b/lib/js/src/tea_animationframe.js @@ -0,0 +1,68 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Tea_sub = require("./tea_sub.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function every(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + var enableCall = function (callbacks) { + var lastTime = { + contents: Date.now() + }; + var id = { + contents: undefined + }; + var onFrame = function (_time) { + var time = Date.now(); + var _i = id.contents; + if (_i === undefined) { + return ; + } + var ret_delta = time < lastTime.contents ? 0.0 : time - lastTime.contents; + var ret = { + time: time, + delta: ret_delta + }; + lastTime.contents = time; + Curry._1(callbacks.enqueue, Curry._1(tagger, ret)); + var _stillActive = id.contents; + if (_stillActive !== undefined) { + id.contents = Caml_option.some(requestAnimationFrame(onFrame)); + return ; + } + + }; + id.contents = Caml_option.some(requestAnimationFrame(onFrame)); + return function (param) { + var i = id.contents; + if (i !== undefined) { + cancelAnimationFrame(Caml_option.valFromOption(i)); + id.contents = undefined; + return ; + } + + }; + }; + return Tea_sub.registration(key, enableCall); +} + +function times(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return every(undefined, (function (ev) { + return Curry._2(tagger, key, ev.time); + })); +} + +function diffs(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return every(undefined, (function (ev) { + return Curry._2(tagger, key, ev.delta); + })); +} + +exports.every = every; +exports.times = times; +exports.diffs = diffs; +/* No side effect */ diff --git a/lib/js/src/tea_app.js b/lib/js/src/tea_app.js new file mode 100644 index 0000000..08edda3 --- /dev/null +++ b/lib/js/src/tea_app.js @@ -0,0 +1,288 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Web = require("./web.js"); +var List = require("rescript/lib/js/list.js"); +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); +var Tea_cmd = require("./tea_cmd.js"); +var Tea_sub = require("./tea_sub.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function programStateWrapper(initModel, pump, shutdown) { + var model = { + contents: initModel + }; + var callbacks = { + contents: { + enqueue: (function (_msg) { + console.log("INVALID enqueue CALL!"); + + }), + on: (function (param) { + + }) + } + }; + var pumperInterface = Curry._1(pump, callbacks); + var pending = { + contents: undefined + }; + var handler = function (msg) { + var msgs = pending.contents; + if (msgs !== undefined) { + pending.contents = { + hd: msg, + tl: msgs + }; + return ; + } + pending.contents = /* [] */0; + var newModel = Curry._2(pumperInterface.handleMsg, model.contents, msg); + model.contents = newModel; + var msgs$1 = pending.contents; + if (msgs$1 !== undefined) { + if (msgs$1) { + pending.contents = undefined; + return List.iter(handler, List.rev(msgs$1)); + } else { + pending.contents = undefined; + return ; + } + } + throw { + RE_EXN_ID: "Failure", + _1: "INVALID message queue state, should never be None during message processing!", + Error: new Error() + }; + }; + var renderEvents = { + contents: /* [] */0 + }; + var finalizedCBs_enqueue = handler; + var finalizedCBs_on = function (x) { + if (typeof x === "number") { + return List.iter(handler, renderEvents.contents); + } + if (x.TAG === /* AddRenderMsg */0) { + renderEvents.contents = List.append(renderEvents.contents, { + hd: x._0, + tl: /* [] */0 + }); + return ; + } + var msg = x._0; + renderEvents.contents = List.filter(function (mg) { + return msg !== mg; + })(renderEvents.contents); + + }; + var finalizedCBs = { + enqueue: finalizedCBs_enqueue, + on: finalizedCBs_on + }; + callbacks.contents = finalizedCBs; + var piRequestShutdown = function (param) { + callbacks.contents = { + enqueue: (function (_msg) { + console.log("INVALID message enqueued when shut down"); + + }), + on: (function (param) { + + }) + }; + var cmd = Curry._1(shutdown, model.contents); + Curry._1(pumperInterface.shutdown, cmd); + + }; + var renderString = function (param) { + return Curry._1(pumperInterface.renderString, model.contents); + }; + Curry._1(pumperInterface.startup, undefined); + return { + pushMsg: handler, + shutdown: piRequestShutdown, + getHtmlString: renderString + }; +} + +function programLoop(update, view, subscriptions, initModel, initCmd, x) { + if (x === undefined) { + return function (callbacks) { + var oldSub = { + contents: /* NoSub */0 + }; + var handleSubscriptionChange = function (model) { + var newSub = Curry._1(subscriptions, model); + oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); + + }; + return { + startup: (function (param) { + Tea_cmd.run(callbacks, initCmd); + handleSubscriptionChange(initModel); + + }), + renderString: (function (model) { + return Vdom.renderToHtmlString(Curry._1(view, model)); + }), + handleMsg: (function (model, msg) { + var match = Curry._2(update, model, msg); + var newModel = match[0]; + Tea_cmd.run(callbacks, match[1]); + handleSubscriptionChange(newModel); + return newModel; + }), + shutdown: (function (cmd) { + Tea_cmd.run(callbacks, cmd); + oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); + + }) + }; + }; + } + var parentNode = Caml_option.valFromOption(x); + return function (callbacks) { + var priorRenderedVdom = { + contents: /* [] */0 + }; + var latestModel = { + contents: initModel + }; + var nextFrameID = { + contents: undefined + }; + var doRender = function (_delta) { + var _id = nextFrameID.contents; + if (_id === undefined) { + return ; + } + var newVdom_0 = Curry._1(view, latestModel.contents); + var newVdom = { + hd: newVdom_0, + tl: /* [] */0 + }; + var justRenderedVdom = Vdom.patchVNodesIntoElement(callbacks, parentNode, priorRenderedVdom.contents, newVdom); + priorRenderedVdom.contents = justRenderedVdom; + Curry._1(callbacks.contents.on, /* Render */0); + nextFrameID.contents = undefined; + + }; + var scheduleRender = function (param) { + var match = nextFrameID.contents; + if (match !== undefined) { + return ; + } + var id = window.requestAnimationFrame(doRender); + nextFrameID.contents = id; + + }; + var clearPnode = function (param) { + while(parentNode.childNodes.length > 0) { + var firstChild = parentNode.firstChild; + if (firstChild !== null) { + parentNode.removeChild(firstChild); + } + + }; + + }; + var oldSub = { + contents: /* NoSub */0 + }; + var handleSubscriptionChange = function (model) { + var newSub = Curry._1(subscriptions, model); + oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); + + }; + var handlerStartup = function (param) { + clearPnode(undefined); + Tea_cmd.run(callbacks, initCmd); + handleSubscriptionChange(latestModel.contents); + nextFrameID.contents = -1; + doRender(16); + + }; + var renderString = function (model) { + return Vdom.renderToHtmlString(Curry._1(view, model)); + }; + var handler = function (model, msg) { + var match = Curry._2(update, model, msg); + var newModel = match[0]; + latestModel.contents = newModel; + Tea_cmd.run(callbacks, match[1]); + scheduleRender(undefined); + handleSubscriptionChange(newModel); + return newModel; + }; + var handlerShutdown = function (cmd) { + nextFrameID.contents = undefined; + Tea_cmd.run(callbacks, cmd); + oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); + priorRenderedVdom.contents = /* [] */0; + clearPnode(undefined); + + }; + return { + startup: handlerStartup, + renderString: renderString, + handleMsg: handler, + shutdown: handlerShutdown + }; + }; +} + +function program(param, pnode, flags) { + Web.polyfills(undefined); + var match = Curry._1(param.init, flags); + var initModel = match[0]; + var opnode = (pnode == null) ? undefined : Caml_option.some(pnode); + var pumpInterface = programLoop(param.update, param.view, param.subscriptions, initModel, match[1], opnode); + return programStateWrapper(initModel, pumpInterface, param.shutdown); +} + +function standardProgram(param, pnode, args) { + return program({ + init: param.init, + update: param.update, + view: param.view, + subscriptions: param.subscriptions, + shutdown: (function (_model) { + return /* NoCmd */0; + }) + }, pnode, args); +} + +function beginnerProgram(param, pnode, param$1) { + var update = param.update; + var model = param.model; + return standardProgram({ + init: (function (param) { + return [ + model, + /* NoCmd */0 + ]; + }), + update: (function (model, msg) { + return [ + Curry._2(update, model, msg), + /* NoCmd */0 + ]; + }), + view: param.view, + subscriptions: (function (_model) { + return /* NoSub */0; + }) + }, pnode, undefined); +} + +var map = Vdom.map; + +exports.programStateWrapper = programStateWrapper; +exports.programLoop = programLoop; +exports.program = program; +exports.standardProgram = standardProgram; +exports.beginnerProgram = beginnerProgram; +exports.map = map; +/* No side effect */ diff --git a/lib/js/src/tea_cmd.js b/lib/js/src/tea_cmd.js new file mode 100644 index 0000000..0a0c380 --- /dev/null +++ b/lib/js/src/tea_cmd.js @@ -0,0 +1,86 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); + +function batch(cmds) { + return { + TAG: /* Batch */1, + _0: cmds + }; +} + +function call(call$1) { + return { + TAG: /* EnqueueCall */2, + _0: call$1 + }; +} + +function fnMsg(fnMsg$1) { + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + return Curry._1(callbacks.contents.enqueue, Curry._1(fnMsg$1, undefined)); + }) + }; +} + +function msg(msg$1) { + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + return Curry._1(callbacks.contents.enqueue, msg$1); + }) + }; +} + +function run(_callbacks, _x) { + while(true) { + var x = _x; + var callbacks = _callbacks; + if (typeof x === "number") { + return ; + } + switch (x.TAG | 0) { + case /* Mapper */0 : + var subCallbacks = Curry._1(x._0, callbacks); + _x = x._1; + _callbacks = subCallbacks; + continue ; + case /* Batch */1 : + return List.fold_left((function(callbacks){ + return function (param, cmd) { + return run(callbacks, cmd); + } + }(callbacks)), undefined, x._0); + case /* EnqueueCall */2 : + return Curry._1(x._0, callbacks); + + } + }; +} + +function map(func, cmd) { + var mapper = function (param) { + return Vdom.wrapCallbacks(func, param); + }; + return { + TAG: /* Mapper */0, + _0: mapper, + _1: cmd + }; +} + +var none = /* NoCmd */0; + +exports.none = none; +exports.batch = batch; +exports.call = call; +exports.fnMsg = fnMsg; +exports.msg = msg; +exports.run = run; +exports.map = map; +/* No side effect */ diff --git a/lib/js/src/tea_debug.js b/lib/js/src/tea_debug.js new file mode 100644 index 0000000..4206313 --- /dev/null +++ b/lib/js/src/tea_debug.js @@ -0,0 +1,1003 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); +var $$String = require("rescript/lib/js/string.js"); +var Tea_app = require("./tea_app.js"); +var Tea_cmd = require("./tea_cmd.js"); +var Tea_sub = require("./tea_sub.js"); +var Tea_html = require("./tea_html.js"); +var Tea_navigation = require("./tea_navigation.js"); + +function clientMsg(msg) { + return { + TAG: /* ClientMsg */0, + _0: msg + }; +} + +function debug(string_of_msg, update, view, subscriptions, shutdown) { + var initDebug = function (param) { + return [ + { + history: { + hd: [ + "_init_", + param[0] + ], + tl: /* [] */0 + }, + state: /* Running */0, + show_details: false + }, + Tea_cmd.map(clientMsg, param[1]) + ]; + }; + var update$p = function (model, x) { + if (typeof x === "number") { + if (x !== /* TogglePaused */0) { + return [ + { + history: model.history, + state: model.state, + show_details: !model.show_details + }, + /* NoCmd */0 + ]; + } + var match = model.state; + if (match) { + return [ + { + history: model.history, + state: /* Running */0, + show_details: model.show_details + }, + /* NoCmd */0 + ]; + } else { + return [ + { + history: model.history, + state: /* Paused */{ + _0: 0 + }, + show_details: model.show_details + }, + /* NoCmd */0 + ]; + } + } else { + if (x.TAG !== /* ClientMsg */0) { + return [ + { + history: model.history, + state: /* Paused */{ + _0: x._0 + }, + show_details: model.show_details + }, + /* NoCmd */0 + ]; + } + if (model.state !== /* Running */0) { + return [ + model, + /* NoCmd */0 + ]; + } + var msg = x._0; + var match$1 = List.hd(model.history); + var match$2 = Curry._2(update, match$1[1], msg); + var dmodel$p_history = { + hd: [ + Curry._1(string_of_msg, msg), + match$2[0] + ], + tl: model.history + }; + var dmodel$p_state = model.state; + var dmodel$p_show_details = model.show_details; + var dmodel$p = { + history: dmodel$p_history, + state: dmodel$p_state, + show_details: dmodel$p_show_details + }; + return [ + dmodel$p, + Tea_cmd.map(clientMsg, match$2[1]) + ]; + } + }; + var viewStyles = function (param) { + var rule = function (selector, properties) { + var x = $$String.concat(";", List.map((function (param) { + return param[0] + (":" + param[1]); + }), properties)); + return { + TAG: /* Text */1, + _0: "" + selector + " {" + x + "}" + }; + }; + return Tea_html.node(undefined, "style", undefined, undefined, /* [] */0, { + hd: rule("#debug.paused", { + hd: [ + "position", + "fixed" + ], + tl: { + hd: [ + "top", + "0" + ], + tl: { + hd: [ + "left", + "0" + ], + tl: { + hd: [ + "width", + "100%" + ], + tl: { + hd: [ + "height", + "100%" + ], + tl: { + hd: [ + "pointer-events", + "all" + ], + tl: { + hd: [ + "background-color", + "rgba(0,0,0,.1)" + ], + tl: { + hd: [ + "box-shadow", + "inset 0 0 10px #333" + ], + tl: /* [] */0 + } + } + } + } + } + } + } + }), + tl: { + hd: rule("#debug nav", { + hd: [ + "position", + "fixed" + ], + tl: { + hd: [ + "max-width", + "50%" + ], + tl: { + hd: [ + "bottom", + "0" + ], + tl: { + hd: [ + "right", + "6px" + ], + tl: { + hd: [ + "border-radius", + "4px 4px 0 0" + ], + tl: { + hd: [ + "background-color", + "#444" + ], + tl: { + hd: [ + "color", + "#fff" + ], + tl: { + hd: [ + "font-family", + "monospace" + ], + tl: { + hd: [ + "box-shadow", + "0 0 10px #333" + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + }), + tl: { + hd: rule("#debug.paused nav", { + hd: [ + "height", + "50%" + ], + tl: { + hd: [ + "padding-bottom", + "2em" + ], + tl: /* [] */0 + } + }), + tl: { + hd: rule("#debug nav .toggle", { + hd: [ + "padding", + "6px" + ], + tl: { + hd: [ + "padding-left", + "9px" + ], + tl: { + hd: [ + "cursor", + "pointer" + ], + tl: { + hd: [ + "min-width", + "24ch" + ], + tl: { + hd: [ + "text-align", + "center" + ], + tl: { + hd: [ + "border-left", + "3px solid #333" + ], + tl: { + hd: [ + "border-radius", + "4px 4px 0 0" + ], + tl: /* [] */0 + } + } + } + } + } + } + }), + tl: { + hd: rule("#debug nav .toggle:before", { + hd: [ + "content", + "' '" + ], + tl: { + hd: [ + "position", + "absolute" + ], + tl: { + hd: [ + "left", + "0" + ], + tl: { + hd: [ + "top", + "0" + ], + tl: { + hd: [ + "width", + ".5ch" + ], + tl: { + hd: [ + "height", + "1.8ch" + ], + tl: { + hd: [ + "margin", + "1.2ch" + ], + tl: { + hd: [ + "border", + "solid #fff" + ], + tl: { + hd: [ + "border-width", + "0 .5ch" + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + }), + tl: { + hd: rule("#debug.paused nav .toggle:before", { + hd: [ + "border-color", + "transparent" + ], + tl: { + hd: [ + "border-left-color", + "#fff" + ], + tl: { + hd: [ + "border-width", + "1ch" + ], + tl: { + hd: [ + "width", + "0" + ], + tl: { + hd: [ + "height", + "0" + ], + tl: /* [] */0 + } + } + } + } + }), + tl: { + hd: rule("#debug nav .history", { + hd: [ + "margin", + "0" + ], + tl: { + hd: [ + "padding", + "0" + ], + tl: { + hd: [ + "height", + "100%" + ], + tl: { + hd: [ + "overflow-y", + "auto" + ], + tl: { + hd: [ + "list-style", + "none" + ], + tl: /* [] */0 + } + } + } + } + }), + tl: { + hd: rule("#debug nav .history li", { + hd: [ + "margin", + "0" + ], + tl: { + hd: [ + "padding", + "0.2ch" + ], + tl: { + hd: [ + "border-left", + "3px solid #333" + ], + tl: /* [] */0 + } + } + }), + tl: { + hd: rule("#debug nav .history li.selected", { + hd: [ + "background-color", + "#333" + ], + tl: /* [] */0 + }), + tl: { + hd: rule("#debug nav .history span.details", { + hd: [ + "display", + "inline-block" + ], + tl: { + hd: [ + "cursor", + "pointer" + ], + tl: { + hd: [ + "width", + "1ch" + ], + tl: { + hd: [ + "margin", + "0 1ch" + ], + tl: { + hd: [ + "vertical-align", + "super" + ], + tl: /* [] */0 + } + } + } + } + }), + tl: { + hd: rule("#debug nav .history li.selected span.details:after", { + hd: [ + "content", + "'\\2026'" + ], + tl: /* [] */0 + }), + tl: { + hd: rule("#debug nav .history li.selected.show", { + hd: [ + "border-left", + "3px solid white" + ], + tl: /* [] */0 + }), + tl: { + hd: rule("#debug nav .history span.message", { + hd: [ + "display", + "inline-block" + ], + tl: { + hd: [ + "cursor", + "pointer" + ], + tl: { + hd: [ + "white-space", + "nowrap" + ], + tl: { + hd: [ + "overflow", + "hidden" + ], + tl: { + hd: [ + "text-overflow", + "ellipsis" + ], + tl: { + hd: [ + "width", + "calc(100% - 75px)" + ], + tl: /* [] */0 + } + } + } + } + } + }), + tl: { + hd: rule("#debug nav .history span.index", { + hd: [ + "display", + "inline-block" + ], + tl: { + hd: [ + "min-width", + "3ch" + ], + tl: { + hd: [ + "margin", + "0 1ch" + ], + tl: { + hd: [ + "color", + "#aaa" + ], + tl: { + hd: [ + "text-align", + "right" + ], + tl: { + hd: [ + "float", + "right" + ], + tl: /* [] */0 + } + } + } + } + } + }), + tl: { + hd: rule("#debug aside.details", { + hd: [ + "position", + "absolute" + ], + tl: { + hd: [ + "width", + "40ch" + ], + tl: { + hd: [ + "top", + "0" + ], + tl: { + hd: [ + "bottom", + "0" + ], + tl: { + hd: [ + "right", + "100%" + ], + tl: { + hd: [ + "margin-right", + "1.5ch" + ], + tl: { + hd: [ + "overflow", + "scroll" + ], + tl: { + hd: [ + "background-color", + "#fff" + ], + tl: { + hd: [ + "color", + "#000" + ], + tl: { + hd: [ + "box-shadow", + "0 0 10px #333" + ], + tl: { + hd: [ + "border-radius", + "4px 4px 0 0" + ], + tl: { + hd: [ + "border", + "2px solid #333" + ], + tl: { + hd: [ + "padding", + "1ch" + ], + tl: { + hd: [ + "white-space", + "pre" + ], + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + }), + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }); + }; + var viewDetails = function (model) { + var format = (function (v) { + var formatRecord = function (data, labels) { + return data.reduce( + function (acc, cur, index) { + acc[labels[index]] = formatValue(cur) + return acc + }, {}) + } + var listToArray = function (data) { + var result = [] + var cur = data + while (typeof cur !== "number") { + result.push(formatValue(cur[0])) + cur = cur[1] + } + return result + } + var formatVariant = function (data, recordVariant) { + if (recordVariant === "::") { + return listToArray(data) + } + else { + return formatRecord(data, [recordVariant]) + } + } + var formatValue = function (x) { + var recordLabels, recordVariant, recordModule, recordPolyVar + if (x == null) { + return null + } + else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { + return formatRecord(x, recordLabels) + } + else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { + return formatRecord(x, recordModule) + } + else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { + return formatVariant(x, recordVariant) + } + else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { + return x[1] + } + else if (Array.isArray(x)) { + // tuple + return x.map(formatValue) + } + else { + // scalar + return x + } + } + return JSON.stringify(formatValue(v), null, 2); + }); + return Tea_html.aside(undefined, undefined, { + hd: Tea_html.Attributes.$$class("details"), + tl: /* [] */0 + }, { + hd: { + TAG: /* Text */1, + _0: format(model) + }, + tl: /* [] */0 + }); + }; + var viewHistory = function (model, selected_index) { + var count = List.length(model.history); + return Tea_html.ul(undefined, undefined, { + hd: Tea_html.Attributes.$$class("history"), + tl: /* [] */0 + }, List.mapi((function (i, param) { + var selected = i === selected_index; + return Tea_html.li(undefined, undefined, { + hd: Tea_html.Events.onClick({ + TAG: /* SelectHistoryItem */1, + _0: i + }), + tl: { + hd: Tea_html.Attributes.classList({ + hd: [ + "selected", + selected + ], + tl: { + hd: [ + "show", + selected && model.show_details + ], + tl: /* [] */0 + } + }), + tl: /* [] */0 + } + }, { + hd: Tea_html.span(undefined, undefined, { + hd: Tea_html.Attributes.classList({ + hd: [ + "details", + true + ], + tl: { + hd: [ + "show", + true + ], + tl: /* [] */0 + } + }), + tl: selected ? ({ + hd: Tea_html.Events.onClick(/* ToggleDetails */1), + tl: { + hd: Tea_html.Attributes.title("toggle details"), + tl: /* [] */0 + } + }) : ({ + hd: Tea_html.Attributes.noProp, + tl: { + hd: Tea_html.Attributes.noProp, + tl: /* [] */0 + } + }) + }, { + hd: selected && model.show_details ? viewDetails(param[1]) : Tea_html.noNode, + tl: /* [] */0 + }), + tl: { + hd: Tea_html.span(undefined, undefined, { + hd: Tea_html.Attributes.$$class("message"), + tl: /* [] */0 + }, { + hd: { + TAG: /* Text */1, + _0: param[0] + }, + tl: /* [] */0 + }), + tl: { + hd: Tea_html.span(undefined, undefined, { + hd: Tea_html.Attributes.$$class("index"), + tl: /* [] */0 + }, { + hd: { + TAG: /* Text */1, + _0: String(count - i | 0) + }, + tl: /* [] */0 + }), + tl: /* [] */0 + } + } + }); + }), model.history)); + }; + var view$p = function (model) { + var index = model.state; + var match; + if (index) { + var index$1 = index._0; + match = [ + index$1, + List.nth(model.history, index$1)[1], + true + ]; + } else { + match = [ + 0, + List.hd(model.history)[1], + false + ]; + } + var paused = match[2]; + var history_count = List.length(model.history); + return Tea_html.div(undefined, undefined, /* [] */0, { + hd: Vdom.map(clientMsg, Curry._1(view, match[1])), + tl: { + hd: Tea_html.div(undefined, undefined, { + hd: Tea_html.Attributes.id("debug"), + tl: { + hd: Tea_html.Attributes.classList({ + hd: [ + "paused", + paused + ], + tl: /* [] */0 + }), + tl: /* [] */0 + } + }, { + hd: viewStyles(undefined), + tl: { + hd: Tea_html.nav(undefined, undefined, /* [] */0, { + hd: Tea_html.div(undefined, undefined, { + hd: Tea_html.Attributes.$$class("toggle"), + tl: { + hd: Tea_html.Events.onClick(/* TogglePaused */0), + tl: { + hd: paused ? Tea_html.Attributes.title("click to resume") : Tea_html.Attributes.title("click to pause"), + tl: /* [] */0 + } + } + }, { + hd: { + TAG: /* Text */1, + _0: "Explore History (" + history_count + ")" + }, + tl: /* [] */0 + }), + tl: { + hd: paused ? viewHistory(model, match[0]) : Tea_html.noNode, + tl: /* [] */0 + } + }), + tl: /* [] */0 + } + }), + tl: /* [] */0 + } + }); + }; + var subscriptions$p = function (model) { + return Tea_sub.map(clientMsg, Curry._1(subscriptions, List.hd(model.history)[1])); + }; + var shutdown$p = function (model) { + return Tea_cmd.map(clientMsg, Curry._1(shutdown, List.hd(model.history)[1])); + }; + return [ + initDebug, + update$p, + view$p, + subscriptions$p, + shutdown$p + ]; +} + +function debugProgram(string_of_msg, param) { + var init = param.init; + var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); + var initDebug = match[0]; + return { + init: (function (flags) { + return Curry._1(initDebug, Curry._1(init, flags)); + }), + update: match[1], + view: match[2], + subscriptions: match[3], + shutdown: match[4] + }; +} + +function debugNavigationProgram(string_of_msg, param) { + var init = param.init; + var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); + var initDebug = match[0]; + return { + init: (function (flags, $$location) { + return Curry._1(initDebug, Curry._2(init, flags, $$location)); + }), + update: match[1], + view: match[2], + subscriptions: match[3], + shutdown: match[4] + }; +} + +function beginnerProgram(param, string_of_msg, pnode, flags) { + var update = param.update; + var model = param.model; + var debugged = debugProgram(string_of_msg, { + init: (function (param) { + return [ + model, + /* NoCmd */0 + ]; + }), + update: (function (model, msg) { + return [ + Curry._2(update, model, msg), + /* NoCmd */0 + ]; + }), + view: param.view, + subscriptions: (function (_model) { + return /* NoSub */0; + }), + shutdown: (function (_model) { + return /* NoCmd */0; + }) + }); + return Tea_app.program(debugged, pnode, flags); +} + +function standardProgram(param, string_of_msg, pnode, flags) { + var debugged = debugProgram(string_of_msg, { + init: param.init, + update: param.update, + view: param.view, + subscriptions: param.subscriptions, + shutdown: (function (_model) { + return /* NoCmd */0; + }) + }); + return Tea_app.program(debugged, pnode, flags); +} + +function program(param, string_of_msg, pnode, flags) { + var debugged = debugProgram(string_of_msg, { + init: param.init, + update: param.update, + view: param.view, + subscriptions: param.subscriptions, + shutdown: param.shutdown + }); + return Tea_app.program(debugged, pnode, flags); +} + +function navigationProgram(location_to_msg, param, string_of_msg, pnode, flags) { + var $$location = function ($$location$1) { + return { + TAG: /* ClientMsg */0, + _0: Curry._1(location_to_msg, $$location$1) + }; + }; + var debugged = debugNavigationProgram(string_of_msg, { + init: param.init, + update: param.update, + view: param.view, + subscriptions: param.subscriptions, + shutdown: param.shutdown + }); + return Tea_navigation.navigationProgram($$location, debugged)(pnode, flags); +} + +exports.clientMsg = clientMsg; +exports.debug = debug; +exports.debugProgram = debugProgram; +exports.debugNavigationProgram = debugNavigationProgram; +exports.beginnerProgram = beginnerProgram; +exports.standardProgram = standardProgram; +exports.program = program; +exports.navigationProgram = navigationProgram; +/* Tea_html Not a pure module */ diff --git a/lib/js/src/tea_ex.js b/lib/js/src/tea_ex.js new file mode 100644 index 0000000..459d228 --- /dev/null +++ b/lib/js/src/tea_ex.js @@ -0,0 +1,172 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Tea_sub = require("./tea_sub.js"); +var Tea_task = require("./tea_task.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Dom_storage = require("rescript/lib/js/dom_storage.js"); + +function renderEvent(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + var enableCall = function (callbacks) { + Curry._1(callbacks.on, { + TAG: /* AddRenderMsg */0, + _0: msg + }); + return function (param) { + return Curry._1(callbacks.on, { + TAG: /* RemoveRenderMsg */1, + _0: msg + }); + }; + }; + return Tea_sub.registration(key, enableCall); +} + +var length = /* Task */{ + _0: (function (cb) { + try { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: localStorage.length + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) +}; + +var clear = /* Task */{ + _0: (function (cb) { + try { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: (localStorage.clear(), undefined) + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) +}; + +function clearCmd(param) { + return Tea_task.attemptOpt((function (param) { + + }), clear); +} + +function key(idx) { + return /* Task */{ + _0: (function (cb) { + try { + var obj = localStorage; + return Curry._1(cb, { + TAG: /* Ok */0, + _0: Caml_option.null_to_opt(obj.key(idx)) + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) + }; +} + +function getItem(key) { + return /* Task */{ + _0: (function (cb) { + try { + var obj = localStorage; + return Curry._1(cb, { + TAG: /* Ok */0, + _0: Caml_option.null_to_opt(obj.getItem(key)) + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) + }; +} + +function removeItem(key) { + return /* Task */{ + _0: (function (cb) { + try { + var obj = localStorage; + return Curry._1(cb, { + TAG: /* Ok */0, + _0: (obj.removeItem(key), undefined) + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) + }; +} + +function removeItemCmd(key) { + return Tea_task.attemptOpt((function (param) { + + }), removeItem(key)); +} + +function setItem(key, value) { + return /* Task */{ + _0: (function (cb) { + try { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: Dom_storage.setItem(key, value, localStorage) + }); + } + catch (_e){ + return Curry._1(cb, { + TAG: /* Error */1, + _0: "localStorage is not available" + }); + } + }) + }; +} + +function setItemCmd(key, value) { + return Tea_task.attemptOpt((function (param) { + + }), setItem(key, value)); +} + +var LocalStorage = { + length: length, + clear: clear, + clearCmd: clearCmd, + key: key, + getItem: getItem, + removeItem: removeItem, + removeItemCmd: removeItemCmd, + setItem: setItem, + setItemCmd: setItemCmd +}; + +exports.renderEvent = renderEvent; +exports.LocalStorage = LocalStorage; +/* No side effect */ diff --git a/lib/js/src/tea_html.js b/lib/js/src/tea_html.js new file mode 100644 index 0000000..f97a1ef --- /dev/null +++ b/lib/js/src/tea_html.js @@ -0,0 +1,1963 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); +var $$String = require("rescript/lib/js/string.js"); +var Tea_app = require("./tea_app.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Caml_string = require("rescript/lib/js/caml_string.js"); +var Json$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json.js"); +var Json_Decode$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json_Decode.js"); +var Rescript_json_combinators_extended = require("./rescript_json_combinators_extended.js"); + +function text(str) { + return { + TAG: /* Text */1, + _0: str + }; +} + +function node(namespaceOpt, tagName, keyOpt, uniqueOpt, props, nodes) { + var namespace = namespaceOpt !== undefined ? namespaceOpt : ""; + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(namespace, tagName, key, unique, props, nodes); +} + +var lazy1 = Vdom.lazyGen; + +function h1(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h1", key, unique, props, nodes); +} + +function h2(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h2", key, unique, props, nodes); +} + +function h3(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h3", key, unique, props, nodes); +} + +function h4(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h4", key, unique, props, nodes); +} + +function h5(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h5", key, unique, props, nodes); +} + +function h6(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "h6", key, unique, props, nodes); +} + +function div(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "div", key, unique, props, nodes); +} + +function p(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "p", key, unique, props, nodes); +} + +function hr(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "hr", key, unique, props, nodes); +} + +function pre(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "pre", key, unique, props, nodes); +} + +function blockquote(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "blockquote", key, unique, props, nodes); +} + +function span(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "span", key, unique, props, nodes); +} + +function a(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "a", key, unique, props, nodes); +} + +function code(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "code", key, unique, props, nodes); +} + +function em(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "em", key, unique, props, nodes); +} + +function strong(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "strong", key, unique, props, nodes); +} + +function i(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "i", key, unique, props, nodes); +} + +function b(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "b", key, unique, props, nodes); +} + +function u(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "u", key, unique, props, nodes); +} + +function sub(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "sub", key, unique, props, nodes); +} + +function sup(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "sup", key, unique, props, nodes); +} + +function br(props) { + return Vdom.fullnode("", "br", "br", "br", props, /* [] */0); +} + +function br$p(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "br", key, unique, props, nodes); +} + +function ol(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "ol", key, unique, props, nodes); +} + +function ul(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "ul", key, unique, props, nodes); +} + +function li(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "li", key, unique, props, nodes); +} + +function dl(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "dl", key, unique, props, nodes); +} + +function dt(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "dt", key, unique, props, nodes); +} + +function dd(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "dd", key, unique, props, nodes); +} + +function img(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "img", key, unique, props, nodes); +} + +function iframe(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "iframe", key, unique, props, nodes); +} + +function canvas(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "canvas", key, unique, props, nodes); +} + +function math(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "math", key, unique, props, nodes); +} + +function form(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "form", key, unique, props, nodes); +} + +function input$p(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "input", key, unique, props, nodes); +} + +function textarea(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "textarea", key, unique, props, nodes); +} + +function button(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "button", key, unique, props, nodes); +} + +function select(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "select", key, unique, props, nodes); +} + +function option(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "option", key, unique, props, nodes); +} + +function optgroup(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "optgroup", key, unique, props, nodes); +} + +function label(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "label", key, unique, props, nodes); +} + +function fieldset(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "fieldset", key, unique, props, nodes); +} + +function legend(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "legend", key, unique, props, nodes); +} + +function section(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "section", key, unique, props, nodes); +} + +function nav(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "nav", key, unique, props, nodes); +} + +function article(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "article", key, unique, props, nodes); +} + +function aside(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "aside", key, unique, props, nodes); +} + +function header(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "header", key, unique, props, nodes); +} + +function footer(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "footer", key, unique, props, nodes); +} + +function address(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "address", key, unique, props, nodes); +} + +function main(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "main", key, unique, props, nodes); +} + +function body(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "body", key, unique, props, nodes); +} + +function figure(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "figure", key, unique, props, nodes); +} + +function figcaption(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "figcaption", key, unique, props, nodes); +} + +function table(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "table", key, unique, props, nodes); +} + +function caption(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "caption", key, unique, props, nodes); +} + +function colgroup(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "colgroup", key, unique, props, nodes); +} + +function col(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "col", key, unique, props, nodes); +} + +function tbody(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "tbody", key, unique, props, nodes); +} + +function thead(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "thead", key, unique, props, nodes); +} + +function tfoot(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "tfoot", key, unique, props, nodes); +} + +function tr(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "tr", key, unique, props, nodes); +} + +function th(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "th", key, unique, props, nodes); +} + +function td(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "td", key, unique, props, nodes); +} + +function datalist(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "datalist", key, unique, props, nodes); +} + +function keygen(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "keygen", key, unique, props, nodes); +} + +function output(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "output", key, unique, props, nodes); +} + +function progress(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "progress", key, unique, props, nodes); +} + +function meter(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "meter", key, unique, props, nodes); +} + +function audio(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "audio", key, unique, props, nodes); +} + +function video(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "video", key, unique, props, nodes); +} + +function source(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "source", key, unique, props, nodes); +} + +function track(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "track", key, unique, props, nodes); +} + +function embed(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "embed", key, unique, props, nodes); +} + +function object(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "object", key, unique, props, nodes); +} + +function param(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "param", key, unique, props, nodes); +} + +function ins(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "ins", key, unique, props, nodes); +} + +function del(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "del", key, unique, props, nodes); +} + +function small(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "small", key, unique, props, nodes); +} + +function cite(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "cite", key, unique, props, nodes); +} + +function dfn(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "dfn", key, unique, props, nodes); +} + +function abbr(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "abbr", key, unique, props, nodes); +} + +function time(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "time", key, unique, props, nodes); +} + +function $$var(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "var", key, unique, props, nodes); +} + +function samp(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "samp", key, unique, props, nodes); +} + +function kbd(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "kbd", key, unique, props, nodes); +} + +function s(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "s", key, unique, props, nodes); +} + +function q(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "q", key, unique, props, nodes); +} + +function mark(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "mark", key, unique, props, nodes); +} + +function ruby(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "ruby", key, unique, props, nodes); +} + +function rt(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "rt", key, unique, props, nodes); +} + +function rp(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "rp", key, unique, props, nodes); +} + +function bdi(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "bdi", key, unique, props, nodes); +} + +function bdo(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "bdo", key, unique, props, nodes); +} + +function wbr(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "wbr", key, unique, props, nodes); +} + +function details(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "details", key, unique, props, nodes); +} + +function summary(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "summary", key, unique, props, nodes); +} + +function menuitem(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "menuitem", key, unique, props, nodes); +} + +function menu(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "menu", key, unique, props, nodes); +} + +function meta(keyOpt, uniqueOpt, props) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "meta", key, unique, props, /* [] */0); +} + +function style(keyOpt, uniqueOpt, props, content) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "style", key, unique, props, { + hd: { + TAG: /* Text */1, + _0: content + }, + tl: /* [] */0 + }); +} + +function title(keyOpt, uniqueOpt, props, content) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "title", key, unique, props, { + hd: { + TAG: /* Text */1, + _0: content + }, + tl: /* [] */0 + }); +} + +function link(keyOpt, uniqueOpt, props) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode("", "link", key, unique, props, /* [] */0); +} + +var style$1 = Vdom.style; + +function styles(s) { + return { + TAG: /* Style */4, + _0: s + }; +} + +function $$class(name) { + return { + TAG: /* RawProp */0, + _0: "className", + _1: name + }; +} + +function classList(classes) { + return { + TAG: /* RawProp */0, + _0: "className", + _1: $$String.concat(" ", List.map((function (param) { + return param[0]; + }), List.filter(function (param) { + return param[1]; + })(classes))) + }; +} + +function id(str) { + return { + TAG: /* RawProp */0, + _0: "id", + _1: str + }; +} + +function title$1(str) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "title", + _2: str + }; +} + +function hidden(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "hidden", + _1: "hidden" + }; + } else { + return /* NoProp */0; + } +} + +function type$p(typ) { + return { + TAG: /* RawProp */0, + _0: "type", + _1: typ + }; +} + +function value(str) { + return { + TAG: /* RawProp */0, + _0: "value", + _1: str + }; +} + +function defaultValue(str) { + return { + TAG: /* RawProp */0, + _0: "defaultValue", + _1: str + }; +} + +function checked(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "checked", + _1: "checked" + }; + } else { + return /* NoProp */0; + } +} + +function placeholder(str) { + return { + TAG: /* RawProp */0, + _0: "placeholder", + _1: str + }; +} + +function selected(b) { + if (b) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "selected", + _2: "true" + }; + } else { + return /* NoProp */0; + } +} + +function accept(c) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "accept", + _2: c + }; +} + +function acceptCharset(c) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "accept-charset", + _2: c + }; +} + +function action(a) { + return { + TAG: /* RawProp */0, + _0: "action", + _1: a + }; +} + +function autocomplete(b) { + return { + TAG: /* RawProp */0, + _0: "autocomplete", + _1: b ? "on" : "off" + }; +} + +function autofocus(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "autofocus", + _1: "autofocus" + }; + } else { + return /* NoProp */0; + } +} + +function disabled(b) { + if (b) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "disabled", + _2: "true" + }; + } else { + return /* NoProp */0; + } +} + +function enctype(encoding) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "enctype", + _2: encoding + }; +} + +function formaction(url) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "formaction", + _2: url + }; +} + +function list(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "list", + _2: value + }; +} + +function minlength(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "minlength", + _2: String(n) + }; +} + +function maxlength(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "maxlength", + _2: String(n) + }; +} + +function method(m) { + return { + TAG: /* RawProp */0, + _0: "method", + _1: m + }; +} + +function multiple(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "multiple", + _1: "multiple" + }; + } else { + return /* NoProp */0; + } +} + +function name(str) { + return { + TAG: /* RawProp */0, + _0: "name", + _1: str + }; +} + +function novalidate(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "novalidate", + _1: "novalidate" + }; + } else { + return /* NoProp */0; + } +} + +function pattern(p) { + return { + TAG: /* RawProp */0, + _0: "pattern", + _1: p + }; +} + +function readonly(b) { + if (b) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "readonly", + _2: "readonly" + }; + } else { + return /* NoProp */0; + } +} + +function required(b) { + if (b) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "required", + _2: "required" + }; + } else { + return /* NoProp */0; + } +} + +function size(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "size", + _2: String(n) + }; +} + +function for$p(str) { + return { + TAG: /* RawProp */0, + _0: "htmlFor", + _1: str + }; +} + +function form$1(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "form", + _2: value + }; +} + +function max(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "max", + _2: value + }; +} + +function min(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "min", + _2: value + }; +} + +function step(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "step", + _2: value + }; +} + +function cols(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "cols", + _2: String(n) + }; +} + +function rows(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rows", + _2: String(n) + }; +} + +function wrap(value) { + return { + TAG: /* RawProp */0, + _0: "wrap", + _1: value + }; +} + +function href(str) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "href", + _2: str + }; +} + +function target(t) { + return { + TAG: /* RawProp */0, + _0: "target", + _1: t + }; +} + +function download(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "download", + _1: "" + }; + } else { + return /* NoProp */0; + } +} + +function downloadAs(name) { + return { + TAG: /* RawProp */0, + _0: "download", + _1: name + }; +} + +function hreflang(code) { + return { + TAG: /* RawProp */0, + _0: "hreflang", + _1: code + }; +} + +function media(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "media", + _2: value + }; +} + +function ping(url) { + return { + TAG: /* RawProp */0, + _0: "ping", + _1: url + }; +} + +function rel(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rel", + _2: value + }; +} + +function ismap(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "ismap", + _1: "ismap" + }; + } else { + return /* NoProp */0; + } +} + +function usemap(name) { + return { + TAG: /* RawProp */0, + _0: "usemap", + _1: name + }; +} + +function shape(value) { + return { + TAG: /* RawProp */0, + _0: "shape", + _1: value + }; +} + +function coords(value) { + return { + TAG: /* RawProp */0, + _0: "coords", + _1: value + }; +} + +function src(str) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "src", + _2: str + }; +} + +function height(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "height", + _2: String(n) + }; +} + +function width(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "width", + _2: String(n) + }; +} + +function alt(value) { + return { + TAG: /* RawProp */0, + _0: "alt", + _1: value + }; +} + +function autoplay(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "autoplay", + _1: "autoplay" + }; + } else { + return /* NoProp */0; + } +} + +function controls(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "controls", + _1: "controls" + }; + } else { + return /* NoProp */0; + } +} + +function loop(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "loop", + _1: "loop" + }; + } else { + return /* NoProp */0; + } +} + +function preload(value) { + return { + TAG: /* RawProp */0, + _0: "preload", + _1: value + }; +} + +function poster(url) { + return { + TAG: /* RawProp */0, + _0: "poster", + _1: url + }; +} + +function $$default(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "default", + _1: "default" + }; + } else { + return /* NoProp */0; + } +} + +function kind(value) { + return { + TAG: /* RawProp */0, + _0: "kind", + _1: value + }; +} + +function srclang(code) { + return { + TAG: /* RawProp */0, + _0: "srclang", + _1: code + }; +} + +function sandbox(value) { + return { + TAG: /* RawProp */0, + _0: "sandbox", + _1: value + }; +} + +function seamless(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "seamless", + _1: "seamless" + }; + } else { + return /* NoProp */0; + } +} + +function srcdoc(value) { + return { + TAG: /* RawProp */0, + _0: "srcdoc", + _1: value + }; +} + +function reversed(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "reversed", + _1: "reversed" + }; + } else { + return /* NoProp */0; + } +} + +function start(n) { + return { + TAG: /* RawProp */0, + _0: "start", + _1: String(n) + }; +} + +function colspan(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "colspan", + _2: String(n) + }; +} + +function rowspan(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rowspan", + _2: String(n) + }; +} + +function headers(value) { + return { + TAG: /* RawProp */0, + _0: "headers", + _1: value + }; +} + +function scope(value) { + return { + TAG: /* RawProp */0, + _0: "scope", + _1: value + }; +} + +function align(value) { + return { + TAG: /* RawProp */0, + _0: "align", + _1: value + }; +} + +function async(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "async", + _1: "async" + }; + } else { + return /* NoProp */0; + } +} + +function charset(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "charset", + _2: value + }; +} + +function content(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "content", + _2: value + }; +} + +function defer(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "defer", + _1: "defer" + }; + } else { + return /* NoProp */0; + } +} + +function httpEquiv(value) { + return { + TAG: /* RawProp */0, + _0: "http-equiv", + _1: value + }; +} + +function language(value) { + return { + TAG: /* RawProp */0, + _0: "language", + _1: value + }; +} + +function scoped(value) { + return { + TAG: /* RawProp */0, + _0: "scoped", + _1: value + }; +} + +function accesskey(ch) { + return { + TAG: /* RawProp */0, + _0: "accesskey", + _1: Caml_string.make(1, ch) + }; +} + +function contenteditable(b) { + if (b) { + return { + TAG: /* RawProp */0, + _0: "contenteditable", + _1: "contenteditable" + }; + } else { + return /* NoProp */0; + } +} + +function contextmenu(id) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "contextmenu", + _2: id + }; +} + +function dir(value) { + return { + TAG: /* RawProp */0, + _0: "dir", + _1: value + }; +} + +function draggable(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "draggable", + _2: value + }; +} + +function dropzone(value) { + return { + TAG: /* RawProp */0, + _0: "dropzone", + _1: value + }; +} + +function itemprop(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "itemprop", + _2: value + }; +} + +function lang(code) { + return { + TAG: /* RawProp */0, + _0: "lang", + _1: code + }; +} + +function spellcheck(b) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "spellcheck", + _2: b ? "true" : "false" + }; +} + +function tabindex(n) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "tabindex", + _2: String(n) + }; +} + +function challenge(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "challenge", + _2: value + }; +} + +function keytype(value) { + return { + TAG: /* RawProp */0, + _0: "keytype", + _1: value + }; +} + +function cite$1(url) { + return { + TAG: /* RawProp */0, + _0: "cite", + _1: url + }; +} + +function datetime(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "datetime", + _2: value + }; +} + +function pubdate(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pubdate", + _2: value + }; +} + +function manifest(value) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "manifest", + _2: value + }; +} + +var Attributes = { + noProp: /* NoProp */0, + style: style$1, + styles: styles, + $$class: $$class, + classList: classList, + id: id, + title: title$1, + hidden: hidden, + type$p: type$p, + value: value, + defaultValue: defaultValue, + checked: checked, + placeholder: placeholder, + selected: selected, + accept: accept, + acceptCharset: acceptCharset, + action: action, + autocomplete: autocomplete, + autofocus: autofocus, + disabled: disabled, + enctype: enctype, + formaction: formaction, + list: list, + minlength: minlength, + maxlength: maxlength, + method: method, + multiple: multiple, + name: name, + novalidate: novalidate, + pattern: pattern, + readonly: readonly, + required: required, + size: size, + for$p: for$p, + form: form$1, + max: max, + min: min, + step: step, + cols: cols, + rows: rows, + wrap: wrap, + href: href, + target: target, + download: download, + downloadAs: downloadAs, + hreflang: hreflang, + media: media, + ping: ping, + rel: rel, + ismap: ismap, + usemap: usemap, + shape: shape, + coords: coords, + src: src, + height: height, + width: width, + alt: alt, + autoplay: autoplay, + controls: controls, + loop: loop, + preload: preload, + poster: poster, + $$default: $$default, + kind: kind, + srclang: srclang, + sandbox: sandbox, + seamless: seamless, + srcdoc: srcdoc, + reversed: reversed, + start: start, + colspan: colspan, + rowspan: rowspan, + headers: headers, + scope: scope, + align: align, + async: async, + charset: charset, + content: content, + defer: defer, + httpEquiv: httpEquiv, + language: language, + scoped: scoped, + accesskey: accesskey, + contenteditable: contenteditable, + contextmenu: contextmenu, + dir: dir, + draggable: draggable, + dropzone: dropzone, + itemprop: itemprop, + lang: lang, + spellcheck: spellcheck, + tabindex: tabindex, + challenge: challenge, + keytype: keytype, + cite: cite$1, + datetime: datetime, + pubdate: pubdate, + manifest: manifest +}; + +function onCB(key, eventName, cb) { + return Vdom.onCB(eventName, key, cb); +} + +var onMsg = Vdom.onMsg; + +var defaultOptions = { + stopPropagation: false, + preventDefault: false +}; + +function onWithOptions(key, eventName, options, decoder) { + return Vdom.onCB(eventName, key, (function ($$event) { + if (options.stopPropagation) { + $$event.stopPropagation(); + } + if (options.preventDefault) { + $$event.preventDefault(); + } + var result = Json$JsonCombinators.decode($$event, decoder); + if (result.TAG === /* Ok */0) { + return Caml_option.some(result._0); + } + + })); +} + +function on(key, eventName, decoder) { + return onWithOptions(key, eventName, defaultOptions, decoder); +} + +var targetValue = Rescript_json_combinators_extended.at({ + hd: "target", + tl: { + hd: "value", + tl: /* [] */0 + } + }, Json_Decode$JsonCombinators.string); + +var targetChecked = Rescript_json_combinators_extended.at({ + hd: "target", + tl: { + hd: "checked", + tl: /* [] */0 + } + }, Json_Decode$JsonCombinators.bool); + +var keyCode = Json_Decode$JsonCombinators.field("keyCode", Json_Decode$JsonCombinators.$$int); + +function preventDefaultOn(keyOpt, eventName, decoder) { + var key = keyOpt !== undefined ? keyOpt : ""; + return onWithOptions(key, eventName, { + stopPropagation: false, + preventDefault: true + }, decoder); +} + +function onClick(msg) { + return Vdom.onMsg("click", msg); +} + +function onDoubleClick(msg) { + return Vdom.onMsg("dblclick", msg); +} + +function onMouseDown(msg) { + return Vdom.onMsg("mousedown", msg); +} + +function onMouseUp(msg) { + return Vdom.onMsg("mouseup", msg); +} + +function onMouseEnter(msg) { + return Vdom.onMsg("mouseenter", msg); +} + +function onMouseLeave(msg) { + return Vdom.onMsg("mouseleave", msg); +} + +function onMouseOver(msg) { + return Vdom.onMsg("mouseover", msg); +} + +function onMouseOut(msg) { + return Vdom.onMsg("mouseout", msg); +} + +function onInputOpt(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return Vdom.onCB("input", key, (function (ev) { + var target = ev.target; + if (target === undefined) { + return ; + } + var value = target.value; + if (value !== undefined) { + return Curry._1(msg, value); + } + + })); +} + +function onInput(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return onInputOpt(key, (function (ev) { + return Caml_option.some(Curry._1(msg, ev)); + })); +} + +function onCheckOpt(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return Vdom.onCB("change", key, (function (ev) { + var target = ev.target; + if (target === undefined) { + return ; + } + var value = target.checked; + if (value !== undefined) { + return Curry._1(msg, value); + } + + })); +} + +function onCheck(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return onCheckOpt(key, (function (ev) { + return Caml_option.some(Curry._1(msg, ev)); + })); +} + +function onChangeOpt(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return Vdom.onCB("change", key, (function (ev) { + var target = ev.target; + if (target === undefined) { + return ; + } + var value = target.value; + if (value !== undefined) { + return Curry._1(msg, value); + } + + })); +} + +function onChange(keyOpt, msg) { + var key = keyOpt !== undefined ? keyOpt : ""; + return onChangeOpt(key, (function (ev) { + return Caml_option.some(Curry._1(msg, ev)); + })); +} + +function onSubmit(msg) { + return preventDefaultOn(undefined, "submit", Json_Decode$JsonCombinators.custom(function (_value) { + return msg; + })); +} + +function onBlur(msg) { + return Vdom.onMsg("blur", msg); +} + +function onFocus(msg) { + return Vdom.onMsg("focus", msg); +} + +var map = Tea_app.map; + +var noNode = Vdom.noNode; + +var Events = { + onCB: onCB, + onMsg: onMsg, + on: on, + onWithOptions: onWithOptions, + defaultOptions: defaultOptions, + targetValue: targetValue, + targetChecked: targetChecked, + keyCode: keyCode, + preventDefaultOn: preventDefaultOn, + onClick: onClick, + onDoubleClick: onDoubleClick, + onMouseDown: onMouseDown, + onMouseUp: onMouseUp, + onMouseEnter: onMouseEnter, + onMouseLeave: onMouseLeave, + onMouseOver: onMouseOver, + onMouseOut: onMouseOut, + onInputOpt: onInputOpt, + onInput: onInput, + onCheckOpt: onCheckOpt, + onCheck: onCheck, + onChangeOpt: onChangeOpt, + onChange: onChange, + onSubmit: onSubmit, + onBlur: onBlur, + onFocus: onFocus +}; + +exports.map = map; +exports.text = text; +exports.node = node; +exports.noNode = noNode; +exports.lazy1 = lazy1; +exports.h1 = h1; +exports.h2 = h2; +exports.h3 = h3; +exports.h4 = h4; +exports.h5 = h5; +exports.h6 = h6; +exports.div = div; +exports.p = p; +exports.hr = hr; +exports.pre = pre; +exports.blockquote = blockquote; +exports.span = span; +exports.a = a; +exports.code = code; +exports.em = em; +exports.strong = strong; +exports.i = i; +exports.b = b; +exports.u = u; +exports.sub = sub; +exports.sup = sup; +exports.br = br; +exports.br$p = br$p; +exports.ol = ol; +exports.ul = ul; +exports.li = li; +exports.dl = dl; +exports.dt = dt; +exports.dd = dd; +exports.img = img; +exports.iframe = iframe; +exports.canvas = canvas; +exports.math = math; +exports.form = form; +exports.input$p = input$p; +exports.textarea = textarea; +exports.button = button; +exports.select = select; +exports.option = option; +exports.optgroup = optgroup; +exports.label = label; +exports.fieldset = fieldset; +exports.legend = legend; +exports.section = section; +exports.nav = nav; +exports.article = article; +exports.aside = aside; +exports.header = header; +exports.footer = footer; +exports.address = address; +exports.main = main; +exports.body = body; +exports.figure = figure; +exports.figcaption = figcaption; +exports.table = table; +exports.caption = caption; +exports.colgroup = colgroup; +exports.col = col; +exports.tbody = tbody; +exports.thead = thead; +exports.tfoot = tfoot; +exports.tr = tr; +exports.th = th; +exports.td = td; +exports.datalist = datalist; +exports.keygen = keygen; +exports.output = output; +exports.progress = progress; +exports.meter = meter; +exports.audio = audio; +exports.video = video; +exports.source = source; +exports.track = track; +exports.embed = embed; +exports.object = object; +exports.param = param; +exports.ins = ins; +exports.del = del; +exports.small = small; +exports.cite = cite; +exports.dfn = dfn; +exports.abbr = abbr; +exports.time = time; +exports.$$var = $$var; +exports.samp = samp; +exports.kbd = kbd; +exports.s = s; +exports.q = q; +exports.mark = mark; +exports.ruby = ruby; +exports.rt = rt; +exports.rp = rp; +exports.bdi = bdi; +exports.bdo = bdo; +exports.wbr = wbr; +exports.details = details; +exports.summary = summary; +exports.menuitem = menuitem; +exports.menu = menu; +exports.meta = meta; +exports.style = style; +exports.title = title; +exports.link = link; +exports.Attributes = Attributes; +exports.Events = Events; +/* targetValue Not a pure module */ diff --git a/lib/js/src/tea_html_cmds.js b/lib/js/src/tea_html_cmds.js new file mode 100644 index 0000000..7b30e8b --- /dev/null +++ b/lib/js/src/tea_html_cmds.js @@ -0,0 +1,35 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Belt_Option = require("rescript/lib/js/belt_Option.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Webapi__Dom__HtmlInputElement = require("rescript-webapi/lib/js/src/Webapi/Dom/Webapi__Dom__HtmlInputElement.js"); + +function focus(id) { + return { + TAG: /* EnqueueCall */2, + _0: (function (_enqueue) { + var ecb = function (param) { + var elem = Belt_Option.flatMap(Caml_option.nullable_to_opt(document.getElementById(id)), Webapi__Dom__HtmlInputElement.ofElement); + if (elem !== undefined) { + Caml_option.valFromOption(elem).focus(); + } else { + console.log([ + "Attempted to focus a non-existant element of: ", + id + ]); + } + + }; + var cb = function (param) { + requestAnimationFrame(ecb); + + }; + requestAnimationFrame(cb); + + }) + }; +} + +exports.focus = focus; +/* Webapi__Dom__HtmlInputElement Not a pure module */ diff --git a/lib/js/src/tea_http.js b/lib/js/src/tea_http.js new file mode 100644 index 0000000..4a48833 --- /dev/null +++ b/lib/js/src/tea_http.js @@ -0,0 +1,1512 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Caml = require("rescript/lib/js/caml.js"); +var List = require("rescript/lib/js/list.js"); +var Curry = require("rescript/lib/js/curry.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Web_xmlhttprequest = require("./web_xmlhttprequest.js"); +var Json_Decode$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json_Decode.js"); + +function stringOfError(x) { + if (typeof x === "number") { + switch (x) { + case /* Timeout */0 : + return "Timeout"; + case /* NetworkError */1 : + return "Unknown network error"; + case /* Aborted */2 : + return "Request aborted"; + + } + } else { + switch (x.TAG | 0) { + case /* BadUrl */0 : + return "Bad Url: " + x._0; + case /* BadStatus */1 : + return "Bad Status: " + x._0.url; + case /* BadPayload */2 : + return "Bad Payload: " + x._1.url; + + } + } +} + +var emptyRequestEvents = { + onreadystatechange: undefined, + onprogress: undefined +}; + +function expectStringResponse(func) { + return /* Expect */{ + _0: /* TextResponseType */5, + _1: (function (param) { + var body = param.body; + if (typeof body === "number" || body.TAG !== /* TextResponse */5) { + return { + TAG: /* Error */1, + _0: "Non-text response returned" + }; + } else { + return Curry._1(func, body._0); + } + }) + }; +} + +var expectString = expectStringResponse(function (resString) { + return { + TAG: /* Ok */0, + _0: resString + }; + }); + +function request(rawRequest) { + return /* Request */{ + _0: rawRequest, + _1: undefined + }; +} + +function getString(url) { + return /* Request */{ + _0: { + method: "GET", + headers: /* [] */0, + url: url, + body: /* EmptyBody */0, + expect: expectString, + timeout: undefined, + withCredentials: false + }, + _1: undefined + }; +} + +function toTask(param) { + var request = param._0; + var height = function (param) { + if (param) { + return param.h; + } else { + return 0; + } + }; + var create = function (l, x, d, r) { + var hl = height(l); + var hr = height(r); + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + var singleton = function (x, d) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: d, + r: /* Empty */0, + h: 1 + }; + }; + var bal = function (l, x, d, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + if (hl > (hr + 2 | 0)) { + if (l) { + var lr = l.r; + var ld = l.d; + var lv = l.v; + var ll = l.l; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } + if (lr) { + return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (r) { + var rr = r.r; + var rd = r.d; + var rv = r.v; + var rl = r.l; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } + if (rl) { + return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + }; + var add = function (x, data, m) { + if (!m) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: data, + r: /* Empty */0, + h: 1 + }; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + if (d === data) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = add(x, data, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = add(x, data, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var min_binding = function (_param) { + while(true) { + var param = _param; + if (param) { + var l = param.l; + if (!l) { + return [ + param.v, + param.d + ]; + } + _param = l; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; + }; + var remove_min_binding = function (param) { + if (param) { + var l = param.l; + if (l) { + return bal(remove_min_binding(l), param.v, param.d, param.r); + } else { + return param.r; + } + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; + }; + var merge = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return bal(t1, match[0], match[1], remove_min_binding(t2)); + }; + var remove = function (x, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + return merge(l, r); + } + if (c < 0) { + var ll = remove(x, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = remove(x, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var update = function (x, f, m) { + if (m) { + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + var data = Curry._1(f, Caml_option.some(d)); + if (data === undefined) { + return merge(l, r); + } + var data$1 = Caml_option.valFromOption(data); + if (d === data$1) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data$1, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = update(x, f, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = update(x, f, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + } + var data$2 = Curry._1(f, undefined); + if (data$2 !== undefined) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: Caml_option.valFromOption(data$2), + r: /* Empty */0, + h: 1 + }; + } else { + return /* Empty */0; + } + }; + var iter = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + iter(f, param.l); + Curry._2(f, param.v, param.d); + _param = param.r; + continue ; + }; + }; + var map = function (f, param) { + if (!param) { + return /* Empty */0; + } + var l$p = map(f, param.l); + var d$p = Curry._1(f, param.d); + var r$p = map(f, param.r); + return /* Node */{ + l: l$p, + v: param.v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var mapi = function (f, param) { + if (!param) { + return /* Empty */0; + } + var v = param.v; + var l$p = mapi(f, param.l); + var d$p = Curry._2(f, v, param.d); + var r$p = mapi(f, param.r); + return /* Node */{ + l: l$p, + v: v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var fold = function (f, _m, _accu) { + while(true) { + var accu = _accu; + var m = _m; + if (!m) { + return accu; + } + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); + _m = m.r; + continue ; + }; + }; + var for_all = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + if (!Curry._2(p, param.v, param.d)) { + return false; + } + if (!for_all(p, param.l)) { + return false; + } + _param = param.r; + continue ; + }; + }; + var exists = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Curry._2(p, param.v, param.d)) { + return true; + } + if (exists(p, param.l)) { + return true; + } + _param = param.r; + continue ; + }; + }; + var add_min_binding = function (k, x, param) { + if (param) { + return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); + } else { + return singleton(k, x); + } + }; + var add_max_binding = function (k, x, param) { + if (param) { + return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); + } else { + return singleton(k, x); + } + }; + var join = function (l, v, d, r) { + if (!l) { + return add_min_binding(v, d, r); + } + if (!r) { + return add_max_binding(v, d, l); + } + var rh = r.h; + var lh = l.h; + if (lh > (rh + 2 | 0)) { + return bal(l.l, l.v, l.d, join(l.r, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, d, r.l), r.v, r.d, r.r); + } else { + return create(l, v, d, r); + } + }; + var concat = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return join(t1, match[0], match[1], remove_min_binding(t2)); + }; + var concat_or_join = function (t1, v, d, t2) { + if (d !== undefined) { + return join(t1, v, Caml_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } + }; + var split = function (x, param) { + if (!param) { + return [ + /* Empty */0, + undefined, + /* Empty */0 + ]; + } + var r = param.r; + var d = param.d; + var v = param.v; + var l = param.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + return [ + l, + Caml_option.some(d), + r + ]; + } + if (c < 0) { + var match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, d, r) + ]; + } + var match$1 = split(x, r); + return [ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + var merge$1 = function (f, s1, s2) { + if (s1) { + var v1 = s1.v; + if (s1.h >= height(s2)) { + var match = split(v1, s2); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + } + + } else if (!s2) { + return /* Empty */0; + } + if (s2) { + var v2 = s2.v; + var match$1 = split(v2, s1); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "map.ml", + 393, + 10 + ], + Error: new Error() + }; + }; + var union = function (f, s1, s2) { + if (!s1) { + return s2; + } + if (!s2) { + return s1; + } + var d2 = s2.d; + var v2 = s2.v; + var d1 = s1.d; + var v1 = s1.v; + if (s1.h >= s2.h) { + var match = split(v1, s2); + var d2$1 = match[1]; + var l = union(f, s1.l, match[0]); + var r = union(f, s1.r, match[2]); + if (d2$1 !== undefined) { + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); + } else { + return join(l, v1, d1, r); + } + } + var match$1 = split(v2, s1); + var d1$1 = match$1[1]; + var l$1 = union(f, match$1[0], s2.l); + var r$1 = union(f, match$1[2], s2.r); + if (d1$1 !== undefined) { + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); + } else { + return join(l$1, v2, d2, r$1); + } + }; + var filter = function (p, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var l$p = filter(p, l); + var pvd = Curry._2(p, v, d); + var r$p = filter(p, r); + if (pvd) { + if (l === l$p && r === r$p) { + return m; + } else { + return join(l$p, v, d, r$p); + } + } else { + return concat(l$p, r$p); + } + }; + var partition = function (p, param) { + if (!param) { + return [ + /* Empty */0, + /* Empty */0 + ]; + } + var d = param.d; + var v = param.v; + var match = partition(p, param.l); + var lf = match[1]; + var lt = match[0]; + var pvd = Curry._2(p, v, d); + var match$1 = partition(p, param.r); + var rf = match$1[1]; + var rt = match$1[0]; + if (pvd) { + return [ + join(lt, v, d, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, d, rf) + ]; + } + }; + var cardinal = function (param) { + if (param) { + return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; + } else { + return 0; + } + }; + var bindings_aux = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.l; + _accu = { + hd: [ + param.v, + param.d + ], + tl: bindings_aux(accu, param.r) + }; + continue ; + }; + }; + var expect = request.expect; + var responseToResult = expect._1; + var typ = expect._0; + var withCredentials = request.withCredentials; + var timeout = request.timeout; + var body = request.body; + var url = request.url; + var headers = request.headers; + var method = request.method; + return /* Task */{ + _0: (function (cb) { + var enqResError = function (result) { + var partial_arg = { + TAG: /* Error */1, + _0: result + }; + return function (param) { + return Curry._1(cb, partial_arg); + }; + }; + var enqResOk = function (result) { + var partial_arg = { + TAG: /* Ok */0, + _0: result + }; + return function (param) { + return Curry._1(cb, partial_arg); + }; + }; + var xhr = new XMLHttpRequest(); + var partial_arg = { + TAG: /* Error */1, + _0: /* NetworkError */1 + }; + var cb$1 = function (param) { + return Curry._1(cb, partial_arg); + }; + xhr.onerror = cb$1; + var partial_arg$1 = { + TAG: /* Error */1, + _0: /* Timeout */0 + }; + var cb$2 = function (param) { + return Curry._1(cb, partial_arg$1); + }; + xhr.ontimeout = cb$2; + var partial_arg$2 = { + TAG: /* Error */1, + _0: /* Aborted */2 + }; + var cb$3 = function (param) { + return Curry._1(cb, partial_arg$2); + }; + xhr.onabort = cb$3; + var cb$4 = function (_ev) { + var _e = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); + var headers; + headers = _e.TAG === /* Ok */0 ? _e._0 : undefined; + var response_url = xhr.responseURL; + var response_status = { + code: xhr.status, + message: xhr.statusText + }; + var response_body = Web_xmlhttprequest.get_response(xhr); + var response = { + url: response_url, + status: response_status, + headers: headers, + body: response_body + }; + if (response_status.code < 200 || 300 <= response_status.code) { + return enqResError({ + TAG: /* BadStatus */1, + _0: response + })(undefined); + } + var error = Curry._1(responseToResult, response); + if (error.TAG === /* Ok */0) { + return enqResOk(error._0)(undefined); + } else { + return enqResError({ + TAG: /* BadPayload */2, + _0: error._0, + _1: response + })(undefined); + } + }; + xhr.onload = cb$4; + try { + Web_xmlhttprequest.open_(method, url, undefined, undefined, undefined, xhr); + } + catch (exn){ + enqResError({ + TAG: /* BadUrl */0, + _0: url + })(undefined); + } + var setHeader = function (param) { + return Web_xmlhttprequest.setRequestHeader(param._0, param._1, xhr); + }; + List.iter(setHeader, headers); + Web_xmlhttprequest.set_responseType(typ, xhr); + if (timeout !== undefined) { + xhr.timeout = timeout; + } + xhr.withCredentials = withCredentials; + Web_xmlhttprequest.send(body, xhr); + + }) + }; +} + +function send(resultToMessage, param) { + var maybeEvents = param._1; + var request = param._0; + var height = function (param) { + if (param) { + return param.h; + } else { + return 0; + } + }; + var create = function (l, x, d, r) { + var hl = height(l); + var hr = height(r); + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + }; + var singleton = function (x, d) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: d, + r: /* Empty */0, + h: 1 + }; + }; + var bal = function (l, x, d, r) { + var hl = l ? l.h : 0; + var hr = r ? r.h : 0; + if (hl > (hr + 2 | 0)) { + if (l) { + var lr = l.r; + var ld = l.d; + var lv = l.v; + var ll = l.l; + if (height(ll) >= height(lr)) { + return create(ll, lv, ld, create(lr, x, d, r)); + } + if (lr) { + return create(create(ll, lv, ld, lr.l), lr.v, lr.d, create(lr.r, x, d, r)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + if (hr <= (hl + 2 | 0)) { + return /* Node */{ + l: l, + v: x, + d: d, + r: r, + h: hl >= hr ? hl + 1 | 0 : hr + 1 | 0 + }; + } + if (r) { + var rr = r.r; + var rd = r.d; + var rv = r.v; + var rl = r.l; + if (height(rr) >= height(rl)) { + return create(create(l, x, d, rl), rv, rd, rr); + } + if (rl) { + return create(create(l, x, d, rl.l), rl.v, rl.d, create(rl.r, rv, rd, rr)); + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.bal", + Error: new Error() + }; + }; + var add = function (x, data, m) { + if (!m) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: data, + r: /* Empty */0, + h: 1 + }; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + if (d === data) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = add(x, data, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = add(x, data, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var min_binding = function (_param) { + while(true) { + var param = _param; + if (param) { + var l = param.l; + if (!l) { + return [ + param.v, + param.d + ]; + } + _param = l; + continue ; + } + throw { + RE_EXN_ID: "Not_found", + Error: new Error() + }; + }; + }; + var remove_min_binding = function (param) { + if (param) { + var l = param.l; + if (l) { + return bal(remove_min_binding(l), param.v, param.d, param.r); + } else { + return param.r; + } + } + throw { + RE_EXN_ID: "Invalid_argument", + _1: "Map.remove_min_elt", + Error: new Error() + }; + }; + var merge = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return bal(t1, match[0], match[1], remove_min_binding(t2)); + }; + var remove = function (x, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + return merge(l, r); + } + if (c < 0) { + var ll = remove(x, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = remove(x, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + }; + var update = function (x, f, m) { + if (m) { + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + var data = Curry._1(f, Caml_option.some(d)); + if (data === undefined) { + return merge(l, r); + } + var data$1 = Caml_option.valFromOption(data); + if (d === data$1) { + return m; + } else { + return /* Node */{ + l: l, + v: x, + d: data$1, + r: r, + h: m.h + }; + } + } + if (c < 0) { + var ll = update(x, f, l); + if (l === ll) { + return m; + } else { + return bal(ll, v, d, r); + } + } + var rr = update(x, f, r); + if (r === rr) { + return m; + } else { + return bal(l, v, d, rr); + } + } + var data$2 = Curry._1(f, undefined); + if (data$2 !== undefined) { + return /* Node */{ + l: /* Empty */0, + v: x, + d: Caml_option.valFromOption(data$2), + r: /* Empty */0, + h: 1 + }; + } else { + return /* Empty */0; + } + }; + var iter = function (f, _param) { + while(true) { + var param = _param; + if (!param) { + return ; + } + iter(f, param.l); + Curry._2(f, param.v, param.d); + _param = param.r; + continue ; + }; + }; + var map = function (f, param) { + if (!param) { + return /* Empty */0; + } + var l$p = map(f, param.l); + var d$p = Curry._1(f, param.d); + var r$p = map(f, param.r); + return /* Node */{ + l: l$p, + v: param.v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var mapi = function (f, param) { + if (!param) { + return /* Empty */0; + } + var v = param.v; + var l$p = mapi(f, param.l); + var d$p = Curry._2(f, v, param.d); + var r$p = mapi(f, param.r); + return /* Node */{ + l: l$p, + v: v, + d: d$p, + r: r$p, + h: param.h + }; + }; + var fold = function (f, _m, _accu) { + while(true) { + var accu = _accu; + var m = _m; + if (!m) { + return accu; + } + _accu = Curry._3(f, m.v, m.d, fold(f, m.l, accu)); + _m = m.r; + continue ; + }; + }; + var for_all = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return true; + } + if (!Curry._2(p, param.v, param.d)) { + return false; + } + if (!for_all(p, param.l)) { + return false; + } + _param = param.r; + continue ; + }; + }; + var exists = function (p, _param) { + while(true) { + var param = _param; + if (!param) { + return false; + } + if (Curry._2(p, param.v, param.d)) { + return true; + } + if (exists(p, param.l)) { + return true; + } + _param = param.r; + continue ; + }; + }; + var add_min_binding = function (k, x, param) { + if (param) { + return bal(add_min_binding(k, x, param.l), param.v, param.d, param.r); + } else { + return singleton(k, x); + } + }; + var add_max_binding = function (k, x, param) { + if (param) { + return bal(param.l, param.v, param.d, add_max_binding(k, x, param.r)); + } else { + return singleton(k, x); + } + }; + var join = function (l, v, d, r) { + if (!l) { + return add_min_binding(v, d, r); + } + if (!r) { + return add_max_binding(v, d, l); + } + var rh = r.h; + var lh = l.h; + if (lh > (rh + 2 | 0)) { + return bal(l.l, l.v, l.d, join(l.r, v, d, r)); + } else if (rh > (lh + 2 | 0)) { + return bal(join(l, v, d, r.l), r.v, r.d, r.r); + } else { + return create(l, v, d, r); + } + }; + var concat = function (t1, t2) { + if (!t1) { + return t2; + } + if (!t2) { + return t1; + } + var match = min_binding(t2); + return join(t1, match[0], match[1], remove_min_binding(t2)); + }; + var concat_or_join = function (t1, v, d, t2) { + if (d !== undefined) { + return join(t1, v, Caml_option.valFromOption(d), t2); + } else { + return concat(t1, t2); + } + }; + var split = function (x, param) { + if (!param) { + return [ + /* Empty */0, + undefined, + /* Empty */0 + ]; + } + var r = param.r; + var d = param.d; + var v = param.v; + var l = param.l; + var c = Caml.caml_string_compare(x, v); + if (c === 0) { + return [ + l, + Caml_option.some(d), + r + ]; + } + if (c < 0) { + var match = split(x, l); + return [ + match[0], + match[1], + join(match[2], v, d, r) + ]; + } + var match$1 = split(x, r); + return [ + join(l, v, d, match$1[0]), + match$1[1], + match$1[2] + ]; + }; + var merge$1 = function (f, s1, s2) { + if (s1) { + var v1 = s1.v; + if (s1.h >= height(s2)) { + var match = split(v1, s2); + return concat_or_join(merge$1(f, s1.l, match[0]), v1, Curry._3(f, v1, Caml_option.some(s1.d), match[1]), merge$1(f, s1.r, match[2])); + } + + } else if (!s2) { + return /* Empty */0; + } + if (s2) { + var v2 = s2.v; + var match$1 = split(v2, s1); + return concat_or_join(merge$1(f, match$1[0], s2.l), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2.d)), merge$1(f, match$1[2], s2.r)); + } + throw { + RE_EXN_ID: "Assert_failure", + _1: [ + "map.ml", + 393, + 10 + ], + Error: new Error() + }; + }; + var union = function (f, s1, s2) { + if (!s1) { + return s2; + } + if (!s2) { + return s1; + } + var d2 = s2.d; + var v2 = s2.v; + var d1 = s1.d; + var v1 = s1.v; + if (s1.h >= s2.h) { + var match = split(v1, s2); + var d2$1 = match[1]; + var l = union(f, s1.l, match[0]); + var r = union(f, s1.r, match[2]); + if (d2$1 !== undefined) { + return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); + } else { + return join(l, v1, d1, r); + } + } + var match$1 = split(v2, s1); + var d1$1 = match$1[1]; + var l$1 = union(f, match$1[0], s2.l); + var r$1 = union(f, match$1[2], s2.r); + if (d1$1 !== undefined) { + return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); + } else { + return join(l$1, v2, d2, r$1); + } + }; + var filter = function (p, m) { + if (!m) { + return /* Empty */0; + } + var r = m.r; + var d = m.d; + var v = m.v; + var l = m.l; + var l$p = filter(p, l); + var pvd = Curry._2(p, v, d); + var r$p = filter(p, r); + if (pvd) { + if (l === l$p && r === r$p) { + return m; + } else { + return join(l$p, v, d, r$p); + } + } else { + return concat(l$p, r$p); + } + }; + var partition = function (p, param) { + if (!param) { + return [ + /* Empty */0, + /* Empty */0 + ]; + } + var d = param.d; + var v = param.v; + var match = partition(p, param.l); + var lf = match[1]; + var lt = match[0]; + var pvd = Curry._2(p, v, d); + var match$1 = partition(p, param.r); + var rf = match$1[1]; + var rt = match$1[0]; + if (pvd) { + return [ + join(lt, v, d, rt), + concat(lf, rf) + ]; + } else { + return [ + concat(lt, rt), + join(lf, v, d, rf) + ]; + } + }; + var cardinal = function (param) { + if (param) { + return (cardinal(param.l) + 1 | 0) + cardinal(param.r) | 0; + } else { + return 0; + } + }; + var bindings_aux = function (_accu, _param) { + while(true) { + var param = _param; + var accu = _accu; + if (!param) { + return accu; + } + _param = param.l; + _accu = { + hd: [ + param.v, + param.d + ], + tl: bindings_aux(accu, param.r) + }; + continue ; + }; + }; + var expect = request.expect; + var responseToResult = expect._1; + var typ = expect._0; + var withCredentials = request.withCredentials; + var timeout = request.timeout; + var body = request.body; + var url = request.url; + var headers = request.headers; + var method = request.method; + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + var enqRes = function (result, _ev) { + return Curry._1(callbacks.contents.enqueue, Curry._1(resultToMessage, result)); + }; + var enqResError = function (result) { + var partial_arg = { + TAG: /* Error */1, + _0: result + }; + return function (param) { + return enqRes(partial_arg, param); + }; + }; + var enqResOk = function (result) { + var partial_arg = { + TAG: /* Ok */0, + _0: result + }; + return function (param) { + return enqRes(partial_arg, param); + }; + }; + var xhr = new XMLHttpRequest(); + if (maybeEvents !== undefined) { + var mayCB = function (thenDo, x) { + if (x !== undefined) { + return Curry._1(thenDo, Curry._1(x, callbacks)); + } + + }; + mayCB((function (param) { + xhr.onreadystatechange = param; + + }), maybeEvents.onreadystatechange); + mayCB((function (param) { + xhr.onprogress = param; + + }), maybeEvents.onprogress); + } + var partial_arg = { + TAG: /* Error */1, + _0: /* NetworkError */1 + }; + var cb = function (param) { + return enqRes(partial_arg, param); + }; + xhr.onerror = cb; + var partial_arg$1 = { + TAG: /* Error */1, + _0: /* Timeout */0 + }; + var cb$1 = function (param) { + return enqRes(partial_arg$1, param); + }; + xhr.ontimeout = cb$1; + var partial_arg$2 = { + TAG: /* Error */1, + _0: /* Aborted */2 + }; + var cb$2 = function (param) { + return enqRes(partial_arg$2, param); + }; + xhr.onabort = cb$2; + var cb$3 = function (_ev) { + var _e = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); + var headers; + headers = _e.TAG === /* Ok */0 ? _e._0 : undefined; + var response_url = xhr.responseURL; + var response_status = { + code: xhr.status, + message: xhr.statusText + }; + var response_body = Web_xmlhttprequest.get_response(xhr); + var response = { + url: response_url, + status: response_status, + headers: headers, + body: response_body + }; + if (response_status.code < 200 || 300 <= response_status.code) { + return enqResError({ + TAG: /* BadStatus */1, + _0: response + })(undefined); + } + var error = Curry._1(responseToResult, response); + if (error.TAG === /* Ok */0) { + return enqResOk(error._0)(undefined); + } else { + return enqResError({ + TAG: /* BadPayload */2, + _0: error._0, + _1: response + })(undefined); + } + }; + xhr.onload = cb$3; + try { + Web_xmlhttprequest.open_(method, url, undefined, undefined, undefined, xhr); + } + catch (exn){ + enqResError({ + TAG: /* BadUrl */0, + _0: url + })(undefined); + } + var setHeader = function (param) { + return Web_xmlhttprequest.setRequestHeader(param._0, param._1, xhr); + }; + List.iter(setHeader, headers); + Web_xmlhttprequest.set_responseType(typ, xhr); + if (timeout !== undefined) { + xhr.timeout = timeout; + } + xhr.withCredentials = withCredentials; + Web_xmlhttprequest.send(body, xhr); + + }) + }; +} + +function encodeUri(str) { + return encodeURIComponent(str); +} + +function decodeUri(str) { + try { + return decodeURIComponent(str); + } + catch (exn){ + return ; + } +} + +function track(toMessage, param) { + var events = param._1; + var onprogress = (function (callbacks, ev) { + var _e = Json_Decode$JsonCombinators.decode(ev, Json_Decode$JsonCombinators.field("lengthComputable", Json_Decode$JsonCombinators.bool)); + var lengthComputable; + lengthComputable = _e.TAG === /* Ok */0 ? _e._0 : false; + if (!lengthComputable) { + return ; + } + var decoder = Json_Decode$JsonCombinators.object(function (field) { + return { + bytes: field.required("loaded", Json_Decode$JsonCombinators.$$int), + bytesExpected: field.required("total", Json_Decode$JsonCombinators.$$int) + }; + }); + var _e$1 = Json_Decode$JsonCombinators.decode(ev, decoder); + if (_e$1.TAG === /* Ok */0) { + return Curry._1(callbacks.contents.enqueue, Curry._1(toMessage, _e$1._0)); + } + + }); + var events$1 = events !== undefined ? events : emptyRequestEvents; + return /* Request */{ + _0: param._0, + _1: { + onreadystatechange: events$1.onreadystatechange, + onprogress: onprogress + } + }; +} + +var Progress_emptyProgress = { + bytes: 0, + bytesExpected: 0 +}; + +var Progress = { + emptyProgress: Progress_emptyProgress, + track: track +}; + +exports.stringOfError = stringOfError; +exports.emptyRequestEvents = emptyRequestEvents; +exports.expectStringResponse = expectStringResponse; +exports.expectString = expectString; +exports.request = request; +exports.getString = getString; +exports.toTask = toTask; +exports.send = send; +exports.encodeUri = encodeUri; +exports.decodeUri = decodeUri; +exports.Progress = Progress; +/* expectString Not a pure module */ diff --git a/lib/js/src/tea_mouse.js b/lib/js/src/tea_mouse.js new file mode 100644 index 0000000..1594884 --- /dev/null +++ b/lib/js/src/tea_mouse.js @@ -0,0 +1,71 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); +var Tea_sub = require("./tea_sub.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Json$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json.js"); +var Json_Decode$JsonCombinators = require("@glennsl/rescript-json-combinators/lib/js/src/Json_Decode.js"); + +var position = Json_Decode$JsonCombinators.object(function (field) { + return { + x: field.required("pageX", Json_Decode$JsonCombinators.$$int), + y: field.required("pageY", Json_Decode$JsonCombinators.$$int) + }; + }); + +function registerGlobal(name, key, tagger) { + var enableCall = function (callbacks_base) { + var callbacks = { + contents: callbacks_base + }; + var fn = function (ev) { + var pos = Json$JsonCombinators.decode(ev, position); + if (pos.TAG === /* Ok */0) { + return Caml_option.some(Curry._1(tagger, pos._0)); + } + + }; + var handler = { + TAG: /* EventHandlerCallback */0, + _0: key, + _1: fn + }; + var elem = document; + var cache = Vdom.eventHandlerRegister(callbacks, elem, name, handler); + return function (param) { + Vdom.eventHandlerUnregister(elem, name, cache); + + }; + }; + return Tea_sub.registration(key, enableCall); +} + +function clicks(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return registerGlobal("click", key, tagger); +} + +function moves(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return registerGlobal("mousemove", key, tagger); +} + +function downs(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return registerGlobal("mousedown", key, tagger); +} + +function ups(keyOpt, tagger) { + var key = keyOpt !== undefined ? keyOpt : ""; + return registerGlobal("mouseup", key, tagger); +} + +exports.position = position; +exports.registerGlobal = registerGlobal; +exports.clicks = clicks; +exports.moves = moves; +exports.downs = downs; +exports.ups = ups; +/* position Not a pure module */ diff --git a/lib/js/src-ocaml/tea_navigation.js b/lib/js/src/tea_navigation.js similarity index 57% rename from lib/js/src-ocaml/tea_navigation.js rename to lib/js/src/tea_navigation.js index cdff7ab..c991737 100644 --- a/lib/js/src-ocaml/tea_navigation.js +++ b/lib/js/src/tea_navigation.js @@ -1,8 +1,7 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); +var Curry = require("rescript/lib/js/curry.js"); var Tea_app = require("./tea_app.js"); var Tea_sub = require("./tea_sub.js"); var Web_window = require("./web_window.js"); @@ -18,14 +17,13 @@ var notifier = { }; function notifyUrlChange(param) { - var match = notifier.contents; - if (match !== undefined) { - var $$location = Web_location.asRecord(document.location); - Curry._1(match, $$location); - return /* () */0; - } else { - return /* () */0; + var cb = notifier.contents; + if (cb === undefined) { + return ; } + var $$location = Web_location.asRecord(document.location); + Curry._1(cb, $$location); + } function subscribe(tagger) { @@ -35,48 +33,57 @@ function subscribe(tagger) { }; notifier.contents = notifyHandler; var handler = function (_event) { - return notifyUrlChange(/* () */0); + return notifyUrlChange(undefined); }; Web_window.addEventListener("popstate", handler, false); - return (function (param) { - return Web_window.removeEventListener("popstate", handler, false); - }); + return function (param) { + return Web_window.removeEventListener("popstate", handler, false); + }; }; return Tea_sub.registration("navigation", enableCall); } function replaceState(url) { Web_window_history.replaceState(window, JSON.parse("{}"), "", url); - return /* () */0; + } function pushState(url) { Web_window_history.pushState(window, JSON.parse("{}"), "", url); - return /* () */0; + } function modifyUrl(url) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - replaceState(url); - notifyUrlChange(/* () */0); - return /* () */0; - })]); + return { + TAG: /* EnqueueCall */2, + _0: (function (_enqueue) { + replaceState(url); + notifyUrlChange(undefined); + + }) + }; } function newUrl(url) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - pushState(url); - notifyUrlChange(/* () */0); - return /* () */0; - })]); + return { + TAG: /* EnqueueCall */2, + _0: (function (_enqueue) { + pushState(url); + notifyUrlChange(undefined); + + }) + }; } function go(step) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - Web_window_history.go(window, step); - notifyUrlChange(/* () */0); - return /* () */0; - })]); + return { + TAG: /* EnqueueCall */2, + _0: (function (_enqueue) { + Web_window_history.go(window, step); + notifyUrlChange(undefined); + + }) + }; } function back(step) { @@ -90,13 +97,16 @@ function navigationProgram(locationToMessage, stuff) { return Curry._2(stuff.init, flag, Web_location.asRecord(document.location)); }; var subscriptions = function (model) { - return /* Batch */Block.__(0, [/* :: */[ - subscribe(locationToMessage), - /* :: */[ - Curry._1(stuff.subscriptions, model), - /* [] */0 - ] - ]]); + return { + TAG: /* Batch */0, + _0: { + hd: subscribe(locationToMessage), + tl: { + hd: Curry._1(stuff.subscriptions, model), + tl: /* [] */0 + } + } + }; }; var partial_arg_update = stuff.update; var partial_arg_view = stuff.view; @@ -108,9 +118,9 @@ function navigationProgram(locationToMessage, stuff) { subscriptions: subscriptions, shutdown: partial_arg_shutdown }; - return (function (param, param$1) { - return Tea_app.program(partial_arg, param, param$1); - }); + return function (param, param$1) { + return Tea_app.program(partial_arg, param, param$1); + }; } exports.getLocation = getLocation; diff --git a/lib/js/src/tea_program.js b/lib/js/src/tea_program.js new file mode 100644 index 0000000..8860a24 --- /dev/null +++ b/lib/js/src/tea_program.js @@ -0,0 +1,31 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function spawn(initState, update, shutdown) { + var state = { + contents: Caml_option.some(initState) + }; + return function (procMsg) { + var model = state.contents; + if (model === undefined) { + return ; + } + var model$1 = Caml_option.valFromOption(model); + if (procMsg) { + state.contents = Curry._2(update, model$1, procMsg._0); + } else { + Curry._1(shutdown, model$1); + state.contents = undefined; + } + + }; +} + +var testing1 = 42; + +exports.spawn = spawn; +exports.testing1 = testing1; +/* No side effect */ diff --git a/lib/js/src/tea_promise.js b/lib/js/src/tea_promise.js new file mode 100644 index 0000000..41afbb1 --- /dev/null +++ b/lib/js/src/tea_promise.js @@ -0,0 +1,50 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function cmd(promise, tagger) { + return { + TAG: /* EnqueueCall */2, + _0: (function (x) { + promise.then(function (x$1) { + var msg = Curry._1(tagger, x$1); + if (msg !== undefined) { + Curry._1(x.contents.enqueue, Caml_option.valFromOption(msg)); + return Promise.resolve(undefined); + } else { + return Promise.resolve(undefined); + } + }); + + }) + }; +} + +function result(promise, msg) { + return { + TAG: /* EnqueueCall */2, + _0: (function (x) { + var enq = function (result) { + return Curry._1(x.contents.enqueue, Curry._1(msg, result)); + }; + promise.then(function (x) { + return Promise.resolve(enq({ + TAG: /* Ok */0, + _0: x + })); + }).catch(function (x) { + return Promise.resolve(enq({ + TAG: /* Error */1, + _0: "" + x + })); + }); + + }) + }; +} + +exports.cmd = cmd; +exports.result = result; +/* No side effect */ diff --git a/lib/js/src/tea_random.js b/lib/js/src/tea_random.js new file mode 100644 index 0000000..3790156 --- /dev/null +++ b/lib/js/src/tea_random.js @@ -0,0 +1,208 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Random = require("rescript/lib/js/random.js"); +var Pervasives = require("rescript/lib/js/pervasives.js"); + +Random.self_init(undefined); + +var bool = /* Generator */{ + _0: (function (state) { + return Random.State.bool(state); + }) +}; + +function $$int(min, max) { + var match = min < max ? [ + min, + max + ] : [ + max, + min + ]; + var max$1 = match[1]; + var min$1 = match[0]; + return /* Generator */{ + _0: (function (state) { + return min$1 + Random.State.$$int(state, (max$1 - min$1 | 0) + 1 | 0) | 0; + }) + }; +} + +function $$float(min, max) { + return /* Generator */{ + _0: (function (state) { + return min + Random.State.$$float(state, max - min); + }) + }; +} + +function list(count, genCmd) { + var genCmd$1 = genCmd._0; + return /* Generator */{ + _0: (function (state) { + var _i = count; + var _acc = /* [] */0; + while(true) { + var acc = _acc; + var i = _i; + if (i <= 0) { + return acc; + } + _acc = { + hd: Curry._1(genCmd$1, state), + tl: acc + }; + _i = i - 1 | 0; + continue ; + }; + }) + }; +} + +function map(func, genCmd) { + var genCmd$1 = genCmd._0; + return /* Generator */{ + _0: (function (state) { + return Curry._1(func, Curry._1(genCmd$1, state)); + }) + }; +} + +function map2(func, genCmd1, genCmd2) { + var genCmd2$1 = genCmd2._0; + var genCmd1$1 = genCmd1._0; + return /* Generator */{ + _0: (function (state) { + var res1 = Curry._1(genCmd1$1, state); + var res2 = Curry._1(genCmd2$1, state); + return Curry._2(func, res1, res2); + }) + }; +} + +function map3(func, genCmd1, genCmd2, genCmd3) { + var genCmd3$1 = genCmd3._0; + var genCmd2$1 = genCmd2._0; + var genCmd1$1 = genCmd1._0; + return /* Generator */{ + _0: (function (state) { + var res1 = Curry._1(genCmd1$1, state); + var res2 = Curry._1(genCmd2$1, state); + var res3 = Curry._1(genCmd3$1, state); + return Curry._3(func, res1, res2, res3); + }) + }; +} + +function map4(func, genCmd1, genCmd2, genCmd3, genCmd4) { + var genCmd4$1 = genCmd4._0; + var genCmd3$1 = genCmd3._0; + var genCmd2$1 = genCmd2._0; + var genCmd1$1 = genCmd1._0; + return /* Generator */{ + _0: (function (state) { + var res1 = Curry._1(genCmd1$1, state); + var res2 = Curry._1(genCmd2$1, state); + var res3 = Curry._1(genCmd3$1, state); + var res4 = Curry._1(genCmd4$1, state); + return Curry._4(func, res1, res2, res3, res4); + }) + }; +} + +function map5(func, genCmd1, genCmd2, genCmd3, genCmd4, genCmd5) { + var genCmd5$1 = genCmd5._0; + var genCmd4$1 = genCmd4._0; + var genCmd3$1 = genCmd3._0; + var genCmd2$1 = genCmd2._0; + var genCmd1$1 = genCmd1._0; + return /* Generator */{ + _0: (function (state) { + var res1 = Curry._1(genCmd1$1, state); + var res2 = Curry._1(genCmd2$1, state); + var res3 = Curry._1(genCmd3$1, state); + var res4 = Curry._1(genCmd4$1, state); + var res5 = Curry._1(genCmd5$1, state); + return Curry._5(func, res1, res2, res3, res4, res5); + }) + }; +} + +function andThen(func, genCmd) { + var genCmd$1 = genCmd._0; + return /* Generator */{ + _0: (function (state) { + var res = Curry._1(genCmd$1, state); + var userGen = Curry._1(func, res); + return Curry._1(userGen._0, state); + }) + }; +} + +function pair(gen1, gen2) { + return map2((function (a, b) { + return [ + a, + b + ]; + }), gen1, gen2); +} + +function generate(tagger, genCmd) { + var genCmd$1 = genCmd._0; + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + var state = Random.get_state(undefined); + var genValue = Curry._1(genCmd$1, state); + Random.set_state(state); + return Curry._1(callbacks.contents.enqueue, Curry._1(tagger, genValue)); + }) + }; +} + +function step(genCmd, state) { + var newState = Random.State.copy(state._0); + return [ + Curry._1(genCmd._0, newState), + /* Seed */{ + _0: newState + } + ]; +} + +function initialSeed(seed) { + return /* Seed */{ + _0: Random.State.make([seed]) + }; +} + +var minInt = Pervasives.min_int; + +var maxInt = Pervasives.max_int; + +var minFloat = Pervasives.min_float; + +var maxFloat = Pervasives.max_float; + +exports.minInt = minInt; +exports.maxInt = maxInt; +exports.minFloat = minFloat; +exports.maxFloat = maxFloat; +exports.bool = bool; +exports.$$int = $$int; +exports.$$float = $$float; +exports.list = list; +exports.map = map; +exports.map2 = map2; +exports.map3 = map3; +exports.map4 = map4; +exports.map5 = map5; +exports.andThen = andThen; +exports.pair = pair; +exports.generate = generate; +exports.step = step; +exports.initialSeed = initialSeed; +/* Not a pure module */ diff --git a/lib/js/src/tea_result.js b/lib/js/src/tea_result.js new file mode 100644 index 0000000..b95088d --- /dev/null +++ b/lib/js/src/tea_result.js @@ -0,0 +1,23 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function first(fst, x) { + if (x.TAG === /* Ok */0) { + return fst; + } else { + return x; + } +} + +function resultToOption(x) { + if (x.TAG === /* Ok */0) { + return Caml_option.some(x._0); + } + +} + +exports.first = first; +exports.resultToOption = resultToOption; +/* No side effect */ diff --git a/lib/js/src/tea_sub.js b/lib/js/src/tea_sub.js new file mode 100644 index 0000000..3147dfb --- /dev/null +++ b/lib/js/src/tea_sub.js @@ -0,0 +1,186 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var Vdom = require("./vdom.js"); +var Curry = require("rescript/lib/js/curry.js"); + +function batch(subs) { + return { + TAG: /* Batch */0, + _0: subs + }; +} + +function registration(key, enableCall) { + return { + TAG: /* Registration */1, + _0: key, + _1: (function (callbacks) { + return Curry._1(enableCall, callbacks.contents); + }), + _2: { + contents: undefined + } + }; +} + +function map(msgMapper, sub) { + var func = function (callbacks) { + return Vdom.wrapCallbacks(msgMapper, callbacks); + }; + return { + TAG: /* Mapper */2, + _0: func, + _1: sub + }; +} + +function mapFunc(func, sub) { + return { + TAG: /* Mapper */2, + _0: func, + _1: sub + }; +} + +function run(oldCallbacks, newCallbacks, oldSub, newSub) { + var enable = function (_callbacks, _x) { + while(true) { + var x = _x; + var callbacks = _callbacks; + if (typeof x === "number") { + return ; + } + switch (x.TAG | 0) { + case /* Batch */0 : + var subs = x._0; + if (subs) { + return List.iter((function(callbacks){ + return function (param) { + return enable(callbacks, param); + } + }(callbacks)), subs); + } else { + return ; + } + case /* Registration */1 : + x._2.contents = Curry._1(x._1, callbacks); + return ; + case /* Mapper */2 : + var subCallbacks = Curry._1(x._0, callbacks); + _x = x._1; + _callbacks = subCallbacks; + continue ; + + } + }; + }; + var disable = function (_callbacks, _x) { + while(true) { + var x = _x; + var callbacks = _callbacks; + if (typeof x === "number") { + return ; + } + switch (x.TAG | 0) { + case /* Batch */0 : + var subs = x._0; + if (subs) { + return List.iter((function(callbacks){ + return function (param) { + return disable(callbacks, param); + } + }(callbacks)), subs); + } else { + return ; + } + case /* Registration */1 : + var diCB = x._2; + var cb = diCB.contents; + if (cb !== undefined) { + diCB.contents = undefined; + return Curry._1(cb, undefined); + } else { + return ; + } + case /* Mapper */2 : + var subCallbacks = Curry._1(x._0, callbacks); + _x = x._1; + _callbacks = subCallbacks; + continue ; + + } + }; + }; + if (typeof oldSub === "number") { + if (typeof newSub === "number") { + return newSub; + } + + } else { + switch (oldSub.TAG | 0) { + case /* Batch */0 : + if (typeof newSub !== "number" && newSub.TAG === /* Batch */0) { + var aux = function (_oldList, _newList) { + while(true) { + var newList = _newList; + var oldList = _oldList; + if (oldList) { + var oldRest = oldList.tl; + var oldSubSub = oldList.hd; + if (newList) { + run(oldCallbacks, newCallbacks, oldSubSub, newList.hd); + _newList = newList.tl; + _oldList = oldRest; + continue ; + } + disable(oldCallbacks, oldSubSub); + _newList = /* [] */0; + _oldList = oldRest; + continue ; + } + if (!newList) { + return ; + } + enable(newCallbacks, newList.hd); + _newList = newList.tl; + _oldList = /* [] */0; + continue ; + }; + }; + aux(oldSub._0, newSub._0); + return newSub; + } + break; + case /* Registration */1 : + if (typeof newSub !== "number" && newSub.TAG === /* Registration */1 && oldSub._0 === newSub._0) { + newSub._2.contents = oldSub._2.contents; + return newSub; + } + break; + case /* Mapper */2 : + if (typeof newSub !== "number" && newSub.TAG === /* Mapper */2) { + var olderCallbacks = Curry._1(oldSub._0, oldCallbacks); + var newerCallbacks = Curry._1(newSub._0, newCallbacks); + run(olderCallbacks, newerCallbacks, oldSub._1, newSub._1); + return newSub; + } + break; + + } + } + disable(oldCallbacks, oldSub); + enable(newCallbacks, newSub); + return newSub; +} + +var none = /* NoSub */0; + +exports.none = none; +exports.batch = batch; +exports.registration = registration; +exports.map = map; +exports.mapFunc = mapFunc; +exports.run = run; +/* No side effect */ diff --git a/lib/js/src/tea_svg.js b/lib/js/src/tea_svg.js new file mode 100644 index 0000000..cec16f6 --- /dev/null +++ b/lib/js/src/tea_svg.js @@ -0,0 +1,599 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Vdom = require("./vdom.js"); + +var svgNamespace = "http://www.w3.org/2000/svg"; + +function text(str) { + return { + TAG: /* Text */1, + _0: str + }; +} + +var lazy1 = Vdom.lazyGen; + +function node(tagName, keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, tagName, key, unique, props, nodes); +} + +function svg(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "svg", key, unique, props, nodes); +} + +function foreignObject(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "foreignObject", key, unique, props, nodes); +} + +function animate(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "animate", key, unique, props, nodes); +} + +function animateColor(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "animateColor", key, unique, props, nodes); +} + +function animateMotion(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "animateMotion", key, unique, props, nodes); +} + +function animateTransform(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "animateTransform", key, unique, props, nodes); +} + +function mpath(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "mpath", key, unique, props, nodes); +} + +function set(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "set", key, unique, props, nodes); +} + +function a(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "a", key, unique, props, nodes); +} + +function defs(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "defs", key, unique, props, nodes); +} + +function g(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "g", key, unique, props, nodes); +} + +function marker(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "marker", key, unique, props, nodes); +} + +function mask(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "mask", key, unique, props, nodes); +} + +function missingGlyph(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "missingGlyph", key, unique, props, nodes); +} + +function pattern(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "pattern", key, unique, props, nodes); +} + +function switch$p(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "switch", key, unique, props, nodes); +} + +function symbol(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "symbol", key, unique, props, nodes); +} + +function desc(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "desc", key, unique, props, nodes); +} + +function metadata(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "metadata", key, unique, props, nodes); +} + +function title(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "title", key, unique, props, nodes); +} + +function feBlend(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feBlend", key, unique, props, nodes); +} + +function feColorMatrix(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feColorMatrix", key, unique, props, nodes); +} + +function feComponentTransfer(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feComponentTransfer", key, unique, props, nodes); +} + +function feComposite(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feComposite", key, unique, props, nodes); +} + +function feConvolveMatrix(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feConvolveMatrix", key, unique, props, nodes); +} + +function feDiffuseLighting(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feDiffuseLighting", key, unique, props, nodes); +} + +function feDisplacementMap(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feDisplacementMap", key, unique, props, nodes); +} + +function feFlood(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feFlood", key, unique, props, nodes); +} + +function feFuncA(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feFuncA", key, unique, props, nodes); +} + +function feFuncB(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feFuncB", key, unique, props, nodes); +} + +function feFuncG(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feFuncG", key, unique, props, nodes); +} + +function feFuncR(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feFuncR", key, unique, props, nodes); +} + +function feGaussianBlur(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feGaussianBlur", key, unique, props, nodes); +} + +function feImage(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feImage", key, unique, props, nodes); +} + +function feMerge(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feMerge", key, unique, props, nodes); +} + +function feMergeNode(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feMergeNode", key, unique, props, nodes); +} + +function feMorphology(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feMorphology", key, unique, props, nodes); +} + +function feOffset(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feOffset", key, unique, props, nodes); +} + +function feSpecularLighting(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feSpecularLighting", key, unique, props, nodes); +} + +function feTile(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feTile", key, unique, props, nodes); +} + +function feTurbulence(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feTurbulence", key, unique, props, nodes); +} + +function font(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "font", key, unique, props, nodes); +} + +function fontFace(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fontFace", key, unique, props, nodes); +} + +function fontFaceFormat(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fontFaceFormat", key, unique, props, nodes); +} + +function fontFaceName(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fontFaceName", key, unique, props, nodes); +} + +function fontFaceSrc(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fontFaceSrc", key, unique, props, nodes); +} + +function fontFaceUri(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fontFaceUri", key, unique, props, nodes); +} + +function hkern(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "hkern", key, unique, props, nodes); +} + +function vkern(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "vkern", key, unique, props, nodes); +} + +function linearGradient(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "linearGradient", key, unique, props, nodes); +} + +function radialGradient(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "radialGradient", key, unique, props, nodes); +} + +function stop(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "stop", key, unique, props, nodes); +} + +function circle(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "circle", key, unique, props, nodes); +} + +function ellipse(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "ellipse", key, unique, props, nodes); +} + +function svgimage(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "image", key, unique, props, nodes); +} + +function line(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "line", key, unique, props, nodes); +} + +function path(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "path", key, unique, props, nodes); +} + +function polygon(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "polygon", key, unique, props, nodes); +} + +function polyline(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "polyline", key, unique, props, nodes); +} + +function rect(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "rect", key, unique, props, nodes); +} + +function use(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "use", key, unique, props, nodes); +} + +function feDistantLight(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feDistantLight", key, unique, props, nodes); +} + +function fePointLight(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "fePointLight", key, unique, props, nodes); +} + +function feSpotLight(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "feSpotLight", key, unique, props, nodes); +} + +function altGlyph(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "altGlyph", key, unique, props, nodes); +} + +function altGlyphDef(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "altGlyphDef", key, unique, props, nodes); +} + +function altGlyphItem(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "altGlyphItem", key, unique, props, nodes); +} + +function glyph(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "glyph", key, unique, props, nodes); +} + +function glyphRef(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "glyphRef", key, unique, props, nodes); +} + +function textPath(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "textPath", key, unique, props, nodes); +} + +function text$p(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "text", key, unique, props, nodes); +} + +function tref(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "tref", key, unique, props, nodes); +} + +function tspan(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "tspan", key, unique, props, nodes); +} + +function clipPath(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "clipPath", key, unique, props, nodes); +} + +function svgcolorProfile(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "colorProfile", key, unique, props, nodes); +} + +function cursor(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "cursor", key, unique, props, nodes); +} + +function filter(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "filter", key, unique, props, nodes); +} + +function script(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "script", key, unique, props, nodes); +} + +function style(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "style", key, unique, props, nodes); +} + +function view(keyOpt, uniqueOpt, props, nodes) { + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return Vdom.fullnode(svgNamespace, "view", key, unique, props, nodes); +} + +var Cmds; + +var Attributes; + +var Events; + +var noNode = Vdom.noNode; + +exports.Cmds = Cmds; +exports.Attributes = Attributes; +exports.Events = Events; +exports.svgNamespace = svgNamespace; +exports.noNode = noNode; +exports.text = text; +exports.lazy1 = lazy1; +exports.node = node; +exports.svg = svg; +exports.foreignObject = foreignObject; +exports.animate = animate; +exports.animateColor = animateColor; +exports.animateMotion = animateMotion; +exports.animateTransform = animateTransform; +exports.mpath = mpath; +exports.set = set; +exports.a = a; +exports.defs = defs; +exports.g = g; +exports.marker = marker; +exports.mask = mask; +exports.missingGlyph = missingGlyph; +exports.pattern = pattern; +exports.switch$p = switch$p; +exports.symbol = symbol; +exports.desc = desc; +exports.metadata = metadata; +exports.title = title; +exports.feBlend = feBlend; +exports.feColorMatrix = feColorMatrix; +exports.feComponentTransfer = feComponentTransfer; +exports.feComposite = feComposite; +exports.feConvolveMatrix = feConvolveMatrix; +exports.feDiffuseLighting = feDiffuseLighting; +exports.feDisplacementMap = feDisplacementMap; +exports.feFlood = feFlood; +exports.feFuncA = feFuncA; +exports.feFuncB = feFuncB; +exports.feFuncG = feFuncG; +exports.feFuncR = feFuncR; +exports.feGaussianBlur = feGaussianBlur; +exports.feImage = feImage; +exports.feMerge = feMerge; +exports.feMergeNode = feMergeNode; +exports.feMorphology = feMorphology; +exports.feOffset = feOffset; +exports.feSpecularLighting = feSpecularLighting; +exports.feTile = feTile; +exports.feTurbulence = feTurbulence; +exports.font = font; +exports.fontFace = fontFace; +exports.fontFaceFormat = fontFaceFormat; +exports.fontFaceName = fontFaceName; +exports.fontFaceSrc = fontFaceSrc; +exports.fontFaceUri = fontFaceUri; +exports.hkern = hkern; +exports.vkern = vkern; +exports.linearGradient = linearGradient; +exports.radialGradient = radialGradient; +exports.stop = stop; +exports.circle = circle; +exports.ellipse = ellipse; +exports.svgimage = svgimage; +exports.line = line; +exports.path = path; +exports.polygon = polygon; +exports.polyline = polyline; +exports.rect = rect; +exports.use = use; +exports.feDistantLight = feDistantLight; +exports.fePointLight = fePointLight; +exports.feSpotLight = feSpotLight; +exports.altGlyph = altGlyph; +exports.altGlyphDef = altGlyphDef; +exports.altGlyphItem = altGlyphItem; +exports.glyph = glyph; +exports.glyphRef = glyphRef; +exports.textPath = textPath; +exports.text$p = text$p; +exports.tref = tref; +exports.tspan = tspan; +exports.clipPath = clipPath; +exports.svgcolorProfile = svgcolorProfile; +exports.cursor = cursor; +exports.filter = filter; +exports.script = script; +exports.style = style; +exports.view = view; +/* No side effect */ diff --git a/lib/js/src/tea_svg_attributes.js b/lib/js/src/tea_svg_attributes.js new file mode 100644 index 0000000..230ecf4 --- /dev/null +++ b/lib/js/src/tea_svg_attributes.js @@ -0,0 +1,2535 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + + +function accentHeight(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "accent-height", + _2: v + }; +} + +function accelerate(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "accelerate", + _2: v + }; +} + +function accumulate(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "accumulate", + _2: v + }; +} + +function additive(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "additive", + _2: v + }; +} + +function alphabetic(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "alphabetic", + _2: v + }; +} + +function allowReorder(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "allowReorder", + _2: v + }; +} + +function amplitude(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "amplitude", + _2: v + }; +} + +function arabicForm(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "arabic-form", + _2: v + }; +} + +function ascent(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "ascent", + _2: v + }; +} + +function attributeName(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "attributeName", + _2: v + }; +} + +function attributeType(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "attributeType", + _2: v + }; +} + +function autoReverse(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "autoReverse", + _2: v + }; +} + +function azimuth(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "azimuth", + _2: v + }; +} + +function baseFrequency(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "baseFrequency", + _2: v + }; +} + +function baseProfile(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "baseProfile", + _2: v + }; +} + +function bbox(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "bbox", + _2: v + }; +} + +function begin(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "begin", + _2: v + }; +} + +function bias(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "bias", + _2: v + }; +} + +function by(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "by", + _2: v + }; +} + +function calcMode(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "calcMode", + _2: v + }; +} + +function capHeight(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "cap-height", + _2: v + }; +} + +function $$class(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "class", + _2: v + }; +} + +function clipPathUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "clipPathUnits", + _2: v + }; +} + +function contentScriptType(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "contentScriptType", + _2: v + }; +} + +function contentStyleType(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "contentStyleType", + _2: v + }; +} + +function cx(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "cx", + _2: v + }; +} + +function cy(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "cy", + _2: v + }; +} + +function d(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "d", + _2: v + }; +} + +function decelerate(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "decelerate", + _2: v + }; +} + +function descent(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "descent", + _2: v + }; +} + +function diffuseConstant(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "diffuseConstant", + _2: v + }; +} + +function divisor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "divisor", + _2: v + }; +} + +function dur(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "dur", + _2: v + }; +} + +function dx(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "dx", + _2: v + }; +} + +function dy(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "dy", + _2: v + }; +} + +function edgeMode(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "edgeMode", + _2: v + }; +} + +function elevation(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "elevation", + _2: v + }; +} + +function end(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "end", + _2: v + }; +} + +function exponent(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "exponent", + _2: v + }; +} + +function externalResourcesRequired(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "externalResourcesRequired", + _2: v + }; +} + +function filterRes(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "filterRes", + _2: v + }; +} + +function filterUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "filterUnits", + _2: v + }; +} + +function format(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "format", + _2: v + }; +} + +function from(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "from", + _2: v + }; +} + +function fx(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "fx", + _2: v + }; +} + +function fy(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "fy", + _2: v + }; +} + +function g1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "g1", + _2: v + }; +} + +function g2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "g2", + _2: v + }; +} + +function glyphName(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "glyph-name", + _2: v + }; +} + +function glyphRef(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "glyphRef", + _2: v + }; +} + +function gradientTransform(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "gradientTransform", + _2: v + }; +} + +function gradientUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "gradientUnits", + _2: v + }; +} + +function hanging(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "hanging", + _2: v + }; +} + +function height(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "height", + _2: v + }; +} + +function horizAdvX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "horiz-adv-x", + _2: v + }; +} + +function horizOriginX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "horiz-origin-x", + _2: v + }; +} + +function horizOriginY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "horiz-origin-y", + _2: v + }; +} + +function id(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "id", + _2: v + }; +} + +function ideographic(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "ideographic", + _2: v + }; +} + +function in$p(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "in", + _2: v + }; +} + +function in2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "in2", + _2: v + }; +} + +function intercept(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "intercept", + _2: v + }; +} + +function k(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "k", + _2: v + }; +} + +function k1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "k1", + _2: v + }; +} + +function k2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "k2", + _2: v + }; +} + +function k3(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "k3", + _2: v + }; +} + +function k4(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "k4", + _2: v + }; +} + +function kernelMatrix(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "kernelMatrix", + _2: v + }; +} + +function kernelUnitLength(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "kernelUnitLength", + _2: v + }; +} + +function keyPoints(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "keyPoints", + _2: v + }; +} + +function keySplines(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "keySplines", + _2: v + }; +} + +function keyTimes(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "keyTimes", + _2: v + }; +} + +function lang(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "lang", + _2: v + }; +} + +function lengthAdjust(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "lengthAdjust", + _2: v + }; +} + +function limitingConeAngle(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "limitingConeAngle", + _2: v + }; +} + +function local(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "local", + _2: v + }; +} + +function markerHeight(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "markerHeight", + _2: v + }; +} + +function markerUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "markerUnits", + _2: v + }; +} + +function markerWidth(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "markerWidth", + _2: v + }; +} + +function maskContentUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "maskContentUnits", + _2: v + }; +} + +function maskUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "maskUnits", + _2: v + }; +} + +function mathematical(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "mathematical", + _2: v + }; +} + +function max(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "max", + _2: v + }; +} + +function media(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "media", + _2: v + }; +} + +function method(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "method", + _2: v + }; +} + +function min(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "min", + _2: v + }; +} + +function mode(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "mode", + _2: v + }; +} + +function name(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "name", + _2: v + }; +} + +function numOctaves(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "numOctaves", + _2: v + }; +} + +function offset(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "offset", + _2: v + }; +} + +function operator(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "operator", + _2: v + }; +} + +function order(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "order", + _2: v + }; +} + +function orient(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "orient", + _2: v + }; +} + +function orientation(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "orientation", + _2: v + }; +} + +function origin(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "origin", + _2: v + }; +} + +function overlinePosition(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "overline-position", + _2: v + }; +} + +function overlineThickness(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "overline-thickness", + _2: v + }; +} + +function panose1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "panose-1", + _2: v + }; +} + +function path(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "path", + _2: v + }; +} + +function pathLength(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pathLength", + _2: v + }; +} + +function patternContentUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "patternContentUnits", + _2: v + }; +} + +function patternTransform(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "patternTransform", + _2: v + }; +} + +function patternUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "patternUnits", + _2: v + }; +} + +function pointOrder(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "point-order", + _2: v + }; +} + +function points(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "points", + _2: v + }; +} + +function pointsAtX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pointsAtX", + _2: v + }; +} + +function pointsAtY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pointsAtY", + _2: v + }; +} + +function pointsAtZ(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pointsAtZ", + _2: v + }; +} + +function preserveAlpha(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "preserveAlpha", + _2: v + }; +} + +function preserveAspectRatio(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "preserveAspectRatio", + _2: v + }; +} + +function primitiveUnits(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "primitiveUnits", + _2: v + }; +} + +function r(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "r", + _2: v + }; +} + +function radius(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "radius", + _2: v + }; +} + +function refX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "refX", + _2: v + }; +} + +function refY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "refY", + _2: v + }; +} + +function renderingIntent(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rendering-intent", + _2: v + }; +} + +function repeatCount(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "repeatCount", + _2: v + }; +} + +function repeatDur(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "repeatDur", + _2: v + }; +} + +function requiredExtensions(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "requiredExtensions", + _2: v + }; +} + +function requiredFeatures(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "requiredFeatures", + _2: v + }; +} + +function restart(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "restart", + _2: v + }; +} + +function result(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "result", + _2: v + }; +} + +function rotate(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rotate", + _2: v + }; +} + +function rx(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "rx", + _2: v + }; +} + +function ry(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "ry", + _2: v + }; +} + +function scale(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "scale", + _2: v + }; +} + +function seed(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "seed", + _2: v + }; +} + +function slope(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "slope", + _2: v + }; +} + +function spacing(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "spacing", + _2: v + }; +} + +function specularConstant(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "specularConstant", + _2: v + }; +} + +function specularExponent(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "specularExponent", + _2: v + }; +} + +function speed(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "speed", + _2: v + }; +} + +function spreadMethod(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "spreadMethod", + _2: v + }; +} + +function startOffset(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "startOffset", + _2: v + }; +} + +function stdDeviation(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stdDeviation", + _2: v + }; +} + +function stemh(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stemh", + _2: v + }; +} + +function stemv(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stemv", + _2: v + }; +} + +function stitchTiles(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stitchTiles", + _2: v + }; +} + +function strikethroughPosition(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "strikethrough-position", + _2: v + }; +} + +function strikethroughThickness(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "strikethrough-thickness", + _2: v + }; +} + +function string(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "string", + _2: v + }; +} + +function style(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "style", + _2: v + }; +} + +function surfaceScale(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "surfaceScale", + _2: v + }; +} + +function systemLanguage(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "systemLanguage", + _2: v + }; +} + +function tableValues(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "tableValues", + _2: v + }; +} + +function target(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "target", + _2: v + }; +} + +function targetX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "targetX", + _2: v + }; +} + +function targetY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "targetY", + _2: v + }; +} + +function textLength(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "textLength", + _2: v + }; +} + +function title(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "title", + _2: v + }; +} + +function to(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "to", + _2: v + }; +} + +function transform(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "transform", + _2: v + }; +} + +function type$p(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "type", + _2: v + }; +} + +function u1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "u1", + _2: v + }; +} + +function u2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "u2", + _2: v + }; +} + +function underlinePosition(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "underline-position", + _2: v + }; +} + +function underlineThickness(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "underline-thickness", + _2: v + }; +} + +function unicode(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "unicode", + _2: v + }; +} + +function unicodeRange(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "unicode-range", + _2: v + }; +} + +function unitsPerEm(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "units-per-em", + _2: v + }; +} + +function vAlphabetic(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "v-alphabetic", + _2: v + }; +} + +function vHanging(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "v-hanging", + _2: v + }; +} + +function vIdeographic(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "v-ideographic", + _2: v + }; +} + +function vMathematical(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "v-mathematical", + _2: v + }; +} + +function values(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "values", + _2: v + }; +} + +function version(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "version", + _2: v + }; +} + +function vertAdvY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "vert-adv-y", + _2: v + }; +} + +function vertOriginX(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "vert-origin-x", + _2: v + }; +} + +function vertOriginY(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "vert-origin-y", + _2: v + }; +} + +function viewBox(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "viewBox", + _2: v + }; +} + +function viewTarget(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "viewTarget", + _2: v + }; +} + +function width(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "width", + _2: v + }; +} + +function widths(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "widths", + _2: v + }; +} + +function x(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "x", + _2: v + }; +} + +function xHeight(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "x-height", + _2: v + }; +} + +function x1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "x1", + _2: v + }; +} + +function x2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "x2", + _2: v + }; +} + +function xChannelSelector(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "xChannelSelector", + _2: v + }; +} + +function xlinkActuate(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:actuate", + _2: v + }; +} + +function xlinkArcrole(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:arcrole", + _2: v + }; +} + +function xlinkHref(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:href", + _2: v + }; +} + +function xlinkRole(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:role", + _2: v + }; +} + +function xlinkShow(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:show", + _2: v + }; +} + +function xlinkTitle(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:title", + _2: v + }; +} + +function xlinkType(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/1999/xlink", + _1: "xlink:type", + _2: v + }; +} + +function xmlBase(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/XML/1998/namespace", + _1: "xml:base", + _2: v + }; +} + +function xmlLang(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/XML/1998/namespace", + _1: "xml:lang", + _2: v + }; +} + +function xmlSpace(v) { + return { + TAG: /* Attribute */1, + _0: "http://www.w3.org/XML/1998/namespace", + _1: "xml:space", + _2: v + }; +} + +function y(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "y", + _2: v + }; +} + +function y1(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "y1", + _2: v + }; +} + +function y2(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "y2", + _2: v + }; +} + +function yChannelSelector(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "yChannelSelector", + _2: v + }; +} + +function z(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "z", + _2: v + }; +} + +function zoomAndPan(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "zoomAndPan", + _2: v + }; +} + +function alignmentBaseline(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "alignment-baseline", + _2: v + }; +} + +function baselineShift(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "baseline-shift", + _2: v + }; +} + +function clipPath(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "clip-path", + _2: v + }; +} + +function clipRule(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "clip-rule", + _2: v + }; +} + +function clip(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "clip", + _2: v + }; +} + +function colorInterpolationFilters(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "color-interpolation-filters", + _2: v + }; +} + +function colorInterpolation(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "color-interpolation", + _2: v + }; +} + +function colorProfile(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "color-profile", + _2: v + }; +} + +function colorRendering(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "color-rendering", + _2: v + }; +} + +function color(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "color", + _2: v + }; +} + +function cursor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "cursor", + _2: v + }; +} + +function direction(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "direction", + _2: v + }; +} + +function display(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "display", + _2: v + }; +} + +function dominantBaseline(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "dominant-baseline", + _2: v + }; +} + +function enableBackground(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "enable-background", + _2: v + }; +} + +function fillOpacity(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "fill-opacity", + _2: v + }; +} + +function fillRule(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "fill-rule", + _2: v + }; +} + +function fill(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "fill", + _2: v + }; +} + +function filter(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "filter", + _2: v + }; +} + +function floodColor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "flood-color", + _2: v + }; +} + +function floodOpacity(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "flood-opacity", + _2: v + }; +} + +function fontFamily(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-family", + _2: v + }; +} + +function fontSizeAdjust(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-size-adjust", + _2: v + }; +} + +function fontSize(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-size", + _2: v + }; +} + +function fontStretch(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-stretch", + _2: v + }; +} + +function fontStyle(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-style", + _2: v + }; +} + +function fontVariant(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-variant", + _2: v + }; +} + +function fontWeight(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "font-weight", + _2: v + }; +} + +function glyphOrientationHorizontal(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "glyph-orientation-horizontal", + _2: v + }; +} + +function glyphOrientationVertical(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "glyph-orientation-vertical", + _2: v + }; +} + +function imageRendering(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "image-rendering", + _2: v + }; +} + +function kerning(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "kerning", + _2: v + }; +} + +function letterSpacing(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "letter-spacing", + _2: v + }; +} + +function lightingColor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "lighting-color", + _2: v + }; +} + +function markerEnd(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "marker-end", + _2: v + }; +} + +function markerMid(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "marker-mid", + _2: v + }; +} + +function markerStart(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "marker-start", + _2: v + }; +} + +function mask(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "mask", + _2: v + }; +} + +function opacity(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "opacity", + _2: v + }; +} + +function overflow(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "overflow", + _2: v + }; +} + +function pointerEvents(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "pointer-events", + _2: v + }; +} + +function shapeRendering(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "shape-rendering", + _2: v + }; +} + +function stopColor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stop-color", + _2: v + }; +} + +function stopOpacity(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stop-opacity", + _2: v + }; +} + +function strokeDasharray(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-dasharray", + _2: v + }; +} + +function strokeDashoffset(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-dashoffset", + _2: v + }; +} + +function strokeLinecap(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-linecap", + _2: v + }; +} + +function strokeLinejoin(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-linejoin", + _2: v + }; +} + +function strokeMiterlimit(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-miterlimit", + _2: v + }; +} + +function strokeOpacity(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-opacity", + _2: v + }; +} + +function strokeWidth(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke-width", + _2: v + }; +} + +function stroke(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "stroke", + _2: v + }; +} + +function textAnchor(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "text-anchor", + _2: v + }; +} + +function textDecoration(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "text-decoration", + _2: v + }; +} + +function textRendering(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "text-rendering", + _2: v + }; +} + +function unicodeBidi(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "unicode-bidi", + _2: v + }; +} + +function visibility(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "visibility", + _2: v + }; +} + +function wordSpacing(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "word-spacing", + _2: v + }; +} + +function writingMode(v) { + return { + TAG: /* Attribute */1, + _0: "", + _1: "writing-mode", + _2: v + }; +} + +exports.accentHeight = accentHeight; +exports.accelerate = accelerate; +exports.accumulate = accumulate; +exports.additive = additive; +exports.alphabetic = alphabetic; +exports.allowReorder = allowReorder; +exports.amplitude = amplitude; +exports.arabicForm = arabicForm; +exports.ascent = ascent; +exports.attributeName = attributeName; +exports.attributeType = attributeType; +exports.autoReverse = autoReverse; +exports.azimuth = azimuth; +exports.baseFrequency = baseFrequency; +exports.baseProfile = baseProfile; +exports.bbox = bbox; +exports.begin = begin; +exports.bias = bias; +exports.by = by; +exports.calcMode = calcMode; +exports.capHeight = capHeight; +exports.$$class = $$class; +exports.clipPathUnits = clipPathUnits; +exports.contentScriptType = contentScriptType; +exports.contentStyleType = contentStyleType; +exports.cx = cx; +exports.cy = cy; +exports.d = d; +exports.decelerate = decelerate; +exports.descent = descent; +exports.diffuseConstant = diffuseConstant; +exports.divisor = divisor; +exports.dur = dur; +exports.dx = dx; +exports.dy = dy; +exports.edgeMode = edgeMode; +exports.elevation = elevation; +exports.end = end; +exports.exponent = exponent; +exports.externalResourcesRequired = externalResourcesRequired; +exports.filterRes = filterRes; +exports.filterUnits = filterUnits; +exports.format = format; +exports.from = from; +exports.fx = fx; +exports.fy = fy; +exports.g1 = g1; +exports.g2 = g2; +exports.glyphName = glyphName; +exports.glyphRef = glyphRef; +exports.gradientTransform = gradientTransform; +exports.gradientUnits = gradientUnits; +exports.hanging = hanging; +exports.height = height; +exports.horizAdvX = horizAdvX; +exports.horizOriginX = horizOriginX; +exports.horizOriginY = horizOriginY; +exports.id = id; +exports.ideographic = ideographic; +exports.in$p = in$p; +exports.in2 = in2; +exports.intercept = intercept; +exports.k = k; +exports.k1 = k1; +exports.k2 = k2; +exports.k3 = k3; +exports.k4 = k4; +exports.kernelMatrix = kernelMatrix; +exports.kernelUnitLength = kernelUnitLength; +exports.keyPoints = keyPoints; +exports.keySplines = keySplines; +exports.keyTimes = keyTimes; +exports.lang = lang; +exports.lengthAdjust = lengthAdjust; +exports.limitingConeAngle = limitingConeAngle; +exports.local = local; +exports.markerHeight = markerHeight; +exports.markerUnits = markerUnits; +exports.markerWidth = markerWidth; +exports.maskContentUnits = maskContentUnits; +exports.maskUnits = maskUnits; +exports.mathematical = mathematical; +exports.max = max; +exports.media = media; +exports.method = method; +exports.min = min; +exports.mode = mode; +exports.name = name; +exports.numOctaves = numOctaves; +exports.offset = offset; +exports.operator = operator; +exports.order = order; +exports.orient = orient; +exports.orientation = orientation; +exports.origin = origin; +exports.overlinePosition = overlinePosition; +exports.overlineThickness = overlineThickness; +exports.panose1 = panose1; +exports.path = path; +exports.pathLength = pathLength; +exports.patternContentUnits = patternContentUnits; +exports.patternTransform = patternTransform; +exports.patternUnits = patternUnits; +exports.pointOrder = pointOrder; +exports.points = points; +exports.pointsAtX = pointsAtX; +exports.pointsAtY = pointsAtY; +exports.pointsAtZ = pointsAtZ; +exports.preserveAlpha = preserveAlpha; +exports.preserveAspectRatio = preserveAspectRatio; +exports.primitiveUnits = primitiveUnits; +exports.r = r; +exports.radius = radius; +exports.refX = refX; +exports.refY = refY; +exports.renderingIntent = renderingIntent; +exports.repeatCount = repeatCount; +exports.repeatDur = repeatDur; +exports.requiredExtensions = requiredExtensions; +exports.requiredFeatures = requiredFeatures; +exports.restart = restart; +exports.result = result; +exports.rotate = rotate; +exports.rx = rx; +exports.ry = ry; +exports.scale = scale; +exports.seed = seed; +exports.slope = slope; +exports.spacing = spacing; +exports.specularConstant = specularConstant; +exports.specularExponent = specularExponent; +exports.speed = speed; +exports.spreadMethod = spreadMethod; +exports.startOffset = startOffset; +exports.stdDeviation = stdDeviation; +exports.stemh = stemh; +exports.stemv = stemv; +exports.stitchTiles = stitchTiles; +exports.strikethroughPosition = strikethroughPosition; +exports.strikethroughThickness = strikethroughThickness; +exports.string = string; +exports.style = style; +exports.surfaceScale = surfaceScale; +exports.systemLanguage = systemLanguage; +exports.tableValues = tableValues; +exports.target = target; +exports.targetX = targetX; +exports.targetY = targetY; +exports.textLength = textLength; +exports.title = title; +exports.to = to; +exports.transform = transform; +exports.type$p = type$p; +exports.u1 = u1; +exports.u2 = u2; +exports.underlinePosition = underlinePosition; +exports.underlineThickness = underlineThickness; +exports.unicode = unicode; +exports.unicodeRange = unicodeRange; +exports.unitsPerEm = unitsPerEm; +exports.vAlphabetic = vAlphabetic; +exports.vHanging = vHanging; +exports.vIdeographic = vIdeographic; +exports.vMathematical = vMathematical; +exports.values = values; +exports.version = version; +exports.vertAdvY = vertAdvY; +exports.vertOriginX = vertOriginX; +exports.vertOriginY = vertOriginY; +exports.viewBox = viewBox; +exports.viewTarget = viewTarget; +exports.width = width; +exports.widths = widths; +exports.x = x; +exports.xHeight = xHeight; +exports.x1 = x1; +exports.x2 = x2; +exports.xChannelSelector = xChannelSelector; +exports.xlinkActuate = xlinkActuate; +exports.xlinkArcrole = xlinkArcrole; +exports.xlinkHref = xlinkHref; +exports.xlinkRole = xlinkRole; +exports.xlinkShow = xlinkShow; +exports.xlinkTitle = xlinkTitle; +exports.xlinkType = xlinkType; +exports.xmlBase = xmlBase; +exports.xmlLang = xmlLang; +exports.xmlSpace = xmlSpace; +exports.y = y; +exports.y1 = y1; +exports.y2 = y2; +exports.yChannelSelector = yChannelSelector; +exports.z = z; +exports.zoomAndPan = zoomAndPan; +exports.alignmentBaseline = alignmentBaseline; +exports.baselineShift = baselineShift; +exports.clipPath = clipPath; +exports.clipRule = clipRule; +exports.clip = clip; +exports.colorInterpolationFilters = colorInterpolationFilters; +exports.colorInterpolation = colorInterpolation; +exports.colorProfile = colorProfile; +exports.colorRendering = colorRendering; +exports.color = color; +exports.cursor = cursor; +exports.direction = direction; +exports.display = display; +exports.dominantBaseline = dominantBaseline; +exports.enableBackground = enableBackground; +exports.fillOpacity = fillOpacity; +exports.fillRule = fillRule; +exports.fill = fill; +exports.filter = filter; +exports.floodColor = floodColor; +exports.floodOpacity = floodOpacity; +exports.fontFamily = fontFamily; +exports.fontSizeAdjust = fontSizeAdjust; +exports.fontSize = fontSize; +exports.fontStretch = fontStretch; +exports.fontStyle = fontStyle; +exports.fontVariant = fontVariant; +exports.fontWeight = fontWeight; +exports.glyphOrientationHorizontal = glyphOrientationHorizontal; +exports.glyphOrientationVertical = glyphOrientationVertical; +exports.imageRendering = imageRendering; +exports.kerning = kerning; +exports.letterSpacing = letterSpacing; +exports.lightingColor = lightingColor; +exports.markerEnd = markerEnd; +exports.markerMid = markerMid; +exports.markerStart = markerStart; +exports.mask = mask; +exports.opacity = opacity; +exports.overflow = overflow; +exports.pointerEvents = pointerEvents; +exports.shapeRendering = shapeRendering; +exports.stopColor = stopColor; +exports.stopOpacity = stopOpacity; +exports.strokeDasharray = strokeDasharray; +exports.strokeDashoffset = strokeDashoffset; +exports.strokeLinecap = strokeLinecap; +exports.strokeLinejoin = strokeLinejoin; +exports.strokeMiterlimit = strokeMiterlimit; +exports.strokeOpacity = strokeOpacity; +exports.strokeWidth = strokeWidth; +exports.stroke = stroke; +exports.textAnchor = textAnchor; +exports.textDecoration = textDecoration; +exports.textRendering = textRendering; +exports.unicodeBidi = unicodeBidi; +exports.visibility = visibility; +exports.wordSpacing = wordSpacing; +exports.writingMode = writingMode; +/* No side effect */ diff --git a/lib/js/src-ocaml/tea_svg_events.js b/lib/js/src/tea_svg_events.js similarity index 67% rename from lib/js/src-ocaml/tea_svg_events.js rename to lib/js/src/tea_svg_events.js index 40fed0f..d856702 100644 --- a/lib/js/src-ocaml/tea_svg_events.js +++ b/lib/js/src/tea_svg_events.js @@ -1,2 +1,2 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/js/src/tea_task.js b/lib/js/src/tea_task.js new file mode 100644 index 0000000..3829383 --- /dev/null +++ b/lib/js/src/tea_task.js @@ -0,0 +1,759 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Curry = require("rescript/lib/js/curry.js"); +var Caml_obj = require("rescript/lib/js/caml_obj.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function nothing(param) { + +} + +function performOpt(toOptionalMessage, task) { + var task$1 = task._0; + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + return Curry._1(task$1, (function (x) { + if (x.TAG === /* Ok */0) { + var result = Curry._1(toOptionalMessage, x._0); + if (result !== undefined) { + return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(result)); + } else { + return ; + } + } + throw { + RE_EXN_ID: "Failure", + _1: "ERROR: Task perfom returned error of never! Should not happen!", + Error: new Error() + }; + })); + }) + }; +} + +function perform(toMessage, task) { + return performOpt((function (v) { + return Caml_option.some(Curry._1(toMessage, v)); + }), task); +} + +function attemptOpt(resultToOptionalMessage, task) { + var task$1 = task._0; + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + return Curry._1(task$1, (function (value) { + var result = Curry._1(resultToOptionalMessage, value); + if (result !== undefined) { + return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(result)); + } + + })); + }) + }; +} + +function attempt(resultToMessage, task) { + return attemptOpt((function (v) { + return Caml_option.some(Curry._1(resultToMessage, v)); + }), task); +} + +function ignore(task) { + return attemptOpt((function (param) { + + }), task); +} + +function succeed(value) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; +} + +function fail(value) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: value + }); + }) + }; +} + +function nativeBinding(func) { + return /* Task */{ + _0: func + }; +} + +function andThen(fn, task) { + var task$1 = task._0; + return /* Task */{ + _0: (function (cb) { + return Curry._1(task$1, (function (x) { + if (x.TAG !== /* Ok */0) { + return Curry._1(cb, x); + } + var nextTask = Curry._1(fn, x._0); + return Curry._1(nextTask._0, cb); + })); + }) + }; +} + +function onError(fn, task) { + var task$1 = task._0; + return /* Task */{ + _0: (function (cb) { + return Curry._1(task$1, (function (x) { + if (x.TAG === /* Ok */0) { + return Curry._1(cb, x); + } + var newTask = Curry._1(fn, x._0); + return Curry._1(newTask._0, cb); + })); + }) + }; +} + +function fromResult(x) { + if (x.TAG === /* Ok */0) { + var value = x._0; + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + } + var value$1 = x._0; + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: value$1 + }); + }) + }; +} + +function mapError(func, task) { + return onError((function (e) { + var value = Curry._1(func, e); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: value + }); + }) + }; + }), task); +} + +function toOption(task) { + return onError((function (param) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: undefined + }); + }) + }; + }), andThen((function (v) { + var value = Caml_option.some(v); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task)); +} + +function map(func, task1) { + return andThen((function (v1) { + var value = Curry._1(func, v1); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task1); +} + +function map2(func, task1, task2) { + return andThen((function (v1) { + return andThen((function (v2) { + var value = Curry._2(func, v1, v2); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task2); + }), task1); +} + +function map3(func, task1, task2, task3) { + return andThen((function (v1) { + return andThen((function (v2) { + return andThen((function (v3) { + var value = Curry._3(func, v1, v2, v3); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task3); + }), task2); + }), task1); +} + +function map4(func, task1, task2, task3, task4) { + return andThen((function (v1) { + return andThen((function (v2) { + return andThen((function (v3) { + return andThen((function (v4) { + var value = Curry._4(func, v1, v2, v3, v4); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task4); + }), task3); + }), task2); + }), task1); +} + +function map5(func, task1, task2, task3, task4, task5) { + return andThen((function (v1) { + return andThen((function (v2) { + return andThen((function (v3) { + return andThen((function (v4) { + return andThen((function (v5) { + var value = Curry._5(func, v1, v2, v3, v4, v5); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task5); + }), task4); + }), task3); + }), task2); + }), task1); +} + +function map6(func, task1, task2, task3, task4, task5, task6) { + return andThen((function (v1) { + return andThen((function (v2) { + return andThen((function (v3) { + return andThen((function (v4) { + return andThen((function (v5) { + return andThen((function (v6) { + var value = Curry._6(func, v1, v2, v3, v4, v5, v6); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), task6); + }), task5); + }), task4); + }), task3); + }), task2); + }), task1); +} + +function sequence(x) { + if (x) { + return map2((function (l, r) { + return { + hd: l, + tl: r + }; + }), x.hd, sequence(x.tl)); + } else { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: /* [] */0 + }); + }) + }; + } +} + +var testingDeop = { + contents: true +}; + +function testing(param) { + var doTest = function (expected, task) { + return Curry._1(task._0, (function (v) { + if (Caml_obj.caml_equal(v, expected)) { + console.log([ + "Passed:", + expected, + v + ]); + } else { + console.log([ + "FAILED:", + expected, + v + ]); + } + + })); + }; + var s = /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 42 + }); + }) + }; + doTest({ + TAG: /* Ok */0, + _0: 42 + }, s); + var f = /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 86 + }); + }) + }; + doTest({ + TAG: /* Error */1, + _0: 86 + }, f); + var r = function (param) { + if (testingDeop.contents) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 42 + }); + }) + }; + } else { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 3.14 + }); + }) + }; + } + }; + var a1 = andThen((function (n) { + var value = n + 2 | 0; + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 2 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: 4 + }, a1); + var a2 = andThen((function (n) { + var value = String(n); + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 2 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: "2" + }, a2); + var m1 = map((function (prim) { + return Math.sqrt(prim); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 9 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: 3 + }, m1); + var m2 = map2((function (prim0, prim1) { + return prim0 + prim1 | 0; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 9 + }); + }) + }, /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 3 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: 12 + }, m2); + var m3 = map((function (prim) { + return String(prim); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 9 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: "9" + }, m3); + var s0 = sequence({ + hd: /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 1 + }); + }) + }, + tl: { + hd: /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 2 + }); + }) + }, + tl: /* [] */0 + } + }); + doTest({ + TAG: /* Ok */0, + _0: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }, s0); + var s1 = sequence({ + hd: /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 1 + }); + }) + }, + tl: { + hd: /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 2.7 + }); + }) + }, + tl: { + hd: r(undefined), + tl: /* [] */0 + } + } + }); + doTest({ + TAG: /* Error */1, + _0: 2.7 + }, s1); + var e0 = onError((function (_msg) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 42 + }); + }) + }; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: "file not found" + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: 42 + }, e0); + var e1 = onError((function (_msg) { + return /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 42 + }); + }) + }; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: "file not found" + }); + }) + }); + doTest({ + TAG: /* Error */1, + _0: 42 + }, e1); + var n0 = sequence({ + hd: mapError((function (prim) { + return String(prim); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 42 + }); + }) + }), + tl: { + hd: mapError((function (prim) { + return prim.toString(); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 3.14 + }); + }) + }), + tl: /* [] */0 + } + }); + doTest({ + TAG: /* Error */1, + _0: "42" + }, n0); + var n1 = sequence({ + hd: mapError((function (prim) { + return String(prim); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 1 + }); + }) + }), + tl: { + hd: mapError((function (prim) { + return prim.toString(); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: 3.14 + }); + }) + }), + tl: /* [] */0 + } + }); + doTest({ + TAG: /* Error */1, + _0: "3.14" + }, n1); + var n2 = sequence({ + hd: mapError((function (prim) { + return String(prim); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 1 + }); + }) + }), + tl: { + hd: mapError((function (prim) { + return prim.toString(); + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 2 + }); + }) + }), + tl: /* [] */0 + } + }); + doTest({ + TAG: /* Ok */0, + _0: { + hd: 1, + tl: { + hd: 2, + tl: /* [] */0 + } + } + }, n2); + perform((function (param) { + return 42; + }), /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 18 + }); + }) + }); + var value = 42; + doTest({ + TAG: /* Ok */0, + _0: 42 + }, /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: value + }); + }) + }); + var value$1 = "failure"; + doTest({ + TAG: /* Error */1, + _0: "failure" + }, /* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: value$1 + }); + }) + }); + doTest({ + TAG: /* Ok */0, + _0: undefined + }, toOption(/* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Error */1, + _0: "for some reason" + }); + }) + })); + doTest({ + TAG: /* Ok */0, + _0: 42 + }, toOption(/* Task */{ + _0: (function (cb) { + return Curry._1(cb, { + TAG: /* Ok */0, + _0: 42 + }); + }) + })); + +} + +exports.nothing = nothing; +exports.performOpt = performOpt; +exports.perform = perform; +exports.attemptOpt = attemptOpt; +exports.attempt = attempt; +exports.ignore = ignore; +exports.succeed = succeed; +exports.fail = fail; +exports.nativeBinding = nativeBinding; +exports.andThen = andThen; +exports.onError = onError; +exports.fromResult = fromResult; +exports.mapError = mapError; +exports.toOption = toOption; +exports.map = map; +exports.map2 = map2; +exports.map3 = map3; +exports.map4 = map4; +exports.map5 = map5; +exports.map6 = map6; +exports.sequence = sequence; +exports.testingDeop = testingDeop; +exports.testing = testing; +/* No side effect */ diff --git a/lib/js/src-ocaml/tea_time.js b/lib/js/src/tea_time.js similarity index 59% rename from lib/js/src-ocaml/tea_time.js rename to lib/js/src/tea_time.js index ac9ca7f..0164d00 100644 --- a/lib/js/src-ocaml/tea_time.js +++ b/lib/js/src/tea_time.js @@ -1,30 +1,32 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); +var Curry = require("rescript/lib/js/curry.js"); var Tea_sub = require("./tea_sub.js"); -var Web_window = require("./web_window.js"); function every(key, interval, tagger) { var enableCall = function (callbacks) { - var id = Web_window.$$setInterval((function (param) { + var id = setInterval((function (param) { return Curry._1(callbacks.enqueue, Curry._1(tagger, Date.now())); }), interval); - return (function (param) { - return window.clearTimeout(id); - }); + return function (param) { + clearInterval(id); + + }; }; return Tea_sub.registration(key, enableCall); } function delay(msTime, msg) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - Web_window.$$setTimeout((function (param) { - return Curry._1(callbacks.contents.enqueue, msg); - }), msTime); - return /* () */0; - })]); + return { + TAG: /* EnqueueCall */2, + _0: (function (callbacks) { + setTimeout((function (param) { + return Curry._1(callbacks.contents.enqueue, msg); + }), msTime); + + }) + }; } var second = 1000.0 * 1.0; diff --git a/lib/js/src/vdom.js b/lib/js/src/vdom.js new file mode 100644 index 0000000..4157762 --- /dev/null +++ b/lib/js/src/vdom.js @@ -0,0 +1,1127 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var Curry = require("rescript/lib/js/curry.js"); +var $$String = require("rescript/lib/js/string.js"); +var Caml_obj = require("rescript/lib/js/caml_obj.js"); +var Web_node = require("./web_node.js"); +var Caml_array = require("rescript/lib/js/caml_array.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Web_document = require("./web_document.js"); + +var noNode = { + TAG: /* CommentNode */0, + _0: "" +}; + +function comment(s) { + return { + TAG: /* CommentNode */0, + _0: s + }; +} + +function text(s) { + return { + TAG: /* Text */1, + _0: s + }; +} + +function fullnode(namespace, tagName, key, unique, props, vdoms) { + return { + TAG: /* Node */2, + _0: namespace, + _1: tagName, + _2: key, + _3: unique, + _4: props, + _5: vdoms + }; +} + +function node(namespaceOpt, tagName, keyOpt, uniqueOpt, props, vdoms) { + var namespace = namespaceOpt !== undefined ? namespaceOpt : ""; + var key = keyOpt !== undefined ? keyOpt : ""; + var unique = uniqueOpt !== undefined ? uniqueOpt : ""; + return fullnode(namespace, tagName, key, unique, props, vdoms); +} + +function lazyGen(key, fn) { + return { + TAG: /* LazyGen */3, + _0: key, + _1: fn, + _2: { + contents: noNode + } + }; +} + +function prop(key, value) { + return { + TAG: /* RawProp */0, + _0: key, + _1: value + }; +} + +function onCB(name, key, cb) { + return { + TAG: /* Event */3, + _0: name, + _1: { + TAG: /* EventHandlerCallback */0, + _0: key, + _1: cb + }, + _2: { + contents: undefined + } + }; +} + +function onMsg(name, msg) { + return { + TAG: /* Event */3, + _0: name, + _1: { + TAG: /* EventHandlerMsg */1, + _0: msg + }, + _2: { + contents: undefined + } + }; +} + +function attribute(namespace, key, value) { + return { + TAG: /* Attribute */1, + _0: namespace, + _1: key, + _2: value + }; +} + +function data(key, value) { + return { + TAG: /* Data */2, + _0: key, + _1: value + }; +} + +function style(key, value) { + return { + TAG: /* Style */4, + _0: { + hd: [ + key, + value + ], + tl: /* [] */0 + } + }; +} + +function styles(s) { + return { + TAG: /* Style */4, + _0: s + }; +} + +function renderToHtmlString(_x) { + while(true) { + var x = _x; + switch (x.TAG | 0) { + case /* CommentNode */0 : + return ""); + case /* Text */1 : + return x._0; + case /* Node */2 : + var tagName = x._1; + var namespace = x._0; + return $$String.concat("", { + hd: "<", + tl: { + hd: namespace, + tl: { + hd: namespace === "" ? "" : ":", + tl: { + hd: tagName, + tl: { + hd: $$String.concat("", List.map((function (p) { + if (typeof p === "number") { + return ""; + } + switch (p.TAG | 0) { + case /* RawProp */0 : + return $$String.concat("", { + hd: " ", + tl: { + hd: p._0, + tl: { + hd: "=\"", + tl: { + hd: p._1, + tl: { + hd: "\"", + tl: /* [] */0 + } + } + } + } + }); + case /* Attribute */1 : + return $$String.concat("", { + hd: " ", + tl: { + hd: p._1, + tl: { + hd: "=\"", + tl: { + hd: p._2, + tl: { + hd: "\"", + tl: /* [] */0 + } + } + } + } + }); + case /* Data */2 : + return $$String.concat("", { + hd: " data-", + tl: { + hd: p._0, + tl: { + hd: "=\"", + tl: { + hd: p._1, + tl: { + hd: "\"", + tl: /* [] */0 + } + } + } + } + }); + case /* Event */3 : + return ""; + case /* Style */4 : + return $$String.concat("", { + hd: " style=\"", + tl: { + hd: $$String.concat(";", List.map((function (param) { + return $$String.concat("", { + hd: param[0], + tl: { + hd: ":", + tl: { + hd: param[1], + tl: { + hd: ";", + tl: /* [] */0 + } + } + } + }); + }), p._0)), + tl: { + hd: "\"", + tl: /* [] */0 + } + } + }); + + } + }), x._4)), + tl: { + hd: ">", + tl: { + hd: $$String.concat("", List.map(renderToHtmlString, x._5)), + tl: { + hd: "", + tl: /* [] */0 + } + } + } + } + } + } + } + } + } + }); + case /* LazyGen */3 : + _x = Curry._1(x._1, undefined); + continue ; + case /* Tagger */4 : + _x = x._1; + continue ; + + } + }; +} + +function emptyEventHandler(_ev) { + +} + +function emptyEventCB(_ev) { + +} + +function eventHandler(callbacks, cb) { + return function (ev) { + var msg = Curry._1(cb.contents, ev); + if (msg !== undefined) { + return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(msg)); + } + + }; +} + +function eventHandlerGetCB(x) { + if (x.TAG === /* EventHandlerCallback */0) { + return x._1; + } + var msg = x._0; + return function (_ev) { + return Caml_option.some(msg); + }; +} + +function compareEventHandlerTypes(left, x) { + if (x.TAG === /* EventHandlerCallback */0) { + if (left.TAG === /* EventHandlerCallback */0) { + return x._0 === left._0; + } else { + return false; + } + } else if (left.TAG === /* EventHandlerCallback */0 || !Caml_obj.caml_equal(x._0, left._0)) { + return false; + } else { + return true; + } +} + +function eventHandlerRegister(callbacks, elem, name, handlerType) { + var cb = { + contents: eventHandlerGetCB(handlerType) + }; + var handler = eventHandler(callbacks, cb); + Web_node.addEventListener(elem, name, handler, false); + return { + handler: handler, + cb: cb + }; +} + +function eventHandlerUnregister(elem, name, x) { + if (x !== undefined) { + Web_node.removeEventListener(elem, name, x.handler, false); + return ; + } + +} + +function eventHandlerMutate(callbacks, elem, oldName, newName, oldHandlerType, newHandlerType, oldCache, newCache) { + var oldcache = oldCache.contents; + if (oldcache === undefined) { + newCache.contents = eventHandlerRegister(callbacks, elem, newName, newHandlerType); + return ; + } + if (oldName === newName) { + newCache.contents = oldCache.contents; + if (compareEventHandlerTypes(oldHandlerType, newHandlerType)) { + return ; + } + var cb = eventHandlerGetCB(newHandlerType); + oldcache.cb.contents = cb; + return ; + } + oldCache.contents = eventHandlerUnregister(elem, oldName, oldCache.contents); + newCache.contents = eventHandlerRegister(callbacks, elem, newName, newHandlerType); + +} + +function patchVNodesOnElemsPropertiesApplyAdd(callbacks, elem, _idx, x) { + if (typeof x === "number") { + return ; + } + switch (x.TAG | 0) { + case /* RawProp */0 : + elem[x._0] = x._1; + return ; + case /* Attribute */1 : + return Web_node.setAttributeNsOptional(elem, x._0, x._1, x._2); + case /* Data */2 : + console.log([ + "TODO: Add Data Unhandled", + x._0, + x._1 + ]); + throw { + RE_EXN_ID: "Failure", + _1: "TODO: Add Data Unhandled", + Error: new Error() + }; + case /* Event */3 : + x._2.contents = eventHandlerRegister(callbacks, elem, x._0, x._1); + return ; + case /* Style */4 : + return List.fold_left((function (param, param$1) { + return Web_node.setStyleProperty(elem, undefined, param$1[0], param$1[1]); + }), undefined, x._0); + + } +} + +function patchVNodesOnElemsPropertiesApplyRemove(_callbacks, elem, _idx, x) { + if (typeof x === "number") { + return ; + } + switch (x.TAG | 0) { + case /* RawProp */0 : + elem[x._0] = undefined; + return ; + case /* Attribute */1 : + return Web_node.removeAttributeNsOptional(elem, x._0, x._1); + case /* Data */2 : + console.log([ + "TODO: Remove Data Unhandled", + x._0, + x._1 + ]); + throw { + RE_EXN_ID: "Failure", + _1: "TODO: Remove Data Unhandled", + Error: new Error() + }; + case /* Event */3 : + var cache = x._2; + cache.contents = eventHandlerUnregister(elem, x._0, cache.contents); + return ; + case /* Style */4 : + return List.fold_left((function (param, param$1) { + return Web_node.setStyleProperty(elem, undefined, param$1[0], null); + }), undefined, x._0); + + } +} + +function patchVNodesOnElemsPropertiesApplyRemoveAdd(callbacks, elem, idx, oldProp, newProp) { + patchVNodesOnElemsPropertiesApplyRemove(callbacks, elem, idx, oldProp); + patchVNodesOnElemsPropertiesApplyAdd(callbacks, elem, idx, newProp); + +} + +function patchVNodesOnElemsPropertiesApplyMutate(_callbacks, elem, _idx, oldProp, x) { + if (typeof x === "number") { + throw { + RE_EXN_ID: "Failure", + _1: "This should never be called as all entries through NoProp are gated.", + Error: new Error() + }; + } + switch (x.TAG | 0) { + case /* RawProp */0 : + elem[x._0] = x._1; + return ; + case /* Attribute */1 : + return Web_node.setAttributeNsOptional(elem, x._0, x._1, x._2); + case /* Data */2 : + console.log([ + "TODO: Mutate Data Unhandled", + x._0, + x._1 + ]); + throw { + RE_EXN_ID: "Failure", + _1: "TODO: Mutate Data Unhandled", + Error: new Error() + }; + case /* Event */3 : + throw { + RE_EXN_ID: "Failure", + _1: "This will never be called because it is gated", + Error: new Error() + }; + case /* Style */4 : + if (typeof oldProp === "number") { + throw { + RE_EXN_ID: "Failure", + _1: "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!", + Error: new Error() + }; + } + if (oldProp.TAG === /* Style */4) { + return List.fold_left2((function (param, param$1, param$2) { + var nv = param$2[1]; + var nk = param$2[0]; + var ok = param$1[0]; + if (ok === nk) { + if (param$1[1] === nv) { + return ; + } else { + return Web_node.setStyleProperty(elem, undefined, nk, nv); + } + } else { + Web_node.setStyleProperty(elem, undefined, ok, null); + return Web_node.setStyleProperty(elem, undefined, nk, nv); + } + }), undefined, oldProp._0, x._0); + } + throw { + RE_EXN_ID: "Failure", + _1: "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!", + Error: new Error() + }; + + } +} + +function patchVNodesOnElemsPropertiesApply(callbacks, elem, _idx, _oldProperties, _newProperties) { + while(true) { + var newProperties = _newProperties; + var oldProperties = _oldProperties; + var idx = _idx; + if (!oldProperties) { + if (newProperties) { + return false; + } else { + return true; + } + } + var _oldProp = oldProperties.hd; + if (!newProperties) { + return false; + } + if (typeof _oldProp === "number") { + if (typeof newProperties.hd === "number") { + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + + } else { + switch (_oldProp.TAG | 0) { + case /* RawProp */0 : + var newProp = newProperties.hd; + if (typeof newProp !== "number" && newProp.TAG === /* RawProp */0) { + if (_oldProp._0 === newProp._0 && _oldProp._1 === newProp._1) { + + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, _oldProp, newProp); + } + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + break; + case /* Attribute */1 : + var newProp$1 = newProperties.hd; + if (typeof newProp$1 !== "number" && newProp$1.TAG === /* Attribute */1) { + if (_oldProp._0 === newProp$1._0 && _oldProp._1 === newProp$1._1 && _oldProp._2 === newProp$1._2) { + + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, _oldProp, newProp$1); + } + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + break; + case /* Data */2 : + var newProp$2 = newProperties.hd; + if (typeof newProp$2 !== "number" && newProp$2.TAG === /* Data */2) { + if (_oldProp._0 === newProp$2._0 && _oldProp._1 === newProp$2._1) { + + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, _oldProp, newProp$2); + } + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + break; + case /* Event */3 : + var _newProp = newProperties.hd; + if (typeof _newProp !== "number" && _newProp.TAG === /* Event */3) { + eventHandlerMutate(callbacks, elem, _oldProp._0, _newProp._0, _oldProp._1, _newProp._1, _oldProp._2, _newProp._2); + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + break; + case /* Style */4 : + var newProp$3 = newProperties.hd; + if (typeof newProp$3 !== "number" && newProp$3.TAG === /* Style */4) { + if (Caml_obj.caml_equal(_oldProp._0, newProp$3._0)) { + + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, _oldProp, newProp$3); + } + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + } + break; + + } + } + patchVNodesOnElemsPropertiesApplyRemoveAdd(callbacks, elem, idx, _oldProp, newProperties.hd); + _newProperties = newProperties.tl; + _oldProperties = oldProperties.tl; + _idx = idx + 1 | 0; + continue ; + }; +} + +function patchVNodesOnElemsProperties(callbacks, elem, oldProperties, newProperties) { + return patchVNodesOnElemsPropertiesApply(callbacks, elem, 0, oldProperties, newProperties); +} + +function genEmptyProps(length) { + var _lst = /* [] */0; + var _x = length; + while(true) { + var x = _x; + var lst = _lst; + if (x === 0) { + return lst; + } + _x = x - 1 | 0; + _lst = { + hd: /* NoProp */0, + tl: lst + }; + continue ; + }; +} + +function mapEmptyProps(props) { + return List.map((function (param) { + return /* NoProp */0; + }), props); +} + +function patchVNodesOnElemsReplaceNode(callbacks, elem, elems, idx, x) { + if (x.TAG === /* Node */2) { + var newProperties = x._4; + var oldChild = Caml_array.get(elems, idx); + var newChild = Web_document.createElementNsOptional(x._0, x._1); + var match = patchVNodesOnElemsProperties(callbacks, newChild, List.map((function (param) { + return /* NoProp */0; + }), newProperties), newProperties); + if (match) { + var childChildren = newChild.childNodes; + patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, x._5); + elem.insertBefore(newChild, oldChild); + elem.removeChild(oldChild); + return ; + } + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "vdom.res", + 380, + 10 + ], + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "Node replacement should never be passed anything but a node itself", + Error: new Error() + }; +} + +function patchVNodesOnElemsCreateElement(_callbacks, _x) { + while(true) { + var x = _x; + var callbacks = _callbacks; + switch (x.TAG | 0) { + case /* CommentNode */0 : + var text = x._0; + return document.createComment(text); + case /* Text */1 : + var text$1 = x._0; + return document.createTextNode(text$1); + case /* Node */2 : + var newProperties = x._4; + var newChild = Web_document.createElementNsOptional(x._0, x._1); + var match = patchVNodesOnElemsProperties(callbacks, newChild, List.map((function (param) { + return /* NoProp */0; + }), newProperties), newProperties); + if (match) { + var childChildren = newChild.childNodes; + patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, x._5); + return newChild; + } + throw { + RE_EXN_ID: "Match_failure", + _1: [ + "vdom.res", + 403, + 10 + ], + Error: new Error() + }; + case /* LazyGen */3 : + var vdom = Curry._1(x._1, undefined); + x._2.contents = vdom; + _x = vdom; + continue ; + case /* Tagger */4 : + _x = x._1; + _callbacks = Curry._1(x._0, callbacks); + continue ; + + } + }; +} + +function patchVNodesOnElemsMutateNode(callbacks, elem, elems, idx, oldNode, newNode) { + if (oldNode.TAG === /* Node */2) { + if (newNode.TAG === /* Node */2) { + if (oldNode._3 !== newNode._3 || oldNode._1 !== newNode._1) { + return patchVNodesOnElemsReplaceNode(callbacks, elem, elems, idx, newNode); + } + var child = Caml_array.get(elems, idx); + var childChildren = child.childNodes; + if (patchVNodesOnElemsProperties(callbacks, child, oldNode._4, newNode._4)) { + + } else { + console.log("VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved."); + patchVNodesOnElemsReplaceNode(callbacks, elem, elems, idx, newNode); + } + return patchVNodesOnElems(callbacks, child, childChildren, 0, oldNode._5, newNode._5); + } + throw { + RE_EXN_ID: "Failure", + _1: "Non-node passed to patchVNodesOnElemsMutateNode", + Error: new Error() + }; + } + throw { + RE_EXN_ID: "Failure", + _1: "Non-node passed to patchVNodesOnElemsMutateNode", + Error: new Error() + }; +} + +function patchVNodesOnElems(callbacks, elem, elems, _idx, _oldVNodes, _newVNodes) { + while(true) { + var newVNodes = _newVNodes; + var oldVNodes = _oldVNodes; + var idx = _idx; + if (oldVNodes) { + var oldNode = oldVNodes.hd; + switch (oldNode.TAG | 0) { + case /* CommentNode */0 : + if (newVNodes) { + var newS = newVNodes.hd; + if (newS.TAG === /* CommentNode */0 && oldNode._0 === newS._0) { + _newVNodes = newVNodes.tl; + _oldVNodes = oldVNodes.tl; + _idx = idx + 1 | 0; + continue ; + } + + } + break; + case /* Text */1 : + if (newVNodes) { + var newText = newVNodes.hd; + if (newText.TAG === /* Text */1) { + var newText$1 = newText._0; + if (oldNode._0 !== newText$1) { + var child = Caml_array.get(elems, idx); + child.nodeValue = newText$1; + } + _newVNodes = newVNodes.tl; + _oldVNodes = oldVNodes.tl; + _idx = idx + 1 | 0; + continue ; + } + + } + break; + case /* Node */2 : + if (newVNodes) { + var newNode = newVNodes.hd; + if (newNode.TAG === /* Node */2) { + var newRest = newVNodes.tl; + var newKey = newNode._2; + var newTagName = newNode._1; + var newNamespace = newNode._0; + var oldRest = oldVNodes.tl; + var oldKey = oldNode._2; + var oldTagName = oldNode._1; + var oldNamespace = oldNode._0; + if (oldKey === newKey && oldKey !== "") { + _newVNodes = newRest; + _oldVNodes = oldRest; + _idx = idx + 1 | 0; + continue ; + } + if (oldKey === "" || newKey === "") { + patchVNodesOnElemsMutateNode(callbacks, elem, elems, idx, oldNode, newNode); + _newVNodes = newRest; + _oldVNodes = oldRest; + _idx = idx + 1 | 0; + continue ; + } + var exit = 0; + var exit$1 = 0; + if (oldRest) { + var match = oldRest.hd; + if (match.TAG === /* Node */2) { + var olderRest = oldRest.tl; + var olderKey = match._2; + var olderTagName = match._1; + var olderNamespace = match._0; + var exit$2 = 0; + if (newRest) { + var match$1 = newRest.hd; + if (match$1.TAG === /* Node */2) { + if (olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey && oldNamespace === match$1._0 && oldTagName === match$1._1 && oldKey === match$1._2) { + var firstChild = Caml_array.get(elems, idx); + var secondChild = Caml_array.get(elems, idx + 1 | 0); + elem.removeChild(secondChild); + elem.insertBefore(secondChild, firstChild); + _newVNodes = newRest.tl; + _oldVNodes = olderRest; + _idx = idx + 2 | 0; + continue ; + } + exit$2 = 4; + } else { + exit$2 = 4; + } + } else { + exit$2 = 4; + } + if (exit$2 === 4) { + if (olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey) { + var oldChild = Caml_array.get(elems, idx); + elem.removeChild(oldChild); + _newVNodes = newRest; + _oldVNodes = olderRest; + _idx = idx + 1 | 0; + continue ; + } + exit$1 = 3; + } + + } else { + exit$1 = 3; + } + } else { + exit$1 = 3; + } + if (exit$1 === 3) { + if (newRest) { + var match$2 = newRest.hd; + if (match$2.TAG === /* Node */2) { + if (oldNamespace === match$2._0 && oldTagName === match$2._1 && oldKey === match$2._2) { + var oldChild$1 = Caml_array.get(elems, idx); + var newChild = patchVNodesOnElemsCreateElement(callbacks, newNode); + elem.insertBefore(newChild, oldChild$1); + _newVNodes = newRest; + _idx = idx + 1 | 0; + continue ; + } + exit = 2; + } else { + exit = 2; + } + } else { + exit = 2; + } + } + if (exit === 2) { + patchVNodesOnElemsMutateNode(callbacks, elem, elems, idx, oldNode, newNode); + _newVNodes = newRest; + _oldVNodes = oldRest; + _idx = idx + 1 | 0; + continue ; + } + + } + + } + break; + case /* LazyGen */3 : + if (newVNodes) { + var match$3 = newVNodes.hd; + if (match$3.TAG === /* LazyGen */3) { + var newRest$1 = newVNodes.tl; + var newCache = match$3._2; + var newGen = match$3._1; + var newKey$1 = match$3._0; + var oldRest$1 = oldVNodes.tl; + var oldCache = oldNode._2; + var oldKey$1 = oldNode._0; + if (oldKey$1 === newKey$1) { + newCache.contents = oldCache.contents; + _newVNodes = newRest$1; + _oldVNodes = oldRest$1; + _idx = idx + 1 | 0; + continue ; + } + var exit$3 = 0; + var exit$4 = 0; + if (oldRest$1) { + var match$4 = oldRest$1.hd; + if (match$4.TAG === /* LazyGen */3) { + var olderRest$1 = oldRest$1.tl; + var olderKey$1 = match$4._0; + var exit$5 = 0; + if (newRest$1) { + var match$5 = newRest$1.hd; + if (match$5.TAG === /* LazyGen */3) { + if (olderKey$1 === newKey$1 && oldKey$1 === match$5._0) { + var firstChild$1 = Caml_array.get(elems, idx); + var secondChild$1 = Caml_array.get(elems, idx + 1 | 0); + elem.removeChild(secondChild$1); + elem.insertBefore(secondChild$1, firstChild$1); + _newVNodes = newRest$1.tl; + _oldVNodes = olderRest$1; + _idx = idx + 2 | 0; + continue ; + } + exit$5 = 4; + } else { + exit$5 = 4; + } + } else { + exit$5 = 4; + } + if (exit$5 === 4) { + if (olderKey$1 === newKey$1) { + var oldChild$2 = Caml_array.get(elems, idx); + elem.removeChild(oldChild$2); + var oldVdom = match$4._2.contents; + newCache.contents = oldVdom; + _newVNodes = newRest$1; + _oldVNodes = olderRest$1; + _idx = idx + 1 | 0; + continue ; + } + exit$4 = 3; + } + + } else { + exit$4 = 3; + } + } else { + exit$4 = 3; + } + if (exit$4 === 3) { + if (newRest$1) { + var match$6 = newRest$1.hd; + if (match$6.TAG === /* LazyGen */3) { + if (match$6._0 === oldKey$1) { + var oldChild$3 = Caml_array.get(elems, idx); + var newVdom = Curry._1(newGen, undefined); + newCache.contents = newVdom; + var newChild$1 = patchVNodesOnElemsCreateElement(callbacks, newVdom); + elem.insertBefore(newChild$1, oldChild$3); + _newVNodes = newRest$1; + _idx = idx + 1 | 0; + continue ; + } + exit$3 = 2; + } else { + exit$3 = 2; + } + } else { + exit$3 = 2; + } + } + if (exit$3 === 2) { + var oldVdom$1 = oldCache.contents; + var newVdom$1 = Curry._1(newGen, undefined); + newCache.contents = newVdom$1; + _newVNodes = { + hd: newVdom$1, + tl: newRest$1 + }; + _oldVNodes = { + hd: oldVdom$1, + tl: oldRest$1 + }; + continue ; + } + + } + + } + break; + case /* Tagger */4 : + _oldVNodes = { + hd: oldNode._1, + tl: oldVNodes.tl + }; + continue ; + + } + var oldRest$2 = oldVNodes.tl; + if (newVNodes) { + var newNode$1 = newVNodes.hd; + if (newNode$1.TAG === /* Tagger */4) { + patchVNodesOnElems(Curry._1(newNode$1._0, callbacks), elem, elems, idx, { + hd: oldNode, + tl: /* [] */0 + }, { + hd: newNode$1._1, + tl: /* [] */0 + }); + _newVNodes = newVNodes.tl; + _oldVNodes = oldRest$2; + _idx = idx + 1 | 0; + continue ; + } + var oldChild$4 = Caml_array.get(elems, idx); + var newChild$2 = patchVNodesOnElemsCreateElement(callbacks, newNode$1); + elem.insertBefore(newChild$2, oldChild$4); + elem.removeChild(oldChild$4); + _newVNodes = newVNodes.tl; + _oldVNodes = oldRest$2; + _idx = idx + 1 | 0; + continue ; + } + var child$1 = Caml_array.get(elems, idx); + elem.removeChild(child$1); + _newVNodes = /* [] */0; + _oldVNodes = oldRest$2; + continue ; + } + if (!newVNodes) { + return ; + } + var newChild$3 = patchVNodesOnElemsCreateElement(callbacks, newVNodes.hd); + elem.appendChild(newChild$3); + _newVNodes = newVNodes.tl; + _oldVNodes = /* [] */0; + _idx = idx + 1 | 0; + continue ; + }; +} + +function patchVNodesIntoElement(callbacks, elem, oldVNodes, newVNodes) { + var elems = elem.childNodes; + patchVNodesOnElems(callbacks, elem, elems, 0, oldVNodes, newVNodes); + return newVNodes; +} + +function patchVNodeIntoElement(callbacks, elem, oldVNode, newVNode) { + return patchVNodesIntoElement(callbacks, elem, { + hd: oldVNode, + tl: /* [] */0 + }, { + hd: newVNode, + tl: /* [] */0 + }); +} + +function wrapCallbacksOn(func, x) { + if (typeof x === "number") { + return /* Render */0; + } else if (x.TAG === /* AddRenderMsg */0) { + return { + TAG: /* AddRenderMsg */0, + _0: Curry._1(func, x._0) + }; + } else { + return { + TAG: /* RemoveRenderMsg */1, + _0: Curry._1(func, x._0) + }; + } +} + +function wrapCallbacks(func, callbacks) { + return { + contents: { + enqueue: (function (msg) { + return Curry._1(callbacks.contents.enqueue, Curry._1(func, msg)); + }), + on: (function (smsg) { + return Curry._1(callbacks.contents.on, wrapCallbacksOn(func, smsg)); + }) + } + }; +} + +function map(func, vdom) { + var tagger = function (param) { + return wrapCallbacks(func, param); + }; + return { + TAG: /* Tagger */4, + _0: tagger, + _1: vdom + }; +} + +var noProp = /* NoProp */0; + +exports.noNode = noNode; +exports.comment = comment; +exports.text = text; +exports.fullnode = fullnode; +exports.node = node; +exports.lazyGen = lazyGen; +exports.noProp = noProp; +exports.prop = prop; +exports.onCB = onCB; +exports.onMsg = onMsg; +exports.attribute = attribute; +exports.data = data; +exports.style = style; +exports.styles = styles; +exports.renderToHtmlString = renderToHtmlString; +exports.emptyEventHandler = emptyEventHandler; +exports.emptyEventCB = emptyEventCB; +exports.eventHandler = eventHandler; +exports.eventHandlerGetCB = eventHandlerGetCB; +exports.compareEventHandlerTypes = compareEventHandlerTypes; +exports.eventHandlerRegister = eventHandlerRegister; +exports.eventHandlerUnregister = eventHandlerUnregister; +exports.eventHandlerMutate = eventHandlerMutate; +exports.patchVNodesOnElemsPropertiesApplyAdd = patchVNodesOnElemsPropertiesApplyAdd; +exports.patchVNodesOnElemsPropertiesApplyRemove = patchVNodesOnElemsPropertiesApplyRemove; +exports.patchVNodesOnElemsPropertiesApplyRemoveAdd = patchVNodesOnElemsPropertiesApplyRemoveAdd; +exports.patchVNodesOnElemsPropertiesApplyMutate = patchVNodesOnElemsPropertiesApplyMutate; +exports.patchVNodesOnElemsPropertiesApply = patchVNodesOnElemsPropertiesApply; +exports.patchVNodesOnElemsProperties = patchVNodesOnElemsProperties; +exports.genEmptyProps = genEmptyProps; +exports.mapEmptyProps = mapEmptyProps; +exports.patchVNodesOnElemsReplaceNode = patchVNodesOnElemsReplaceNode; +exports.patchVNodesOnElemsCreateElement = patchVNodesOnElemsCreateElement; +exports.patchVNodesOnElemsMutateNode = patchVNodesOnElemsMutateNode; +exports.patchVNodesOnElems = patchVNodesOnElems; +exports.patchVNodesIntoElement = patchVNodesIntoElement; +exports.patchVNodeIntoElement = patchVNodeIntoElement; +exports.wrapCallbacksOn = wrapCallbacksOn; +exports.wrapCallbacks = wrapCallbacks; +exports.map = map; +/* No side effect */ diff --git a/lib/js/src-ocaml/web.js b/lib/js/src/web.js similarity index 51% rename from lib/js/src-ocaml/web.js rename to lib/js/src/web.js index 01fbe05..2ea74ee 100644 --- a/lib/js/src-ocaml/web.js +++ b/lib/js/src/web.js @@ -1,32 +1,32 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; var Web_node = require("./web_node.js"); var Web_window = require("./web_window.js"); function polyfills(param) { - Web_node.remove_polyfill(/* () */0); - Web_window.requestAnimationFrame_polyfill(/* () */0); - return /* () */0; + Web_node.remove_polyfill(undefined); + Web_window.requestAnimationFrame_polyfill(undefined); + } -var $$Event = /* alias */0; +var $$Event; -var $$Node = /* alias */0; +var $$Node; -var $$Document = /* alias */0; +var $$Document; -var $$Date = /* alias */0; +var $$Date; -var $$Window = /* alias */0; +var $$Window; -var $$Location = /* alias */0; +var $$Location; -var Json = /* alias */0; +var Json; -var $$XMLHttpRequest = /* alias */0; +var $$XMLHttpRequest; -var $$FormData = /* alias */0; +var $$FormData; exports.$$Event = $$Event; exports.$$Node = $$Node; diff --git a/lib/js/src-ocaml/web_date.js b/lib/js/src/web_date.js similarity index 66% rename from lib/js/src-ocaml/web_date.js rename to lib/js/src/web_date.js index 0616b11..6e84fe7 100644 --- a/lib/js/src-ocaml/web_date.js +++ b/lib/js/src/web_date.js @@ -1,4 +1,4 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; diff --git a/lib/js/src-ocaml/web_document.js b/lib/js/src/web_document.js similarity index 95% rename from lib/js/src-ocaml/web_document.js rename to lib/js/src/web_document.js index def5ddf..24272ed 100644 --- a/lib/js/src-ocaml/web_document.js +++ b/lib/js/src/web_document.js @@ -1,4 +1,4 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; diff --git a/lib/js/src-ocaml/web_event.js b/lib/js/src/web_event.js similarity index 67% rename from lib/js/src-ocaml/web_event.js rename to lib/js/src/web_event.js index 40fed0f..d856702 100644 --- a/lib/js/src-ocaml/web_event.js +++ b/lib/js/src/web_event.js @@ -1,2 +1,2 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/lib/js/src-ocaml/web_formdata.js b/lib/js/src/web_formdata.js similarity index 54% rename from lib/js/src-ocaml/web_formdata.js rename to lib/js/src/web_formdata.js index 5c11e71..73fe08d 100644 --- a/lib/js/src-ocaml/web_formdata.js +++ b/lib/js/src/web_formdata.js @@ -1,9 +1,10 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; function append(key, value, f) { - return f.append(key, value); + f.append(key, value); + } exports.append = append; diff --git a/lib/js/src-ocaml/web_json.js b/lib/js/src/web_json.js similarity index 61% rename from lib/js/src-ocaml/web_json.js rename to lib/js/src/web_json.js index fccb829..763197c 100644 --- a/lib/js/src-ocaml/web_json.js +++ b/lib/js/src/web_json.js @@ -1,20 +1,19 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; -var Js_json = require("bs-platform/lib/js/js_json.js"); - -function string_of_json($staropt$star, value) { - var indent = $staropt$star !== undefined ? $staropt$star : 2; - if (value !== undefined) { - try { - return JSON.stringify(value, null, indent); - } - catch (exn){ - return ""; - } - } else { +var Js_json = require("rescript/lib/js/js_json.js"); + +function string_of_json(indentOpt, value) { + var indent = indentOpt !== undefined ? indentOpt : 2; + if (value === undefined) { return "undefined"; } + try { + return JSON.stringify(value, null, indent); + } + catch (exn){ + return ""; + } } function of_type(_v, x) { @@ -37,6 +36,10 @@ var decodeBoolean = Js_json.decodeBoolean; var decodeNull = Js_json.decodeNull; +var deserializeUnsafe = Js_json.deserializeUnsafe; + +var serializeExn = Js_json.serializeExn; + var $$null = null; exports.classify = classify; @@ -47,6 +50,8 @@ exports.decodeObject = decodeObject; exports.decodeArray = decodeArray; exports.decodeBoolean = decodeBoolean; exports.decodeNull = decodeNull; +exports.deserializeUnsafe = deserializeUnsafe; +exports.serializeExn = serializeExn; exports.string_of_json = string_of_json; exports.of_type = of_type; exports.$$null = $$null; diff --git a/lib/js/src-ocaml/web_location.js b/lib/js/src/web_location.js similarity index 91% rename from lib/js/src-ocaml/web_location.js rename to lib/js/src/web_location.js index 6ab044c..d05f9ac 100644 --- a/lib/js/src-ocaml/web_location.js +++ b/lib/js/src/web_location.js @@ -1,4 +1,4 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; @@ -8,7 +8,7 @@ function getHref($$location) { function setHref($$location, value) { $$location.href = value; - return /* () */0; + } function getProtocol($$location) { @@ -17,7 +17,7 @@ function getProtocol($$location) { function setProtocol($$location, value) { $$location.protocol = value; - return /* () */0; + } function getHost($$location) { @@ -26,7 +26,7 @@ function getHost($$location) { function setHost($$location, value) { $$location.host = value; - return /* () */0; + } function getHostname($$location) { @@ -35,7 +35,7 @@ function getHostname($$location) { function setHostname($$location, value) { $$location.hostname = value; - return /* () */0; + } function getPort($$location) { @@ -44,7 +44,7 @@ function getPort($$location) { function setPort($$location, value) { $$location.port = value; - return /* () */0; + } function getPathname($$location) { @@ -53,7 +53,7 @@ function getPathname($$location) { function setPathname($$location, value) { $$location.pathname = value; - return /* () */0; + } function getSearch($$location) { @@ -62,7 +62,7 @@ function getSearch($$location) { function setSearch($$location, value) { $$location.search = value; - return /* () */0; + } function getHash($$location) { @@ -71,7 +71,7 @@ function getHash($$location) { function setHash($$location, value) { $$location.hash = value; - return /* () */0; + } function getUsername($$location) { @@ -80,7 +80,7 @@ function getUsername($$location) { function setUsername($$location, value) { $$location.username = value; - return /* () */0; + } function getPassword($$location) { @@ -89,7 +89,7 @@ function getPassword($$location) { function setPassword($$location, value) { $$location.password = value; - return /* () */0; + } function getOrigin($$location) { diff --git a/lib/js/src-ocaml/web_node.js b/lib/js/src/web_node.js similarity index 72% rename from lib/js/src-ocaml/web_node.js rename to lib/js/src/web_node.js index b80a1a8..190f0c7 100644 --- a/lib/js/src-ocaml/web_node.js +++ b/lib/js/src/web_node.js @@ -1,4 +1,4 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; @@ -12,15 +12,16 @@ function getStyle(n, key) { function setStyle(n, key, value) { n.style[key] = value; - return /* () */0; + } -function setStyleProperty(n, $staropt$star, key, value) { - var priority = $staropt$star !== undefined ? $staropt$star : false; +function setStyleProperty(n, priorityOpt, key, value) { + var priority = priorityOpt !== undefined ? priorityOpt : false; var style = n.style; - var match = style.setProperty; - if (match !== undefined) { - return style.setProperty(key, value, priority ? "important" : null); + var _valid = style.setProperty; + if (_valid !== undefined) { + key.setProperty__(value, priority ? "important" : null); + return ; } else { return setStyle(n, key, value); } @@ -47,56 +48,64 @@ function insertBefore(n, child, refNode) { } function remove(n, child) { - return n.remove(child); + n.remove(); + } function setAttributeNS(n, namespace, key, value) { - return n.setAttributeNS(namespace, key, value); + n.setAttributeNS(namespace, key, value); + } function setAttribute(n, key, value) { - return n.setAttribute(key, value); + n.setAttribute(key, value); + } function setAttributeNsOptional(n, namespace, key, value) { if (namespace === "") { - return n.setAttribute(key, value); + return setAttribute(n, key, value); } else { - return n.setAttributeNS(namespace, key, value); + return setAttributeNS(n, namespace, key, value); } } function removeAttributeNS(n, namespace, key) { - return n.removeAttributeNS(namespace, key); + n.removeAttributeNS(namespace, key); + } function removeAttribute(n, key) { - return n.removeAttribute(key); + n.removeAttribute(key); + } function removeAttributeNsOptional(n, namespace, key) { - if (namespace === "") { - return n.removeAttribute(key); - } else { - return n.removeAttributeNS(namespace, key); + if (namespace !== "") { + return removeAttributeNS(n, namespace, key); } + n.removeAttribute(key); + } function addEventListener(n, typ, listener, options) { - return n.addEventListener(typ, listener, options); + n.addEventListener(typ, listener, options); + } function removeEventListener(n, typ, listener, options) { - return n.removeEventListener(typ, listener, options); + n.removeEventListener(typ, listener, options); + } function focus(n) { - return n.focus(); + n.focus(); + } function set_nodeValue(n, text) { n.nodeValue = text; - return /* () */0; + } function get_nodeValue(n) { diff --git a/lib/js/src-ocaml/web_window.js b/lib/js/src/web_window.js similarity index 88% rename from lib/js/src-ocaml/web_window.js rename to lib/js/src/web_window.js index bb7aa95..6bb5ba8 100644 --- a/lib/js/src-ocaml/web_window.js +++ b/lib/js/src/web_window.js @@ -1,4 +1,4 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE +// Generated by ReScript, PLEASE EDIT WITH CARE 'use strict'; @@ -19,11 +19,13 @@ function requestAnimationFrame(callback) { } function cancelAnimationFrame(id) { - return window.cancelAnimationFrame(id); + window.cancelAnimationFrame(id); + } function $$clearTimeout(id) { - return window.clearTimeout(id); + window.clearTimeout(id); + } function $$setInterval(cb, msTime) { @@ -35,11 +37,13 @@ function $$setTimeout(cb, msTime) { } function addEventListener(typ, listener, options) { - return window.addEventListener(typ, listener, options); + window.addEventListener(typ, listener, options); + } function removeEventListener(typ, listener, options) { - return window.removeEventListener(typ, listener, options); + window.removeEventListener(typ, listener, options); + } function requestAnimationFrame_polyfill(param) { @@ -70,9 +74,9 @@ function requestAnimationFrame_polyfill(param) { }())); } -var $$History = /* alias */0; +var $$History; -var LocalStorage = /* alias */0; +var LocalStorage; exports.$$History = $$History; exports.LocalStorage = LocalStorage; diff --git a/lib/js/src/web_window_history.js b/lib/js/src/web_window_history.js new file mode 100644 index 0000000..71d5b4c --- /dev/null +++ b/lib/js/src/web_window_history.js @@ -0,0 +1,74 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + + +function length($$window) { + var history = $$window.history; + if (history !== undefined) { + return history.length; + } else { + return -1; + } +} + +function back($$window) { + var history = $$window.history; + if (history !== undefined) { + history.back(); + return ; + } + +} + +function forward($$window) { + var history = $$window.history; + if (history !== undefined) { + history.forward(); + return ; + } + +} + +function go($$window, to) { + var history = $$window.history; + if (history !== undefined) { + history.go(to); + return ; + } + +} + +function pushState($$window, state, title, url) { + var history = $$window.history; + if (history !== undefined) { + history.pushState(state, title, url); + return ; + } + +} + +function replaceState($$window, state, title, url) { + var history = $$window.history; + if (history !== undefined) { + history.replaceState(state, title, url); + return ; + } + +} + +function state($$window) { + var history = $$window.history; + if (history !== undefined) { + return history.state; + } + +} + +exports.length = length; +exports.back = back; +exports.forward = forward; +exports.go = go; +exports.pushState = pushState; +exports.replaceState = replaceState; +exports.state = state; +/* No side effect */ diff --git a/lib/js/src/web_window_localstorage.js b/lib/js/src/web_window_localstorage.js new file mode 100644 index 0000000..8bd5dc0 --- /dev/null +++ b/lib/js/src/web_window_localstorage.js @@ -0,0 +1,65 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_option = require("rescript/lib/js/caml_option.js"); + +function length($$window) { + var localStorage = $$window.localStorage; + if (localStorage !== undefined) { + return Caml_option.some(localStorage.length); + } + +} + +function clear($$window) { + var localStorage = $$window.localStorage; + if (localStorage !== undefined) { + return Caml_option.some((localStorage.clear(), undefined)); + } + +} + +function key($$window, idx) { + var localStorage = $$window.localStorage; + if (localStorage !== undefined) { + return localStorage.key(idx); + } + +} + +function getItem($$window, key) { + var localStorage = $$window.localStorage; + if (localStorage === undefined) { + return ; + } + try { + return localStorage.getItem(key); + } + catch (exn){ + return ; + } +} + +function removeItem($$window, key) { + var localStorage = $$window.localStorage; + if (localStorage !== undefined) { + return Caml_option.some((localStorage.removeItem(key), undefined)); + } + +} + +function setItem($$window, key, value) { + var localStorage = $$window.localStorage; + if (localStorage !== undefined) { + return Caml_option.some((localStorage.setItem(key, value), undefined)); + } + +} + +exports.length = length; +exports.clear = clear; +exports.key = key; +exports.getItem = getItem; +exports.removeItem = removeItem; +exports.setItem = setItem; +/* No side effect */ diff --git a/lib/js/src/web_xmlhttprequest.js b/lib/js/src/web_xmlhttprequest.js new file mode 100644 index 0000000..f0aa897 --- /dev/null +++ b/lib/js/src/web_xmlhttprequest.js @@ -0,0 +1,394 @@ +// Generated by ReScript, PLEASE EDIT WITH CARE +'use strict'; + +var List = require("rescript/lib/js/list.js"); +var $$Array = require("rescript/lib/js/array.js"); +var Curry = require("rescript/lib/js/curry.js"); +var Caml_option = require("rescript/lib/js/caml_option.js"); +var Web_formdata = require("./web_formdata.js"); +var Belt_MapString = require("rescript/lib/js/belt_MapString.js"); + +function abort(x) { + x.abort(); + +} + +function getAllResponseHeaders(x) { + var s = x.getAllResponseHeaders(); + if (s !== null) { + if (s === "") { + return { + TAG: /* Error */1, + _0: /* NetworkError */1 + }; + } else { + return { + TAG: /* Ok */0, + _0: s + }; + } + } else { + return { + TAG: /* Error */1, + _0: /* IncompleteResponse */0 + }; + } +} + +function getAllResponseHeadersAsList(x) { + var err = getAllResponseHeaders(x); + if (err.TAG === /* Ok */0) { + return { + TAG: /* Ok */0, + _0: List.map((function (x) { + if (x.length !== 2) { + throw { + RE_EXN_ID: "Failure", + _1: "Cannot happen, already checked length", + Error: new Error() + }; + } + var key = x[0]; + var value = x[1]; + return [ + key, + value + ]; + }), List.filter(function (a) { + return a.length === 2; + })($$Array.to_list($$Array.map((function (param) { + return param.split(": ", 2); + }), err._0.split("\r\n"))))) + }; + } else { + return err; + } +} + +function getAllResponseHeadersAsDict(x) { + var err = getAllResponseHeadersAsList(x); + if (err.TAG !== /* Ok */0) { + return err; + } + var insert = function (d, param) { + return Belt_MapString.set(d, param[0], param[1]); + }; + return { + TAG: /* Ok */0, + _0: List.fold_left(insert, undefined, err._0) + }; +} + +function getResponseHeader(key, x) { + return Caml_option.null_to_opt(Curry._1(x.getResponse, key)); +} + +function open_(method, url, asyncOpt, userOpt, passwordOpt, x) { + var async = asyncOpt !== undefined ? asyncOpt : true; + var user = userOpt !== undefined ? userOpt : ""; + var password = passwordOpt !== undefined ? passwordOpt : ""; + x._open(method, url, async, user, password); + +} + +function overrideMimeType(mimetype, x) { + x.overrideMimeType(mimetype); + +} + +function send(body, x) { + if (typeof body === "number") { + if (body === /* EmptyBody */0) { + x.send(); + return ; + } + x.send__string(null); + return ; + } else { + switch (body.TAG | 0) { + case /* StringBody */0 : + x.send__string(body._0); + return ; + case /* FormDataBody */1 : + x.send__formdata(body._0); + return ; + case /* FormListBody */2 : + var form = List.fold_left((function (f, param) { + Web_formdata.append(param[0], param[1], f); + return f; + }), new FormData(), body._0); + x.send__formdata(form); + return ; + case /* DocumentBody */3 : + x.send__document(body._0); + return ; + + } + } +} + +function setRequestHeader(header, value, x) { + x.setRequestHeader(header, value); + +} + +function set_onreadystatechange(cb, x) { + x.onreadystatechange = cb; + +} + +function get_onreadystatechange(x) { + return x.onreadystatechange; +} + +function readyState(x) { + var i = x.readyState; + if (!(i > 4 || i < 0)) { + return i; + } + var s = "Invalid return from 'readystate' of: " + String(i); + throw { + RE_EXN_ID: "Failure", + _1: s, + Error: new Error() + }; +} + +function set_responseType(typ, x) { + if (typeof typ !== "number") { + x.responseType = typ._0; + return ; + } + switch (typ) { + case /* StringResponseType */0 : + x.responseType = ""; + return ; + case /* ArrayBufferResponseType */1 : + x.responseType = "arraybuffer"; + return ; + case /* BlobResponseType */2 : + x.responseType = "blob"; + return ; + case /* DocumentResponseType */3 : + x.responseType = "document"; + return ; + case /* JsonResponseType */4 : + x.responseType = "json"; + return ; + case /* TextResponseType */5 : + x.responseType = "text"; + return ; + + } +} + +function get_responseType(x) { + var s = x.responseType; + switch (s) { + case "" : + return /* StringResponseType */0; + case "arraybuffer" : + return /* ArrayBufferResponseType */1; + case "blob" : + return /* BlobResponseType */2; + case "document" : + return /* DocumentResponseType */3; + case "json" : + return /* JsonResponseType */4; + case "text" : + return /* TextResponseType */5; + default: + return /* RawResponseType */{ + _0: s + }; + } +} + +function get_response(x) { + var resp = x.response; + if (resp === null) { + return /* NoResponse */0; + } + var s = get_responseType(x); + if (typeof s !== "number") { + return { + TAG: /* RawResponse */6, + _0: s._0, + _1: resp + }; + } + switch (s) { + case /* StringResponseType */0 : + return { + TAG: /* StringResponse */0, + _0: resp + }; + case /* ArrayBufferResponseType */1 : + return { + TAG: /* ArrayBufferResponse */1, + _0: resp + }; + case /* BlobResponseType */2 : + return { + TAG: /* BlobResponse */2, + _0: resp + }; + case /* DocumentResponseType */3 : + return { + TAG: /* DocumentResponse */3, + _0: resp + }; + case /* JsonResponseType */4 : + return { + TAG: /* JsonResponse */4, + _0: resp + }; + case /* TextResponseType */5 : + return { + TAG: /* TextResponse */5, + _0: resp + }; + + } +} + +function get_responseText(x) { + return x.responseText; +} + +function get_responseURL(x) { + return x.responseURL; +} + +function get_responseXML(x) { + return Caml_option.null_to_opt(x.responseXML); +} + +function get_status(x) { + return x.status; +} + +function get_statusText(x) { + return x.statusText; +} + +function set_timeout(t, x) { + x.timeout = t; + +} + +function get_timeout(x) { + return x.timeout; +} + +function set_withCredentials(b, x) { + x.withCredentials = b; + +} + +function get_withCredentials(x) { + return x.withCredentials; +} + +function set_onabort(cb, x) { + x.onabort = cb; + +} + +function get_onabort(x) { + return x.onabort; +} + +function set_onerror(cb, x) { + x.onerror = cb; + +} + +function get_onerror(x) { + return x.onerror; +} + +function set_onload(cb, x) { + x.onload = cb; + +} + +function get_onload(x) { + return x.onload; +} + +function set_onloadstart(cb, x) { + x.onloadstart = cb; + +} + +function get_onloadstart(x) { + return x.onloadstart; +} + +function set_onprogress(cb, x) { + x.onprogress = cb; + +} + +function get_onprogress(x) { + return x.onprogress; +} + +function set_ontimeout(cb, x) { + x.ontimeout = cb; + +} + +function get_ontimeout(x) { + return x.ontimeout; +} + +function set_onloadend(cb, x) { + x.onloadend = cb; + +} + +function get_onloadend(x) { + return x.onloadend; +} + +exports.abort = abort; +exports.getAllResponseHeaders = getAllResponseHeaders; +exports.getAllResponseHeadersAsList = getAllResponseHeadersAsList; +exports.getAllResponseHeadersAsDict = getAllResponseHeadersAsDict; +exports.getResponseHeader = getResponseHeader; +exports.open_ = open_; +exports.overrideMimeType = overrideMimeType; +exports.send = send; +exports.setRequestHeader = setRequestHeader; +exports.set_onreadystatechange = set_onreadystatechange; +exports.get_onreadystatechange = get_onreadystatechange; +exports.readyState = readyState; +exports.set_responseType = set_responseType; +exports.get_responseType = get_responseType; +exports.get_response = get_response; +exports.get_responseText = get_responseText; +exports.get_responseURL = get_responseURL; +exports.get_responseXML = get_responseXML; +exports.get_status = get_status; +exports.get_statusText = get_statusText; +exports.set_timeout = set_timeout; +exports.get_timeout = get_timeout; +exports.set_withCredentials = set_withCredentials; +exports.get_withCredentials = get_withCredentials; +exports.set_onabort = set_onabort; +exports.get_onabort = get_onabort; +exports.set_onerror = set_onerror; +exports.get_onerror = get_onerror; +exports.set_onload = set_onload; +exports.get_onload = get_onload; +exports.set_onloadstart = set_onloadstart; +exports.get_onloadstart = get_onloadstart; +exports.set_onprogress = set_onprogress; +exports.get_onprogress = get_onprogress; +exports.set_ontimeout = set_ontimeout; +exports.get_ontimeout = get_ontimeout; +exports.set_onloadend = set_onloadend; +exports.get_onloadend = get_onloadend; +/* No side effect */ diff --git a/lib/js/test-ocaml/app_test_client.js b/lib/js/test-ocaml/app_test_client.js deleted file mode 100644 index 30269de..0000000 --- a/lib/js/test-ocaml/app_test_client.js +++ /dev/null @@ -1,28080 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Test_client = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 0) { - var match = parentNode.firstChild; - if (match !== null) { - parentNode.removeChild(match); - } - - }; - return /* () */0; - }; - var oldSub = { - contents: /* NoSub */0 - }; - var handleSubscriptionChange = function (model) { - var newSub = Curry._1(subscriptions, model); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); - return /* () */0; - }; - var handlerStartup = function (param) { - clearPnode(/* () */0); - Tea_cmd.run(callbacks, initCmd); - handleSubscriptionChange(latestModel.contents); - nextFrameID.contents = -1; - doRender(16); - return /* () */0; - }; - var render_string = function (model) { - return Vdom.renderToHtmlString(Curry._1(view, model)); - }; - var handler = function (model, msg) { - var match = Curry._2(update, model, msg); - var newModel = match[0]; - latestModel.contents = newModel; - Tea_cmd.run(callbacks, match[1]); - scheduleRender(/* () */0); - handleSubscriptionChange(newModel); - return newModel; - }; - var handlerShutdown = function (cmd) { - nextFrameID.contents = undefined; - Tea_cmd.run(callbacks, cmd); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); - priorRenderedVdom.contents = /* [] */0; - clearPnode(/* () */0); - return /* () */0; - }; - return { - startup: handlerStartup, - render_string: render_string, - handleMsg: handler, - shutdown: handlerShutdown - }; - }); - } else { - return (function (callbacks) { - var oldSub = { - contents: /* NoSub */0 - }; - var handleSubscriptionChange = function (model) { - var newSub = Curry._1(subscriptions, model); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub); - return /* () */0; - }; - return { - startup: (function (param) { - Tea_cmd.run(callbacks, initCmd); - handleSubscriptionChange(initModel); - return /* () */0; - }), - render_string: (function (model) { - return Vdom.renderToHtmlString(Curry._1(view, model)); - }), - handleMsg: (function (model, msg) { - var match = Curry._2(update, model, msg); - var newModel = match[0]; - Tea_cmd.run(callbacks, match[1]); - handleSubscriptionChange(newModel); - return newModel; - }), - shutdown: (function (cmd) { - Tea_cmd.run(callbacks, cmd); - oldSub.contents = Tea_sub.run(callbacks, callbacks, oldSub.contents, /* NoSub */0); - return /* () */0; - }) - }; - }); - } -} - -function program(param, pnode, flags) { - Web.polyfills(/* () */0); - var match = Curry._1(param.init, flags); - var initModel = match[0]; - var opnode = (pnode == null) ? undefined : Caml_option.some(pnode); - var pumpInterface = programLoop(param.update, param.view, param.subscriptions, initModel, match[1], opnode); - return programStateWrapper(initModel, pumpInterface, param.shutdown); -} - -function standardProgram(param, pnode, args) { - return program({ - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }, pnode, args); -} - -function beginnerProgram(param, pnode, param$1) { - var update = param.update; - var model = param.model; - return standardProgram({ - init: (function (param) { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - }), - update: (function (model, msg) { - return /* tuple */[ - Curry._2(update, model, msg), - /* NoCmd */0 - ]; - }), - view: param.view, - subscriptions: (function (_model) { - return /* NoSub */0; - }) - }, pnode, /* () */0); -} - -var map = Vdom.map; - -exports.programStateWrapper = programStateWrapper; -exports.programLoop = programLoop; -exports.program = program; -exports.standardProgram = standardProgram; -exports.beginnerProgram = beginnerProgram; -exports.map = map; -/* No side effect */ - -},{"./tea_cmd.js":2,"./tea_sub.js":12,"./vdom.js":14,"./web.js":15,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],2:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); - -function batch(cmds) { - return /* Batch */Block.__(1, [cmds]); -} - -function call(call$1) { - return /* EnqueueCall */Block.__(2, [call$1]); -} - -function fnMsg(fnMsg$1) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(callbacks.contents.enqueue, Curry._1(fnMsg$1, /* () */0)); - })]); -} - -function msg(msg$1) { - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(callbacks.contents.enqueue, msg$1); - })]); -} - -function run(_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Mapper */0 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - case /* Batch */1 : - return List.fold_left((function(callbacks){ - return function (param, cmd) { - return run(callbacks, cmd); - } - }(callbacks)), /* () */0, param[0]); - case /* EnqueueCall */2 : - return Curry._1(param[0], callbacks); - - } - } - }; -} - -function map(func, cmd) { - var mapper = function (param) { - return Vdom.wrapCallbacks(func, param); - }; - return /* Mapper */Block.__(0, [ - mapper, - cmd - ]); -} - -var none = /* NoCmd */0; - -exports.none = none; -exports.batch = batch; -exports.call = call; -exports.fnMsg = fnMsg; -exports.msg = msg; -exports.run = run; -exports.map = map; -/* No side effect */ - -},{"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],3:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Printf = require("bs-platform/lib/js/printf.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_cmd = require("./tea_cmd.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_html2 = require("./tea_html2.js"); -var Tea_navigation = require("./tea_navigation.js"); - -function client_msg(msg) { - return /* ClientMsg */Block.__(0, [msg]); -} - -function debug(string_of_msg, update, view, subscriptions, shutdown) { - var init_debug = function (param) { - return /* tuple */[ - { - history: /* :: */[ - /* tuple */[ - "_init_", - param[0] - ], - /* [] */0 - ], - state: /* Running */0, - show_details: false - }, - Tea_cmd.map(client_msg, param[1]) - ]; - }; - var update$prime = function (model, param) { - if (typeof param === "number") { - if (param === /* TogglePaused */0) { - var match = model.state; - if (match) { - return /* tuple */[ - { - history: model.history, - state: /* Running */0, - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } else { - return /* tuple */[ - { - history: model.history, - state: /* Paused */[0], - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } - } else { - return /* tuple */[ - { - history: model.history, - state: model.state, - show_details: !model.show_details - }, - /* NoCmd */0 - ]; - } - } else if (param.tag) { - return /* tuple */[ - { - history: model.history, - state: /* Paused */[param[0]], - show_details: model.show_details - }, - /* NoCmd */0 - ]; - } else if (model.state === /* Running */0) { - var msg = param[0]; - var match$1 = List.hd(model.history); - var match$2 = Curry._2(update, match$1[1], msg); - var dmodel$prime_history = /* :: */[ - /* tuple */[ - Curry._1(string_of_msg, msg), - match$2[0] - ], - model.history - ]; - var dmodel$prime_state = model.state; - var dmodel$prime_show_details = model.show_details; - var dmodel$prime = { - history: dmodel$prime_history, - state: dmodel$prime_state, - show_details: dmodel$prime_show_details - }; - return /* tuple */[ - dmodel$prime, - Tea_cmd.map(client_msg, match$2[1]) - ]; - } else { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - } - }; - var view_styles = function (param) { - var rule = function (selector, properties) { - return /* Text */Block.__(1, [Curry._2(Printf.sprintf(/* Format */[ - /* String */Block.__(2, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " {", - /* String */Block.__(2, [ - /* No_padding */0, - /* Char_literal */Block.__(12, [ - /* "}" */125, - /* End_of_format */0 - ]) - ]) - ]) - ]), - "%s {%s}" - ]), selector, $$String.concat(";", List.map((function (param) { - return param[0] + (":" + param[1]); - }), properties)))]); - }; - return Tea_html2.node(undefined, "style", undefined, undefined, /* [] */0, /* :: */[ - rule("#debug.paused", /* :: */[ - /* tuple */[ - "position", - "fixed" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "left", - "0" - ], - /* :: */[ - /* tuple */[ - "width", - "100%" - ], - /* :: */[ - /* tuple */[ - "height", - "100%" - ], - /* :: */[ - /* tuple */[ - "pointer-events", - "all" - ], - /* :: */[ - /* tuple */[ - "background-color", - "rgba(0,0,0,.1)" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "inset 0 0 10px #333" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav", /* :: */[ - /* tuple */[ - "position", - "fixed" - ], - /* :: */[ - /* tuple */[ - "max-width", - "50%" - ], - /* :: */[ - /* tuple */[ - "bottom", - "0" - ], - /* :: */[ - /* tuple */[ - "right", - "6px" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* :: */[ - /* tuple */[ - "background-color", - "#444" - ], - /* :: */[ - /* tuple */[ - "color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "font-family", - "monospace" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "0 0 10px #333" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug.paused nav", /* :: */[ - /* tuple */[ - "height", - "50%" - ], - /* :: */[ - /* tuple */[ - "padding-bottom", - "2em" - ], - /* [] */0 - ] - ]), - /* :: */[ - rule("#debug nav .toggle", /* :: */[ - /* tuple */[ - "padding", - "6px" - ], - /* :: */[ - /* tuple */[ - "padding-left", - "9px" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "min-width", - "24ch" - ], - /* :: */[ - /* tuple */[ - "text-align", - "center" - ], - /* :: */[ - /* tuple */[ - "border-left", - "3px solid #333" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .toggle:before", /* :: */[ - /* tuple */[ - "content", - "' '" - ], - /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "left", - "0" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "width", - ".5ch" - ], - /* :: */[ - /* tuple */[ - "height", - "1.8ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "1.2ch" - ], - /* :: */[ - /* tuple */[ - "border", - "solid #fff" - ], - /* :: */[ - /* tuple */[ - "border-width", - "0 .5ch" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug.paused nav .toggle:before", /* :: */[ - /* tuple */[ - "border-color", - "transparent" - ], - /* :: */[ - /* tuple */[ - "border-left-color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "border-width", - "1ch" - ], - /* :: */[ - /* tuple */[ - "width", - "0" - ], - /* :: */[ - /* tuple */[ - "height", - "0" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history", /* :: */[ - /* tuple */[ - "margin", - "0" - ], - /* :: */[ - /* tuple */[ - "padding", - "0" - ], - /* :: */[ - /* tuple */[ - "height", - "100%" - ], - /* :: */[ - /* tuple */[ - "overflow-y", - "auto" - ], - /* :: */[ - /* tuple */[ - "list-style", - "none" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li", /* :: */[ - /* tuple */[ - "margin", - "0" - ], - /* :: */[ - /* tuple */[ - "padding", - "0.2ch" - ], - /* :: */[ - /* tuple */[ - "border-left", - "3px solid #333" - ], - /* [] */0 - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li.selected", /* :: */[ - /* tuple */[ - "background-color", - "#333" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history span.details", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "width", - "1ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "0 1ch" - ], - /* :: */[ - /* tuple */[ - "vertical-align", - "super" - ], - /* [] */0 - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history li.selected span.details:after", /* :: */[ - /* tuple */[ - "content", - "'\\2026'" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history li.selected.show", /* :: */[ - /* tuple */[ - "border-left", - "3px solid white" - ], - /* [] */0 - ]), - /* :: */[ - rule("#debug nav .history span.message", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "cursor", - "pointer" - ], - /* :: */[ - /* tuple */[ - "white-space", - "nowrap" - ], - /* :: */[ - /* tuple */[ - "overflow", - "hidden" - ], - /* :: */[ - /* tuple */[ - "text-overflow", - "ellipsis" - ], - /* :: */[ - /* tuple */[ - "width", - "calc(100% - 75px)" - ], - /* [] */0 - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug nav .history span.index", /* :: */[ - /* tuple */[ - "display", - "inline-block" - ], - /* :: */[ - /* tuple */[ - "min-width", - "3ch" - ], - /* :: */[ - /* tuple */[ - "margin", - "0 1ch" - ], - /* :: */[ - /* tuple */[ - "color", - "#aaa" - ], - /* :: */[ - /* tuple */[ - "text-align", - "right" - ], - /* :: */[ - /* tuple */[ - "float", - "right" - ], - /* [] */0 - ] - ] - ] - ] - ] - ]), - /* :: */[ - rule("#debug aside.details", /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "width", - "40ch" - ], - /* :: */[ - /* tuple */[ - "top", - "0" - ], - /* :: */[ - /* tuple */[ - "bottom", - "0" - ], - /* :: */[ - /* tuple */[ - "right", - "100%" - ], - /* :: */[ - /* tuple */[ - "margin-right", - "1.5ch" - ], - /* :: */[ - /* tuple */[ - "overflow", - "scroll" - ], - /* :: */[ - /* tuple */[ - "background-color", - "#fff" - ], - /* :: */[ - /* tuple */[ - "color", - "#000" - ], - /* :: */[ - /* tuple */[ - "box-shadow", - "0 0 10px #333" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px 4px 0 0" - ], - /* :: */[ - /* tuple */[ - "border", - "2px solid #333" - ], - /* :: */[ - /* tuple */[ - "padding", - "1ch" - ], - /* :: */[ - /* tuple */[ - "white-space", - "pre" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]), - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]); - }; - var view_details = function (model) { - var format = (function (v) { - var formatRecord = function (data, labels) { - return data.reduce( - function (acc, cur, index) { - acc[labels[index]] = formatValue(cur) - return acc - }, {}) - } - var listToArray = function (data) { - var result = [] - var cur = data - while (typeof cur !== "number") { - result.push(formatValue(cur[0])) - cur = cur[1] - } - return result - } - var formatVariant = function (data, recordVariant) { - if (recordVariant === "::") { - return listToArray(data) - } - else { - return formatRecord(data, [recordVariant]) - } - } - var formatValue = function (x) { - var recordLabels, recordVariant, recordModule, recordPolyVar - if (x == null) { - return null - } - else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { - return formatRecord(x, recordLabels) - } - else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { - return formatRecord(x, recordModule) - } - else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { - return formatVariant(x, recordVariant) - } - else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { - return x[1] - } - else if (Array.isArray(x)) { - // tuple - return x.map(formatValue) - } - else { - // scalar - return x - } - } - return JSON.stringify(formatValue(v), null, 2); - }); - return Tea_html2.aside(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("details"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [format(model)]), - /* [] */0 - ]); - }; - var view_history = function (model, selected_index) { - var count = List.length(model.history); - return Tea_html2.ul(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("history"), - /* [] */0 - ], List.mapi((function (i, param) { - var selected = i === selected_index; - return Tea_html2.li(undefined, undefined, /* :: */[ - Tea_html2.Events.onClick(/* SelectHistoryItem */Block.__(1, [i])), - /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "selected", - selected - ], - /* :: */[ - /* tuple */[ - "show", - selected && model.show_details - ], - /* [] */0 - ] - ]), - /* [] */0 - ] - ], /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "details", - true - ], - /* :: */[ - /* tuple */[ - "show", - true - ], - /* [] */0 - ] - ]), - selected ? /* :: */[ - Tea_html2.Events.onClick(/* ToggleDetails */1), - /* :: */[ - Tea_html2.Attributes.title("toggle details"), - /* [] */0 - ] - ] : /* :: */[ - Tea_html2.Attributes.noProp, - /* :: */[ - Tea_html2.Attributes.noProp, - /* [] */0 - ] - ] - ], /* :: */[ - selected && model.show_details ? view_details(param[1]) : Tea_html2.noNode, - /* [] */0 - ]), - /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("message"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [param[0]]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.span(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("index"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(count - i | 0)]), - /* [] */0 - ]), - /* [] */0 - ] - ] - ]); - }), model.history)); - }; - var view$prime = function (model) { - var match = model.state; - var match$1; - if (match) { - var index = match[0]; - match$1 = /* tuple */[ - index, - List.nth(model.history, index)[1], - true - ]; - } else { - match$1 = /* tuple */[ - 0, - List.hd(model.history)[1], - false - ]; - } - var paused = match$1[2]; - var history_count = List.length(model.history); - var vnode = Curry._1(view, match$1[1]); - return Tea_html2.div(undefined, undefined, /* [] */0, /* :: */[ - Vdom.map(client_msg, vnode), - /* :: */[ - Tea_html2.div(undefined, undefined, /* :: */[ - Tea_html2.Attributes.id("debug"), - /* :: */[ - Tea_html2.Attributes.classList(/* :: */[ - /* tuple */[ - "paused", - paused - ], - /* [] */0 - ]), - /* [] */0 - ] - ], /* :: */[ - view_styles(/* () */0), - /* :: */[ - Tea_html2.nav(undefined, undefined, /* [] */0, /* :: */[ - Tea_html2.div(undefined, undefined, /* :: */[ - Tea_html2.Attributes.class$prime("toggle"), - /* :: */[ - Tea_html2.Events.onClick(/* TogglePaused */0), - /* :: */[ - paused ? Tea_html2.Attributes.title("click to resume") : Tea_html2.Attributes.title("click to pause"), - /* [] */0 - ] - ] - ], /* :: */[ - /* Text */Block.__(1, [Curry._1(Printf.sprintf(/* Format */[ - /* String_literal */Block.__(11, [ - "Explore History (", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* Char_literal */Block.__(12, [ - /* ")" */41, - /* End_of_format */0 - ]) - ]) - ]), - "Explore History (%d)" - ]), history_count)]), - /* [] */0 - ]), - /* :: */[ - paused ? view_history(model, match$1[0]) : Tea_html2.noNode, - /* [] */0 - ] - ]), - /* [] */0 - ] - ]), - /* [] */0 - ] - ]); - }; - var subscriptions$prime = function (model) { - return Tea_sub.map(client_msg, Curry._1(subscriptions, List.hd(model.history)[1])); - }; - var shutdown$prime = function (model) { - return Tea_cmd.map(client_msg, Curry._1(shutdown, List.hd(model.history)[1])); - }; - return /* tuple */[ - init_debug, - update$prime, - view$prime, - subscriptions$prime, - shutdown$prime - ]; -} - -function debug_program(string_of_msg, param) { - var init = param.init; - var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); - var init_debug = match[0]; - return { - init: (function (flags) { - return Curry._1(init_debug, Curry._1(init, flags)); - }), - update: match[1], - view: match[2], - subscriptions: match[3], - shutdown: match[4] - }; -} - -function debug_navigation_program(string_of_msg, param) { - var init = param.init; - var match = debug(string_of_msg, param.update, param.view, param.subscriptions, param.shutdown); - var init_debug = match[0]; - return { - init: (function (flags, $$location) { - return Curry._1(init_debug, Curry._2(init, flags, $$location)); - }), - update: match[1], - view: match[2], - subscriptions: match[3], - shutdown: match[4] - }; -} - -function beginnerProgram(param, string_of_msg, pnode, flags) { - var update = param.update; - var model = param.model; - var debugged = debug_program(string_of_msg, { - init: (function (param) { - return /* tuple */[ - model, - /* NoCmd */0 - ]; - }), - update: (function (model, msg) { - return /* tuple */[ - Curry._2(update, model, msg), - /* NoCmd */0 - ]; - }), - view: param.view, - subscriptions: (function (_model) { - return /* NoSub */0; - }), - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }); - return Tea_app.program(debugged, pnode, flags); -} - -function standardProgram(param, string_of_msg, pnode, flags) { - var debugged = debug_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: (function (_model) { - return /* NoCmd */0; - }) - }); - return Tea_app.program(debugged, pnode, flags); -} - -function program(param, string_of_msg, pnode, flags) { - var debugged = debug_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: param.shutdown - }); - return Tea_app.program(debugged, pnode, flags); -} - -function navigationProgram(location_to_msg, param, string_of_msg, pnode, flags) { - var $$location = function ($$location$1) { - return /* ClientMsg */Block.__(0, [Curry._1(location_to_msg, $$location$1)]); - }; - var debugged = debug_navigation_program(string_of_msg, { - init: param.init, - update: param.update, - view: param.view, - subscriptions: param.subscriptions, - shutdown: param.shutdown - }); - return Tea_navigation.navigationProgram($$location, debugged)(pnode, flags); -} - -exports.client_msg = client_msg; -exports.debug = debug; -exports.debug_program = debug_program; -exports.debug_navigation_program = debug_navigation_program; -exports.beginnerProgram = beginnerProgram; -exports.standardProgram = standardProgram; -exports.program = program; -exports.navigationProgram = navigationProgram; -/* Tea_html2 Not a pure module */ - -},{"./tea_app.js":1,"./tea_cmd.js":2,"./tea_html2.js":6,"./tea_navigation.js":10,"./tea_sub.js":12,"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61,"bs-platform/lib/js/printf.js":63,"bs-platform/lib/js/string.js":64}],4:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_task = require("./tea_task.js"); -var Web_window_localstorage = require("./web_window_localstorage.js"); - -function render_event($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var enableCall = function (callbacks) { - Curry._1(callbacks.on, /* AddRenderMsg */Block.__(0, [msg])); - return (function (param) { - return Curry._1(callbacks.on, /* RemoveRenderMsg */Block.__(1, [msg])); - }); - }; - return Tea_sub.registration(key, enableCall); -} - -var length = /* Task */[(function (cb) { - var match = Web_window_localstorage.length(window); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; - -var clear = /* Task */[(function (cb) { - var match = Web_window_localstorage.clear(window); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; - -function clearCmd(param) { - return Tea_task.attemptOpt((function (param) { - return ; - }), clear); -} - -function key(idx) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.key(window, idx); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function getItem(key) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.getItem(window, key); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function removeItem(key) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.removeItem(window, key); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [match])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function removeItemCmd(key) { - return Tea_task.attemptOpt((function (param) { - return ; - }), removeItem(key)); -} - -function setItem(key, value) { - return /* Task */[(function (cb) { - var match = Web_window_localstorage.setItem(window, key, value); - if (match !== undefined) { - return Curry._1(cb, /* Ok */Block.__(0, [/* () */0])); - } else { - return Curry._1(cb, /* Error */Block.__(1, ["localStorage is not available"])); - } - })]; -} - -function setItemCmd(key, value) { - return Tea_task.attemptOpt((function (param) { - return ; - }), setItem(key, value)); -} - -var LocalStorage = { - length: length, - clear: clear, - clearCmd: clearCmd, - key: key, - getItem: getItem, - removeItem: removeItem, - removeItemCmd: removeItemCmd, - setItem: setItem, - setItemCmd: setItemCmd -}; - -exports.render_event = render_event; -exports.LocalStorage = LocalStorage; -/* No side effect */ - -},{"./tea_sub.js":12,"./tea_task.js":13,"./web_window_localstorage.js":23,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58}],5:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_json = require("./tea_json.js"); -var Tea_result = require("./tea_result.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function text(str) { - return /* Text */Block.__(1, [str]); -} - -var lazy1 = Vdom.lazyGen; - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, nodes) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return Vdom.fullnode(namespace, tagName, key, unique, props, nodes); -} - -function br(props) { - return Vdom.fullnode("", "br", "br", "br", props, /* [] */0); -} - -function br$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "br", key, unique, props, nodes); -} - -function div($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "div", key, unique, props, nodes); -} - -function span($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "span", key, unique, props, nodes); -} - -function p($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "p", key, unique, props, nodes); -} - -function pre($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "pre", key, unique, props, nodes); -} - -function a($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "a", key, unique, props, nodes); -} - -function section($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "section", key, unique, props, nodes); -} - -function header($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "header", key, unique, props, nodes); -} - -function footer($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "footer", key, unique, props, nodes); -} - -function h1($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h1", key, unique, props, nodes); -} - -function h2($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h2", key, unique, props, nodes); -} - -function h3($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h3", key, unique, props, nodes); -} - -function h4($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h4", key, unique, props, nodes); -} - -function h5($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h5", key, unique, props, nodes); -} - -function h6($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h6", key, unique, props, nodes); -} - -function i($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "i", key, unique, props, nodes); -} - -function strong($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "strong", key, unique, props, nodes); -} - -function button($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "button", key, unique, props, nodes); -} - -function input$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "input", key, unique, props, nodes); -} - -function textarea($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "textarea", key, unique, props, nodes); -} - -function label($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "label", key, unique, props, nodes); -} - -function ul($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ul", key, unique, props, nodes); -} - -function ol($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ol", key, unique, props, nodes); -} - -function li($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "li", key, unique, props, nodes); -} - -function table($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "table", key, unique, props, nodes); -} - -function thead($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "thead", key, unique, props, nodes); -} - -function tfoot($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tfoot", key, unique, props, nodes); -} - -function tbody($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tbody", key, unique, props, nodes); -} - -function th($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "th", key, unique, props, nodes); -} - -function tr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tr", key, unique, props, nodes); -} - -function td($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "td", key, unique, props, nodes); -} - -function progress($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "progress", key, unique, props, nodes); -} - -function img($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "img", key, unique, props, nodes); -} - -function select($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "select", key, unique, props, nodes); -} - -function option$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "option", key, unique, props, nodes); -} - -function form($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "form", key, unique, props, nodes); -} - -function nav($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "nav", key, unique, props, nodes); -} - -function main($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "main", key, unique, props, nodes); -} - -function aside($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "aside", key, unique, props, nodes); -} - -function article($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "article", key, unique, props, nodes); -} - -function details($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "details", key, unique, props, nodes); -} - -function figcaption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figcaption", key, unique, props, nodes); -} - -function figure($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figure", key, unique, props, nodes); -} - -function mark($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "mark", key, unique, props, nodes); -} - -function summary($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "summary", key, unique, props, nodes); -} - -function time($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "time", key, unique, props, nodes); -} - -function hr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "hr", key, unique, props, nodes); -} - -function blockquote($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "blockquote", key, unique, props, nodes); -} - -function code($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "code", key, unique, props, nodes); -} - -function em($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "em", key, unique, props, nodes); -} - -function b($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "b", key, unique, props, nodes); -} - -function u($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "u", key, unique, props, nodes); -} - -function sub($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sub", key, unique, props, nodes); -} - -function sup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sup", key, unique, props, nodes); -} - -function dl($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dl", key, unique, props, nodes); -} - -function dt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dt", key, unique, props, nodes); -} - -function dd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dd", key, unique, props, nodes); -} - -function iframe($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "iframe", key, unique, props, nodes); -} - -function canvas($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "canvas", key, unique, props, nodes); -} - -function address($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "address", key, unique, props, nodes); -} - -function caption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "caption", key, unique, props, nodes); -} - -function colgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "colgroup", key, unique, props, nodes); -} - -function col($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "col", key, unique, props, nodes); -} - -function fieldset($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "fieldset", key, unique, props, nodes); -} - -function legend($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "legend", key, unique, props, nodes); -} - -function datalist($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "datalist", key, unique, props, nodes); -} - -function optgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "optgroup", key, unique, props, nodes); -} - -function output($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "output", key, unique, props, nodes); -} - -function meter($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meter", key, unique, props, nodes); -} - -function audio($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "audio", key, unique, props, nodes); -} - -function video($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "video", key, unique, props, nodes); -} - -function source($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "source", key, unique, props, nodes); -} - -function track($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "track", key, unique, props, nodes); -} - -function embed($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "embed", key, unique, props, nodes); -} - -function object$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "object", key, unique, props, nodes); -} - -function param($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "param", key, unique, props, nodes); -} - -function ins($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ins", key, unique, props, nodes); -} - -function del($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "del", key, unique, props, nodes); -} - -function small($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "small", key, unique, props, nodes); -} - -function cite($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "cite", key, unique, props, nodes); -} - -function dfn($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dfn", key, unique, props, nodes); -} - -function abbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "abbr", key, unique, props, nodes); -} - -function var$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "var", key, unique, props, nodes); -} - -function samp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "samp", key, unique, props, nodes); -} - -function kbd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "kbd", key, unique, props, nodes); -} - -function s($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "s", key, unique, props, nodes); -} - -function q($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "q", key, unique, props, nodes); -} - -function rt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rt", key, unique, props, nodes); -} - -function bdi($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdi", key, unique, props, nodes); -} - -function bdo($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdo", key, unique, props, nodes); -} - -function wbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "wbr", key, unique, props, nodes); -} - -function menuitem($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menuitem", key, unique, props, nodes); -} - -function menu($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menu", key, unique, props, nodes); -} - -function id(str) { - return /* RawProp */Block.__(0, [ - "id", - str - ]); -} - -function href(str) { - return /* Attribute */Block.__(1, [ - "", - "href", - str - ]); -} - -function src(str) { - return /* Attribute */Block.__(1, [ - "", - "src", - str - ]); -} - -function title(str) { - return /* Attribute */Block.__(1, [ - "", - "title", - str - ]); -} - -function class$prime(name) { - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function classList(classes) { - var name = $$String.concat(" ", List.map((function (param) { - return param[0]; - }), List.filter((function (param) { - return param[1]; - }))(classes))); - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function type$prime(typ) { - return /* RawProp */Block.__(0, [ - "type", - typ - ]); -} - -var style = Vdom.style; - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function placeholder(str) { - return /* RawProp */Block.__(0, [ - "placeholder", - str - ]); -} - -function autofocus(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autofocus", - "autofocus" - ]); - } else { - return /* NoProp */0; - } -} - -function value(str) { - return /* RawProp */Block.__(0, [ - "value", - str - ]); -} - -function name(str) { - return /* RawProp */Block.__(0, [ - "name", - str - ]); -} - -function checked(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "checked", - "checked" - ]); - } else { - return /* NoProp */0; - } -} - -function for$prime(str) { - return /* RawProp */Block.__(0, [ - "htmlFor", - str - ]); -} - -function hidden(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "hidden", - "hidden" - ]); - } else { - return /* NoProp */0; - } -} - -function target(t) { - return /* RawProp */Block.__(0, [ - "target", - t - ]); -} - -function action(a) { - return /* RawProp */Block.__(0, [ - "action", - a - ]); -} - -function method$prime(m) { - return /* RawProp */Block.__(0, [ - "method", - m - ]); -} - -var onCB = Vdom.onCB; - -var onMsg = Vdom.onMsg; - -function onInputOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("input", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onInput($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onInputOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onChangeOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onChange($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onChangeOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onClick(msg) { - return Vdom.onMsg("click", msg); -} - -function onDoubleClick(msg) { - return Vdom.onMsg("dblclick", msg); -} - -function onBlur(msg) { - return Vdom.onMsg("blur", msg); -} - -function onFocus(msg) { - return Vdom.onMsg("focus", msg); -} - -function onCheckOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.checked; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onCheck($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onCheckOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onMouseDown(msg) { - return Vdom.onMsg("mousedown", msg); -} - -function onMouseUp(msg) { - return Vdom.onMsg("mouseup", msg); -} - -function onMouseEnter(msg) { - return Vdom.onMsg("mouseenter", msg); -} - -function onMouseLeave(msg) { - return Vdom.onMsg("mouseleave", msg); -} - -function onMouseOver(msg) { - return Vdom.onMsg("mouseover", msg); -} - -function onMouseOut(msg) { - return Vdom.onMsg("mouseout", msg); -} - -var defaultOptions = { - stopPropagation: false, - preventDefault: false -}; - -function onWithOptions(key, eventName, options, decoder) { - return Vdom.onCB(eventName, key, (function ($$event) { - if (options.stopPropagation) { - $$event.stopPropagation(); - } - if (options.preventDefault) { - $$event.preventDefault(); - } - return Tea_result.result_to_option(Tea_json.Decoder.decodeEvent(decoder, $$event)); - })); -} - -function on(key, eventName, decoder) { - return onWithOptions(key, eventName, defaultOptions, decoder); -} - -var targetValue = Tea_json.Decoder.at(/* :: */[ - "target", - /* :: */[ - "value", - /* [] */0 - ] - ], Tea_json.Decoder.string); - -var targetChecked = Tea_json.Decoder.at(/* :: */[ - "target", - /* :: */[ - "checked", - /* [] */0 - ] - ], Tea_json.Decoder.bool); - -var keyCode = Tea_json.Decoder.field("keyCode", Tea_json.Decoder.$$int); - -function max(value) { - return /* Attribute */Block.__(1, [ - "", - "max", - value - ]); -} - -function min(value) { - return /* Attribute */Block.__(1, [ - "", - "min", - value - ]); -} - -function step(value) { - return /* Attribute */Block.__(1, [ - "", - "step", - value - ]); -} - -function disabled(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "disabled", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function selected(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "selected", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function acceptCharset(c) { - return /* Attribute */Block.__(1, [ - "", - "accept-charset", - c - ]); -} - -function rel(value) { - return /* Attribute */Block.__(1, [ - "", - "rel", - value - ]); -} - -var Attributes = { - max: max, - min: min, - step: step, - disabled: disabled, - selected: selected, - acceptCharset: acceptCharset, - rel: rel -}; - -var Cmds = /* alias */0; - -var map = Tea_app.map; - -var noNode = Vdom.noNode; - -var noProp = /* NoProp */0; - -exports.Cmds = Cmds; -exports.map = map; -exports.noNode = noNode; -exports.text = text; -exports.lazy1 = lazy1; -exports.node = node; -exports.br = br; -exports.br$prime = br$prime; -exports.div = div; -exports.span = span; -exports.p = p; -exports.pre = pre; -exports.a = a; -exports.section = section; -exports.header = header; -exports.footer = footer; -exports.h1 = h1; -exports.h2 = h2; -exports.h3 = h3; -exports.h4 = h4; -exports.h5 = h5; -exports.h6 = h6; -exports.i = i; -exports.strong = strong; -exports.button = button; -exports.input$prime = input$prime; -exports.textarea = textarea; -exports.label = label; -exports.ul = ul; -exports.ol = ol; -exports.li = li; -exports.table = table; -exports.thead = thead; -exports.tfoot = tfoot; -exports.tbody = tbody; -exports.th = th; -exports.tr = tr; -exports.td = td; -exports.progress = progress; -exports.img = img; -exports.select = select; -exports.option$prime = option$prime; -exports.form = form; -exports.nav = nav; -exports.main = main; -exports.aside = aside; -exports.article = article; -exports.details = details; -exports.figcaption = figcaption; -exports.figure = figure; -exports.mark = mark; -exports.summary = summary; -exports.time = time; -exports.hr = hr; -exports.blockquote = blockquote; -exports.code = code; -exports.em = em; -exports.b = b; -exports.u = u; -exports.sub = sub; -exports.sup = sup; -exports.dl = dl; -exports.dt = dt; -exports.dd = dd; -exports.iframe = iframe; -exports.canvas = canvas; -exports.address = address; -exports.caption = caption; -exports.colgroup = colgroup; -exports.col = col; -exports.fieldset = fieldset; -exports.legend = legend; -exports.datalist = datalist; -exports.optgroup = optgroup; -exports.output = output; -exports.meter = meter; -exports.audio = audio; -exports.video = video; -exports.source = source; -exports.track = track; -exports.embed = embed; -exports.object$prime = object$prime; -exports.param = param; -exports.ins = ins; -exports.del = del; -exports.small = small; -exports.cite = cite; -exports.dfn = dfn; -exports.abbr = abbr; -exports.var$prime = var$prime; -exports.samp = samp; -exports.kbd = kbd; -exports.s = s; -exports.q = q; -exports.rt = rt; -exports.bdi = bdi; -exports.bdo = bdo; -exports.wbr = wbr; -exports.menuitem = menuitem; -exports.menu = menu; -exports.noProp = noProp; -exports.id = id; -exports.href = href; -exports.src = src; -exports.title = title; -exports.class$prime = class$prime; -exports.classList = classList; -exports.type$prime = type$prime; -exports.style = style; -exports.styles = styles; -exports.placeholder = placeholder; -exports.autofocus = autofocus; -exports.value = value; -exports.name = name; -exports.checked = checked; -exports.for$prime = for$prime; -exports.hidden = hidden; -exports.target = target; -exports.action = action; -exports.method$prime = method$prime; -exports.onCB = onCB; -exports.onMsg = onMsg; -exports.onInputOpt = onInputOpt; -exports.onInput = onInput; -exports.onChangeOpt = onChangeOpt; -exports.onChange = onChange; -exports.onClick = onClick; -exports.onDoubleClick = onDoubleClick; -exports.onBlur = onBlur; -exports.onFocus = onFocus; -exports.onCheckOpt = onCheckOpt; -exports.onCheck = onCheck; -exports.onMouseDown = onMouseDown; -exports.onMouseUp = onMouseUp; -exports.onMouseEnter = onMouseEnter; -exports.onMouseLeave = onMouseLeave; -exports.onMouseOver = onMouseOver; -exports.onMouseOut = onMouseOut; -exports.defaultOptions = defaultOptions; -exports.onWithOptions = onWithOptions; -exports.on = on; -exports.targetValue = targetValue; -exports.targetChecked = targetChecked; -exports.keyCode = keyCode; -exports.Attributes = Attributes; -/* targetValue Not a pure module */ - -},{"./tea_app.js":1,"./tea_json.js":8,"./tea_result.js":11,"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61,"bs-platform/lib/js/string.js":64}],6:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Bytes = require("bs-platform/lib/js/bytes.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Tea_app = require("./tea_app.js"); -var Tea_html = require("./tea_html.js"); -var Tea_json = require("./tea_json.js"); -var Caml_bytes = require("bs-platform/lib/js/caml_bytes.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function text(str) { - return /* Text */Block.__(1, [str]); -} - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, nodes) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return Vdom.fullnode(namespace, tagName, key, unique, props, nodes); -} - -var lazy1 = Vdom.lazyGen; - -function h1($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h1", key, unique, props, nodes); -} - -function h2($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h2", key, unique, props, nodes); -} - -function h3($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h3", key, unique, props, nodes); -} - -function h4($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h4", key, unique, props, nodes); -} - -function h5($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h5", key, unique, props, nodes); -} - -function h6($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "h6", key, unique, props, nodes); -} - -function div($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "div", key, unique, props, nodes); -} - -function p($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "p", key, unique, props, nodes); -} - -function hr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "hr", key, unique, props, nodes); -} - -function pre($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "pre", key, unique, props, nodes); -} - -function blockquote($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "blockquote", key, unique, props, nodes); -} - -function span($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "span", key, unique, props, nodes); -} - -function a($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "a", key, unique, props, nodes); -} - -function code($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "code", key, unique, props, nodes); -} - -function em($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "em", key, unique, props, nodes); -} - -function strong($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "strong", key, unique, props, nodes); -} - -function i($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "i", key, unique, props, nodes); -} - -function b($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "b", key, unique, props, nodes); -} - -function u($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "u", key, unique, props, nodes); -} - -function sub($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sub", key, unique, props, nodes); -} - -function sup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "sup", key, unique, props, nodes); -} - -function br(props) { - return Vdom.fullnode("", "br", "br", "br", props, /* [] */0); -} - -function br$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "br", key, unique, props, nodes); -} - -function ol($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ol", key, unique, props, nodes); -} - -function ul($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ul", key, unique, props, nodes); -} - -function li($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "li", key, unique, props, nodes); -} - -function dl($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dl", key, unique, props, nodes); -} - -function dt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dt", key, unique, props, nodes); -} - -function dd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dd", key, unique, props, nodes); -} - -function img($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "img", key, unique, props, nodes); -} - -function iframe($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "iframe", key, unique, props, nodes); -} - -function canvas($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "canvas", key, unique, props, nodes); -} - -function math($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "math", key, unique, props, nodes); -} - -function form($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "form", key, unique, props, nodes); -} - -function input$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "input", key, unique, props, nodes); -} - -function textarea($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "textarea", key, unique, props, nodes); -} - -function button($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "button", key, unique, props, nodes); -} - -function select($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "select", key, unique, props, nodes); -} - -function option$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "option", key, unique, props, nodes); -} - -function optgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "optgroup", key, unique, props, nodes); -} - -function label($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "label", key, unique, props, nodes); -} - -function fieldset($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "fieldset", key, unique, props, nodes); -} - -function legend($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "legend", key, unique, props, nodes); -} - -function section($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "section", key, unique, props, nodes); -} - -function nav($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "nav", key, unique, props, nodes); -} - -function article($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "article", key, unique, props, nodes); -} - -function aside($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "aside", key, unique, props, nodes); -} - -function header($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "header", key, unique, props, nodes); -} - -function footer($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "footer", key, unique, props, nodes); -} - -function address($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "address", key, unique, props, nodes); -} - -function main($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "main", key, unique, props, nodes); -} - -function body($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "body", key, unique, props, nodes); -} - -function figure($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figure", key, unique, props, nodes); -} - -function figcaption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "figcaption", key, unique, props, nodes); -} - -function table($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "table", key, unique, props, nodes); -} - -function caption($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "caption", key, unique, props, nodes); -} - -function colgroup($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "colgroup", key, unique, props, nodes); -} - -function col($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "col", key, unique, props, nodes); -} - -function tbody($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tbody", key, unique, props, nodes); -} - -function thead($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "thead", key, unique, props, nodes); -} - -function tfoot($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tfoot", key, unique, props, nodes); -} - -function tr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "tr", key, unique, props, nodes); -} - -function th($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "th", key, unique, props, nodes); -} - -function td($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "td", key, unique, props, nodes); -} - -function datalist($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "datalist", key, unique, props, nodes); -} - -function keygen($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "keygen", key, unique, props, nodes); -} - -function output($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "output", key, unique, props, nodes); -} - -function progress($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "progress", key, unique, props, nodes); -} - -function meter($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meter", key, unique, props, nodes); -} - -function audio($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "audio", key, unique, props, nodes); -} - -function video($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "video", key, unique, props, nodes); -} - -function source($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "source", key, unique, props, nodes); -} - -function track($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "track", key, unique, props, nodes); -} - -function embed($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "embed", key, unique, props, nodes); -} - -function object$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "object", key, unique, props, nodes); -} - -function param($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "param", key, unique, props, nodes); -} - -function ins($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ins", key, unique, props, nodes); -} - -function del($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "del", key, unique, props, nodes); -} - -function small($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "small", key, unique, props, nodes); -} - -function cite($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "cite", key, unique, props, nodes); -} - -function dfn($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "dfn", key, unique, props, nodes); -} - -function abbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "abbr", key, unique, props, nodes); -} - -function time($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "time", key, unique, props, nodes); -} - -function var$prime($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "var", key, unique, props, nodes); -} - -function samp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "samp", key, unique, props, nodes); -} - -function kbd($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "kbd", key, unique, props, nodes); -} - -function s($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "s", key, unique, props, nodes); -} - -function q($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "q", key, unique, props, nodes); -} - -function mark($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "mark", key, unique, props, nodes); -} - -function ruby($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "ruby", key, unique, props, nodes); -} - -function rt($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rt", key, unique, props, nodes); -} - -function rp($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "rp", key, unique, props, nodes); -} - -function bdi($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdi", key, unique, props, nodes); -} - -function bdo($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "bdo", key, unique, props, nodes); -} - -function wbr($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "wbr", key, unique, props, nodes); -} - -function details($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "details", key, unique, props, nodes); -} - -function summary($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "summary", key, unique, props, nodes); -} - -function menuitem($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menuitem", key, unique, props, nodes); -} - -function menu($staropt$star, $staropt$star$1, props, nodes) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "menu", key, unique, props, nodes); -} - -function meta($staropt$star, $staropt$star$1, props) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "meta", key, unique, props, /* [] */0); -} - -function style($staropt$star, $staropt$star$1, props, content) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "style", key, unique, props, /* :: */[ - /* Text */Block.__(1, [content]), - /* [] */0 - ]); -} - -function title($staropt$star, $staropt$star$1, props, content) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "title", key, unique, props, /* :: */[ - /* Text */Block.__(1, [content]), - /* [] */0 - ]); -} - -function link($staropt$star, $staropt$star$1, props) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - var unique = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - return Vdom.fullnode("", "link", key, unique, props, /* [] */0); -} - -var style$1 = Vdom.style; - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function class$prime(name) { - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function classList(classes) { - var name = $$String.concat(" ", List.map((function (param) { - return param[0]; - }), List.filter((function (param) { - return param[1]; - }))(classes))); - return /* RawProp */Block.__(0, [ - "className", - name - ]); -} - -function id(str) { - return /* RawProp */Block.__(0, [ - "id", - str - ]); -} - -function title$1(str) { - return /* Attribute */Block.__(1, [ - "", - "title", - str - ]); -} - -function hidden(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "hidden", - "hidden" - ]); - } else { - return /* NoProp */0; - } -} - -function type$prime(typ) { - return /* RawProp */Block.__(0, [ - "type", - typ - ]); -} - -function value(str) { - return /* RawProp */Block.__(0, [ - "value", - str - ]); -} - -function defaultValue(str) { - return /* RawProp */Block.__(0, [ - "defaultValue", - str - ]); -} - -function checked(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "checked", - "checked" - ]); - } else { - return /* NoProp */0; - } -} - -function placeholder(str) { - return /* RawProp */Block.__(0, [ - "placeholder", - str - ]); -} - -function selected(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "selected", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function accept(c) { - return /* Attribute */Block.__(1, [ - "", - "accept", - c - ]); -} - -function acceptCharset(c) { - return /* Attribute */Block.__(1, [ - "", - "accept-charset", - c - ]); -} - -function action(a) { - return /* RawProp */Block.__(0, [ - "action", - a - ]); -} - -function autocomplete(b) { - return /* RawProp */Block.__(0, [ - "autocomplete", - b ? "on" : "off" - ]); -} - -function autofocus(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autofocus", - "autofocus" - ]); - } else { - return /* NoProp */0; - } -} - -function disabled(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "disabled", - "true" - ]); - } else { - return /* NoProp */0; - } -} - -function enctype(encoding) { - return /* Attribute */Block.__(1, [ - "", - "enctype", - encoding - ]); -} - -function formaction(url) { - return /* Attribute */Block.__(1, [ - "", - "formaction", - url - ]); -} - -function list(value) { - return /* Attribute */Block.__(1, [ - "", - "list", - value - ]); -} - -function minlength(n) { - return /* Attribute */Block.__(1, [ - "", - "minlength", - String(n) - ]); -} - -function maxlength(n) { - return /* Attribute */Block.__(1, [ - "", - "maxlength", - String(n) - ]); -} - -function method$prime(m) { - return /* RawProp */Block.__(0, [ - "method", - m - ]); -} - -function multiple(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "multiple", - "multiple" - ]); - } else { - return /* NoProp */0; - } -} - -function name(str) { - return /* RawProp */Block.__(0, [ - "name", - str - ]); -} - -function novalidate(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "novalidate", - "novalidate" - ]); - } else { - return /* NoProp */0; - } -} - -function pattern(p) { - return /* RawProp */Block.__(0, [ - "pattern", - p - ]); -} - -function readonly(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "readonly", - "readonly" - ]); - } else { - return /* NoProp */0; - } -} - -function required(b) { - if (b) { - return /* Attribute */Block.__(1, [ - "", - "required", - "required" - ]); - } else { - return /* NoProp */0; - } -} - -function size(n) { - return /* Attribute */Block.__(1, [ - "", - "size", - String(n) - ]); -} - -function for$prime(str) { - return /* RawProp */Block.__(0, [ - "htmlFor", - str - ]); -} - -function form$1(value) { - return /* Attribute */Block.__(1, [ - "", - "form", - value - ]); -} - -function max(value) { - return /* Attribute */Block.__(1, [ - "", - "max", - value - ]); -} - -function min(value) { - return /* Attribute */Block.__(1, [ - "", - "min", - value - ]); -} - -function step(value) { - return /* Attribute */Block.__(1, [ - "", - "step", - value - ]); -} - -function cols(n) { - return /* Attribute */Block.__(1, [ - "", - "cols", - String(n) - ]); -} - -function rows(n) { - return /* Attribute */Block.__(1, [ - "", - "rows", - String(n) - ]); -} - -function wrap(value) { - return /* RawProp */Block.__(0, [ - "wrap", - value - ]); -} - -function href(str) { - return /* Attribute */Block.__(1, [ - "", - "href", - str - ]); -} - -function target(t) { - return /* RawProp */Block.__(0, [ - "target", - t - ]); -} - -function download(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "download", - "" - ]); - } else { - return /* NoProp */0; - } -} - -function downloadAs(name) { - return /* RawProp */Block.__(0, [ - "download", - name - ]); -} - -function hreflang(code) { - return /* RawProp */Block.__(0, [ - "hreflang", - code - ]); -} - -function media(value) { - return /* Attribute */Block.__(1, [ - "", - "media", - value - ]); -} - -function ping(url) { - return /* RawProp */Block.__(0, [ - "ping", - url - ]); -} - -function rel(value) { - return /* Attribute */Block.__(1, [ - "", - "rel", - value - ]); -} - -function ismap(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "ismap", - "ismap" - ]); - } else { - return /* NoProp */0; - } -} - -function usemap(name) { - return /* RawProp */Block.__(0, [ - "usemap", - name - ]); -} - -function shape(value) { - return /* RawProp */Block.__(0, [ - "shape", - value - ]); -} - -function coords(value) { - return /* RawProp */Block.__(0, [ - "coords", - value - ]); -} - -function src(str) { - return /* Attribute */Block.__(1, [ - "", - "src", - str - ]); -} - -function height(n) { - return /* Attribute */Block.__(1, [ - "", - "height", - String(n) - ]); -} - -function width(n) { - return /* Attribute */Block.__(1, [ - "", - "width", - String(n) - ]); -} - -function alt(value) { - return /* RawProp */Block.__(0, [ - "alt", - value - ]); -} - -function autoplay(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "autoplay", - "autoplay" - ]); - } else { - return /* NoProp */0; - } -} - -function controls(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "controls", - "controls" - ]); - } else { - return /* NoProp */0; - } -} - -function loop(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "loop", - "loop" - ]); - } else { - return /* NoProp */0; - } -} - -function preload(value) { - return /* RawProp */Block.__(0, [ - "preload", - value - ]); -} - -function poster(url) { - return /* RawProp */Block.__(0, [ - "poster", - url - ]); -} - -function $$default(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "default", - "default" - ]); - } else { - return /* NoProp */0; - } -} - -function kind(value) { - return /* RawProp */Block.__(0, [ - "kind", - value - ]); -} - -function srclang(code) { - return /* RawProp */Block.__(0, [ - "srclang", - code - ]); -} - -function sandbox(value) { - return /* RawProp */Block.__(0, [ - "sandbox", - value - ]); -} - -function seamless(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "seamless", - "seamless" - ]); - } else { - return /* NoProp */0; - } -} - -function srcdoc(value) { - return /* RawProp */Block.__(0, [ - "srcdoc", - value - ]); -} - -function reversed(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "reversed", - "reversed" - ]); - } else { - return /* NoProp */0; - } -} - -function start(n) { - return /* RawProp */Block.__(0, [ - "start", - String(n) - ]); -} - -function colspan(n) { - return /* Attribute */Block.__(1, [ - "", - "colspan", - String(n) - ]); -} - -function rowspan(n) { - return /* Attribute */Block.__(1, [ - "", - "rowspan", - String(n) - ]); -} - -function headers(value) { - return /* RawProp */Block.__(0, [ - "headers", - value - ]); -} - -function scope(value) { - return /* RawProp */Block.__(0, [ - "scope", - value - ]); -} - -function align(value) { - return /* RawProp */Block.__(0, [ - "align", - value - ]); -} - -function async(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "async", - "async" - ]); - } else { - return /* NoProp */0; - } -} - -function charset(value) { - return /* Attribute */Block.__(1, [ - "", - "charset", - value - ]); -} - -function content(value) { - return /* Attribute */Block.__(1, [ - "", - "content", - value - ]); -} - -function defer(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "defer", - "defer" - ]); - } else { - return /* NoProp */0; - } -} - -function httpEquiv(value) { - return /* RawProp */Block.__(0, [ - "http-equiv", - value - ]); -} - -function language(value) { - return /* RawProp */Block.__(0, [ - "language", - value - ]); -} - -function scoped(value) { - return /* RawProp */Block.__(0, [ - "scoped", - value - ]); -} - -function accesskey(ch) { - return /* RawProp */Block.__(0, [ - "accesskey", - Caml_bytes.bytes_to_string(Bytes.make(1, ch)) - ]); -} - -function contenteditable(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "contenteditable", - "contenteditable" - ]); - } else { - return /* NoProp */0; - } -} - -function contextmenu(id) { - return /* Attribute */Block.__(1, [ - "", - "contextmenu", - id - ]); -} - -function dir(value) { - return /* RawProp */Block.__(0, [ - "dir", - value - ]); -} - -function draggable(value) { - return /* Attribute */Block.__(1, [ - "", - "draggable", - value - ]); -} - -function dropzone(value) { - return /* RawProp */Block.__(0, [ - "dropzone", - value - ]); -} - -function itemprop(value) { - return /* Attribute */Block.__(1, [ - "", - "itemprop", - value - ]); -} - -function lang(code) { - return /* RawProp */Block.__(0, [ - "lang", - code - ]); -} - -function spellcheck(b) { - if (b) { - return /* RawProp */Block.__(0, [ - "spellcheck", - "spellcheck" - ]); - } else { - return /* NoProp */0; - } -} - -function tabindex(n) { - return /* Attribute */Block.__(1, [ - "", - "tabindex", - String(n) - ]); -} - -function challenge(value) { - return /* Attribute */Block.__(1, [ - "", - "challenge", - value - ]); -} - -function keytype(value) { - return /* RawProp */Block.__(0, [ - "keytype", - value - ]); -} - -function cite$1(url) { - return /* RawProp */Block.__(0, [ - "cite", - url - ]); -} - -function datetime(value) { - return /* Attribute */Block.__(1, [ - "", - "datetime", - value - ]); -} - -function pubdate(value) { - return /* Attribute */Block.__(1, [ - "", - "pubdate", - value - ]); -} - -function manifest(value) { - return /* Attribute */Block.__(1, [ - "", - "manifest", - value - ]); -} - -var Attributes = { - noProp: /* NoProp */0, - style: style$1, - styles: styles, - class$prime: class$prime, - classList: classList, - id: id, - title: title$1, - hidden: hidden, - type$prime: type$prime, - value: value, - defaultValue: defaultValue, - checked: checked, - placeholder: placeholder, - selected: selected, - accept: accept, - acceptCharset: acceptCharset, - action: action, - autocomplete: autocomplete, - autofocus: autofocus, - disabled: disabled, - enctype: enctype, - formaction: formaction, - list: list, - minlength: minlength, - maxlength: maxlength, - method$prime: method$prime, - multiple: multiple, - name: name, - novalidate: novalidate, - pattern: pattern, - readonly: readonly, - required: required, - size: size, - for$prime: for$prime, - form: form$1, - max: max, - min: min, - step: step, - cols: cols, - rows: rows, - wrap: wrap, - href: href, - target: target, - download: download, - downloadAs: downloadAs, - hreflang: hreflang, - media: media, - ping: ping, - rel: rel, - ismap: ismap, - usemap: usemap, - shape: shape, - coords: coords, - src: src, - height: height, - width: width, - alt: alt, - autoplay: autoplay, - controls: controls, - loop: loop, - preload: preload, - poster: poster, - $$default: $$default, - kind: kind, - srclang: srclang, - sandbox: sandbox, - seamless: seamless, - srcdoc: srcdoc, - reversed: reversed, - start: start, - colspan: colspan, - rowspan: rowspan, - headers: headers, - scope: scope, - align: align, - async: async, - charset: charset, - content: content, - defer: defer, - httpEquiv: httpEquiv, - language: language, - scoped: scoped, - accesskey: accesskey, - contenteditable: contenteditable, - contextmenu: contextmenu, - dir: dir, - draggable: draggable, - dropzone: dropzone, - itemprop: itemprop, - lang: lang, - spellcheck: spellcheck, - tabindex: tabindex, - challenge: challenge, - keytype: keytype, - cite: cite$1, - datetime: datetime, - pubdate: pubdate, - manifest: manifest -}; - -var onCB = Vdom.onCB; - -var onMsg = Vdom.onMsg; - -function preventDefaultOn($staropt$star, eventName, decoder) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Tea_html.onWithOptions(key, eventName, { - stopPropagation: Tea_html.defaultOptions.stopPropagation, - preventDefault: true - }, decoder); -} - -function onClick(msg) { - return Vdom.onMsg("click", msg); -} - -function onDoubleClick(msg) { - return Vdom.onMsg("dblclick", msg); -} - -function onMouseDown(msg) { - return Vdom.onMsg("mousedown", msg); -} - -function onMouseUp(msg) { - return Vdom.onMsg("mouseup", msg); -} - -function onMouseEnter(msg) { - return Vdom.onMsg("mouseenter", msg); -} - -function onMouseLeave(msg) { - return Vdom.onMsg("mouseleave", msg); -} - -function onMouseOver(msg) { - return Vdom.onMsg("mouseover", msg); -} - -function onMouseOut(msg) { - return Vdom.onMsg("mouseout", msg); -} - -function onInputOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("input", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onInput($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onInputOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onCheckOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.checked; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onCheck($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onCheckOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onChangeOpt($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return Vdom.onCB("change", key, (function (ev) { - var match = ev.target; - if (match !== undefined) { - var match$1 = match.value; - if (match$1 !== undefined) { - return Curry._1(msg, match$1); - } else { - return ; - } - } - - })); -} - -function onChange($staropt$star, msg) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return onChangeOpt(key, (function (ev) { - return Caml_option.some(Curry._1(msg, ev)); - })); -} - -function onSubmit(msg) { - return preventDefaultOn(undefined, "submit", Tea_json.Decoder.succeed(msg)); -} - -function onBlur(msg) { - return Vdom.onMsg("blur", msg); -} - -function onFocus(msg) { - return Vdom.onMsg("focus", msg); -} - -var Events = { - onCB: onCB, - onMsg: onMsg, - on: Tea_html.on, - onWithOptions: Tea_html.onWithOptions, - defaultOptions: Tea_html.defaultOptions, - targetValue: Tea_html.targetValue, - targetChecked: Tea_html.targetChecked, - keyCode: Tea_html.keyCode, - preventDefaultOn: preventDefaultOn, - onClick: onClick, - onDoubleClick: onDoubleClick, - onMouseDown: onMouseDown, - onMouseUp: onMouseUp, - onMouseEnter: onMouseEnter, - onMouseLeave: onMouseLeave, - onMouseOver: onMouseOver, - onMouseOut: onMouseOut, - onInputOpt: onInputOpt, - onInput: onInput, - onCheckOpt: onCheckOpt, - onCheck: onCheck, - onChangeOpt: onChangeOpt, - onChange: onChange, - onSubmit: onSubmit, - onBlur: onBlur, - onFocus: onFocus -}; - -var Cmds = /* alias */0; - -var map = Tea_app.map; - -var noNode = Vdom.noNode; - -exports.Cmds = Cmds; -exports.map = map; -exports.text = text; -exports.node = node; -exports.noNode = noNode; -exports.lazy1 = lazy1; -exports.h1 = h1; -exports.h2 = h2; -exports.h3 = h3; -exports.h4 = h4; -exports.h5 = h5; -exports.h6 = h6; -exports.div = div; -exports.p = p; -exports.hr = hr; -exports.pre = pre; -exports.blockquote = blockquote; -exports.span = span; -exports.a = a; -exports.code = code; -exports.em = em; -exports.strong = strong; -exports.i = i; -exports.b = b; -exports.u = u; -exports.sub = sub; -exports.sup = sup; -exports.br = br; -exports.br$prime = br$prime; -exports.ol = ol; -exports.ul = ul; -exports.li = li; -exports.dl = dl; -exports.dt = dt; -exports.dd = dd; -exports.img = img; -exports.iframe = iframe; -exports.canvas = canvas; -exports.math = math; -exports.form = form; -exports.input$prime = input$prime; -exports.textarea = textarea; -exports.button = button; -exports.select = select; -exports.option$prime = option$prime; -exports.optgroup = optgroup; -exports.label = label; -exports.fieldset = fieldset; -exports.legend = legend; -exports.section = section; -exports.nav = nav; -exports.article = article; -exports.aside = aside; -exports.header = header; -exports.footer = footer; -exports.address = address; -exports.main = main; -exports.body = body; -exports.figure = figure; -exports.figcaption = figcaption; -exports.table = table; -exports.caption = caption; -exports.colgroup = colgroup; -exports.col = col; -exports.tbody = tbody; -exports.thead = thead; -exports.tfoot = tfoot; -exports.tr = tr; -exports.th = th; -exports.td = td; -exports.datalist = datalist; -exports.keygen = keygen; -exports.output = output; -exports.progress = progress; -exports.meter = meter; -exports.audio = audio; -exports.video = video; -exports.source = source; -exports.track = track; -exports.embed = embed; -exports.object$prime = object$prime; -exports.param = param; -exports.ins = ins; -exports.del = del; -exports.small = small; -exports.cite = cite; -exports.dfn = dfn; -exports.abbr = abbr; -exports.time = time; -exports.var$prime = var$prime; -exports.samp = samp; -exports.kbd = kbd; -exports.s = s; -exports.q = q; -exports.mark = mark; -exports.ruby = ruby; -exports.rt = rt; -exports.rp = rp; -exports.bdi = bdi; -exports.bdo = bdo; -exports.wbr = wbr; -exports.details = details; -exports.summary = summary; -exports.menuitem = menuitem; -exports.menu = menu; -exports.meta = meta; -exports.style = style; -exports.title = title; -exports.link = link; -exports.Attributes = Attributes; -exports.Events = Events; -/* Tea_html Not a pure module */ - -},{"./tea_app.js":1,"./tea_html.js":5,"./tea_json.js":8,"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/bytes.js":38,"bs-platform/lib/js/caml_bytes.js":41,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61,"bs-platform/lib/js/string.js":64}],7:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_json = require("./tea_json.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Web_xmlhttprequest = require("./web_xmlhttprequest.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function string_of_error(param) { - if (typeof param === "number") { - switch (param) { - case /* Timeout */0 : - return "Timeout"; - case /* NetworkError */1 : - return "Unknown network error"; - case /* Aborted */2 : - return "Request aborted"; - - } - } else { - switch (param.tag | 0) { - case /* BadUrl */0 : - return "Bad Url: " + param[0]; - case /* BadStatus */1 : - return "Bad Status: " + param[0].url; - case /* BadPayload */2 : - return "Bad Payload: " + param[1].url; - - } - } -} - -var emptyRequestEvents = { - onreadystatechange: undefined, - onprogress: undefined -}; - -function expectStringResponse(func) { - return /* Expect */[ - /* TextResponseType */5, - (function (param) { - var body = param.body; - if (typeof body === "number" || body.tag !== /* TextResponse */5) { - return /* Error */Block.__(1, ["Non-text response returned"]); - } else { - return Curry._1(func, body[0]); - } - }) - ]; -} - -var expectString = expectStringResponse((function (resString) { - return /* Ok */Block.__(0, [resString]); - })); - -function request(rawRequest) { - return /* Request */[ - rawRequest, - undefined - ]; -} - -function getString(url) { - return /* Request */[ - { - "method'": "GET", - headers: /* [] */0, - url: url, - body: /* EmptyBody */0, - expect: expectString, - timeout: undefined, - withCredentials: false - }, - undefined - ]; -} - -function toTask(param) { - var request = param[0]; - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var expect = request.expect; - var responseToResult = expect[1]; - var typ = expect[0]; - var withCredentials = request.withCredentials; - var timeout = request.timeout; - var body = request.body; - var url = request.url; - var headers = request.headers; - var method$prime = request["method'"]; - return /* Task */[(function (cb) { - var enqResError = function (result) { - var partial_arg = /* Error */Block.__(1, [result]); - return (function (param) { - return Curry._1(cb, partial_arg); - }); - }; - var enqResOk = function (result) { - var partial_arg = /* Ok */Block.__(0, [result]); - return (function (param) { - return Curry._1(cb, partial_arg); - }); - }; - var xhr = new XMLHttpRequest(); - var partial_arg = /* Error */Block.__(1, [/* NetworkError */1]); - var cb$1 = function (param) { - return Curry._1(cb, partial_arg); - }; - xhr.onerror = cb$1; - var partial_arg$1 = /* Error */Block.__(1, [/* Timeout */0]); - var cb$2 = function (param) { - return Curry._1(cb, partial_arg$1); - }; - xhr.ontimeout = cb$2; - var partial_arg$2 = /* Error */Block.__(1, [/* Aborted */2]); - var cb$3 = function (param) { - return Curry._1(cb, partial_arg$2); - }; - xhr.onabort = cb$3; - var cb$4 = function (_ev) { - var match = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); - var headers; - headers = match.tag ? /* Empty */0 : match[0]; - var response_url = xhr.responseURL; - var response_status = { - code: xhr.status, - message: xhr.statusText - }; - var response_body = Web_xmlhttprequest.get_response(xhr); - var response = { - url: response_url, - status: response_status, - headers: headers, - body: response_body - }; - if (response_status.code < 200 || 300 <= response_status.code) { - return enqResError(/* BadStatus */Block.__(1, [response]))(/* () */0); - } else { - var match$1 = Curry._1(responseToResult, response); - if (match$1.tag) { - return enqResError(/* BadPayload */Block.__(2, [ - match$1[0], - response - ]))(/* () */0); - } else { - return enqResOk(match$1[0])(/* () */0); - } - } - }; - xhr.onload = cb$4; - try { - Web_xmlhttprequest.open_(method$prime, url, undefined, undefined, undefined, xhr); - } - catch (exn){ - enqResError(/* BadUrl */Block.__(0, [url]))(/* () */0); - } - var setHeader = function (param) { - return Web_xmlhttprequest.setRequestHeader(param[0], param[1], xhr); - }; - List.iter(setHeader, headers); - Web_xmlhttprequest.set_responseType(typ, xhr); - if (timeout !== undefined) { - xhr.timeout = timeout; - } - xhr.withCredentials = withCredentials; - Web_xmlhttprequest.send(body, xhr); - return /* () */0; - })]; -} - -function send(resultToMessage, param) { - var maybeEvents = param[1]; - var request = param[0]; - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var expect = request.expect; - var responseToResult = expect[1]; - var typ = expect[0]; - var withCredentials = request.withCredentials; - var timeout = request.timeout; - var body = request.body; - var url = request.url; - var headers = request.headers; - var method$prime = request["method'"]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - var enqRes = function (result, _ev) { - return Curry._1(callbacks.contents.enqueue, Curry._1(resultToMessage, result)); - }; - var enqResError = function (result) { - var partial_arg = /* Error */Block.__(1, [result]); - return (function (param) { - return enqRes(partial_arg, param); - }); - }; - var enqResOk = function (result) { - var partial_arg = /* Ok */Block.__(0, [result]); - return (function (param) { - return enqRes(partial_arg, param); - }); - }; - var xhr = new XMLHttpRequest(); - if (maybeEvents !== undefined) { - var match = maybeEvents; - var mayCB = function (thenDo, param) { - if (param !== undefined) { - return Curry._1(thenDo, Curry._1(param, callbacks)); - } else { - return /* () */0; - } - }; - mayCB((function (param) { - xhr.onreadystatechange = param; - return /* () */0; - }), match.onreadystatechange); - mayCB((function (param) { - xhr.onprogress = param; - return /* () */0; - }), match.onprogress); - } - var partial_arg = /* Error */Block.__(1, [/* NetworkError */1]); - var cb = function (param) { - return enqRes(partial_arg, param); - }; - xhr.onerror = cb; - var partial_arg$1 = /* Error */Block.__(1, [/* Timeout */0]); - var cb$1 = function (param) { - return enqRes(partial_arg$1, param); - }; - xhr.ontimeout = cb$1; - var partial_arg$2 = /* Error */Block.__(1, [/* Aborted */2]); - var cb$2 = function (param) { - return enqRes(partial_arg$2, param); - }; - xhr.onabort = cb$2; - var cb$3 = function (_ev) { - var match = Web_xmlhttprequest.getAllResponseHeadersAsDict(xhr); - var headers; - headers = match.tag ? /* Empty */0 : match[0]; - var response_url = xhr.responseURL; - var response_status = { - code: xhr.status, - message: xhr.statusText - }; - var response_body = Web_xmlhttprequest.get_response(xhr); - var response = { - url: response_url, - status: response_status, - headers: headers, - body: response_body - }; - if (response_status.code < 200 || 300 <= response_status.code) { - return enqResError(/* BadStatus */Block.__(1, [response]))(/* () */0); - } else { - var match$1 = Curry._1(responseToResult, response); - if (match$1.tag) { - return enqResError(/* BadPayload */Block.__(2, [ - match$1[0], - response - ]))(/* () */0); - } else { - return enqResOk(match$1[0])(/* () */0); - } - } - }; - xhr.onload = cb$3; - try { - Web_xmlhttprequest.open_(method$prime, url, undefined, undefined, undefined, xhr); - } - catch (exn){ - enqResError(/* BadUrl */Block.__(0, [url]))(/* () */0); - } - var setHeader = function (param) { - return Web_xmlhttprequest.setRequestHeader(param[0], param[1], xhr); - }; - List.iter(setHeader, headers); - Web_xmlhttprequest.set_responseType(typ, xhr); - if (timeout !== undefined) { - xhr.timeout = timeout; - } - xhr.withCredentials = withCredentials; - Web_xmlhttprequest.send(body, xhr); - return /* () */0; - })]); -} - -function encodeUri(str) { - return encodeURIComponent(str); -} - -function decodeUri(str) { - try { - return decodeURIComponent(str); - } - catch (exn){ - return ; - } -} - -function track(toMessage, param) { - var events = param[1]; - var onprogress = (function (callbacks, ev) { - var match = Tea_json.Decoder.decodeValue(Tea_json.Decoder.field("lengthComputable", Tea_json.Decoder.bool), ev); - var lengthComputable; - lengthComputable = match.tag ? false : match[0]; - if (lengthComputable) { - var decoder = Tea_json.Decoder.map2((function (bytes, bytesExpected) { - return { - bytes: bytes, - bytesExpected: bytesExpected - }; - }), Tea_json.Decoder.field("loaded", Tea_json.Decoder.$$int), Tea_json.Decoder.field("total", Tea_json.Decoder.$$int)); - var match$1 = Tea_json.Decoder.decodeValue(decoder, ev); - if (match$1.tag) { - return /* () */0; - } else { - return Curry._1(callbacks.contents.enqueue, Curry._1(toMessage, match$1[0])); - } - } else { - return 0; - } - }); - var events$1 = events !== undefined ? events : emptyRequestEvents; - return /* Request */[ - param[0], - { - onreadystatechange: events$1.onreadystatechange, - onprogress: onprogress - } - ]; -} - -var Progress_emptyProgress = { - bytes: 0, - bytesExpected: 0 -}; - -var Progress = { - emptyProgress: Progress_emptyProgress, - track: track -}; - -exports.string_of_error = string_of_error; -exports.emptyRequestEvents = emptyRequestEvents; -exports.expectStringResponse = expectStringResponse; -exports.expectString = expectString; -exports.request = request; -exports.getString = getString; -exports.toTask = toTask; -exports.send = send; -exports.encodeUri = encodeUri; -exports.decodeUri = decodeUri; -exports.Progress = Progress; -/* expectString Not a pure module */ - -},{"./tea_json.js":8,"./web_xmlhttprequest.js":24,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/caml_primitive.js":51,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],8:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var $$Array = require("bs-platform/lib/js/array.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Js_dict = require("bs-platform/lib/js/js_dict.js"); -var Web_json = require("./web_json.js"); -var Caml_array = require("bs-platform/lib/js/caml_array.js"); -var Pervasives = require("bs-platform/lib/js/pervasives.js"); -var Tea_result = require("./tea_result.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Caml_exceptions = require("bs-platform/lib/js/caml_exceptions.js"); -var Caml_js_exceptions = require("bs-platform/lib/js/caml_js_exceptions.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function height(param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } -} - -function create(l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; -} - -function singleton(x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; -} - -function bal(l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } -} - -function is_empty(param) { - if (param) { - return false; - } else { - return true; - } -} - -function add(x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } -} - -function find(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return param[/* d */2]; - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_first(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* l */0]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* l */0]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* r */3]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_first_opt(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* l */0]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* l */0]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* r */3]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return ; - } - }; -} - -function find_last(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* r */3]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* r */3]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* l */0]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* l */0]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_last_opt(f, _param) { - while(true) { - var param = _param; - if (param) { - var v = param[/* v */1]; - if (Curry._1(f, v)) { - var _v0 = v; - var _d0 = param[/* d */2]; - var f$1 = f; - var _param$1 = param[/* r */3]; - while(true) { - var param$1 = _param$1; - var d0 = _d0; - var v0 = _v0; - if (param$1) { - var v$1 = param$1[/* v */1]; - if (Curry._1(f$1, v$1)) { - _param$1 = param$1[/* r */3]; - _d0 = param$1[/* d */2]; - _v0 = v$1; - continue ; - } else { - _param$1 = param$1[/* l */0]; - continue ; - } - } else { - return /* tuple */[ - v0, - d0 - ]; - } - }; - } else { - _param = param[/* l */0]; - continue ; - } - } else { - return ; - } - }; -} - -function find_opt(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return Caml_option.some(param[/* d */2]); - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - return ; - } - }; -} - -function mem(x, _param) { - while(true) { - var param = _param; - if (param) { - var c = Caml_primitive.caml_string_compare(x, param[/* v */1]); - if (c === 0) { - return true; - } else { - _param = c < 0 ? param[/* l */0] : param[/* r */3]; - continue ; - } - } else { - return false; - } - }; -} - -function min_binding(_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function min_binding_opt(_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - return ; - } - }; -} - -function max_binding(_param) { - while(true) { - var param = _param; - if (param) { - var r = param[/* r */3]; - if (r) { - _param = r; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function max_binding_opt(_param) { - while(true) { - var param = _param; - if (param) { - var r = param[/* r */3]; - if (r) { - _param = r; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - return ; - } - }; -} - -function remove_min_binding(param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } -} - -function merge(t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } -} - -function remove(x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } -} - -function update(x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } -} - -function iter(f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; -} - -function map(f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } -} - -function mapi(f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } -} - -function fold(f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; -} - -function for_all(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; -} - -function exists(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; -} - -function add_min_binding(k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } -} - -function add_max_binding(k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } -} - -function join(l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } -} - -function concat(t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } -} - -function concat_or_join(t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } -} - -function split(x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } -} - -function merge$1(f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } -} - -function union(f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } -} - -function filter(p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } -} - -function partition(p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } -} - -function cons_enum(_m, _e) { - while(true) { - var e = _e; - var m = _m; - if (m) { - _e = /* More */[ - m[/* v */1], - m[/* d */2], - m[/* r */3], - e - ]; - _m = m[/* l */0]; - continue ; - } else { - return e; - } - }; -} - -function compare(cmp, m1, m2) { - var _e1 = cons_enum(m1, /* End */0); - var _e2 = cons_enum(m2, /* End */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (e1) { - if (e2) { - var c = Caml_primitive.caml_string_compare(e1[0], e2[0]); - if (c !== 0) { - return c; - } else { - var c$1 = Curry._2(cmp, e1[1], e2[1]); - if (c$1 !== 0) { - return c$1; - } else { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); - continue ; - } - } - } else { - return 1; - } - } else if (e2) { - return -1; - } else { - return 0; - } - }; -} - -function equal(cmp, m1, m2) { - var _e1 = cons_enum(m1, /* End */0); - var _e2 = cons_enum(m2, /* End */0); - while(true) { - var e2 = _e2; - var e1 = _e1; - if (e1) { - if (e2 && Caml_primitive.caml_string_compare(e1[0], e2[0]) === 0 && Curry._2(cmp, e1[1], e2[1])) { - _e2 = cons_enum(e2[2], e2[3]); - _e1 = cons_enum(e1[2], e1[3]); - continue ; - } else { - return false; - } - } else if (e2) { - return false; - } else { - return true; - } - }; -} - -function cardinal(param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } -} - -function bindings_aux(_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; -} - -function bindings(s) { - return bindings_aux(/* [] */0, s); -} - -var ObjectDict = { - empty: /* Empty */0, - is_empty: is_empty, - mem: mem, - add: add, - update: update, - singleton: singleton, - remove: remove, - merge: merge$1, - union: union, - compare: compare, - equal: equal, - iter: iter, - fold: fold, - for_all: for_all, - exists: exists, - filter: filter, - partition: partition, - cardinal: cardinal, - bindings: bindings, - min_binding: min_binding, - min_binding_opt: min_binding_opt, - max_binding: max_binding, - max_binding_opt: max_binding_opt, - choose: min_binding, - choose_opt: min_binding_opt, - split: split, - find: find, - find_opt: find_opt, - find_first: find_first, - find_first_opt: find_first_opt, - find_last: find_last, - find_last_opt: find_last_opt, - map: map, - mapi: mapi -}; - -var ParseFail = Caml_exceptions.create("Tea_json.Decoder.ParseFail"); - -var string = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag) { - return /* Error */Block.__(1, ["Non-string value"]); - } else { - return /* Ok */Block.__(0, [match[0]]); - } - })]; - -var $$int = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONNumber */1) { - return /* Error */Block.__(1, ["Non-int value"]); - } else { - var n = match[0]; - if (n > Pervasives.min_int && n < Pervasives.max_int) { - return /* Ok */Block.__(0, [n | 0]); - } else { - return /* Error */Block.__(1, ["number out of int range"]); - } - } - })]; - -var $$float = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONNumber */1) { - return /* Error */Block.__(1, ["Non-float-value"]); - } else { - return /* Ok */Block.__(0, [match[0]]); - } - })]; - -var bool = /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number") { - switch (match) { - case /* JSONFalse */0 : - return /* Ok */Block.__(0, [false]); - case /* JSONTrue */1 : - return /* Ok */Block.__(0, [true]); - case /* JSONNull */2 : - return /* Error */Block.__(1, ["Non-boolean value"]); - - } - } else { - return /* Error */Block.__(1, ["Non-boolean value"]); - } - })]; - -function $$null(v) { - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" && match >= 2) { - return /* Ok */Block.__(0, [v]); - } else { - return /* Error */Block.__(1, ["Non-null value"]); - } - })]; -} - -function list(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-list value"]); - } else { - var parse = function (v) { - var match = Curry._1(decoder, v); - if (match.tag) { - throw [ - ParseFail, - match[0] - ]; - } else { - return match[0]; - } - }; - try { - return /* Ok */Block.__(0, [List.map(parse, $$Array.to_list(match[0]))]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["list -> " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function array(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-array value"]); - } else { - var parse = function (v) { - var match = Curry._1(decoder, v); - if (match.tag) { - throw [ - ParseFail, - match[0] - ]; - } else { - return match[0]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.map(parse, match[0])]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["array -> " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function keyValuePairs(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-keyValuePair value"]); - } else { - var o = match[0]; - var keys = Object.keys(o); - var parse = function (k, l) { - var match = Js_dict.get(o, k); - if (match !== undefined) { - var match$1 = Curry._1(decoder, Caml_option.valFromOption(match)); - if (match$1.tag) { - throw [ - ParseFail, - match$1[0] - ]; - } else { - return /* :: */[ - /* tuple */[ - k, - match$1[0] - ], - l - ]; - } - } else { - throw [ - ParseFail, - "Key is undefined: " + k - ]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.fold_right(parse, keys, /* [] */0)]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["Invalid keyValuePair parsing: " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function dict(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-dict value"]); - } else { - var o = match[0]; - var keys = Object.keys(o); - var parse = function (k, d) { - var match = Js_dict.get(o, k); - if (match !== undefined) { - var match$1 = Curry._1(decoder, Caml_option.valFromOption(match)); - if (match$1.tag) { - throw [ - ParseFail, - match$1[0] - ]; - } else { - return add(k, match$1[0], d); - } - } else { - throw [ - ParseFail, - "Key is undefined: " + k - ]; - } - }; - try { - return /* Ok */Block.__(0, [$$Array.fold_right(parse, keys, /* Empty */0)]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, ["Invalid dict parsing: " + exn[1]]); - } else { - throw exn; - } - } - } - })]; -} - -function field(key, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONObject */2) { - return /* Error */Block.__(1, ["Non-fieldable value"]); - } else { - var match$1 = Js_dict.get(match[0], key); - if (match$1 !== undefined) { - var o = Curry._1(decoder, Caml_option.valFromOption(match$1)); - if (o.tag) { - return /* Error */Block.__(1, ["field `" + (key + ("` -> " + o[0]))]); - } else { - return o; - } - } else { - return /* Error */Block.__(1, ["Field Value is undefined: " + key]); - } - } - })]; -} - -function at(fields, dec) { - return List.fold_right(field, fields, dec); -} - -function index(idx, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Web_json.classify(value); - if (typeof match === "number" || match.tag !== /* JSONArray */3) { - return /* Error */Block.__(1, ["Non-array value"]); - } else { - var a = match[0]; - if (idx < 0 || idx > a.length) { - return /* Error */Block.__(1, ["Array index out of range: " + String(idx)]); - } else { - return Curry._1(decoder, Caml_array.caml_array_get(a, idx)); - } - } - })]; -} - -function maybe(param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder, value); - if (match.tag) { - return /* Ok */Block.__(0, [undefined]); - } else { - return /* Ok */Block.__(0, [Caml_option.some(match[0])]); - } - })]; -} - -function oneOf(decoders) { - return /* Decoder */[(function (value) { - var parse = function (v, _param) { - while(true) { - var param = _param; - if (param) { - var rest = param[1]; - try { - var ok = Curry._1(param[0][0], v); - if (ok.tag) { - return parse(v, rest); - } else { - return ok; - } - } - catch (exn){ - _param = rest; - continue ; - } - } else { - return /* Error */Block.__(1, ["No one-of's matched"]); - } - }; - }; - return parse(value, decoders); - })]; -} - -function map$1(mapper, param) { - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - if (match.tag) { - return /* Error */Block.__(1, ["map " + match[0]]); - } else { - return /* Ok */Block.__(0, [Curry._1(mapper, match[0])]); - } - })]; -} - -function map2(mapper, param, param$1) { - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - if (!match.tag && !match$1.tag) { - return /* Ok */Block.__(0, [Curry._2(mapper, match[0], match$1[0])]); - } - var match$2 = Tea_result.error_of_first(match, match$1); - if (match$2 !== undefined) { - return /* Error */Block.__(1, ["map2 -> " + match$2]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map3(mapper, param, param$1, param$2) { - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - if (!match.tag && !match$1.tag && !match$2.tag) { - return /* Ok */Block.__(0, [Curry._3(mapper, match[0], match$1[0], match$2[0])]); - } - var match$3 = Tea_result.first(match$2, Tea_result.first(match$1, match)); - if (match$3.tag) { - return /* Error */Block.__(1, ["map3 -> " + match$3[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map4(mapper, param, param$1, param$2, param$3) { - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag) { - return /* Ok */Block.__(0, [Curry._4(mapper, match[0], match$1[0], match$2[0], match$3[0])]); - } - var match$4 = Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))); - if (match$4.tag) { - return /* Error */Block.__(1, ["map4 -> " + match$4[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map5(mapper, param, param$1, param$2, param$3, param$4) { - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag) { - return /* Ok */Block.__(0, [Curry._5(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0])]); - } - var match$5 = Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match)))); - if (match$5.tag) { - return /* Error */Block.__(1, ["map5 -> " + match$5[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map6(mapper, param, param$1, param$2, param$3, param$4, param$5) { - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag) { - return /* Ok */Block.__(0, [Curry._6(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0])]); - } - var match$6 = Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))))); - if (match$6.tag) { - return /* Error */Block.__(1, ["map6 -> " + match$6[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map7(mapper, param, param$1, param$2, param$3, param$4, param$5, param$6) { - var decoder7 = param$6[0]; - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - var match$6 = Curry._1(decoder7, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag && !match$6.tag) { - return /* Ok */Block.__(0, [Curry._7(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0], match$6[0])]); - } - var match$7 = Tea_result.first(match$6, Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match)))))); - if (match$7.tag) { - return /* Error */Block.__(1, ["map7 -> " + match$7[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function map8(mapper, param, param$1, param$2, param$3, param$4, param$5, param$6, param$7) { - var decoder8 = param$7[0]; - var decoder7 = param$6[0]; - var decoder6 = param$5[0]; - var decoder5 = param$4[0]; - var decoder4 = param$3[0]; - var decoder3 = param$2[0]; - var decoder2 = param$1[0]; - var decoder1 = param[0]; - return /* Decoder */[(function (value) { - var match = Curry._1(decoder1, value); - var match$1 = Curry._1(decoder2, value); - var match$2 = Curry._1(decoder3, value); - var match$3 = Curry._1(decoder4, value); - var match$4 = Curry._1(decoder5, value); - var match$5 = Curry._1(decoder6, value); - var match$6 = Curry._1(decoder7, value); - var match$7 = Curry._1(decoder8, value); - if (!match.tag && !match$1.tag && !match$2.tag && !match$3.tag && !match$4.tag && !match$5.tag && !match$6.tag && !match$7.tag) { - return /* Ok */Block.__(0, [Curry._8(mapper, match[0], match$1[0], match$2[0], match$3[0], match$4[0], match$5[0], match$6[0], match$7[0])]); - } - var match$8 = Tea_result.first(match$7, Tea_result.first(match$6, Tea_result.first(match$5, Tea_result.first(match$4, Tea_result.first(match$3, Tea_result.first(match$2, Tea_result.first(match$1, match))))))); - if (match$8.tag) { - return /* Error */Block.__(1, ["map8 -> " + match$8[0]]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Impossible case" - ]; - } - })]; -} - -function succeed(v) { - return /* Decoder */[(function (_value) { - return /* Ok */Block.__(0, [v]); - })]; -} - -function fail(e) { - return /* Decoder */[(function (_value) { - return /* Error */Block.__(1, [e]); - })]; -} - -var value = /* Decoder */[(function (value) { - return /* Ok */Block.__(0, [value]); - })]; - -function andThen(func, param) { - var decoder = param[0]; - return /* Decoder */[(function (value) { - var err = Curry._1(decoder, value); - if (err.tag) { - return err; - } else { - var match = Curry._1(func, err[0]); - return Curry._1(match[0], value); - } - })]; -} - -function lazy_(func) { - return andThen(func, /* Decoder */[(function (_value) { - return /* Ok */Block.__(0, [/* () */0]); - })]); -} - -function nullable(decoder) { - return oneOf(/* :: */[ - $$null(undefined), - /* :: */[ - map$1((function (v) { - return Caml_option.some(v); - }), decoder), - /* [] */0 - ] - ]); -} - -function decodeValue(param, value) { - try { - return Curry._1(param[0], value); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, [exn[1]]); - } else { - return /* Error */Block.__(1, ["Unknown JSON parsing error"]); - } - } -} - -function decodeEvent(param, value) { - try { - return Curry._1(param[0], value); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === ParseFail) { - return /* Error */Block.__(1, [exn[1]]); - } else { - return /* Error */Block.__(1, ["Unknown JSON parsing error"]); - } - } -} - -function decodeString(decoder, string) { - try { - var value = JSON.parse(string); - return decodeValue(decoder, value); - } - catch (exn){ - return /* Error */Block.__(1, ["Invalid JSON string"]); - } -} - -var Decoder = { - ObjectDict: ObjectDict, - ParseFail: ParseFail, - string: string, - $$int: $$int, - $$float: $$float, - bool: bool, - $$null: $$null, - list: list, - array: array, - keyValuePairs: keyValuePairs, - dict: dict, - field: field, - at: at, - index: index, - maybe: maybe, - oneOf: oneOf, - map: map$1, - map2: map2, - map3: map3, - map4: map4, - map5: map5, - map6: map6, - map7: map7, - map8: map8, - succeed: succeed, - fail: fail, - value: value, - andThen: andThen, - lazy_: lazy_, - nullable: nullable, - decodeValue: decodeValue, - decodeEvent: decodeEvent, - decodeString: decodeString -}; - -function encode(indentLevel, value) { - return Web_json.string_of_json(indentLevel, value); -} - -function string$1(v) { - return v; -} - -function $$int$1(v) { - return v; -} - -function $$float$1(v) { - return v; -} - -function bool$1(v) { - return v; -} - -function object_(v) { - var aux = function (o, param) { - o[param[0]] = param[1]; - return o; - }; - return List.fold_left(aux, { }, v); -} - -function array$1(v) { - return v; -} - -var list$1 = $$Array.of_list; - -var Encoder = { - encode: encode, - string: string$1, - $$int: $$int$1, - $$float: $$float$1, - bool: bool$1, - $$null: Web_json.$$null, - object_: object_, - array: array$1, - list: list$1 -}; - -exports.Decoder = Decoder; -exports.Encoder = Encoder; -/* No side effect */ - -},{"./tea_result.js":11,"./web_json.js":18,"bs-platform/lib/js/array.js":35,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_array.js":39,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_exceptions.js":42,"bs-platform/lib/js/caml_js_exceptions.js":48,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/caml_primitive.js":51,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/js_dict.js":59,"bs-platform/lib/js/list.js":61,"bs-platform/lib/js/pervasives.js":62}],9:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_sub = require("./tea_sub.js"); -var Tea_json = require("./tea_json.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -var position = Tea_json.Decoder.map2((function (x, y) { - return { - x: x, - y: y - }; - }), Tea_json.Decoder.field("pageX", Tea_json.Decoder.$$int), Tea_json.Decoder.field("pageY", Tea_json.Decoder.$$int)); - -function registerGlobal(name, key, tagger) { - var enableCall = function (callbacks_base) { - var callbacks = { - contents: callbacks_base - }; - var fn = function (ev) { - var match = Tea_json.Decoder.decodeEvent(position, ev); - if (match.tag) { - return ; - } else { - return Caml_option.some(Curry._1(tagger, match[0])); - } - }; - var handler = /* EventHandlerCallback */Block.__(0, [ - key, - fn - ]); - var elem = document; - var cache = Vdom.eventHandler_Register(callbacks, elem, name, handler); - return (function (param) { - Vdom.eventHandler_Unregister(elem, name, cache); - return /* () */0; - }); - }; - return Tea_sub.registration(key, enableCall); -} - -function clicks($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("click", key, tagger); -} - -function moves($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mousemove", key, tagger); -} - -function downs($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mousedown", key, tagger); -} - -function ups($staropt$star, tagger) { - var key = $staropt$star !== undefined ? $staropt$star : ""; - return registerGlobal("mouseup", key, tagger); -} - -exports.position = position; -exports.registerGlobal = registerGlobal; -exports.clicks = clicks; -exports.moves = moves; -exports.downs = downs; -exports.ups = ups; -/* position Not a pure module */ - -},{"./tea_json.js":8,"./tea_sub.js":12,"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58}],10:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_app = require("./tea_app.js"); -var Tea_sub = require("./tea_sub.js"); -var Web_window = require("./web_window.js"); -var Web_location = require("./web_location.js"); -var Web_window_history = require("./web_window_history.js"); - -function getLocation(param) { - return Web_location.asRecord(document.location); -} - -var notifier = { - contents: undefined -}; - -function notifyUrlChange(param) { - var match = notifier.contents; - if (match !== undefined) { - var $$location = Web_location.asRecord(document.location); - Curry._1(match, $$location); - return /* () */0; - } else { - return /* () */0; - } -} - -function subscribe(tagger) { - var enableCall = function (callbacks) { - var notifyHandler = function ($$location) { - return Curry._1(callbacks.enqueue, Curry._1(tagger, $$location)); - }; - notifier.contents = notifyHandler; - var handler = function (_event) { - return notifyUrlChange(/* () */0); - }; - Web_window.addEventListener("popstate", handler, false); - return (function (param) { - return Web_window.removeEventListener("popstate", handler, false); - }); - }; - return Tea_sub.registration("navigation", enableCall); -} - -function replaceState(url) { - Web_window_history.replaceState(window, JSON.parse("{}"), "", url); - return /* () */0; -} - -function pushState(url) { - Web_window_history.pushState(window, JSON.parse("{}"), "", url); - return /* () */0; -} - -function modifyUrl(url) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - replaceState(url); - notifyUrlChange(/* () */0); - return /* () */0; - })]); -} - -function newUrl(url) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - pushState(url); - notifyUrlChange(/* () */0); - return /* () */0; - })]); -} - -function go(step) { - return /* EnqueueCall */Block.__(2, [(function (_enqueue) { - Web_window_history.go(window, step); - notifyUrlChange(/* () */0); - return /* () */0; - })]); -} - -function back(step) { - return go(-step | 0); -} - -var forward = go; - -function navigationProgram(locationToMessage, stuff) { - var init = function (flag) { - return Curry._2(stuff.init, flag, Web_location.asRecord(document.location)); - }; - var subscriptions = function (model) { - return /* Batch */Block.__(0, [/* :: */[ - subscribe(locationToMessage), - /* :: */[ - Curry._1(stuff.subscriptions, model), - /* [] */0 - ] - ]]); - }; - var partial_arg_update = stuff.update; - var partial_arg_view = stuff.view; - var partial_arg_shutdown = stuff.shutdown; - var partial_arg = { - init: init, - update: partial_arg_update, - view: partial_arg_view, - subscriptions: subscriptions, - shutdown: partial_arg_shutdown - }; - return (function (param, param$1) { - return Tea_app.program(partial_arg, param, param$1); - }); -} - -exports.getLocation = getLocation; -exports.notifier = notifier; -exports.notifyUrlChange = notifyUrlChange; -exports.subscribe = subscribe; -exports.replaceState = replaceState; -exports.pushState = pushState; -exports.modifyUrl = modifyUrl; -exports.newUrl = newUrl; -exports.go = go; -exports.back = back; -exports.forward = forward; -exports.navigationProgram = navigationProgram; -/* No side effect */ - -},{"./tea_app.js":1,"./tea_sub.js":12,"./web_location.js":19,"./web_window.js":21,"./web_window_history.js":22,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58}],11:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function result_to_option(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function option_of_result(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function ok(param) { - if (param.tag) { - return ; - } else { - return Caml_option.some(param[0]); - } -} - -function error(param) { - if (param.tag) { - return Caml_option.some(param[0]); - } - -} - -function last_of(_param) { - while(true) { - var param = _param; - if (param) { - var tl = param[1]; - var last = param[0]; - if (tl && !last.tag) { - _param = tl; - continue ; - } else { - return last; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "`Tea.Result.do` must never be passed the empty list" - ]; - } - }; -} - -function accumulate(param) { - if (param) { - var tl = param[1]; - var last = param[0]; - if (tl) { - if (last.tag) { - return last; - } else { - var e = accumulate(tl); - if (e.tag) { - return e; - } else { - return /* Ok */Block.__(0, [/* :: */[ - last[0], - e[0] - ]]); - } - } - } else if (last.tag) { - return last; - } else { - return /* Ok */Block.__(0, [/* :: */[ - last[0], - /* [] */0 - ]]); - } - } else { - return /* Ok */Block.__(0, [/* [] */0]); - } -} - -function first(fst, e) { - if (e.tag) { - return e; - } else { - return fst; - } -} - -function error_of_any(_param) { - while(true) { - var param = _param; - if (param) { - var hd = param[0]; - if (hd.tag) { - return Caml_option.some(hd[0]); - } else { - _param = param[1]; - continue ; - } - } else { - return ; - } - }; -} - -function error_of_first(fst, param) { - if (param.tag) { - return Caml_option.some(param[0]); - } else { - return error(fst); - } -} - -exports.result_to_option = result_to_option; -exports.option_of_result = option_of_result; -exports.ok = ok; -exports.error = error; -exports.last_of = last_of; -exports.accumulate = accumulate; -exports.first = first; -exports.error_of_any = error_of_any; -exports.error_of_first = error_of_first; -/* No side effect */ - -},{"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_option.js":50}],12:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("./vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); - -function batch(subs) { - return /* Batch */Block.__(0, [subs]); -} - -function registration(key, enableCall) { - return /* Registration */Block.__(1, [ - key, - (function (callbacks) { - return Curry._1(enableCall, callbacks.contents); - }), - { - contents: undefined - } - ]); -} - -function map(msgMapper, sub) { - var func = function (callbacks) { - return Vdom.wrapCallbacks(msgMapper, callbacks); - }; - return /* Mapper */Block.__(2, [ - func, - sub - ]); -} - -function mapFunc(func, sub) { - return /* Mapper */Block.__(2, [ - func, - sub - ]); -} - -function run(oldCallbacks, newCallbacks, oldSub, newSub) { - var enable = function (_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Batch */0 : - var subs = param[0]; - if (subs) { - return List.iter((function(callbacks){ - return function (param) { - return enable(callbacks, param); - } - }(callbacks)), subs); - } else { - return /* () */0; - } - case /* Registration */1 : - param[2].contents = Curry._1(param[1], callbacks); - return /* () */0; - case /* Mapper */2 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - - } - } - }; - }; - var disable = function (_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* Batch */0 : - var subs = param[0]; - if (subs) { - return List.iter((function(callbacks){ - return function (param) { - return disable(callbacks, param); - } - }(callbacks)), subs); - } else { - return /* () */0; - } - case /* Registration */1 : - var diCB = param[2]; - var match = diCB.contents; - if (match !== undefined) { - diCB.contents = undefined; - return Curry._1(match, /* () */0); - } else { - return /* () */0; - } - case /* Mapper */2 : - var subCallbacks = Curry._1(param[0], callbacks); - _param = param[1]; - _callbacks = subCallbacks; - continue ; - - } - } - }; - }; - if (typeof oldSub === "number") { - if (typeof newSub === "number") { - return newSub; - } - - } else { - switch (oldSub.tag | 0) { - case /* Batch */0 : - if (typeof newSub !== "number" && !newSub.tag) { - var aux = function (_oldList, _newList) { - while(true) { - var newList = _newList; - var oldList = _oldList; - if (oldList) { - var oldRest = oldList[1]; - var oldSubSub = oldList[0]; - if (newList) { - run(oldCallbacks, newCallbacks, oldSubSub, newList[0]); - _newList = newList[1]; - _oldList = oldRest; - continue ; - } else { - disable(oldCallbacks, oldSubSub); - _newList = /* [] */0; - _oldList = oldRest; - continue ; - } - } else if (newList) { - enable(newCallbacks, newList[0]); - _newList = newList[1]; - _oldList = /* [] */0; - continue ; - } else { - return /* () */0; - } - }; - }; - aux(oldSub[0], newSub[0]); - return newSub; - } - break; - case /* Registration */1 : - if (typeof newSub !== "number" && newSub.tag === /* Registration */1 && oldSub[0] === newSub[0]) { - newSub[2].contents = oldSub[2].contents; - return newSub; - } - break; - case /* Mapper */2 : - if (typeof newSub !== "number" && newSub.tag === /* Mapper */2) { - var olderCallbacks = Curry._1(oldSub[0], oldCallbacks); - var newerCallbacks = Curry._1(newSub[0], newCallbacks); - run(olderCallbacks, newerCallbacks, oldSub[1], newSub[1]); - return newSub; - } - break; - - } - } - disable(oldCallbacks, oldSub); - enable(newCallbacks, newSub); - return newSub; -} - -var none = /* NoSub */0; - -exports.none = none; -exports.batch = batch; -exports.registration = registration; -exports.map = map; -exports.mapFunc = mapFunc; -exports.run = run; -/* No side effect */ - -},{"./vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],13:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_obj = require("bs-platform/lib/js/caml_obj.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function nothing(param) { - return /* () */0; -} - -function performOpt(toOptionalMessage, param) { - var task = param[0]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(task, (function (param) { - if (param.tag) { - throw [ - Caml_builtin_exceptions.failure, - "ERROR: Task perfom returned error of never! Should not happen!" - ]; - } else { - var match = Curry._1(toOptionalMessage, param[0]); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - } - })); - })]); -} - -function perform(toMessage, task) { - return performOpt((function (v) { - return Caml_option.some(Curry._1(toMessage, v)); - }), task); -} - -function attemptOpt(resultToOptionalMessage, param) { - var task = param[0]; - return /* EnqueueCall */Block.__(2, [(function (callbacks) { - return Curry._1(task, (function (value) { - var match = Curry._1(resultToOptionalMessage, value); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - })); - })]); -} - -function attempt(resultToMessage, task) { - return attemptOpt((function (v) { - return Caml_option.some(Curry._1(resultToMessage, v)); - }), task); -} - -function ignore(task) { - return attemptOpt((function (param) { - return ; - }), task); -} - -function succeed(value) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; -} - -function fail(value) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; -} - -function nativeBinding(func) { - return /* Task */[func]; -} - -function andThen(fn, param) { - var task = param[0]; - return /* Task */[(function (cb) { - return Curry._1(task, (function (err) { - if (err.tag) { - return Curry._1(cb, err); - } else { - var match = Curry._1(fn, err[0]); - return Curry._1(match[0], cb); - } - })); - })]; -} - -function onError(fn, param) { - var task = param[0]; - return /* Task */[(function (cb) { - return Curry._1(task, (function (ok) { - if (ok.tag) { - var match = Curry._1(fn, ok[0]); - return Curry._1(match[0], cb); - } else { - return Curry._1(cb, ok); - } - })); - })]; -} - -function fromResult(param) { - if (param.tag) { - var value = param[0]; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; - } else { - var value$1 = param[0]; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value$1])); - })]; - } -} - -function mapError(func, task) { - return onError((function (e) { - var value = Curry._1(func, e); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value])); - })]; - }), task); -} - -function toOption(task) { - return onError((function (param) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [undefined])); - })]; - }), andThen((function (v) { - var value = Caml_option.some(v); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task)); -} - -function map(func, task1) { - return andThen((function (v1) { - var value = Curry._1(func, v1); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task1); -} - -function map2(func, task1, task2) { - return andThen((function (v1) { - return andThen((function (v2) { - var value = Curry._2(func, v1, v2); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task2); - }), task1); -} - -function map3(func, task1, task2, task3) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - var value = Curry._3(func, v1, v2, v3); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task3); - }), task2); - }), task1); -} - -function map4(func, task1, task2, task3, task4) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - var value = Curry._4(func, v1, v2, v3, v4); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task4); - }), task3); - }), task2); - }), task1); -} - -function map5(func, task1, task2, task3, task4, task5) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - return andThen((function (v5) { - var value = Curry._5(func, v1, v2, v3, v4, v5); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task5); - }), task4); - }), task3); - }), task2); - }), task1); -} - -function map6(func, task1, task2, task3, task4, task5, task6) { - return andThen((function (v1) { - return andThen((function (v2) { - return andThen((function (v3) { - return andThen((function (v4) { - return andThen((function (v5) { - return andThen((function (v6) { - var value = Curry._6(func, v1, v2, v3, v4, v5, v6); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), task6); - }), task5); - }), task4); - }), task3); - }), task2); - }), task1); -} - -function sequence(param) { - if (param) { - return map2((function (l, r) { - return /* :: */[ - l, - r - ]; - }), param[0], sequence(param[1])); - } else { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [/* [] */0])); - })]; - } -} - -var testing_deop = { - contents: true -}; - -function testing(param) { - var doTest = function (expected, param) { - return Curry._1(param[0], (function (v) { - if (Caml_obj.caml_equal(v, expected)) { - console.log(/* tuple */[ - "Passed:", - expected, - v - ]); - return /* () */0; - } else { - console.log(/* tuple */[ - "FAILED:", - expected, - v - ]); - return /* () */0; - } - })); - }; - var s = /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - doTest(/* Ok */Block.__(0, [42]), s); - var f = /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [86])); - })]; - doTest(/* Error */Block.__(1, [86]), f); - var r = function (param) { - if (testing_deop.contents) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - } else { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]; - } - }; - var a1 = andThen((function (n) { - var value = n + 2 | 0; - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]); - doTest(/* Ok */Block.__(0, [4]), a1); - var a2 = andThen((function (n) { - var value = String(n); - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]); - doTest(/* Ok */Block.__(0, ["2"]), a2); - var m1 = map((function (prim) { - return Math.sqrt(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })]); - doTest(/* Ok */Block.__(0, [3]), m1); - var m2 = map2((function (prim, prim$1) { - return prim + prim$1 | 0; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })], /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [3])); - })]); - doTest(/* Ok */Block.__(0, [12]), m2); - var m3 = map((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [9])); - })]); - doTest(/* Ok */Block.__(0, ["9"]), m3); - var s0 = sequence(/* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })], - /* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })], - /* [] */0 - ] - ]); - doTest(/* Ok */Block.__(0, [/* :: */[ - 1, - /* :: */[ - 2, - /* [] */0 - ] - ]]), s0); - var s1 = sequence(/* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })], - /* :: */[ - /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [2.7])); - })], - /* :: */[ - r(/* () */0), - /* [] */0 - ] - ] - ]); - doTest(/* Error */Block.__(1, [2.7]), s1); - var e0 = onError((function (_msg) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["file not found"])); - })]); - doTest(/* Ok */Block.__(0, [42]), e0); - var e1 = onError((function (_msg) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [42])); - })]; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["file not found"])); - })]); - doTest(/* Error */Block.__(1, [42]), e1); - var n0 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [42])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]), - /* [] */0 - ] - ]); - doTest(/* Error */Block.__(1, ["42"]), n0); - var n1 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [3.14])); - })]), - /* [] */0 - ] - ]); - doTest(/* Error */Block.__(1, ["3.14"]), n1); - var n2 = sequence(/* :: */[ - mapError((function (prim) { - return String(prim); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [1])); - })]), - /* :: */[ - mapError((function (prim) { - return prim.toString(); - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [2])); - })]), - /* [] */0 - ] - ]); - doTest(/* Ok */Block.__(0, [/* :: */[ - 1, - /* :: */[ - 2, - /* [] */0 - ] - ]]), n2); - perform((function (param) { - return 42; - }), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [18])); - })]); - var value = 42; - doTest(/* Ok */Block.__(0, [42]), /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [value])); - })]); - var value$1 = "failure"; - doTest(/* Error */Block.__(1, ["failure"]), /* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, [value$1])); - })]); - doTest(/* Ok */Block.__(0, [undefined]), toOption(/* Task */[(function (cb) { - return Curry._1(cb, /* Error */Block.__(1, ["for some reason"])); - })])); - doTest(/* Ok */Block.__(0, [42]), toOption(/* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, [42])); - })])); - return /* () */0; -} - -exports.nothing = nothing; -exports.performOpt = performOpt; -exports.perform = perform; -exports.attemptOpt = attemptOpt; -exports.attempt = attempt; -exports.ignore = ignore; -exports.succeed = succeed; -exports.fail = fail; -exports.nativeBinding = nativeBinding; -exports.andThen = andThen; -exports.onError = onError; -exports.fromResult = fromResult; -exports.mapError = mapError; -exports.toOption = toOption; -exports.map = map; -exports.map2 = map2; -exports.map3 = map3; -exports.map4 = map4; -exports.map5 = map5; -exports.map6 = map6; -exports.sequence = sequence; -exports.testing_deop = testing_deop; -exports.testing = testing; -/* No side effect */ - -},{"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_obj.js":49,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58}],14:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var $$String = require("bs-platform/lib/js/string.js"); -var Caml_obj = require("bs-platform/lib/js/caml_obj.js"); -var Web_node = require("./web_node.js"); -var Caml_array = require("bs-platform/lib/js/caml_array.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Web_document = require("./web_document.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -var noNode = /* CommentNode */Block.__(0, [""]); - -function comment(s) { - return /* CommentNode */Block.__(0, [s]); -} - -function text(s) { - return /* Text */Block.__(1, [s]); -} - -function fullnode(namespace, tagName, key, unique, props, vdoms) { - return /* Node */Block.__(2, [ - namespace, - tagName, - key, - unique, - props, - vdoms - ]); -} - -function node($staropt$star, tagName, $staropt$star$1, $staropt$star$2, props, vdoms) { - var namespace = $staropt$star !== undefined ? $staropt$star : ""; - var key = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var unique = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return fullnode(namespace, tagName, key, unique, props, vdoms); -} - -function lazyGen(key, fn) { - return /* LazyGen */Block.__(3, [ - key, - fn, - { - contents: noNode - } - ]); -} - -function prop(key, value) { - return /* RawProp */Block.__(0, [ - key, - value - ]); -} - -function onCB(name, key, cb) { - return /* Event */Block.__(3, [ - name, - /* EventHandlerCallback */Block.__(0, [ - key, - cb - ]), - { - contents: undefined - } - ]); -} - -function onMsg(name, msg) { - return /* Event */Block.__(3, [ - name, - /* EventHandlerMsg */Block.__(1, [msg]), - { - contents: undefined - } - ]); -} - -function attribute(namespace, key, value) { - return /* Attribute */Block.__(1, [ - namespace, - key, - value - ]); -} - -function data(key, value) { - return /* Data */Block.__(2, [ - key, - value - ]); -} - -function style(key, value) { - return /* Style */Block.__(4, [/* :: */[ - /* tuple */[ - key, - value - ], - /* [] */0 - ]]); -} - -function styles(s) { - return /* Style */Block.__(4, [s]); -} - -function renderToHtmlString(_param) { - while(true) { - var param = _param; - switch (param.tag | 0) { - case /* CommentNode */0 : - return ""); - case /* Text */1 : - return param[0]; - case /* Node */2 : - var tagName = param[1]; - var namespace = param[0]; - return $$String.concat("", /* :: */[ - "<", - /* :: */[ - namespace, - /* :: */[ - namespace === "" ? "" : ":", - /* :: */[ - tagName, - /* :: */[ - $$String.concat("", List.map((function (p) { - var param = p; - if (typeof param === "number") { - return ""; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - return $$String.concat("", /* :: */[ - " ", - /* :: */[ - param[0], - /* :: */[ - "=\"", - /* :: */[ - param[1], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Attribute */1 : - return $$String.concat("", /* :: */[ - " ", - /* :: */[ - param[1], - /* :: */[ - "=\"", - /* :: */[ - param[2], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Data */2 : - return $$String.concat("", /* :: */[ - " data-", - /* :: */[ - param[0], - /* :: */[ - "=\"", - /* :: */[ - param[1], - /* :: */[ - "\"", - /* [] */0 - ] - ] - ] - ] - ]); - case /* Event */3 : - return ""; - case /* Style */4 : - return $$String.concat("", /* :: */[ - " style=\"", - /* :: */[ - $$String.concat(";", List.map((function (param) { - return $$String.concat("", /* :: */[ - param[0], - /* :: */[ - ":", - /* :: */[ - param[1], - /* :: */[ - ";", - /* [] */0 - ] - ] - ] - ]); - }), param[0])), - /* :: */[ - "\"", - /* [] */0 - ] - ] - ]); - - } - } - }), param[4])), - /* :: */[ - ">", - /* :: */[ - $$String.concat("", List.map(renderToHtmlString, param[5])), - /* :: */[ - "", - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]); - case /* LazyGen */3 : - _param = Curry._1(param[1], /* () */0); - continue ; - case /* Tagger */4 : - _param = param[1]; - continue ; - - } - }; -} - -function emptyEventHandler(_ev) { - return /* () */0; -} - -function emptyEventCB(_ev) { - return ; -} - -function eventHandler(callbacks, cb) { - return (function (ev) { - var match = Curry._1(cb.contents, ev); - if (match !== undefined) { - return Curry._1(callbacks.contents.enqueue, Caml_option.valFromOption(match)); - } else { - return /* () */0; - } - }); -} - -function eventHandler_GetCB(param) { - if (param.tag) { - var msg = param[0]; - return (function (_ev) { - return Caml_option.some(msg); - }); - } else { - return param[1]; - } -} - -function compareEventHandlerTypes(left, param) { - if (param.tag) { - if (left.tag && Caml_obj.caml_equal(param[0], left[0])) { - return true; - } else { - return false; - } - } else if (left.tag) { - return false; - } else { - return param[0] === left[0]; - } -} - -function eventHandler_Register(callbacks, elem, name, handlerType) { - var cb = { - contents: eventHandler_GetCB(handlerType) - }; - var handler = eventHandler(callbacks, cb); - Web_node.addEventListener(elem, name, handler, false); - return { - handler: handler, - cb: cb - }; -} - -function eventHandler_Unregister(elem, name, param) { - if (param !== undefined) { - Web_node.removeEventListener(elem, name, param.handler, false); - return ; - } - -} - -function eventHandler_Mutate(callbacks, elem, oldName, newName, oldHandlerType, newHandlerType, oldCache, newCache) { - var match = oldCache.contents; - if (match !== undefined) { - if (oldName === newName) { - newCache.contents = oldCache.contents; - if (compareEventHandlerTypes(oldHandlerType, newHandlerType)) { - return /* () */0; - } else { - var cb = eventHandler_GetCB(newHandlerType); - match.cb.contents = cb; - return /* () */0; - } - } else { - oldCache.contents = eventHandler_Unregister(elem, oldName, oldCache.contents); - newCache.contents = eventHandler_Register(callbacks, elem, newName, newHandlerType); - return /* () */0; - } - } else { - newCache.contents = eventHandler_Register(callbacks, elem, newName, newHandlerType); - return /* () */0; - } -} - -function patchVNodesOnElems_PropertiesApply_Add(callbacks, elem, _idx, param) { - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - elem[param[0]] = param[1]; - return /* () */0; - case /* Attribute */1 : - return Web_node.setAttributeNsOptional(elem, param[0], param[1], param[2]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Add Data Unhandled", - param[0], - param[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Add Data Unhandled" - ]; - case /* Event */3 : - param[2].contents = eventHandler_Register(callbacks, elem, param[0], param[1]); - return /* () */0; - case /* Style */4 : - return List.fold_left((function (param, param$1) { - return Web_node.setStyleProperty(elem, undefined, param$1[0], param$1[1]); - }), /* () */0, param[0]); - - } - } -} - -function patchVNodesOnElems_PropertiesApply_Remove(_callbacks, elem, _idx, param) { - if (typeof param === "number") { - return /* () */0; - } else { - switch (param.tag | 0) { - case /* RawProp */0 : - elem[param[0]] = undefined; - return /* () */0; - case /* Attribute */1 : - return Web_node.removeAttributeNsOptional(elem, param[0], param[1]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Remove Data Unhandled", - param[0], - param[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Remove Data Unhandled" - ]; - case /* Event */3 : - var cache = param[2]; - cache.contents = eventHandler_Unregister(elem, param[0], cache.contents); - return /* () */0; - case /* Style */4 : - return List.fold_left((function (param, param$1) { - return Web_node.setStyleProperty(elem, undefined, param$1[0], null); - }), /* () */0, param[0]); - - } - } -} - -function patchVNodesOnElems_PropertiesApply_RemoveAdd(callbacks, elem, idx, oldProp, newProp) { - patchVNodesOnElems_PropertiesApply_Remove(callbacks, elem, idx, oldProp); - patchVNodesOnElems_PropertiesApply_Add(callbacks, elem, idx, newProp); - return /* () */0; -} - -function patchVNodesOnElems_PropertiesApply_Mutate(_callbacks, elem, _idx, oldProp, _newProp) { - if (typeof _newProp === "number") { - throw [ - Caml_builtin_exceptions.failure, - "This should never be called as all entries through NoProp are gated." - ]; - } else { - switch (_newProp.tag | 0) { - case /* RawProp */0 : - elem[_newProp[0]] = _newProp[1]; - return /* () */0; - case /* Attribute */1 : - return Web_node.setAttributeNsOptional(elem, _newProp[0], _newProp[1], _newProp[2]); - case /* Data */2 : - console.log(/* tuple */[ - "TODO: Mutate Data Unhandled", - _newProp[0], - _newProp[1] - ]); - throw [ - Caml_builtin_exceptions.failure, - "TODO: Mutate Data Unhandled" - ]; - case /* Event */3 : - throw [ - Caml_builtin_exceptions.failure, - "This will never be called because it is gated" - ]; - case /* Style */4 : - if (typeof oldProp === "number") { - throw [ - Caml_builtin_exceptions.failure, - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!" - ]; - } else if (oldProp.tag === /* Style */4) { - return List.fold_left2((function (param, param$1, param$2) { - var nv = param$2[1]; - var nk = param$2[0]; - var ok = param$1[0]; - if (ok === nk) { - if (param$1[1] === nv) { - return /* () */0; - } else { - return Web_node.setStyleProperty(elem, undefined, nk, nv); - } - } else { - Web_node.setStyleProperty(elem, undefined, ok, null); - return Web_node.setStyleProperty(elem, undefined, nk, nv); - } - }), /* () */0, oldProp[0], _newProp[0]); - } else { - throw [ - Caml_builtin_exceptions.failure, - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!" - ]; - } - - } - } -} - -function patchVNodesOnElems_PropertiesApply(callbacks, elem, _idx, _oldProperties, _newProperties) { - while(true) { - var newProperties = _newProperties; - var oldProperties = _oldProperties; - var idx = _idx; - if (oldProperties) { - var _oldProp = oldProperties[0]; - if (newProperties) { - if (typeof _oldProp === "number") { - if (typeof newProperties[0] === "number") { - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - - } else { - switch (_oldProp.tag | 0) { - case /* RawProp */0 : - var newProp = newProperties[0]; - if (typeof newProp !== "number" && !newProp.tag) { - if (!(_oldProp[0] === newProp[0] && _oldProp[1] === newProp[1])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Attribute */1 : - var newProp$1 = newProperties[0]; - if (typeof newProp$1 !== "number" && newProp$1.tag === /* Attribute */1) { - if (!(_oldProp[0] === newProp$1[0] && _oldProp[1] === newProp$1[1] && _oldProp[2] === newProp$1[2])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$1); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Data */2 : - var newProp$2 = newProperties[0]; - if (typeof newProp$2 !== "number" && newProp$2.tag === /* Data */2) { - if (!(_oldProp[0] === newProp$2[0] && _oldProp[1] === newProp$2[1])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$2); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Event */3 : - var _newProp = newProperties[0]; - if (typeof _newProp !== "number" && _newProp.tag === /* Event */3) { - eventHandler_Mutate(callbacks, elem, _oldProp[0], _newProp[0], _oldProp[1], _newProp[1], _oldProp[2], _newProp[2]); - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - case /* Style */4 : - var newProp$3 = newProperties[0]; - if (typeof newProp$3 !== "number" && newProp$3.tag === /* Style */4) { - if (!Caml_obj.caml_equal(_oldProp[0], newProp$3[0])) { - patchVNodesOnElems_PropertiesApply_Mutate(callbacks, elem, idx, _oldProp, newProp$3); - } - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } - break; - - } - } - } else { - return false; - } - patchVNodesOnElems_PropertiesApply_RemoveAdd(callbacks, elem, idx, _oldProp, newProperties[0]); - _newProperties = newProperties[1]; - _oldProperties = oldProperties[1]; - _idx = idx + 1 | 0; - continue ; - } else if (newProperties) { - return false; - } else { - return true; - } - }; -} - -function patchVNodesOnElems_Properties(callbacks, elem, oldProperties, newProperties) { - return patchVNodesOnElems_PropertiesApply(callbacks, elem, 0, oldProperties, newProperties); -} - -function genEmptyProps(length) { - var _lst = /* [] */0; - var _len = length; - while(true) { - var len = _len; - var lst = _lst; - if (len !== 0) { - _len = len - 1 | 0; - _lst = /* :: */[ - /* NoProp */0, - lst - ]; - continue ; - } else { - return lst; - } - }; -} - -function mapEmptyProps(props) { - return List.map((function (param) { - return /* NoProp */0; - }), props); -} - -function patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, param) { - if (param.tag === /* Node */2) { - var newProperties = param[4]; - var oldChild = Caml_array.caml_array_get(elems, idx); - var newChild = Web_document.createElementNsOptional(param[0], param[1]); - var match = patchVNodesOnElems_Properties(callbacks, newChild, List.map((function (param) { - return /* NoProp */0; - }), newProperties), newProperties); - if (match) { - var childChildren = newChild.childNodes; - patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, param[5]); - Web_node.insertBefore(elem, newChild, oldChild); - elem.removeChild(oldChild); - return /* () */0; - } else { - throw [ - Caml_builtin_exceptions.match_failure, - /* tuple */[ - "vdom.ml", - 343, - 13 - ] - ]; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Node replacement should never be passed anything but a node itself" - ]; - } -} - -function patchVNodesOnElems_CreateElement(_callbacks, _param) { - while(true) { - var param = _param; - var callbacks = _callbacks; - switch (param.tag | 0) { - case /* CommentNode */0 : - var text = param[0]; - return document.createComment(text); - case /* Text */1 : - var text$1 = param[0]; - return document.createTextNode(text$1); - case /* Node */2 : - var newProperties = param[4]; - var newChild = Web_document.createElementNsOptional(param[0], param[1]); - var match = patchVNodesOnElems_Properties(callbacks, newChild, List.map((function (param) { - return /* NoProp */0; - }), newProperties), newProperties); - if (match) { - var childChildren = newChild.childNodes; - patchVNodesOnElems(callbacks, newChild, childChildren, 0, /* [] */0, param[5]); - return newChild; - } else { - throw [ - Caml_builtin_exceptions.match_failure, - /* tuple */[ - "vdom.ml", - 368, - 11 - ] - ]; - } - case /* LazyGen */3 : - var vdom = Curry._1(param[1], /* () */0); - param[2].contents = vdom; - _param = vdom; - continue ; - case /* Tagger */4 : - _param = param[1]; - _callbacks = Curry._1(param[0], callbacks); - continue ; - - } - }; -} - -function patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode) { - if (oldNode.tag === /* Node */2) { - if (newNode.tag === /* Node */2) { - if (oldNode[3] !== newNode[3] || oldNode[1] !== newNode[1]) { - return patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, newNode); - } else { - var child = Caml_array.caml_array_get(elems, idx); - var childChildren = child.childNodes; - if (!patchVNodesOnElems_Properties(callbacks, child, oldNode[4], newNode[4])) { - console.log("VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved."); - patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, newNode); - } - return patchVNodesOnElems(callbacks, child, childChildren, 0, oldNode[5], newNode[5]); - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Non-node passed to patchVNodesOnElems_MutateNode" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "Non-node passed to patchVNodesOnElems_MutateNode" - ]; - } -} - -function patchVNodesOnElems(callbacks, elem, elems, _idx, _oldVNodes, _newVNodes) { - while(true) { - var newVNodes = _newVNodes; - var oldVNodes = _oldVNodes; - var idx = _idx; - if (oldVNodes) { - var oldNode = oldVNodes[0]; - switch (oldNode.tag | 0) { - case /* CommentNode */0 : - if (newVNodes) { - var match = newVNodes[0]; - if (!match.tag && oldNode[0] === match[0]) { - _newVNodes = newVNodes[1]; - _oldVNodes = oldVNodes[1]; - _idx = idx + 1 | 0; - continue ; - } - - } - break; - case /* Text */1 : - if (newVNodes) { - var match$1 = newVNodes[0]; - if (match$1.tag === /* Text */1) { - var newText = match$1[0]; - if (oldNode[0] !== newText) { - var child = Caml_array.caml_array_get(elems, idx); - child.nodeValue = newText; - } - _newVNodes = newVNodes[1]; - _oldVNodes = oldVNodes[1]; - _idx = idx + 1 | 0; - continue ; - } - - } - break; - case /* Node */2 : - if (newVNodes) { - var newNode = newVNodes[0]; - if (newNode.tag === /* Node */2) { - var newRest = newVNodes[1]; - var newKey = newNode[2]; - var newTagName = newNode[1]; - var newNamespace = newNode[0]; - var oldRest = oldVNodes[1]; - var oldKey = oldNode[2]; - var oldTagName = oldNode[1]; - var oldNamespace = oldNode[0]; - if (oldKey === newKey && oldKey !== "") { - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } else if (oldKey === "" || newKey === "") { - patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode); - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } else { - var exit = 0; - var exit$1 = 0; - if (oldRest) { - var match$2 = oldRest[0]; - if (match$2.tag === /* Node */2) { - var olderRest = oldRest[1]; - var olderKey = match$2[2]; - var olderTagName = match$2[1]; - var olderNamespace = match$2[0]; - var exit$2 = 0; - if (newRest) { - var match$3 = newRest[0]; - if (match$3.tag === /* Node */2 && olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey && oldNamespace === match$3[0] && oldTagName === match$3[1] && oldKey === match$3[2]) { - var firstChild = Caml_array.caml_array_get(elems, idx); - var secondChild = Caml_array.caml_array_get(elems, idx + 1 | 0); - elem.removeChild(secondChild); - Web_node.insertBefore(elem, secondChild, firstChild); - _newVNodes = newRest[1]; - _oldVNodes = olderRest; - _idx = idx + 2 | 0; - continue ; - } else { - exit$2 = 4; - } - } else { - exit$2 = 4; - } - if (exit$2 === 4) { - if (olderNamespace === newNamespace && olderTagName === newTagName && olderKey === newKey) { - var oldChild = Caml_array.caml_array_get(elems, idx); - elem.removeChild(oldChild); - _newVNodes = newRest; - _oldVNodes = olderRest; - _idx = idx + 1 | 0; - continue ; - } else { - exit$1 = 3; - } - } - - } else { - exit$1 = 3; - } - } else { - exit$1 = 3; - } - if (exit$1 === 3) { - if (newRest) { - var match$4 = newRest[0]; - if (match$4.tag === /* Node */2 && oldNamespace === match$4[0] && oldTagName === match$4[1] && oldKey === match$4[2]) { - var oldChild$1 = Caml_array.caml_array_get(elems, idx); - var newChild = patchVNodesOnElems_CreateElement(callbacks, newNode); - Web_node.insertBefore(elem, newChild, oldChild$1); - _newVNodes = newRest; - _idx = idx + 1 | 0; - continue ; - } else { - exit = 2; - } - } else { - exit = 2; - } - } - if (exit === 2) { - patchVNodesOnElems_MutateNode(callbacks, elem, elems, idx, oldNode, newNode); - _newVNodes = newRest; - _oldVNodes = oldRest; - _idx = idx + 1 | 0; - continue ; - } - - } - } - - } - break; - case /* LazyGen */3 : - if (newVNodes) { - var match$5 = newVNodes[0]; - if (match$5.tag === /* LazyGen */3) { - var newRest$1 = newVNodes[1]; - var newCache = match$5[2]; - var newGen = match$5[1]; - var newKey$1 = match$5[0]; - var oldRest$1 = oldVNodes[1]; - var oldCache = oldNode[2]; - var oldKey$1 = oldNode[0]; - if (oldKey$1 === newKey$1) { - newCache.contents = oldCache.contents; - _newVNodes = newRest$1; - _oldVNodes = oldRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - var exit$3 = 0; - var exit$4 = 0; - if (oldRest$1) { - var match$6 = oldRest$1[0]; - if (match$6.tag === /* LazyGen */3) { - var olderRest$1 = oldRest$1[1]; - var olderKey$1 = match$6[0]; - var exit$5 = 0; - if (newRest$1) { - var match$7 = newRest$1[0]; - if (match$7.tag === /* LazyGen */3 && olderKey$1 === newKey$1 && oldKey$1 === match$7[0]) { - var firstChild$1 = Caml_array.caml_array_get(elems, idx); - var secondChild$1 = Caml_array.caml_array_get(elems, idx + 1 | 0); - elem.removeChild(secondChild$1); - Web_node.insertBefore(elem, secondChild$1, firstChild$1); - _newVNodes = newRest$1[1]; - _oldVNodes = olderRest$1; - _idx = idx + 2 | 0; - continue ; - } else { - exit$5 = 4; - } - } else { - exit$5 = 4; - } - if (exit$5 === 4) { - if (olderKey$1 === newKey$1) { - var oldChild$2 = Caml_array.caml_array_get(elems, idx); - elem.removeChild(oldChild$2); - var oldVdom = match$6[2].contents; - newCache.contents = oldVdom; - _newVNodes = newRest$1; - _oldVNodes = olderRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - exit$4 = 3; - } - } - - } else { - exit$4 = 3; - } - } else { - exit$4 = 3; - } - if (exit$4 === 3) { - if (newRest$1) { - var match$8 = newRest$1[0]; - if (match$8.tag === /* LazyGen */3 && match$8[0] === oldKey$1) { - var oldChild$3 = Caml_array.caml_array_get(elems, idx); - var newVdom = Curry._1(newGen, /* () */0); - newCache.contents = newVdom; - var newChild$1 = patchVNodesOnElems_CreateElement(callbacks, newVdom); - Web_node.insertBefore(elem, newChild$1, oldChild$3); - _newVNodes = newRest$1; - _idx = idx + 1 | 0; - continue ; - } else { - exit$3 = 2; - } - } else { - exit$3 = 2; - } - } - if (exit$3 === 2) { - var oldVdom$1 = oldCache.contents; - var newVdom$1 = Curry._1(newGen, /* () */0); - newCache.contents = newVdom$1; - _newVNodes = /* :: */[ - newVdom$1, - newRest$1 - ]; - _oldVNodes = /* :: */[ - oldVdom$1, - oldRest$1 - ]; - continue ; - } - - } - } - - } - break; - case /* Tagger */4 : - _oldVNodes = /* :: */[ - oldNode[1], - oldVNodes[1] - ]; - continue ; - - } - var oldRest$2 = oldVNodes[1]; - if (newVNodes) { - var newNode$1 = newVNodes[0]; - if (newNode$1.tag === /* Tagger */4) { - patchVNodesOnElems(Curry._1(newNode$1[0], callbacks), elem, elems, idx, /* :: */[ - oldNode, - /* [] */0 - ], /* :: */[ - newNode$1[1], - /* [] */0 - ]); - _newVNodes = newVNodes[1]; - _oldVNodes = oldRest$2; - _idx = idx + 1 | 0; - continue ; - } else { - var oldChild$4 = Caml_array.caml_array_get(elems, idx); - var newChild$2 = patchVNodesOnElems_CreateElement(callbacks, newNode$1); - Web_node.insertBefore(elem, newChild$2, oldChild$4); - elem.removeChild(oldChild$4); - _newVNodes = newVNodes[1]; - _oldVNodes = oldRest$2; - _idx = idx + 1 | 0; - continue ; - } - } else { - var child$1 = Caml_array.caml_array_get(elems, idx); - elem.removeChild(child$1); - _newVNodes = /* [] */0; - _oldVNodes = oldRest$2; - continue ; - } - } else if (newVNodes) { - var newChild$3 = patchVNodesOnElems_CreateElement(callbacks, newVNodes[0]); - elem.appendChild(newChild$3); - _newVNodes = newVNodes[1]; - _oldVNodes = /* [] */0; - _idx = idx + 1 | 0; - continue ; - } else { - return /* () */0; - } - }; -} - -function patchVNodesIntoElement(callbacks, elem, oldVNodes, newVNodes) { - var elems = elem.childNodes; - patchVNodesOnElems(callbacks, elem, elems, 0, oldVNodes, newVNodes); - return newVNodes; -} - -function patchVNodeIntoElement(callbacks, elem, oldVNode, newVNode) { - return patchVNodesIntoElement(callbacks, elem, /* :: */[ - oldVNode, - /* [] */0 - ], /* :: */[ - newVNode, - /* [] */0 - ]); -} - -function wrapCallbacks_On(func, param) { - if (typeof param === "number") { - return /* Render */0; - } else if (param.tag) { - return /* RemoveRenderMsg */Block.__(1, [Curry._1(func, param[0])]); - } else { - return /* AddRenderMsg */Block.__(0, [Curry._1(func, param[0])]); - } -} - -function wrapCallbacks(func, callbacks) { - return { - contents: { - enqueue: (function (msg) { - return Curry._1(callbacks.contents.enqueue, Curry._1(func, msg)); - }), - on: (function (smsg) { - return Curry._1(callbacks.contents.on, wrapCallbacks_On(func, smsg)); - }) - } - }; -} - -function map(func, vdom) { - var tagger = function (param) { - return wrapCallbacks(func, param); - }; - return /* Tagger */Block.__(4, [ - tagger, - vdom - ]); -} - -var noProp = /* NoProp */0; - -exports.noNode = noNode; -exports.comment = comment; -exports.text = text; -exports.fullnode = fullnode; -exports.node = node; -exports.lazyGen = lazyGen; -exports.noProp = noProp; -exports.prop = prop; -exports.onCB = onCB; -exports.onMsg = onMsg; -exports.attribute = attribute; -exports.data = data; -exports.style = style; -exports.styles = styles; -exports.renderToHtmlString = renderToHtmlString; -exports.emptyEventHandler = emptyEventHandler; -exports.emptyEventCB = emptyEventCB; -exports.eventHandler = eventHandler; -exports.eventHandler_GetCB = eventHandler_GetCB; -exports.compareEventHandlerTypes = compareEventHandlerTypes; -exports.eventHandler_Register = eventHandler_Register; -exports.eventHandler_Unregister = eventHandler_Unregister; -exports.eventHandler_Mutate = eventHandler_Mutate; -exports.patchVNodesOnElems_PropertiesApply_Add = patchVNodesOnElems_PropertiesApply_Add; -exports.patchVNodesOnElems_PropertiesApply_Remove = patchVNodesOnElems_PropertiesApply_Remove; -exports.patchVNodesOnElems_PropertiesApply_RemoveAdd = patchVNodesOnElems_PropertiesApply_RemoveAdd; -exports.patchVNodesOnElems_PropertiesApply_Mutate = patchVNodesOnElems_PropertiesApply_Mutate; -exports.patchVNodesOnElems_PropertiesApply = patchVNodesOnElems_PropertiesApply; -exports.patchVNodesOnElems_Properties = patchVNodesOnElems_Properties; -exports.genEmptyProps = genEmptyProps; -exports.mapEmptyProps = mapEmptyProps; -exports.patchVNodesOnElems_ReplaceNode = patchVNodesOnElems_ReplaceNode; -exports.patchVNodesOnElems_CreateElement = patchVNodesOnElems_CreateElement; -exports.patchVNodesOnElems_MutateNode = patchVNodesOnElems_MutateNode; -exports.patchVNodesOnElems = patchVNodesOnElems; -exports.patchVNodesIntoElement = patchVNodesIntoElement; -exports.patchVNodeIntoElement = patchVNodeIntoElement; -exports.wrapCallbacks_On = wrapCallbacks_On; -exports.wrapCallbacks = wrapCallbacks; -exports.map = map; -/* No side effect */ - -},{"./web_document.js":16,"./web_node.js":20,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_array.js":39,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_obj.js":49,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61,"bs-platform/lib/js/string.js":64}],15:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Web_node = require("./web_node.js"); -var Web_window = require("./web_window.js"); - -function polyfills(param) { - Web_node.remove_polyfill(/* () */0); - Web_window.requestAnimationFrame_polyfill(/* () */0); - return /* () */0; -} - -var $$Event = /* alias */0; - -var $$Node = /* alias */0; - -var $$Document = /* alias */0; - -var $$Date = /* alias */0; - -var $$Window = /* alias */0; - -var $$Location = /* alias */0; - -var Json = /* alias */0; - -var $$XMLHttpRequest = /* alias */0; - -var $$FormData = /* alias */0; - -exports.$$Event = $$Event; -exports.$$Node = $$Node; -exports.$$Document = $$Document; -exports.$$Date = $$Date; -exports.$$Window = $$Window; -exports.$$Location = $$Location; -exports.Json = Json; -exports.$$XMLHttpRequest = $$XMLHttpRequest; -exports.$$FormData = $$FormData; -exports.polyfills = polyfills; -/* No side effect */ - -},{"./web_node.js":20,"./web_window.js":21}],16:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function body(param) { - return document.body; -} - -function createElement(typ) { - return document.createElement(typ); -} - -function createElementNS(namespace, key) { - return document.createElementNS(namespace, key); -} - -function createComment(text) { - return document.createComment(text); -} - -function createTextNode(text) { - return document.createTextNode(text); -} - -function getElementById(id) { - return document.getElementById(id); -} - -function createElementNsOptional(namespace, tagName) { - if (namespace === "") { - return document.createElement(tagName); - } else { - return document.createElementNS(namespace, tagName); - } -} - -function $$location(param) { - return document.location; -} - -exports.body = body; -exports.createElement = createElement; -exports.createElementNS = createElementNS; -exports.createComment = createComment; -exports.createTextNode = createTextNode; -exports.getElementById = getElementById; -exports.createElementNsOptional = createElementNsOptional; -exports.$$location = $$location; -/* No side effect */ - -},{}],17:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function append(key, value, f) { - return f.append(key, value); -} - -exports.append = append; -/* No side effect */ - -},{}],18:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Js_json = require("bs-platform/lib/js/js_json.js"); - -function string_of_json($staropt$star, value) { - var indent = $staropt$star !== undefined ? $staropt$star : 2; - if (value !== undefined) { - try { - return JSON.stringify(value, null, indent); - } - catch (exn){ - return ""; - } - } else { - return "undefined"; - } -} - -function of_type(_v, x) { - return x; -} - -var classify = Js_json.classify; - -var test = Js_json.test; - -var decodeString = Js_json.decodeString; - -var decodeNumber = Js_json.decodeNumber; - -var decodeObject = Js_json.decodeObject; - -var decodeArray = Js_json.decodeArray; - -var decodeBoolean = Js_json.decodeBoolean; - -var decodeNull = Js_json.decodeNull; - -var $$null = null; - -exports.classify = classify; -exports.test = test; -exports.decodeString = decodeString; -exports.decodeNumber = decodeNumber; -exports.decodeObject = decodeObject; -exports.decodeArray = decodeArray; -exports.decodeBoolean = decodeBoolean; -exports.decodeNull = decodeNull; -exports.string_of_json = string_of_json; -exports.of_type = of_type; -exports.$$null = $$null; -/* No side effect */ - -},{"bs-platform/lib/js/js_json.js":60}],19:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function getHref($$location) { - return $$location.href; -} - -function setHref($$location, value) { - $$location.href = value; - return /* () */0; -} - -function getProtocol($$location) { - return $$location.protocol; -} - -function setProtocol($$location, value) { - $$location.protocol = value; - return /* () */0; -} - -function getHost($$location) { - return $$location.host; -} - -function setHost($$location, value) { - $$location.host = value; - return /* () */0; -} - -function getHostname($$location) { - return $$location.hostname; -} - -function setHostname($$location, value) { - $$location.hostname = value; - return /* () */0; -} - -function getPort($$location) { - return $$location.port; -} - -function setPort($$location, value) { - $$location.port = value; - return /* () */0; -} - -function getPathname($$location) { - return $$location.pathname; -} - -function setPathname($$location, value) { - $$location.pathname = value; - return /* () */0; -} - -function getSearch($$location) { - return $$location.search; -} - -function setSearch($$location, value) { - $$location.search = value; - return /* () */0; -} - -function getHash($$location) { - return $$location.hash; -} - -function setHash($$location, value) { - $$location.hash = value; - return /* () */0; -} - -function getUsername($$location) { - return $$location.username; -} - -function setUsername($$location, value) { - $$location.username = value; - return /* () */0; -} - -function getPassword($$location) { - return $$location.password; -} - -function setPassword($$location, value) { - $$location.password = value; - return /* () */0; -} - -function getOrigin($$location) { - return $$location.origin; -} - -function asRecord($$location) { - return { - href: $$location.href, - protocol: $$location.protocol, - host: $$location.host, - hostname: $$location.hostname, - port: $$location.port, - pathname: $$location.pathname, - search: $$location.search, - hash: $$location.hash, - username: $$location.username, - password: $$location.password, - origin: $$location.origin - }; -} - -exports.getHref = getHref; -exports.setHref = setHref; -exports.getProtocol = getProtocol; -exports.setProtocol = setProtocol; -exports.getHost = getHost; -exports.setHost = setHost; -exports.getHostname = getHostname; -exports.setHostname = setHostname; -exports.getPort = getPort; -exports.setPort = setPort; -exports.getPathname = getPathname; -exports.setPathname = setPathname; -exports.getSearch = getSearch; -exports.setSearch = setSearch; -exports.getHash = getHash; -exports.setHash = setHash; -exports.getUsername = getUsername; -exports.setUsername = setUsername; -exports.getPassword = getPassword; -exports.setPassword = setPassword; -exports.getOrigin = getOrigin; -exports.asRecord = asRecord; -/* No side effect */ - -},{}],20:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function style(n) { - return n.style; -} - -function getStyle(n, key) { - return n.style[key]; -} - -function setStyle(n, key, value) { - n.style[key] = value; - return /* () */0; -} - -function setStyleProperty(n, $staropt$star, key, value) { - var priority = $staropt$star !== undefined ? $staropt$star : false; - var style = n.style; - var match = style.setProperty; - if (match !== undefined) { - return style.setProperty(key, value, priority ? "important" : null); - } else { - return setStyle(n, key, value); - } -} - -function childNodes(n) { - return n.childNodes; -} - -function firstChild(n) { - return n.firstChild; -} - -function appendChild(n, child) { - return n.appendChild(child); -} - -function removeChild(n, child) { - return n.removeChild(child); -} - -function insertBefore(n, child, refNode) { - return n.insertBefore(child, refNode); -} - -function remove(n, child) { - return n.remove(child); -} - -function setAttributeNS(n, namespace, key, value) { - return n.setAttributeNS(namespace, key, value); -} - -function setAttribute(n, key, value) { - return n.setAttribute(key, value); -} - -function setAttributeNsOptional(n, namespace, key, value) { - if (namespace === "") { - return n.setAttribute(key, value); - } else { - return n.setAttributeNS(namespace, key, value); - } -} - -function removeAttributeNS(n, namespace, key) { - return n.removeAttributeNS(namespace, key); -} - -function removeAttribute(n, key) { - return n.removeAttribute(key); -} - -function removeAttributeNsOptional(n, namespace, key) { - if (namespace === "") { - return n.removeAttribute(key); - } else { - return n.removeAttributeNS(namespace, key); - } -} - -function addEventListener(n, typ, listener, options) { - return n.addEventListener(typ, listener, options); -} - -function removeEventListener(n, typ, listener, options) { - return n.removeEventListener(typ, listener, options); -} - -function focus(n) { - return n.focus(); -} - -function set_nodeValue(n, text) { - n.nodeValue = text; - return /* () */0; -} - -function get_nodeValue(n) { - return n.nodeValue; -} - -function remove_polyfill(param) { - return (// remove polyfill - (function() { - if (!('remove' in Element.prototype)) { - Element.prototype.remove = function() { - if (this.parentNode) { - this.parentNode.removeChild(this); - } - }; - }; - }())); -} - -exports.style = style; -exports.getStyle = getStyle; -exports.setStyle = setStyle; -exports.setStyleProperty = setStyleProperty; -exports.childNodes = childNodes; -exports.firstChild = firstChild; -exports.appendChild = appendChild; -exports.removeChild = removeChild; -exports.insertBefore = insertBefore; -exports.remove = remove; -exports.setAttributeNS = setAttributeNS; -exports.setAttribute = setAttribute; -exports.setAttributeNsOptional = setAttributeNsOptional; -exports.removeAttributeNS = removeAttributeNS; -exports.removeAttribute = removeAttribute; -exports.removeAttributeNsOptional = removeAttributeNsOptional; -exports.addEventListener = addEventListener; -exports.removeEventListener = removeEventListener; -exports.focus = focus; -exports.set_nodeValue = set_nodeValue; -exports.get_nodeValue = get_nodeValue; -exports.remove_polyfill = remove_polyfill; -/* No side effect */ - -},{}],21:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function history(param) { - return window.history; -} - -function localStorage(param) { - return window.localStorage; -} - -function $$location(param) { - return window.location; -} - -function requestAnimationFrame(callback) { - return window.requestAnimationFrame(callback); -} - -function cancelAnimationFrame(id) { - return window.cancelAnimationFrame(id); -} - -function $$clearTimeout(id) { - return window.clearTimeout(id); -} - -function $$setInterval(cb, msTime) { - return window.setInterval(cb, msTime); -} - -function $$setTimeout(cb, msTime) { - return window.setTimeout(cb, msTime); -} - -function addEventListener(typ, listener, options) { - return window.addEventListener(typ, listener, options); -} - -function removeEventListener(typ, listener, options) { - return window.removeEventListener(typ, listener, options); -} - -function requestAnimationFrame_polyfill(param) { - return (// requestAnimationFrame polyfill - (function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] - || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - }())); -} - -var $$History = /* alias */0; - -var LocalStorage = /* alias */0; - -exports.$$History = $$History; -exports.LocalStorage = LocalStorage; -exports.history = history; -exports.localStorage = localStorage; -exports.$$location = $$location; -exports.requestAnimationFrame = requestAnimationFrame; -exports.cancelAnimationFrame = cancelAnimationFrame; -exports.$$clearTimeout = $$clearTimeout; -exports.$$setInterval = $$setInterval; -exports.$$setTimeout = $$setTimeout; -exports.addEventListener = addEventListener; -exports.removeEventListener = removeEventListener; -exports.requestAnimationFrame_polyfill = requestAnimationFrame_polyfill; -/* No side effect */ - -},{}],22:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -function length($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.length; - } else { - return -1; - } -} - -function back($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.back; - } else { - return /* () */0; - } -} - -function forward($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.forward; - } else { - return /* () */0; - } -} - -function go($$window, to$prime) { - var match = $$window.history; - if (match !== undefined) { - return match.go(to$prime); - } else { - return /* () */0; - } -} - -function pushState($$window, state, title, url) { - var match = $$window.history; - if (match !== undefined) { - return match.pushState(state, title, url); - } else { - return /* () */0; - } -} - -function replaceState($$window, state, title, url) { - var match = $$window.history; - if (match !== undefined) { - return match.replaceState(state, title, url); - } else { - return /* () */0; - } -} - -function state($$window) { - var match = $$window.history; - if (match !== undefined) { - return match.state; - } - -} - -exports.length = length; -exports.back = back; -exports.forward = forward; -exports.go = go; -exports.pushState = pushState; -exports.replaceState = replaceState; -exports.state = state; -/* No side effect */ - -},{}],23:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function length($$window) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.length); - } - -} - -function clear($$window) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.clear()); - } - -} - -function key($$window, idx) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.key(idx)); - } - -} - -function getItem($$window, key) { - var match = $$window.localStorage; - if (match !== undefined) { - try { - return Caml_option.some(match.getItem(key)); - } - catch (exn){ - return ; - } - } - -} - -function removeItem($$window, key) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.removeItem(key)); - } - -} - -function setItem($$window, key, value) { - var match = $$window.localStorage; - if (match !== undefined) { - return Caml_option.some(match.setItem(key, value)); - } - -} - -exports.length = length; -exports.clear = clear; -exports.key = key; -exports.getItem = getItem; -exports.removeItem = removeItem; -exports.setItem = setItem; -/* No side effect */ - -},{"bs-platform/lib/js/caml_option.js":50}],24:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var $$Array = require("bs-platform/lib/js/array.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); -var Web_formdata = require("./web_formdata.js"); -var Caml_primitive = require("bs-platform/lib/js/caml_primitive.js"); -var Caml_builtin_exceptions = require("bs-platform/lib/js/caml_builtin_exceptions.js"); - -function abort(x) { - return x.abort(); -} - -function getAllResponseHeaders(x) { - var match = x.getAllResponseHeaders(); - if (match !== null) { - if (match === "") { - return /* Error */Block.__(1, [/* NetworkError */1]); - } else { - return /* Ok */Block.__(0, [match]); - } - } else { - return /* Error */Block.__(1, [/* IncompleteResponse */0]); - } -} - -function getAllResponseHeadersAsList(x) { - var err = getAllResponseHeaders(x); - if (err.tag) { - return err; - } else { - return /* Ok */Block.__(0, [List.map((function (param) { - if (param.length !== 2) { - throw [ - Caml_builtin_exceptions.failure, - "Cannot happen, already checked length" - ]; - } - var key = param[0]; - var value = param[1]; - return /* tuple */[ - key, - value - ]; - }), List.filter((function (a) { - return a.length === 2; - }))($$Array.to_list($$Array.map((function (param) { - return param.split(": ", 2); - }), err[0].split("\r\n")))))]); - } -} - -function getAllResponseHeadersAsDict(x) { - var height = function (param) { - if (param) { - return param[/* h */4]; - } else { - return 0; - } - }; - var create = function (l, x, d, r) { - var hl = height(l); - var hr = height(r); - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - }; - var singleton = function (x, d) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */d, - /* r : Empty */0, - /* h */1 - ]; - }; - var bal = function (l, x, d, r) { - var hl = l ? l[/* h */4] : 0; - var hr = r ? r[/* h */4] : 0; - if (hl > (hr + 2 | 0)) { - if (l) { - var lr = l[/* r */3]; - var ld = l[/* d */2]; - var lv = l[/* v */1]; - var ll = l[/* l */0]; - if (height(ll) >= height(lr)) { - return create(ll, lv, ld, create(lr, x, d, r)); - } else if (lr) { - return create(create(ll, lv, ld, lr[/* l */0]), lr[/* v */1], lr[/* d */2], create(lr[/* r */3], x, d, r)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else if (hr > (hl + 2 | 0)) { - if (r) { - var rr = r[/* r */3]; - var rd = r[/* d */2]; - var rv = r[/* v */1]; - var rl = r[/* l */0]; - if (height(rr) >= height(rl)) { - return create(create(l, x, d, rl), rv, rd, rr); - } else if (rl) { - return create(create(l, x, d, rl[/* l */0]), rl[/* v */1], rl[/* d */2], create(rl[/* r */3], rv, rd, rr)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.bal" - ]; - } - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */d, - /* r */r, - /* h */hl >= hr ? hl + 1 | 0 : hr + 1 | 0 - ]; - } - }; - var add = function (x, data, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else if (c < 0) { - var ll = add(x, data, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = add(x, data, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */data, - /* r : Empty */0, - /* h */1 - ]; - } - }; - var min_binding = function (_param) { - while(true) { - var param = _param; - if (param) { - var l = param[/* l */0]; - if (l) { - _param = l; - continue ; - } else { - return /* tuple */[ - param[/* v */1], - param[/* d */2] - ]; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; - }; - var remove_min_binding = function (param) { - if (param) { - var l = param[/* l */0]; - if (l) { - return bal(remove_min_binding(l), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return param[/* r */3]; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Map.remove_min_elt" - ]; - } - }; - var merge = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return bal(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var remove = function (x, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return merge(l, r); - } else if (c < 0) { - var ll = remove(x, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = remove(x, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - return /* Empty */0; - } - }; - var update = function (x, f, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - var match = Curry._1(f, Caml_option.some(d)); - if (match !== undefined) { - var data = Caml_option.valFromOption(match); - if (d === data) { - return m; - } else { - return /* Node */[ - /* l */l, - /* v */x, - /* d */data, - /* r */r, - /* h */m[/* h */4] - ]; - } - } else { - return merge(l, r); - } - } else if (c < 0) { - var ll = update(x, f, l); - if (l === ll) { - return m; - } else { - return bal(ll, v, d, r); - } - } else { - var rr = update(x, f, r); - if (r === rr) { - return m; - } else { - return bal(l, v, d, rr); - } - } - } else { - var match$1 = Curry._1(f, undefined); - if (match$1 !== undefined) { - return /* Node */[ - /* l : Empty */0, - /* v */x, - /* d */Caml_option.valFromOption(match$1), - /* r : Empty */0, - /* h */1 - ]; - } else { - return /* Empty */0; - } - } - }; - var iter = function (f, _param) { - while(true) { - var param = _param; - if (param) { - iter(f, param[/* l */0]); - Curry._2(f, param[/* v */1], param[/* d */2]); - _param = param[/* r */3]; - continue ; - } else { - return /* () */0; - } - }; - }; - var map = function (f, param) { - if (param) { - var l$prime = map(f, param[/* l */0]); - var d$prime = Curry._1(f, param[/* d */2]); - var r$prime = map(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */param[/* v */1], - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var mapi = function (f, param) { - if (param) { - var v = param[/* v */1]; - var l$prime = mapi(f, param[/* l */0]); - var d$prime = Curry._2(f, v, param[/* d */2]); - var r$prime = mapi(f, param[/* r */3]); - return /* Node */[ - /* l */l$prime, - /* v */v, - /* d */d$prime, - /* r */r$prime, - /* h */param[/* h */4] - ]; - } else { - return /* Empty */0; - } - }; - var fold = function (f, _m, _accu) { - while(true) { - var accu = _accu; - var m = _m; - if (m) { - _accu = Curry._3(f, m[/* v */1], m[/* d */2], fold(f, m[/* l */0], accu)); - _m = m[/* r */3]; - continue ; - } else { - return accu; - } - }; - }; - var for_all = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) && for_all(p, param[/* l */0])) { - _param = param[/* r */3]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; - }; - var exists = function (p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._2(p, param[/* v */1], param[/* d */2]) || exists(p, param[/* l */0])) { - return true; - } else { - _param = param[/* r */3]; - continue ; - } - } else { - return false; - } - }; - }; - var add_min_binding = function (k, x, param) { - if (param) { - return bal(add_min_binding(k, x, param[/* l */0]), param[/* v */1], param[/* d */2], param[/* r */3]); - } else { - return singleton(k, x); - } - }; - var add_max_binding = function (k, x, param) { - if (param) { - return bal(param[/* l */0], param[/* v */1], param[/* d */2], add_max_binding(k, x, param[/* r */3])); - } else { - return singleton(k, x); - } - }; - var join = function (l, v, d, r) { - if (l) { - if (r) { - var rh = r[/* h */4]; - var lh = l[/* h */4]; - if (lh > (rh + 2 | 0)) { - return bal(l[/* l */0], l[/* v */1], l[/* d */2], join(l[/* r */3], v, d, r)); - } else if (rh > (lh + 2 | 0)) { - return bal(join(l, v, d, r[/* l */0]), r[/* v */1], r[/* d */2], r[/* r */3]); - } else { - return create(l, v, d, r); - } - } else { - return add_max_binding(v, d, l); - } - } else { - return add_min_binding(v, d, r); - } - }; - var concat = function (t1, t2) { - if (t1) { - if (t2) { - var match = min_binding(t2); - return join(t1, match[0], match[1], remove_min_binding(t2)); - } else { - return t1; - } - } else { - return t2; - } - }; - var concat_or_join = function (t1, v, d, t2) { - if (d !== undefined) { - return join(t1, v, Caml_option.valFromOption(d), t2); - } else { - return concat(t1, t2); - } - }; - var split = function (x, param) { - if (param) { - var r = param[/* r */3]; - var d = param[/* d */2]; - var v = param[/* v */1]; - var l = param[/* l */0]; - var c = Caml_primitive.caml_string_compare(x, v); - if (c === 0) { - return /* tuple */[ - l, - Caml_option.some(d), - r - ]; - } else if (c < 0) { - var match = split(x, l); - return /* tuple */[ - match[0], - match[1], - join(match[2], v, d, r) - ]; - } else { - var match$1 = split(x, r); - return /* tuple */[ - join(l, v, d, match$1[0]), - match$1[1], - match$1[2] - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - undefined, - /* Empty */0 - ]; - } - }; - var merge$1 = function (f, s1, s2) { - if (s1) { - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= height(s2)) { - var match = split(v1, s2); - return concat_or_join(merge$1(f, s1[/* l */0], match[0]), v1, Curry._3(f, v1, Caml_option.some(s1[/* d */2]), match[1]), merge$1(f, s1[/* r */3], match[2])); - } - - } else if (!s2) { - return /* Empty */0; - } - if (s2) { - var v2 = s2[/* v */1]; - var match$1 = split(v2, s1); - return concat_or_join(merge$1(f, match$1[0], s2[/* l */0]), v2, Curry._3(f, v2, match$1[1], Caml_option.some(s2[/* d */2])), merge$1(f, match$1[2], s2[/* r */3])); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "map.ml", - 393, - 10 - ] - ]; - } - }; - var union = function (f, s1, s2) { - if (s1) { - if (s2) { - var d2 = s2[/* d */2]; - var v2 = s2[/* v */1]; - var d1 = s1[/* d */2]; - var v1 = s1[/* v */1]; - if (s1[/* h */4] >= s2[/* h */4]) { - var match = split(v1, s2); - var d2$1 = match[1]; - var l = union(f, s1[/* l */0], match[0]); - var r = union(f, s1[/* r */3], match[2]); - if (d2$1 !== undefined) { - return concat_or_join(l, v1, Curry._3(f, v1, d1, Caml_option.valFromOption(d2$1)), r); - } else { - return join(l, v1, d1, r); - } - } else { - var match$1 = split(v2, s1); - var d1$1 = match$1[1]; - var l$1 = union(f, match$1[0], s2[/* l */0]); - var r$1 = union(f, match$1[2], s2[/* r */3]); - if (d1$1 !== undefined) { - return concat_or_join(l$1, v2, Curry._3(f, v2, Caml_option.valFromOption(d1$1), d2), r$1); - } else { - return join(l$1, v2, d2, r$1); - } - } - } else { - return s1; - } - } else { - return s2; - } - }; - var filter = function (p, m) { - if (m) { - var r = m[/* r */3]; - var d = m[/* d */2]; - var v = m[/* v */1]; - var l = m[/* l */0]; - var l$prime = filter(p, l); - var pvd = Curry._2(p, v, d); - var r$prime = filter(p, r); - if (pvd) { - if (l === l$prime && r === r$prime) { - return m; - } else { - return join(l$prime, v, d, r$prime); - } - } else { - return concat(l$prime, r$prime); - } - } else { - return /* Empty */0; - } - }; - var partition = function (p, param) { - if (param) { - var d = param[/* d */2]; - var v = param[/* v */1]; - var match = partition(p, param[/* l */0]); - var lf = match[1]; - var lt = match[0]; - var pvd = Curry._2(p, v, d); - var match$1 = partition(p, param[/* r */3]); - var rf = match$1[1]; - var rt = match$1[0]; - if (pvd) { - return /* tuple */[ - join(lt, v, d, rt), - concat(lf, rf) - ]; - } else { - return /* tuple */[ - concat(lt, rt), - join(lf, v, d, rf) - ]; - } - } else { - return /* tuple */[ - /* Empty */0, - /* Empty */0 - ]; - } - }; - var cardinal = function (param) { - if (param) { - return (cardinal(param[/* l */0]) + 1 | 0) + cardinal(param[/* r */3]) | 0; - } else { - return 0; - } - }; - var bindings_aux = function (_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[/* l */0]; - _accu = /* :: */[ - /* tuple */[ - param[/* v */1], - param[/* d */2] - ], - bindings_aux(accu, param[/* r */3]) - ]; - continue ; - } else { - return accu; - } - }; - }; - var err = getAllResponseHeadersAsList(x); - if (err.tag) { - return err; - } else { - var insert = function (d, param) { - return add(param[0], param[1], d); - }; - return /* Ok */Block.__(0, [List.fold_left(insert, /* Empty */0, err[0])]); - } -} - -function getResponseHeader(key, x) { - return Caml_option.null_to_opt(x.getResponse(key)); -} - -function open_(method$prime, url, $staropt$star, $staropt$star$1, $staropt$star$2, x) { - var async = $staropt$star !== undefined ? $staropt$star : true; - var user = $staropt$star$1 !== undefined ? $staropt$star$1 : ""; - var password = $staropt$star$2 !== undefined ? $staropt$star$2 : ""; - return x.open(method$prime, url, async, user, password); -} - -function overrideMimeType(mimetype, x) { - return x.overrideMimeType(mimetype); -} - -function send(body, x) { - if (typeof body === "number") { - if (body === /* EmptyBody */0) { - return x.send(); - } else { - return x.send(null); - } - } else { - switch (body.tag | 0) { - case /* FormListBody */2 : - var form = List.fold_left((function (f, param) { - Web_formdata.append(param[0], param[1], f); - return f; - }), new FormData(), body[0]); - return x.send(form); - case /* StringBody */0 : - case /* FormDataBody */1 : - case /* DocumentBody */3 : - return x.send(body[0]); - - } - } -} - -function setRequestHeader(header, value, x) { - return x.setRequestHeader(header, value); -} - -function set_onreadystatechange(cb, x) { - x.onreadystatechange = cb; - return /* () */0; -} - -function get_onreadystatechange(x) { - return x.onreadystatechange; -} - -function readyState(x) { - var i = x.readyState; - if (i > 4 || i < 0) { - var s = "Invalid return from 'readystate' of: " + String(i); - throw [ - Caml_builtin_exceptions.failure, - s - ]; - } else { - return i; - } -} - -function set_responseType(typ, x) { - if (typeof typ === "number") { - switch (typ) { - case /* StringResponseType */0 : - x.responseType = ""; - return /* () */0; - case /* ArrayBufferResponseType */1 : - x.responseType = "arraybuffer"; - return /* () */0; - case /* BlobResponseType */2 : - x.responseType = "blob"; - return /* () */0; - case /* DocumentResponseType */3 : - x.responseType = "document"; - return /* () */0; - case /* JsonResponseType */4 : - x.responseType = "json"; - return /* () */0; - case /* TextResponseType */5 : - x.responseType = "text"; - return /* () */0; - - } - } else { - x.responseType = typ[0]; - return /* () */0; - } -} - -function get_responseType(x) { - var s = x.responseType; - switch (s) { - case "" : - return /* StringResponseType */0; - case "arraybuffer" : - return /* ArrayBufferResponseType */1; - case "blob" : - return /* BlobResponseType */2; - case "document" : - return /* DocumentResponseType */3; - case "json" : - return /* JsonResponseType */4; - case "text" : - return /* TextResponseType */5; - default: - return /* RawResponseType */[s]; - } -} - -function get_response(x) { - var match = x.response; - if (match !== null) { - var match$1 = get_responseType(x); - if (typeof match$1 === "number") { - switch (match$1) { - case /* StringResponseType */0 : - return /* StringResponse */Block.__(0, [match]); - case /* ArrayBufferResponseType */1 : - return /* ArrayBufferResponse */Block.__(1, [match]); - case /* BlobResponseType */2 : - return /* BlobResponse */Block.__(2, [match]); - case /* DocumentResponseType */3 : - return /* DocumentResponse */Block.__(3, [match]); - case /* JsonResponseType */4 : - return /* JsonResponse */Block.__(4, [match]); - case /* TextResponseType */5 : - return /* TextResponse */Block.__(5, [match]); - - } - } else { - return /* RawResponse */Block.__(6, [ - match$1[0], - match - ]); - } - } else { - return /* NoResponse */0; - } -} - -function get_responseText(x) { - return x.responseText; -} - -function get_responseURL(x) { - return x.responseURL; -} - -function get_responseXML(x) { - return Caml_option.null_to_opt(x.responseXML); -} - -function get_status(x) { - return x.status; -} - -function get_statusText(x) { - return x.statusText; -} - -function set_timeout(t, x) { - x.timeout = t; - return /* () */0; -} - -function get_timeout(x) { - return x.timeout; -} - -function set_withCredentials(b, x) { - x.withCredentials = b; - return /* () */0; -} - -function get_withCredentials(x) { - return x.withCredentials; -} - -function set_onabort(cb, x) { - x.onabort = cb; - return /* () */0; -} - -function get_onabort(x) { - return x.onabort; -} - -function set_onerror(cb, x) { - x.onerror = cb; - return /* () */0; -} - -function get_onerror(x) { - return x.onerror; -} - -function set_onload(cb, x) { - x.onload = cb; - return /* () */0; -} - -function get_onload(x) { - return x.onload; -} - -function set_onloadstart(cb, x) { - x.onloadstart = cb; - return /* () */0; -} - -function get_onloadstart(x) { - return x.onloadstart; -} - -function set_onprogress(cb, x) { - x.onprogress = cb; - return /* () */0; -} - -function get_onprogress(x) { - return x.onprogress; -} - -function set_ontimeout(cb, x) { - x.ontimeout = cb; - return /* () */0; -} - -function get_ontimeout(x) { - return x.ontimeout; -} - -function set_onloadend(cb, x) { - x.onloadend = cb; - return /* () */0; -} - -function get_onloadend(x) { - return x.onloadend; -} - -exports.abort = abort; -exports.getAllResponseHeaders = getAllResponseHeaders; -exports.getAllResponseHeadersAsList = getAllResponseHeadersAsList; -exports.getAllResponseHeadersAsDict = getAllResponseHeadersAsDict; -exports.getResponseHeader = getResponseHeader; -exports.open_ = open_; -exports.overrideMimeType = overrideMimeType; -exports.send = send; -exports.setRequestHeader = setRequestHeader; -exports.set_onreadystatechange = set_onreadystatechange; -exports.get_onreadystatechange = get_onreadystatechange; -exports.readyState = readyState; -exports.set_responseType = set_responseType; -exports.get_responseType = get_responseType; -exports.get_response = get_response; -exports.get_responseText = get_responseText; -exports.get_responseURL = get_responseURL; -exports.get_responseXML = get_responseXML; -exports.get_status = get_status; -exports.get_statusText = get_statusText; -exports.set_timeout = set_timeout; -exports.get_timeout = get_timeout; -exports.set_withCredentials = set_withCredentials; -exports.get_withCredentials = get_withCredentials; -exports.set_onabort = set_onabort; -exports.get_onabort = get_onabort; -exports.set_onerror = set_onerror; -exports.get_onerror = get_onerror; -exports.set_onload = set_onload; -exports.get_onload = get_onload; -exports.set_onloadstart = set_onloadstart; -exports.get_onloadstart = get_onloadstart; -exports.set_onprogress = set_onprogress; -exports.get_onprogress = get_onprogress; -exports.set_ontimeout = set_ontimeout; -exports.get_ontimeout = get_ontimeout; -exports.set_onloadend = set_onloadend; -exports.get_onloadend = get_onloadend; -/* No side effect */ - -},{"./web_formdata.js":17,"bs-platform/lib/js/array.js":35,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_builtin_exceptions.js":40,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/caml_primitive.js":51,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],25:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Test_client_drag = require("./test_client_drag.js"); -var Test_client_counter = require("./test_client_counter.js"); -var Test_client_http_task = require("./test_client_http_task.js"); -var Test_client_btn_update_span = require("./test_client_btn_update_span.js"); -var Test_client_on_with_options = require("./test_client_on_with_options.js"); -var Test_client_attribute_removal = require("./test_client_attribute_removal.js"); -var Test_client_counter_debug_program = require("./test_client_counter_debug_program.js"); -var Test_client_counter_debug_beginner = require("./test_client_counter_debug_beginner.js"); -var Test_client_counter_debug_standard = require("./test_client_counter_debug_standard.js"); - -var counter = Test_client_counter.main; - -var counter_debug_beginner = Test_client_counter_debug_beginner.main; - -var counter_debug_standard = Test_client_counter_debug_standard.main; - -var counter_debug_program = Test_client_counter_debug_program.main; - -var btn_update_span = Test_client_btn_update_span.main; - -var attribute_removal = Test_client_attribute_removal.main; - -var drag = Test_client_drag.main; - -var on_with_options = Test_client_on_with_options.main; - -var http_task = Test_client_http_task.main; - -exports.counter = counter; -exports.counter_debug_beginner = counter_debug_beginner; -exports.counter_debug_standard = counter_debug_standard; -exports.counter_debug_program = counter_debug_program; -exports.btn_update_span = btn_update_span; -exports.attribute_removal = attribute_removal; -exports.drag = drag; -exports.on_with_options = on_with_options; -exports.http_task = http_task; -/* Test_client_drag Not a pure module */ - -},{"./test_client_attribute_removal.js":26,"./test_client_btn_update_span.js":27,"./test_client_counter.js":28,"./test_client_counter_debug_beginner.js":29,"./test_client_counter_debug_program.js":30,"./test_client_counter_debug_standard.js":31,"./test_client_drag.js":32,"./test_client_http_task.js":33,"./test_client_on_with_options.js":34}],26:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function select(param_0) { - return /* Select */[param_0]; -} - -function render_selected(param) { - if (param !== undefined) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["you selected " + param]), - /* :: */[ - Tea_html.div(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Delete */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["delete selection"]), - /* [] */0 - ]), - /* [] */0 - ] - ]); - } else { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["Nothing selected"]), - /* [] */0 - ]); - } -} - -function lang(l, is_selected) { - var msg = /* Select */[l]; - return Tea_html.li(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* :: */[ - Vdom.style("color", "blue"), - /* :: */[ - is_selected ? Vdom.style("border", "1px solid black") : Tea_html.noProp, - /* :: */[ - is_selected ? /* Attribute */Block.__(1, [ - "", - "lang", - l - ]) : Tea_html.noProp, - /* [] */0 - ] - ] - ] - ], /* :: */[ - /* Text */Block.__(1, [l]), - /* [] */0 - ]); -} - -function render_languages(selected, languages) { - var is_selected = function (selected, language) { - if (selected !== undefined) { - return language === Caml_option.valFromOption(selected); - } else { - return false; - } - }; - var rendered = List.map((function (l) { - return lang(l, is_selected(selected, l)); - }), languages); - return Tea_html.ul(undefined, undefined, /* [] */0, rendered); -} - -function update(state, param) { - if (param) { - return { - selected: param[0], - languages: state.languages - }; - } else { - return { - selected: undefined, - languages: state.languages - }; - } -} - -function view(state) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - render_selected(state.selected), - /* :: */[ - render_languages(state.selected, state.languages), - /* [] */0 - ] - ]); -} - -var partial_arg_model = { - selected: "Erlang", - languages: /* :: */[ - "Erlang", - /* :: */[ - "Ocaml", - /* :: */[ - "Clojure", - /* [] */0 - ] - ] - ] -}; - -var partial_arg = { - model: partial_arg_model, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var $$delete = /* Delete */0; - -exports.select = select; -exports.$$delete = $$delete; -exports.render_selected = render_selected; -exports.lang = lang; -exports.render_languages = render_languages; -exports.update = update; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_app.js":1,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_option.js":50,"bs-platform/lib/js/list.js":61}],27:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); - -function update$prime(model, param) { - return /* tuple */[ - model[0], - "right" - ]; -} - -function render_model(param) { - if (param[0] !== undefined && param[1] !== undefined) { - return Tea_html.input$prime(undefined, undefined, /* :: */[ - /* RawProp */Block.__(0, [ - "value", - "This should be on screen" - ]), - /* [] */0 - ], /* [] */0); - } - return Tea_html.span(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["nothing"]), - /* [] */0 - ]); -} - -function view$prime(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Trigger */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["trigger rerender"]), - /* [] */0 - ]), - /* :: */[ - render_model(model), - /* [] */0 - ] - ]); -} - -var partial_arg_model = /* tuple */[ - "left", - undefined -]; - -var partial_arg = { - model: partial_arg_model, - update: update$prime, - view: view$prime -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var trigger = /* Trigger */0; - -exports.trigger = trigger; -exports.update$prime = update$prime; -exports.render_model = render_model; -exports.view$prime = view$prime; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_app.js":1,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],28:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return model + 1 | 0; - case /* Decrement */1 : - return model - 1 | 0; - case /* Reset */2 : - return 0; - - } - } else { - return param[0]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - model: 4, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_app.js":1,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],29:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return model + 1 | 0; - case /* Decrement */1 : - return model - 1 | 0; - case /* Reset */2 : - return 0; - - } - } else { - return param[0]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - model: 4, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_debug.beginnerProgram(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_debug.js":3,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],30:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function init(param) { - return /* tuple */[ - 4, - /* NoCmd */0 - ]; -} - -function subscriptions(param) { - return /* NoSub */0; -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return /* tuple */[ - model + 1 | 0, - /* NoCmd */0 - ]; - case /* Decrement */1 : - return /* tuple */[ - model - 1 | 0, - /* NoCmd */0 - ]; - case /* Reset */2 : - return /* tuple */[ - 0, - /* NoCmd */0 - ]; - - } - } else { - return /* tuple */[ - param[0], - /* NoCmd */0 - ]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -function partial_arg_shutdown(_model) { - return /* NoCmd */0; -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions, - shutdown: partial_arg_shutdown -}; - -function main(param, param$1) { - return Tea_debug.program(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.init = init; -exports.subscriptions = subscriptions; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_debug.js":3,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],31:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function init(param) { - return /* tuple */[ - 4, - /* NoCmd */0 - ]; -} - -function subscriptions(param) { - return /* NoSub */0; -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return /* tuple */[ - model + 1 | 0, - /* NoCmd */0 - ]; - case /* Decrement */1 : - return /* tuple */[ - model - 1 | 0, - /* NoCmd */0 - ]; - case /* Reset */2 : - return /* tuple */[ - 0, - /* NoCmd */0 - ]; - - } - } else { - return /* tuple */[ - param[0], - /* NoCmd */0 - ]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions -}; - -function main(param, param$1) { - return Tea_debug.standardProgram(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.init = init; -exports.subscriptions = subscriptions; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_debug.js":3,"../src-ocaml/tea_html.js":5,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],32:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_json = require("../src-ocaml/tea_json.js"); -var Tea_mouse = require("../src-ocaml/tea_mouse.js"); -var Tea_result = require("../src-ocaml/tea_result.js"); - -function dragStart(param_0) { - return /* DragStart */Block.__(0, [param_0]); -} - -function dragAt(param_0) { - return /* DragAt */Block.__(1, [param_0]); -} - -function dragEnd(param_0) { - return /* DragEnd */Block.__(2, [param_0]); -} - -function init(param) { - return /* tuple */[ - { - position: { - x: 200, - y: 200 - }, - drag: undefined - }, - /* NoCmd */0 - ]; -} - -function getPosition(param) { - var drag = param.drag; - var position = param.position; - if (drag !== undefined) { - var match = drag; - var current = match.current; - var start = match.start; - return { - x: (position.x + current.x | 0) - start.x | 0, - y: (position.y + current.y | 0) - start.y | 0 - }; - } else { - return position; - } -} - -function updateHelp(model, param) { - var position = model.position; - switch (param.tag | 0) { - case /* DragStart */0 : - var xy = param[0]; - return { - position: position, - drag: { - start: xy, - current: xy - } - }; - case /* DragAt */1 : - var match = model.drag; - return { - position: position, - drag: match !== undefined ? ({ - start: match.start, - current: param[0] - }) : undefined - }; - case /* DragEnd */2 : - return { - position: getPosition(model), - drag: undefined - }; - - } -} - -function update(model, msg) { - return /* tuple */[ - updateHelp(model, msg), - /* NoCmd */0 - ]; -} - -function subscriptions(model) { - var match = model.drag; - if (match !== undefined) { - return /* Batch */Block.__(0, [/* :: */[ - Tea_mouse.moves(undefined, dragAt), - /* :: */[ - Tea_mouse.ups(undefined, dragEnd), - /* [] */0 - ] - ]]); - } else { - return /* NoSub */0; - } -} - -function px(number) { - return String(number) + "px"; -} - -function cb(ev) { - return Tea_result.result_to_option(Tea_json.Decoder.decodeEvent(Tea_json.Decoder.map(dragStart, Tea_mouse.position), ev)); -} - -var onMouseDown = Vdom.onCB("mousedown", "", cb); - -function view(model) { - var realPosition = getPosition(model); - return Tea_html.div(undefined, undefined, /* :: */[ - onMouseDown, - /* :: */[ - /* Style */Block.__(4, [/* :: */[ - /* tuple */[ - "background-color", - "#3C8D2F" - ], - /* :: */[ - /* tuple */[ - "cursor", - "move" - ], - /* :: */[ - /* tuple */[ - "width", - "100px" - ], - /* :: */[ - /* tuple */[ - "height", - "100px" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px" - ], - /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "left", - String(realPosition.x) + "px" - ], - /* :: */[ - /* tuple */[ - "top", - String(realPosition.y) + "px" - ], - /* :: */[ - /* tuple */[ - "color", - "white" - ], - /* :: */[ - /* tuple */[ - "display", - "flex" - ], - /* :: */[ - /* tuple */[ - "align-items", - "center" - ], - /* :: */[ - /* tuple */[ - "justify-content", - "center" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]]), - /* [] */0 - ] - ], /* :: */[ - /* Text */Block.__(1, ["Drag Me!"]), - /* [] */0 - ]); -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions -}; - -function main(param, param$1) { - return Tea_app.standardProgram(partial_arg, param, param$1); -} - -exports.dragStart = dragStart; -exports.dragAt = dragAt; -exports.dragEnd = dragEnd; -exports.init = init; -exports.getPosition = getPosition; -exports.updateHelp = updateHelp; -exports.update = update; -exports.subscriptions = subscriptions; -exports.px = px; -exports.onMouseDown = onMouseDown; -exports.view = view; -exports.main = main; -/* onMouseDown Not a pure module */ - -},{"../src-ocaml/tea_app.js":1,"../src-ocaml/tea_html.js":5,"../src-ocaml/tea_json.js":8,"../src-ocaml/tea_mouse.js":9,"../src-ocaml/tea_result.js":11,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36}],33:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_ex = require("../src-ocaml/tea_ex.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_http = require("../src-ocaml/tea_http.js"); -var Tea_task = require("../src-ocaml/tea_task.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function gotResponse(param_0) { - return /* GotResponse */[param_0]; -} - -function update(model, param) { - if (param) { - return /* tuple */[ - param[0][0], - /* NoCmd */0 - ]; - } else { - return /* tuple */[ - model, - Tea_task.attempt(gotResponse, Tea_task.andThen((function (param) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, ["both saved"])); - })]; - }), Tea_task.andThen((function (res) { - return Tea_ex.LocalStorage.setItem("todo-2", res); - }), Tea_task.andThen((function (param) { - return Tea_task.mapError(Tea_http.string_of_error, Tea_http.toTask(Tea_http.getString("https://jsonplaceholder.typicode.com/todos/2"))); - }), Tea_task.andThen((function (res) { - return Tea_ex.LocalStorage.setItem("todo-1", res); - }), Tea_task.mapError(Tea_http.string_of_error, Tea_http.toTask(Tea_http.getString("https://jsonplaceholder.typicode.com/todos/1")))))))) - ]; - } -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Req */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["execute"]), - /* [] */0 - ]), - /* :: */[ - /* Text */Block.__(1, [model]), - /* [] */0 - ] - ]); -} - -function som(param) { - if (param) { - if (param[0].tag) { - return "GotResponse Error"; - } else { - return "GotResponse Ok"; - } - } else { - return "Req"; - } -} - -function partial_arg_init(param) { - return /* tuple */[ - "nothing", - /* NoCmd */0 - ]; -} - -function partial_arg_subscriptions(param) { - return /* NoSub */0; -} - -var partial_arg = { - init: partial_arg_init, - update: update, - view: view, - subscriptions: partial_arg_subscriptions -}; - -function main(param, param$1) { - return Tea_debug.standardProgram(partial_arg, som, param, param$1); -} - -var req = /* Req */0; - -exports.gotResponse = gotResponse; -exports.req = req; -exports.update = update; -exports.view = view; -exports.som = som; -exports.main = main; -/* Tea_html Not a pure module */ - -},{"../src-ocaml/tea_debug.js":3,"../src-ocaml/tea_ex.js":4,"../src-ocaml/tea_html.js":5,"../src-ocaml/tea_http.js":7,"../src-ocaml/tea_task.js":13,"../src-ocaml/vdom.js":14,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/curry.js":58}],34:[function(require,module,exports){ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_json = require("../src-ocaml/tea_json.js"); -var Tea_html2 = require("../src-ocaml/tea_html2.js"); -var Caml_format = require("bs-platform/lib/js/caml_format.js"); - -function set_value(param_0) { - return /* Set_value */[param_0]; -} - -function update(model, param) { - if (param) { - return param[0]; - } else { - return model + 1 | 0; - } -} - -function view(model) { - var clientX = Tea_json.Decoder.field("clientX", Tea_json.Decoder.$$int); - var init = Tea_html2.Events.defaultOptions; - return Tea_html2.div(undefined, undefined, /* [] */0, List.map((function (e) { - return Tea_html2.div(undefined, undefined, /* [] */0, /* :: */[ - e, - /* [] */0 - ]); - }), /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Tea_html2.Events.onClick(/* Click */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["onClick"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Curry._3(Tea_html2.Events.on, "", "click", Tea_json.Decoder.succeed(/* Click */0)), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["on \"click\""]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.a(undefined, undefined, /* :: */[ - Tea_html2.Attributes.href("https://www.google.com"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["a normal link"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.a(undefined, undefined, /* :: */[ - Tea_html2.Attributes.href("https://www.google.com"), - /* :: */[ - Curry._4(Tea_html2.Events.onWithOptions, "", "click", { - stopPropagation: init.stopPropagation, - preventDefault: true - }, Tea_json.Decoder.succeed(/* Click */0)), - /* [] */0 - ] - ], /* :: */[ - /* Text */Block.__(1, ["a link with prevent default"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Curry._3(Tea_html2.Events.on, "", "click", Tea_json.Decoder.map(set_value, clientX)), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["on \"click\", use clientX value"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.input$prime(undefined, undefined, /* :: */[ - Tea_html2.Attributes.type$prime("text"), - /* :: */[ - Curry._3(Tea_html2.Events.on, "", "input", Tea_json.Decoder.map((function (v) { - return /* Set_value */[Caml_format.caml_int_of_string(v)]; - }), Tea_html2.Events.targetValue)), - /* [] */0 - ] - ], /* [] */0), - /* [] */0 - ] - ] - ] - ] - ] - ] - ])); -} - -var partial_arg = { - model: 0, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var click = /* Click */0; - -exports.click = click; -exports.set_value = set_value; -exports.update = update; -exports.view = view; -exports.main = main; -/* Tea_html2 Not a pure module */ - -},{"../src-ocaml/tea_app.js":1,"../src-ocaml/tea_html2.js":6,"../src-ocaml/tea_json.js":8,"bs-platform/lib/js/block.js":36,"bs-platform/lib/js/caml_format.js":44,"bs-platform/lib/js/curry.js":58,"bs-platform/lib/js/list.js":61}],35:[function(require,module,exports){ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_obj = require("./caml_obj.js"); -var Caml_array = require("./caml_array.js"); -var Caml_exceptions = require("./caml_exceptions.js"); -var Caml_js_exceptions = require("./caml_js_exceptions.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -var make_float = Caml_array.caml_make_float_vect; - -var Floatarray = { }; - -function init(l, f) { - if (l === 0) { - return []; - } else { - if (l < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.init" - ]; - } - var res = Caml_array.caml_make_vect(l, Curry._1(f, 0)); - for(var i = 1 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - res[i] = Curry._1(f, i); - } - return res; - } -} - -function make_matrix(sx, sy, init) { - var res = Caml_array.caml_make_vect(sx, []); - for(var x = 0 ,x_finish = sx - 1 | 0; x <= x_finish; ++x){ - res[x] = Caml_array.caml_make_vect(sy, init); - } - return res; -} - -function copy(a) { - var l = a.length; - if (l === 0) { - return []; - } else { - return Caml_array.caml_array_sub(a, 0, l); - } -} - -function append(a1, a2) { - var l1 = a1.length; - if (l1 === 0) { - return copy(a2); - } else if (a2.length === 0) { - return Caml_array.caml_array_sub(a1, 0, l1); - } else { - return a1.concat(a2); - } -} - -function sub(a, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.sub" - ]; - } - return Caml_array.caml_array_sub(a, ofs, len); -} - -function fill(a, ofs, len, v) { - if (ofs < 0 || len < 0 || ofs > (a.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.fill" - ]; - } - for(var i = ofs ,i_finish = (ofs + len | 0) - 1 | 0; i <= i_finish; ++i){ - a[i] = v; - } - return /* () */0; -} - -function blit(a1, ofs1, a2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (a1.length - len | 0) || ofs2 < 0 || ofs2 > (a2.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.blit" - ]; - } - return Caml_array.caml_array_blit(a1, ofs1, a2, ofs2, len); -} - -function iter(f, a) { - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - Curry._1(f, a[i]); - } - return /* () */0; -} - -function iter2(f, a, b) { - if (a.length !== b.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.iter2: arrays must have the same length" - ]; - } - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - Curry._2(f, a[i], b[i]); - } - return /* () */0; -} - -function map(f, a) { - var l = a.length; - if (l === 0) { - return []; - } else { - var r = Caml_array.caml_make_vect(l, Curry._1(f, a[0])); - for(var i = 1 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - r[i] = Curry._1(f, a[i]); - } - return r; - } -} - -function map2(f, a, b) { - var la = a.length; - var lb = b.length; - if (la !== lb) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Array.map2: arrays must have the same length" - ]; - } - if (la === 0) { - return []; - } else { - var r = Caml_array.caml_make_vect(la, Curry._2(f, a[0], b[0])); - for(var i = 1 ,i_finish = la - 1 | 0; i <= i_finish; ++i){ - r[i] = Curry._2(f, a[i], b[i]); - } - return r; - } -} - -function iteri(f, a) { - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - Curry._2(f, i, a[i]); - } - return /* () */0; -} - -function mapi(f, a) { - var l = a.length; - if (l === 0) { - return []; - } else { - var r = Caml_array.caml_make_vect(l, Curry._2(f, 0, a[0])); - for(var i = 1 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - r[i] = Curry._2(f, i, a[i]); - } - return r; - } -} - -function to_list(a) { - var _i = a.length - 1 | 0; - var _res = /* [] */0; - while(true) { - var res = _res; - var i = _i; - if (i < 0) { - return res; - } else { - _res = /* :: */[ - a[i], - res - ]; - _i = i - 1 | 0; - continue ; - } - }; -} - -function list_length(_accu, _param) { - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[1]; - _accu = accu + 1 | 0; - continue ; - } else { - return accu; - } - }; -} - -function of_list(l) { - if (l) { - var a = Caml_array.caml_make_vect(list_length(0, l), l[0]); - var _i = 1; - var _param = l[1]; - while(true) { - var param = _param; - var i = _i; - if (param) { - a[i] = param[0]; - _param = param[1]; - _i = i + 1 | 0; - continue ; - } else { - return a; - } - }; - } else { - return []; - } -} - -function fold_left(f, x, a) { - var r = x; - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - r = Curry._2(f, r, a[i]); - } - return r; -} - -function fold_right(f, a, x) { - var r = x; - for(var i = a.length - 1 | 0; i >= 0; --i){ - r = Curry._2(f, a[i], r); - } - return r; -} - -function exists(p, a) { - var n = a.length; - var _i = 0; - while(true) { - var i = _i; - if (i === n) { - return false; - } else if (Curry._1(p, a[i])) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function for_all(p, a) { - var n = a.length; - var _i = 0; - while(true) { - var i = _i; - if (i === n) { - return true; - } else if (Curry._1(p, a[i])) { - _i = i + 1 | 0; - continue ; - } else { - return false; - } - }; -} - -function mem(x, a) { - var n = a.length; - var _i = 0; - while(true) { - var i = _i; - if (i === n) { - return false; - } else if (Caml_obj.caml_equal(a[i], x)) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function memq(x, a) { - var n = a.length; - var _i = 0; - while(true) { - var i = _i; - if (i === n) { - return false; - } else if (x === a[i]) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -var Bottom = Caml_exceptions.create("Array.Bottom"); - -function sort(cmp, a) { - var maxson = function (l, i) { - var i31 = ((i + i | 0) + i | 0) + 1 | 0; - var x = i31; - if ((i31 + 2 | 0) < l) { - if (Curry._2(cmp, Caml_array.caml_array_get(a, i31), Caml_array.caml_array_get(a, i31 + 1 | 0)) < 0) { - x = i31 + 1 | 0; - } - if (Curry._2(cmp, Caml_array.caml_array_get(a, x), Caml_array.caml_array_get(a, i31 + 2 | 0)) < 0) { - x = i31 + 2 | 0; - } - return x; - } else if ((i31 + 1 | 0) < l && Curry._2(cmp, Caml_array.caml_array_get(a, i31), Caml_array.caml_array_get(a, i31 + 1 | 0)) < 0) { - return i31 + 1 | 0; - } else if (i31 < l) { - return i31; - } else { - throw [ - Bottom, - i - ]; - } - }; - var trickle = function (l, i, e) { - try { - var l$1 = l; - var _i = i; - var e$1 = e; - while(true) { - var i$1 = _i; - var j = maxson(l$1, i$1); - if (Curry._2(cmp, Caml_array.caml_array_get(a, j), e$1) > 0) { - Caml_array.caml_array_set(a, i$1, Caml_array.caml_array_get(a, j)); - _i = j; - continue ; - } else { - return Caml_array.caml_array_set(a, i$1, e$1); - } - }; - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Bottom) { - return Caml_array.caml_array_set(a, exn[1], e); - } else { - throw exn; - } - } - }; - var bubble = function (l, i) { - try { - var l$1 = l; - var _i = i; - while(true) { - var i$1 = _i; - var j = maxson(l$1, i$1); - Caml_array.caml_array_set(a, i$1, Caml_array.caml_array_get(a, j)); - _i = j; - continue ; - }; - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Bottom) { - return exn[1]; - } else { - throw exn; - } - } - }; - var trickleup = function (_i, e) { - while(true) { - var i = _i; - var father = (i - 1 | 0) / 3 | 0; - if (i === father) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "array.ml", - 238, - 4 - ] - ]; - } - if (Curry._2(cmp, Caml_array.caml_array_get(a, father), e) < 0) { - Caml_array.caml_array_set(a, i, Caml_array.caml_array_get(a, father)); - if (father > 0) { - _i = father; - continue ; - } else { - return Caml_array.caml_array_set(a, 0, e); - } - } else { - return Caml_array.caml_array_set(a, i, e); - } - }; - }; - var l = a.length; - for(var i = ((l + 1 | 0) / 3 | 0) - 1 | 0; i >= 0; --i){ - trickle(l, i, Caml_array.caml_array_get(a, i)); - } - for(var i$1 = l - 1 | 0; i$1 >= 2; --i$1){ - var e = Caml_array.caml_array_get(a, i$1); - Caml_array.caml_array_set(a, i$1, Caml_array.caml_array_get(a, 0)); - trickleup(bubble(i$1, 0), e); - } - if (l > 1) { - var e$1 = Caml_array.caml_array_get(a, 1); - Caml_array.caml_array_set(a, 1, Caml_array.caml_array_get(a, 0)); - return Caml_array.caml_array_set(a, 0, e$1); - } else { - return 0; - } -} - -function stable_sort(cmp, a) { - var merge = function (src1ofs, src1len, src2, src2ofs, src2len, dst, dstofs) { - var src1r = src1ofs + src1len | 0; - var src2r = src2ofs + src2len | 0; - var _i1 = src1ofs; - var _s1 = Caml_array.caml_array_get(a, src1ofs); - var _i2 = src2ofs; - var _s2 = Caml_array.caml_array_get(src2, src2ofs); - var _d = dstofs; - while(true) { - var d = _d; - var s2 = _s2; - var i2 = _i2; - var s1 = _s1; - var i1 = _i1; - if (Curry._2(cmp, s1, s2) <= 0) { - Caml_array.caml_array_set(dst, d, s1); - var i1$1 = i1 + 1 | 0; - if (i1$1 < src1r) { - _d = d + 1 | 0; - _s1 = Caml_array.caml_array_get(a, i1$1); - _i1 = i1$1; - continue ; - } else { - return blit(src2, i2, dst, d + 1 | 0, src2r - i2 | 0); - } - } else { - Caml_array.caml_array_set(dst, d, s2); - var i2$1 = i2 + 1 | 0; - if (i2$1 < src2r) { - _d = d + 1 | 0; - _s2 = Caml_array.caml_array_get(src2, i2$1); - _i2 = i2$1; - continue ; - } else { - return blit(a, i1, dst, d + 1 | 0, src1r - i1 | 0); - } - } - }; - }; - var isortto = function (srcofs, dst, dstofs, len) { - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - var e = Caml_array.caml_array_get(a, srcofs + i | 0); - var j = (dstofs + i | 0) - 1 | 0; - while(j >= dstofs && Curry._2(cmp, Caml_array.caml_array_get(dst, j), e) > 0) { - Caml_array.caml_array_set(dst, j + 1 | 0, Caml_array.caml_array_get(dst, j)); - j = j - 1 | 0; - }; - Caml_array.caml_array_set(dst, j + 1 | 0, e); - } - return /* () */0; - }; - var sortto = function (srcofs, dst, dstofs, len) { - if (len <= 5) { - return isortto(srcofs, dst, dstofs, len); - } else { - var l1 = len / 2 | 0; - var l2 = len - l1 | 0; - sortto(srcofs + l1 | 0, dst, dstofs + l1 | 0, l2); - sortto(srcofs, a, srcofs + l2 | 0, l1); - return merge(srcofs + l2 | 0, l1, dst, dstofs + l1 | 0, l2, dst, dstofs); - } - }; - var l = a.length; - if (l <= 5) { - return isortto(0, a, 0, l); - } else { - var l1 = l / 2 | 0; - var l2 = l - l1 | 0; - var t = Caml_array.caml_make_vect(l2, Caml_array.caml_array_get(a, 0)); - sortto(l1, t, 0, l2); - sortto(0, a, l2, l1); - return merge(l2, l1, t, 0, l2, a, 0); - } -} - -var create_matrix = make_matrix; - -var concat = Caml_array.caml_array_concat; - -var fast_sort = stable_sort; - -exports.make_float = make_float; -exports.init = init; -exports.make_matrix = make_matrix; -exports.create_matrix = create_matrix; -exports.append = append; -exports.concat = concat; -exports.sub = sub; -exports.copy = copy; -exports.fill = fill; -exports.blit = blit; -exports.to_list = to_list; -exports.of_list = of_list; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.for_all = for_all; -exports.exists = exists; -exports.mem = mem; -exports.memq = memq; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -exports.Floatarray = Floatarray; -/* No side effect */ - -},{"./caml_array.js":39,"./caml_builtin_exceptions.js":40,"./caml_exceptions.js":42,"./caml_js_exceptions.js":48,"./caml_obj.js":49,"./curry.js":58}],36:[function(require,module,exports){ -'use strict'; - - -function __(tag, block) { - block.tag = tag; - return block; -} - -exports.__ = __; -/* No side effect */ - -},{}],37:[function(require,module,exports){ -'use strict'; - -var Bytes = require("./bytes.js"); -var Curry = require("./curry.js"); -var $$String = require("./string.js"); -var Caml_bytes = require("./caml_bytes.js"); -var Pervasives = require("./pervasives.js"); -var Caml_string = require("./caml_string.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function create(n) { - var n$1 = n < 1 ? 1 : n; - var s = Caml_bytes.caml_create_bytes(n$1); - return { - buffer: s, - position: 0, - length: n$1, - initial_buffer: s - }; -} - -function contents(b) { - return Bytes.sub_string(b.buffer, 0, b.position); -} - -function to_bytes(b) { - return Bytes.sub(b.buffer, 0, b.position); -} - -function sub(b, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (b.position - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.sub" - ]; - } - return Bytes.sub_string(b.buffer, ofs, len); -} - -function blit(src, srcoff, dst, dstoff, len) { - if (len < 0 || srcoff < 0 || srcoff > (src.position - len | 0) || dstoff < 0 || dstoff > (dst.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.blit" - ]; - } - return Caml_bytes.caml_blit_bytes(src.buffer, srcoff, dst, dstoff, len); -} - -function nth(b, ofs) { - if (ofs < 0 || ofs >= b.position) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.nth" - ]; - } - return b.buffer[ofs]; -} - -function length(b) { - return b.position; -} - -function clear(b) { - b.position = 0; - return /* () */0; -} - -function reset(b) { - b.position = 0; - b.buffer = b.initial_buffer; - b.length = b.buffer.length; - return /* () */0; -} - -function resize(b, more) { - var len = b.length; - var new_len = len; - while((b.position + more | 0) > new_len) { - new_len = (new_len << 1); - }; - var new_buffer = Caml_bytes.caml_create_bytes(new_len); - Bytes.blit(b.buffer, 0, new_buffer, 0, b.position); - b.buffer = new_buffer; - b.length = new_len; - return /* () */0; -} - -function add_char(b, c) { - var pos = b.position; - if (pos >= b.length) { - resize(b, 1); - } - b.buffer[pos] = c; - b.position = pos + 1 | 0; - return /* () */0; -} - -function add_utf_8_uchar(b, u) { - var u$1 = u; - if (u$1 < 0) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 90, - 19 - ] - ]; - } - if (u$1 <= 127) { - return add_char(b, u$1); - } else if (u$1 <= 2047) { - var pos = b.position; - if ((pos + 2 | 0) > b.length) { - resize(b, 2); - } - b.buffer[pos] = 192 | (u$1 >>> 6); - b.buffer[pos + 1 | 0] = 128 | u$1 & 63; - b.position = pos + 2 | 0; - return /* () */0; - } else if (u$1 <= 65535) { - var pos$1 = b.position; - if ((pos$1 + 3 | 0) > b.length) { - resize(b, 3); - } - b.buffer[pos$1] = 224 | (u$1 >>> 12); - b.buffer[pos$1 + 1 | 0] = 128 | (u$1 >>> 6) & 63; - b.buffer[pos$1 + 2 | 0] = 128 | u$1 & 63; - b.position = pos$1 + 3 | 0; - return /* () */0; - } else if (u$1 <= 1114111) { - var pos$2 = b.position; - if ((pos$2 + 4 | 0) > b.length) { - resize(b, 4); - } - b.buffer[pos$2] = 240 | (u$1 >>> 18); - b.buffer[pos$2 + 1 | 0] = 128 | (u$1 >>> 12) & 63; - b.buffer[pos$2 + 2 | 0] = 128 | (u$1 >>> 6) & 63; - b.buffer[pos$2 + 3 | 0] = 128 | u$1 & 63; - b.position = pos$2 + 4 | 0; - return /* () */0; - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 123, - 8 - ] - ]; - } -} - -function add_utf_16be_uchar(b, u) { - var u$1 = u; - if (u$1 < 0) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 126, - 19 - ] - ]; - } - if (u$1 <= 65535) { - var pos = b.position; - if ((pos + 2 | 0) > b.length) { - resize(b, 2); - } - b.buffer[pos] = (u$1 >>> 8); - b.buffer[pos + 1 | 0] = u$1 & 255; - b.position = pos + 2 | 0; - return /* () */0; - } else if (u$1 <= 1114111) { - var u$prime = u$1 - 65536 | 0; - var hi = 55296 | (u$prime >>> 10); - var lo = 56320 | u$prime & 1023; - var pos$1 = b.position; - if ((pos$1 + 4 | 0) > b.length) { - resize(b, 4); - } - b.buffer[pos$1] = (hi >>> 8); - b.buffer[pos$1 + 1 | 0] = hi & 255; - b.buffer[pos$1 + 2 | 0] = (lo >>> 8); - b.buffer[pos$1 + 3 | 0] = lo & 255; - b.position = pos$1 + 4 | 0; - return /* () */0; - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 144, - 8 - ] - ]; - } -} - -function add_utf_16le_uchar(b, u) { - var u$1 = u; - if (u$1 < 0) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 147, - 19 - ] - ]; - } - if (u$1 <= 65535) { - var pos = b.position; - if ((pos + 2 | 0) > b.length) { - resize(b, 2); - } - b.buffer[pos] = u$1 & 255; - b.buffer[pos + 1 | 0] = (u$1 >>> 8); - b.position = pos + 2 | 0; - return /* () */0; - } else if (u$1 <= 1114111) { - var u$prime = u$1 - 65536 | 0; - var hi = 55296 | (u$prime >>> 10); - var lo = 56320 | u$prime & 1023; - var pos$1 = b.position; - if ((pos$1 + 4 | 0) > b.length) { - resize(b, 4); - } - b.buffer[pos$1] = hi & 255; - b.buffer[pos$1 + 1 | 0] = (hi >>> 8); - b.buffer[pos$1 + 2 | 0] = lo & 255; - b.buffer[pos$1 + 3 | 0] = (lo >>> 8); - b.position = pos$1 + 4 | 0; - return /* () */0; - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 165, - 8 - ] - ]; - } -} - -function add_substring(b, s, offset, len) { - if (offset < 0 || len < 0 || offset > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.add_substring/add_subbytes" - ]; - } - var new_position = b.position + len | 0; - if (new_position > b.length) { - resize(b, len); - } - Bytes.blit_string(s, offset, b.buffer, b.position, len); - b.position = new_position; - return /* () */0; -} - -function add_subbytes(b, s, offset, len) { - return add_substring(b, Caml_bytes.bytes_to_string(s), offset, len); -} - -function add_string(b, s) { - var len = s.length; - var new_position = b.position + len | 0; - if (new_position > b.length) { - resize(b, len); - } - Bytes.blit_string(s, 0, b.buffer, b.position, len); - b.position = new_position; - return /* () */0; -} - -function add_bytes(b, s) { - return add_string(b, Caml_bytes.bytes_to_string(s)); -} - -function add_buffer(b, bs) { - return add_subbytes(b, bs.buffer, 0, bs.position); -} - -function add_channel(b, ic, len) { - if (len < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.add_channel" - ]; - } - if ((b.position + len | 0) > b.length) { - resize(b, len); - } - var b$1 = b; - var ic$1 = ic; - var _len = len; - while(true) { - var len$1 = _len; - if (len$1 > 0) { - var n = Pervasives.input(ic$1, b$1.buffer, b$1.position, len$1); - b$1.position = b$1.position + n | 0; - if (n === 0) { - throw Caml_builtin_exceptions.end_of_file; - } - _len = len$1 - n | 0; - continue ; - } else { - return 0; - } - }; -} - -function output_buffer(oc, b) { - return Pervasives.output(oc, b.buffer, 0, b.position); -} - -function closing(param) { - if (param !== 40) { - if (param !== 123) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "buffer.ml", - 216, - 9 - ] - ]; - } else { - return /* "}" */125; - } - } else { - return /* ")" */41; - } -} - -function advance_to_closing(opening, closing, k, s, start) { - var _k = k; - var _i = start; - var lim = s.length; - while(true) { - var i = _i; - var k$1 = _k; - if (i >= lim) { - throw Caml_builtin_exceptions.not_found; - } - if (Caml_string.get(s, i) === opening) { - _i = i + 1 | 0; - _k = k$1 + 1 | 0; - continue ; - } else if (Caml_string.get(s, i) === closing) { - if (k$1 === 0) { - return i; - } else { - _i = i + 1 | 0; - _k = k$1 - 1 | 0; - continue ; - } - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function advance_to_non_alpha(s, start) { - var _i = start; - var lim = s.length; - while(true) { - var i = _i; - if (i >= lim) { - return lim; - } else { - var match = Caml_string.get(s, i); - if (match >= 91) { - if (match >= 97) { - if (match >= 123) { - return i; - } - - } else if (match !== 95) { - return i; - } - - } else if (match >= 58) { - if (match < 65) { - return i; - } - - } else if (match < 48) { - return i; - } - _i = i + 1 | 0; - continue ; - } - }; -} - -function find_ident(s, start, lim) { - if (start >= lim) { - throw Caml_builtin_exceptions.not_found; - } - var c = Caml_string.get(s, start); - if (c !== 40 && c !== 123) { - var stop = advance_to_non_alpha(s, start + 1 | 0); - return /* tuple */[ - $$String.sub(s, start, stop - start | 0), - stop - ]; - } - var new_start = start + 1 | 0; - var stop$1 = advance_to_closing(c, closing(c), 0, s, new_start); - return /* tuple */[ - $$String.sub(s, new_start, (stop$1 - start | 0) - 1 | 0), - stop$1 + 1 | 0 - ]; -} - -function add_substitute(b, f, s) { - var lim = s.length; - var _previous = /* " " */32; - var _i = 0; - while(true) { - var i = _i; - var previous = _previous; - if (i < lim) { - var current = Caml_string.get(s, i); - if (current !== 36) { - if (previous === /* "\\" */92) { - add_char(b, /* "\\" */92); - add_char(b, current); - _i = i + 1 | 0; - _previous = /* " " */32; - continue ; - } else if (current !== 92) { - add_char(b, current); - _i = i + 1 | 0; - _previous = current; - continue ; - } else { - _i = i + 1 | 0; - _previous = current; - continue ; - } - } else if (previous === /* "\\" */92) { - add_char(b, current); - _i = i + 1 | 0; - _previous = /* " " */32; - continue ; - } else { - var j = i + 1 | 0; - var match = find_ident(s, j, lim); - add_string(b, Curry._1(f, match[0])); - _i = match[1]; - _previous = /* " " */32; - continue ; - } - } else if (previous === /* "\\" */92) { - return add_char(b, previous); - } else { - return 0; - } - }; -} - -function truncate(b, len) { - if (len < 0 || len > b.position) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Buffer.truncate" - ]; - } - b.position = len; - return /* () */0; -} - -exports.create = create; -exports.contents = contents; -exports.to_bytes = to_bytes; -exports.sub = sub; -exports.blit = blit; -exports.nth = nth; -exports.length = length; -exports.clear = clear; -exports.reset = reset; -exports.add_char = add_char; -exports.add_utf_8_uchar = add_utf_8_uchar; -exports.add_utf_16le_uchar = add_utf_16le_uchar; -exports.add_utf_16be_uchar = add_utf_16be_uchar; -exports.add_string = add_string; -exports.add_bytes = add_bytes; -exports.add_substring = add_substring; -exports.add_subbytes = add_subbytes; -exports.add_substitute = add_substitute; -exports.add_buffer = add_buffer; -exports.add_channel = add_channel; -exports.output_buffer = output_buffer; -exports.truncate = truncate; -/* No side effect */ - -},{"./bytes.js":38,"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41,"./caml_string.js":52,"./curry.js":58,"./pervasives.js":62,"./string.js":64}],38:[function(require,module,exports){ -'use strict'; - -var Char = require("./char.js"); -var Curry = require("./curry.js"); -var Caml_bytes = require("./caml_bytes.js"); -var Caml_primitive = require("./caml_primitive.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function make(n, c) { - var s = Caml_bytes.caml_create_bytes(n); - Caml_bytes.caml_fill_bytes(s, 0, n, c); - return s; -} - -function init(n, f) { - var s = Caml_bytes.caml_create_bytes(n); - for(var i = 0 ,i_finish = n - 1 | 0; i <= i_finish; ++i){ - s[i] = Curry._1(f, i); - } - return s; -} - -var empty = []; - -function copy(s) { - var len = s.length; - var r = Caml_bytes.caml_create_bytes(len); - Caml_bytes.caml_blit_bytes(s, 0, r, 0, len); - return r; -} - -function to_string(b) { - return Caml_bytes.bytes_to_string(copy(b)); -} - -function of_string(s) { - return copy(Caml_bytes.bytes_of_string(s)); -} - -function sub(s, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.sub / Bytes.sub" - ]; - } - var r = Caml_bytes.caml_create_bytes(len); - Caml_bytes.caml_blit_bytes(s, ofs, r, 0, len); - return r; -} - -function sub_string(b, ofs, len) { - return Caml_bytes.bytes_to_string(sub(b, ofs, len)); -} - -function $plus$plus(a, b) { - var c = a + b | 0; - var match = a < 0; - var match$1 = b < 0; - var match$2 = c < 0; - if (match) { - if (match$1 && !match$2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Bytes.extend" - ]; - } else { - return c; - } - } else if (match$1) { - return c; - } else { - if (match$2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Bytes.extend" - ]; - } - return c; - } -} - -function extend(s, left, right) { - var len = $plus$plus($plus$plus(s.length, left), right); - var r = Caml_bytes.caml_create_bytes(len); - var match = left < 0 ? /* tuple */[ - -left | 0, - 0 - ] : /* tuple */[ - 0, - left - ]; - var dstoff = match[1]; - var srcoff = match[0]; - var cpylen = Caml_primitive.caml_int_min(s.length - srcoff | 0, len - dstoff | 0); - if (cpylen > 0) { - Caml_bytes.caml_blit_bytes(s, srcoff, r, dstoff, cpylen); - } - return r; -} - -function fill(s, ofs, len, c) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.fill / Bytes.fill" - ]; - } - return Caml_bytes.caml_fill_bytes(s, ofs, len, c); -} - -function blit(s1, ofs1, s2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Bytes.blit" - ]; - } - return Caml_bytes.caml_blit_bytes(s1, ofs1, s2, ofs2, len); -} - -function blit_string(s1, ofs1, s2, ofs2, len) { - if (len < 0 || ofs1 < 0 || ofs1 > (s1.length - len | 0) || ofs2 < 0 || ofs2 > (s2.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.blit / Bytes.blit_string" - ]; - } - return Caml_bytes.caml_blit_string(s1, ofs1, s2, ofs2, len); -} - -function iter(f, a) { - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - Curry._1(f, a[i]); - } - return /* () */0; -} - -function iteri(f, a) { - for(var i = 0 ,i_finish = a.length - 1 | 0; i <= i_finish; ++i){ - Curry._2(f, i, a[i]); - } - return /* () */0; -} - -function ensure_ge(x, y) { - if (x >= y) { - return x; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Bytes.concat" - ]; - } -} - -function sum_lengths(_acc, seplen, _param) { - while(true) { - var param = _param; - var acc = _acc; - if (param) { - var tl = param[1]; - var hd = param[0]; - if (tl) { - _param = tl; - _acc = ensure_ge((hd.length + seplen | 0) + acc | 0, acc); - continue ; - } else { - return hd.length + acc | 0; - } - } else { - return acc; - } - }; -} - -function concat(sep, l) { - if (l) { - var seplen = sep.length; - var dst = Caml_bytes.caml_create_bytes(sum_lengths(0, seplen, l)); - var _pos = 0; - var sep$1 = sep; - var seplen$1 = seplen; - var _param = l; - while(true) { - var param = _param; - var pos = _pos; - if (param) { - var tl = param[1]; - var hd = param[0]; - if (tl) { - Caml_bytes.caml_blit_bytes(hd, 0, dst, pos, hd.length); - Caml_bytes.caml_blit_bytes(sep$1, 0, dst, pos + hd.length | 0, seplen$1); - _param = tl; - _pos = (pos + hd.length | 0) + seplen$1 | 0; - continue ; - } else { - Caml_bytes.caml_blit_bytes(hd, 0, dst, pos, hd.length); - return dst; - } - } else { - return dst; - } - }; - } else { - return empty; - } -} - -function cat(s1, s2) { - var l1 = s1.length; - var l2 = s2.length; - var r = Caml_bytes.caml_create_bytes(l1 + l2 | 0); - Caml_bytes.caml_blit_bytes(s1, 0, r, 0, l1); - Caml_bytes.caml_blit_bytes(s2, 0, r, l1, l2); - return r; -} - -function is_space(param) { - var switcher = param - 9 | 0; - if (switcher > 4 || switcher < 0) { - return switcher === 23; - } else { - return switcher !== 2; - } -} - -function trim(s) { - var len = s.length; - var i = 0; - while(i < len && is_space(s[i])) { - i = i + 1 | 0; - }; - var j = len - 1 | 0; - while(j >= i && is_space(s[j])) { - j = j - 1 | 0; - }; - if (j >= i) { - return sub(s, i, (j - i | 0) + 1 | 0); - } else { - return empty; - } -} - -function escaped(s) { - var n = 0; - for(var i = 0 ,i_finish = s.length - 1 | 0; i <= i_finish; ++i){ - var match = s[i]; - var tmp; - if (match >= 32) { - var switcher = match - 34 | 0; - tmp = switcher > 58 || switcher < 0 ? ( - switcher >= 93 ? 4 : 1 - ) : ( - switcher > 57 || switcher < 1 ? 2 : 1 - ); - } else { - tmp = match >= 11 ? ( - match !== 13 ? 4 : 2 - ) : ( - match >= 8 ? 2 : 4 - ); - } - n = n + tmp | 0; - } - if (n === s.length) { - return copy(s); - } else { - var s$prime = Caml_bytes.caml_create_bytes(n); - n = 0; - for(var i$1 = 0 ,i_finish$1 = s.length - 1 | 0; i$1 <= i_finish$1; ++i$1){ - var c = s[i$1]; - var exit = 0; - if (c >= 35) { - if (c !== 92) { - if (c >= 127) { - exit = 1; - } else { - s$prime[n] = c; - } - } else { - exit = 2; - } - } else if (c >= 32) { - if (c >= 34) { - exit = 2; - } else { - s$prime[n] = c; - } - } else if (c >= 14) { - exit = 1; - } else { - switch (c) { - case 8 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = /* "b" */98; - break; - case 9 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = /* "t" */116; - break; - case 10 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = /* "n" */110; - break; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 11 : - case 12 : - exit = 1; - break; - case 13 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = /* "r" */114; - break; - - } - } - switch (exit) { - case 1 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = 48 + (c / 100 | 0) | 0; - n = n + 1 | 0; - s$prime[n] = 48 + (c / 10 | 0) % 10 | 0; - n = n + 1 | 0; - s$prime[n] = 48 + c % 10 | 0; - break; - case 2 : - s$prime[n] = /* "\\" */92; - n = n + 1 | 0; - s$prime[n] = c; - break; - - } - n = n + 1 | 0; - } - return s$prime; - } -} - -function map(f, s) { - var l = s.length; - if (l === 0) { - return s; - } else { - var r = Caml_bytes.caml_create_bytes(l); - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - r[i] = Curry._1(f, s[i]); - } - return r; - } -} - -function mapi(f, s) { - var l = s.length; - if (l === 0) { - return s; - } else { - var r = Caml_bytes.caml_create_bytes(l); - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - r[i] = Curry._2(f, i, s[i]); - } - return r; - } -} - -function uppercase_ascii(s) { - return map(Char.uppercase_ascii, s); -} - -function lowercase_ascii(s) { - return map(Char.lowercase_ascii, s); -} - -function apply1(f, s) { - if (s.length === 0) { - return s; - } else { - var r = copy(s); - r[0] = Curry._1(f, s[0]); - return r; - } -} - -function capitalize_ascii(s) { - return apply1(Char.uppercase_ascii, s); -} - -function uncapitalize_ascii(s) { - return apply1(Char.lowercase_ascii, s); -} - -function index_rec(s, lim, _i, c) { - while(true) { - var i = _i; - if (i >= lim) { - throw Caml_builtin_exceptions.not_found; - } - if (s[i] === c) { - return i; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function index(s, c) { - return index_rec(s, s.length, 0, c); -} - -function index_rec_opt(s, lim, _i, c) { - while(true) { - var i = _i; - if (i >= lim) { - return ; - } else if (s[i] === c) { - return i; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function index_opt(s, c) { - return index_rec_opt(s, s.length, 0, c); -} - -function index_from(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.index_from / Bytes.index_from" - ]; - } - return index_rec(s, l, i, c); -} - -function index_from_opt(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.index_from_opt / Bytes.index_from_opt" - ]; - } - return index_rec_opt(s, l, i, c); -} - -function rindex_rec(s, _i, c) { - while(true) { - var i = _i; - if (i < 0) { - throw Caml_builtin_exceptions.not_found; - } - if (s[i] === c) { - return i; - } else { - _i = i - 1 | 0; - continue ; - } - }; -} - -function rindex(s, c) { - return rindex_rec(s, s.length - 1 | 0, c); -} - -function rindex_from(s, i, c) { - if (i < -1 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rindex_from / Bytes.rindex_from" - ]; - } - return rindex_rec(s, i, c); -} - -function rindex_rec_opt(s, _i, c) { - while(true) { - var i = _i; - if (i < 0) { - return ; - } else if (s[i] === c) { - return i; - } else { - _i = i - 1 | 0; - continue ; - } - }; -} - -function rindex_opt(s, c) { - return rindex_rec_opt(s, s.length - 1 | 0, c); -} - -function rindex_from_opt(s, i, c) { - if (i < -1 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rindex_from_opt / Bytes.rindex_from_opt" - ]; - } - return rindex_rec_opt(s, i, c); -} - -function contains_from(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.contains_from / Bytes.contains_from" - ]; - } - try { - index_rec(s, l, i, c); - return true; - } - catch (exn){ - if (exn === Caml_builtin_exceptions.not_found) { - return false; - } else { - throw exn; - } - } -} - -function contains(s, c) { - return contains_from(s, 0, c); -} - -function rcontains_from(s, i, c) { - if (i < 0 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rcontains_from / Bytes.rcontains_from" - ]; - } - try { - rindex_rec(s, i, c); - return true; - } - catch (exn){ - if (exn === Caml_builtin_exceptions.not_found) { - return false; - } else { - throw exn; - } - } -} - -var compare = Caml_primitive.caml_bytes_compare; - -function uppercase(s) { - return map(Char.uppercase, s); -} - -function lowercase(s) { - return map(Char.lowercase, s); -} - -function capitalize(s) { - return apply1(Char.uppercase, s); -} - -function uncapitalize(s) { - return apply1(Char.lowercase, s); -} - -var equal = Caml_primitive.caml_bytes_equal; - -var unsafe_to_string = Caml_bytes.bytes_to_string; - -var unsafe_of_string = Caml_bytes.bytes_of_string; - -exports.make = make; -exports.init = init; -exports.empty = empty; -exports.copy = copy; -exports.of_string = of_string; -exports.to_string = to_string; -exports.sub = sub; -exports.sub_string = sub_string; -exports.extend = extend; -exports.fill = fill; -exports.blit = blit; -exports.blit_string = blit_string; -exports.concat = concat; -exports.cat = cat; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.trim = trim; -exports.escaped = escaped; -exports.index = index; -exports.index_opt = index_opt; -exports.rindex = rindex; -exports.rindex_opt = rindex_opt; -exports.index_from = index_from; -exports.index_from_opt = index_from_opt; -exports.rindex_from = rindex_from; -exports.rindex_from_opt = rindex_from_opt; -exports.contains = contains; -exports.contains_from = contains_from; -exports.rcontains_from = rcontains_from; -exports.uppercase = uppercase; -exports.lowercase = lowercase; -exports.capitalize = capitalize; -exports.uncapitalize = uncapitalize; -exports.uppercase_ascii = uppercase_ascii; -exports.lowercase_ascii = lowercase_ascii; -exports.capitalize_ascii = capitalize_ascii; -exports.uncapitalize_ascii = uncapitalize_ascii; -exports.compare = compare; -exports.equal = equal; -exports.unsafe_to_string = unsafe_to_string; -exports.unsafe_of_string = unsafe_of_string; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41,"./caml_primitive.js":51,"./char.js":57,"./curry.js":58}],39:[function(require,module,exports){ -'use strict'; - -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function caml_array_sub(x, offset, len) { - var result = new Array(len); - var j = 0; - var i = offset; - while(j < len) { - result[j] = x[i]; - j = j + 1 | 0; - i = i + 1 | 0; - }; - return result; -} - -function len(_acc, _l) { - while(true) { - var l = _l; - var acc = _acc; - if (l) { - _l = l[1]; - _acc = l[0].length + acc | 0; - continue ; - } else { - return acc; - } - }; -} - -function fill(arr, _i, _l) { - while(true) { - var l = _l; - var i = _i; - if (l) { - var x = l[0]; - var l$1 = x.length; - var k = i; - var j = 0; - while(j < l$1) { - arr[k] = x[j]; - k = k + 1 | 0; - j = j + 1 | 0; - }; - _l = l[1]; - _i = k; - continue ; - } else { - return /* () */0; - } - }; -} - -function caml_array_concat(l) { - var v = len(0, l); - var result = new Array(v); - fill(result, 0, l); - return result; -} - -function caml_array_set(xs, index, newval) { - if (index < 0 || index >= xs.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "index out of bounds" - ]; - } - xs[index] = newval; - return /* () */0; -} - -function caml_array_get(xs, index) { - if (index < 0 || index >= xs.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "index out of bounds" - ]; - } - return xs[index]; -} - -function caml_make_vect(len, init) { - var b = new Array(len); - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - b[i] = init; - } - return b; -} - -function caml_make_float_vect(len) { - var b = new Array(len); - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - b[i] = 0; - } - return b; -} - -function caml_array_blit(a1, i1, a2, i2, len) { - if (i2 <= i1) { - for(var j = 0 ,j_finish = len - 1 | 0; j <= j_finish; ++j){ - a2[j + i2 | 0] = a1[j + i1 | 0]; - } - return /* () */0; - } else { - for(var j$1 = len - 1 | 0; j$1 >= 0; --j$1){ - a2[j$1 + i2 | 0] = a1[j$1 + i1 | 0]; - } - return /* () */0; - } -} - -function caml_array_dup(prim) { - return prim.slice(0); -} - -exports.caml_array_dup = caml_array_dup; -exports.caml_array_sub = caml_array_sub; -exports.caml_array_concat = caml_array_concat; -exports.caml_make_vect = caml_make_vect; -exports.caml_make_float_vect = caml_make_float_vect; -exports.caml_array_blit = caml_array_blit; -exports.caml_array_get = caml_array_get; -exports.caml_array_set = caml_array_set; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40}],40:[function(require,module,exports){ -'use strict'; - - -var out_of_memory = /* tuple */[ - "Out_of_memory", - 0 -]; - -var sys_error = /* tuple */[ - "Sys_error", - -1 -]; - -var failure = /* tuple */[ - "Failure", - -2 -]; - -var invalid_argument = /* tuple */[ - "Invalid_argument", - -3 -]; - -var end_of_file = /* tuple */[ - "End_of_file", - -4 -]; - -var division_by_zero = /* tuple */[ - "Division_by_zero", - -5 -]; - -var not_found = /* tuple */[ - "Not_found", - -6 -]; - -var match_failure = /* tuple */[ - "Match_failure", - -7 -]; - -var stack_overflow = /* tuple */[ - "Stack_overflow", - -8 -]; - -var sys_blocked_io = /* tuple */[ - "Sys_blocked_io", - -9 -]; - -var assert_failure = /* tuple */[ - "Assert_failure", - -10 -]; - -var undefined_recursive_module = /* tuple */[ - "Undefined_recursive_module", - -11 -]; - -out_of_memory.tag = 248; - -sys_error.tag = 248; - -failure.tag = 248; - -invalid_argument.tag = 248; - -end_of_file.tag = 248; - -division_by_zero.tag = 248; - -not_found.tag = 248; - -match_failure.tag = 248; - -stack_overflow.tag = 248; - -sys_blocked_io.tag = 248; - -assert_failure.tag = 248; - -undefined_recursive_module.tag = 248; - -exports.out_of_memory = out_of_memory; -exports.sys_error = sys_error; -exports.failure = failure; -exports.invalid_argument = invalid_argument; -exports.end_of_file = end_of_file; -exports.division_by_zero = division_by_zero; -exports.not_found = not_found; -exports.match_failure = match_failure; -exports.stack_overflow = stack_overflow; -exports.sys_blocked_io = sys_blocked_io; -exports.assert_failure = assert_failure; -exports.undefined_recursive_module = undefined_recursive_module; -/* Not a pure module */ - -},{}],41:[function(require,module,exports){ -'use strict'; - -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function get(s, i) { - if (i < 0 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "index out of bounds" - ]; - } - return s[i]; -} - -function caml_fill_bytes(s, i, l, c) { - if (l > 0) { - for(var k = i ,k_finish = (l + i | 0) - 1 | 0; k <= k_finish; ++k){ - s[k] = c; - } - return /* () */0; - } else { - return 0; - } -} - -function caml_create_bytes(len) { - if (len < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.create" - ]; - } - var result = new Array(len); - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - result[i] = /* "\000" */0; - } - return result; -} - -function caml_blit_bytes(s1, i1, s2, i2, len) { - if (len > 0) { - if (s1 === s2) { - var s1$1 = s1; - var i1$1 = i1; - var i2$1 = i2; - var len$1 = len; - if (i1$1 < i2$1) { - var range_a = (s1$1.length - i2$1 | 0) - 1 | 0; - var range_b = len$1 - 1 | 0; - var range = range_a > range_b ? range_b : range_a; - for(var j = range; j >= 0; --j){ - s1$1[i2$1 + j | 0] = s1$1[i1$1 + j | 0]; - } - return /* () */0; - } else if (i1$1 > i2$1) { - var range_a$1 = (s1$1.length - i1$1 | 0) - 1 | 0; - var range_b$1 = len$1 - 1 | 0; - var range$1 = range_a$1 > range_b$1 ? range_b$1 : range_a$1; - for(var k = 0; k <= range$1; ++k){ - s1$1[i2$1 + k | 0] = s1$1[i1$1 + k | 0]; - } - return /* () */0; - } else { - return 0; - } - } else { - var off1 = s1.length - i1 | 0; - if (len <= off1) { - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - s2[i2 + i | 0] = s1[i1 + i | 0]; - } - return /* () */0; - } else { - for(var i$1 = 0 ,i_finish$1 = off1 - 1 | 0; i$1 <= i_finish$1; ++i$1){ - s2[i2 + i$1 | 0] = s1[i1 + i$1 | 0]; - } - for(var i$2 = off1 ,i_finish$2 = len - 1 | 0; i$2 <= i_finish$2; ++i$2){ - s2[i2 + i$2 | 0] = /* "\000" */0; - } - return /* () */0; - } - } - } else { - return 0; - } -} - -function bytes_to_string(a) { - var bytes = a; - var i = 0; - var len = a.length; - var s = ""; - var s_len = len; - if (i === 0 && len <= 4096 && len === bytes.length) { - return String.fromCharCode.apply(null, bytes); - } else { - var offset = 0; - while(s_len > 0) { - var next = s_len < 1024 ? s_len : 1024; - var tmp_bytes = new Array(next); - caml_blit_bytes(bytes, offset, tmp_bytes, 0, next); - s = s + String.fromCharCode.apply(null, tmp_bytes); - s_len = s_len - next | 0; - offset = offset + next | 0; - }; - return s; - } -} - -function caml_blit_string(s1, i1, s2, i2, len) { - if (len > 0) { - var off1 = s1.length - i1 | 0; - if (len <= off1) { - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - s2[i2 + i | 0] = s1.charCodeAt(i1 + i | 0); - } - return /* () */0; - } else { - for(var i$1 = 0 ,i_finish$1 = off1 - 1 | 0; i$1 <= i_finish$1; ++i$1){ - s2[i2 + i$1 | 0] = s1.charCodeAt(i1 + i$1 | 0); - } - for(var i$2 = off1 ,i_finish$2 = len - 1 | 0; i$2 <= i_finish$2; ++i$2){ - s2[i2 + i$2 | 0] = /* "\000" */0; - } - return /* () */0; - } - } else { - return 0; - } -} - -function bytes_of_string(s) { - var len = s.length; - var res = new Array(len); - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - res[i] = s.charCodeAt(i); - } - return res; -} - -exports.caml_create_bytes = caml_create_bytes; -exports.caml_fill_bytes = caml_fill_bytes; -exports.get = get; -exports.bytes_to_string = bytes_to_string; -exports.caml_blit_bytes = caml_blit_bytes; -exports.caml_blit_string = caml_blit_string; -exports.bytes_of_string = bytes_of_string; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40}],42:[function(require,module,exports){ -'use strict'; - - -var id = { - contents: 0 -}; - -function caml_set_oo_id(b) { - b[1] = id.contents; - id.contents = id.contents + 1; - return b; -} - -function caml_fresh_oo_id(param) { - id.contents = id.contents + 1; - return id.contents; -} - -function create(str) { - var v_001 = caml_fresh_oo_id(/* () */0); - var v = /* tuple */[ - str, - v_001 - ]; - v.tag = 248; - return v; -} - -function caml_is_extension(e) { - if (e === undefined) { - return false; - } else if (e.tag === 248) { - return true; - } else { - var slot = e[0]; - if (slot !== undefined) { - return slot.tag === 248; - } else { - return false; - } - } -} - -exports.caml_set_oo_id = caml_set_oo_id; -exports.caml_fresh_oo_id = caml_fresh_oo_id; -exports.create = create; -exports.caml_is_extension = caml_is_extension; -/* No side effect */ - -},{}],43:[function(require,module,exports){ -(function (global){ -'use strict'; - - -var getGlobalThis = (function(){ - if (typeof globalThis !== 'undefined') return globalThis; - if (typeof self !== 'undefined') return self; - if (typeof window !== 'undefined') return window; - if (typeof global !== 'undefined') return global; - if (typeof this !== 'undefined') return this; - throw new Error('Unable to locate global `this`'); -}); - -var resolve = (function(s){ - var myGlobal = getGlobalThis(); - if (myGlobal[s] === undefined){ - throw new Error(s + " not polyfilled by BuckleScript yet\n") - } - return myGlobal[s] -}); - -var register = (function(s,fn){ - var myGlobal = getGlobalThis(); - myGlobal[s] = fn - return 0 -}); - -exports.getGlobalThis = getGlobalThis; -exports.resolve = resolve; -exports.register = register; -/* No side effect */ - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],44:[function(require,module,exports){ -'use strict'; - -var Caml_int32 = require("./caml_int32.js"); -var Caml_int64 = require("./caml_int64.js"); -var Caml_utils = require("./caml_utils.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function parse_digit(c) { - if (c >= 65) { - if (c >= 97) { - if (c >= 123) { - return -1; - } else { - return c - 87 | 0; - } - } else if (c >= 91) { - return -1; - } else { - return c - 55 | 0; - } - } else if (c > 57 || c < 48) { - return -1; - } else { - return c - /* "0" */48 | 0; - } -} - -function int_of_string_base(param) { - switch (param) { - case /* Oct */0 : - return 8; - case /* Hex */1 : - return 16; - case /* Dec */2 : - return 10; - case /* Bin */3 : - return 2; - - } -} - -function parse_sign_and_base(s) { - var sign = 1; - var base = /* Dec */2; - var i = 0; - var match = s.charCodeAt(i); - switch (match) { - case 43 : - i = i + 1 | 0; - break; - case 44 : - break; - case 45 : - sign = -1; - i = i + 1 | 0; - break; - default: - - } - if (s[i] === "0") { - var match$1 = s.charCodeAt(i + 1 | 0); - if (match$1 >= 89) { - if (match$1 >= 111) { - if (match$1 < 121) { - switch (match$1 - 111 | 0) { - case 0 : - base = /* Oct */0; - i = i + 2 | 0; - break; - case 6 : - i = i + 2 | 0; - break; - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 7 : - case 8 : - break; - case 9 : - base = /* Hex */1; - i = i + 2 | 0; - break; - - } - } - - } else if (match$1 === 98) { - base = /* Bin */3; - i = i + 2 | 0; - } - - } else if (match$1 !== 66) { - if (match$1 >= 79) { - switch (match$1 - 79 | 0) { - case 0 : - base = /* Oct */0; - i = i + 2 | 0; - break; - case 6 : - i = i + 2 | 0; - break; - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 7 : - case 8 : - break; - case 9 : - base = /* Hex */1; - i = i + 2 | 0; - break; - - } - } - - } else { - base = /* Bin */3; - i = i + 2 | 0; - } - } - return /* tuple */[ - i, - sign, - base - ]; -} - -function caml_int_of_string(s) { - var match = parse_sign_and_base(s); - var i = match[0]; - var base = int_of_string_base(match[2]); - var threshold = 4294967295; - var len = s.length; - var c = i < len ? s.charCodeAt(i) : /* "\000" */0; - var d = parse_digit(c); - if (d < 0 || d >= base) { - throw [ - Caml_builtin_exceptions.failure, - "int_of_string" - ]; - } - var aux = function (_acc, _k) { - while(true) { - var k = _k; - var acc = _acc; - if (k === len) { - return acc; - } else { - var a = s.charCodeAt(k); - if (a === /* "_" */95) { - _k = k + 1 | 0; - continue ; - } else { - var v = parse_digit(a); - if (v < 0 || v >= base) { - throw [ - Caml_builtin_exceptions.failure, - "int_of_string" - ]; - } - var acc$1 = base * acc + v; - if (acc$1 > threshold) { - throw [ - Caml_builtin_exceptions.failure, - "int_of_string" - ]; - } - _k = k + 1 | 0; - _acc = acc$1; - continue ; - } - } - }; - }; - var res = match[1] * aux(d, i + 1 | 0); - var or_res = res | 0; - if (base === 10 && res !== or_res) { - throw [ - Caml_builtin_exceptions.failure, - "int_of_string" - ]; - } - return or_res; -} - -function caml_int64_of_string(s) { - var match = parse_sign_and_base(s); - var hbase = match[2]; - var i = match[0]; - var base = Caml_int64.of_int32(int_of_string_base(hbase)); - var sign = Caml_int64.of_int32(match[1]); - var threshold; - switch (hbase) { - case /* Oct */0 : - threshold = /* int64 */[ - /* hi */536870911, - /* lo */4294967295 - ]; - break; - case /* Hex */1 : - threshold = /* int64 */[ - /* hi */268435455, - /* lo */4294967295 - ]; - break; - case /* Dec */2 : - threshold = /* int64 */[ - /* hi */429496729, - /* lo */2576980377 - ]; - break; - case /* Bin */3 : - threshold = /* int64 */[ - /* hi */2147483647, - /* lo */4294967295 - ]; - break; - - } - var len = s.length; - var c = i < len ? s.charCodeAt(i) : /* "\000" */0; - var d = Caml_int64.of_int32(parse_digit(c)); - if (Caml_int64.lt(d, /* int64 */[ - /* hi */0, - /* lo */0 - ]) || Caml_int64.ge(d, base)) { - throw [ - Caml_builtin_exceptions.failure, - "int64_of_string" - ]; - } - var aux = function (_acc, _k) { - while(true) { - var k = _k; - var acc = _acc; - if (k === len) { - return acc; - } else { - var a = s.charCodeAt(k); - if (a === /* "_" */95) { - _k = k + 1 | 0; - continue ; - } else { - var v = Caml_int64.of_int32(parse_digit(a)); - if (Caml_int64.lt(v, /* int64 */[ - /* hi */0, - /* lo */0 - ]) || Caml_int64.ge(v, base) || Caml_int64.gt(acc, threshold)) { - throw [ - Caml_builtin_exceptions.failure, - "int64_of_string" - ]; - } - var acc$1 = Caml_int64.add(Caml_int64.mul(base, acc), v); - _k = k + 1 | 0; - _acc = acc$1; - continue ; - } - } - }; - }; - var res = Caml_int64.mul(sign, aux(d, i + 1 | 0)); - var or_res = Caml_int64.or_(res, /* int64 */[ - /* hi */0, - /* lo */0 - ]); - if (Caml_int64.eq(base, /* int64 */[ - /* hi */0, - /* lo */10 - ]) && Caml_int64.neq(res, or_res)) { - throw [ - Caml_builtin_exceptions.failure, - "int64_of_string" - ]; - } - return or_res; -} - -function int_of_base(param) { - switch (param) { - case /* Oct */0 : - return 8; - case /* Hex */1 : - return 16; - case /* Dec */2 : - return 10; - - } -} - -function lowercase(c) { - if (c >= /* "A" */65 && c <= /* "Z" */90 || c >= /* "\192" */192 && c <= /* "\214" */214 || c >= /* "\216" */216 && c <= /* "\222" */222) { - return c + 32 | 0; - } else { - return c; - } -} - -function parse_format(fmt) { - var len = fmt.length; - if (len > 31) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "format_int: format too long" - ]; - } - var f = { - justify: "+", - signstyle: "-", - filter: " ", - alternate: false, - base: /* Dec */2, - signedconv: false, - width: 0, - uppercase: false, - sign: 1, - prec: -1, - conv: "f" - }; - var _i = 0; - while(true) { - var i = _i; - if (i >= len) { - return f; - } else { - var c = fmt.charCodeAt(i); - var exit = 0; - if (c >= 69) { - if (c >= 88) { - if (c >= 121) { - exit = 1; - } else { - switch (c - 88 | 0) { - case 0 : - f.base = /* Hex */1; - f.uppercase = true; - _i = i + 1 | 0; - continue ; - case 13 : - case 14 : - case 15 : - exit = 5; - break; - case 12 : - case 17 : - exit = 4; - break; - case 23 : - f.base = /* Oct */0; - _i = i + 1 | 0; - continue ; - case 29 : - f.base = /* Dec */2; - _i = i + 1 | 0; - continue ; - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 8 : - case 9 : - case 10 : - case 11 : - case 16 : - case 18 : - case 19 : - case 20 : - case 21 : - case 22 : - case 24 : - case 25 : - case 26 : - case 27 : - case 28 : - case 30 : - case 31 : - exit = 1; - break; - case 32 : - f.base = /* Hex */1; - _i = i + 1 | 0; - continue ; - - } - } - } else if (c >= 72) { - exit = 1; - } else { - f.signedconv = true; - f.uppercase = true; - f.conv = String.fromCharCode(lowercase(c)); - _i = i + 1 | 0; - continue ; - } - } else { - switch (c) { - case 35 : - f.alternate = true; - _i = i + 1 | 0; - continue ; - case 32 : - case 43 : - exit = 2; - break; - case 45 : - f.justify = "-"; - _i = i + 1 | 0; - continue ; - case 46 : - f.prec = 0; - var j = i + 1 | 0; - while((function(j){ - return function () { - var w = fmt.charCodeAt(j) - /* "0" */48 | 0; - return w >= 0 && w <= 9; - } - }(j))()) { - f.prec = (Caml_int32.imul(f.prec, 10) + fmt.charCodeAt(j) | 0) - /* "0" */48 | 0; - j = j + 1 | 0; - }; - _i = j; - continue ; - case 33 : - case 34 : - case 36 : - case 37 : - case 38 : - case 39 : - case 40 : - case 41 : - case 42 : - case 44 : - case 47 : - exit = 1; - break; - case 48 : - f.filter = "0"; - _i = i + 1 | 0; - continue ; - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - exit = 3; - break; - default: - exit = 1; - } - } - switch (exit) { - case 1 : - _i = i + 1 | 0; - continue ; - case 2 : - f.signstyle = String.fromCharCode(c); - _i = i + 1 | 0; - continue ; - case 3 : - f.width = 0; - var j$1 = i; - while((function(j$1){ - return function () { - var w = fmt.charCodeAt(j$1) - /* "0" */48 | 0; - return w >= 0 && w <= 9; - } - }(j$1))()) { - f.width = (Caml_int32.imul(f.width, 10) + fmt.charCodeAt(j$1) | 0) - /* "0" */48 | 0; - j$1 = j$1 + 1 | 0; - }; - _i = j$1; - continue ; - case 4 : - f.signedconv = true; - f.base = /* Dec */2; - _i = i + 1 | 0; - continue ; - case 5 : - f.signedconv = true; - f.conv = String.fromCharCode(c); - _i = i + 1 | 0; - continue ; - - } - } - }; -} - -function finish_formatting(config, rawbuffer) { - var justify = config.justify; - var signstyle = config.signstyle; - var filter = config.filter; - var alternate = config.alternate; - var base = config.base; - var signedconv = config.signedconv; - var width = config.width; - var uppercase = config.uppercase; - var sign = config.sign; - var len = rawbuffer.length; - if (signedconv && (sign < 0 || signstyle !== "-")) { - len = len + 1 | 0; - } - if (alternate) { - if (base === /* Oct */0) { - len = len + 1 | 0; - } else if (base === /* Hex */1) { - len = len + 2 | 0; - } - - } - var buffer = ""; - if (justify === "+" && filter === " ") { - for(var _for = len ,_for_finish = width - 1 | 0; _for <= _for_finish; ++_for){ - buffer = buffer + filter; - } - } - if (signedconv) { - if (sign < 0) { - buffer = buffer + "-"; - } else if (signstyle !== "-") { - buffer = buffer + signstyle; - } - - } - if (alternate && base === /* Oct */0) { - buffer = buffer + "0"; - } - if (alternate && base === /* Hex */1) { - buffer = buffer + "0x"; - } - if (justify === "+" && filter === "0") { - for(var _for$1 = len ,_for_finish$1 = width - 1 | 0; _for$1 <= _for_finish$1; ++_for$1){ - buffer = buffer + filter; - } - } - buffer = uppercase ? buffer + rawbuffer.toUpperCase() : buffer + rawbuffer; - if (justify === "-") { - for(var _for$2 = len ,_for_finish$2 = width - 1 | 0; _for$2 <= _for_finish$2; ++_for$2){ - buffer = buffer + " "; - } - } - return buffer; -} - -function caml_format_int(fmt, i) { - if (fmt === "%d") { - return String(i); - } else { - var f = parse_format(fmt); - var f$1 = f; - var i$1 = i; - var i$2 = i$1 < 0 ? ( - f$1.signedconv ? (f$1.sign = -1, -i$1) : (i$1 >>> 0) - ) : i$1; - var s = i$2.toString(int_of_base(f$1.base)); - if (f$1.prec >= 0) { - f$1.filter = " "; - var n = f$1.prec - s.length | 0; - if (n > 0) { - s = Caml_utils.repeat(n, "0") + s; - } - - } - return finish_formatting(f$1, s); - } -} - -function caml_int64_format(fmt, x) { - var f = parse_format(fmt); - var x$1 = f.signedconv && Caml_int64.lt(x, /* int64 */[ - /* hi */0, - /* lo */0 - ]) ? (f.sign = -1, Caml_int64.neg(x)) : x; - var s = ""; - var match = f.base; - switch (match) { - case /* Oct */0 : - var wbase = /* int64 */[ - /* hi */0, - /* lo */8 - ]; - var cvtbl = "01234567"; - if (Caml_int64.lt(x$1, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var y = Caml_int64.discard_sign(x$1); - var match$1 = Caml_int64.div_mod(y, wbase); - var quotient = Caml_int64.add(/* int64 */[ - /* hi */268435456, - /* lo */0 - ], match$1[0]); - var modulus = match$1[1]; - s = String.fromCharCode(cvtbl.charCodeAt(Caml_int64.to_int32(modulus))) + s; - while(Caml_int64.neq(quotient, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var match$2 = Caml_int64.div_mod(quotient, wbase); - quotient = match$2[0]; - modulus = match$2[1]; - s = String.fromCharCode(cvtbl.charCodeAt(Caml_int64.to_int32(modulus))) + s; - }; - } else { - var match$3 = Caml_int64.div_mod(x$1, wbase); - var quotient$1 = match$3[0]; - var modulus$1 = match$3[1]; - s = String.fromCharCode(cvtbl.charCodeAt(Caml_int64.to_int32(modulus$1))) + s; - while(Caml_int64.neq(quotient$1, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var match$4 = Caml_int64.div_mod(quotient$1, wbase); - quotient$1 = match$4[0]; - modulus$1 = match$4[1]; - s = String.fromCharCode(cvtbl.charCodeAt(Caml_int64.to_int32(modulus$1))) + s; - }; - } - break; - case /* Hex */1 : - s = Caml_int64.to_hex(x$1) + s; - break; - case /* Dec */2 : - var wbase$1 = /* int64 */[ - /* hi */0, - /* lo */10 - ]; - var cvtbl$1 = "0123456789"; - if (Caml_int64.lt(x$1, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var y$1 = Caml_int64.discard_sign(x$1); - var match$5 = Caml_int64.div_mod(y$1, wbase$1); - var match$6 = Caml_int64.div_mod(Caml_int64.add(/* int64 */[ - /* hi */0, - /* lo */8 - ], match$5[1]), wbase$1); - var quotient$2 = Caml_int64.add(Caml_int64.add(/* int64 */[ - /* hi */214748364, - /* lo */3435973836 - ], match$5[0]), match$6[0]); - var modulus$2 = match$6[1]; - s = String.fromCharCode(cvtbl$1.charCodeAt(Caml_int64.to_int32(modulus$2))) + s; - while(Caml_int64.neq(quotient$2, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var match$7 = Caml_int64.div_mod(quotient$2, wbase$1); - quotient$2 = match$7[0]; - modulus$2 = match$7[1]; - s = String.fromCharCode(cvtbl$1.charCodeAt(Caml_int64.to_int32(modulus$2))) + s; - }; - } else { - var match$8 = Caml_int64.div_mod(x$1, wbase$1); - var quotient$3 = match$8[0]; - var modulus$3 = match$8[1]; - s = String.fromCharCode(cvtbl$1.charCodeAt(Caml_int64.to_int32(modulus$3))) + s; - while(Caml_int64.neq(quotient$3, /* int64 */[ - /* hi */0, - /* lo */0 - ])) { - var match$9 = Caml_int64.div_mod(quotient$3, wbase$1); - quotient$3 = match$9[0]; - modulus$3 = match$9[1]; - s = String.fromCharCode(cvtbl$1.charCodeAt(Caml_int64.to_int32(modulus$3))) + s; - }; - } - break; - - } - if (f.prec >= 0) { - f.filter = " "; - var n = f.prec - s.length | 0; - if (n > 0) { - s = Caml_utils.repeat(n, "0") + s; - } - - } - return finish_formatting(f, s); -} - -function caml_format_float(fmt, x) { - var f = parse_format(fmt); - var prec = f.prec < 0 ? 6 : f.prec; - var x$1 = x < 0 ? (f.sign = -1, -x) : x; - var s = ""; - if (isNaN(x$1)) { - s = "nan"; - f.filter = " "; - } else if (isFinite(x$1)) { - var match = f.conv; - switch (match) { - case "e" : - s = x$1.toExponential(prec); - var i = s.length; - if (s[i - 3 | 0] === "e") { - s = s.slice(0, i - 1 | 0) + ("0" + s.slice(i - 1 | 0)); - } - break; - case "f" : - s = x$1.toFixed(prec); - break; - case "g" : - var prec$1 = prec !== 0 ? prec : 1; - s = x$1.toExponential(prec$1 - 1 | 0); - var j = s.indexOf("e"); - var exp = Number(s.slice(j + 1 | 0)) | 0; - if (exp < -4 || x$1 >= 1e21 || x$1.toFixed().length > prec$1) { - var i$1 = j - 1 | 0; - while(s[i$1] === "0") { - i$1 = i$1 - 1 | 0; - }; - if (s[i$1] === ".") { - i$1 = i$1 - 1 | 0; - } - s = s.slice(0, i$1 + 1 | 0) + s.slice(j); - var i$2 = s.length; - if (s[i$2 - 3 | 0] === "e") { - s = s.slice(0, i$2 - 1 | 0) + ("0" + s.slice(i$2 - 1 | 0)); - } - - } else { - var p = prec$1; - if (exp < 0) { - p = p - (exp + 1 | 0) | 0; - s = x$1.toFixed(p); - } else { - while((function () { - s = x$1.toFixed(p); - return s.length > (prec$1 + 1 | 0); - })()) { - p = p - 1 | 0; - }; - } - if (p !== 0) { - var k = s.length - 1 | 0; - while(s[k] === "0") { - k = k - 1 | 0; - }; - if (s[k] === ".") { - k = k - 1 | 0; - } - s = s.slice(0, k + 1 | 0); - } - - } - break; - default: - - } - } else { - s = "inf"; - f.filter = " "; - } - return finish_formatting(f, s); -} - -var caml_hexstring_of_float = (function(x,prec,style){ - if (!isFinite(x)) { - if (isNaN(x)) return "nan"; - return x > 0 ? "infinity":"-infinity"; - } - var sign = (x==0 && 1/x == -Infinity)?1:(x>=0)?0:1; - if(sign) x = -x; - var exp = 0; - if (x == 0) { } - else if (x < 1) { - while (x < 1 && exp > -1022) { x *= 2; exp-- } - } else { - while (x >= 2) { x /= 2; exp++ } - } - var exp_sign = exp < 0 ? '' : '+'; - var sign_str = ''; - if (sign) sign_str = '-' - else { - switch(style){ - case 43 /* '+' */: sign_str = '+'; break; - case 32 /* ' ' */: sign_str = ' '; break; - default: break; - } - } - if (prec >= 0 && prec < 13) { - /* If a precision is given, and is small, round mantissa accordingly */ - var cst = Math.pow(2,prec * 4); - x = Math.round(x * cst) / cst; - } - var x_str = x.toString(16); - if(prec >= 0){ - var idx = x_str.indexOf('.'); - if(idx<0) { - x_str += '.' + '0'.repeat(prec); - } - else { - var size = idx+1+prec; - if(x_str.length < size) - x_str += '0'.repeat(size - x_str.length); - else - x_str = x_str.substr(0,size); - } - } - return (sign_str + '0x' + x_str + 'p' + exp_sign + exp.toString(10)); -}); - -var float_of_string = (function(s,exn){ - - var res = +s; - if ((s.length > 0) && (res === res)) - return res; - s = s.replace(/_/g, ""); - res = +s; - if (((s.length > 0) && (res === res)) || /^[+-]?nan$/i.test(s)) { - return res; - }; - var m = /^ *([+-]?)0x([0-9a-f]+)\.?([0-9a-f]*)p([+-]?[0-9]+)/i.exec(s); - // 1 2 3 4 - if(m){ - var m3 = m[3].replace(/0+$/,''); - var mantissa = parseInt(m[1] + m[2] + m3, 16); - var exponent = (m[4]|0) - 4*m3.length; - res = mantissa * Math.pow(2, exponent); - return res; - } - if (/^\+?inf(inity)?$/i.test(s)) - return Infinity; - if (/^-inf(inity)?$/i.test(s)) - return -Infinity; - throw exn; -}); - -function caml_float_of_string(s) { - return float_of_string(s, [ - Caml_builtin_exceptions.failure, - "float_of_string" - ]); -} - -var caml_nativeint_format = caml_format_int; - -var caml_int32_format = caml_format_int; - -var caml_int32_of_string = caml_int_of_string; - -var caml_nativeint_of_string = caml_int_of_string; - -exports.caml_format_float = caml_format_float; -exports.caml_hexstring_of_float = caml_hexstring_of_float; -exports.caml_format_int = caml_format_int; -exports.caml_nativeint_format = caml_nativeint_format; -exports.caml_int32_format = caml_int32_format; -exports.caml_float_of_string = caml_float_of_string; -exports.caml_int64_format = caml_int64_format; -exports.caml_int_of_string = caml_int_of_string; -exports.caml_int32_of_string = caml_int32_of_string; -exports.caml_int64_of_string = caml_int64_of_string; -exports.caml_nativeint_of_string = caml_nativeint_of_string; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40,"./caml_int32.js":45,"./caml_int64.js":46,"./caml_utils.js":54}],45:[function(require,module,exports){ -'use strict'; - -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function div(x, y) { - if (y === 0) { - throw Caml_builtin_exceptions.division_by_zero; - } - return x / y | 0; -} - -function mod_(x, y) { - if (y === 0) { - throw Caml_builtin_exceptions.division_by_zero; - } - return x % y; -} - -function caml_bswap16(x) { - return ((x & 255) << 8) | ((x & 65280) >>> 8); -} - -function caml_int32_bswap(x) { - return ((x & 255) << 24) | ((x & 65280) << 8) | ((x & 16711680) >>> 8) | ((x & 4278190080) >>> 24); -} - -var imul = (Math.imul || function (x,y) { - y |= 0; return ((((x >> 16) * y) << 16) + (x & 0xffff) * y)|0; -}); - -var caml_nativeint_bswap = caml_int32_bswap; - -exports.div = div; -exports.mod_ = mod_; -exports.caml_bswap16 = caml_bswap16; -exports.caml_int32_bswap = caml_int32_bswap; -exports.caml_nativeint_bswap = caml_nativeint_bswap; -exports.imul = imul; -/* imul Not a pure module */ - -},{"./caml_builtin_exceptions.js":40}],46:[function(require,module,exports){ -'use strict'; - -var Caml_int32 = require("./caml_int32.js"); -var Caml_utils = require("./caml_utils.js"); -var Caml_primitive = require("./caml_primitive.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -var min_int = /* Int64 */[ - /* hi */-2147483648, - /* lo */0 -]; - -var max_int = /* Int64 */[ - /* hi */2147483647, - /* lo */1 -]; - -var one = /* Int64 */[ - /* hi */0, - /* lo */1 -]; - -var zero = /* Int64 */[ - /* hi */0, - /* lo */0 -]; - -var neg_one = /* Int64 */[ - /* hi */-1, - /* lo */4294967295 -]; - -function neg_signed(x) { - return (x & 2147483648) !== 0; -} - -function add(param, param$1) { - var other_low_ = param$1[/* lo */1]; - var this_low_ = param[/* lo */1]; - var lo = this_low_ + other_low_ & 4294967295; - var overflow = neg_signed(this_low_) && (neg_signed(other_low_) || !neg_signed(lo)) || neg_signed(other_low_) && !neg_signed(lo) ? 1 : 0; - var hi = param[/* hi */0] + param$1[/* hi */0] + overflow & 4294967295; - return /* Int64 */[ - /* hi */hi, - /* lo */(lo >>> 0) - ]; -} - -function not(param) { - var hi = param[/* hi */0] ^ -1; - var lo = param[/* lo */1] ^ -1; - return /* Int64 */[ - /* hi */hi, - /* lo */(lo >>> 0) - ]; -} - -function eq(param, param$1) { - if (param[/* hi */0] === param$1[/* hi */0]) { - return param[/* lo */1] === param$1[/* lo */1]; - } else { - return false; - } -} - -function equal_null(x, y) { - if (y !== null) { - return eq(x, y); - } else { - return false; - } -} - -function equal_undefined(x, y) { - if (y !== undefined) { - return eq(x, y); - } else { - return false; - } -} - -function equal_nullable(x, y) { - if (y == null) { - return false; - } else { - return eq(x, y); - } -} - -function neg(x) { - if (eq(x, min_int)) { - return min_int; - } else { - return add(not(x), one); - } -} - -function sub(x, y) { - return add(x, neg(y)); -} - -function lsl_(x, numBits) { - if (numBits === 0) { - return x; - } else { - var lo = x[/* lo */1]; - if (numBits >= 32) { - return /* Int64 */[ - /* hi */(lo << (numBits - 32 | 0)), - /* lo */0 - ]; - } else { - var hi = (lo >>> (32 - numBits | 0)) | (x[/* hi */0] << numBits); - return /* Int64 */[ - /* hi */hi, - /* lo */((lo << numBits) >>> 0) - ]; - } - } -} - -function lsr_(x, numBits) { - if (numBits === 0) { - return x; - } else { - var hi = x[/* hi */0]; - var offset = numBits - 32 | 0; - if (offset === 0) { - return /* Int64 */[ - /* hi */0, - /* lo */(hi >>> 0) - ]; - } else if (offset > 0) { - var lo = (hi >>> offset); - return /* Int64 */[ - /* hi */0, - /* lo */(lo >>> 0) - ]; - } else { - var hi$1 = (hi >>> numBits); - var lo$1 = (hi << (-offset | 0)) | (x[/* lo */1] >>> numBits); - return /* Int64 */[ - /* hi */hi$1, - /* lo */(lo$1 >>> 0) - ]; - } - } -} - -function asr_(x, numBits) { - if (numBits === 0) { - return x; - } else { - var hi = x[/* hi */0]; - if (numBits < 32) { - var hi$1 = (hi >> numBits); - var lo = (hi << (32 - numBits | 0)) | (x[/* lo */1] >>> numBits); - return /* Int64 */[ - /* hi */hi$1, - /* lo */(lo >>> 0) - ]; - } else { - var lo$1 = (hi >> (numBits - 32 | 0)); - return /* Int64 */[ - /* hi */hi >= 0 ? 0 : -1, - /* lo */(lo$1 >>> 0) - ]; - } - } -} - -function is_zero(param) { - if (param[/* hi */0] !== 0 || param[/* lo */1] !== 0) { - return false; - } else { - return true; - } -} - -function mul(_this, _other) { - while(true) { - var other = _other; - var $$this = _this; - var lo; - var exit = 0; - var exit$1 = 0; - if ($$this[/* hi */0] !== 0 || $$this[/* lo */1] !== 0) { - exit$1 = 3; - } else { - return zero; - } - if (exit$1 === 3) { - if (other[/* hi */0] !== 0 || other[/* lo */1] !== 0) { - exit = 2; - } else { - return zero; - } - } - if (exit === 2) { - var this_hi = $$this[/* hi */0]; - var exit$2 = 0; - if (this_hi !== -2147483648 || $$this[/* lo */1] !== 0) { - exit$2 = 3; - } else { - lo = other[/* lo */1]; - } - if (exit$2 === 3) { - var other_hi = other[/* hi */0]; - var lo$1 = $$this[/* lo */1]; - var exit$3 = 0; - if (other_hi !== -2147483648 || other[/* lo */1] !== 0) { - exit$3 = 4; - } else { - lo = lo$1; - } - if (exit$3 === 4) { - var other_lo = other[/* lo */1]; - if (this_hi < 0) { - if (other_hi < 0) { - _other = neg(other); - _this = neg($$this); - continue ; - } else { - return neg(mul(neg($$this), other)); - } - } else if (other_hi < 0) { - return neg(mul($$this, neg(other))); - } else { - var a48 = (this_hi >>> 16); - var a32 = this_hi & 65535; - var a16 = (lo$1 >>> 16); - var a00 = lo$1 & 65535; - var b48 = (other_hi >>> 16); - var b32 = other_hi & 65535; - var b16 = (other_lo >>> 16); - var b00 = other_lo & 65535; - var c48 = 0; - var c32 = 0; - var c16 = 0; - var c00 = a00 * b00; - c16 = (c00 >>> 16) + a16 * b00; - c32 = (c16 >>> 16); - c16 = (c16 & 65535) + a00 * b16; - c32 = c32 + (c16 >>> 16) + a32 * b00; - c48 = (c32 >>> 16); - c32 = (c32 & 65535) + a16 * b16; - c48 = c48 + (c32 >>> 16); - c32 = (c32 & 65535) + a00 * b32; - c48 = c48 + (c32 >>> 16); - c32 = c32 & 65535; - c48 = c48 + (a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48) & 65535; - var hi = c32 | (c48 << 16); - var lo$2 = c00 & 65535 | ((c16 & 65535) << 16); - return /* Int64 */[ - /* hi */hi, - /* lo */(lo$2 >>> 0) - ]; - } - } - - } - - } - if ((lo & 1) === 0) { - return zero; - } else { - return min_int; - } - }; -} - -function swap(param) { - var hi = Caml_int32.caml_int32_bswap(param[/* lo */1]); - var lo = Caml_int32.caml_int32_bswap(param[/* hi */0]); - return /* Int64 */[ - /* hi */hi, - /* lo */(lo >>> 0) - ]; -} - -function xor(param, param$1) { - return /* Int64 */[ - /* hi */param[/* hi */0] ^ param$1[/* hi */0], - /* lo */((param[/* lo */1] ^ param$1[/* lo */1]) >>> 0) - ]; -} - -function or_(param, param$1) { - return /* Int64 */[ - /* hi */param[/* hi */0] | param$1[/* hi */0], - /* lo */((param[/* lo */1] | param$1[/* lo */1]) >>> 0) - ]; -} - -function and_(param, param$1) { - return /* Int64 */[ - /* hi */param[/* hi */0] & param$1[/* hi */0], - /* lo */((param[/* lo */1] & param$1[/* lo */1]) >>> 0) - ]; -} - -function ge(param, param$1) { - var other_hi = param$1[/* hi */0]; - var hi = param[/* hi */0]; - if (hi > other_hi) { - return true; - } else if (hi < other_hi) { - return false; - } else { - return param[/* lo */1] >= param$1[/* lo */1]; - } -} - -function neq(x, y) { - return !eq(x, y); -} - -function lt(x, y) { - return !ge(x, y); -} - -function gt(param, param$1) { - if (param[/* hi */0] > param$1[/* hi */0]) { - return true; - } else if (param[/* hi */0] < param$1[/* hi */0]) { - return false; - } else { - return param[/* lo */1] > param$1[/* lo */1]; - } -} - -function le(x, y) { - return !gt(x, y); -} - -function min(x, y) { - if (ge(x, y)) { - return y; - } else { - return x; - } -} - -function max(x, y) { - if (gt(x, y)) { - return x; - } else { - return y; - } -} - -function to_float(param) { - return param[/* hi */0] * 0x100000000 + param[/* lo */1]; -} - -function of_float(x) { - if (isNaN(x) || !isFinite(x)) { - return zero; - } else if (x <= -9.22337203685477581e+18) { - return min_int; - } else if (x + 1 >= 9.22337203685477581e+18) { - return max_int; - } else if (x < 0) { - return neg(of_float(-x)); - } else { - var hi = x / 4294967296 | 0; - var lo = x % 4294967296 | 0; - return /* Int64 */[ - /* hi */hi, - /* lo */(lo >>> 0) - ]; - } -} - -function div(_self, _other) { - while(true) { - var other = _other; - var self = _self; - var exit = 0; - var exit$1 = 0; - if (other[/* hi */0] !== 0 || other[/* lo */1] !== 0) { - exit$1 = 3; - } else { - throw Caml_builtin_exceptions.division_by_zero; - } - if (exit$1 === 3) { - var match = self[/* hi */0]; - if (match !== -2147483648) { - if (match !== 0 || self[/* lo */1] !== 0) { - exit = 2; - } else { - return zero; - } - } else if (self[/* lo */1] !== 0) { - exit = 2; - } else if (eq(other, one) || eq(other, neg_one)) { - return self; - } else if (eq(other, min_int)) { - return one; - } else { - var half_this = asr_(self, 1); - var approx = lsl_(div(half_this, other), 1); - var exit$2 = 0; - if (approx[/* hi */0] !== 0 || approx[/* lo */1] !== 0) { - exit$2 = 4; - } else if (other[/* hi */0] < 0) { - return one; - } else { - return neg(one); - } - if (exit$2 === 4) { - var y = mul(other, approx); - var rem = add(self, neg(y)); - return add(approx, div(rem, other)); - } - - } - } - if (exit === 2 && other[/* hi */0] === -2147483648 && other[/* lo */1] === 0) { - return zero; - } - var other_hi = other[/* hi */0]; - if (self[/* hi */0] < 0) { - if (other_hi < 0) { - _other = neg(other); - _self = neg(self); - continue ; - } else { - return neg(div(neg(self), other)); - } - } else if (other_hi < 0) { - return neg(div(self, neg(other))); - } else { - var res = zero; - var rem$1 = self; - while(ge(rem$1, other)) { - var approx$1 = Caml_primitive.caml_float_max(1, Math.floor(to_float(rem$1) / to_float(other))); - var log2 = Math.ceil(Math.log(approx$1) / Math.LN2); - var delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48); - var approxRes = of_float(approx$1); - var approxRem = mul(approxRes, other); - while(approxRem[/* hi */0] < 0 || gt(approxRem, rem$1)) { - approx$1 = approx$1 - delta; - approxRes = of_float(approx$1); - approxRem = mul(approxRes, other); - }; - if (is_zero(approxRes)) { - approxRes = one; - } - res = add(res, approxRes); - rem$1 = add(rem$1, neg(approxRem)); - }; - return res; - } - }; -} - -function mod_(self, other) { - var y = mul(div(self, other), other); - return add(self, neg(y)); -} - -function div_mod(self, other) { - var quotient = div(self, other); - var y = mul(quotient, other); - return /* tuple */[ - quotient, - add(self, neg(y)) - ]; -} - -function compare(param, param$1) { - var v = Caml_primitive.caml_nativeint_compare(param[/* hi */0], param$1[/* hi */0]); - if (v === 0) { - return Caml_primitive.caml_nativeint_compare(param[/* lo */1], param$1[/* lo */1]); - } else { - return v; - } -} - -function of_int32(lo) { - return /* Int64 */[ - /* hi */lo < 0 ? -1 : 0, - /* lo */(lo >>> 0) - ]; -} - -function to_int32(param) { - return param[/* lo */1] | 0; -} - -function to_hex(x) { - var x_lo = x[/* lo */1]; - var x_hi = x[/* hi */0]; - var aux = function (v) { - return (v >>> 0).toString(16); - }; - if (x_hi === 0 && x_lo === 0) { - return "0"; - } - if (x_lo !== 0) { - if (x_hi !== 0) { - var lo = aux(x_lo); - var pad = 8 - lo.length | 0; - if (pad <= 0) { - return aux(x_hi) + lo; - } else { - return aux(x_hi) + (Caml_utils.repeat(pad, "0") + lo); - } - } else { - return aux(x_lo); - } - } else { - return aux(x_hi) + "00000000"; - } -} - -function discard_sign(x) { - return /* Int64 */[ - /* hi */2147483647 & x[/* hi */0], - /* lo */x[/* lo */1] - ]; -} - -function float_of_bits(param) { - return (function(lo,hi){ return (new Float64Array(new Int32Array([lo,hi]).buffer))[0]})(param[/* lo */1], param[/* hi */0]); -} - -function bits_of_float(x) { - var buf = (function(x){return new Int32Array(new Float64Array([x]).buffer)})(x); - return /* Int64 */[ - /* hi */buf[1], - /* lo */(buf[0] >>> 0) - ]; -} - -function get64(s, i) { - var hi = (s.charCodeAt(i + 4 | 0) << 32) | (s.charCodeAt(i + 5 | 0) << 40) | (s.charCodeAt(i + 6 | 0) << 48) | (s.charCodeAt(i + 7 | 0) << 56); - var lo = s.charCodeAt(i) | (s.charCodeAt(i + 1 | 0) << 8) | (s.charCodeAt(i + 2 | 0) << 16) | (s.charCodeAt(i + 3 | 0) << 24); - return /* Int64 */[ - /* hi */hi, - /* lo */(lo >>> 0) - ]; -} - -exports.min_int = min_int; -exports.max_int = max_int; -exports.one = one; -exports.zero = zero; -exports.not = not; -exports.of_int32 = of_int32; -exports.to_int32 = to_int32; -exports.add = add; -exports.neg = neg; -exports.sub = sub; -exports.lsl_ = lsl_; -exports.lsr_ = lsr_; -exports.asr_ = asr_; -exports.is_zero = is_zero; -exports.mul = mul; -exports.xor = xor; -exports.or_ = or_; -exports.and_ = and_; -exports.swap = swap; -exports.ge = ge; -exports.eq = eq; -exports.neq = neq; -exports.lt = lt; -exports.gt = gt; -exports.le = le; -exports.equal_null = equal_null; -exports.equal_undefined = equal_undefined; -exports.equal_nullable = equal_nullable; -exports.min = min; -exports.max = max; -exports.to_float = to_float; -exports.of_float = of_float; -exports.div = div; -exports.mod_ = mod_; -exports.compare = compare; -exports.float_of_bits = float_of_bits; -exports.bits_of_float = bits_of_float; -exports.get64 = get64; -exports.div_mod = div_mod; -exports.to_hex = to_hex; -exports.discard_sign = discard_sign; -/* Caml_int32 Not a pure module */ - -},{"./caml_builtin_exceptions.js":40,"./caml_int32.js":45,"./caml_primitive.js":51,"./caml_utils.js":54}],47:[function(require,module,exports){ -(function (process){ -'use strict'; - -var Curry = require("./curry.js"); - -var stdout = { - buffer: "", - output: (function (param, s) { - var v = s.length - 1 | 0; - if (((typeof process !== "undefined") && process.stdout && process.stdout.write)) { - return process.stdout.write(s); - } else if (s[v] === "\n") { - console.log(s.slice(0, v)); - return /* () */0; - } else { - console.log(s); - return /* () */0; - } - }) -}; - -var stderr = { - buffer: "", - output: (function (param, s) { - var v = s.length - 1 | 0; - if (s[v] === "\n") { - console.log(s.slice(0, v)); - return /* () */0; - } else { - console.log(s); - return /* () */0; - } - }) -}; - -function caml_ml_flush(oc) { - if (oc.buffer !== "") { - Curry._2(oc.output, oc, oc.buffer); - oc.buffer = ""; - return /* () */0; - } else { - return 0; - } -} - -function caml_ml_output(oc, str, offset, len) { - var str$1 = offset === 0 && len === str.length ? str : str.slice(offset, len); - if (((typeof process !== "undefined") && process.stdout && process.stdout.write) && oc === stdout) { - return process.stdout.write(str$1); - } else { - var id = str$1.lastIndexOf("\n"); - if (id < 0) { - oc.buffer = oc.buffer + str$1; - return /* () */0; - } else { - oc.buffer = oc.buffer + str$1.slice(0, id + 1 | 0); - caml_ml_flush(oc); - oc.buffer = oc.buffer + str$1.slice(id + 1 | 0); - return /* () */0; - } - } -} - -function caml_ml_output_char(oc, $$char) { - return caml_ml_output(oc, String.fromCharCode($$char), 0, 1); -} - -function caml_ml_out_channels_list(param) { - return /* :: */[ - stdout, - /* :: */[ - stderr, - /* [] */0 - ] - ]; -} - -var stdin = undefined; - -exports.stdin = stdin; -exports.stdout = stdout; -exports.stderr = stderr; -exports.caml_ml_flush = caml_ml_flush; -exports.caml_ml_output = caml_ml_output; -exports.caml_ml_output_char = caml_ml_output_char; -exports.caml_ml_out_channels_list = caml_ml_out_channels_list; -/* No side effect */ - -}).call(this,require('_process')) -},{"./curry.js":58,"_process":65}],48:[function(require,module,exports){ -'use strict'; - -var Caml_option = require("./caml_option.js"); -var Caml_exceptions = require("./caml_exceptions.js"); - -var $$Error = Caml_exceptions.create("Caml_js_exceptions.Error"); - -function internalToOCamlException(e) { - if (Caml_exceptions.caml_is_extension(e)) { - return e; - } else { - return [ - $$Error, - e - ]; - } -} - -function caml_as_js_exn(exn) { - if (exn[0] === $$Error) { - return Caml_option.some(exn[1]); - } - -} - -exports.$$Error = $$Error; -exports.internalToOCamlException = internalToOCamlException; -exports.caml_as_js_exn = caml_as_js_exn; -/* No side effect */ - -},{"./caml_exceptions.js":42,"./caml_option.js":50}],49:[function(require,module,exports){ -'use strict'; - -var Block = require("./block.js"); -var Caml_primitive = require("./caml_primitive.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -var for_in = (function(o,foo){ - for (var x in o) { foo(x) }}); - -function caml_obj_block(tag, size) { - var v = new Array(size); - v.tag = tag; - return v; -} - -function caml_obj_dup(x) { - if (Array.isArray(x)) { - var len = x.length | 0; - var v = new Array(len); - for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - v[i] = x[i]; - } - v.tag = x.tag | 0; - return v; - } else { - return Object.assign(({}), x); - } -} - -function caml_obj_truncate(x, new_size) { - var len = x.length | 0; - if (new_size <= 0 || new_size > len) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Obj.truncate" - ]; - } - if (len !== new_size) { - for(var i = new_size ,i_finish = len - 1 | 0; i <= i_finish; ++i){ - x[i] = 0; - } - x.length = new_size; - return /* () */0; - } else { - return 0; - } -} - -function caml_lazy_make_forward(x) { - return Block.__(250, [x]); -} - -function caml_lazy_make(fn) { - var block = [fn]; - block.tag = 246; - return block; -} - -var caml_update_dummy = (function(x,y){ - for (var k in y){ - x[k] = y[k] - } - return 0; - }); - -function caml_compare(_a, _b) { - while(true) { - var b = _b; - var a = _a; - if (a === b) { - return 0; - } else { - var a_type = typeof a; - var b_type = typeof b; - switch (a_type) { - case "boolean" : - if (b_type === "boolean") { - return Caml_primitive.caml_bool_compare(a, b); - } - break; - case "function" : - if (b_type === "function") { - throw [ - Caml_builtin_exceptions.invalid_argument, - "compare: functional value" - ]; - } - break; - case "number" : - if (b_type === "number") { - return Caml_primitive.caml_int_compare(a, b); - } - break; - case "string" : - if (b_type === "string") { - return Caml_primitive.caml_string_compare(a, b); - } else { - return 1; - } - case "undefined" : - return -1; - default: - - } - switch (b_type) { - case "string" : - return -1; - case "undefined" : - return 1; - default: - if (a_type === "boolean") { - return 1; - } else if (b_type === "boolean") { - return -1; - } else if (a_type === "function") { - return 1; - } else if (b_type === "function") { - return -1; - } else if (a_type === "number") { - if (b === null || b.tag === 256) { - return 1; - } else { - return -1; - } - } else if (b_type === "number") { - if (a === null || a.tag === 256) { - return -1; - } else { - return 1; - } - } else if (a === null) { - if (b.tag === 256) { - return 1; - } else { - return -1; - } - } else if (b === null) { - if (a.tag === 256) { - return -1; - } else { - return 1; - } - } else { - var tag_a = a.tag | 0; - var tag_b = b.tag | 0; - if (tag_a === 250) { - _a = a[0]; - continue ; - } else if (tag_b === 250) { - _b = b[0]; - continue ; - } else if (tag_a === 256) { - if (tag_b === 256) { - return Caml_primitive.caml_int_compare(a[1], b[1]); - } else { - return -1; - } - } else if (tag_a === 248) { - return Caml_primitive.caml_int_compare(a[1], b[1]); - } else { - if (tag_a === 251) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "equal: abstract value" - ]; - } - if (tag_a !== tag_b) { - if (tag_a < tag_b) { - return -1; - } else { - return 1; - } - } else { - var len_a = a.length | 0; - var len_b = b.length | 0; - if (len_a === len_b) { - if (Array.isArray(a)) { - var a$1 = a; - var b$1 = b; - var _i = 0; - var same_length = len_a; - while(true) { - var i = _i; - if (i === same_length) { - return 0; - } else { - var res = caml_compare(a$1[i], b$1[i]); - if (res !== 0) { - return res; - } else { - _i = i + 1 | 0; - continue ; - } - } - }; - } else if ((a instanceof Date && b instanceof Date)) { - return (a - b); - } else { - var a$2 = a; - var b$2 = b; - var min_key_lhs = { - contents: undefined - }; - var min_key_rhs = { - contents: undefined - }; - var do_key = function (param, key) { - var min_key = param[2]; - var b = param[1]; - if (!b.hasOwnProperty(key) || caml_compare(param[0][key], b[key]) > 0) { - var match = min_key.contents; - if (match !== undefined && key >= match) { - return 0; - } else { - min_key.contents = key; - return /* () */0; - } - } else { - return 0; - } - }; - var partial_arg = /* tuple */[ - a$2, - b$2, - min_key_rhs - ]; - var do_key_a = (function(partial_arg){ - return function do_key_a(param) { - return do_key(partial_arg, param); - } - }(partial_arg)); - var partial_arg$1 = /* tuple */[ - b$2, - a$2, - min_key_lhs - ]; - var do_key_b = (function(partial_arg$1){ - return function do_key_b(param) { - return do_key(partial_arg$1, param); - } - }(partial_arg$1)); - for_in(a$2, do_key_a); - for_in(b$2, do_key_b); - var match = min_key_lhs.contents; - var match$1 = min_key_rhs.contents; - if (match !== undefined) { - if (match$1 !== undefined) { - return Caml_primitive.caml_string_compare(match, match$1); - } else { - return -1; - } - } else if (match$1 !== undefined) { - return 1; - } else { - return 0; - } - } - } else if (len_a < len_b) { - var a$3 = a; - var b$3 = b; - var _i$1 = 0; - var short_length = len_a; - while(true) { - var i$1 = _i$1; - if (i$1 === short_length) { - return -1; - } else { - var res$1 = caml_compare(a$3[i$1], b$3[i$1]); - if (res$1 !== 0) { - return res$1; - } else { - _i$1 = i$1 + 1 | 0; - continue ; - } - } - }; - } else { - var a$4 = a; - var b$4 = b; - var _i$2 = 0; - var short_length$1 = len_b; - while(true) { - var i$2 = _i$2; - if (i$2 === short_length$1) { - return 1; - } else { - var res$2 = caml_compare(a$4[i$2], b$4[i$2]); - if (res$2 !== 0) { - return res$2; - } else { - _i$2 = i$2 + 1 | 0; - continue ; - } - } - }; - } - } - } - } - } - } - }; -} - -function caml_equal(_a, _b) { - while(true) { - var b = _b; - var a = _a; - if (a === b) { - return true; - } else { - var a_type = typeof a; - if (a_type === "string" || a_type === "number" || a_type === "boolean" || a_type === "undefined" || a === null) { - return false; - } else { - var b_type = typeof b; - if (a_type === "function" || b_type === "function") { - throw [ - Caml_builtin_exceptions.invalid_argument, - "equal: functional value" - ]; - } - if (b_type === "number" || b_type === "undefined" || b === null) { - return false; - } else { - var tag_a = a.tag | 0; - var tag_b = b.tag | 0; - if (tag_a === 250) { - _a = a[0]; - continue ; - } else if (tag_b === 250) { - _b = b[0]; - continue ; - } else if (tag_a === 248) { - return a[1] === b[1]; - } else { - if (tag_a === 251) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "equal: abstract value" - ]; - } - if (tag_a !== tag_b) { - return false; - } else if (tag_a === 256) { - return a[1] === b[1]; - } else { - var len_a = a.length | 0; - var len_b = b.length | 0; - if (len_a === len_b) { - if (Array.isArray(a)) { - var a$1 = a; - var b$1 = b; - var _i = 0; - var same_length = len_a; - while(true) { - var i = _i; - if (i === same_length) { - return true; - } else if (caml_equal(a$1[i], b$1[i])) { - _i = i + 1 | 0; - continue ; - } else { - return false; - } - }; - } else if ((a instanceof Date && b instanceof Date)) { - return !(a > b || a < b); - } else { - var a$2 = a; - var b$2 = b; - var result = { - contents: true - }; - var do_key_a = (function(b$2,result){ - return function do_key_a(key) { - if (b$2.hasOwnProperty(key)) { - return 0; - } else { - result.contents = false; - return /* () */0; - } - } - }(b$2,result)); - var do_key_b = (function(a$2,b$2,result){ - return function do_key_b(key) { - if (!a$2.hasOwnProperty(key) || !caml_equal(b$2[key], a$2[key])) { - result.contents = false; - return /* () */0; - } else { - return 0; - } - } - }(a$2,b$2,result)); - for_in(a$2, do_key_a); - if (result.contents) { - for_in(b$2, do_key_b); - } - return result.contents; - } - } else { - return false; - } - } - } - } - } - } - }; -} - -function caml_equal_null(x, y) { - if (y !== null) { - return caml_equal(x, y); - } else { - return x === y; - } -} - -function caml_equal_undefined(x, y) { - if (y !== undefined) { - return caml_equal(x, y); - } else { - return x === y; - } -} - -function caml_equal_nullable(x, y) { - if (y == null) { - return x === y; - } else { - return caml_equal(x, y); - } -} - -function caml_notequal(a, b) { - return !caml_equal(a, b); -} - -function caml_greaterequal(a, b) { - return caml_compare(a, b) >= 0; -} - -function caml_greaterthan(a, b) { - return caml_compare(a, b) > 0; -} - -function caml_lessequal(a, b) { - return caml_compare(a, b) <= 0; -} - -function caml_lessthan(a, b) { - return caml_compare(a, b) < 0; -} - -function caml_min(x, y) { - if (caml_compare(x, y) <= 0) { - return x; - } else { - return y; - } -} - -function caml_max(x, y) { - if (caml_compare(x, y) >= 0) { - return x; - } else { - return y; - } -} - -function caml_obj_set_tag(prim, prim$1) { - prim.tag = prim$1; - return /* () */0; -} - -exports.caml_obj_block = caml_obj_block; -exports.caml_obj_dup = caml_obj_dup; -exports.caml_obj_truncate = caml_obj_truncate; -exports.caml_lazy_make_forward = caml_lazy_make_forward; -exports.caml_lazy_make = caml_lazy_make; -exports.caml_update_dummy = caml_update_dummy; -exports.caml_compare = caml_compare; -exports.caml_equal = caml_equal; -exports.caml_equal_null = caml_equal_null; -exports.caml_equal_undefined = caml_equal_undefined; -exports.caml_equal_nullable = caml_equal_nullable; -exports.caml_notequal = caml_notequal; -exports.caml_greaterequal = caml_greaterequal; -exports.caml_greaterthan = caml_greaterthan; -exports.caml_lessthan = caml_lessthan; -exports.caml_lessequal = caml_lessequal; -exports.caml_min = caml_min; -exports.caml_max = caml_max; -exports.caml_obj_set_tag = caml_obj_set_tag; -/* No side effect */ - -},{"./block.js":36,"./caml_builtin_exceptions.js":40,"./caml_primitive.js":51}],50:[function(require,module,exports){ -'use strict'; - - -var undefinedHeader = []; - -function some(x) { - if (x === undefined) { - var block = /* tuple */[ - undefinedHeader, - 0 - ]; - block.tag = 256; - return block; - } else if (x !== null && x[0] === undefinedHeader) { - var nid = x[1] + 1 | 0; - var block$1 = /* tuple */[ - undefinedHeader, - nid - ]; - block$1.tag = 256; - return block$1; - } else { - return x; - } -} - -function nullable_to_opt(x) { - if (x === null || x === undefined) { - return ; - } else { - return some(x); - } -} - -function undefined_to_opt(x) { - if (x === undefined) { - return ; - } else { - return some(x); - } -} - -function null_to_opt(x) { - if (x === null) { - return ; - } else { - return some(x); - } -} - -function valFromOption(x) { - if (x !== null && x[0] === undefinedHeader) { - var depth = x[1]; - if (depth === 0) { - return ; - } else { - return /* tuple */[ - undefinedHeader, - depth - 1 | 0 - ]; - } - } else { - return x; - } -} - -function option_get(x) { - if (x === undefined) { - return ; - } else { - return valFromOption(x); - } -} - -function option_get_unwrap(x) { - if (x === undefined) { - return ; - } else { - return valFromOption(x)[1]; - } -} - -exports.nullable_to_opt = nullable_to_opt; -exports.undefined_to_opt = undefined_to_opt; -exports.null_to_opt = null_to_opt; -exports.valFromOption = valFromOption; -exports.some = some; -exports.option_get = option_get; -exports.option_get_unwrap = option_get_unwrap; -/* No side effect */ - -},{}],51:[function(require,module,exports){ -'use strict'; - - -function caml_int_compare(x, y) { - if (x < y) { - return -1; - } else if (x === y) { - return 0; - } else { - return 1; - } -} - -function caml_bool_compare(x, y) { - if (x) { - if (y) { - return 0; - } else { - return 1; - } - } else if (y) { - return -1; - } else { - return 0; - } -} - -function caml_float_compare(x, y) { - if (x === y) { - return 0; - } else if (x < y) { - return -1; - } else if (x > y || x === x) { - return 1; - } else if (y === y) { - return -1; - } else { - return 0; - } -} - -function caml_string_compare(s1, s2) { - if (s1 === s2) { - return 0; - } else if (s1 < s2) { - return -1; - } else { - return 1; - } -} - -function caml_bytes_compare_aux(s1, s2, _off, len, def) { - while(true) { - var off = _off; - if (off < len) { - var a = s1[off]; - var b = s2[off]; - if (a > b) { - return 1; - } else if (a < b) { - return -1; - } else { - _off = off + 1 | 0; - continue ; - } - } else { - return def; - } - }; -} - -function caml_bytes_compare(s1, s2) { - var len1 = s1.length; - var len2 = s2.length; - if (len1 === len2) { - return caml_bytes_compare_aux(s1, s2, 0, len1, 0); - } else if (len1 < len2) { - return caml_bytes_compare_aux(s1, s2, 0, len1, -1); - } else { - return caml_bytes_compare_aux(s1, s2, 0, len2, 1); - } -} - -function caml_bytes_equal(s1, s2) { - var len1 = s1.length; - var len2 = s2.length; - if (len1 === len2) { - var s1$1 = s1; - var s2$1 = s2; - var _off = 0; - var len = len1; - while(true) { - var off = _off; - if (off === len) { - return true; - } else { - var a = s1$1[off]; - var b = s2$1[off]; - if (a === b) { - _off = off + 1 | 0; - continue ; - } else { - return false; - } - } - }; - } else { - return false; - } -} - -function caml_bool_min(x, y) { - if (x) { - return y; - } else { - return x; - } -} - -function caml_int_min(x, y) { - if (x < y) { - return x; - } else { - return y; - } -} - -function caml_float_min(x, y) { - if (x < y) { - return x; - } else { - return y; - } -} - -function caml_string_min(x, y) { - if (x < y) { - return x; - } else { - return y; - } -} - -function caml_nativeint_min(x, y) { - if (x < y) { - return x; - } else { - return y; - } -} - -function caml_int32_min(x, y) { - if (x < y) { - return x; - } else { - return y; - } -} - -function caml_bool_max(x, y) { - if (x) { - return x; - } else { - return y; - } -} - -function caml_int_max(x, y) { - if (x > y) { - return x; - } else { - return y; - } -} - -function caml_float_max(x, y) { - if (x > y) { - return x; - } else { - return y; - } -} - -function caml_string_max(x, y) { - if (x > y) { - return x; - } else { - return y; - } -} - -function caml_nativeint_max(x, y) { - if (x > y) { - return x; - } else { - return y; - } -} - -function caml_int32_max(x, y) { - if (x > y) { - return x; - } else { - return y; - } -} - -var caml_nativeint_compare = caml_int_compare; - -var caml_int32_compare = caml_int_compare; - -exports.caml_bytes_compare = caml_bytes_compare; -exports.caml_bytes_equal = caml_bytes_equal; -exports.caml_int_compare = caml_int_compare; -exports.caml_bool_compare = caml_bool_compare; -exports.caml_float_compare = caml_float_compare; -exports.caml_nativeint_compare = caml_nativeint_compare; -exports.caml_string_compare = caml_string_compare; -exports.caml_int32_compare = caml_int32_compare; -exports.caml_bool_min = caml_bool_min; -exports.caml_int_min = caml_int_min; -exports.caml_float_min = caml_float_min; -exports.caml_string_min = caml_string_min; -exports.caml_nativeint_min = caml_nativeint_min; -exports.caml_int32_min = caml_int32_min; -exports.caml_bool_max = caml_bool_max; -exports.caml_int_max = caml_int_max; -exports.caml_float_max = caml_float_max; -exports.caml_string_max = caml_string_max; -exports.caml_nativeint_max = caml_nativeint_max; -exports.caml_int32_max = caml_int32_max; -/* No side effect */ - -},{}],52:[function(require,module,exports){ -'use strict'; - -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function caml_string_get(s, i) { - if (i >= s.length || i < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "index out of bounds" - ]; - } - return s.charCodeAt(i); -} - -function caml_string_get16(s, i) { - return s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0; -} - -function caml_string_get32(s, i) { - return ((s.charCodeAt(i) + (s.charCodeAt(i + 1 | 0) << 8) | 0) + (s.charCodeAt(i + 2 | 0) << 16) | 0) + (s.charCodeAt(i + 3 | 0) << 24) | 0; -} - -function get(s, i) { - if (i < 0 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "index out of bounds" - ]; - } - return s.charCodeAt(i); -} - -exports.caml_string_get = caml_string_get; -exports.caml_string_get16 = caml_string_get16; -exports.caml_string_get32 = caml_string_get32; -exports.get = get; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40}],53:[function(require,module,exports){ -(function (process){ -'use strict'; - -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function caml_sys_getenv(s) { - if (typeof process === "undefined" || process.env === undefined) { - throw Caml_builtin_exceptions.not_found; - } - var match = process.env[s]; - if (match !== undefined) { - return match; - } else { - throw Caml_builtin_exceptions.not_found; - } -} - -function caml_sys_time(param) { - if (typeof process === "undefined" || process.uptime === undefined) { - return -1; - } else { - return process.uptime(); - } -} - -function caml_sys_random_seed(param) { - return [((Date.now() | 0) ^ 4294967295) * Math.random() | 0]; -} - -function caml_sys_system_command(_cmd) { - return 127; -} - -var caml_sys_getcwd = (function(param){ - if (typeof process === "undefined" || process.cwd === undefined){ - return "/" - } - return process.cwd() - }); - -function caml_sys_get_argv(param) { - if (typeof process === "undefined") { - return /* tuple */[ - "", - [""] - ]; - } else { - var argv = process.argv; - if (argv == null) { - return /* tuple */[ - "", - [""] - ]; - } else { - return /* tuple */[ - argv[0], - argv - ]; - } - } -} - -function caml_sys_exit(exit_code) { - if (typeof process !== "undefined") { - return process.exit(exit_code); - } else { - return 0; - } -} - -function caml_sys_is_directory(_s) { - throw [ - Caml_builtin_exceptions.failure, - "caml_sys_is_directory not implemented" - ]; -} - -function caml_sys_file_exists(_s) { - throw [ - Caml_builtin_exceptions.failure, - "caml_sys_file_exists not implemented" - ]; -} - -exports.caml_sys_getenv = caml_sys_getenv; -exports.caml_sys_time = caml_sys_time; -exports.caml_sys_random_seed = caml_sys_random_seed; -exports.caml_sys_system_command = caml_sys_system_command; -exports.caml_sys_getcwd = caml_sys_getcwd; -exports.caml_sys_get_argv = caml_sys_get_argv; -exports.caml_sys_exit = caml_sys_exit; -exports.caml_sys_is_directory = caml_sys_is_directory; -exports.caml_sys_file_exists = caml_sys_file_exists; -/* No side effect */ - -}).call(this,require('_process')) -},{"./caml_builtin_exceptions.js":40,"_process":65}],54:[function(require,module,exports){ -'use strict'; - - -var repeat = (function(count,self){ - if (self.repeat){ - return self.repeat(count) - } - if (self.length == 0 || count == 0) { - return ''; - } - // Ensuring count is a 31-bit integer allows us to heavily optimize the - // main part. But anyway, most current (August 2014) browsers can't handle - // strings 1 << 28 chars or longer, so: - if (self.length * count >= 1 << 28) { - throw new RangeError('repeat count must not overflow maximum string size'); - } - var rpt = ''; - for (;;) { - if ((count & 1) == 1) { - rpt += self; - } - count >>>= 1; - if (count == 0) { - break; - } - self += self; - } - return rpt; -}); - -exports.repeat = repeat; -/* No side effect */ - -},{}],55:[function(require,module,exports){ -'use strict'; - -var Char = require("./char.js"); -var Block = require("./block.js"); -var Bytes = require("./bytes.js"); -var Curry = require("./curry.js"); -var $$Buffer = require("./buffer.js"); -var $$String = require("./string.js"); -var Caml_io = require("./caml_io.js"); -var Caml_obj = require("./caml_obj.js"); -var Caml_bytes = require("./caml_bytes.js"); -var Caml_int32 = require("./caml_int32.js"); -var Pervasives = require("./pervasives.js"); -var Caml_format = require("./caml_format.js"); -var Caml_string = require("./caml_string.js"); -var Caml_primitive = require("./caml_primitive.js"); -var Caml_exceptions = require("./caml_exceptions.js"); -var Caml_js_exceptions = require("./caml_js_exceptions.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); -var CamlinternalFormatBasics = require("./camlinternalFormatBasics.js"); - -function create_char_set(param) { - return Bytes.make(32, /* "\000" */0); -} - -function add_in_char_set(char_set, c) { - var str_ind = (c >>> 3); - var mask = (1 << (c & 7)); - char_set[str_ind] = Pervasives.char_of_int(Caml_bytes.get(char_set, str_ind) | mask); - return /* () */0; -} - -var freeze_char_set = Bytes.to_string; - -function rev_char_set(char_set) { - var char_set$prime = Bytes.make(32, /* "\000" */0); - for(var i = 0; i <= 31; ++i){ - char_set$prime[i] = Pervasives.char_of_int(Caml_string.get(char_set, i) ^ 255); - } - return Caml_bytes.bytes_to_string(char_set$prime); -} - -function is_in_char_set(char_set, c) { - var str_ind = (c >>> 3); - var mask = (1 << (c & 7)); - return (Caml_string.get(char_set, str_ind) & mask) !== 0; -} - -function pad_of_pad_opt(pad_opt) { - if (pad_opt !== undefined) { - return /* Lit_padding */Block.__(0, [ - /* Right */1, - pad_opt - ]); - } else { - return /* No_padding */0; - } -} - -function prec_of_prec_opt(prec_opt) { - if (prec_opt !== undefined) { - return /* Lit_precision */[prec_opt]; - } else { - return /* No_precision */0; - } -} - -function param_format_of_ignored_format(ign, fmt) { - if (typeof ign === "number") { - switch (ign) { - case /* Ignored_char */0 : - return /* Param_format_EBB */[/* Char */Block.__(0, [fmt])]; - case /* Ignored_caml_char */1 : - return /* Param_format_EBB */[/* Caml_char */Block.__(1, [fmt])]; - case /* Ignored_reader */2 : - return /* Param_format_EBB */[/* Reader */Block.__(19, [fmt])]; - case /* Ignored_scan_next_char */3 : - return /* Param_format_EBB */[/* Scan_next_char */Block.__(22, [fmt])]; - - } - } else { - switch (ign.tag | 0) { - case /* Ignored_string */0 : - return /* Param_format_EBB */[/* String */Block.__(2, [ - pad_of_pad_opt(ign[0]), - fmt - ])]; - case /* Ignored_caml_string */1 : - return /* Param_format_EBB */[/* Caml_string */Block.__(3, [ - pad_of_pad_opt(ign[0]), - fmt - ])]; - case /* Ignored_int */2 : - return /* Param_format_EBB */[/* Int */Block.__(4, [ - ign[0], - pad_of_pad_opt(ign[1]), - /* No_precision */0, - fmt - ])]; - case /* Ignored_int32 */3 : - return /* Param_format_EBB */[/* Int32 */Block.__(5, [ - ign[0], - pad_of_pad_opt(ign[1]), - /* No_precision */0, - fmt - ])]; - case /* Ignored_nativeint */4 : - return /* Param_format_EBB */[/* Nativeint */Block.__(6, [ - ign[0], - pad_of_pad_opt(ign[1]), - /* No_precision */0, - fmt - ])]; - case /* Ignored_int64 */5 : - return /* Param_format_EBB */[/* Int64 */Block.__(7, [ - ign[0], - pad_of_pad_opt(ign[1]), - /* No_precision */0, - fmt - ])]; - case /* Ignored_float */6 : - return /* Param_format_EBB */[/* Float */Block.__(8, [ - /* Float_f */0, - pad_of_pad_opt(ign[0]), - prec_of_prec_opt(ign[1]), - fmt - ])]; - case /* Ignored_bool */7 : - return /* Param_format_EBB */[/* Bool */Block.__(9, [ - pad_of_pad_opt(ign[0]), - fmt - ])]; - case /* Ignored_format_arg */8 : - return /* Param_format_EBB */[/* Format_arg */Block.__(13, [ - ign[0], - ign[1], - fmt - ])]; - case /* Ignored_format_subst */9 : - return /* Param_format_EBB */[/* Format_subst */Block.__(14, [ - ign[0], - ign[1], - fmt - ])]; - case /* Ignored_scan_char_set */10 : - return /* Param_format_EBB */[/* Scan_char_set */Block.__(20, [ - ign[0], - ign[1], - fmt - ])]; - case /* Ignored_scan_get_counter */11 : - return /* Param_format_EBB */[/* Scan_get_counter */Block.__(21, [ - ign[0], - fmt - ])]; - - } - } -} - -function buffer_check_size(buf, overhead) { - var len = buf.bytes.length; - var min_len = buf.ind + overhead | 0; - if (min_len > len) { - var new_len = Caml_primitive.caml_int_max((len << 1), min_len); - var new_str = Caml_bytes.caml_create_bytes(new_len); - Bytes.blit(buf.bytes, 0, new_str, 0, len); - buf.bytes = new_str; - return /* () */0; - } else { - return 0; - } -} - -function buffer_add_char(buf, c) { - buffer_check_size(buf, 1); - buf.bytes[buf.ind] = c; - buf.ind = buf.ind + 1 | 0; - return /* () */0; -} - -function buffer_add_string(buf, s) { - var str_len = s.length; - buffer_check_size(buf, str_len); - $$String.blit(s, 0, buf.bytes, buf.ind, str_len); - buf.ind = buf.ind + str_len | 0; - return /* () */0; -} - -function buffer_contents(buf) { - return Bytes.sub_string(buf.bytes, 0, buf.ind); -} - -function char_of_iconv(iconv) { - switch (iconv) { - case /* Int_d */0 : - case /* Int_pd */1 : - case /* Int_sd */2 : - return /* "d" */100; - case /* Int_i */3 : - case /* Int_pi */4 : - case /* Int_si */5 : - return /* "i" */105; - case /* Int_x */6 : - case /* Int_Cx */7 : - return /* "x" */120; - case /* Int_X */8 : - case /* Int_CX */9 : - return /* "X" */88; - case /* Int_o */10 : - case /* Int_Co */11 : - return /* "o" */111; - case /* Int_u */12 : - return /* "u" */117; - - } -} - -function char_of_fconv(fconv) { - switch (fconv) { - case /* Float_f */0 : - case /* Float_pf */1 : - case /* Float_sf */2 : - return /* "f" */102; - case /* Float_e */3 : - case /* Float_pe */4 : - case /* Float_se */5 : - return /* "e" */101; - case /* Float_E */6 : - case /* Float_pE */7 : - case /* Float_sE */8 : - return /* "E" */69; - case /* Float_g */9 : - case /* Float_pg */10 : - case /* Float_sg */11 : - return /* "g" */103; - case /* Float_G */12 : - case /* Float_pG */13 : - case /* Float_sG */14 : - return /* "G" */71; - case /* Float_F */15 : - return /* "F" */70; - case /* Float_h */16 : - case /* Float_ph */17 : - case /* Float_sh */18 : - return /* "h" */104; - case /* Float_H */19 : - case /* Float_pH */20 : - case /* Float_sH */21 : - return /* "H" */72; - - } -} - -function char_of_counter(counter) { - switch (counter) { - case /* Line_counter */0 : - return /* "l" */108; - case /* Char_counter */1 : - return /* "n" */110; - case /* Token_counter */2 : - return /* "N" */78; - - } -} - -function bprint_char_set(buf, char_set) { - var print_char = function (buf, i) { - var c = Pervasives.char_of_int(i); - if (c !== 37) { - if (c !== 64) { - return buffer_add_char(buf, c); - } else { - buffer_add_char(buf, /* "%" */37); - return buffer_add_char(buf, /* "@" */64); - } - } else { - buffer_add_char(buf, /* "%" */37); - return buffer_add_char(buf, /* "%" */37); - } - }; - var print_out = function (set, _i) { - while(true) { - var i = _i; - if (i < 256) { - if (is_in_char_set(set, Pervasives.char_of_int(i))) { - var set$1 = set; - var i$1 = i; - var match = Pervasives.char_of_int(i$1); - var switcher = match - 45 | 0; - if (switcher > 48 || switcher < 0) { - if (switcher >= 210) { - return print_char(buf, 255); - } else { - return print_second(set$1, i$1 + 1 | 0); - } - } else if (switcher > 47 || switcher < 1) { - return print_out(set$1, i$1 + 1 | 0); - } else { - return print_second(set$1, i$1 + 1 | 0); - } - } else { - _i = i + 1 | 0; - continue ; - } - } else { - return 0; - } - }; - }; - var print_second = function (set, i) { - if (is_in_char_set(set, Pervasives.char_of_int(i))) { - var match = Pervasives.char_of_int(i); - var switcher = match - 45 | 0; - if (switcher > 48 || switcher < 0) { - if (switcher >= 210) { - print_char(buf, 254); - return print_char(buf, 255); - } - - } else if ((switcher > 47 || switcher < 1) && !is_in_char_set(set, Pervasives.char_of_int(i + 1 | 0))) { - print_char(buf, i - 1 | 0); - return print_out(set, i + 1 | 0); - } - if (is_in_char_set(set, Pervasives.char_of_int(i + 1 | 0))) { - var set$1 = set; - var i$1 = i - 1 | 0; - var _j = i + 2 | 0; - while(true) { - var j = _j; - if (j === 256 || !is_in_char_set(set$1, Pervasives.char_of_int(j))) { - print_char(buf, i$1); - print_char(buf, /* "-" */45); - print_char(buf, j - 1 | 0); - if (j < 256) { - return print_out(set$1, j + 1 | 0); - } else { - return 0; - } - } else { - _j = j + 1 | 0; - continue ; - } - }; - } else { - print_char(buf, i - 1 | 0); - print_char(buf, i); - return print_out(set, i + 2 | 0); - } - } else { - print_char(buf, i - 1 | 0); - return print_out(set, i + 1 | 0); - } - }; - var print_start = function (set) { - var is_alone = function (c) { - var before = Char.chr(c - 1 | 0); - var after = Char.chr(c + 1 | 0); - if (is_in_char_set(set, c)) { - return !(is_in_char_set(set, before) && is_in_char_set(set, after)); - } else { - return false; - } - }; - if (is_alone(/* "]" */93)) { - buffer_add_char(buf, /* "]" */93); - } - print_out(set, 1); - if (is_alone(/* "-" */45)) { - return buffer_add_char(buf, /* "-" */45); - } else { - return 0; - } - }; - buffer_add_char(buf, /* "[" */91); - print_start(is_in_char_set(char_set, /* "\000" */0) ? (buffer_add_char(buf, /* "^" */94), rev_char_set(char_set)) : char_set); - return buffer_add_char(buf, /* "]" */93); -} - -function bprint_padty(buf, padty) { - switch (padty) { - case /* Left */0 : - return buffer_add_char(buf, /* "-" */45); - case /* Right */1 : - return /* () */0; - case /* Zeros */2 : - return buffer_add_char(buf, /* "0" */48); - - } -} - -function bprint_ignored_flag(buf, ign_flag) { - if (ign_flag) { - return buffer_add_char(buf, /* "_" */95); - } else { - return 0; - } -} - -function bprint_pad_opt(buf, pad_opt) { - if (pad_opt !== undefined) { - return buffer_add_string(buf, String(pad_opt)); - } else { - return /* () */0; - } -} - -function bprint_padding(buf, pad) { - if (typeof pad === "number") { - return /* () */0; - } else { - bprint_padty(buf, pad[0]); - if (pad.tag) { - return buffer_add_char(buf, /* "*" */42); - } else { - return buffer_add_string(buf, String(pad[1])); - } - } -} - -function bprint_precision(buf, prec) { - if (typeof prec === "number") { - if (prec !== 0) { - return buffer_add_string(buf, ".*"); - } else { - return /* () */0; - } - } else { - buffer_add_char(buf, /* "." */46); - return buffer_add_string(buf, String(prec[0])); - } -} - -function bprint_iconv_flag(buf, iconv) { - switch (iconv) { - case /* Int_pd */1 : - case /* Int_pi */4 : - return buffer_add_char(buf, /* "+" */43); - case /* Int_sd */2 : - case /* Int_si */5 : - return buffer_add_char(buf, /* " " */32); - case /* Int_Cx */7 : - case /* Int_CX */9 : - case /* Int_Co */11 : - return buffer_add_char(buf, /* "#" */35); - case /* Int_d */0 : - case /* Int_i */3 : - case /* Int_x */6 : - case /* Int_X */8 : - case /* Int_o */10 : - case /* Int_u */12 : - return /* () */0; - - } -} - -function bprint_int_fmt(buf, ign_flag, iconv, pad, prec) { - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_iconv_flag(buf, iconv); - bprint_padding(buf, pad); - bprint_precision(buf, prec); - return buffer_add_char(buf, char_of_iconv(iconv)); -} - -function bprint_altint_fmt(buf, ign_flag, iconv, pad, prec, c) { - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_iconv_flag(buf, iconv); - bprint_padding(buf, pad); - bprint_precision(buf, prec); - buffer_add_char(buf, c); - return buffer_add_char(buf, char_of_iconv(iconv)); -} - -function bprint_fconv_flag(buf, fconv) { - switch (fconv) { - case /* Float_f */0 : - case /* Float_e */3 : - case /* Float_E */6 : - case /* Float_g */9 : - case /* Float_G */12 : - case /* Float_F */15 : - case /* Float_h */16 : - case /* Float_H */19 : - return /* () */0; - case /* Float_pf */1 : - case /* Float_pe */4 : - case /* Float_pE */7 : - case /* Float_pg */10 : - case /* Float_pG */13 : - case /* Float_ph */17 : - case /* Float_pH */20 : - return buffer_add_char(buf, /* "+" */43); - case /* Float_sf */2 : - case /* Float_se */5 : - case /* Float_sE */8 : - case /* Float_sg */11 : - case /* Float_sG */14 : - case /* Float_sh */18 : - case /* Float_sH */21 : - return buffer_add_char(buf, /* " " */32); - - } -} - -function bprint_float_fmt(buf, ign_flag, fconv, pad, prec) { - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_fconv_flag(buf, fconv); - bprint_padding(buf, pad); - bprint_precision(buf, prec); - return buffer_add_char(buf, char_of_fconv(fconv)); -} - -function string_of_formatting_lit(formatting_lit) { - if (typeof formatting_lit === "number") { - switch (formatting_lit) { - case /* Close_box */0 : - return "@]"; - case /* Close_tag */1 : - return "@}"; - case /* FFlush */2 : - return "@?"; - case /* Force_newline */3 : - return "@\n"; - case /* Flush_newline */4 : - return "@."; - case /* Escaped_at */5 : - return "@@"; - case /* Escaped_percent */6 : - return "@%"; - - } - } else { - switch (formatting_lit.tag | 0) { - case /* Break */0 : - case /* Magic_size */1 : - return formatting_lit[0]; - case /* Scan_indic */2 : - return "@" + Caml_bytes.bytes_to_string(Bytes.make(1, formatting_lit[0])); - - } - } -} - -function string_of_formatting_gen(formatting_gen) { - return formatting_gen[0][1]; -} - -function bprint_char_literal(buf, chr) { - if (chr !== 37) { - return buffer_add_char(buf, chr); - } else { - return buffer_add_string(buf, "%%"); - } -} - -function bprint_string_literal(buf, str) { - for(var i = 0 ,i_finish = str.length - 1 | 0; i <= i_finish; ++i){ - bprint_char_literal(buf, Caml_string.get(str, i)); - } - return /* () */0; -} - -function bprint_fmtty(buf, _fmtty) { - while(true) { - var fmtty = _fmtty; - if (typeof fmtty === "number") { - return /* () */0; - } else { - switch (fmtty.tag | 0) { - case /* Char_ty */0 : - buffer_add_string(buf, "%c"); - _fmtty = fmtty[0]; - continue ; - case /* String_ty */1 : - buffer_add_string(buf, "%s"); - _fmtty = fmtty[0]; - continue ; - case /* Int_ty */2 : - buffer_add_string(buf, "%i"); - _fmtty = fmtty[0]; - continue ; - case /* Int32_ty */3 : - buffer_add_string(buf, "%li"); - _fmtty = fmtty[0]; - continue ; - case /* Nativeint_ty */4 : - buffer_add_string(buf, "%ni"); - _fmtty = fmtty[0]; - continue ; - case /* Int64_ty */5 : - buffer_add_string(buf, "%Li"); - _fmtty = fmtty[0]; - continue ; - case /* Float_ty */6 : - buffer_add_string(buf, "%f"); - _fmtty = fmtty[0]; - continue ; - case /* Bool_ty */7 : - buffer_add_string(buf, "%B"); - _fmtty = fmtty[0]; - continue ; - case /* Format_arg_ty */8 : - buffer_add_string(buf, "%{"); - bprint_fmtty(buf, fmtty[0]); - buffer_add_string(buf, "%}"); - _fmtty = fmtty[1]; - continue ; - case /* Format_subst_ty */9 : - buffer_add_string(buf, "%("); - bprint_fmtty(buf, fmtty[0]); - buffer_add_string(buf, "%)"); - _fmtty = fmtty[2]; - continue ; - case /* Alpha_ty */10 : - buffer_add_string(buf, "%a"); - _fmtty = fmtty[0]; - continue ; - case /* Theta_ty */11 : - buffer_add_string(buf, "%t"); - _fmtty = fmtty[0]; - continue ; - case /* Any_ty */12 : - buffer_add_string(buf, "%?"); - _fmtty = fmtty[0]; - continue ; - case /* Reader_ty */13 : - buffer_add_string(buf, "%r"); - _fmtty = fmtty[0]; - continue ; - case /* Ignored_reader_ty */14 : - buffer_add_string(buf, "%_r"); - _fmtty = fmtty[0]; - continue ; - - } - } - }; -} - -function int_of_custom_arity(param) { - if (param) { - return 1 + int_of_custom_arity(param[0]) | 0; - } else { - return 0; - } -} - -function bprint_fmt(buf, fmt) { - var _fmt = fmt; - var _ign_flag = false; - while(true) { - var ign_flag = _ign_flag; - var fmt$1 = _fmt; - if (typeof fmt$1 === "number") { - return /* () */0; - } else { - switch (fmt$1.tag | 0) { - case /* Char */0 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "c" */99); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* Caml_char */1 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "C" */67); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* String */2 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_padding(buf, fmt$1[0]); - buffer_add_char(buf, /* "s" */115); - _ign_flag = false; - _fmt = fmt$1[1]; - continue ; - case /* Caml_string */3 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_padding(buf, fmt$1[0]); - buffer_add_char(buf, /* "S" */83); - _ign_flag = false; - _fmt = fmt$1[1]; - continue ; - case /* Int */4 : - bprint_int_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2]); - _ign_flag = false; - _fmt = fmt$1[3]; - continue ; - case /* Int32 */5 : - bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "l" */108); - _ign_flag = false; - _fmt = fmt$1[3]; - continue ; - case /* Nativeint */6 : - bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "n" */110); - _ign_flag = false; - _fmt = fmt$1[3]; - continue ; - case /* Int64 */7 : - bprint_altint_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2], /* "L" */76); - _ign_flag = false; - _fmt = fmt$1[3]; - continue ; - case /* Float */8 : - bprint_float_fmt(buf, ign_flag, fmt$1[0], fmt$1[1], fmt$1[2]); - _ign_flag = false; - _fmt = fmt$1[3]; - continue ; - case /* Bool */9 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_padding(buf, fmt$1[0]); - buffer_add_char(buf, /* "B" */66); - _ign_flag = false; - _fmt = fmt$1[1]; - continue ; - case /* Flush */10 : - buffer_add_string(buf, "%!"); - _fmt = fmt$1[0]; - continue ; - case /* String_literal */11 : - bprint_string_literal(buf, fmt$1[0]); - _fmt = fmt$1[1]; - continue ; - case /* Char_literal */12 : - bprint_char_literal(buf, fmt$1[0]); - _fmt = fmt$1[1]; - continue ; - case /* Format_arg */13 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[0]); - buffer_add_char(buf, /* "{" */123); - bprint_fmtty(buf, fmt$1[1]); - buffer_add_char(buf, /* "%" */37); - buffer_add_char(buf, /* "}" */125); - _ign_flag = false; - _fmt = fmt$1[2]; - continue ; - case /* Format_subst */14 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[0]); - buffer_add_char(buf, /* "(" */40); - bprint_fmtty(buf, fmt$1[1]); - buffer_add_char(buf, /* "%" */37); - buffer_add_char(buf, /* ")" */41); - _ign_flag = false; - _fmt = fmt$1[2]; - continue ; - case /* Alpha */15 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "a" */97); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* Theta */16 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "t" */116); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* Formatting_lit */17 : - bprint_string_literal(buf, string_of_formatting_lit(fmt$1[0])); - _fmt = fmt$1[1]; - continue ; - case /* Formatting_gen */18 : - bprint_string_literal(buf, "@{"); - bprint_string_literal(buf, string_of_formatting_gen(fmt$1[0])); - _fmt = fmt$1[1]; - continue ; - case /* Reader */19 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "r" */114); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* Scan_char_set */20 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_pad_opt(buf, fmt$1[0]); - bprint_char_set(buf, fmt$1[1]); - _ign_flag = false; - _fmt = fmt$1[2]; - continue ; - case /* Scan_get_counter */21 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, char_of_counter(fmt$1[0])); - _ign_flag = false; - _fmt = fmt$1[1]; - continue ; - case /* Scan_next_char */22 : - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - bprint_string_literal(buf, "0c"); - _ign_flag = false; - _fmt = fmt$1[0]; - continue ; - case /* Ignored_param */23 : - var match = param_format_of_ignored_format(fmt$1[0], fmt$1[1]); - _ign_flag = true; - _fmt = match[0]; - continue ; - case /* Custom */24 : - for(var _i = 1 ,_i_finish = int_of_custom_arity(fmt$1[0]); _i <= _i_finish; ++_i){ - buffer_add_char(buf, /* "%" */37); - bprint_ignored_flag(buf, ign_flag); - buffer_add_char(buf, /* "?" */63); - } - _ign_flag = false; - _fmt = fmt$1[2]; - continue ; - - } - } - }; -} - -function string_of_fmt(fmt) { - var buf = { - ind: 0, - bytes: Caml_bytes.caml_create_bytes(16) - }; - bprint_fmt(buf, fmt); - return buffer_contents(buf); -} - -function symm(param) { - if (typeof param === "number") { - return /* End_of_fmtty */0; - } else { - switch (param.tag | 0) { - case /* Char_ty */0 : - return /* Char_ty */Block.__(0, [symm(param[0])]); - case /* String_ty */1 : - return /* String_ty */Block.__(1, [symm(param[0])]); - case /* Int_ty */2 : - return /* Int_ty */Block.__(2, [symm(param[0])]); - case /* Int32_ty */3 : - return /* Int32_ty */Block.__(3, [symm(param[0])]); - case /* Nativeint_ty */4 : - return /* Nativeint_ty */Block.__(4, [symm(param[0])]); - case /* Int64_ty */5 : - return /* Int64_ty */Block.__(5, [symm(param[0])]); - case /* Float_ty */6 : - return /* Float_ty */Block.__(6, [symm(param[0])]); - case /* Bool_ty */7 : - return /* Bool_ty */Block.__(7, [symm(param[0])]); - case /* Format_arg_ty */8 : - return /* Format_arg_ty */Block.__(8, [ - param[0], - symm(param[1]) - ]); - case /* Format_subst_ty */9 : - return /* Format_subst_ty */Block.__(9, [ - param[1], - param[0], - symm(param[2]) - ]); - case /* Alpha_ty */10 : - return /* Alpha_ty */Block.__(10, [symm(param[0])]); - case /* Theta_ty */11 : - return /* Theta_ty */Block.__(11, [symm(param[0])]); - case /* Any_ty */12 : - return /* Any_ty */Block.__(12, [symm(param[0])]); - case /* Reader_ty */13 : - return /* Reader_ty */Block.__(13, [symm(param[0])]); - case /* Ignored_reader_ty */14 : - return /* Ignored_reader_ty */Block.__(14, [symm(param[0])]); - - } - } -} - -function fmtty_rel_det(param) { - if (typeof param === "number") { - return /* tuple */[ - (function (param) { - return /* Refl */0; - }), - (function (param) { - return /* Refl */0; - }), - (function (param) { - return /* Refl */0; - }), - (function (param) { - return /* Refl */0; - }) - ]; - } else { - switch (param.tag | 0) { - case /* Char_ty */0 : - var match = fmtty_rel_det(param[0]); - var af = match[1]; - var fa = match[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af, /* Refl */0); - return /* Refl */0; - }), - match[2], - match[3] - ]; - case /* String_ty */1 : - var match$1 = fmtty_rel_det(param[0]); - var af$1 = match$1[1]; - var fa$1 = match$1[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$1, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$1, /* Refl */0); - return /* Refl */0; - }), - match$1[2], - match$1[3] - ]; - case /* Int_ty */2 : - var match$2 = fmtty_rel_det(param[0]); - var af$2 = match$2[1]; - var fa$2 = match$2[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$2, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$2, /* Refl */0); - return /* Refl */0; - }), - match$2[2], - match$2[3] - ]; - case /* Int32_ty */3 : - var match$3 = fmtty_rel_det(param[0]); - var af$3 = match$3[1]; - var fa$3 = match$3[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$3, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$3, /* Refl */0); - return /* Refl */0; - }), - match$3[2], - match$3[3] - ]; - case /* Nativeint_ty */4 : - var match$4 = fmtty_rel_det(param[0]); - var af$4 = match$4[1]; - var fa$4 = match$4[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$4, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$4, /* Refl */0); - return /* Refl */0; - }), - match$4[2], - match$4[3] - ]; - case /* Int64_ty */5 : - var match$5 = fmtty_rel_det(param[0]); - var af$5 = match$5[1]; - var fa$5 = match$5[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$5, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$5, /* Refl */0); - return /* Refl */0; - }), - match$5[2], - match$5[3] - ]; - case /* Float_ty */6 : - var match$6 = fmtty_rel_det(param[0]); - var af$6 = match$6[1]; - var fa$6 = match$6[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$6, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$6, /* Refl */0); - return /* Refl */0; - }), - match$6[2], - match$6[3] - ]; - case /* Bool_ty */7 : - var match$7 = fmtty_rel_det(param[0]); - var af$7 = match$7[1]; - var fa$7 = match$7[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$7, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$7, /* Refl */0); - return /* Refl */0; - }), - match$7[2], - match$7[3] - ]; - case /* Format_arg_ty */8 : - var match$8 = fmtty_rel_det(param[1]); - var af$8 = match$8[1]; - var fa$8 = match$8[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$8, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$8, /* Refl */0); - return /* Refl */0; - }), - match$8[2], - match$8[3] - ]; - case /* Format_subst_ty */9 : - var match$9 = fmtty_rel_det(param[2]); - var de = match$9[3]; - var ed = match$9[2]; - var af$9 = match$9[1]; - var fa$9 = match$9[0]; - var ty = trans(symm(param[0]), param[1]); - var match$10 = fmtty_rel_det(ty); - var jd = match$10[3]; - var dj = match$10[2]; - var ga = match$10[1]; - var ag = match$10[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$9, /* Refl */0); - Curry._1(ag, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(ga, /* Refl */0); - Curry._1(af$9, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(ed, /* Refl */0); - Curry._1(dj, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(jd, /* Refl */0); - Curry._1(de, /* Refl */0); - return /* Refl */0; - }) - ]; - case /* Alpha_ty */10 : - var match$11 = fmtty_rel_det(param[0]); - var af$10 = match$11[1]; - var fa$10 = match$11[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$10, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$10, /* Refl */0); - return /* Refl */0; - }), - match$11[2], - match$11[3] - ]; - case /* Theta_ty */11 : - var match$12 = fmtty_rel_det(param[0]); - var af$11 = match$12[1]; - var fa$11 = match$12[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$11, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$11, /* Refl */0); - return /* Refl */0; - }), - match$12[2], - match$12[3] - ]; - case /* Any_ty */12 : - var match$13 = fmtty_rel_det(param[0]); - var af$12 = match$13[1]; - var fa$12 = match$13[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$12, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$12, /* Refl */0); - return /* Refl */0; - }), - match$13[2], - match$13[3] - ]; - case /* Reader_ty */13 : - var match$14 = fmtty_rel_det(param[0]); - var de$1 = match$14[3]; - var ed$1 = match$14[2]; - var af$13 = match$14[1]; - var fa$13 = match$14[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$13, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$13, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(ed$1, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(de$1, /* Refl */0); - return /* Refl */0; - }) - ]; - case /* Ignored_reader_ty */14 : - var match$15 = fmtty_rel_det(param[0]); - var de$2 = match$15[3]; - var ed$2 = match$15[2]; - var af$14 = match$15[1]; - var fa$14 = match$15[0]; - return /* tuple */[ - (function (param) { - Curry._1(fa$14, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(af$14, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(ed$2, /* Refl */0); - return /* Refl */0; - }), - (function (param) { - Curry._1(de$2, /* Refl */0); - return /* Refl */0; - }) - ]; - - } - } -} - -function trans(ty1, ty2) { - var exit = 0; - if (typeof ty1 === "number") { - if (typeof ty2 === "number") { - return /* End_of_fmtty */0; - } else { - switch (ty2.tag | 0) { - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 846, - 23 - ] - ]; - } - } - } else { - switch (ty1.tag | 0) { - case /* Char_ty */0 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Char_ty */0 : - return /* Char_ty */Block.__(0, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* String_ty */1 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* String_ty */1 : - return /* String_ty */Block.__(1, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Int_ty */2 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Int_ty */2 : - return /* Int_ty */Block.__(2, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Int32_ty */3 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Int32_ty */3 : - return /* Int32_ty */Block.__(3, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Nativeint_ty */4 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Nativeint_ty */4 : - return /* Nativeint_ty */Block.__(4, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Int64_ty */5 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Int64_ty */5 : - return /* Int64_ty */Block.__(5, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Float_ty */6 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Float_ty */6 : - return /* Float_ty */Block.__(6, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Bool_ty */7 : - if (typeof ty2 === "number") { - exit = 8; - } else { - switch (ty2.tag | 0) { - case /* Bool_ty */7 : - return /* Bool_ty */Block.__(7, [trans(ty1[0], ty2[0])]); - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - exit = 7; - break; - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - - } - } - break; - case /* Format_arg_ty */8 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 832, - 26 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Format_arg_ty */8 : - return /* Format_arg_ty */Block.__(8, [ - trans(ty1[0], ty2[0]), - trans(ty1[1], ty2[1]) - ]); - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 832, - 26 - ] - ]; - } - } - break; - case /* Format_subst_ty */9 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 842, - 28 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Format_arg_ty */8 : - exit = 6; - break; - case /* Format_subst_ty */9 : - var ty = trans(symm(ty1[1]), ty2[0]); - var match = fmtty_rel_det(ty); - Curry._1(match[1], /* Refl */0); - Curry._1(match[3], /* Refl */0); - return /* Format_subst_ty */Block.__(9, [ - ty1[0], - ty2[1], - trans(ty1[2], ty2[2]) - ]); - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - exit = 5; - break; - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 842, - 28 - ] - ]; - } - } - break; - case /* Alpha_ty */10 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 810, - 21 - ] - ]; - } else if (ty2.tag === /* Alpha_ty */10) { - return /* Alpha_ty */Block.__(10, [trans(ty1[0], ty2[0])]); - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 810, - 21 - ] - ]; - } - case /* Theta_ty */11 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 814, - 21 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - return /* Theta_ty */Block.__(11, [trans(ty1[0], ty2[0])]); - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 814, - 21 - ] - ]; - } - } - break; - case /* Any_ty */12 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 818, - 19 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - return /* Any_ty */Block.__(12, [trans(ty1[0], ty2[0])]); - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 818, - 19 - ] - ]; - } - } - break; - case /* Reader_ty */13 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 822, - 22 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - return /* Reader_ty */Block.__(13, [trans(ty1[0], ty2[0])]); - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 822, - 22 - ] - ]; - } - } - break; - case /* Ignored_reader_ty */14 : - if (typeof ty2 === "number") { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 827, - 30 - ] - ]; - } else { - switch (ty2.tag | 0) { - case /* Alpha_ty */10 : - exit = 1; - break; - case /* Theta_ty */11 : - exit = 2; - break; - case /* Any_ty */12 : - exit = 3; - break; - case /* Reader_ty */13 : - exit = 4; - break; - case /* Ignored_reader_ty */14 : - return /* Ignored_reader_ty */Block.__(14, [trans(ty1[0], ty2[0])]); - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 827, - 30 - ] - ]; - } - } - break; - - } - } - switch (exit) { - case 1 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 811, - 21 - ] - ]; - case 2 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 815, - 21 - ] - ]; - case 3 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 819, - 19 - ] - ]; - case 4 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 823, - 22 - ] - ]; - case 5 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 828, - 30 - ] - ]; - case 6 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 833, - 26 - ] - ]; - case 7 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 843, - 28 - ] - ]; - case 8 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 847, - 23 - ] - ]; - - } -} - -function fmtty_of_formatting_gen(formatting_gen) { - return fmtty_of_fmt(formatting_gen[0][0]); -} - -function fmtty_of_fmt(_fmtty) { - while(true) { - var fmtty = _fmtty; - if (typeof fmtty === "number") { - return /* End_of_fmtty */0; - } else { - switch (fmtty.tag | 0) { - case /* String */2 : - case /* Caml_string */3 : - break; - case /* Int */4 : - var ty_rest = fmtty_of_fmt(fmtty[3]); - var prec_ty = fmtty_of_precision_fmtty(fmtty[2], /* Int_ty */Block.__(2, [ty_rest])); - return fmtty_of_padding_fmtty(fmtty[1], prec_ty); - case /* Int32 */5 : - var ty_rest$1 = fmtty_of_fmt(fmtty[3]); - var prec_ty$1 = fmtty_of_precision_fmtty(fmtty[2], /* Int32_ty */Block.__(3, [ty_rest$1])); - return fmtty_of_padding_fmtty(fmtty[1], prec_ty$1); - case /* Nativeint */6 : - var ty_rest$2 = fmtty_of_fmt(fmtty[3]); - var prec_ty$2 = fmtty_of_precision_fmtty(fmtty[2], /* Nativeint_ty */Block.__(4, [ty_rest$2])); - return fmtty_of_padding_fmtty(fmtty[1], prec_ty$2); - case /* Int64 */7 : - var ty_rest$3 = fmtty_of_fmt(fmtty[3]); - var prec_ty$3 = fmtty_of_precision_fmtty(fmtty[2], /* Int64_ty */Block.__(5, [ty_rest$3])); - return fmtty_of_padding_fmtty(fmtty[1], prec_ty$3); - case /* Float */8 : - var ty_rest$4 = fmtty_of_fmt(fmtty[3]); - var prec_ty$4 = fmtty_of_precision_fmtty(fmtty[2], /* Float_ty */Block.__(6, [ty_rest$4])); - return fmtty_of_padding_fmtty(fmtty[1], prec_ty$4); - case /* Bool */9 : - return fmtty_of_padding_fmtty(fmtty[0], /* Bool_ty */Block.__(7, [fmtty_of_fmt(fmtty[1])])); - case /* Flush */10 : - _fmtty = fmtty[0]; - continue ; - case /* Format_arg */13 : - return /* Format_arg_ty */Block.__(8, [ - fmtty[1], - fmtty_of_fmt(fmtty[2]) - ]); - case /* Format_subst */14 : - var ty = fmtty[1]; - return /* Format_subst_ty */Block.__(9, [ - ty, - ty, - fmtty_of_fmt(fmtty[2]) - ]); - case /* Alpha */15 : - return /* Alpha_ty */Block.__(10, [fmtty_of_fmt(fmtty[0])]); - case /* Theta */16 : - return /* Theta_ty */Block.__(11, [fmtty_of_fmt(fmtty[0])]); - case /* String_literal */11 : - case /* Char_literal */12 : - case /* Formatting_lit */17 : - _fmtty = fmtty[1]; - continue ; - case /* Formatting_gen */18 : - return CamlinternalFormatBasics.concat_fmtty(fmtty_of_formatting_gen(fmtty[0]), fmtty_of_fmt(fmtty[1])); - case /* Reader */19 : - return /* Reader_ty */Block.__(13, [fmtty_of_fmt(fmtty[0])]); - case /* Scan_char_set */20 : - return /* String_ty */Block.__(1, [fmtty_of_fmt(fmtty[2])]); - case /* Scan_get_counter */21 : - return /* Int_ty */Block.__(2, [fmtty_of_fmt(fmtty[1])]); - case /* Ignored_param */23 : - var ign = fmtty[0]; - var fmt = fmtty[1]; - if (typeof ign === "number") { - if (ign === /* Ignored_reader */2) { - return /* Ignored_reader_ty */Block.__(14, [fmtty_of_fmt(fmt)]); - } else { - return fmtty_of_fmt(fmt); - } - } else if (ign.tag === /* Ignored_format_subst */9) { - return CamlinternalFormatBasics.concat_fmtty(ign[1], fmtty_of_fmt(fmt)); - } else { - return fmtty_of_fmt(fmt); - } - case /* Custom */24 : - return fmtty_of_custom(fmtty[0], fmtty_of_fmt(fmtty[2])); - default: - return /* Char_ty */Block.__(0, [fmtty_of_fmt(fmtty[0])]); - } - } - return fmtty_of_padding_fmtty(fmtty[0], /* String_ty */Block.__(1, [fmtty_of_fmt(fmtty[1])])); - }; -} - -function fmtty_of_custom(arity, fmtty) { - if (arity) { - return /* Any_ty */Block.__(12, [fmtty_of_custom(arity[0], fmtty)]); - } else { - return fmtty; - } -} - -function fmtty_of_padding_fmtty(pad, fmtty) { - if (typeof pad === "number" || !pad.tag) { - return fmtty; - } else { - return /* Int_ty */Block.__(2, [fmtty]); - } -} - -function fmtty_of_precision_fmtty(prec, fmtty) { - if (typeof prec === "number" && prec !== 0) { - return /* Int_ty */Block.__(2, [fmtty]); - } else { - return fmtty; - } -} - -var Type_mismatch = Caml_exceptions.create("CamlinternalFormat.Type_mismatch"); - -function type_padding(pad, fmtty) { - if (typeof pad === "number") { - return /* Padding_fmtty_EBB */[ - /* No_padding */0, - fmtty - ]; - } else if (pad.tag) { - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Int_ty */2) { - return /* Padding_fmtty_EBB */[ - /* Arg_padding */Block.__(1, [pad[0]]), - fmtty[0] - ]; - } else { - throw Type_mismatch; - } - } else { - return /* Padding_fmtty_EBB */[ - /* Lit_padding */Block.__(0, [ - pad[0], - pad[1] - ]), - fmtty - ]; - } -} - -function type_padprec(pad, prec, fmtty) { - var match = type_padding(pad, fmtty); - if (typeof prec === "number") { - if (prec !== 0) { - var match$1 = match[1]; - if (typeof match$1 === "number") { - throw Type_mismatch; - } else if (match$1.tag === /* Int_ty */2) { - return /* Padprec_fmtty_EBB */[ - match[0], - /* Arg_precision */1, - match$1[0] - ]; - } else { - throw Type_mismatch; - } - } else { - return /* Padprec_fmtty_EBB */[ - match[0], - /* No_precision */0, - match[1] - ]; - } - } else { - return /* Padprec_fmtty_EBB */[ - match[0], - /* Lit_precision */[prec[0]], - match[1] - ]; - } -} - -function type_ignored_format_substitution(sub_fmtty, fmt, fmtty) { - if (typeof sub_fmtty === "number") { - return /* Fmtty_fmt_EBB */[ - /* End_of_fmtty */0, - type_format_gen(fmt, fmtty) - ]; - } else { - switch (sub_fmtty.tag | 0) { - case /* Char_ty */0 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag) { - throw Type_mismatch; - } else { - var match = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Char_ty */Block.__(0, [match[0]]), - match[1] - ]; - } - case /* String_ty */1 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* String_ty */1) { - var match$1 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* String_ty */Block.__(1, [match$1[0]]), - match$1[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int_ty */2 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Int_ty */2) { - var match$2 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Int_ty */Block.__(2, [match$2[0]]), - match$2[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int32_ty */3 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Int32_ty */3) { - var match$3 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Int32_ty */Block.__(3, [match$3[0]]), - match$3[1] - ]; - } else { - throw Type_mismatch; - } - case /* Nativeint_ty */4 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Nativeint_ty */4) { - var match$4 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Nativeint_ty */Block.__(4, [match$4[0]]), - match$4[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int64_ty */5 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Int64_ty */5) { - var match$5 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Int64_ty */Block.__(5, [match$5[0]]), - match$5[1] - ]; - } else { - throw Type_mismatch; - } - case /* Float_ty */6 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Float_ty */6) { - var match$6 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Float_ty */Block.__(6, [match$6[0]]), - match$6[1] - ]; - } else { - throw Type_mismatch; - } - case /* Bool_ty */7 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Bool_ty */7) { - var match$7 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Bool_ty */Block.__(7, [match$7[0]]), - match$7[1] - ]; - } else { - throw Type_mismatch; - } - case /* Format_arg_ty */8 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Format_arg_ty */8) { - var sub2_fmtty$prime = fmtty[0]; - if (Caml_obj.caml_notequal(/* Fmtty_EBB */[sub_fmtty[0]], /* Fmtty_EBB */[sub2_fmtty$prime])) { - throw Type_mismatch; - } - var match$8 = type_ignored_format_substitution(sub_fmtty[1], fmt, fmtty[1]); - return /* Fmtty_fmt_EBB */[ - /* Format_arg_ty */Block.__(8, [ - sub2_fmtty$prime, - match$8[0] - ]), - match$8[1] - ]; - } else { - throw Type_mismatch; - } - case /* Format_subst_ty */9 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Format_subst_ty */9) { - var sub2_fmtty$prime$1 = fmtty[1]; - var sub1_fmtty$prime = fmtty[0]; - if (Caml_obj.caml_notequal(/* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(sub_fmtty[0])], /* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(sub1_fmtty$prime)])) { - throw Type_mismatch; - } - if (Caml_obj.caml_notequal(/* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(sub_fmtty[1])], /* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(sub2_fmtty$prime$1)])) { - throw Type_mismatch; - } - var sub_fmtty$prime = trans(symm(sub1_fmtty$prime), sub2_fmtty$prime$1); - var match$9 = fmtty_rel_det(sub_fmtty$prime); - Curry._1(match$9[1], /* Refl */0); - Curry._1(match$9[3], /* Refl */0); - var match$10 = type_ignored_format_substitution(CamlinternalFormatBasics.erase_rel(sub_fmtty[2]), fmt, fmtty[2]); - return /* Fmtty_fmt_EBB */[ - /* Format_subst_ty */Block.__(9, [ - sub1_fmtty$prime, - sub2_fmtty$prime$1, - symm(match$10[0]) - ]), - match$10[1] - ]; - } else { - throw Type_mismatch; - } - case /* Alpha_ty */10 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Alpha_ty */10) { - var match$11 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Alpha_ty */Block.__(10, [match$11[0]]), - match$11[1] - ]; - } else { - throw Type_mismatch; - } - case /* Theta_ty */11 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Theta_ty */11) { - var match$12 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Theta_ty */Block.__(11, [match$12[0]]), - match$12[1] - ]; - } else { - throw Type_mismatch; - } - case /* Any_ty */12 : - throw Type_mismatch; - case /* Reader_ty */13 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Reader_ty */13) { - var match$13 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Reader_ty */Block.__(13, [match$13[0]]), - match$13[1] - ]; - } else { - throw Type_mismatch; - } - case /* Ignored_reader_ty */14 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Ignored_reader_ty */14) { - var match$14 = type_ignored_format_substitution(sub_fmtty[0], fmt, fmtty[0]); - return /* Fmtty_fmt_EBB */[ - /* Ignored_reader_ty */Block.__(14, [match$14[0]]), - match$14[1] - ]; - } else { - throw Type_mismatch; - } - - } - } -} - -function type_format_gen(fmt, fmtty) { - if (typeof fmt === "number") { - return /* Fmt_fmtty_EBB */[ - /* End_of_format */0, - fmtty - ]; - } else { - switch (fmt.tag | 0) { - case /* Char */0 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag) { - throw Type_mismatch; - } else { - var match = type_format_gen(fmt[0], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Char */Block.__(0, [match[0]]), - match[1] - ]; - } - case /* Caml_char */1 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag) { - throw Type_mismatch; - } else { - var match$1 = type_format_gen(fmt[0], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Caml_char */Block.__(1, [match$1[0]]), - match$1[1] - ]; - } - case /* String */2 : - var match$2 = type_padding(fmt[0], fmtty); - var match$3 = match$2[1]; - if (typeof match$3 === "number") { - throw Type_mismatch; - } else if (match$3.tag === /* String_ty */1) { - var match$4 = type_format_gen(fmt[1], match$3[0]); - return /* Fmt_fmtty_EBB */[ - /* String */Block.__(2, [ - match$2[0], - match$4[0] - ]), - match$4[1] - ]; - } else { - throw Type_mismatch; - } - case /* Caml_string */3 : - var match$5 = type_padding(fmt[0], fmtty); - var match$6 = match$5[1]; - if (typeof match$6 === "number") { - throw Type_mismatch; - } else if (match$6.tag === /* String_ty */1) { - var match$7 = type_format_gen(fmt[1], match$6[0]); - return /* Fmt_fmtty_EBB */[ - /* Caml_string */Block.__(3, [ - match$5[0], - match$7[0] - ]), - match$7[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int */4 : - var match$8 = type_padprec(fmt[1], fmt[2], fmtty); - var match$9 = match$8[2]; - if (typeof match$9 === "number") { - throw Type_mismatch; - } else if (match$9.tag === /* Int_ty */2) { - var match$10 = type_format_gen(fmt[3], match$9[0]); - return /* Fmt_fmtty_EBB */[ - /* Int */Block.__(4, [ - fmt[0], - match$8[0], - match$8[1], - match$10[0] - ]), - match$10[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int32 */5 : - var match$11 = type_padprec(fmt[1], fmt[2], fmtty); - var match$12 = match$11[2]; - if (typeof match$12 === "number") { - throw Type_mismatch; - } else if (match$12.tag === /* Int32_ty */3) { - var match$13 = type_format_gen(fmt[3], match$12[0]); - return /* Fmt_fmtty_EBB */[ - /* Int32 */Block.__(5, [ - fmt[0], - match$11[0], - match$11[1], - match$13[0] - ]), - match$13[1] - ]; - } else { - throw Type_mismatch; - } - case /* Nativeint */6 : - var match$14 = type_padprec(fmt[1], fmt[2], fmtty); - var match$15 = match$14[2]; - if (typeof match$15 === "number") { - throw Type_mismatch; - } else if (match$15.tag === /* Nativeint_ty */4) { - var match$16 = type_format_gen(fmt[3], match$15[0]); - return /* Fmt_fmtty_EBB */[ - /* Nativeint */Block.__(6, [ - fmt[0], - match$14[0], - match$14[1], - match$16[0] - ]), - match$16[1] - ]; - } else { - throw Type_mismatch; - } - case /* Int64 */7 : - var match$17 = type_padprec(fmt[1], fmt[2], fmtty); - var match$18 = match$17[2]; - if (typeof match$18 === "number") { - throw Type_mismatch; - } else if (match$18.tag === /* Int64_ty */5) { - var match$19 = type_format_gen(fmt[3], match$18[0]); - return /* Fmt_fmtty_EBB */[ - /* Int64 */Block.__(7, [ - fmt[0], - match$17[0], - match$17[1], - match$19[0] - ]), - match$19[1] - ]; - } else { - throw Type_mismatch; - } - case /* Float */8 : - var match$20 = type_padprec(fmt[1], fmt[2], fmtty); - var match$21 = match$20[2]; - if (typeof match$21 === "number") { - throw Type_mismatch; - } else if (match$21.tag === /* Float_ty */6) { - var match$22 = type_format_gen(fmt[3], match$21[0]); - return /* Fmt_fmtty_EBB */[ - /* Float */Block.__(8, [ - fmt[0], - match$20[0], - match$20[1], - match$22[0] - ]), - match$22[1] - ]; - } else { - throw Type_mismatch; - } - case /* Bool */9 : - var match$23 = type_padding(fmt[0], fmtty); - var match$24 = match$23[1]; - if (typeof match$24 === "number") { - throw Type_mismatch; - } else if (match$24.tag === /* Bool_ty */7) { - var match$25 = type_format_gen(fmt[1], match$24[0]); - return /* Fmt_fmtty_EBB */[ - /* Bool */Block.__(9, [ - match$23[0], - match$25[0] - ]), - match$25[1] - ]; - } else { - throw Type_mismatch; - } - case /* Flush */10 : - var match$26 = type_format_gen(fmt[0], fmtty); - return /* Fmt_fmtty_EBB */[ - /* Flush */Block.__(10, [match$26[0]]), - match$26[1] - ]; - case /* String_literal */11 : - var match$27 = type_format_gen(fmt[1], fmtty); - return /* Fmt_fmtty_EBB */[ - /* String_literal */Block.__(11, [ - fmt[0], - match$27[0] - ]), - match$27[1] - ]; - case /* Char_literal */12 : - var match$28 = type_format_gen(fmt[1], fmtty); - return /* Fmt_fmtty_EBB */[ - /* Char_literal */Block.__(12, [ - fmt[0], - match$28[0] - ]), - match$28[1] - ]; - case /* Format_arg */13 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Format_arg_ty */8) { - var sub_fmtty$prime = fmtty[0]; - if (Caml_obj.caml_notequal(/* Fmtty_EBB */[fmt[1]], /* Fmtty_EBB */[sub_fmtty$prime])) { - throw Type_mismatch; - } - var match$29 = type_format_gen(fmt[2], fmtty[1]); - return /* Fmt_fmtty_EBB */[ - /* Format_arg */Block.__(13, [ - fmt[0], - sub_fmtty$prime, - match$29[0] - ]), - match$29[1] - ]; - } else { - throw Type_mismatch; - } - case /* Format_subst */14 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Format_subst_ty */9) { - var sub_fmtty1 = fmtty[0]; - if (Caml_obj.caml_notequal(/* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(fmt[1])], /* Fmtty_EBB */[CamlinternalFormatBasics.erase_rel(sub_fmtty1)])) { - throw Type_mismatch; - } - var match$30 = type_format_gen(fmt[2], CamlinternalFormatBasics.erase_rel(fmtty[2])); - return /* Fmt_fmtty_EBB */[ - /* Format_subst */Block.__(14, [ - fmt[0], - sub_fmtty1, - match$30[0] - ]), - match$30[1] - ]; - } else { - throw Type_mismatch; - } - case /* Alpha */15 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Alpha_ty */10) { - var match$31 = type_format_gen(fmt[0], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Alpha */Block.__(15, [match$31[0]]), - match$31[1] - ]; - } else { - throw Type_mismatch; - } - case /* Theta */16 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Theta_ty */11) { - var match$32 = type_format_gen(fmt[0], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Theta */Block.__(16, [match$32[0]]), - match$32[1] - ]; - } else { - throw Type_mismatch; - } - case /* Formatting_lit */17 : - var match$33 = type_format_gen(fmt[1], fmtty); - return /* Fmt_fmtty_EBB */[ - /* Formatting_lit */Block.__(17, [ - fmt[0], - match$33[0] - ]), - match$33[1] - ]; - case /* Formatting_gen */18 : - var formatting_gen = fmt[0]; - var fmt0 = fmt[1]; - var fmtty0 = fmtty; - if (formatting_gen.tag) { - var match$34 = formatting_gen[0]; - var match$35 = type_format_gen(match$34[0], fmtty0); - var match$36 = type_format_gen(fmt0, match$35[1]); - return /* Fmt_fmtty_EBB */[ - /* Formatting_gen */Block.__(18, [ - /* Open_box */Block.__(1, [/* Format */[ - match$35[0], - match$34[1] - ]]), - match$36[0] - ]), - match$36[1] - ]; - } else { - var match$37 = formatting_gen[0]; - var match$38 = type_format_gen(match$37[0], fmtty0); - var match$39 = type_format_gen(fmt0, match$38[1]); - return /* Fmt_fmtty_EBB */[ - /* Formatting_gen */Block.__(18, [ - /* Open_tag */Block.__(0, [/* Format */[ - match$38[0], - match$37[1] - ]]), - match$39[0] - ]), - match$39[1] - ]; - } - case /* Reader */19 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Reader_ty */13) { - var match$40 = type_format_gen(fmt[0], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Reader */Block.__(19, [match$40[0]]), - match$40[1] - ]; - } else { - throw Type_mismatch; - } - case /* Scan_char_set */20 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* String_ty */1) { - var match$41 = type_format_gen(fmt[2], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Scan_char_set */Block.__(20, [ - fmt[0], - fmt[1], - match$41[0] - ]), - match$41[1] - ]; - } else { - throw Type_mismatch; - } - case /* Scan_get_counter */21 : - if (typeof fmtty === "number") { - throw Type_mismatch; - } else if (fmtty.tag === /* Int_ty */2) { - var match$42 = type_format_gen(fmt[1], fmtty[0]); - return /* Fmt_fmtty_EBB */[ - /* Scan_get_counter */Block.__(21, [ - fmt[0], - match$42[0] - ]), - match$42[1] - ]; - } else { - throw Type_mismatch; - } - case /* Ignored_param */23 : - var ign = fmt[0]; - var fmt$1 = fmt[1]; - var fmtty$1 = fmtty; - if (typeof ign === "number") { - if (ign === /* Ignored_reader */2) { - if (typeof fmtty$1 === "number") { - throw Type_mismatch; - } else if (fmtty$1.tag === /* Ignored_reader_ty */14) { - var match$43 = type_format_gen(fmt$1, fmtty$1[0]); - return /* Fmt_fmtty_EBB */[ - /* Ignored_param */Block.__(23, [ - /* Ignored_reader */2, - match$43[0] - ]), - match$43[1] - ]; - } else { - throw Type_mismatch; - } - } else { - return type_ignored_param_one(ign, fmt$1, fmtty$1); - } - } else { - switch (ign.tag | 0) { - case /* Ignored_format_arg */8 : - return type_ignored_param_one(/* Ignored_format_arg */Block.__(8, [ - ign[0], - ign[1] - ]), fmt$1, fmtty$1); - case /* Ignored_format_subst */9 : - var match$44 = type_ignored_format_substitution(ign[1], fmt$1, fmtty$1); - var match$45 = match$44[1]; - return /* Fmt_fmtty_EBB */[ - /* Ignored_param */Block.__(23, [ - /* Ignored_format_subst */Block.__(9, [ - ign[0], - match$44[0] - ]), - match$45[0] - ]), - match$45[1] - ]; - default: - return type_ignored_param_one(ign, fmt$1, fmtty$1); - } - } - case /* Scan_next_char */22 : - case /* Custom */24 : - throw Type_mismatch; - - } - } -} - -function type_ignored_param_one(ign, fmt, fmtty) { - var match = type_format_gen(fmt, fmtty); - return /* Fmt_fmtty_EBB */[ - /* Ignored_param */Block.__(23, [ - ign, - match[0] - ]), - match[1] - ]; -} - -function type_format(fmt, fmtty) { - var match = type_format_gen(fmt, fmtty); - if (typeof match[1] === "number") { - return match[0]; - } else { - throw Type_mismatch; - } -} - -function recast(fmt, fmtty) { - return type_format(fmt, CamlinternalFormatBasics.erase_rel(symm(fmtty))); -} - -function fix_padding(padty, width, str) { - var len = str.length; - var width$1 = Pervasives.abs(width); - var padty$1 = width < 0 ? /* Left */0 : padty; - if (width$1 <= len) { - return str; - } else { - var res = Bytes.make(width$1, padty$1 === /* Zeros */2 ? /* "0" */48 : /* " " */32); - switch (padty$1) { - case /* Left */0 : - $$String.blit(str, 0, res, 0, len); - break; - case /* Right */1 : - $$String.blit(str, 0, res, width$1 - len | 0, len); - break; - case /* Zeros */2 : - if (len > 0 && (Caml_string.get(str, 0) === /* "+" */43 || Caml_string.get(str, 0) === /* "-" */45 || Caml_string.get(str, 0) === /* " " */32)) { - res[0] = Caml_string.get(str, 0); - $$String.blit(str, 1, res, (width$1 - len | 0) + 1 | 0, len - 1 | 0); - } else if (len > 1 && Caml_string.get(str, 0) === /* "0" */48 && (Caml_string.get(str, 1) === /* "x" */120 || Caml_string.get(str, 1) === /* "X" */88)) { - res[1] = Caml_string.get(str, 1); - $$String.blit(str, 2, res, (width$1 - len | 0) + 2 | 0, len - 2 | 0); - } else { - $$String.blit(str, 0, res, width$1 - len | 0, len); - } - break; - - } - return Caml_bytes.bytes_to_string(res); - } -} - -function fix_int_precision(prec, str) { - var prec$1 = Pervasives.abs(prec); - var len = str.length; - var c = Caml_string.get(str, 0); - var exit = 0; - if (c >= 58) { - if (c >= 71) { - if (c > 102 || c < 97) { - return str; - } else { - exit = 2; - } - } else if (c >= 65) { - exit = 2; - } else { - return str; - } - } else if (c !== 32) { - if (c >= 43) { - switch (c - 43 | 0) { - case 0 : - case 2 : - exit = 1; - break; - case 1 : - case 3 : - case 4 : - return str; - case 5 : - if ((prec$1 + 2 | 0) > len && len > 1 && (Caml_string.get(str, 1) === /* "x" */120 || Caml_string.get(str, 1) === /* "X" */88)) { - var res = Bytes.make(prec$1 + 2 | 0, /* "0" */48); - res[1] = Caml_string.get(str, 1); - $$String.blit(str, 2, res, (prec$1 - len | 0) + 4 | 0, len - 2 | 0); - return Caml_bytes.bytes_to_string(res); - } else { - exit = 2; - } - break; - case 6 : - case 7 : - case 8 : - case 9 : - case 10 : - case 11 : - case 12 : - case 13 : - case 14 : - exit = 2; - break; - - } - } else { - return str; - } - } else { - exit = 1; - } - switch (exit) { - case 1 : - if ((prec$1 + 1 | 0) > len) { - var res$1 = Bytes.make(prec$1 + 1 | 0, /* "0" */48); - res$1[0] = c; - $$String.blit(str, 1, res$1, (prec$1 - len | 0) + 2 | 0, len - 1 | 0); - return Caml_bytes.bytes_to_string(res$1); - } else { - return str; - } - case 2 : - if (prec$1 > len) { - var res$2 = Bytes.make(prec$1, /* "0" */48); - $$String.blit(str, 0, res$2, prec$1 - len | 0, len); - return Caml_bytes.bytes_to_string(res$2); - } else { - return str; - } - - } -} - -function string_to_caml_string(str) { - var str$1 = $$String.escaped(str); - var l = str$1.length; - var res = Bytes.make(l + 2 | 0, /* "\"" */34); - Caml_bytes.caml_blit_string(str$1, 0, res, 1, l); - return Caml_bytes.bytes_to_string(res); -} - -function format_of_iconv(param) { - switch (param) { - case /* Int_d */0 : - return "%d"; - case /* Int_pd */1 : - return "%+d"; - case /* Int_sd */2 : - return "% d"; - case /* Int_i */3 : - return "%i"; - case /* Int_pi */4 : - return "%+i"; - case /* Int_si */5 : - return "% i"; - case /* Int_x */6 : - return "%x"; - case /* Int_Cx */7 : - return "%#x"; - case /* Int_X */8 : - return "%X"; - case /* Int_CX */9 : - return "%#X"; - case /* Int_o */10 : - return "%o"; - case /* Int_Co */11 : - return "%#o"; - case /* Int_u */12 : - return "%u"; - - } -} - -function format_of_iconvL(param) { - switch (param) { - case /* Int_d */0 : - return "%Ld"; - case /* Int_pd */1 : - return "%+Ld"; - case /* Int_sd */2 : - return "% Ld"; - case /* Int_i */3 : - return "%Li"; - case /* Int_pi */4 : - return "%+Li"; - case /* Int_si */5 : - return "% Li"; - case /* Int_x */6 : - return "%Lx"; - case /* Int_Cx */7 : - return "%#Lx"; - case /* Int_X */8 : - return "%LX"; - case /* Int_CX */9 : - return "%#LX"; - case /* Int_o */10 : - return "%Lo"; - case /* Int_Co */11 : - return "%#Lo"; - case /* Int_u */12 : - return "%Lu"; - - } -} - -function format_of_iconvl(param) { - switch (param) { - case /* Int_d */0 : - return "%ld"; - case /* Int_pd */1 : - return "%+ld"; - case /* Int_sd */2 : - return "% ld"; - case /* Int_i */3 : - return "%li"; - case /* Int_pi */4 : - return "%+li"; - case /* Int_si */5 : - return "% li"; - case /* Int_x */6 : - return "%lx"; - case /* Int_Cx */7 : - return "%#lx"; - case /* Int_X */8 : - return "%lX"; - case /* Int_CX */9 : - return "%#lX"; - case /* Int_o */10 : - return "%lo"; - case /* Int_Co */11 : - return "%#lo"; - case /* Int_u */12 : - return "%lu"; - - } -} - -function format_of_iconvn(param) { - switch (param) { - case /* Int_d */0 : - return "%nd"; - case /* Int_pd */1 : - return "%+nd"; - case /* Int_sd */2 : - return "% nd"; - case /* Int_i */3 : - return "%ni"; - case /* Int_pi */4 : - return "%+ni"; - case /* Int_si */5 : - return "% ni"; - case /* Int_x */6 : - return "%nx"; - case /* Int_Cx */7 : - return "%#nx"; - case /* Int_X */8 : - return "%nX"; - case /* Int_CX */9 : - return "%#nX"; - case /* Int_o */10 : - return "%no"; - case /* Int_Co */11 : - return "%#no"; - case /* Int_u */12 : - return "%nu"; - - } -} - -function format_of_fconv(fconv, prec) { - if (fconv === /* Float_F */15) { - return "%.12g"; - } else { - var prec$1 = Pervasives.abs(prec); - var symb = char_of_fconv(fconv); - var buf = { - ind: 0, - bytes: Caml_bytes.caml_create_bytes(16) - }; - buffer_add_char(buf, /* "%" */37); - bprint_fconv_flag(buf, fconv); - buffer_add_char(buf, /* "." */46); - buffer_add_string(buf, String(prec$1)); - buffer_add_char(buf, symb); - return buffer_contents(buf); - } -} - -function convert_int(iconv, n) { - return Caml_format.caml_format_int(format_of_iconv(iconv), n); -} - -function convert_int32(iconv, n) { - return Caml_format.caml_int32_format(format_of_iconvl(iconv), n); -} - -function convert_nativeint(iconv, n) { - return Caml_format.caml_nativeint_format(format_of_iconvn(iconv), n); -} - -function convert_int64(iconv, n) { - return Caml_format.caml_int64_format(format_of_iconvL(iconv), n); -} - -function convert_float(fconv, prec, x) { - if (fconv >= 16) { - var sign; - if (fconv >= 17) { - switch (fconv - 17 | 0) { - case /* Float_sf */2 : - sign = /* "-" */45; - break; - case /* Float_f */0 : - case /* Float_e */3 : - sign = /* "+" */43; - break; - case /* Float_pf */1 : - case /* Float_pe */4 : - sign = /* " " */32; - break; - - } - } else { - sign = /* "-" */45; - } - var str = Caml_format.caml_hexstring_of_float(x, prec, sign); - if (fconv >= 19) { - return Caml_bytes.bytes_to_string(Bytes.uppercase_ascii(Caml_bytes.bytes_of_string(str))); - } else { - return str; - } - } else { - var str$1 = Caml_format.caml_format_float(format_of_fconv(fconv, prec), x); - if (fconv !== /* Float_F */15) { - return str$1; - } else { - var len = str$1.length; - var is_valid = function (_i) { - while(true) { - var i = _i; - if (i === len) { - return false; - } else { - var match = Caml_string.get(str$1, i); - var switcher = match - 46 | 0; - if (switcher > 23 || switcher < 0) { - if (switcher !== 55) { - _i = i + 1 | 0; - continue ; - } else { - return true; - } - } else if (switcher > 22 || switcher < 1) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - } - }; - }; - var match = Pervasives.classify_float(x); - if (match !== 3) { - if (match >= 4) { - return "nan"; - } else if (is_valid(0)) { - return str$1; - } else { - return str$1 + "."; - } - } else if (x < 0.0) { - return "neg_infinity"; - } else { - return "infinity"; - } - } - } -} - -function format_caml_char(c) { - var str = Char.escaped(c); - var l = str.length; - var res = Bytes.make(l + 2 | 0, /* "'" */39); - Caml_bytes.caml_blit_string(str, 0, res, 1, l); - return Caml_bytes.bytes_to_string(res); -} - -function string_of_fmtty(fmtty) { - var buf = { - ind: 0, - bytes: Caml_bytes.caml_create_bytes(16) - }; - bprint_fmtty(buf, fmtty); - return buffer_contents(buf); -} - -function make_printf(_k, o, _acc, _fmt) { - while(true) { - var fmt = _fmt; - var acc = _acc; - var k = _k; - if (typeof fmt === "number") { - return Curry._2(k, o, acc); - } else { - switch (fmt.tag | 0) { - case /* Char */0 : - var rest = fmt[0]; - return (function(k,acc,rest){ - return function (c) { - var new_acc = /* Acc_data_char */Block.__(5, [ - acc, - c - ]); - return make_printf(k, o, new_acc, rest); - } - }(k,acc,rest)); - case /* Caml_char */1 : - var rest$1 = fmt[0]; - return (function(k,acc,rest$1){ - return function (c) { - var new_acc_001 = format_caml_char(c); - var new_acc = /* Acc_data_string */Block.__(4, [ - acc, - new_acc_001 - ]); - return make_printf(k, o, new_acc, rest$1); - } - }(k,acc,rest$1)); - case /* String */2 : - return make_padding(k, o, acc, fmt[1], fmt[0], (function (str) { - return str; - })); - case /* Caml_string */3 : - return make_padding(k, o, acc, fmt[1], fmt[0], string_to_caml_string); - case /* Int */4 : - return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int, fmt[0]); - case /* Int32 */5 : - return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int32, fmt[0]); - case /* Nativeint */6 : - return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_nativeint, fmt[0]); - case /* Int64 */7 : - return make_int_padding_precision(k, o, acc, fmt[3], fmt[1], fmt[2], convert_int64, fmt[0]); - case /* Float */8 : - var k$1 = k; - var o$1 = o; - var acc$1 = acc; - var fmt$1 = fmt[3]; - var pad = fmt[1]; - var prec = fmt[2]; - var fconv = fmt[0]; - if (typeof pad === "number") { - if (typeof prec === "number") { - if (prec !== 0) { - return (function(k$1,o$1,acc$1,fmt$1,fconv){ - return function (p, x) { - var str = convert_float(fconv, p, x); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv)); - } else { - return (function(k$1,o$1,acc$1,fmt$1,fconv){ - return function (x) { - var str = convert_float(fconv, -6, x); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv)); - } - } else { - var p = prec[0]; - return (function(k$1,o$1,acc$1,fmt$1,fconv,p){ - return function (x) { - var str = convert_float(fconv, p, x); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,p)); - } - } else if (pad.tag) { - var padty = pad[0]; - if (typeof prec === "number") { - if (prec !== 0) { - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty){ - return function (w, p, x) { - var str = fix_padding(padty, w, convert_float(fconv, p, x)); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty)); - } else { - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty){ - return function (w, x) { - var str = convert_float(fconv, -6, x); - var str$prime = fix_padding(padty, w, str); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str$prime - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty)); - } - } else { - var p$1 = prec[0]; - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty,p$1){ - return function (w, x) { - var str = fix_padding(padty, w, convert_float(fconv, p$1, x)); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty,p$1)); - } - } else { - var w = pad[1]; - var padty$1 = pad[0]; - if (typeof prec === "number") { - if (prec !== 0) { - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w){ - return function (p, x) { - var str = fix_padding(padty$1, w, convert_float(fconv, p, x)); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w)); - } else { - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w){ - return function (x) { - var str = convert_float(fconv, -6, x); - var str$prime = fix_padding(padty$1, w, str); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str$prime - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w)); - } - } else { - var p$2 = prec[0]; - return (function(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w,p$2){ - return function (x) { - var str = fix_padding(padty$1, w, convert_float(fconv, p$2, x)); - return make_printf(k$1, o$1, /* Acc_data_string */Block.__(4, [ - acc$1, - str - ]), fmt$1); - } - }(k$1,o$1,acc$1,fmt$1,fconv,padty$1,w,p$2)); - } - } - case /* Bool */9 : - return make_padding(k, o, acc, fmt[1], fmt[0], Pervasives.string_of_bool); - case /* Flush */10 : - _fmt = fmt[0]; - _acc = /* Acc_flush */Block.__(7, [acc]); - continue ; - case /* String_literal */11 : - _fmt = fmt[1]; - _acc = /* Acc_string_literal */Block.__(2, [ - acc, - fmt[0] - ]); - continue ; - case /* Char_literal */12 : - _fmt = fmt[1]; - _acc = /* Acc_char_literal */Block.__(3, [ - acc, - fmt[0] - ]); - continue ; - case /* Format_arg */13 : - var rest$2 = fmt[2]; - var ty = string_of_fmtty(fmt[1]); - return (function(k,acc,rest$2,ty){ - return function (str) { - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - ty - ]), rest$2); - } - }(k,acc,rest$2,ty)); - case /* Format_subst */14 : - var rest$3 = fmt[2]; - var fmtty = fmt[1]; - return (function(k,acc,fmtty,rest$3){ - return function (param) { - return make_printf(k, o, acc, CamlinternalFormatBasics.concat_fmt(recast(param[0], fmtty), rest$3)); - } - }(k,acc,fmtty,rest$3)); - case /* Alpha */15 : - var rest$4 = fmt[0]; - return (function(k,acc,rest$4){ - return function (f, x) { - return make_printf(k, o, /* Acc_delay */Block.__(6, [ - acc, - (function (o) { - return Curry._2(f, o, x); - }) - ]), rest$4); - } - }(k,acc,rest$4)); - case /* Theta */16 : - var rest$5 = fmt[0]; - return (function(k,acc,rest$5){ - return function (f) { - return make_printf(k, o, /* Acc_delay */Block.__(6, [ - acc, - f - ]), rest$5); - } - }(k,acc,rest$5)); - case /* Formatting_lit */17 : - _fmt = fmt[1]; - _acc = /* Acc_formatting_lit */Block.__(0, [ - acc, - fmt[0] - ]); - continue ; - case /* Formatting_gen */18 : - var match = fmt[0]; - if (match.tag) { - var rest$6 = fmt[1]; - var k$prime = (function(k,acc,rest$6){ - return function k$prime(koc, kacc) { - return make_printf(k, koc, /* Acc_formatting_gen */Block.__(1, [ - acc, - /* Acc_open_box */Block.__(1, [kacc]) - ]), rest$6); - } - }(k,acc,rest$6)); - _fmt = match[0][0]; - _acc = /* End_of_acc */0; - _k = k$prime; - continue ; - } else { - var rest$7 = fmt[1]; - var k$prime$1 = (function(k,acc,rest$7){ - return function k$prime$1(koc, kacc) { - return make_printf(k, koc, /* Acc_formatting_gen */Block.__(1, [ - acc, - /* Acc_open_tag */Block.__(0, [kacc]) - ]), rest$7); - } - }(k,acc,rest$7)); - _fmt = match[0][0]; - _acc = /* End_of_acc */0; - _k = k$prime$1; - continue ; - } - case /* Reader */19 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 1525, - 4 - ] - ]; - case /* Scan_char_set */20 : - var rest$8 = fmt[2]; - var new_acc = /* Acc_invalid_arg */Block.__(8, [ - acc, - "Printf: bad conversion %[" - ]); - return (function(k,rest$8,new_acc){ - return function (param) { - return make_printf(k, o, new_acc, rest$8); - } - }(k,rest$8,new_acc)); - case /* Scan_get_counter */21 : - var rest$9 = fmt[1]; - return (function(k,acc,rest$9){ - return function (n) { - var new_acc_001 = Caml_format.caml_format_int("%u", n); - var new_acc = /* Acc_data_string */Block.__(4, [ - acc, - new_acc_001 - ]); - return make_printf(k, o, new_acc, rest$9); - } - }(k,acc,rest$9)); - case /* Scan_next_char */22 : - var rest$10 = fmt[0]; - return (function(k,acc,rest$10){ - return function (c) { - var new_acc = /* Acc_data_char */Block.__(5, [ - acc, - c - ]); - return make_printf(k, o, new_acc, rest$10); - } - }(k,acc,rest$10)); - case /* Ignored_param */23 : - return make_ignored_param(k, o, acc, fmt[0], fmt[1]); - case /* Custom */24 : - return make_custom(k, o, acc, fmt[2], fmt[0], Curry._1(fmt[1], /* () */0)); - - } - } - }; -} - -function make_ignored_param(k, o, acc, ign, fmt) { - if (typeof ign === "number") { - if (ign === /* Ignored_reader */2) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 1593, - 39 - ] - ]; - } else { - return make_invalid_arg(k, o, acc, fmt); - } - } else if (ign.tag === /* Ignored_format_subst */9) { - return make_from_fmtty(k, o, acc, ign[1], fmt); - } else { - return make_invalid_arg(k, o, acc, fmt); - } -} - -function make_from_fmtty(k, o, acc, fmtty, fmt) { - if (typeof fmtty === "number") { - return make_invalid_arg(k, o, acc, fmt); - } else { - switch (fmtty.tag | 0) { - case /* Char_ty */0 : - var rest = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest, fmt); - }); - case /* String_ty */1 : - var rest$1 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$1, fmt); - }); - case /* Int_ty */2 : - var rest$2 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$2, fmt); - }); - case /* Int32_ty */3 : - var rest$3 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$3, fmt); - }); - case /* Nativeint_ty */4 : - var rest$4 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$4, fmt); - }); - case /* Int64_ty */5 : - var rest$5 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$5, fmt); - }); - case /* Float_ty */6 : - var rest$6 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$6, fmt); - }); - case /* Bool_ty */7 : - var rest$7 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$7, fmt); - }); - case /* Format_arg_ty */8 : - var rest$8 = fmtty[1]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$8, fmt); - }); - case /* Format_subst_ty */9 : - var rest$9 = fmtty[2]; - var ty = trans(symm(fmtty[0]), fmtty[1]); - return (function (param) { - return make_from_fmtty(k, o, acc, CamlinternalFormatBasics.concat_fmtty(ty, rest$9), fmt); - }); - case /* Alpha_ty */10 : - var rest$10 = fmtty[0]; - return (function (param, param$1) { - return make_from_fmtty(k, o, acc, rest$10, fmt); - }); - case /* Theta_ty */11 : - var rest$11 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$11, fmt); - }); - case /* Any_ty */12 : - var rest$12 = fmtty[0]; - return (function (param) { - return make_from_fmtty(k, o, acc, rest$12, fmt); - }); - case /* Reader_ty */13 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 1616, - 31 - ] - ]; - case /* Ignored_reader_ty */14 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 1617, - 31 - ] - ]; - - } - } -} - -function make_invalid_arg(k, o, acc, fmt) { - return make_printf(k, o, /* Acc_invalid_arg */Block.__(8, [ - acc, - "Printf: bad conversion %_" - ]), fmt); -} - -function make_padding(k, o, acc, fmt, pad, trans) { - if (typeof pad === "number") { - return (function (x) { - var new_acc_001 = Curry._1(trans, x); - var new_acc = /* Acc_data_string */Block.__(4, [ - acc, - new_acc_001 - ]); - return make_printf(k, o, new_acc, fmt); - }); - } else if (pad.tag) { - var padty = pad[0]; - return (function (w, x) { - var new_acc_001 = fix_padding(padty, w, Curry._1(trans, x)); - var new_acc = /* Acc_data_string */Block.__(4, [ - acc, - new_acc_001 - ]); - return make_printf(k, o, new_acc, fmt); - }); - } else { - var width = pad[1]; - var padty$1 = pad[0]; - return (function (x) { - var new_acc_001 = fix_padding(padty$1, width, Curry._1(trans, x)); - var new_acc = /* Acc_data_string */Block.__(4, [ - acc, - new_acc_001 - ]); - return make_printf(k, o, new_acc, fmt); - }); - } -} - -function make_int_padding_precision(k, o, acc, fmt, pad, prec, trans, iconv) { - if (typeof pad === "number") { - if (typeof prec === "number") { - if (prec !== 0) { - return (function (p, x) { - var str = fix_int_precision(p, Curry._2(trans, iconv, x)); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } else { - return (function (x) { - var str = Curry._2(trans, iconv, x); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } else { - var p = prec[0]; - return (function (x) { - var str = fix_int_precision(p, Curry._2(trans, iconv, x)); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } else if (pad.tag) { - var padty = pad[0]; - if (typeof prec === "number") { - if (prec !== 0) { - return (function (w, p, x) { - var str = fix_padding(padty, w, fix_int_precision(p, Curry._2(trans, iconv, x))); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } else { - return (function (w, x) { - var str = fix_padding(padty, w, Curry._2(trans, iconv, x)); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } else { - var p$1 = prec[0]; - return (function (w, x) { - var str = fix_padding(padty, w, fix_int_precision(p$1, Curry._2(trans, iconv, x))); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } else { - var w = pad[1]; - var padty$1 = pad[0]; - if (typeof prec === "number") { - if (prec !== 0) { - return (function (p, x) { - var str = fix_padding(padty$1, w, fix_int_precision(p, Curry._2(trans, iconv, x))); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } else { - return (function (x) { - var str = fix_padding(padty$1, w, Curry._2(trans, iconv, x)); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } else { - var p$2 = prec[0]; - return (function (x) { - var str = fix_padding(padty$1, w, fix_int_precision(p$2, Curry._2(trans, iconv, x))); - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - str - ]), fmt); - }); - } - } -} - -function make_custom(k, o, acc, rest, arity, f) { - if (arity) { - var arity$1 = arity[0]; - return (function (x) { - return make_custom(k, o, acc, rest, arity$1, Curry._1(f, x)); - }); - } else { - return make_printf(k, o, /* Acc_data_string */Block.__(4, [ - acc, - f - ]), rest); - } -} - -function make_iprintf(_k, o, _fmt) { - while(true) { - var fmt = _fmt; - var k = _k; - var exit = 0; - if (typeof fmt === "number") { - return Curry._1(k, o); - } else { - switch (fmt.tag | 0) { - case /* String */2 : - var tmp = fmt[0]; - if (typeof tmp !== "number" && tmp.tag) { - var partial_arg = make_iprintf(k, o, fmt[1]); - var partial_arg$1 = (function(partial_arg){ - return function partial_arg$1(param) { - return partial_arg; - } - }(partial_arg)); - return (function (param) { - return partial_arg$1; - }); - } - var partial_arg$2 = make_iprintf(k, o, fmt[1]); - return (function(partial_arg$2){ - return function (param) { - return partial_arg$2; - } - }(partial_arg$2)); - case /* Caml_string */3 : - var tmp$1 = fmt[0]; - if (typeof tmp$1 !== "number" && tmp$1.tag) { - var partial_arg$3 = make_iprintf(k, o, fmt[1]); - var partial_arg$4 = (function(partial_arg$3){ - return function partial_arg$4(param) { - return partial_arg$3; - } - }(partial_arg$3)); - return (function (param) { - return partial_arg$4; - }); - } - var partial_arg$5 = make_iprintf(k, o, fmt[1]); - return (function(partial_arg$5){ - return function (param) { - return partial_arg$5; - } - }(partial_arg$5)); - case /* Bool */9 : - var tmp$2 = fmt[0]; - if (typeof tmp$2 !== "number" && tmp$2.tag) { - var partial_arg$6 = make_iprintf(k, o, fmt[1]); - var partial_arg$7 = (function(partial_arg$6){ - return function partial_arg$7(param) { - return partial_arg$6; - } - }(partial_arg$6)); - return (function (param) { - return partial_arg$7; - }); - } - var partial_arg$8 = make_iprintf(k, o, fmt[1]); - return (function(partial_arg$8){ - return function (param) { - return partial_arg$8; - } - }(partial_arg$8)); - case /* Flush */10 : - _fmt = fmt[0]; - continue ; - case /* Format_subst */14 : - var rest = fmt[2]; - var fmtty = fmt[1]; - return (function(k,fmtty,rest){ - return function (param) { - return make_iprintf(k, o, CamlinternalFormatBasics.concat_fmt(recast(param[0], fmtty), rest)); - } - }(k,fmtty,rest)); - case /* Alpha */15 : - var partial_arg$9 = make_iprintf(k, o, fmt[0]); - var partial_arg$10 = (function(partial_arg$9){ - return function partial_arg$10(param) { - return partial_arg$9; - } - }(partial_arg$9)); - return (function (param) { - return partial_arg$10; - }); - case /* String_literal */11 : - case /* Char_literal */12 : - case /* Formatting_lit */17 : - exit = 2; - break; - case /* Formatting_gen */18 : - var match = fmt[0]; - if (match.tag) { - var rest$1 = fmt[1]; - _fmt = match[0][0]; - _k = (function(k,rest$1){ - return function (koc) { - return make_iprintf(k, koc, rest$1); - } - }(k,rest$1)); - continue ; - } else { - var rest$2 = fmt[1]; - _fmt = match[0][0]; - _k = (function(k,rest$2){ - return function (koc) { - return make_iprintf(k, koc, rest$2); - } - }(k,rest$2)); - continue ; - } - case /* Reader */19 : - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 1797, - 8 - ] - ]; - case /* Format_arg */13 : - case /* Scan_char_set */20 : - exit = 3; - break; - case /* Scan_get_counter */21 : - var partial_arg$11 = make_iprintf(k, o, fmt[1]); - return (function(partial_arg$11){ - return function (param) { - return partial_arg$11; - } - }(partial_arg$11)); - case /* Char */0 : - case /* Caml_char */1 : - case /* Theta */16 : - case /* Scan_next_char */22 : - exit = 1; - break; - case /* Ignored_param */23 : - return make_ignored_param((function(k){ - return function (x, param) { - return Curry._1(k, x); - } - }(k)), o, /* End_of_acc */0, fmt[0], fmt[1]); - case /* Custom */24 : - return fn_of_custom_arity(k, o, fmt[2], fmt[0]); - default: - var k$1 = k; - var o$1 = o; - var fmt$1 = fmt[3]; - var pad = fmt[1]; - var prec = fmt[2]; - if (typeof pad === "number") { - if (typeof prec === "number") { - if (prec !== 0) { - var partial_arg$12 = make_iprintf(k$1, o$1, fmt$1); - var partial_arg$13 = (function(partial_arg$12){ - return function partial_arg$13(param) { - return partial_arg$12; - } - }(partial_arg$12)); - return (function (param) { - return partial_arg$13; - }); - } else { - var partial_arg$14 = make_iprintf(k$1, o$1, fmt$1); - return (function(partial_arg$14){ - return function (param) { - return partial_arg$14; - } - }(partial_arg$14)); - } - } else { - var partial_arg$15 = make_iprintf(k$1, o$1, fmt$1); - return (function(partial_arg$15){ - return function (param) { - return partial_arg$15; - } - }(partial_arg$15)); - } - } else if (pad.tag) { - if (typeof prec === "number") { - if (prec !== 0) { - var partial_arg$16 = make_iprintf(k$1, o$1, fmt$1); - var partial_arg$17 = (function(partial_arg$16){ - return function partial_arg$17(param) { - return partial_arg$16; - } - }(partial_arg$16)); - var partial_arg$18 = function (param) { - return partial_arg$17; - }; - return (function (param) { - return partial_arg$18; - }); - } else { - var partial_arg$19 = make_iprintf(k$1, o$1, fmt$1); - var partial_arg$20 = (function(partial_arg$19){ - return function partial_arg$20(param) { - return partial_arg$19; - } - }(partial_arg$19)); - return (function (param) { - return partial_arg$20; - }); - } - } else { - var partial_arg$21 = make_iprintf(k$1, o$1, fmt$1); - var partial_arg$22 = (function(partial_arg$21){ - return function partial_arg$22(param) { - return partial_arg$21; - } - }(partial_arg$21)); - return (function (param) { - return partial_arg$22; - }); - } - } else if (typeof prec === "number") { - if (prec !== 0) { - var partial_arg$23 = make_iprintf(k$1, o$1, fmt$1); - var partial_arg$24 = (function(partial_arg$23){ - return function partial_arg$24(param) { - return partial_arg$23; - } - }(partial_arg$23)); - return (function (param) { - return partial_arg$24; - }); - } else { - var partial_arg$25 = make_iprintf(k$1, o$1, fmt$1); - return (function(partial_arg$25){ - return function (param) { - return partial_arg$25; - } - }(partial_arg$25)); - } - } else { - var partial_arg$26 = make_iprintf(k$1, o$1, fmt$1); - return (function(partial_arg$26){ - return function (param) { - return partial_arg$26; - } - }(partial_arg$26)); - } - } - } - switch (exit) { - case 1 : - var partial_arg$27 = make_iprintf(k, o, fmt[0]); - return (function(partial_arg$27){ - return function (param) { - return partial_arg$27; - } - }(partial_arg$27)); - case 2 : - _fmt = fmt[1]; - continue ; - case 3 : - var partial_arg$28 = make_iprintf(k, o, fmt[2]); - return (function(partial_arg$28){ - return function (param) { - return partial_arg$28; - } - }(partial_arg$28)); - - } - }; -} - -function fn_of_custom_arity(k, o, fmt, param) { - if (param) { - var partial_arg = fn_of_custom_arity(k, o, fmt, param[0]); - return (function (param) { - return partial_arg; - }); - } else { - return make_iprintf(k, o, fmt); - } -} - -function output_acc(o, _acc) { - while(true) { - var acc = _acc; - var exit = 0; - if (typeof acc === "number") { - return /* () */0; - } else { - switch (acc.tag | 0) { - case /* Acc_formatting_lit */0 : - var s = string_of_formatting_lit(acc[1]); - output_acc(o, acc[0]); - return Pervasives.output_string(o, s); - case /* Acc_formatting_gen */1 : - var match = acc[1]; - var p = acc[0]; - output_acc(o, p); - if (match.tag) { - Pervasives.output_string(o, "@["); - _acc = match[0]; - continue ; - } else { - Pervasives.output_string(o, "@{"); - _acc = match[0]; - continue ; - } - case /* Acc_string_literal */2 : - case /* Acc_data_string */4 : - exit = 1; - break; - case /* Acc_char_literal */3 : - case /* Acc_data_char */5 : - exit = 2; - break; - case /* Acc_delay */6 : - output_acc(o, acc[0]); - return Curry._1(acc[1], o); - case /* Acc_flush */7 : - output_acc(o, acc[0]); - return Caml_io.caml_ml_flush(o); - case /* Acc_invalid_arg */8 : - output_acc(o, acc[0]); - throw [ - Caml_builtin_exceptions.invalid_argument, - acc[1] - ]; - - } - } - switch (exit) { - case 1 : - output_acc(o, acc[0]); - return Pervasives.output_string(o, acc[1]); - case 2 : - output_acc(o, acc[0]); - return Caml_io.caml_ml_output_char(o, acc[1]); - - } - }; -} - -function bufput_acc(b, _acc) { - while(true) { - var acc = _acc; - var exit = 0; - if (typeof acc === "number") { - return /* () */0; - } else { - switch (acc.tag | 0) { - case /* Acc_formatting_lit */0 : - var s = string_of_formatting_lit(acc[1]); - bufput_acc(b, acc[0]); - return $$Buffer.add_string(b, s); - case /* Acc_formatting_gen */1 : - var match = acc[1]; - var p = acc[0]; - bufput_acc(b, p); - if (match.tag) { - $$Buffer.add_string(b, "@["); - _acc = match[0]; - continue ; - } else { - $$Buffer.add_string(b, "@{"); - _acc = match[0]; - continue ; - } - case /* Acc_string_literal */2 : - case /* Acc_data_string */4 : - exit = 1; - break; - case /* Acc_char_literal */3 : - case /* Acc_data_char */5 : - exit = 2; - break; - case /* Acc_delay */6 : - bufput_acc(b, acc[0]); - return Curry._1(acc[1], b); - case /* Acc_flush */7 : - _acc = acc[0]; - continue ; - case /* Acc_invalid_arg */8 : - bufput_acc(b, acc[0]); - throw [ - Caml_builtin_exceptions.invalid_argument, - acc[1] - ]; - - } - } - switch (exit) { - case 1 : - bufput_acc(b, acc[0]); - return $$Buffer.add_string(b, acc[1]); - case 2 : - bufput_acc(b, acc[0]); - return $$Buffer.add_char(b, acc[1]); - - } - }; -} - -function strput_acc(b, _acc) { - while(true) { - var acc = _acc; - var exit = 0; - if (typeof acc === "number") { - return /* () */0; - } else { - switch (acc.tag | 0) { - case /* Acc_formatting_lit */0 : - var s = string_of_formatting_lit(acc[1]); - strput_acc(b, acc[0]); - return $$Buffer.add_string(b, s); - case /* Acc_formatting_gen */1 : - var match = acc[1]; - var p = acc[0]; - strput_acc(b, p); - if (match.tag) { - $$Buffer.add_string(b, "@["); - _acc = match[0]; - continue ; - } else { - $$Buffer.add_string(b, "@{"); - _acc = match[0]; - continue ; - } - case /* Acc_string_literal */2 : - case /* Acc_data_string */4 : - exit = 1; - break; - case /* Acc_char_literal */3 : - case /* Acc_data_char */5 : - exit = 2; - break; - case /* Acc_delay */6 : - strput_acc(b, acc[0]); - return $$Buffer.add_string(b, Curry._1(acc[1], /* () */0)); - case /* Acc_flush */7 : - _acc = acc[0]; - continue ; - case /* Acc_invalid_arg */8 : - strput_acc(b, acc[0]); - throw [ - Caml_builtin_exceptions.invalid_argument, - acc[1] - ]; - - } - } - switch (exit) { - case 1 : - strput_acc(b, acc[0]); - return $$Buffer.add_string(b, acc[1]); - case 2 : - strput_acc(b, acc[0]); - return $$Buffer.add_char(b, acc[1]); - - } - }; -} - -function failwith_message(param) { - var buf = $$Buffer.create(256); - var k = function (param, acc) { - strput_acc(buf, acc); - var s = $$Buffer.contents(buf); - throw [ - Caml_builtin_exceptions.failure, - s - ]; - }; - return make_printf(k, /* () */0, /* End_of_acc */0, param[0]); -} - -function open_box_of_string(str) { - if (str === "") { - return /* tuple */[ - 0, - /* Pp_box */4 - ]; - } else { - var len = str.length; - var invalid_box = function (param) { - return Curry._1(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid box description ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ]), - "invalid box description %S" - ]), str); - }; - var parse_spaces = function (_i) { - while(true) { - var i = _i; - if (i === len) { - return i; - } else { - var match = Caml_string.get(str, i); - if (match !== 9) { - if (match !== 32) { - return i; - } else { - _i = i + 1 | 0; - continue ; - } - } else { - _i = i + 1 | 0; - continue ; - } - } - }; - }; - var parse_lword = function (i, _j) { - while(true) { - var j = _j; - if (j === len) { - return j; - } else { - var match = Caml_string.get(str, j); - if (match > 122 || match < 97) { - return j; - } else { - _j = j + 1 | 0; - continue ; - } - } - }; - }; - var parse_int = function (i, _j) { - while(true) { - var j = _j; - if (j === len) { - return j; - } else { - var match = Caml_string.get(str, j); - if (match >= 48) { - if (match >= 58) { - return j; - } else { - _j = j + 1 | 0; - continue ; - } - } else if (match !== 45) { - return j; - } else { - _j = j + 1 | 0; - continue ; - } - } - }; - }; - var wstart = parse_spaces(0); - var wend = parse_lword(wstart, wstart); - var box_name = $$String.sub(str, wstart, wend - wstart | 0); - var nstart = parse_spaces(wend); - var nend = parse_int(nstart, nstart); - var indent; - if (nstart === nend) { - indent = 0; - } else { - try { - indent = Caml_format.caml_int_of_string($$String.sub(str, nstart, nend - nstart | 0)); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Caml_builtin_exceptions.failure) { - indent = invalid_box(/* () */0); - } else { - throw exn; - } - } - } - var exp_end = parse_spaces(nend); - if (exp_end !== len) { - invalid_box(/* () */0); - } - var box_type; - switch (box_name) { - case "" : - case "b" : - box_type = /* Pp_box */4; - break; - case "h" : - box_type = /* Pp_hbox */0; - break; - case "hov" : - box_type = /* Pp_hovbox */3; - break; - case "hv" : - box_type = /* Pp_hvbox */2; - break; - case "v" : - box_type = /* Pp_vbox */1; - break; - default: - box_type = invalid_box(/* () */0); - } - return /* tuple */[ - indent, - box_type - ]; - } -} - -function make_padding_fmt_ebb(pad, fmt) { - if (typeof pad === "number") { - return /* Padding_fmt_EBB */[ - /* No_padding */0, - fmt - ]; - } else if (pad.tag) { - return /* Padding_fmt_EBB */[ - /* Arg_padding */Block.__(1, [pad[0]]), - fmt - ]; - } else { - return /* Padding_fmt_EBB */[ - /* Lit_padding */Block.__(0, [ - pad[0], - pad[1] - ]), - fmt - ]; - } -} - -function make_precision_fmt_ebb(prec, fmt) { - if (typeof prec === "number") { - if (prec !== 0) { - return /* Precision_fmt_EBB */[ - /* Arg_precision */1, - fmt - ]; - } else { - return /* Precision_fmt_EBB */[ - /* No_precision */0, - fmt - ]; - } - } else { - return /* Precision_fmt_EBB */[ - /* Lit_precision */[prec[0]], - fmt - ]; - } -} - -function make_padprec_fmt_ebb(pad, prec, fmt) { - var match = make_precision_fmt_ebb(prec, fmt); - var fmt$prime = match[1]; - var prec$1 = match[0]; - if (typeof pad === "number") { - return /* Padprec_fmt_EBB */[ - /* No_padding */0, - prec$1, - fmt$prime - ]; - } else if (pad.tag) { - return /* Padprec_fmt_EBB */[ - /* Arg_padding */Block.__(1, [pad[0]]), - prec$1, - fmt$prime - ]; - } else { - return /* Padprec_fmt_EBB */[ - /* Lit_padding */Block.__(0, [ - pad[0], - pad[1] - ]), - prec$1, - fmt$prime - ]; - } -} - -function fmt_ebb_of_string(legacy_behavior, str) { - var legacy_behavior$1 = legacy_behavior !== undefined ? legacy_behavior : true; - var invalid_format_message = function (str_ind, msg) { - return Curry._3(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", ", - /* String */Block.__(2, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, %s" - ]), str, str_ind, msg); - }; - var invalid_format_without = function (str_ind, c, s) { - return Curry._4(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", '", - /* Char */Block.__(0, [/* String_literal */Block.__(11, [ - "' without ", - /* String */Block.__(2, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ])]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, '%c' without %s" - ]), str, str_ind, c, s); - }; - var expected_character = function (str_ind, expected, read) { - return Curry._4(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", ", - /* String */Block.__(2, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " expected, read ", - /* Caml_char */Block.__(1, [/* End_of_format */0]) - ]) - ]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, %s expected, read %C" - ]), str, str_ind, expected, read); - }; - var parse_after_at = function (str_ind, end_ind) { - if (str_ind === end_ind) { - return /* Fmt_EBB */[/* Char_literal */Block.__(12, [ - /* "@" */64, - /* End_of_format */0 - ])]; - } else { - var c = Caml_string.get(str, str_ind); - if (c >= 65) { - if (c >= 94) { - switch (c) { - case 123 : - return parse_tag(true, str_ind + 1 | 0, end_ind); - case 124 : - break; - case 125 : - var beg_ind = str_ind + 1 | 0; - var match = parse_literal(beg_ind, beg_ind, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Close_tag */1, - match[0] - ])]; - default: - - } - } else if (c >= 91) { - switch (c - 91 | 0) { - case 0 : - return parse_tag(false, str_ind + 1 | 0, end_ind); - case 1 : - break; - case 2 : - var beg_ind$1 = str_ind + 1 | 0; - var match$1 = parse_literal(beg_ind$1, beg_ind$1, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Close_box */0, - match$1[0] - ])]; - - } - } - - } else if (c !== 10) { - if (c >= 32) { - switch (c - 32 | 0) { - case 0 : - var beg_ind$2 = str_ind + 1 | 0; - var match$2 = parse_literal(beg_ind$2, beg_ind$2, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Break */Block.__(0, [ - "@ ", - 1, - 0 - ]), - match$2[0] - ])]; - case 5 : - if ((str_ind + 1 | 0) < end_ind && Caml_string.get(str, str_ind + 1 | 0) === /* "%" */37) { - var beg_ind$3 = str_ind + 2 | 0; - var match$3 = parse_literal(beg_ind$3, beg_ind$3, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Escaped_percent */6, - match$3[0] - ])]; - } else { - var match$4 = parse_literal(str_ind, str_ind, end_ind); - return /* Fmt_EBB */[/* Char_literal */Block.__(12, [ - /* "@" */64, - match$4[0] - ])]; - } - case 12 : - var beg_ind$4 = str_ind + 1 | 0; - var match$5 = parse_literal(beg_ind$4, beg_ind$4, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Break */Block.__(0, [ - "@,", - 0, - 0 - ]), - match$5[0] - ])]; - case 14 : - var beg_ind$5 = str_ind + 1 | 0; - var match$6 = parse_literal(beg_ind$5, beg_ind$5, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Flush_newline */4, - match$6[0] - ])]; - case 27 : - var str_ind$1 = str_ind + 1 | 0; - var end_ind$1 = end_ind; - var match$7; - try { - if (str_ind$1 === end_ind$1 || Caml_string.get(str, str_ind$1) !== /* "<" */60) { - throw Caml_builtin_exceptions.not_found; - } - var str_ind_1 = parse_spaces(str_ind$1 + 1 | 0, end_ind$1); - var match$8 = Caml_string.get(str, str_ind_1); - var exit = 0; - if (match$8 >= 48) { - if (match$8 >= 58) { - throw Caml_builtin_exceptions.not_found; - } - exit = 1; - } else { - if (match$8 !== 45) { - throw Caml_builtin_exceptions.not_found; - } - exit = 1; - } - if (exit === 1) { - var match$9 = parse_integer(str_ind_1, end_ind$1); - var width = match$9[1]; - var str_ind_3 = parse_spaces(match$9[0], end_ind$1); - var match$10 = Caml_string.get(str, str_ind_3); - var switcher = match$10 - 45 | 0; - if (switcher > 12 || switcher < 0) { - if (switcher !== 17) { - throw Caml_builtin_exceptions.not_found; - } - var s = $$String.sub(str, str_ind$1 - 2 | 0, (str_ind_3 - str_ind$1 | 0) + 3 | 0); - match$7 = /* tuple */[ - str_ind_3 + 1 | 0, - /* Break */Block.__(0, [ - s, - width, - 0 - ]) - ]; - } else if (switcher === 2 || switcher === 1) { - throw Caml_builtin_exceptions.not_found; - } else { - var match$11 = parse_integer(str_ind_3, end_ind$1); - var str_ind_5 = parse_spaces(match$11[0], end_ind$1); - if (Caml_string.get(str, str_ind_5) !== /* ">" */62) { - throw Caml_builtin_exceptions.not_found; - } - var s$1 = $$String.sub(str, str_ind$1 - 2 | 0, (str_ind_5 - str_ind$1 | 0) + 3 | 0); - match$7 = /* tuple */[ - str_ind_5 + 1 | 0, - /* Break */Block.__(0, [ - s$1, - width, - match$11[1] - ]) - ]; - } - } - - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn === Caml_builtin_exceptions.not_found || exn[0] === Caml_builtin_exceptions.failure) { - match$7 = /* tuple */[ - str_ind$1, - /* Break */Block.__(0, [ - "@;", - 1, - 0 - ]) - ]; - } else { - throw exn; - } - } - var next_ind = match$7[0]; - var match$12 = parse_literal(next_ind, next_ind, end_ind$1); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - match$7[1], - match$12[0] - ])]; - case 28 : - var str_ind$2 = str_ind + 1 | 0; - var end_ind$2 = end_ind; - var match$13; - try { - var str_ind_1$1 = parse_spaces(str_ind$2, end_ind$2); - var match$14 = Caml_string.get(str, str_ind_1$1); - var exit$1 = 0; - if (match$14 >= 48) { - if (match$14 >= 58) { - match$13 = undefined; - } else { - exit$1 = 1; - } - } else if (match$14 !== 45) { - match$13 = undefined; - } else { - exit$1 = 1; - } - if (exit$1 === 1) { - var match$15 = parse_integer(str_ind_1$1, end_ind$2); - var str_ind_3$1 = parse_spaces(match$15[0], end_ind$2); - if (Caml_string.get(str, str_ind_3$1) !== /* ">" */62) { - throw Caml_builtin_exceptions.not_found; - } - var s$2 = $$String.sub(str, str_ind$2 - 2 | 0, (str_ind_3$1 - str_ind$2 | 0) + 3 | 0); - match$13 = /* tuple */[ - str_ind_3$1 + 1 | 0, - /* Magic_size */Block.__(1, [ - s$2, - match$15[1] - ]) - ]; - } - - } - catch (raw_exn$1){ - var exn$1 = Caml_js_exceptions.internalToOCamlException(raw_exn$1); - if (exn$1 === Caml_builtin_exceptions.not_found || exn$1[0] === Caml_builtin_exceptions.failure) { - match$13 = undefined; - } else { - throw exn$1; - } - } - if (match$13 !== undefined) { - var match$16 = match$13; - var next_ind$1 = match$16[0]; - var match$17 = parse_literal(next_ind$1, next_ind$1, end_ind$2); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - match$16[1], - match$17[0] - ])]; - } else { - var match$18 = parse_literal(str_ind$2, str_ind$2, end_ind$2); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Scan_indic */Block.__(2, [/* "<" */60]), - match$18[0] - ])]; - } - case 1 : - case 2 : - case 3 : - case 4 : - case 6 : - case 7 : - case 8 : - case 9 : - case 10 : - case 11 : - case 13 : - case 15 : - case 16 : - case 17 : - case 18 : - case 19 : - case 20 : - case 21 : - case 22 : - case 23 : - case 24 : - case 25 : - case 26 : - case 29 : - case 30 : - break; - case 31 : - var beg_ind$6 = str_ind + 1 | 0; - var match$19 = parse_literal(beg_ind$6, beg_ind$6, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* FFlush */2, - match$19[0] - ])]; - case 32 : - var beg_ind$7 = str_ind + 1 | 0; - var match$20 = parse_literal(beg_ind$7, beg_ind$7, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Escaped_at */5, - match$20[0] - ])]; - - } - } - - } else { - var beg_ind$8 = str_ind + 1 | 0; - var match$21 = parse_literal(beg_ind$8, beg_ind$8, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Force_newline */3, - match$21[0] - ])]; - } - var beg_ind$9 = str_ind + 1 | 0; - var match$22 = parse_literal(beg_ind$9, beg_ind$9, end_ind); - return /* Fmt_EBB */[/* Formatting_lit */Block.__(17, [ - /* Scan_indic */Block.__(2, [c]), - match$22[0] - ])]; - } - }; - var add_literal = function (lit_start, str_ind, fmt) { - var size = str_ind - lit_start | 0; - if (size !== 0) { - if (size !== 1) { - return /* Fmt_EBB */[/* String_literal */Block.__(11, [ - $$String.sub(str, lit_start, size), - fmt - ])]; - } else { - return /* Fmt_EBB */[/* Char_literal */Block.__(12, [ - Caml_string.get(str, lit_start), - fmt - ])]; - } - } else { - return /* Fmt_EBB */[fmt]; - } - }; - var parse_format = function (pct_ind, end_ind) { - var pct_ind$1 = pct_ind; - var str_ind = pct_ind + 1 | 0; - var end_ind$1 = end_ind; - if (str_ind === end_ind$1) { - invalid_format_message(end_ind$1, "unexpected end of format"); - } - var match = Caml_string.get(str, str_ind); - if (match !== 95) { - return parse_flags(pct_ind$1, str_ind, end_ind$1, false); - } else { - return parse_flags(pct_ind$1, str_ind + 1 | 0, end_ind$1, true); - } - }; - var parse_literal = function (lit_start, _str_ind, end_ind) { - while(true) { - var str_ind = _str_ind; - if (str_ind === end_ind) { - return add_literal(lit_start, str_ind, /* End_of_format */0); - } else { - var match = Caml_string.get(str, str_ind); - if (match !== 37) { - if (match !== 64) { - _str_ind = str_ind + 1 | 0; - continue ; - } else { - var match$1 = parse_after_at(str_ind + 1 | 0, end_ind); - return add_literal(lit_start, str_ind, match$1[0]); - } - } else { - var match$2 = parse_format(str_ind, end_ind); - return add_literal(lit_start, str_ind, match$2[0]); - } - } - }; - }; - var parse_spaces = function (_str_ind, end_ind) { - while(true) { - var str_ind = _str_ind; - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - if (Caml_string.get(str, str_ind) === /* " " */32) { - _str_ind = str_ind + 1 | 0; - continue ; - } else { - return str_ind; - } - }; - }; - var parse_flags = function (pct_ind, str_ind, end_ind, ign) { - var zero = { - contents: false - }; - var minus = { - contents: false - }; - var plus = { - contents: false - }; - var space = { - contents: false - }; - var hash = { - contents: false - }; - var set_flag = function (str_ind, flag) { - if (flag.contents && !legacy_behavior$1) { - Curry._3(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", duplicate flag ", - /* Caml_char */Block.__(1, [/* End_of_format */0]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, duplicate flag %C" - ]), str, str_ind, Caml_string.get(str, str_ind)); - } - flag.contents = true; - return /* () */0; - }; - var _str_ind = str_ind; - while(true) { - var str_ind$1 = _str_ind; - if (str_ind$1 === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var match = Caml_string.get(str, str_ind$1); - switch (match) { - case 32 : - set_flag(str_ind$1, space); - _str_ind = str_ind$1 + 1 | 0; - continue ; - case 35 : - set_flag(str_ind$1, hash); - _str_ind = str_ind$1 + 1 | 0; - continue ; - case 43 : - set_flag(str_ind$1, plus); - _str_ind = str_ind$1 + 1 | 0; - continue ; - case 45 : - set_flag(str_ind$1, minus); - _str_ind = str_ind$1 + 1 | 0; - continue ; - case 33 : - case 34 : - case 36 : - case 37 : - case 38 : - case 39 : - case 40 : - case 41 : - case 42 : - case 44 : - case 46 : - case 47 : - break; - case 48 : - set_flag(str_ind$1, zero); - _str_ind = str_ind$1 + 1 | 0; - continue ; - default: - - } - var pct_ind$1 = pct_ind; - var str_ind$2 = str_ind$1; - var end_ind$1 = end_ind; - var zero$1 = zero.contents; - var minus$1 = minus.contents; - var plus$1 = plus.contents; - var hash$1 = hash.contents; - var space$1 = space.contents; - var ign$1 = ign; - if (str_ind$2 === end_ind$1) { - invalid_format_message(end_ind$1, "unexpected end of format"); - } - var padty = zero$1 ? ( - minus$1 ? ( - legacy_behavior$1 ? /* Left */0 : incompatible_flag(pct_ind$1, str_ind$2, /* "-" */45, "0") - ) : /* Zeros */2 - ) : ( - minus$1 ? /* Left */0 : /* Right */1 - ); - var match$1 = Caml_string.get(str, str_ind$2); - if (match$1 >= 48) { - if (match$1 < 58) { - var match$2 = parse_positive(str_ind$2, end_ind$1, 0); - return parse_after_padding(pct_ind$1, match$2[0], end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, /* Lit_padding */Block.__(0, [ - padty, - match$2[1] - ])); - } - - } else if (match$1 === 42) { - return parse_after_padding(pct_ind$1, str_ind$2 + 1 | 0, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, /* Arg_padding */Block.__(1, [padty])); - } - switch (padty) { - case /* Left */0 : - if (!legacy_behavior$1) { - invalid_format_without(str_ind$2 - 1 | 0, /* "-" */45, "padding"); - } - return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, /* No_padding */0); - case /* Right */1 : - return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, /* No_padding */0); - case /* Zeros */2 : - return parse_after_padding(pct_ind$1, str_ind$2, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, /* Lit_padding */Block.__(0, [ - /* Right */1, - 0 - ])); - - } - }; - }; - var search_subformat_end = function (_str_ind, end_ind, c) { - while(true) { - var str_ind = _str_ind; - if (str_ind === end_ind) { - Curry._3(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": unclosed sub-format, expected \"", - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* Char */Block.__(0, [/* String_literal */Block.__(11, [ - "\" at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* End_of_format */0 - ]) - ])]) - ]) - ]) - ]) - ]), - "invalid format %S: unclosed sub-format, expected \"%%%c\" at character number %d" - ]), str, c, end_ind); - } - var match = Caml_string.get(str, str_ind); - if (match !== 37) { - _str_ind = str_ind + 1 | 0; - continue ; - } else { - if ((str_ind + 1 | 0) === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - if (Caml_string.get(str, str_ind + 1 | 0) === c) { - return str_ind; - } else { - var match$1 = Caml_string.get(str, str_ind + 1 | 0); - if (match$1 >= 95) { - if (match$1 >= 123) { - if (match$1 < 126) { - switch (match$1 - 123 | 0) { - case 0 : - var sub_end = search_subformat_end(str_ind + 2 | 0, end_ind, /* "}" */125); - _str_ind = sub_end + 2 | 0; - continue ; - case 1 : - break; - case 2 : - return expected_character(str_ind + 1 | 0, "character ')'", /* "}" */125); - - } - } - - } else if (match$1 < 96) { - if ((str_ind + 2 | 0) === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var match$2 = Caml_string.get(str, str_ind + 2 | 0); - if (match$2 !== 40) { - if (match$2 !== 123) { - _str_ind = str_ind + 3 | 0; - continue ; - } else { - var sub_end$1 = search_subformat_end(str_ind + 3 | 0, end_ind, /* "}" */125); - _str_ind = sub_end$1 + 2 | 0; - continue ; - } - } else { - var sub_end$2 = search_subformat_end(str_ind + 3 | 0, end_ind, /* ")" */41); - _str_ind = sub_end$2 + 2 | 0; - continue ; - } - } - - } else if (match$1 !== 40) { - if (match$1 === 41) { - return expected_character(str_ind + 1 | 0, "character '}'", /* ")" */41); - } - - } else { - var sub_end$3 = search_subformat_end(str_ind + 2 | 0, end_ind, /* ")" */41); - _str_ind = sub_end$3 + 2 | 0; - continue ; - } - _str_ind = str_ind + 2 | 0; - continue ; - } - } - }; - }; - var parse_positive = function (_str_ind, end_ind, _acc) { - while(true) { - var acc = _acc; - var str_ind = _str_ind; - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var c = Caml_string.get(str, str_ind); - if (c > 57 || c < 48) { - return /* tuple */[ - str_ind, - acc - ]; - } else { - var new_acc = Caml_int32.imul(acc, 10) + (c - /* "0" */48 | 0) | 0; - _acc = new_acc; - _str_ind = str_ind + 1 | 0; - continue ; - } - }; - }; - var check_open_box = function (fmt) { - if (typeof fmt === "number" || !(fmt.tag === /* String_literal */11 && typeof fmt[1] === "number")) { - return /* () */0; - } else { - try { - open_box_of_string(fmt[0]); - return /* () */0; - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Caml_builtin_exceptions.failure) { - return /* () */0; - } else { - throw exn; - } - } - } - }; - var parse_conversion = function (pct_ind, str_ind, end_ind, plus, hash, space, ign, pad, prec, padprec, symb) { - var plus_used = false; - var hash_used = false; - var space_used = false; - var ign_used = { - contents: false - }; - var pad_used = { - contents: false - }; - var prec_used = { - contents: false - }; - var get_int_pad = function (param) { - pad_used.contents = true; - prec_used.contents = true; - if (typeof prec === "number" && prec === 0) { - return pad; - } - if (typeof pad === "number") { - return /* No_padding */0; - } else if (pad.tag) { - if (pad[0] >= 2) { - if (legacy_behavior$1) { - return /* Arg_padding */Block.__(1, [/* Right */1]); - } else { - return incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision"); - } - } else { - return pad; - } - } else if (pad[0] >= 2) { - if (legacy_behavior$1) { - return /* Lit_padding */Block.__(0, [ - /* Right */1, - pad[1] - ]); - } else { - return incompatible_flag(pct_ind, str_ind, /* "0" */48, "precision"); - } - } else { - return pad; - } - }; - var check_no_0 = function (symb, pad) { - if (typeof pad === "number") { - return pad; - } else if (pad.tag) { - if (pad[0] >= 2) { - if (legacy_behavior$1) { - return /* Arg_padding */Block.__(1, [/* Right */1]); - } else { - return incompatible_flag(pct_ind, str_ind, symb, "0"); - } - } else { - return pad; - } - } else if (pad[0] >= 2) { - if (legacy_behavior$1) { - return /* Lit_padding */Block.__(0, [ - /* Right */1, - pad[1] - ]); - } else { - return incompatible_flag(pct_ind, str_ind, symb, "0"); - } - } else { - return pad; - } - }; - var opt_of_pad = function (c, pad) { - if (typeof pad === "number") { - return ; - } else if (pad.tag) { - return incompatible_flag(pct_ind, str_ind, c, "'*'"); - } else { - switch (pad[0]) { - case /* Left */0 : - if (legacy_behavior$1) { - return pad[1]; - } else { - return incompatible_flag(pct_ind, str_ind, c, "'-'"); - } - case /* Right */1 : - return pad[1]; - case /* Zeros */2 : - if (legacy_behavior$1) { - return pad[1]; - } else { - return incompatible_flag(pct_ind, str_ind, c, "'0'"); - } - - } - } - }; - var get_prec_opt = function (param) { - prec_used.contents = true; - if (typeof prec === "number") { - if (prec !== 0) { - return incompatible_flag(pct_ind, str_ind, /* "_" */95, "'*'"); - } else { - return ; - } - } else { - return prec[0]; - } - }; - var fmt_result; - var exit = 0; - var exit$1 = 0; - var exit$2 = 0; - if (symb >= 124) { - exit$1 = 6; - } else { - switch (symb) { - case 33 : - var match = parse_literal(str_ind, str_ind, end_ind); - fmt_result = /* Fmt_EBB */[/* Flush */Block.__(10, [match[0]])]; - break; - case 40 : - var sub_end = search_subformat_end(str_ind, end_ind, /* ")" */41); - var beg_ind = sub_end + 2 | 0; - var match$1 = parse_literal(beg_ind, beg_ind, end_ind); - var fmt_rest = match$1[0]; - var match$2 = parse_literal(str_ind, str_ind, sub_end); - var sub_fmtty = fmtty_of_fmt(match$2[0]); - if (ign_used.contents = true, ign) { - var ignored_000 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored = /* Ignored_format_subst */Block.__(9, [ - ignored_000, - sub_fmtty - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored, - fmt_rest - ])]; - } else { - fmt_result = /* Fmt_EBB */[/* Format_subst */Block.__(14, [ - opt_of_pad(/* "(" */40, (pad_used.contents = true, pad)), - sub_fmtty, - fmt_rest - ])]; - } - break; - case 44 : - fmt_result = parse_literal(str_ind, str_ind, end_ind); - break; - case 37 : - case 64 : - exit$1 = 4; - break; - case 67 : - var match$3 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$1 = match$3[0]; - fmt_result = (ign_used.contents = true, ign) ? /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - /* Ignored_caml_char */1, - fmt_rest$1 - ])] : /* Fmt_EBB */[/* Caml_char */Block.__(1, [fmt_rest$1])]; - break; - case 78 : - var match$4 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$2 = match$4[0]; - if (ign_used.contents = true, ign) { - var ignored$1 = /* Ignored_scan_get_counter */Block.__(11, [/* Token_counter */2]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$1, - fmt_rest$2 - ])]; - } else { - fmt_result = /* Fmt_EBB */[/* Scan_get_counter */Block.__(21, [ - /* Token_counter */2, - fmt_rest$2 - ])]; - } - break; - case 83 : - var pad$1 = check_no_0(symb, (pad_used.contents = true, padprec)); - var match$5 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$3 = match$5[0]; - if (ign_used.contents = true, ign) { - var ignored$2 = /* Ignored_caml_string */Block.__(1, [opt_of_pad(/* "_" */95, (pad_used.contents = true, padprec))]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$2, - fmt_rest$3 - ])]; - } else { - var match$6 = make_padding_fmt_ebb(pad$1, fmt_rest$3); - fmt_result = /* Fmt_EBB */[/* Caml_string */Block.__(3, [ - match$6[0], - match$6[1] - ])]; - } - break; - case 91 : - var match$7 = parse_char_set(str_ind, end_ind); - var char_set = match$7[1]; - var next_ind = match$7[0]; - var match$8 = parse_literal(next_ind, next_ind, end_ind); - var fmt_rest$4 = match$8[0]; - if (ign_used.contents = true, ign) { - var ignored_000$1 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$3 = /* Ignored_scan_char_set */Block.__(10, [ - ignored_000$1, - char_set - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$3, - fmt_rest$4 - ])]; - } else { - fmt_result = /* Fmt_EBB */[/* Scan_char_set */Block.__(20, [ - opt_of_pad(/* "[" */91, (pad_used.contents = true, pad)), - char_set, - fmt_rest$4 - ])]; - } - break; - case 32 : - case 35 : - case 43 : - case 45 : - case 95 : - exit$1 = 5; - break; - case 97 : - var match$9 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = /* Fmt_EBB */[/* Alpha */Block.__(15, [match$9[0]])]; - break; - case 66 : - case 98 : - exit$1 = 3; - break; - case 99 : - var char_format = function (fmt_rest) { - if (ign_used.contents = true, ign) { - return /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - /* Ignored_char */0, - fmt_rest - ])]; - } else { - return /* Fmt_EBB */[/* Char */Block.__(0, [fmt_rest])]; - } - }; - var scan_format = function (fmt_rest) { - if (ign_used.contents = true, ign) { - return /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - /* Ignored_scan_next_char */3, - fmt_rest - ])]; - } else { - return /* Fmt_EBB */[/* Scan_next_char */Block.__(22, [fmt_rest])]; - } - }; - var match$10 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$5 = match$10[0]; - var match$11 = opt_of_pad(/* "c" */99, (pad_used.contents = true, pad)); - fmt_result = match$11 !== undefined ? ( - match$11 !== 0 ? ( - legacy_behavior$1 ? char_format(fmt_rest$5) : invalid_format_message(str_ind, "non-zero widths are unsupported for %c conversions") - ) : scan_format(fmt_rest$5) - ) : char_format(fmt_rest$5); - break; - case 69 : - case 70 : - case 71 : - case 72 : - case 101 : - case 102 : - case 103 : - case 104 : - exit$1 = 2; - break; - case 76 : - case 108 : - case 110 : - exit$2 = 8; - break; - case 114 : - var match$12 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$6 = match$12[0]; - fmt_result = (ign_used.contents = true, ign) ? /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - /* Ignored_reader */2, - fmt_rest$6 - ])] : /* Fmt_EBB */[/* Reader */Block.__(19, [fmt_rest$6])]; - break; - case 115 : - var pad$2 = check_no_0(symb, (pad_used.contents = true, padprec)); - var match$13 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$7 = match$13[0]; - if (ign_used.contents = true, ign) { - var ignored$4 = /* Ignored_string */Block.__(0, [opt_of_pad(/* "_" */95, (pad_used.contents = true, padprec))]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$4, - fmt_rest$7 - ])]; - } else { - var match$14 = make_padding_fmt_ebb(pad$2, fmt_rest$7); - fmt_result = /* Fmt_EBB */[/* String */Block.__(2, [ - match$14[0], - match$14[1] - ])]; - } - break; - case 116 : - var match$15 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = /* Fmt_EBB */[/* Theta */Block.__(16, [match$15[0]])]; - break; - case 88 : - case 100 : - case 105 : - case 111 : - case 117 : - case 120 : - exit$2 = 7; - break; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 8 : - case 9 : - case 10 : - case 11 : - case 12 : - case 13 : - case 14 : - case 15 : - case 16 : - case 17 : - case 18 : - case 19 : - case 20 : - case 21 : - case 22 : - case 23 : - case 24 : - case 25 : - case 26 : - case 27 : - case 28 : - case 29 : - case 30 : - case 31 : - case 34 : - case 36 : - case 38 : - case 39 : - case 41 : - case 42 : - case 46 : - case 47 : - case 48 : - case 49 : - case 50 : - case 51 : - case 52 : - case 53 : - case 54 : - case 55 : - case 56 : - case 57 : - case 58 : - case 59 : - case 60 : - case 61 : - case 62 : - case 63 : - case 65 : - case 68 : - case 73 : - case 74 : - case 75 : - case 77 : - case 79 : - case 80 : - case 81 : - case 82 : - case 84 : - case 85 : - case 86 : - case 87 : - case 89 : - case 90 : - case 92 : - case 93 : - case 94 : - case 96 : - case 106 : - case 107 : - case 109 : - case 112 : - case 113 : - case 118 : - case 119 : - case 121 : - case 122 : - exit$1 = 6; - break; - case 123 : - var sub_end$1 = search_subformat_end(str_ind, end_ind, /* "}" */125); - var match$16 = parse_literal(str_ind, str_ind, sub_end$1); - var beg_ind$1 = sub_end$1 + 2 | 0; - var match$17 = parse_literal(beg_ind$1, beg_ind$1, end_ind); - var fmt_rest$8 = match$17[0]; - var sub_fmtty$1 = fmtty_of_fmt(match$16[0]); - if (ign_used.contents = true, ign) { - var ignored_000$2 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$5 = /* Ignored_format_arg */Block.__(8, [ - ignored_000$2, - sub_fmtty$1 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$5, - fmt_rest$8 - ])]; - } else { - fmt_result = /* Fmt_EBB */[/* Format_arg */Block.__(13, [ - opt_of_pad(/* "{" */123, (pad_used.contents = true, pad)), - sub_fmtty$1, - fmt_rest$8 - ])]; - } - break; - - } - } - switch (exit$2) { - case 7 : - plus_used = true; - hash_used = true; - space_used = true; - var iconv = compute_int_conv(pct_ind, str_ind, plus, hash, space, symb); - var match$18 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$9 = match$18[0]; - if (ign_used.contents = true, ign) { - var ignored_001 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$6 = /* Ignored_int */Block.__(2, [ - iconv, - ignored_001 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$6, - fmt_rest$9 - ])]; - } else { - var match$19 = make_padprec_fmt_ebb(get_int_pad(/* () */0), (prec_used.contents = true, prec), fmt_rest$9); - fmt_result = /* Fmt_EBB */[/* Int */Block.__(4, [ - iconv, - match$19[0], - match$19[1], - match$19[2] - ])]; - } - break; - case 8 : - if (str_ind === end_ind || !is_int_base(Caml_string.get(str, str_ind))) { - var match$20 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$10 = match$20[0]; - var counter = counter_of_char(symb); - if (ign_used.contents = true, ign) { - var ignored$7 = /* Ignored_scan_get_counter */Block.__(11, [counter]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$7, - fmt_rest$10 - ])]; - } else { - fmt_result = /* Fmt_EBB */[/* Scan_get_counter */Block.__(21, [ - counter, - fmt_rest$10 - ])]; - } - } else { - exit$1 = 6; - } - break; - - } - switch (exit$1) { - case 2 : - plus_used = true; - space_used = true; - var fconv = compute_float_conv(pct_ind, str_ind, plus, space, symb); - var match$21 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$11 = match$21[0]; - if (ign_used.contents = true, ign) { - var ignored_000$3 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored_001$1 = get_prec_opt(/* () */0); - var ignored$8 = /* Ignored_float */Block.__(6, [ - ignored_000$3, - ignored_001$1 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$8, - fmt_rest$11 - ])]; - } else { - var match$22 = make_padprec_fmt_ebb((pad_used.contents = true, pad), (prec_used.contents = true, prec), fmt_rest$11); - fmt_result = /* Fmt_EBB */[/* Float */Block.__(8, [ - fconv, - match$22[0], - match$22[1], - match$22[2] - ])]; - } - break; - case 3 : - var pad$3 = check_no_0(symb, (pad_used.contents = true, padprec)); - var match$23 = parse_literal(str_ind, str_ind, end_ind); - var fmt_rest$12 = match$23[0]; - if (ign_used.contents = true, ign) { - var ignored$9 = /* Ignored_bool */Block.__(7, [opt_of_pad(/* "_" */95, (pad_used.contents = true, padprec))]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$9, - fmt_rest$12 - ])]; - } else { - var match$24 = make_padding_fmt_ebb(pad$3, fmt_rest$12); - fmt_result = /* Fmt_EBB */[/* Bool */Block.__(9, [ - match$24[0], - match$24[1] - ])]; - } - break; - case 4 : - var match$25 = parse_literal(str_ind, str_ind, end_ind); - fmt_result = /* Fmt_EBB */[/* Char_literal */Block.__(12, [ - symb, - match$25[0] - ])]; - break; - case 5 : - fmt_result = Curry._3(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", flag ", - /* Caml_char */Block.__(1, [/* String_literal */Block.__(11, [ - " is only allowed after the '", - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* String_literal */Block.__(11, [ - "', before padding and precision", - /* End_of_format */0 - ]) - ]) - ])]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, flag %C is only allowed after the '%%', before padding and precision" - ]), str, pct_ind, symb); - break; - case 6 : - if (symb >= 108) { - if (symb >= 111) { - exit = 1; - } else { - switch (symb - 108 | 0) { - case 0 : - plus_used = true; - hash_used = true; - space_used = true; - var iconv$1 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); - var beg_ind$2 = str_ind + 1 | 0; - var match$26 = parse_literal(beg_ind$2, beg_ind$2, end_ind); - var fmt_rest$13 = match$26[0]; - if (ign_used.contents = true, ign) { - var ignored_001$2 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$10 = /* Ignored_int32 */Block.__(3, [ - iconv$1, - ignored_001$2 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$10, - fmt_rest$13 - ])]; - } else { - var match$27 = make_padprec_fmt_ebb(get_int_pad(/* () */0), (prec_used.contents = true, prec), fmt_rest$13); - fmt_result = /* Fmt_EBB */[/* Int32 */Block.__(5, [ - iconv$1, - match$27[0], - match$27[1], - match$27[2] - ])]; - } - break; - case 1 : - exit = 1; - break; - case 2 : - plus_used = true; - hash_used = true; - space_used = true; - var iconv$2 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); - var beg_ind$3 = str_ind + 1 | 0; - var match$28 = parse_literal(beg_ind$3, beg_ind$3, end_ind); - var fmt_rest$14 = match$28[0]; - if (ign_used.contents = true, ign) { - var ignored_001$3 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$11 = /* Ignored_nativeint */Block.__(4, [ - iconv$2, - ignored_001$3 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$11, - fmt_rest$14 - ])]; - } else { - var match$29 = make_padprec_fmt_ebb(get_int_pad(/* () */0), (prec_used.contents = true, prec), fmt_rest$14); - fmt_result = /* Fmt_EBB */[/* Nativeint */Block.__(6, [ - iconv$2, - match$29[0], - match$29[1], - match$29[2] - ])]; - } - break; - - } - } - } else if (symb !== 76) { - exit = 1; - } else { - plus_used = true; - hash_used = true; - space_used = true; - var iconv$3 = compute_int_conv(pct_ind, str_ind + 1 | 0, plus, hash, space, Caml_string.get(str, str_ind)); - var beg_ind$4 = str_ind + 1 | 0; - var match$30 = parse_literal(beg_ind$4, beg_ind$4, end_ind); - var fmt_rest$15 = match$30[0]; - if (ign_used.contents = true, ign) { - var ignored_001$4 = opt_of_pad(/* "_" */95, (pad_used.contents = true, pad)); - var ignored$12 = /* Ignored_int64 */Block.__(5, [ - iconv$3, - ignored_001$4 - ]); - fmt_result = /* Fmt_EBB */[/* Ignored_param */Block.__(23, [ - ignored$12, - fmt_rest$15 - ])]; - } else { - var match$31 = make_padprec_fmt_ebb(get_int_pad(/* () */0), (prec_used.contents = true, prec), fmt_rest$15); - fmt_result = /* Fmt_EBB */[/* Int64 */Block.__(7, [ - iconv$3, - match$31[0], - match$31[1], - match$31[2] - ])]; - } - } - break; - - } - if (exit === 1) { - fmt_result = Curry._3(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", invalid conversion \"", - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* Char */Block.__(0, [/* Char_literal */Block.__(12, [ - /* "\"" */34, - /* End_of_format */0 - ])]) - ]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, invalid conversion \"%%%c\"" - ]), str, str_ind - 1 | 0, symb); - } - if (!legacy_behavior$1) { - if (!plus_used && plus) { - incompatible_flag(pct_ind, str_ind, symb, "'+'"); - } - if (!hash_used && hash) { - incompatible_flag(pct_ind, str_ind, symb, "'#'"); - } - if (!space_used && space) { - incompatible_flag(pct_ind, str_ind, symb, "' '"); - } - if (!pad_used.contents && Caml_obj.caml_notequal(/* Padding_EBB */[pad], /* Padding_EBB */[/* No_padding */0])) { - incompatible_flag(pct_ind, str_ind, symb, "`padding'"); - } - if (!prec_used.contents && Caml_obj.caml_notequal(/* Precision_EBB */[prec], /* Precision_EBB */[/* No_precision */0])) { - incompatible_flag(pct_ind, str_ind, ign ? /* "_" */95 : symb, "`precision'"); - } - if (ign && plus) { - incompatible_flag(pct_ind, str_ind, /* "_" */95, "'+'"); - } - - } - if (!ign_used.contents && ign) { - var exit$3 = 0; - if (symb >= 38) { - if (symb !== 44) { - if (symb !== 64 || !legacy_behavior$1) { - exit$3 = 1; - } - - } else if (!legacy_behavior$1) { - exit$3 = 1; - } - - } else if (symb !== 33) { - if (!(symb >= 37 && legacy_behavior$1)) { - exit$3 = 1; - } - - } else if (!legacy_behavior$1) { - exit$3 = 1; - } - if (exit$3 === 1) { - incompatible_flag(pct_ind, str_ind, symb, "'_'"); - } - - } - return fmt_result; - }; - var parse_integer = function (str_ind, end_ind) { - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var match = Caml_string.get(str, str_ind); - if (match >= 48) { - if (match >= 58) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2814, - 11 - ] - ]; - } - return parse_positive(str_ind, end_ind, 0); - } else { - if (match !== 45) { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2814, - 11 - ] - ]; - } - if ((str_ind + 1 | 0) === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var c = Caml_string.get(str, str_ind + 1 | 0); - if (c > 57 || c < 48) { - return expected_character(str_ind + 1 | 0, "digit", c); - } else { - var match$1 = parse_positive(str_ind + 1 | 0, end_ind, 0); - return /* tuple */[ - match$1[0], - -match$1[1] | 0 - ]; - } - } - }; - var incompatible_flag = function (pct_ind, str_ind, symb, option) { - var subfmt = $$String.sub(str, pct_ind, str_ind - pct_ind | 0); - return Curry._5(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": at character number ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* String_literal */Block.__(11, [ - ", ", - /* String */Block.__(2, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " is incompatible with '", - /* Char */Block.__(0, [/* String_literal */Block.__(11, [ - "' in sub-format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ])]) - ]) - ]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: at character number %d, %s is incompatible with '%c' in sub-format %S" - ]), str, pct_ind, option, symb, subfmt); - }; - var parse_after_padding = function (pct_ind, str_ind, end_ind, minus, plus, hash, space, ign, pad) { - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var symb = Caml_string.get(str, str_ind); - if (symb !== 46) { - return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, /* No_precision */0, pad, symb); - } else { - var pct_ind$1 = pct_ind; - var str_ind$1 = str_ind + 1 | 0; - var end_ind$1 = end_ind; - var minus$1 = minus; - var plus$1 = plus; - var hash$1 = hash; - var space$1 = space; - var ign$1 = ign; - var pad$1 = pad; - if (str_ind$1 === end_ind$1) { - invalid_format_message(end_ind$1, "unexpected end of format"); - } - var parse_literal = function (minus, str_ind) { - var match = parse_positive(str_ind, end_ind$1, 0); - return parse_after_precision(pct_ind$1, match[0], end_ind$1, minus, plus$1, hash$1, space$1, ign$1, pad$1, /* Lit_precision */[match[1]]); - }; - var symb$1 = Caml_string.get(str, str_ind$1); - var exit = 0; - if (symb$1 >= 48) { - if (symb$1 < 58) { - return parse_literal(minus$1, str_ind$1); - } - - } else if (symb$1 >= 42) { - switch (symb$1 - 42 | 0) { - case 0 : - return parse_after_precision(pct_ind$1, str_ind$1 + 1 | 0, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, pad$1, /* Arg_precision */1); - case 1 : - case 3 : - exit = 2; - break; - case 2 : - case 4 : - case 5 : - break; - - } - } - if (exit === 2 && legacy_behavior$1) { - return parse_literal(minus$1 || symb$1 === /* "-" */45, str_ind$1 + 1 | 0); - } - if (legacy_behavior$1) { - return parse_after_precision(pct_ind$1, str_ind$1, end_ind$1, minus$1, plus$1, hash$1, space$1, ign$1, pad$1, /* Lit_precision */[0]); - } else { - return invalid_format_without(str_ind$1 - 1 | 0, /* "." */46, "precision"); - } - } - }; - var is_int_base = function (symb) { - switch (symb) { - case 89 : - case 90 : - case 91 : - case 92 : - case 93 : - case 94 : - case 95 : - case 96 : - case 97 : - case 98 : - case 99 : - case 101 : - case 102 : - case 103 : - case 104 : - case 106 : - case 107 : - case 108 : - case 109 : - case 110 : - case 112 : - case 113 : - case 114 : - case 115 : - case 116 : - case 118 : - case 119 : - return false; - case 88 : - case 100 : - case 105 : - case 111 : - case 117 : - case 120 : - return true; - default: - return false; - } - }; - var counter_of_char = function (symb) { - if (symb >= 108) { - if (symb < 111) { - switch (symb - 108 | 0) { - case 0 : - return /* Line_counter */0; - case 1 : - break; - case 2 : - return /* Char_counter */1; - - } - } - - } else if (symb === 76) { - return /* Token_counter */2; - } - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2876, - 34 - ] - ]; - }; - var parse_char_set = function (str_ind, end_ind) { - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var char_set = Bytes.make(32, /* "\000" */0); - var add_range = function (c, c$prime) { - for(var i = c; i <= c$prime; ++i){ - add_in_char_set(char_set, Pervasives.char_of_int(i)); - } - return /* () */0; - }; - var fail_single_percent = function (str_ind) { - return Curry._2(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "invalid format ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - ": '", - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* String_literal */Block.__(11, [ - "' alone is not accepted in character sets, use ", - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* Char_literal */Block.__(12, [ - /* "%" */37, - /* String_literal */Block.__(11, [ - " instead at position ", - /* Int */Block.__(4, [ - /* Int_d */0, - /* No_padding */0, - /* No_precision */0, - /* Char_literal */Block.__(12, [ - /* "." */46, - /* End_of_format */0 - ]) - ]) - ]) - ]) - ]) - ]) - ]) - ]) - ]) - ]), - "invalid format %S: '%%' alone is not accepted in character sets, use %%%% instead at position %d." - ]), str, str_ind); - }; - var parse_char_set_content = function (_str_ind, end_ind) { - while(true) { - var str_ind = _str_ind; - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var c = Caml_string.get(str, str_ind); - if (c !== 45) { - if (c !== 93) { - return parse_char_set_after_char(str_ind + 1 | 0, end_ind, c); - } else { - return str_ind + 1 | 0; - } - } else { - add_in_char_set(char_set, /* "-" */45); - _str_ind = str_ind + 1 | 0; - continue ; - } - }; - }; - var parse_char_set_after_char = function (_str_ind, end_ind, _c) { - while(true) { - var c = _c; - var str_ind = _str_ind; - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var c$prime = Caml_string.get(str, str_ind); - var exit = 0; - if (c$prime >= 46) { - if (c$prime !== 64) { - if (c$prime === 93) { - add_in_char_set(char_set, c); - return str_ind + 1 | 0; - } - - } else { - exit = 2; - } - } else if (c$prime !== 37) { - if (c$prime >= 45) { - var str_ind$1 = str_ind + 1 | 0; - var end_ind$1 = end_ind; - var c$1 = c; - if (str_ind$1 === end_ind$1) { - invalid_format_message(end_ind$1, "unexpected end of format"); - } - var c$prime$1 = Caml_string.get(str, str_ind$1); - if (c$prime$1 !== 37) { - if (c$prime$1 !== 93) { - add_range(c$1, c$prime$1); - return parse_char_set_content(str_ind$1 + 1 | 0, end_ind$1); - } else { - add_in_char_set(char_set, c$1); - add_in_char_set(char_set, /* "-" */45); - return str_ind$1 + 1 | 0; - } - } else { - if ((str_ind$1 + 1 | 0) === end_ind$1) { - invalid_format_message(end_ind$1, "unexpected end of format"); - } - var c$prime$2 = Caml_string.get(str, str_ind$1 + 1 | 0); - if (c$prime$2 !== 37 && c$prime$2 !== 64) { - return fail_single_percent(str_ind$1); - } - add_range(c$1, c$prime$2); - return parse_char_set_content(str_ind$1 + 2 | 0, end_ind$1); - } - } - - } else { - exit = 2; - } - if (exit === 2 && c === /* "%" */37) { - add_in_char_set(char_set, c$prime); - return parse_char_set_content(str_ind + 1 | 0, end_ind); - } - if (c === /* "%" */37) { - fail_single_percent(str_ind); - } - add_in_char_set(char_set, c); - _c = c$prime; - _str_ind = str_ind + 1 | 0; - continue ; - }; - }; - var parse_char_set_start = function (str_ind, end_ind) { - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var c = Caml_string.get(str, str_ind); - return parse_char_set_after_char(str_ind + 1 | 0, end_ind, c); - }; - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var match = Caml_string.get(str, str_ind); - var match$1 = match !== 94 ? /* tuple */[ - str_ind, - false - ] : /* tuple */[ - str_ind + 1 | 0, - true - ]; - var next_ind = parse_char_set_start(match$1[0], end_ind); - var char_set$1 = Bytes.to_string(char_set); - return /* tuple */[ - next_ind, - match$1[1] ? rev_char_set(char_set$1) : char_set$1 - ]; - }; - var compute_int_conv = function (pct_ind, str_ind, _plus, _hash, _space, symb) { - while(true) { - var space = _space; - var hash = _hash; - var plus = _plus; - var exit = 0; - if (plus) { - if (hash) { - exit = 2; - } else if (!space) { - if (symb !== 100) { - if (symb === 105) { - return /* Int_pi */4; - } - - } else { - return /* Int_pd */1; - } - } - - } else if (hash) { - if (space) { - exit = 2; - } else if (symb !== 88) { - if (symb !== 111) { - if (symb !== 120) { - exit = 2; - } else { - return /* Int_Cx */7; - } - } else { - return /* Int_Co */11; - } - } else { - return /* Int_CX */9; - } - } else if (space) { - if (symb !== 100) { - if (symb === 105) { - return /* Int_si */5; - } - - } else { - return /* Int_sd */2; - } - } else { - switch (symb) { - case 88 : - return /* Int_X */8; - case 100 : - return /* Int_d */0; - case 105 : - return /* Int_i */3; - case 111 : - return /* Int_o */10; - case 117 : - return /* Int_u */12; - case 89 : - case 90 : - case 91 : - case 92 : - case 93 : - case 94 : - case 95 : - case 96 : - case 97 : - case 98 : - case 99 : - case 101 : - case 102 : - case 103 : - case 104 : - case 106 : - case 107 : - case 108 : - case 109 : - case 110 : - case 112 : - case 113 : - case 114 : - case 115 : - case 116 : - case 118 : - case 119 : - break; - case 120 : - return /* Int_x */6; - default: - - } - } - if (exit === 2) { - var exit$1 = 0; - switch (symb) { - case 88 : - if (legacy_behavior$1) { - return /* Int_CX */9; - } - break; - case 111 : - if (legacy_behavior$1) { - return /* Int_Co */11; - } - break; - case 100 : - case 105 : - case 117 : - exit$1 = 3; - break; - case 89 : - case 90 : - case 91 : - case 92 : - case 93 : - case 94 : - case 95 : - case 96 : - case 97 : - case 98 : - case 99 : - case 101 : - case 102 : - case 103 : - case 104 : - case 106 : - case 107 : - case 108 : - case 109 : - case 110 : - case 112 : - case 113 : - case 114 : - case 115 : - case 116 : - case 118 : - case 119 : - break; - case 120 : - if (legacy_behavior$1) { - return /* Int_Cx */7; - } - break; - default: - - } - if (exit$1 === 3) { - if (legacy_behavior$1) { - _hash = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, symb, "'#'"); - } - } - - } - if (plus) { - if (space) { - if (legacy_behavior$1) { - _space = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, /* " " */32, "'+'"); - } - } else if (legacy_behavior$1) { - _plus = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, symb, "'+'"); - } - } else if (space) { - if (legacy_behavior$1) { - _space = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, symb, "' '"); - } - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2909, - 28 - ] - ]; - } - }; - }; - var compute_float_conv = function (pct_ind, str_ind, _plus, _space, symb) { - while(true) { - var space = _space; - var plus = _plus; - if (plus) { - if (space) { - if (legacy_behavior$1) { - _space = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, /* " " */32, "'+'"); - } - } else { - if (symb >= 73) { - switch (symb) { - case 101 : - return /* Float_pe */4; - case 102 : - return /* Float_pf */1; - case 103 : - return /* Float_pg */10; - case 104 : - return /* Float_ph */17; - default: - - } - } else if (symb >= 69) { - switch (symb - 69 | 0) { - case 0 : - return /* Float_pE */7; - case 1 : - break; - case 2 : - return /* Float_pG */13; - case 3 : - return /* Float_pH */20; - - } - } - if (legacy_behavior$1) { - _plus = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, symb, "'+'"); - } - } - } else if (space) { - if (symb >= 73) { - switch (symb) { - case 101 : - return /* Float_se */5; - case 102 : - return /* Float_sf */2; - case 103 : - return /* Float_sg */11; - case 104 : - return /* Float_sh */18; - default: - - } - } else if (symb >= 69) { - switch (symb - 69 | 0) { - case 0 : - return /* Float_sE */8; - case 1 : - break; - case 2 : - return /* Float_sG */14; - case 3 : - return /* Float_sH */21; - - } - } - if (legacy_behavior$1) { - _space = false; - continue ; - } else { - return incompatible_flag(pct_ind, str_ind, symb, "' '"); - } - } else if (symb >= 73) { - switch (symb) { - case 101 : - return /* Float_e */3; - case 102 : - return /* Float_f */0; - case 103 : - return /* Float_g */9; - case 104 : - return /* Float_h */16; - default: - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2943, - 25 - ] - ]; - } - } else if (symb >= 69) { - switch (symb - 69 | 0) { - case 0 : - return /* Float_E */6; - case 1 : - return /* Float_F */15; - case 2 : - return /* Float_G */12; - case 3 : - return /* Float_H */19; - - } - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "camlinternalFormat.ml", - 2943, - 25 - ] - ]; - } - }; - }; - var parse_after_precision = function (pct_ind, str_ind, end_ind, minus, plus, hash, space, ign, pad, prec) { - if (str_ind === end_ind) { - invalid_format_message(end_ind, "unexpected end of format"); - } - var parse_conv = function (padprec) { - return parse_conversion(pct_ind, str_ind + 1 | 0, end_ind, plus, hash, space, ign, pad, prec, padprec, Caml_string.get(str, str_ind)); - }; - if (typeof pad === "number") { - if (typeof prec === "number" && prec === 0) { - return parse_conv(/* No_padding */0); - } - if (minus) { - if (typeof prec === "number") { - return parse_conv(/* Arg_padding */Block.__(1, [/* Left */0])); - } else { - return parse_conv(/* Lit_padding */Block.__(0, [ - /* Left */0, - prec[0] - ])); - } - } else if (typeof prec === "number") { - return parse_conv(/* Arg_padding */Block.__(1, [/* Right */1])); - } else { - return parse_conv(/* Lit_padding */Block.__(0, [ - /* Right */1, - prec[0] - ])); - } - } else { - return parse_conv(pad); - } - }; - var parse_tag = function (is_open_tag, str_ind, end_ind) { - try { - if (str_ind === end_ind) { - throw Caml_builtin_exceptions.not_found; - } - var match = Caml_string.get(str, str_ind); - if (match !== 60) { - throw Caml_builtin_exceptions.not_found; - } - var ind = $$String.index_from(str, str_ind + 1 | 0, /* ">" */62); - if (ind >= end_ind) { - throw Caml_builtin_exceptions.not_found; - } - var sub_str = $$String.sub(str, str_ind, (ind - str_ind | 0) + 1 | 0); - var beg_ind = ind + 1 | 0; - var match$1 = parse_literal(beg_ind, beg_ind, end_ind); - var match$2 = parse_literal(str_ind, str_ind, ind + 1 | 0); - var sub_fmt = match$2[0]; - var sub_format = /* Format */[ - sub_fmt, - sub_str - ]; - var formatting = is_open_tag ? /* Open_tag */Block.__(0, [sub_format]) : (check_open_box(sub_fmt), /* Open_box */Block.__(1, [sub_format])); - return /* Fmt_EBB */[/* Formatting_gen */Block.__(18, [ - formatting, - match$1[0] - ])]; - } - catch (exn){ - if (exn === Caml_builtin_exceptions.not_found) { - var match$3 = parse_literal(str_ind, str_ind, end_ind); - var sub_format$1 = /* Format */[ - /* End_of_format */0, - "" - ]; - var formatting$1 = is_open_tag ? /* Open_tag */Block.__(0, [sub_format$1]) : /* Open_box */Block.__(1, [sub_format$1]); - return /* Fmt_EBB */[/* Formatting_gen */Block.__(18, [ - formatting$1, - match$3[0] - ])]; - } else { - throw exn; - } - } - }; - return parse_literal(0, 0, str.length); -} - -function format_of_string_fmtty(str, fmtty) { - var match = fmt_ebb_of_string(undefined, str); - try { - return /* Format */[ - type_format(match[0], fmtty), - str - ]; - } - catch (exn){ - if (exn === Type_mismatch) { - return Curry._2(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "bad input: format type mismatch between ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " and ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ]) - ]) - ]), - "bad input: format type mismatch between %S and %S" - ]), str, string_of_fmtty(fmtty)); - } else { - throw exn; - } - } -} - -function format_of_string_format(str, param) { - var match = fmt_ebb_of_string(undefined, str); - try { - return /* Format */[ - type_format(match[0], fmtty_of_fmt(param[0])), - str - ]; - } - catch (exn){ - if (exn === Type_mismatch) { - return Curry._2(failwith_message(/* Format */[ - /* String_literal */Block.__(11, [ - "bad input: format type mismatch between ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* String_literal */Block.__(11, [ - " and ", - /* Caml_string */Block.__(3, [ - /* No_padding */0, - /* End_of_format */0 - ]) - ]) - ]) - ]), - "bad input: format type mismatch between %S and %S" - ]), str, param[1]); - } else { - throw exn; - } - } -} - -exports.is_in_char_set = is_in_char_set; -exports.rev_char_set = rev_char_set; -exports.create_char_set = create_char_set; -exports.add_in_char_set = add_in_char_set; -exports.freeze_char_set = freeze_char_set; -exports.param_format_of_ignored_format = param_format_of_ignored_format; -exports.make_printf = make_printf; -exports.make_iprintf = make_iprintf; -exports.output_acc = output_acc; -exports.bufput_acc = bufput_acc; -exports.strput_acc = strput_acc; -exports.type_format = type_format; -exports.fmt_ebb_of_string = fmt_ebb_of_string; -exports.format_of_string_fmtty = format_of_string_fmtty; -exports.format_of_string_format = format_of_string_format; -exports.char_of_iconv = char_of_iconv; -exports.string_of_formatting_lit = string_of_formatting_lit; -exports.string_of_formatting_gen = string_of_formatting_gen; -exports.string_of_fmtty = string_of_fmtty; -exports.string_of_fmt = string_of_fmt; -exports.open_box_of_string = open_box_of_string; -exports.symm = symm; -exports.trans = trans; -exports.recast = recast; -/* No side effect */ - -},{"./block.js":36,"./buffer.js":37,"./bytes.js":38,"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41,"./caml_exceptions.js":42,"./caml_format.js":44,"./caml_int32.js":45,"./caml_io.js":47,"./caml_js_exceptions.js":48,"./caml_obj.js":49,"./caml_primitive.js":51,"./caml_string.js":52,"./camlinternalFormatBasics.js":56,"./char.js":57,"./curry.js":58,"./pervasives.js":62,"./string.js":64}],56:[function(require,module,exports){ -'use strict'; - -var Block = require("./block.js"); - -function erase_rel(param) { - if (typeof param === "number") { - return /* End_of_fmtty */0; - } else { - switch (param.tag | 0) { - case /* Char_ty */0 : - return /* Char_ty */Block.__(0, [erase_rel(param[0])]); - case /* String_ty */1 : - return /* String_ty */Block.__(1, [erase_rel(param[0])]); - case /* Int_ty */2 : - return /* Int_ty */Block.__(2, [erase_rel(param[0])]); - case /* Int32_ty */3 : - return /* Int32_ty */Block.__(3, [erase_rel(param[0])]); - case /* Nativeint_ty */4 : - return /* Nativeint_ty */Block.__(4, [erase_rel(param[0])]); - case /* Int64_ty */5 : - return /* Int64_ty */Block.__(5, [erase_rel(param[0])]); - case /* Float_ty */6 : - return /* Float_ty */Block.__(6, [erase_rel(param[0])]); - case /* Bool_ty */7 : - return /* Bool_ty */Block.__(7, [erase_rel(param[0])]); - case /* Format_arg_ty */8 : - return /* Format_arg_ty */Block.__(8, [ - param[0], - erase_rel(param[1]) - ]); - case /* Format_subst_ty */9 : - var ty1 = param[0]; - return /* Format_subst_ty */Block.__(9, [ - ty1, - ty1, - erase_rel(param[2]) - ]); - case /* Alpha_ty */10 : - return /* Alpha_ty */Block.__(10, [erase_rel(param[0])]); - case /* Theta_ty */11 : - return /* Theta_ty */Block.__(11, [erase_rel(param[0])]); - case /* Any_ty */12 : - return /* Any_ty */Block.__(12, [erase_rel(param[0])]); - case /* Reader_ty */13 : - return /* Reader_ty */Block.__(13, [erase_rel(param[0])]); - case /* Ignored_reader_ty */14 : - return /* Ignored_reader_ty */Block.__(14, [erase_rel(param[0])]); - - } - } -} - -function concat_fmtty(fmtty1, fmtty2) { - if (typeof fmtty1 === "number") { - return fmtty2; - } else { - switch (fmtty1.tag | 0) { - case /* Char_ty */0 : - return /* Char_ty */Block.__(0, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* String_ty */1 : - return /* String_ty */Block.__(1, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Int_ty */2 : - return /* Int_ty */Block.__(2, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Int32_ty */3 : - return /* Int32_ty */Block.__(3, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Nativeint_ty */4 : - return /* Nativeint_ty */Block.__(4, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Int64_ty */5 : - return /* Int64_ty */Block.__(5, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Float_ty */6 : - return /* Float_ty */Block.__(6, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Bool_ty */7 : - return /* Bool_ty */Block.__(7, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Format_arg_ty */8 : - return /* Format_arg_ty */Block.__(8, [ - fmtty1[0], - concat_fmtty(fmtty1[1], fmtty2) - ]); - case /* Format_subst_ty */9 : - return /* Format_subst_ty */Block.__(9, [ - fmtty1[0], - fmtty1[1], - concat_fmtty(fmtty1[2], fmtty2) - ]); - case /* Alpha_ty */10 : - return /* Alpha_ty */Block.__(10, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Theta_ty */11 : - return /* Theta_ty */Block.__(11, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Any_ty */12 : - return /* Any_ty */Block.__(12, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Reader_ty */13 : - return /* Reader_ty */Block.__(13, [concat_fmtty(fmtty1[0], fmtty2)]); - case /* Ignored_reader_ty */14 : - return /* Ignored_reader_ty */Block.__(14, [concat_fmtty(fmtty1[0], fmtty2)]); - - } - } -} - -function concat_fmt(fmt1, fmt2) { - if (typeof fmt1 === "number") { - return fmt2; - } else { - switch (fmt1.tag | 0) { - case /* Char */0 : - return /* Char */Block.__(0, [concat_fmt(fmt1[0], fmt2)]); - case /* Caml_char */1 : - return /* Caml_char */Block.__(1, [concat_fmt(fmt1[0], fmt2)]); - case /* String */2 : - return /* String */Block.__(2, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Caml_string */3 : - return /* Caml_string */Block.__(3, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Int */4 : - return /* Int */Block.__(4, [ - fmt1[0], - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]); - case /* Int32 */5 : - return /* Int32 */Block.__(5, [ - fmt1[0], - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]); - case /* Nativeint */6 : - return /* Nativeint */Block.__(6, [ - fmt1[0], - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]); - case /* Int64 */7 : - return /* Int64 */Block.__(7, [ - fmt1[0], - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]); - case /* Float */8 : - return /* Float */Block.__(8, [ - fmt1[0], - fmt1[1], - fmt1[2], - concat_fmt(fmt1[3], fmt2) - ]); - case /* Bool */9 : - return /* Bool */Block.__(9, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Flush */10 : - return /* Flush */Block.__(10, [concat_fmt(fmt1[0], fmt2)]); - case /* String_literal */11 : - return /* String_literal */Block.__(11, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Char_literal */12 : - return /* Char_literal */Block.__(12, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Format_arg */13 : - return /* Format_arg */Block.__(13, [ - fmt1[0], - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]); - case /* Format_subst */14 : - return /* Format_subst */Block.__(14, [ - fmt1[0], - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]); - case /* Alpha */15 : - return /* Alpha */Block.__(15, [concat_fmt(fmt1[0], fmt2)]); - case /* Theta */16 : - return /* Theta */Block.__(16, [concat_fmt(fmt1[0], fmt2)]); - case /* Formatting_lit */17 : - return /* Formatting_lit */Block.__(17, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Formatting_gen */18 : - return /* Formatting_gen */Block.__(18, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Reader */19 : - return /* Reader */Block.__(19, [concat_fmt(fmt1[0], fmt2)]); - case /* Scan_char_set */20 : - return /* Scan_char_set */Block.__(20, [ - fmt1[0], - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]); - case /* Scan_get_counter */21 : - return /* Scan_get_counter */Block.__(21, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Scan_next_char */22 : - return /* Scan_next_char */Block.__(22, [concat_fmt(fmt1[0], fmt2)]); - case /* Ignored_param */23 : - return /* Ignored_param */Block.__(23, [ - fmt1[0], - concat_fmt(fmt1[1], fmt2) - ]); - case /* Custom */24 : - return /* Custom */Block.__(24, [ - fmt1[0], - fmt1[1], - concat_fmt(fmt1[2], fmt2) - ]); - - } - } -} - -exports.concat_fmtty = concat_fmtty; -exports.erase_rel = erase_rel; -exports.concat_fmt = concat_fmt; -/* No side effect */ - -},{"./block.js":36}],57:[function(require,module,exports){ -'use strict'; - -var Caml_bytes = require("./caml_bytes.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function chr(n) { - if (n < 0 || n > 255) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "Char.chr" - ]; - } - return n; -} - -function escaped(c) { - var exit = 0; - if (c >= 40) { - if (c !== 92) { - exit = c >= 127 ? 1 : 2; - } else { - return "\\\\"; - } - } else if (c >= 32) { - if (c >= 39) { - return "\\'"; - } else { - exit = 2; - } - } else if (c >= 14) { - exit = 1; - } else { - switch (c) { - case 8 : - return "\\b"; - case 9 : - return "\\t"; - case 10 : - return "\\n"; - case 0 : - case 1 : - case 2 : - case 3 : - case 4 : - case 5 : - case 6 : - case 7 : - case 11 : - case 12 : - exit = 1; - break; - case 13 : - return "\\r"; - - } - } - switch (exit) { - case 1 : - var s = [ - 0, - 0, - 0, - 0 - ]; - s[0] = /* "\\" */92; - s[1] = 48 + (c / 100 | 0) | 0; - s[2] = 48 + (c / 10 | 0) % 10 | 0; - s[3] = 48 + c % 10 | 0; - return Caml_bytes.bytes_to_string(s); - case 2 : - var s$1 = [0]; - s$1[0] = c; - return Caml_bytes.bytes_to_string(s$1); - - } -} - -function lowercase(c) { - if (c >= /* "A" */65 && c <= /* "Z" */90 || c >= /* "\192" */192 && c <= /* "\214" */214 || c >= /* "\216" */216 && c <= /* "\222" */222) { - return c + 32 | 0; - } else { - return c; - } -} - -function uppercase(c) { - if (c >= /* "a" */97 && c <= /* "z" */122 || c >= /* "\224" */224 && c <= /* "\246" */246 || c >= /* "\248" */248 && c <= /* "\254" */254) { - return c - 32 | 0; - } else { - return c; - } -} - -function lowercase_ascii(c) { - if (c >= /* "A" */65 && c <= /* "Z" */90) { - return c + 32 | 0; - } else { - return c; - } -} - -function uppercase_ascii(c) { - if (c >= /* "a" */97 && c <= /* "z" */122) { - return c - 32 | 0; - } else { - return c; - } -} - -function compare(c1, c2) { - return c1 - c2 | 0; -} - -function equal(c1, c2) { - return (c1 - c2 | 0) === 0; -} - -exports.chr = chr; -exports.escaped = escaped; -exports.lowercase = lowercase; -exports.uppercase = uppercase; -exports.lowercase_ascii = lowercase_ascii; -exports.uppercase_ascii = uppercase_ascii; -exports.compare = compare; -exports.equal = equal; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41}],58:[function(require,module,exports){ -'use strict'; - -var Caml_array = require("./caml_array.js"); - -function app(_f, _args) { - while(true) { - var args = _args; - var f = _f; - var init_arity = f.length; - var arity = init_arity === 0 ? 1 : init_arity; - var len = args.length; - var d = arity - len | 0; - if (d === 0) { - return f.apply(null, args); - } else if (d < 0) { - _args = Caml_array.caml_array_sub(args, arity, -d | 0); - _f = f.apply(null, Caml_array.caml_array_sub(args, 0, arity)); - continue ; - } else { - return (function(f,args){ - return function (x) { - return app(f, args.concat([x])); - } - }(f,args)); - } - }; -} - -function curry_1(o, a0, arity) { - switch (arity) { - case 1 : - return o(a0); - case 2 : - return (function (param) { - return o(a0, param); - }); - case 3 : - return (function (param, param$1) { - return o(a0, param, param$1); - }); - case 4 : - return (function (param, param$1, param$2) { - return o(a0, param, param$1, param$2); - }); - case 5 : - return (function (param, param$1, param$2, param$3) { - return o(a0, param, param$1, param$2, param$3); - }); - case 6 : - return (function (param, param$1, param$2, param$3, param$4) { - return o(a0, param, param$1, param$2, param$3, param$4); - }); - case 7 : - return (function (param, param$1, param$2, param$3, param$4, param$5) { - return o(a0, param, param$1, param$2, param$3, param$4, param$5); - }); - default: - return app(o, [a0]); - } -} - -function _1(o, a0) { - var arity = o.length; - if (arity === 1) { - return o(a0); - } else { - return curry_1(o, a0, arity); - } -} - -function __1(o) { - var arity = o.length; - if (arity === 1) { - return o; - } else { - return (function (a0) { - return _1(o, a0); - }); - } -} - -function curry_2(o, a0, a1, arity) { - switch (arity) { - case 1 : - return app(o(a0), [a1]); - case 2 : - return o(a0, a1); - case 3 : - return (function (param) { - return o(a0, a1, param); - }); - case 4 : - return (function (param, param$1) { - return o(a0, a1, param, param$1); - }); - case 5 : - return (function (param, param$1, param$2) { - return o(a0, a1, param, param$1, param$2); - }); - case 6 : - return (function (param, param$1, param$2, param$3) { - return o(a0, a1, param, param$1, param$2, param$3); - }); - case 7 : - return (function (param, param$1, param$2, param$3, param$4) { - return o(a0, a1, param, param$1, param$2, param$3, param$4); - }); - default: - return app(o, [ - a0, - a1 - ]); - } -} - -function _2(o, a0, a1) { - var arity = o.length; - if (arity === 2) { - return o(a0, a1); - } else { - return curry_2(o, a0, a1, arity); - } -} - -function __2(o) { - var arity = o.length; - if (arity === 2) { - return o; - } else { - return (function (a0, a1) { - return _2(o, a0, a1); - }); - } -} - -function curry_3(o, a0, a1, a2, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2 - ]); - case 2 : - return app(o(a0, a1), [a2]); - case 3 : - return o(a0, a1, a2); - case 4 : - return (function (param) { - return o(a0, a1, a2, param); - }); - case 5 : - return (function (param, param$1) { - return o(a0, a1, a2, param, param$1); - }); - case 6 : - return (function (param, param$1, param$2) { - return o(a0, a1, a2, param, param$1, param$2); - }); - case 7 : - return (function (param, param$1, param$2, param$3) { - return o(a0, a1, a2, param, param$1, param$2, param$3); - }); - default: - return app(o, [ - a0, - a1, - a2 - ]); - } -} - -function _3(o, a0, a1, a2) { - var arity = o.length; - if (arity === 3) { - return o(a0, a1, a2); - } else { - return curry_3(o, a0, a1, a2, arity); - } -} - -function __3(o) { - var arity = o.length; - if (arity === 3) { - return o; - } else { - return (function (a0, a1, a2) { - return _3(o, a0, a1, a2); - }); - } -} - -function curry_4(o, a0, a1, a2, a3, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2, - a3 - ]); - case 2 : - return app(o(a0, a1), [ - a2, - a3 - ]); - case 3 : - return app(o(a0, a1, a2), [a3]); - case 4 : - return o(a0, a1, a2, a3); - case 5 : - return (function (param) { - return o(a0, a1, a2, a3, param); - }); - case 6 : - return (function (param, param$1) { - return o(a0, a1, a2, a3, param, param$1); - }); - case 7 : - return (function (param, param$1, param$2) { - return o(a0, a1, a2, a3, param, param$1, param$2); - }); - default: - return app(o, [ - a0, - a1, - a2, - a3 - ]); - } -} - -function _4(o, a0, a1, a2, a3) { - var arity = o.length; - if (arity === 4) { - return o(a0, a1, a2, a3); - } else { - return curry_4(o, a0, a1, a2, a3, arity); - } -} - -function __4(o) { - var arity = o.length; - if (arity === 4) { - return o; - } else { - return (function (a0, a1, a2, a3) { - return _4(o, a0, a1, a2, a3); - }); - } -} - -function curry_5(o, a0, a1, a2, a3, a4, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2, - a3, - a4 - ]); - case 2 : - return app(o(a0, a1), [ - a2, - a3, - a4 - ]); - case 3 : - return app(o(a0, a1, a2), [ - a3, - a4 - ]); - case 4 : - return app(o(a0, a1, a2, a3), [a4]); - case 5 : - return o(a0, a1, a2, a3, a4); - case 6 : - return (function (param) { - return o(a0, a1, a2, a3, a4, param); - }); - case 7 : - return (function (param, param$1) { - return o(a0, a1, a2, a3, a4, param, param$1); - }); - default: - return app(o, [ - a0, - a1, - a2, - a3, - a4 - ]); - } -} - -function _5(o, a0, a1, a2, a3, a4) { - var arity = o.length; - if (arity === 5) { - return o(a0, a1, a2, a3, a4); - } else { - return curry_5(o, a0, a1, a2, a3, a4, arity); - } -} - -function __5(o) { - var arity = o.length; - if (arity === 5) { - return o; - } else { - return (function (a0, a1, a2, a3, a4) { - return _5(o, a0, a1, a2, a3, a4); - }); - } -} - -function curry_6(o, a0, a1, a2, a3, a4, a5, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2, - a3, - a4, - a5 - ]); - case 2 : - return app(o(a0, a1), [ - a2, - a3, - a4, - a5 - ]); - case 3 : - return app(o(a0, a1, a2), [ - a3, - a4, - a5 - ]); - case 4 : - return app(o(a0, a1, a2, a3), [ - a4, - a5 - ]); - case 5 : - return app(o(a0, a1, a2, a3, a4), [a5]); - case 6 : - return o(a0, a1, a2, a3, a4, a5); - case 7 : - return (function (param) { - return o(a0, a1, a2, a3, a4, a5, param); - }); - default: - return app(o, [ - a0, - a1, - a2, - a3, - a4, - a5 - ]); - } -} - -function _6(o, a0, a1, a2, a3, a4, a5) { - var arity = o.length; - if (arity === 6) { - return o(a0, a1, a2, a3, a4, a5); - } else { - return curry_6(o, a0, a1, a2, a3, a4, a5, arity); - } -} - -function __6(o) { - var arity = o.length; - if (arity === 6) { - return o; - } else { - return (function (a0, a1, a2, a3, a4, a5) { - return _6(o, a0, a1, a2, a3, a4, a5); - }); - } -} - -function curry_7(o, a0, a1, a2, a3, a4, a5, a6, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2, - a3, - a4, - a5, - a6 - ]); - case 2 : - return app(o(a0, a1), [ - a2, - a3, - a4, - a5, - a6 - ]); - case 3 : - return app(o(a0, a1, a2), [ - a3, - a4, - a5, - a6 - ]); - case 4 : - return app(o(a0, a1, a2, a3), [ - a4, - a5, - a6 - ]); - case 5 : - return app(o(a0, a1, a2, a3, a4), [ - a5, - a6 - ]); - case 6 : - return app(o(a0, a1, a2, a3, a4, a5), [a6]); - case 7 : - return o(a0, a1, a2, a3, a4, a5, a6); - default: - return app(o, [ - a0, - a1, - a2, - a3, - a4, - a5, - a6 - ]); - } -} - -function _7(o, a0, a1, a2, a3, a4, a5, a6) { - var arity = o.length; - if (arity === 7) { - return o(a0, a1, a2, a3, a4, a5, a6); - } else { - return curry_7(o, a0, a1, a2, a3, a4, a5, a6, arity); - } -} - -function __7(o) { - var arity = o.length; - if (arity === 7) { - return o; - } else { - return (function (a0, a1, a2, a3, a4, a5, a6) { - return _7(o, a0, a1, a2, a3, a4, a5, a6); - }); - } -} - -function curry_8(o, a0, a1, a2, a3, a4, a5, a6, a7, arity) { - switch (arity) { - case 1 : - return app(o(a0), [ - a1, - a2, - a3, - a4, - a5, - a6, - a7 - ]); - case 2 : - return app(o(a0, a1), [ - a2, - a3, - a4, - a5, - a6, - a7 - ]); - case 3 : - return app(o(a0, a1, a2), [ - a3, - a4, - a5, - a6, - a7 - ]); - case 4 : - return app(o(a0, a1, a2, a3), [ - a4, - a5, - a6, - a7 - ]); - case 5 : - return app(o(a0, a1, a2, a3, a4), [ - a5, - a6, - a7 - ]); - case 6 : - return app(o(a0, a1, a2, a3, a4, a5), [ - a6, - a7 - ]); - case 7 : - return app(o(a0, a1, a2, a3, a4, a5, a6), [a7]); - default: - return app(o, [ - a0, - a1, - a2, - a3, - a4, - a5, - a6, - a7 - ]); - } -} - -function _8(o, a0, a1, a2, a3, a4, a5, a6, a7) { - var arity = o.length; - if (arity === 8) { - return o(a0, a1, a2, a3, a4, a5, a6, a7); - } else { - return curry_8(o, a0, a1, a2, a3, a4, a5, a6, a7, arity); - } -} - -function __8(o) { - var arity = o.length; - if (arity === 8) { - return o; - } else { - return (function (a0, a1, a2, a3, a4, a5, a6, a7) { - return _8(o, a0, a1, a2, a3, a4, a5, a6, a7); - }); - } -} - -exports.app = app; -exports.curry_1 = curry_1; -exports._1 = _1; -exports.__1 = __1; -exports.curry_2 = curry_2; -exports._2 = _2; -exports.__2 = __2; -exports.curry_3 = curry_3; -exports._3 = _3; -exports.__3 = __3; -exports.curry_4 = curry_4; -exports._4 = _4; -exports.__4 = __4; -exports.curry_5 = curry_5; -exports._5 = _5; -exports.__5 = __5; -exports.curry_6 = curry_6; -exports._6 = _6; -exports.__6 = __6; -exports.curry_7 = curry_7; -exports._7 = _7; -exports.__7 = __7; -exports.curry_8 = curry_8; -exports._8 = _8; -exports.__8 = __8; -/* No side effect */ - -},{"./caml_array.js":39}],59:[function(require,module,exports){ -'use strict'; - -var Caml_option = require("./caml_option.js"); - -function get(dict, k) { - if ((k in dict)) { - return Caml_option.some(dict[k]); - } - -} - -var unsafeDeleteKey = (function (dict,key){ - delete dict[key]; - return 0 - }); - -function entries(dict) { - var keys = Object.keys(dict); - var l = keys.length; - var values = new Array(l); - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - var key = keys[i]; - values[i] = /* tuple */[ - key, - dict[key] - ]; - } - return values; -} - -function values(dict) { - var keys = Object.keys(dict); - var l = keys.length; - var values$1 = new Array(l); - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - values$1[i] = dict[keys[i]]; - } - return values$1; -} - -function fromList(entries) { - var dict = { }; - var _param = entries; - while(true) { - var param = _param; - if (param) { - var match = param[0]; - dict[match[0]] = match[1]; - _param = param[1]; - continue ; - } else { - return dict; - } - }; -} - -function fromArray(entries) { - var dict = { }; - var l = entries.length; - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - var match = entries[i]; - dict[match[0]] = match[1]; - } - return dict; -} - -function map(f, source) { - var target = { }; - var keys = Object.keys(source); - var l = keys.length; - for(var i = 0 ,i_finish = l - 1 | 0; i <= i_finish; ++i){ - var key = keys[i]; - target[key] = f(source[key]); - } - return target; -} - -exports.get = get; -exports.unsafeDeleteKey = unsafeDeleteKey; -exports.entries = entries; -exports.values = values; -exports.fromList = fromList; -exports.fromArray = fromArray; -exports.map = map; -/* No side effect */ - -},{"./caml_option.js":50}],60:[function(require,module,exports){ -'use strict'; - -var Block = require("./block.js"); -var Caml_option = require("./caml_option.js"); - -function classify(x) { - var ty = typeof x; - if (ty === "string") { - return /* JSONString */Block.__(0, [x]); - } else if (ty === "number") { - return /* JSONNumber */Block.__(1, [x]); - } else if (ty === "boolean") { - if (x === true) { - return /* JSONTrue */1; - } else { - return /* JSONFalse */0; - } - } else if (x === null) { - return /* JSONNull */2; - } else if (Array.isArray(x)) { - return /* JSONArray */Block.__(3, [x]); - } else { - return /* JSONObject */Block.__(2, [x]); - } -} - -function test(x, v) { - switch (v) { - case /* String */0 : - return typeof x === "string"; - case /* Number */1 : - return typeof x === "number"; - case /* Object */2 : - if (x !== null && typeof x === "object") { - return !Array.isArray(x); - } else { - return false; - } - case /* Array */3 : - return Array.isArray(x); - case /* Boolean */4 : - return typeof x === "boolean"; - case /* Null */5 : - return x === null; - - } -} - -function decodeString(json) { - if (typeof json === "string") { - return json; - } - -} - -function decodeNumber(json) { - if (typeof json === "number") { - return json; - } - -} - -function decodeObject(json) { - if (typeof json === "object" && !Array.isArray(json) && json !== null) { - return Caml_option.some(json); - } - -} - -function decodeArray(json) { - if (Array.isArray(json)) { - return json; - } - -} - -function decodeBoolean(json) { - if (typeof json === "boolean") { - return json; - } - -} - -function decodeNull(json) { - if (json === null) { - return null; - } - -} - -exports.classify = classify; -exports.test = test; -exports.decodeString = decodeString; -exports.decodeNumber = decodeNumber; -exports.decodeObject = decodeObject; -exports.decodeArray = decodeArray; -exports.decodeBoolean = decodeBoolean; -exports.decodeNull = decodeNull; -/* No side effect */ - -},{"./block.js":36,"./caml_option.js":50}],61:[function(require,module,exports){ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_obj = require("./caml_obj.js"); -var Pervasives = require("./pervasives.js"); -var Caml_option = require("./caml_option.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function length(l) { - var _len = 0; - var _param = l; - while(true) { - var param = _param; - var len = _len; - if (param) { - _param = param[1]; - _len = len + 1 | 0; - continue ; - } else { - return len; - } - }; -} - -function cons(a, l) { - return /* :: */[ - a, - l - ]; -} - -function hd(param) { - if (param) { - return param[0]; - } else { - throw [ - Caml_builtin_exceptions.failure, - "hd" - ]; - } -} - -function tl(param) { - if (param) { - return param[1]; - } else { - throw [ - Caml_builtin_exceptions.failure, - "tl" - ]; - } -} - -function nth(l, n) { - if (n < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.nth" - ]; - } - var _l = l; - var _n = n; - while(true) { - var n$1 = _n; - var l$1 = _l; - if (l$1) { - if (n$1 === 0) { - return l$1[0]; - } else { - _n = n$1 - 1 | 0; - _l = l$1[1]; - continue ; - } - } else { - throw [ - Caml_builtin_exceptions.failure, - "nth" - ]; - } - }; -} - -function nth_opt(l, n) { - if (n < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.nth" - ]; - } - var _l = l; - var _n = n; - while(true) { - var n$1 = _n; - var l$1 = _l; - if (l$1) { - if (n$1 === 0) { - return Caml_option.some(l$1[0]); - } else { - _n = n$1 - 1 | 0; - _l = l$1[1]; - continue ; - } - } else { - return ; - } - }; -} - -function rev_append(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (l1) { - _l2 = /* :: */[ - l1[0], - l2 - ]; - _l1 = l1[1]; - continue ; - } else { - return l2; - } - }; -} - -function rev(l) { - return rev_append(l, /* [] */0); -} - -function init_tailrec_aux(_acc, _i, n, f) { - while(true) { - var i = _i; - var acc = _acc; - if (i >= n) { - return acc; - } else { - _i = i + 1 | 0; - _acc = /* :: */[ - Curry._1(f, i), - acc - ]; - continue ; - } - }; -} - -function init_aux(i, n, f) { - if (i >= n) { - return /* [] */0; - } else { - var r = Curry._1(f, i); - return /* :: */[ - r, - init_aux(i + 1 | 0, n, f) - ]; - } -} - -function init(len, f) { - if (len < 0) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.init" - ]; - } - if (len > 10000) { - return rev_append(init_tailrec_aux(/* [] */0, 0, len, f), /* [] */0); - } else { - return init_aux(0, len, f); - } -} - -function flatten(param) { - if (param) { - return Pervasives.$at(param[0], flatten(param[1])); - } else { - return /* [] */0; - } -} - -function map(f, param) { - if (param) { - var r = Curry._1(f, param[0]); - return /* :: */[ - r, - map(f, param[1]) - ]; - } else { - return /* [] */0; - } -} - -function mapi(i, f, param) { - if (param) { - var r = Curry._2(f, i, param[0]); - return /* :: */[ - r, - mapi(i + 1 | 0, f, param[1]) - ]; - } else { - return /* [] */0; - } -} - -function mapi$1(f, l) { - return mapi(0, f, l); -} - -function rev_map(f, l) { - var _accu = /* [] */0; - var _param = l; - while(true) { - var param = _param; - var accu = _accu; - if (param) { - _param = param[1]; - _accu = /* :: */[ - Curry._1(f, param[0]), - accu - ]; - continue ; - } else { - return accu; - } - }; -} - -function iter(f, _param) { - while(true) { - var param = _param; - if (param) { - Curry._1(f, param[0]); - _param = param[1]; - continue ; - } else { - return /* () */0; - } - }; -} - -function iteri(f, l) { - var _i = 0; - var f$1 = f; - var _param = l; - while(true) { - var param = _param; - var i = _i; - if (param) { - Curry._2(f$1, i, param[0]); - _param = param[1]; - _i = i + 1 | 0; - continue ; - } else { - return /* () */0; - } - }; -} - -function fold_left(f, _accu, _l) { - while(true) { - var l = _l; - var accu = _accu; - if (l) { - _l = l[1]; - _accu = Curry._2(f, accu, l[0]); - continue ; - } else { - return accu; - } - }; -} - -function fold_right(f, l, accu) { - if (l) { - return Curry._2(f, l[0], fold_right(f, l[1], accu)); - } else { - return accu; - } -} - -function map2(f, l1, l2) { - if (l1) { - if (l2) { - var r = Curry._2(f, l1[0], l2[0]); - return /* :: */[ - r, - map2(f, l1[1], l2[1]) - ]; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.map2" - ]; - } - } else if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.map2" - ]; - } else { - return /* [] */0; - } -} - -function rev_map2(f, l1, l2) { - var _accu = /* [] */0; - var _l1 = l1; - var _l2 = l2; - while(true) { - var l2$1 = _l2; - var l1$1 = _l1; - var accu = _accu; - if (l1$1) { - if (l2$1) { - _l2 = l2$1[1]; - _l1 = l1$1[1]; - _accu = /* :: */[ - Curry._2(f, l1$1[0], l2$1[0]), - accu - ]; - continue ; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.rev_map2" - ]; - } - } else { - if (l2$1) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.rev_map2" - ]; - } - return accu; - } - }; -} - -function iter2(f, _l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (l1) { - if (l2) { - Curry._2(f, l1[0], l2[0]); - _l2 = l2[1]; - _l1 = l1[1]; - continue ; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.iter2" - ]; - } - } else if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.iter2" - ]; - } else { - return /* () */0; - } - }; -} - -function fold_left2(f, _accu, _l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - var accu = _accu; - if (l1) { - if (l2) { - _l2 = l2[1]; - _l1 = l1[1]; - _accu = Curry._3(f, accu, l1[0], l2[0]); - continue ; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.fold_left2" - ]; - } - } else { - if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.fold_left2" - ]; - } - return accu; - } - }; -} - -function fold_right2(f, l1, l2, accu) { - if (l1) { - if (l2) { - return Curry._3(f, l1[0], l2[0], fold_right2(f, l1[1], l2[1], accu)); - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.fold_right2" - ]; - } - } else { - if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.fold_right2" - ]; - } - return accu; - } -} - -function for_all(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._1(p, param[0])) { - _param = param[1]; - continue ; - } else { - return false; - } - } else { - return true; - } - }; -} - -function exists(p, _param) { - while(true) { - var param = _param; - if (param) { - if (Curry._1(p, param[0])) { - return true; - } else { - _param = param[1]; - continue ; - } - } else { - return false; - } - }; -} - -function for_all2(p, _l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (l1) { - if (l2) { - if (Curry._2(p, l1[0], l2[0])) { - _l2 = l2[1]; - _l1 = l1[1]; - continue ; - } else { - return false; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.for_all2" - ]; - } - } else if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.for_all2" - ]; - } else { - return true; - } - }; -} - -function exists2(p, _l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (l1) { - if (l2) { - if (Curry._2(p, l1[0], l2[0])) { - return true; - } else { - _l2 = l2[1]; - _l1 = l1[1]; - continue ; - } - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.exists2" - ]; - } - } else if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.exists2" - ]; - } else { - return false; - } - }; -} - -function mem(x, _param) { - while(true) { - var param = _param; - if (param) { - if (Caml_obj.caml_equal(param[0], x)) { - return true; - } else { - _param = param[1]; - continue ; - } - } else { - return false; - } - }; -} - -function memq(x, _param) { - while(true) { - var param = _param; - if (param) { - if (param[0] === x) { - return true; - } else { - _param = param[1]; - continue ; - } - } else { - return false; - } - }; -} - -function assoc(x, _param) { - while(true) { - var param = _param; - if (param) { - var match = param[0]; - if (Caml_obj.caml_equal(match[0], x)) { - return match[1]; - } else { - _param = param[1]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function assoc_opt(x, _param) { - while(true) { - var param = _param; - if (param) { - var match = param[0]; - if (Caml_obj.caml_equal(match[0], x)) { - return Caml_option.some(match[1]); - } else { - _param = param[1]; - continue ; - } - } else { - return ; - } - }; -} - -function assq(x, _param) { - while(true) { - var param = _param; - if (param) { - var match = param[0]; - if (match[0] === x) { - return match[1]; - } else { - _param = param[1]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function assq_opt(x, _param) { - while(true) { - var param = _param; - if (param) { - var match = param[0]; - if (match[0] === x) { - return Caml_option.some(match[1]); - } else { - _param = param[1]; - continue ; - } - } else { - return ; - } - }; -} - -function mem_assoc(x, _param) { - while(true) { - var param = _param; - if (param) { - if (Caml_obj.caml_equal(param[0][0], x)) { - return true; - } else { - _param = param[1]; - continue ; - } - } else { - return false; - } - }; -} - -function mem_assq(x, _param) { - while(true) { - var param = _param; - if (param) { - if (param[0][0] === x) { - return true; - } else { - _param = param[1]; - continue ; - } - } else { - return false; - } - }; -} - -function remove_assoc(x, param) { - if (param) { - var l = param[1]; - var pair = param[0]; - if (Caml_obj.caml_equal(pair[0], x)) { - return l; - } else { - return /* :: */[ - pair, - remove_assoc(x, l) - ]; - } - } else { - return /* [] */0; - } -} - -function remove_assq(x, param) { - if (param) { - var l = param[1]; - var pair = param[0]; - if (pair[0] === x) { - return l; - } else { - return /* :: */[ - pair, - remove_assq(x, l) - ]; - } - } else { - return /* [] */0; - } -} - -function find(p, _param) { - while(true) { - var param = _param; - if (param) { - var x = param[0]; - if (Curry._1(p, x)) { - return x; - } else { - _param = param[1]; - continue ; - } - } else { - throw Caml_builtin_exceptions.not_found; - } - }; -} - -function find_opt(p, _param) { - while(true) { - var param = _param; - if (param) { - var x = param[0]; - if (Curry._1(p, x)) { - return Caml_option.some(x); - } else { - _param = param[1]; - continue ; - } - } else { - return ; - } - }; -} - -function find_all(p) { - return (function (param) { - var _accu = /* [] */0; - var _param = param; - while(true) { - var param$1 = _param; - var accu = _accu; - if (param$1) { - var l = param$1[1]; - var x = param$1[0]; - if (Curry._1(p, x)) { - _param = l; - _accu = /* :: */[ - x, - accu - ]; - continue ; - } else { - _param = l; - continue ; - } - } else { - return rev_append(accu, /* [] */0); - } - }; - }); -} - -function partition(p, l) { - var _yes = /* [] */0; - var _no = /* [] */0; - var _param = l; - while(true) { - var param = _param; - var no = _no; - var yes = _yes; - if (param) { - var l$1 = param[1]; - var x = param[0]; - if (Curry._1(p, x)) { - _param = l$1; - _yes = /* :: */[ - x, - yes - ]; - continue ; - } else { - _param = l$1; - _no = /* :: */[ - x, - no - ]; - continue ; - } - } else { - return /* tuple */[ - rev_append(yes, /* [] */0), - rev_append(no, /* [] */0) - ]; - } - }; -} - -function split(param) { - if (param) { - var match = param[0]; - var match$1 = split(param[1]); - return /* tuple */[ - /* :: */[ - match[0], - match$1[0] - ], - /* :: */[ - match[1], - match$1[1] - ] - ]; - } else { - return /* tuple */[ - /* [] */0, - /* [] */0 - ]; - } -} - -function combine(l1, l2) { - if (l1) { - if (l2) { - return /* :: */[ - /* tuple */[ - l1[0], - l2[0] - ], - combine(l1[1], l2[1]) - ]; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.combine" - ]; - } - } else if (l2) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "List.combine" - ]; - } else { - return /* [] */0; - } -} - -function merge(cmp, l1, l2) { - if (l1) { - if (l2) { - var h2 = l2[0]; - var h1 = l1[0]; - if (Curry._2(cmp, h1, h2) <= 0) { - return /* :: */[ - h1, - merge(cmp, l1[1], l2) - ]; - } else { - return /* :: */[ - h2, - merge(cmp, l1, l2[1]) - ]; - } - } else { - return l1; - } - } else { - return l2; - } -} - -function chop(_k, _l) { - while(true) { - var l = _l; - var k = _k; - if (k === 0) { - return l; - } else if (l) { - _l = l[1]; - _k = k - 1 | 0; - continue ; - } else { - throw [ - Caml_builtin_exceptions.assert_failure, - /* tuple */[ - "list.ml", - 262, - 11 - ] - ]; - } - }; -} - -function stable_sort(cmp, l) { - var sort = function (n, l) { - if (n !== 2) { - if (n === 3 && l) { - var match = l[1]; - if (match) { - var match$1 = match[1]; - if (match$1) { - var x3 = match$1[0]; - var x2 = match[0]; - var x1 = l[0]; - if (Curry._2(cmp, x1, x2) <= 0) { - if (Curry._2(cmp, x2, x3) <= 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else if (Curry._2(cmp, x1, x3) <= 0) { - return /* :: */[ - x1, - /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } - } else if (Curry._2(cmp, x1, x3) <= 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else if (Curry._2(cmp, x2, x3) <= 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } - } - - } - - } - - } else if (l) { - var match$2 = l[1]; - if (match$2) { - var x2$1 = match$2[0]; - var x1$1 = l[0]; - if (Curry._2(cmp, x1$1, x2$1) <= 0) { - return /* :: */[ - x1$1, - /* :: */[ - x2$1, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x2$1, - /* :: */[ - x1$1, - /* [] */0 - ] - ]; - } - } - - } - var n1 = (n >> 1); - var n2 = n - n1 | 0; - var l2 = chop(n1, l); - var s1 = rev_sort(n1, l); - var s2 = rev_sort(n2, l2); - var _l1 = s1; - var _l2 = s2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1 = _l1; - if (l1) { - if (l2$1) { - var h2 = l2$1[0]; - var h1 = l1[0]; - if (Curry._2(cmp, h1, h2) > 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l1 = l1[1]; - continue ; - } else { - _accu = /* :: */[ - h2, - accu - ]; - _l2 = l2$1[1]; - continue ; - } - } else { - return rev_append(l1, accu); - } - } else { - return rev_append(l2$1, accu); - } - }; - }; - var rev_sort = function (n, l) { - if (n !== 2) { - if (n === 3 && l) { - var match = l[1]; - if (match) { - var match$1 = match[1]; - if (match$1) { - var x3 = match$1[0]; - var x2 = match[0]; - var x1 = l[0]; - if (Curry._2(cmp, x1, x2) > 0) { - if (Curry._2(cmp, x2, x3) > 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else if (Curry._2(cmp, x1, x3) > 0) { - return /* :: */[ - x1, - /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } - } else if (Curry._2(cmp, x1, x3) > 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else if (Curry._2(cmp, x2, x3) > 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } - } - - } - - } - - } else if (l) { - var match$2 = l[1]; - if (match$2) { - var x2$1 = match$2[0]; - var x1$1 = l[0]; - if (Curry._2(cmp, x1$1, x2$1) > 0) { - return /* :: */[ - x1$1, - /* :: */[ - x2$1, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x2$1, - /* :: */[ - x1$1, - /* [] */0 - ] - ]; - } - } - - } - var n1 = (n >> 1); - var n2 = n - n1 | 0; - var l2 = chop(n1, l); - var s1 = sort(n1, l); - var s2 = sort(n2, l2); - var _l1 = s1; - var _l2 = s2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1 = _l1; - if (l1) { - if (l2$1) { - var h2 = l2$1[0]; - var h1 = l1[0]; - if (Curry._2(cmp, h1, h2) <= 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l1 = l1[1]; - continue ; - } else { - _accu = /* :: */[ - h2, - accu - ]; - _l2 = l2$1[1]; - continue ; - } - } else { - return rev_append(l1, accu); - } - } else { - return rev_append(l2$1, accu); - } - }; - }; - var len = length(l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -function sort_uniq(cmp, l) { - var sort = function (n, l) { - if (n !== 2) { - if (n === 3 && l) { - var match = l[1]; - if (match) { - var match$1 = match[1]; - if (match$1) { - var x3 = match$1[0]; - var x2 = match[0]; - var x1 = l[0]; - var c = Curry._2(cmp, x1, x2); - if (c === 0) { - var c$1 = Curry._2(cmp, x2, x3); - if (c$1 === 0) { - return /* :: */[ - x2, - /* [] */0 - ]; - } else if (c$1 < 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } - } else if (c < 0) { - var c$2 = Curry._2(cmp, x2, x3); - if (c$2 === 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } else if (c$2 < 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else { - var c$3 = Curry._2(cmp, x1, x3); - if (c$3 === 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } else if (c$3 < 0) { - return /* :: */[ - x1, - /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } - } - } else { - var c$4 = Curry._2(cmp, x1, x3); - if (c$4 === 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ]; - } else if (c$4 < 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else { - var c$5 = Curry._2(cmp, x2, x3); - if (c$5 === 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ]; - } else if (c$5 < 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } - } - } - } - - } - - } - - } else if (l) { - var match$2 = l[1]; - if (match$2) { - var x2$1 = match$2[0]; - var x1$1 = l[0]; - var c$6 = Curry._2(cmp, x1$1, x2$1); - if (c$6 === 0) { - return /* :: */[ - x1$1, - /* [] */0 - ]; - } else if (c$6 < 0) { - return /* :: */[ - x1$1, - /* :: */[ - x2$1, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x2$1, - /* :: */[ - x1$1, - /* [] */0 - ] - ]; - } - } - - } - var n1 = (n >> 1); - var n2 = n - n1 | 0; - var l2 = chop(n1, l); - var s1 = rev_sort(n1, l); - var s2 = rev_sort(n2, l2); - var _l1 = s1; - var _l2 = s2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1 = _l1; - if (l1) { - if (l2$1) { - var t2 = l2$1[1]; - var h2 = l2$1[0]; - var t1 = l1[1]; - var h1 = l1[0]; - var c$7 = Curry._2(cmp, h1, h2); - if (c$7 === 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l2 = t2; - _l1 = t1; - continue ; - } else if (c$7 > 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l1 = t1; - continue ; - } else { - _accu = /* :: */[ - h2, - accu - ]; - _l2 = t2; - continue ; - } - } else { - return rev_append(l1, accu); - } - } else { - return rev_append(l2$1, accu); - } - }; - }; - var rev_sort = function (n, l) { - if (n !== 2) { - if (n === 3 && l) { - var match = l[1]; - if (match) { - var match$1 = match[1]; - if (match$1) { - var x3 = match$1[0]; - var x2 = match[0]; - var x1 = l[0]; - var c = Curry._2(cmp, x1, x2); - if (c === 0) { - var c$1 = Curry._2(cmp, x2, x3); - if (c$1 === 0) { - return /* :: */[ - x2, - /* [] */0 - ]; - } else if (c$1 > 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } - } else if (c > 0) { - var c$2 = Curry._2(cmp, x2, x3); - if (c$2 === 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } else if (c$2 > 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else { - var c$3 = Curry._2(cmp, x1, x3); - if (c$3 === 0) { - return /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ]; - } else if (c$3 > 0) { - return /* :: */[ - x1, - /* :: */[ - x3, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x1, - /* :: */[ - x2, - /* [] */0 - ] - ] - ]; - } - } - } else { - var c$4 = Curry._2(cmp, x1, x3); - if (c$4 === 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ]; - } else if (c$4 > 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* :: */[ - x3, - /* [] */0 - ] - ] - ]; - } else { - var c$5 = Curry._2(cmp, x2, x3); - if (c$5 === 0) { - return /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ]; - } else if (c$5 > 0) { - return /* :: */[ - x2, - /* :: */[ - x3, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } else { - return /* :: */[ - x3, - /* :: */[ - x2, - /* :: */[ - x1, - /* [] */0 - ] - ] - ]; - } - } - } - } - - } - - } - - } else if (l) { - var match$2 = l[1]; - if (match$2) { - var x2$1 = match$2[0]; - var x1$1 = l[0]; - var c$6 = Curry._2(cmp, x1$1, x2$1); - if (c$6 === 0) { - return /* :: */[ - x1$1, - /* [] */0 - ]; - } else if (c$6 > 0) { - return /* :: */[ - x1$1, - /* :: */[ - x2$1, - /* [] */0 - ] - ]; - } else { - return /* :: */[ - x2$1, - /* :: */[ - x1$1, - /* [] */0 - ] - ]; - } - } - - } - var n1 = (n >> 1); - var n2 = n - n1 | 0; - var l2 = chop(n1, l); - var s1 = sort(n1, l); - var s2 = sort(n2, l2); - var _l1 = s1; - var _l2 = s2; - var _accu = /* [] */0; - while(true) { - var accu = _accu; - var l2$1 = _l2; - var l1 = _l1; - if (l1) { - if (l2$1) { - var t2 = l2$1[1]; - var h2 = l2$1[0]; - var t1 = l1[1]; - var h1 = l1[0]; - var c$7 = Curry._2(cmp, h1, h2); - if (c$7 === 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l2 = t2; - _l1 = t1; - continue ; - } else if (c$7 < 0) { - _accu = /* :: */[ - h1, - accu - ]; - _l1 = t1; - continue ; - } else { - _accu = /* :: */[ - h2, - accu - ]; - _l2 = t2; - continue ; - } - } else { - return rev_append(l1, accu); - } - } else { - return rev_append(l2$1, accu); - } - }; - }; - var len = length(l); - if (len < 2) { - return l; - } else { - return sort(len, l); - } -} - -function compare_lengths(_l1, _l2) { - while(true) { - var l2 = _l2; - var l1 = _l1; - if (l1) { - if (l2) { - _l2 = l2[1]; - _l1 = l1[1]; - continue ; - } else { - return 1; - } - } else if (l2) { - return -1; - } else { - return 0; - } - }; -} - -function compare_length_with(_l, _n) { - while(true) { - var n = _n; - var l = _l; - if (l) { - if (n <= 0) { - return 1; - } else { - _n = n - 1 | 0; - _l = l[1]; - continue ; - } - } else if (n === 0) { - return 0; - } else if (n > 0) { - return -1; - } else { - return 1; - } - }; -} - -var append = Pervasives.$at; - -var concat = flatten; - -var filter = find_all; - -var sort = stable_sort; - -var fast_sort = stable_sort; - -exports.length = length; -exports.compare_lengths = compare_lengths; -exports.compare_length_with = compare_length_with; -exports.cons = cons; -exports.hd = hd; -exports.tl = tl; -exports.nth = nth; -exports.nth_opt = nth_opt; -exports.rev = rev; -exports.init = init; -exports.append = append; -exports.rev_append = rev_append; -exports.concat = concat; -exports.flatten = flatten; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi$1; -exports.rev_map = rev_map; -exports.fold_left = fold_left; -exports.fold_right = fold_right; -exports.iter2 = iter2; -exports.map2 = map2; -exports.rev_map2 = rev_map2; -exports.fold_left2 = fold_left2; -exports.fold_right2 = fold_right2; -exports.for_all = for_all; -exports.exists = exists; -exports.for_all2 = for_all2; -exports.exists2 = exists2; -exports.mem = mem; -exports.memq = memq; -exports.find = find; -exports.find_opt = find_opt; -exports.filter = filter; -exports.find_all = find_all; -exports.partition = partition; -exports.assoc = assoc; -exports.assoc_opt = assoc_opt; -exports.assq = assq; -exports.assq_opt = assq_opt; -exports.mem_assoc = mem_assoc; -exports.mem_assq = mem_assq; -exports.remove_assoc = remove_assoc; -exports.remove_assq = remove_assq; -exports.split = split; -exports.combine = combine; -exports.sort = sort; -exports.stable_sort = stable_sort; -exports.fast_sort = fast_sort; -exports.sort_uniq = sort_uniq; -exports.merge = merge; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40,"./caml_obj.js":49,"./caml_option.js":50,"./curry.js":58,"./pervasives.js":62}],62:[function(require,module,exports){ -'use strict'; - -var Curry = require("./curry.js"); -var Caml_io = require("./caml_io.js"); -var Caml_sys = require("./caml_sys.js"); -var Caml_bytes = require("./caml_bytes.js"); -var Caml_format = require("./caml_format.js"); -var Caml_string = require("./caml_string.js"); -var Caml_exceptions = require("./caml_exceptions.js"); -var Caml_js_exceptions = require("./caml_js_exceptions.js"); -var Caml_external_polyfill = require("./caml_external_polyfill.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); -var CamlinternalFormatBasics = require("./camlinternalFormatBasics.js"); - -function failwith(s) { - throw [ - Caml_builtin_exceptions.failure, - s - ]; -} - -function invalid_arg(s) { - throw [ - Caml_builtin_exceptions.invalid_argument, - s - ]; -} - -var Exit = Caml_exceptions.create("Pervasives.Exit"); - -function abs(x) { - if (x >= 0) { - return x; - } else { - return -x | 0; - } -} - -function lnot(x) { - return x ^ -1; -} - -var min_int = -2147483648; - -function classify_float(x) { - if (isFinite(x)) { - if (Math.abs(x) >= 2.22507385850720138e-308) { - return /* FP_normal */0; - } else if (x !== 0) { - return /* FP_subnormal */1; - } else { - return /* FP_zero */2; - } - } else if (isNaN(x)) { - return /* FP_nan */4; - } else { - return /* FP_infinite */3; - } -} - -function char_of_int(n) { - if (n < 0 || n > 255) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "char_of_int" - ]; - } - return n; -} - -function string_of_bool(b) { - if (b) { - return "true"; - } else { - return "false"; - } -} - -function bool_of_string(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - throw [ - Caml_builtin_exceptions.invalid_argument, - "bool_of_string" - ]; - } -} - -function bool_of_string_opt(param) { - switch (param) { - case "false" : - return false; - case "true" : - return true; - default: - return ; - } -} - -function int_of_string_opt(s) { - try { - return Caml_format.caml_int_of_string(s); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Caml_builtin_exceptions.failure) { - return ; - } else { - throw exn; - } - } -} - -function valid_float_lexem(s) { - var l = s.length; - var _i = 0; - while(true) { - var i = _i; - if (i >= l) { - return s + "."; - } else { - var match = Caml_string.get(s, i); - if (match >= 48) { - if (match >= 58) { - return s; - } else { - _i = i + 1 | 0; - continue ; - } - } else if (match !== 45) { - return s; - } else { - _i = i + 1 | 0; - continue ; - } - } - }; -} - -function string_of_float(f) { - return valid_float_lexem(Caml_format.caml_format_float("%.12g", f)); -} - -function float_of_string_opt(s) { - try { - return Caml_format.caml_float_of_string(s); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] === Caml_builtin_exceptions.failure) { - return ; - } else { - throw exn; - } - } -} - -function $at(l1, l2) { - if (l1) { - return /* :: */[ - l1[0], - $at(l1[1], l2) - ]; - } else { - return l2; - } -} - -var stdin = Caml_io.stdin; - -var stdout = Caml_io.stdout; - -var stderr = Caml_io.stderr; - -function open_out_gen(mode, perm, name) { - var c = Caml_external_polyfill.resolve("caml_ml_open_descriptor_out")(Caml_external_polyfill.resolve("caml_sys_open")(name, mode, perm)); - Caml_external_polyfill.resolve("caml_ml_set_channel_name")(c, name); - return c; -} - -function open_out(name) { - return open_out_gen(/* :: */[ - /* Open_wronly */1, - /* :: */[ - /* Open_creat */3, - /* :: */[ - /* Open_trunc */4, - /* :: */[ - /* Open_text */7, - /* [] */0 - ] - ] - ] - ], 438, name); -} - -function open_out_bin(name) { - return open_out_gen(/* :: */[ - /* Open_wronly */1, - /* :: */[ - /* Open_creat */3, - /* :: */[ - /* Open_trunc */4, - /* :: */[ - /* Open_binary */6, - /* [] */0 - ] - ] - ] - ], 438, name); -} - -function flush_all(param) { - var _param = Caml_io.caml_ml_out_channels_list(/* () */0); - while(true) { - var param$1 = _param; - if (param$1) { - try { - Caml_io.caml_ml_flush(param$1[0]); - } - catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn[0] !== Caml_builtin_exceptions.sys_error) { - throw exn; - } - - } - _param = param$1[1]; - continue ; - } else { - return /* () */0; - } - }; -} - -function output_bytes(oc, s) { - return Caml_external_polyfill.resolve("caml_ml_output_bytes")(oc, s, 0, s.length); -} - -function output_string(oc, s) { - return Caml_io.caml_ml_output(oc, s, 0, s.length); -} - -function output(oc, s, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "output" - ]; - } - return Caml_external_polyfill.resolve("caml_ml_output_bytes")(oc, s, ofs, len); -} - -function output_substring(oc, s, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "output_substring" - ]; - } - return Caml_io.caml_ml_output(oc, s, ofs, len); -} - -function output_value(chan, v) { - return Caml_external_polyfill.resolve("caml_output_value")(chan, v, /* [] */0); -} - -function close_out(oc) { - Caml_io.caml_ml_flush(oc); - return Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); -} - -function close_out_noerr(oc) { - try { - Caml_io.caml_ml_flush(oc); - } - catch (exn){ - - } - try { - return Caml_external_polyfill.resolve("caml_ml_close_channel")(oc); - } - catch (exn$1){ - return /* () */0; - } -} - -function open_in_gen(mode, perm, name) { - var c = Caml_external_polyfill.resolve("caml_ml_open_descriptor_in")(Caml_external_polyfill.resolve("caml_sys_open")(name, mode, perm)); - Caml_external_polyfill.resolve("caml_ml_set_channel_name")(c, name); - return c; -} - -function open_in(name) { - return open_in_gen(/* :: */[ - /* Open_rdonly */0, - /* :: */[ - /* Open_text */7, - /* [] */0 - ] - ], 0, name); -} - -function open_in_bin(name) { - return open_in_gen(/* :: */[ - /* Open_rdonly */0, - /* :: */[ - /* Open_binary */6, - /* [] */0 - ] - ], 0, name); -} - -function input(ic, s, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "input" - ]; - } - return Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); -} - -function unsafe_really_input(ic, s, _ofs, _len) { - while(true) { - var len = _len; - var ofs = _ofs; - if (len <= 0) { - return /* () */0; - } else { - var r = Caml_external_polyfill.resolve("caml_ml_input")(ic, s, ofs, len); - if (r === 0) { - throw Caml_builtin_exceptions.end_of_file; - } - _len = len - r | 0; - _ofs = ofs + r | 0; - continue ; - } - }; -} - -function really_input(ic, s, ofs, len) { - if (ofs < 0 || len < 0 || ofs > (s.length - len | 0)) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "really_input" - ]; - } - return unsafe_really_input(ic, s, ofs, len); -} - -function really_input_string(ic, len) { - var s = Caml_bytes.caml_create_bytes(len); - really_input(ic, s, 0, len); - return Caml_bytes.bytes_to_string(s); -} - -function input_line(chan) { - var build_result = function (buf, _pos, _param) { - while(true) { - var param = _param; - var pos = _pos; - if (param) { - var hd = param[0]; - var len = hd.length; - Caml_bytes.caml_blit_bytes(hd, 0, buf, pos - len | 0, len); - _param = param[1]; - _pos = pos - len | 0; - continue ; - } else { - return buf; - } - }; - }; - var scan = function (_accu, _len) { - while(true) { - var len = _len; - var accu = _accu; - var n = Caml_external_polyfill.resolve("caml_ml_input_scan_line")(chan); - if (n === 0) { - if (accu) { - return build_result(Caml_bytes.caml_create_bytes(len), len, accu); - } else { - throw Caml_builtin_exceptions.end_of_file; - } - } else if (n > 0) { - var res = Caml_bytes.caml_create_bytes(n - 1 | 0); - Caml_external_polyfill.resolve("caml_ml_input")(chan, res, 0, n - 1 | 0); - Caml_external_polyfill.resolve("caml_ml_input_char")(chan); - if (accu) { - var len$1 = (len + n | 0) - 1 | 0; - return build_result(Caml_bytes.caml_create_bytes(len$1), len$1, /* :: */[ - res, - accu - ]); - } else { - return res; - } - } else { - var beg = Caml_bytes.caml_create_bytes(-n | 0); - Caml_external_polyfill.resolve("caml_ml_input")(chan, beg, 0, -n | 0); - _len = len - n | 0; - _accu = /* :: */[ - beg, - accu - ]; - continue ; - } - }; - }; - return Caml_bytes.bytes_to_string(scan(/* [] */0, 0)); -} - -function close_in_noerr(ic) { - try { - return Caml_external_polyfill.resolve("caml_ml_close_channel")(ic); - } - catch (exn){ - return /* () */0; - } -} - -function print_char(c) { - return Caml_io.caml_ml_output_char(stdout, c); -} - -function print_string(s) { - return output_string(stdout, s); -} - -function print_bytes(s) { - return output_bytes(stdout, s); -} - -function print_int(i) { - return output_string(stdout, String(i)); -} - -function print_float(f) { - return output_string(stdout, valid_float_lexem(Caml_format.caml_format_float("%.12g", f))); -} - -function print_newline(param) { - Caml_io.caml_ml_output_char(stdout, /* "\n" */10); - return Caml_io.caml_ml_flush(stdout); -} - -function prerr_char(c) { - return Caml_io.caml_ml_output_char(stderr, c); -} - -function prerr_string(s) { - return output_string(stderr, s); -} - -function prerr_bytes(s) { - return output_bytes(stderr, s); -} - -function prerr_int(i) { - return output_string(stderr, String(i)); -} - -function prerr_float(f) { - return output_string(stderr, valid_float_lexem(Caml_format.caml_format_float("%.12g", f))); -} - -function prerr_newline(param) { - Caml_io.caml_ml_output_char(stderr, /* "\n" */10); - return Caml_io.caml_ml_flush(stderr); -} - -function read_line(param) { - Caml_io.caml_ml_flush(stdout); - return input_line(stdin); -} - -function read_int(param) { - return Caml_format.caml_int_of_string((Caml_io.caml_ml_flush(stdout), input_line(stdin))); -} - -function read_int_opt(param) { - return int_of_string_opt((Caml_io.caml_ml_flush(stdout), input_line(stdin))); -} - -function read_float(param) { - return Caml_format.caml_float_of_string((Caml_io.caml_ml_flush(stdout), input_line(stdin))); -} - -function read_float_opt(param) { - return float_of_string_opt((Caml_io.caml_ml_flush(stdout), input_line(stdin))); -} - -function string_of_format(param) { - return param[1]; -} - -function $caret$caret(param, param$1) { - return /* Format */[ - CamlinternalFormatBasics.concat_fmt(param[0], param$1[0]), - param[1] + ("%," + param$1[1]) - ]; -} - -var exit_function = { - contents: flush_all -}; - -function at_exit(f) { - var g = exit_function.contents; - exit_function.contents = (function (param) { - Curry._1(f, /* () */0); - return Curry._1(g, /* () */0); - }); - return /* () */0; -} - -function do_at_exit(param) { - return Curry._1(exit_function.contents, /* () */0); -} - -function exit(retcode) { - do_at_exit(/* () */0); - return Caml_sys.caml_sys_exit(retcode); -} - -var max_int = 2147483647; - -var infinity = Infinity; - -var neg_infinity = -Infinity; - -var max_float = 1.79769313486231571e+308; - -var min_float = 2.22507385850720138e-308; - -var epsilon_float = 2.22044604925031308e-16; - -var flush = Caml_io.caml_ml_flush; - -var output_char = Caml_io.caml_ml_output_char; - -var output_byte = Caml_io.caml_ml_output_char; - -function output_binary_int(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_output_int")(prim, prim$1); -} - -function seek_out(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_seek_out")(prim, prim$1); -} - -function pos_out(prim) { - return Caml_external_polyfill.resolve("caml_ml_pos_out")(prim); -} - -function out_channel_length(prim) { - return Caml_external_polyfill.resolve("caml_ml_channel_size")(prim); -} - -function set_binary_mode_out(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_set_binary_mode")(prim, prim$1); -} - -function input_char(prim) { - return Caml_external_polyfill.resolve("caml_ml_input_char")(prim); -} - -function input_byte(prim) { - return Caml_external_polyfill.resolve("caml_ml_input_char")(prim); -} - -function input_binary_int(prim) { - return Caml_external_polyfill.resolve("caml_ml_input_int")(prim); -} - -function input_value(prim) { - return Caml_external_polyfill.resolve("caml_input_value")(prim); -} - -function seek_in(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_seek_in")(prim, prim$1); -} - -function pos_in(prim) { - return Caml_external_polyfill.resolve("caml_ml_pos_in")(prim); -} - -function in_channel_length(prim) { - return Caml_external_polyfill.resolve("caml_ml_channel_size")(prim); -} - -function close_in(prim) { - return Caml_external_polyfill.resolve("caml_ml_close_channel")(prim); -} - -function set_binary_mode_in(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_set_binary_mode")(prim, prim$1); -} - -function LargeFile_seek_out(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_seek_out_64")(prim, prim$1); -} - -function LargeFile_pos_out(prim) { - return Caml_external_polyfill.resolve("caml_ml_pos_out_64")(prim); -} - -function LargeFile_out_channel_length(prim) { - return Caml_external_polyfill.resolve("caml_ml_channel_size_64")(prim); -} - -function LargeFile_seek_in(prim, prim$1) { - return Caml_external_polyfill.resolve("caml_ml_seek_in_64")(prim, prim$1); -} - -function LargeFile_pos_in(prim) { - return Caml_external_polyfill.resolve("caml_ml_pos_in_64")(prim); -} - -function LargeFile_in_channel_length(prim) { - return Caml_external_polyfill.resolve("caml_ml_channel_size_64")(prim); -} - -var LargeFile = { - seek_out: LargeFile_seek_out, - pos_out: LargeFile_pos_out, - out_channel_length: LargeFile_out_channel_length, - seek_in: LargeFile_seek_in, - pos_in: LargeFile_pos_in, - in_channel_length: LargeFile_in_channel_length -}; - -exports.invalid_arg = invalid_arg; -exports.failwith = failwith; -exports.Exit = Exit; -exports.abs = abs; -exports.max_int = max_int; -exports.min_int = min_int; -exports.lnot = lnot; -exports.infinity = infinity; -exports.neg_infinity = neg_infinity; -exports.max_float = max_float; -exports.min_float = min_float; -exports.epsilon_float = epsilon_float; -exports.classify_float = classify_float; -exports.char_of_int = char_of_int; -exports.string_of_bool = string_of_bool; -exports.bool_of_string = bool_of_string; -exports.bool_of_string_opt = bool_of_string_opt; -exports.int_of_string_opt = int_of_string_opt; -exports.string_of_float = string_of_float; -exports.float_of_string_opt = float_of_string_opt; -exports.$at = $at; -exports.stdin = stdin; -exports.stdout = stdout; -exports.stderr = stderr; -exports.print_char = print_char; -exports.print_string = print_string; -exports.print_bytes = print_bytes; -exports.print_int = print_int; -exports.print_float = print_float; -exports.print_newline = print_newline; -exports.prerr_char = prerr_char; -exports.prerr_string = prerr_string; -exports.prerr_bytes = prerr_bytes; -exports.prerr_int = prerr_int; -exports.prerr_float = prerr_float; -exports.prerr_newline = prerr_newline; -exports.read_line = read_line; -exports.read_int = read_int; -exports.read_int_opt = read_int_opt; -exports.read_float = read_float; -exports.read_float_opt = read_float_opt; -exports.open_out = open_out; -exports.open_out_bin = open_out_bin; -exports.open_out_gen = open_out_gen; -exports.flush = flush; -exports.flush_all = flush_all; -exports.output_char = output_char; -exports.output_string = output_string; -exports.output_bytes = output_bytes; -exports.output = output; -exports.output_substring = output_substring; -exports.output_byte = output_byte; -exports.output_binary_int = output_binary_int; -exports.output_value = output_value; -exports.seek_out = seek_out; -exports.pos_out = pos_out; -exports.out_channel_length = out_channel_length; -exports.close_out = close_out; -exports.close_out_noerr = close_out_noerr; -exports.set_binary_mode_out = set_binary_mode_out; -exports.open_in = open_in; -exports.open_in_bin = open_in_bin; -exports.open_in_gen = open_in_gen; -exports.input_char = input_char; -exports.input_line = input_line; -exports.input = input; -exports.really_input = really_input; -exports.really_input_string = really_input_string; -exports.input_byte = input_byte; -exports.input_binary_int = input_binary_int; -exports.input_value = input_value; -exports.seek_in = seek_in; -exports.pos_in = pos_in; -exports.in_channel_length = in_channel_length; -exports.close_in = close_in; -exports.close_in_noerr = close_in_noerr; -exports.set_binary_mode_in = set_binary_mode_in; -exports.LargeFile = LargeFile; -exports.string_of_format = string_of_format; -exports.$caret$caret = $caret$caret; -exports.exit = exit; -exports.at_exit = at_exit; -exports.valid_float_lexem = valid_float_lexem; -exports.unsafe_really_input = unsafe_really_input; -exports.do_at_exit = do_at_exit; -/* No side effect */ - -},{"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41,"./caml_exceptions.js":42,"./caml_external_polyfill.js":43,"./caml_format.js":44,"./caml_io.js":47,"./caml_js_exceptions.js":48,"./caml_string.js":52,"./caml_sys.js":53,"./camlinternalFormatBasics.js":56,"./curry.js":58}],63:[function(require,module,exports){ -'use strict'; - -var Curry = require("./curry.js"); -var $$Buffer = require("./buffer.js"); -var Pervasives = require("./pervasives.js"); -var CamlinternalFormat = require("./camlinternalFormat.js"); - -function kfprintf(k, o, param) { - return CamlinternalFormat.make_printf((function (o, acc) { - CamlinternalFormat.output_acc(o, acc); - return Curry._1(k, o); - }), o, /* End_of_acc */0, param[0]); -} - -function kbprintf(k, b, param) { - return CamlinternalFormat.make_printf((function (b, acc) { - CamlinternalFormat.bufput_acc(b, acc); - return Curry._1(k, b); - }), b, /* End_of_acc */0, param[0]); -} - -function ikfprintf(k, oc, param) { - return CamlinternalFormat.make_iprintf(k, oc, param[0]); -} - -function fprintf(oc, fmt) { - return kfprintf((function (prim) { - return /* () */0; - }), oc, fmt); -} - -function bprintf(b, fmt) { - return kbprintf((function (prim) { - return /* () */0; - }), b, fmt); -} - -function ifprintf(oc, fmt) { - return ikfprintf((function (prim) { - return /* () */0; - }), oc, fmt); -} - -function printf(fmt) { - return fprintf(Pervasives.stdout, fmt); -} - -function eprintf(fmt) { - return fprintf(Pervasives.stderr, fmt); -} - -function ksprintf(k, param) { - var k$prime = function (param, acc) { - var buf = $$Buffer.create(64); - CamlinternalFormat.strput_acc(buf, acc); - return Curry._1(k, $$Buffer.contents(buf)); - }; - return CamlinternalFormat.make_printf(k$prime, /* () */0, /* End_of_acc */0, param[0]); -} - -function sprintf(fmt) { - return ksprintf((function (s) { - return s; - }), fmt); -} - -var kprintf = ksprintf; - -exports.fprintf = fprintf; -exports.printf = printf; -exports.eprintf = eprintf; -exports.sprintf = sprintf; -exports.bprintf = bprintf; -exports.ifprintf = ifprintf; -exports.kfprintf = kfprintf; -exports.ikfprintf = ikfprintf; -exports.ksprintf = ksprintf; -exports.kbprintf = kbprintf; -exports.kprintf = kprintf; -/* No side effect */ - -},{"./buffer.js":37,"./camlinternalFormat.js":55,"./curry.js":58,"./pervasives.js":62}],64:[function(require,module,exports){ -'use strict'; - -var Bytes = require("./bytes.js"); -var Curry = require("./curry.js"); -var Caml_bytes = require("./caml_bytes.js"); -var Caml_primitive = require("./caml_primitive.js"); -var Caml_builtin_exceptions = require("./caml_builtin_exceptions.js"); - -function make(n, c) { - return Caml_bytes.bytes_to_string(Bytes.make(n, c)); -} - -function init(n, f) { - return Caml_bytes.bytes_to_string(Bytes.init(n, f)); -} - -function copy(s) { - return Caml_bytes.bytes_to_string(Bytes.copy(Caml_bytes.bytes_of_string(s))); -} - -function sub(s, ofs, len) { - return Caml_bytes.bytes_to_string(Bytes.sub(Caml_bytes.bytes_of_string(s), ofs, len)); -} - -function ensure_ge(x, y) { - if (x >= y) { - return x; - } else { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.concat" - ]; - } -} - -function sum_lengths(_acc, seplen, _param) { - while(true) { - var param = _param; - var acc = _acc; - if (param) { - var tl = param[1]; - var hd = param[0]; - if (tl) { - _param = tl; - _acc = ensure_ge((hd.length + seplen | 0) + acc | 0, acc); - continue ; - } else { - return hd.length + acc | 0; - } - } else { - return acc; - } - }; -} - -function unsafe_blits(dst, _pos, sep, seplen, _param) { - while(true) { - var param = _param; - var pos = _pos; - if (param) { - var tl = param[1]; - var hd = param[0]; - if (tl) { - Caml_bytes.caml_blit_string(hd, 0, dst, pos, hd.length); - Caml_bytes.caml_blit_string(sep, 0, dst, pos + hd.length | 0, seplen); - _param = tl; - _pos = (pos + hd.length | 0) + seplen | 0; - continue ; - } else { - Caml_bytes.caml_blit_string(hd, 0, dst, pos, hd.length); - return dst; - } - } else { - return dst; - } - }; -} - -function concat(sep, l) { - if (l) { - var seplen = sep.length; - return Caml_bytes.bytes_to_string(unsafe_blits(Caml_bytes.caml_create_bytes(sum_lengths(0, seplen, l)), 0, sep, seplen, l)); - } else { - return ""; - } -} - -function iter(f, s) { - for(var i = 0 ,i_finish = s.length - 1 | 0; i <= i_finish; ++i){ - Curry._1(f, s.charCodeAt(i)); - } - return /* () */0; -} - -function iteri(f, s) { - for(var i = 0 ,i_finish = s.length - 1 | 0; i <= i_finish; ++i){ - Curry._2(f, i, s.charCodeAt(i)); - } - return /* () */0; -} - -function map(f, s) { - return Caml_bytes.bytes_to_string(Bytes.map(f, Caml_bytes.bytes_of_string(s))); -} - -function mapi(f, s) { - return Caml_bytes.bytes_to_string(Bytes.mapi(f, Caml_bytes.bytes_of_string(s))); -} - -function is_space(param) { - var switcher = param - 9 | 0; - if (switcher > 4 || switcher < 0) { - return switcher === 23; - } else { - return switcher !== 2; - } -} - -function trim(s) { - if (s === "" || !(is_space(s.charCodeAt(0)) || is_space(s.charCodeAt(s.length - 1 | 0)))) { - return s; - } else { - return Caml_bytes.bytes_to_string(Bytes.trim(Caml_bytes.bytes_of_string(s))); - } -} - -function escaped(s) { - var needs_escape = function (_i) { - while(true) { - var i = _i; - if (i >= s.length) { - return false; - } else { - var match = s.charCodeAt(i); - if (match >= 32) { - var switcher = match - 34 | 0; - if (switcher > 58 || switcher < 0) { - if (switcher >= 93) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - } else if (switcher > 57 || switcher < 1) { - return true; - } else { - _i = i + 1 | 0; - continue ; - } - } else { - return true; - } - } - }; - }; - if (needs_escape(0)) { - return Caml_bytes.bytes_to_string(Bytes.escaped(Caml_bytes.bytes_of_string(s))); - } else { - return s; - } -} - -function index_rec(s, lim, _i, c) { - while(true) { - var i = _i; - if (i >= lim) { - throw Caml_builtin_exceptions.not_found; - } - if (s.charCodeAt(i) === c) { - return i; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function index(s, c) { - return index_rec(s, s.length, 0, c); -} - -function index_rec_opt(s, lim, _i, c) { - while(true) { - var i = _i; - if (i >= lim) { - return ; - } else if (s.charCodeAt(i) === c) { - return i; - } else { - _i = i + 1 | 0; - continue ; - } - }; -} - -function index_opt(s, c) { - return index_rec_opt(s, s.length, 0, c); -} - -function index_from(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.index_from / Bytes.index_from" - ]; - } - return index_rec(s, l, i, c); -} - -function index_from_opt(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.index_from_opt / Bytes.index_from_opt" - ]; - } - return index_rec_opt(s, l, i, c); -} - -function rindex_rec(s, _i, c) { - while(true) { - var i = _i; - if (i < 0) { - throw Caml_builtin_exceptions.not_found; - } - if (s.charCodeAt(i) === c) { - return i; - } else { - _i = i - 1 | 0; - continue ; - } - }; -} - -function rindex(s, c) { - return rindex_rec(s, s.length - 1 | 0, c); -} - -function rindex_from(s, i, c) { - if (i < -1 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rindex_from / Bytes.rindex_from" - ]; - } - return rindex_rec(s, i, c); -} - -function rindex_rec_opt(s, _i, c) { - while(true) { - var i = _i; - if (i < 0) { - return ; - } else if (s.charCodeAt(i) === c) { - return i; - } else { - _i = i - 1 | 0; - continue ; - } - }; -} - -function rindex_opt(s, c) { - return rindex_rec_opt(s, s.length - 1 | 0, c); -} - -function rindex_from_opt(s, i, c) { - if (i < -1 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rindex_from_opt / Bytes.rindex_from_opt" - ]; - } - return rindex_rec_opt(s, i, c); -} - -function contains_from(s, i, c) { - var l = s.length; - if (i < 0 || i > l) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.contains_from / Bytes.contains_from" - ]; - } - try { - index_rec(s, l, i, c); - return true; - } - catch (exn){ - if (exn === Caml_builtin_exceptions.not_found) { - return false; - } else { - throw exn; - } - } -} - -function contains(s, c) { - return contains_from(s, 0, c); -} - -function rcontains_from(s, i, c) { - if (i < 0 || i >= s.length) { - throw [ - Caml_builtin_exceptions.invalid_argument, - "String.rcontains_from / Bytes.rcontains_from" - ]; - } - try { - rindex_rec(s, i, c); - return true; - } - catch (exn){ - if (exn === Caml_builtin_exceptions.not_found) { - return false; - } else { - throw exn; - } - } -} - -function uppercase_ascii(s) { - return Caml_bytes.bytes_to_string(Bytes.uppercase_ascii(Caml_bytes.bytes_of_string(s))); -} - -function lowercase_ascii(s) { - return Caml_bytes.bytes_to_string(Bytes.lowercase_ascii(Caml_bytes.bytes_of_string(s))); -} - -function capitalize_ascii(s) { - return Caml_bytes.bytes_to_string(Bytes.capitalize_ascii(Caml_bytes.bytes_of_string(s))); -} - -function uncapitalize_ascii(s) { - return Caml_bytes.bytes_to_string(Bytes.uncapitalize_ascii(Caml_bytes.bytes_of_string(s))); -} - -var compare = Caml_primitive.caml_string_compare; - -function split_on_char(sep, s) { - var r = /* [] */0; - var j = s.length; - for(var i = s.length - 1 | 0; i >= 0; --i){ - if (s.charCodeAt(i) === sep) { - r = /* :: */[ - sub(s, i + 1 | 0, (j - i | 0) - 1 | 0), - r - ]; - j = i; - } - - } - return /* :: */[ - sub(s, 0, j), - r - ]; -} - -function uppercase(s) { - return Caml_bytes.bytes_to_string(Bytes.uppercase(Caml_bytes.bytes_of_string(s))); -} - -function lowercase(s) { - return Caml_bytes.bytes_to_string(Bytes.lowercase(Caml_bytes.bytes_of_string(s))); -} - -function capitalize(s) { - return Caml_bytes.bytes_to_string(Bytes.capitalize(Caml_bytes.bytes_of_string(s))); -} - -function uncapitalize(s) { - return Caml_bytes.bytes_to_string(Bytes.uncapitalize(Caml_bytes.bytes_of_string(s))); -} - -var fill = Bytes.fill; - -var blit = Bytes.blit_string; - -function equal(prim, prim$1) { - return prim === prim$1; -} - -exports.make = make; -exports.init = init; -exports.copy = copy; -exports.sub = sub; -exports.fill = fill; -exports.blit = blit; -exports.concat = concat; -exports.iter = iter; -exports.iteri = iteri; -exports.map = map; -exports.mapi = mapi; -exports.trim = trim; -exports.escaped = escaped; -exports.index = index; -exports.index_opt = index_opt; -exports.rindex = rindex; -exports.rindex_opt = rindex_opt; -exports.index_from = index_from; -exports.index_from_opt = index_from_opt; -exports.rindex_from = rindex_from; -exports.rindex_from_opt = rindex_from_opt; -exports.contains = contains; -exports.contains_from = contains_from; -exports.rcontains_from = rcontains_from; -exports.uppercase = uppercase; -exports.lowercase = lowercase; -exports.capitalize = capitalize; -exports.uncapitalize = uncapitalize; -exports.uppercase_ascii = uppercase_ascii; -exports.lowercase_ascii = lowercase_ascii; -exports.capitalize_ascii = capitalize_ascii; -exports.uncapitalize_ascii = uncapitalize_ascii; -exports.compare = compare; -exports.equal = equal; -exports.split_on_char = split_on_char; -/* No side effect */ - -},{"./bytes.js":38,"./caml_builtin_exceptions.js":40,"./caml_bytes.js":41,"./caml_primitive.js":51,"./curry.js":58}],65:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - -} -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - - - -} -var queue = []; -var draining = false; -var currentQueue; -var queueIndex = -1; - -function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - draining = false; - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - if (queue.length) { - drainQueue(); - } -} - -function drainQueue() { - if (draining) { - return; - } - var timeout = runTimeout(cleanUpNextTick); - draining = true; - - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - queueIndex = -1; - len = queue.length; - } - currentQueue = null; - draining = false; - runClearTimeout(timeout); -} - -process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - queue.push(new Item(fun, args)); - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } -}; - -// v8 likes predictible objects -function Item(fun, array) { - this.fun = fun; - this.array = array; -} -Item.prototype.run = function () { - this.fun.apply(null, this.array); -}; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues -process.versions = {}; - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}]},{},[25])(25) -}); \ No newline at end of file diff --git a/lib/js/test-ocaml/test_client.js b/lib/js/test-ocaml/test_client.js deleted file mode 100644 index 9efd4ec..0000000 --- a/lib/js/test-ocaml/test_client.js +++ /dev/null @@ -1,41 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Test_client_drag = require("./test_client_drag.js"); -var Test_client_counter = require("./test_client_counter.js"); -var Test_client_http_task = require("./test_client_http_task.js"); -var Test_client_btn_update_span = require("./test_client_btn_update_span.js"); -var Test_client_on_with_options = require("./test_client_on_with_options.js"); -var Test_client_attribute_removal = require("./test_client_attribute_removal.js"); -var Test_client_counter_debug_program = require("./test_client_counter_debug_program.js"); -var Test_client_counter_debug_beginner = require("./test_client_counter_debug_beginner.js"); -var Test_client_counter_debug_standard = require("./test_client_counter_debug_standard.js"); - -var counter = Test_client_counter.main; - -var counter_debug_beginner = Test_client_counter_debug_beginner.main; - -var counter_debug_standard = Test_client_counter_debug_standard.main; - -var counter_debug_program = Test_client_counter_debug_program.main; - -var btn_update_span = Test_client_btn_update_span.main; - -var attribute_removal = Test_client_attribute_removal.main; - -var drag = Test_client_drag.main; - -var on_with_options = Test_client_on_with_options.main; - -var http_task = Test_client_http_task.main; - -exports.counter = counter; -exports.counter_debug_beginner = counter_debug_beginner; -exports.counter_debug_standard = counter_debug_standard; -exports.counter_debug_program = counter_debug_program; -exports.btn_update_span = btn_update_span; -exports.attribute_removal = attribute_removal; -exports.drag = drag; -exports.on_with_options = on_with_options; -exports.http_task = http_task; -/* Test_client_drag Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_attribute_removal.js b/lib/js/test-ocaml/test_client_attribute_removal.js deleted file mode 100644 index 6799e30..0000000 --- a/lib/js/test-ocaml/test_client_attribute_removal.js +++ /dev/null @@ -1,134 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Caml_option = require("bs-platform/lib/js/caml_option.js"); - -function select(param_0) { - return /* Select */[param_0]; -} - -function render_selected(param) { - if (param !== undefined) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["you selected " + param]), - /* :: */[ - Tea_html.div(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Delete */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["delete selection"]), - /* [] */0 - ]), - /* [] */0 - ] - ]); - } else { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["Nothing selected"]), - /* [] */0 - ]); - } -} - -function lang(l, is_selected) { - var msg = /* Select */[l]; - return Tea_html.li(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* :: */[ - Vdom.style("color", "blue"), - /* :: */[ - is_selected ? Vdom.style("border", "1px solid black") : Tea_html.noProp, - /* :: */[ - is_selected ? /* Attribute */Block.__(1, [ - "", - "lang", - l - ]) : Tea_html.noProp, - /* [] */0 - ] - ] - ] - ], /* :: */[ - /* Text */Block.__(1, [l]), - /* [] */0 - ]); -} - -function render_languages(selected, languages) { - var is_selected = function (selected, language) { - if (selected !== undefined) { - return language === Caml_option.valFromOption(selected); - } else { - return false; - } - }; - var rendered = List.map((function (l) { - return lang(l, is_selected(selected, l)); - }), languages); - return Tea_html.ul(undefined, undefined, /* [] */0, rendered); -} - -function update(state, param) { - if (param) { - return { - selected: param[0], - languages: state.languages - }; - } else { - return { - selected: undefined, - languages: state.languages - }; - } -} - -function view(state) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - render_selected(state.selected), - /* :: */[ - render_languages(state.selected, state.languages), - /* [] */0 - ] - ]); -} - -var partial_arg_model = { - selected: "Erlang", - languages: /* :: */[ - "Erlang", - /* :: */[ - "Ocaml", - /* :: */[ - "Clojure", - /* [] */0 - ] - ] - ] -}; - -var partial_arg = { - model: partial_arg_model, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var $$delete = /* Delete */0; - -exports.select = select; -exports.$$delete = $$delete; -exports.render_selected = render_selected; -exports.lang = lang; -exports.render_languages = render_languages; -exports.update = update; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_btn_update_span.js b/lib/js/test-ocaml/test_client_btn_update_span.js deleted file mode 100644 index 0fa5d75..0000000 --- a/lib/js/test-ocaml/test_client_btn_update_span.js +++ /dev/null @@ -1,70 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); - -function update$prime(model, param) { - return /* tuple */[ - model[0], - "right" - ]; -} - -function render_model(param) { - if (param[0] !== undefined && param[1] !== undefined) { - return Tea_html.input$prime(undefined, undefined, /* :: */[ - /* RawProp */Block.__(0, [ - "value", - "This should be on screen" - ]), - /* [] */0 - ], /* [] */0); - } - return Tea_html.span(undefined, undefined, /* [] */0, /* :: */[ - /* Text */Block.__(1, ["nothing"]), - /* [] */0 - ]); -} - -function view$prime(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Trigger */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["trigger rerender"]), - /* [] */0 - ]), - /* :: */[ - render_model(model), - /* [] */0 - ] - ]); -} - -var partial_arg_model = /* tuple */[ - "left", - undefined -]; - -var partial_arg = { - model: partial_arg_model, - update: update$prime, - view: view$prime -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var trigger = /* Trigger */0; - -exports.trigger = trigger; -exports.update$prime = update$prime; -exports.render_model = render_model; -exports.view$prime = view$prime; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_counter.js b/lib/js/test-ocaml/test_client_counter.js deleted file mode 100644 index 21f7950..0000000 --- a/lib/js/test-ocaml/test_client_counter.js +++ /dev/null @@ -1,86 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return model + 1 | 0; - case /* Decrement */1 : - return model - 1 | 0; - case /* Reset */2 : - return 0; - - } - } else { - return param[0]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - model: 4, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_counter_debug_beginner.js b/lib/js/test-ocaml/test_client_counter_debug_beginner.js deleted file mode 100644 index b542eb7..0000000 --- a/lib/js/test-ocaml/test_client_counter_debug_beginner.js +++ /dev/null @@ -1,103 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return model + 1 | 0; - case /* Decrement */1 : - return model - 1 | 0; - case /* Reset */2 : - return 0; - - } - } else { - return param[0]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - model: 4, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_debug.beginnerProgram(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_counter_debug_program.js b/lib/js/test-ocaml/test_client_counter_debug_program.js deleted file mode 100644 index d58e06a..0000000 --- a/lib/js/test-ocaml/test_client_counter_debug_program.js +++ /dev/null @@ -1,134 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function init(param) { - return /* tuple */[ - 4, - /* NoCmd */0 - ]; -} - -function subscriptions(param) { - return /* NoSub */0; -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return /* tuple */[ - model + 1 | 0, - /* NoCmd */0 - ]; - case /* Decrement */1 : - return /* tuple */[ - model - 1 | 0, - /* NoCmd */0 - ]; - case /* Reset */2 : - return /* tuple */[ - 0, - /* NoCmd */0 - ]; - - } - } else { - return /* tuple */[ - param[0], - /* NoCmd */0 - ]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -function partial_arg_shutdown(_model) { - return /* NoCmd */0; -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions, - shutdown: partial_arg_shutdown -}; - -function main(param, param$1) { - return Tea_debug.program(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.init = init; -exports.subscriptions = subscriptions; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_counter_debug_standard.js b/lib/js/test-ocaml/test_client_counter_debug_standard.js deleted file mode 100644 index 5059f10..0000000 --- a/lib/js/test-ocaml/test_client_counter_debug_standard.js +++ /dev/null @@ -1,129 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function string_of_msg(param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return "Increment"; - case /* Decrement */1 : - return "Decrement"; - case /* Reset */2 : - return "Reset"; - - } - } else { - return "Set"; - } -} - -function init(param) { - return /* tuple */[ - 4, - /* NoCmd */0 - ]; -} - -function subscriptions(param) { - return /* NoSub */0; -} - -function update(model, param) { - if (typeof param === "number") { - switch (param) { - case /* Increment */0 : - return /* tuple */[ - model + 1 | 0, - /* NoCmd */0 - ]; - case /* Decrement */1 : - return /* tuple */[ - model - 1 | 0, - /* NoCmd */0 - ]; - case /* Reset */2 : - return /* tuple */[ - 0, - /* NoCmd */0 - ]; - - } - } else { - return /* tuple */[ - param[0], - /* NoCmd */0 - ]; - } -} - -function view_button(title, msg) { - return Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", msg), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [title]), - /* [] */0 - ]); -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.span(undefined, undefined, /* :: */[ - Vdom.style("text-weight", "bold"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* [] */0 - ]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Decrement", /* Decrement */1), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - view_button("Set to 42", /* Set */[42]), - /* :: */[ - Tea_html.br(/* [] */0), - /* :: */[ - model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode, - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ]); -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions -}; - -function main(param, param$1) { - return Tea_debug.standardProgram(partial_arg, string_of_msg, param, param$1); -} - -exports.string_of_msg = string_of_msg; -exports.init = init; -exports.subscriptions = subscriptions; -exports.update = update; -exports.view_button = view_button; -exports.view = view; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_drag.js b/lib/js/test-ocaml/test_client_drag.js deleted file mode 100644 index 898b11b..0000000 --- a/lib/js/test-ocaml/test_client_drag.js +++ /dev/null @@ -1,224 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_json = require("../src-ocaml/tea_json.js"); -var Tea_mouse = require("../src-ocaml/tea_mouse.js"); -var Tea_result = require("../src-ocaml/tea_result.js"); - -function dragStart(param_0) { - return /* DragStart */Block.__(0, [param_0]); -} - -function dragAt(param_0) { - return /* DragAt */Block.__(1, [param_0]); -} - -function dragEnd(param_0) { - return /* DragEnd */Block.__(2, [param_0]); -} - -function init(param) { - return /* tuple */[ - { - position: { - x: 200, - y: 200 - }, - drag: undefined - }, - /* NoCmd */0 - ]; -} - -function getPosition(param) { - var drag = param.drag; - var position = param.position; - if (drag !== undefined) { - var match = drag; - var current = match.current; - var start = match.start; - return { - x: (position.x + current.x | 0) - start.x | 0, - y: (position.y + current.y | 0) - start.y | 0 - }; - } else { - return position; - } -} - -function updateHelp(model, param) { - var position = model.position; - switch (param.tag | 0) { - case /* DragStart */0 : - var xy = param[0]; - return { - position: position, - drag: { - start: xy, - current: xy - } - }; - case /* DragAt */1 : - var match = model.drag; - return { - position: position, - drag: match !== undefined ? ({ - start: match.start, - current: param[0] - }) : undefined - }; - case /* DragEnd */2 : - return { - position: getPosition(model), - drag: undefined - }; - - } -} - -function update(model, msg) { - return /* tuple */[ - updateHelp(model, msg), - /* NoCmd */0 - ]; -} - -function subscriptions(model) { - var match = model.drag; - if (match !== undefined) { - return /* Batch */Block.__(0, [/* :: */[ - Tea_mouse.moves(undefined, dragAt), - /* :: */[ - Tea_mouse.ups(undefined, dragEnd), - /* [] */0 - ] - ]]); - } else { - return /* NoSub */0; - } -} - -function px(number) { - return String(number) + "px"; -} - -function cb(ev) { - return Tea_result.result_to_option(Tea_json.Decoder.decodeEvent(Tea_json.Decoder.map(dragStart, Tea_mouse.position), ev)); -} - -var onMouseDown = Vdom.onCB("mousedown", "", cb); - -function view(model) { - var realPosition = getPosition(model); - return Tea_html.div(undefined, undefined, /* :: */[ - onMouseDown, - /* :: */[ - /* Style */Block.__(4, [/* :: */[ - /* tuple */[ - "background-color", - "#3C8D2F" - ], - /* :: */[ - /* tuple */[ - "cursor", - "move" - ], - /* :: */[ - /* tuple */[ - "width", - "100px" - ], - /* :: */[ - /* tuple */[ - "height", - "100px" - ], - /* :: */[ - /* tuple */[ - "border-radius", - "4px" - ], - /* :: */[ - /* tuple */[ - "position", - "absolute" - ], - /* :: */[ - /* tuple */[ - "left", - String(realPosition.x) + "px" - ], - /* :: */[ - /* tuple */[ - "top", - String(realPosition.y) + "px" - ], - /* :: */[ - /* tuple */[ - "color", - "white" - ], - /* :: */[ - /* tuple */[ - "display", - "flex" - ], - /* :: */[ - /* tuple */[ - "align-items", - "center" - ], - /* :: */[ - /* tuple */[ - "justify-content", - "center" - ], - /* [] */0 - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ] - ]]), - /* [] */0 - ] - ], /* :: */[ - /* Text */Block.__(1, ["Drag Me!"]), - /* [] */0 - ]); -} - -var partial_arg = { - init: init, - update: update, - view: view, - subscriptions: subscriptions -}; - -function main(param, param$1) { - return Tea_app.standardProgram(partial_arg, param, param$1); -} - -exports.dragStart = dragStart; -exports.dragAt = dragAt; -exports.dragEnd = dragEnd; -exports.init = init; -exports.getPosition = getPosition; -exports.updateHelp = updateHelp; -exports.update = update; -exports.subscriptions = subscriptions; -exports.px = px; -exports.onMouseDown = onMouseDown; -exports.view = view; -exports.main = main; -/* onMouseDown Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_http_task.js b/lib/js/test-ocaml/test_client_http_task.js deleted file mode 100644 index a0ea6be..0000000 --- a/lib/js/test-ocaml/test_client_http_task.js +++ /dev/null @@ -1,99 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var Vdom = require("../src-ocaml/vdom.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_ex = require("../src-ocaml/tea_ex.js"); -var Tea_html = require("../src-ocaml/tea_html.js"); -var Tea_http = require("../src-ocaml/tea_http.js"); -var Tea_task = require("../src-ocaml/tea_task.js"); -var Tea_debug = require("../src-ocaml/tea_debug.js"); - -function gotResponse(param_0) { - return /* GotResponse */[param_0]; -} - -function update(model, param) { - if (param) { - return /* tuple */[ - param[0][0], - /* NoCmd */0 - ]; - } else { - return /* tuple */[ - model, - Tea_task.attempt(gotResponse, Tea_task.andThen((function (param) { - return /* Task */[(function (cb) { - return Curry._1(cb, /* Ok */Block.__(0, ["both saved"])); - })]; - }), Tea_task.andThen((function (res) { - return Tea_ex.LocalStorage.setItem("todo-2", res); - }), Tea_task.andThen((function (param) { - return Tea_task.mapError(Tea_http.string_of_error, Tea_http.toTask(Tea_http.getString("https://jsonplaceholder.typicode.com/todos/2"))); - }), Tea_task.andThen((function (res) { - return Tea_ex.LocalStorage.setItem("todo-1", res); - }), Tea_task.mapError(Tea_http.string_of_error, Tea_http.toTask(Tea_http.getString("https://jsonplaceholder.typicode.com/todos/1")))))))) - ]; - } -} - -function view(model) { - return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[ - Tea_html.button(undefined, undefined, /* :: */[ - Vdom.onMsg("click", /* Req */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["execute"]), - /* [] */0 - ]), - /* :: */[ - /* Text */Block.__(1, [model]), - /* [] */0 - ] - ]); -} - -function som(param) { - if (param) { - if (param[0].tag) { - return "GotResponse Error"; - } else { - return "GotResponse Ok"; - } - } else { - return "Req"; - } -} - -function partial_arg_init(param) { - return /* tuple */[ - "nothing", - /* NoCmd */0 - ]; -} - -function partial_arg_subscriptions(param) { - return /* NoSub */0; -} - -var partial_arg = { - init: partial_arg_init, - update: update, - view: view, - subscriptions: partial_arg_subscriptions -}; - -function main(param, param$1) { - return Tea_debug.standardProgram(partial_arg, som, param, param$1); -} - -var req = /* Req */0; - -exports.gotResponse = gotResponse; -exports.req = req; -exports.update = update; -exports.view = view; -exports.som = som; -exports.main = main; -/* Tea_html Not a pure module */ diff --git a/lib/js/test-ocaml/test_client_on_with_options.js b/lib/js/test-ocaml/test_client_on_with_options.js deleted file mode 100644 index e55a877..0000000 --- a/lib/js/test-ocaml/test_client_on_with_options.js +++ /dev/null @@ -1,117 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - -var List = require("bs-platform/lib/js/list.js"); -var Block = require("bs-platform/lib/js/block.js"); -var Curry = require("bs-platform/lib/js/curry.js"); -var Tea_app = require("../src-ocaml/tea_app.js"); -var Tea_json = require("../src-ocaml/tea_json.js"); -var Tea_html2 = require("../src-ocaml/tea_html2.js"); -var Caml_format = require("bs-platform/lib/js/caml_format.js"); - -function set_value(param_0) { - return /* Set_value */[param_0]; -} - -function update(model, param) { - if (param) { - return param[0]; - } else { - return model + 1 | 0; - } -} - -function view(model) { - var clientX = Tea_json.Decoder.field("clientX", Tea_json.Decoder.$$int); - var init = Tea_html2.Events.defaultOptions; - return Tea_html2.div(undefined, undefined, /* [] */0, List.map((function (e) { - return Tea_html2.div(undefined, undefined, /* [] */0, /* :: */[ - e, - /* [] */0 - ]); - }), /* :: */[ - /* Text */Block.__(1, [String(model)]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Tea_html2.Events.onClick(/* Click */0), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["onClick"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Curry._3(Tea_html2.Events.on, "", "click", Tea_json.Decoder.succeed(/* Click */0)), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["on \"click\""]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.a(undefined, undefined, /* :: */[ - Tea_html2.Attributes.href("https://www.google.com"), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["a normal link"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.a(undefined, undefined, /* :: */[ - Tea_html2.Attributes.href("https://www.google.com"), - /* :: */[ - Curry._4(Tea_html2.Events.onWithOptions, "", "click", { - stopPropagation: init.stopPropagation, - preventDefault: true - }, Tea_json.Decoder.succeed(/* Click */0)), - /* [] */0 - ] - ], /* :: */[ - /* Text */Block.__(1, ["a link with prevent default"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.button(undefined, undefined, /* :: */[ - Curry._3(Tea_html2.Events.on, "", "click", Tea_json.Decoder.map(set_value, clientX)), - /* [] */0 - ], /* :: */[ - /* Text */Block.__(1, ["on \"click\", use clientX value"]), - /* [] */0 - ]), - /* :: */[ - Tea_html2.input$prime(undefined, undefined, /* :: */[ - Tea_html2.Attributes.type$prime("text"), - /* :: */[ - Curry._3(Tea_html2.Events.on, "", "input", Tea_json.Decoder.map((function (v) { - return /* Set_value */[Caml_format.caml_int_of_string(v)]; - }), Tea_html2.Events.targetValue)), - /* [] */0 - ] - ], /* [] */0), - /* [] */0 - ] - ] - ] - ] - ] - ] - ])); -} - -var partial_arg = { - model: 0, - update: update, - view: view -}; - -function main(param, param$1) { - return Tea_app.beginnerProgram(partial_arg, param, param$1); -} - -var click = /* Click */0; - -exports.click = click; -exports.set_value = set_value; -exports.update = update; -exports.view = view; -exports.main = main; -/* Tea_html2 Not a pure module */ diff --git a/lib/js/test-ocaml/tester.js b/lib/js/test-ocaml/tester.js deleted file mode 100644 index f49efdb..0000000 --- a/lib/js/test-ocaml/tester.js +++ /dev/null @@ -1,8 +0,0 @@ -// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE -'use strict'; - - -var a = 42; - -exports.a = a; -/* No side effect */ diff --git a/package-lock.json b/package-lock.json index b231981..b6b6ae3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,13 +1,18 @@ { - "name": "bucklescript-tea", + "name": "rescript-tea", "version": "0.15.0", "lockfileVersion": 1, "requires": true, "dependencies": { + "@glennsl/rescript-json-combinators": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@glennsl/rescript-json-combinators/-/rescript-json-combinators-1.0.0.tgz", + "integrity": "sha512-LpdrSfd2M2FIxDH52LsrZ1HBwiUnZz1ypAB7hbY44ocHOEn/MDMoeXvzTfDGpj+u/81WbPyBv02uaKwuFGvq+Q==" + }, "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", "dev": true, "requires": { "jsonparse": "^1.2.0", @@ -15,53 +20,38 @@ } }, "acorn": { - "version": "4.0.13", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-4.0.13.tgz", - "integrity": "sha1-EFSVrlNh1pe9GVyCUZLhrX8lN4c=", - "dev": true - }, - "acorn-dynamic-import": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz", - "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-node": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.7.0.tgz", - "integrity": "sha512-XhahLSsCB6X6CJbe+uNu3Mn9sJBNFxtBN9NLgAOQovfS6Kh0lDUtmlclhjn9CvEK7A7YyRU13PXlNcpSiLI9Yw==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", + "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", "dev": true, "requires": { - "acorn": "^6.1.1", - "acorn-dynamic-import": "^4.0.0", - "acorn-walk": "^6.1.1", - "xtend": "^4.0.1" - }, - "dependencies": { - "acorn": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.0.tgz", - "integrity": "sha512-8oe72N3WPMjA+2zVG71Ia0nXZ8DpQH+QyyHO+p06jT8eg8FGG3FbcUIi8KziHlAfheJQZeoqbvq1mQSQHXKYLw==", - "dev": true - } + "acorn": "^7.0.0", + "acorn-walk": "^7.0.0", + "xtend": "^4.0.2" } }, "acorn-walk": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", - "integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==", + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", "dev": true }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "integrity": "sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA==", "dev": true }, "anymatch": { @@ -77,80 +67,80 @@ "arr-diff": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", + "integrity": "sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==", "dev": true }, "arr-flatten": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", "dev": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-filter": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", - "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", - "dev": true - }, - "array-map": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", - "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", - "dev": true - }, - "array-reduce": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", - "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", + "integrity": "sha512-sKpyeERZ02v1FeCZT8lrfJq5u6goHCtpTAzPwJYe7c8SPFOboNjNg1vz2L4VTn9T4PQxEx13TbXLmYUcS6Ug7Q==", "dev": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", + "integrity": "sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==", "dev": true }, "asn1.js": { - "version": "4.9.2", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz", - "integrity": "sha1-gRfvT37YfNj4kES1v/l6wkOhbJo=", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", "dev": true, "requires": { "bn.js": "^4.0.0", "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", "dev": true, "requires": { + "object-assign": "^4.1.1", "util": "0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha512-8nWq2nLTAwd02jTqJExUYFSD/fKq6VH9Y/oG2accc/kdI0V98Bag8d5a4gi3XHz73rDWa2PvTtvcWYquKqSENA==", + "dev": true + }, + "util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha512-5KiHfsmkqacuKjkRkdV7SsfDJ2EGiPsK92s2MhNSY0craxjTdKTtqKsJaCWp4LW33ZZ0OPUv1WO/TFvNQRiQxQ==", + "dev": true, + "requires": { + "inherits": "2.0.1" + } + } } }, "assign-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "integrity": "sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==", "dev": true }, - "astw": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/astw/-/astw-2.2.0.tgz", - "integrity": "sha1-e9QXhNMkk5h66yOba04cV6hzuRc=", - "dev": true, - "requires": { - "acorn": "^4.0.3" - } - }, "async-each": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", @@ -164,9 +154,9 @@ "dev": true }, "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "base": { @@ -187,7 +177,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -225,9 +215,9 @@ } }, "base64-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", - "integrity": "sha1-qRlH2h9KUW6jjltOwOw3c2deCIY=", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "dev": true }, "binary-extensions": { @@ -236,16 +226,26 @@ "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, + "bindings": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", + "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", + "dev": true, + "optional": true, + "requires": { + "file-uri-to-path": "1.0.0" + } + }, "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", + "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", "dev": true }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "^1.0.0", @@ -273,7 +273,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -284,26 +284,27 @@ "brorand": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", "dev": true }, "browser-pack": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.0.2.tgz", - "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", + "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" } }, "browser-resolve": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.2.tgz", - "integrity": "sha1-j/CbCixCFxihBRwmCzLkj0QpOM4=", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-1.11.3.tgz", + "integrity": "sha512-exDi1BYWB/6raKHmDTCicQfTkqwN5fioMFV4j8BsfMU4R2DK/QfZfK7kOVkmWCNANf0snkBzqGqAJBao9gZMdQ==", "dev": true, "requires": { "resolve": "1.1.7" @@ -312,7 +313,7 @@ "resolve": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "integrity": "sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==", "dev": true } } @@ -320,7 +321,7 @@ "browserify": { "version": "14.5.0", "resolved": "https://registry.npmjs.org/browserify/-/browserify-14.5.0.tgz", - "integrity": "sha1-C7vOUhrNbk0dVNjpNlAI77hanMU=", + "integrity": "sha512-gKfOsNQv/toWz+60nSPfYzuwSEdzvV2WdxrVPUbPD/qui44rAkB3t3muNtmmGYHqrG56FGwX9SUEQmzNLAeS7g==", "dev": true, "requires": { "JSONStream": "^1.0.3", @@ -373,9 +374,9 @@ } }, "browserify-aes": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.1.1.tgz", - "integrity": "sha1-OLerVe24Bv8tzaGn8WIHc6R3xJ8=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", "dev": true, "requires": { "buffer-xor": "^1.0.3", @@ -387,9 +388,9 @@ } }, "browserify-cipher": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.0.tgz", - "integrity": "sha1-mYgkSHS/XtTijalWZtzWasj8Njo=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", "dev": true, "requires": { "browserify-aes": "^1.0.4", @@ -398,88 +399,101 @@ } }, "browserify-des": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.0.tgz", - "integrity": "sha1-2qJ3cXRwki7S/hhZQRihdUOXId0=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", "dev": true, "requires": { "cipher-base": "^1.0.1", "des.js": "^1.0.0", - "inherits": "^2.0.1" + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", "dev": true, "requires": { - "bn.js": "^4.1.0", + "bn.js": "^5.0.0", "randombytes": "^2.0.1" } }, "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", - "dev": true, - "requires": { - "bn.js": "^4.1.1", - "browserify-rsa": "^4.0.0", - "create-hash": "^1.1.0", - "create-hmac": "^1.1.2", - "elliptic": "^6.0.0", - "inherits": "^2.0.1", - "parse-asn1": "^5.0.0" + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", + "dev": true, + "requires": { + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + } } }, "browserify-zlib": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha1-KGlFnZqjviRf6P4sofRuLn9U1z8=", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", "dev": true, "requires": { "pako": "~1.0.5" } }, - "bs-platform": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/bs-platform/-/bs-platform-7.1.1.tgz", - "integrity": "sha512-ckZHR3J+yxyEKXOBHX8+hfzWG2XX5BxhQ4Iw9lulHFGYdAm9Ep9LgKkIah7G6RYADLmVfTxFE48igvY3kkkl+g==", - "dev": true - }, "buffer": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.0.8.tgz", - "integrity": "sha1-hNqlLnzy+ozkGVvFzw94CeCTCyQ=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, "buffer-from": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", - "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", - "dev": true - }, - "builtin-modules": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", "dev": true }, "builtin-status-codes": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==", "dev": true }, "cache-base": { @@ -500,15 +514,25 @@ } }, "cached-path-relative": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", - "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.1.0.tgz", + "integrity": "sha512-WF0LihfemtesFcJgO7xfOoOcnWzY/QHR4qeDqV44jPU3HTI54+LnfXK3SA27AVVGCdZFgjjFFaqUA9Jx7dMJZA==", "dev": true }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "chalk": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "integrity": "sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A==", "dev": true, "requires": { "ansi-styles": "^2.2.1", @@ -519,9 +543,9 @@ } }, "chokidar": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.6.tgz", - "integrity": "sha512-V2jUo67OKkc6ySiRpJrjlpJKl9kDuG+Xb8VgsGzb+aEouhgS1D0weyPU4lEzdAcsCAvrih2J2BqyXqHWvVLw5g==", + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", + "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", "dev": true, "requires": { "anymatch": "^2.0.0", @@ -549,7 +573,7 @@ "cipher-base": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -571,7 +595,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -582,7 +606,7 @@ "collection-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "integrity": "sha512-lNkKvzEeMBBjUGHZ+q6z9pSJla0KWAQPvtzhEV9+iGyQYG+pBpl7xKDhxoNSOZH2hhv0v5k0y2yAM4o4SjoSkw==", "dev": true, "requires": { "map-visit": "^1.0.0", @@ -590,9 +614,9 @@ } }, "combine-source-map": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.7.2.tgz", - "integrity": "sha1-CHAxKFazB6h8xKxIbzqaYq7MwJ4=", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha512-UlxQ9Vw0b/Bt/KYwCFqdEwsQ1eL8d1gibiFb7lxQJFdvTgc2hIZi6ugsg+kyhzhPV+QEpUiEIwInIAIrgoEkrg==", "dev": true, "requires": { "convert-source-map": "~1.1.0", @@ -610,13 +634,13 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, "concat-stream": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.5.2.tgz", - "integrity": "sha1-cIl4Yk2FavQaWnQd790mHadSwmY=", + "integrity": "sha512-H6xsIBfQ94aESBG8jGHXQ7i5AEpy5ZeVaLDOisDICiTCKpqEfr34/KmTrspKQNoLKNu9gTkovlpQcUi630AKiQ==", "dev": true, "requires": { "inherits": "~2.0.1", @@ -624,10 +648,16 @@ "typedarray": "~0.0.5" }, "dependencies": { + "process-nextick-args": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", + "integrity": "sha512-yN0WQmuCX63LP/TMvAg31nvT6m4vDqJEiiv2CAZqWOGNWutc9DfDk1NPYYmKUFmaVM2UwDowH4u5AHWYP/jxKw==", + "dev": true + }, "readable-stream": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", + "integrity": "sha512-TXcFfb63BQe1+ySzsHZI/5v1aJPCShfqvWJ64ayNImXMsN1Cd0YGk/wm8KB7/OeessgPc9QvS9Zou8QTkFzsLw==", "dev": true, "requires": { "core-util-is": "~1.0.0", @@ -641,70 +671,76 @@ "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", "dev": true } } }, "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", - "dev": true, - "requires": { - "date-now": "^0.1.4" - } + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", + "dev": true }, "constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "integrity": "sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==", "dev": true }, "convert-source-map": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", - "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", + "integrity": "sha512-Y8L5rp6jo+g9VEPgvqNfEopjTR4OTYct8lXlS8iVQdmnjDvbdbzYe9rjtFCB9egC86JoNCU61WRY+ScjkZpnIg==", "dev": true }, "copy-descriptor": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "integrity": "sha512-XgZ0pFcakEUlbwQEVNg3+QAis1FyTL3Qel9FYy8pSkQqoG3PNoT0bOCQtOXcOkur21r2Eq2kI+IE+gsmAEVlYw==", "dev": true }, "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", "dev": true }, "create-ecdh": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.0.tgz", - "integrity": "sha1-iIxyNZbN92EvZJgjPuvXo1MBc30=", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", "dev": true, "requires": { "bn.js": "^4.1.0", - "elliptic": "^6.0.0" + "elliptic": "^6.5.3" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "create-hash": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.3.tgz", - "integrity": "sha1-YGBCrIuSYnUPSDyt2rD1gZFy2P0=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", "dev": true, "requires": { "cipher-base": "^1.0.1", "inherits": "^2.0.1", - "ripemd160": "^2.0.0", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", "sha.js": "^2.4.0" } }, "create-hmac": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.6.tgz", - "integrity": "sha1-rLniIaThe9sHbpBlfEK5PjcmzwY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", "dev": true, "requires": { "cipher-base": "^1.0.3", @@ -718,7 +754,7 @@ "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "integrity": "sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==", "dev": true, "requires": { "lru-cache": "^4.0.1", @@ -729,7 +765,7 @@ "crypto-browserify": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha1-OWz58xN/A+S45TLFj2mCVOAPgOw=", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", "dev": true, "requires": { "browserify-cipher": "^1.0.0", @@ -745,10 +781,10 @@ "randomfill": "^1.0.3" } }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "dash-ast": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", + "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", "dev": true }, "debug": { @@ -763,17 +799,17 @@ "decode-uri-component": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==", "dev": true }, "define-properties": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", - "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", "dev": true, "requires": { - "foreach": "^2.0.5", - "object-keys": "^1.0.8" + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" } }, "define-property": { @@ -820,25 +856,25 @@ "defined": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", - "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "integrity": "sha512-Y2caI5+ZwS5c3RiNDJ6u53VhQHv+hHKwhkI1iHvceKUHw9Df6EK2zRLfjejRgMuCuxK7PfSWIMwWecceVvThjQ==", "dev": true }, "deps-sort": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.0.tgz", - "integrity": "sha1-CRckkC6EZYJg65EHSMzNGvbiH7U=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", + "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "shasum": "^1.0.0", + "shasum-object": "^1.0.0", "subarg": "^1.0.0", "through2": "^2.0.0" } }, "des.js": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", - "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -846,9 +882,9 @@ } }, "detective": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.0.tgz", - "integrity": "sha1-YnbhUPnlCCmtH5Cs5NmiMEGIr88=", + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", + "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", "dev": true, "requires": { "acorn": "^5.2.1", @@ -856,103 +892,137 @@ }, "dependencies": { "acorn": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", - "integrity": "sha1-MXrHghgmwixwLWYYmrg1lnXxNdc=", + "version": "5.7.4", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz", + "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==", "dev": true } } }, "diffie-hellman": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.2.tgz", - "integrity": "sha1-tYNXOScM/ias9jIJn97SoH8gnl4=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", "dev": true, "requires": { "bn.js": "^4.1.0", "miller-rabin": "^4.0.0", "randombytes": "^2.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "domain-browser": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", - "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", + "integrity": "sha512-fJ5MoHxe69h3E4/lJtFRhcWwLb04bhIBSfvCEMS1YDH+/9yEZTqBHTSTgch8nCP5tE5k2gdQEjodUqJzy7qJ9Q==", "dev": true }, "duplexer": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", - "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", + "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", "dev": true }, "duplexer2": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", "dev": true, "requires": { "readable-stream": "^2.0.2" } }, "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", "dev": true, "requires": { - "bn.js": "^4.4.0", - "brorand": "^1.0.1", + "bn.js": "^4.11.9", + "brorand": "^1.1.0", "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.0", - "inherits": "^2.0.1", - "minimalistic-assert": "^1.0.0", - "minimalistic-crypto-utils": "^1.0.0" + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "error-ex": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", - "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", "dev": true, "requires": { "is-arrayish": "^0.2.1" } }, "es-abstract": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.10.0.tgz", - "integrity": "sha1-Hss2wZeEKgDY7kwt/YZGu5fWCGQ=", + "version": "1.20.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.20.1.tgz", + "integrity": "sha512-WEm2oBhfoI2sImeM4OF2zE2V3BYdSF+KnSi9Sidz51fQHd7+JuF8Xgcj9/0o+OWeIeIS/MiuNnlruQrJf16GQA==", "dev": true, "requires": { - "es-to-primitive": "^1.1.1", + "call-bind": "^1.0.2", + "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", - "has": "^1.0.1", - "is-callable": "^1.1.3", - "is-regex": "^1.0.4" + "function.prototype.name": "^1.1.5", + "get-intrinsic": "^1.1.1", + "get-symbol-description": "^1.0.0", + "has": "^1.0.3", + "has-property-descriptors": "^1.0.0", + "has-symbols": "^1.0.3", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.4", + "is-negative-zero": "^2.0.2", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "is-string": "^1.0.7", + "is-weakref": "^1.0.2", + "object-inspect": "^1.12.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.2", + "regexp.prototype.flags": "^1.4.3", + "string.prototype.trimend": "^1.0.5", + "string.prototype.trimstart": "^1.0.5", + "unbox-primitive": "^1.0.2" } }, "es-to-primitive": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz", - "integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", "dev": true, "requires": { - "is-callable": "^1.1.1", + "is-callable": "^1.1.4", "is-date-object": "^1.0.1", - "is-symbol": "^1.0.1" + "is-symbol": "^1.0.2" } }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true }, "event-stream": { "version": "3.3.4", "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "integrity": "sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==", "dev": true, "requires": { "duplexer": "~0.1.1", @@ -967,13 +1037,13 @@ "events": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "integrity": "sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw==", "dev": true }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha1-f8vbGY3HGVlDLv4ThCaE4FJaywI=", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", "dev": true, "requires": { "md5.js": "^1.3.4", @@ -983,7 +1053,7 @@ "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", + "integrity": "sha512-w/ozOKR9Obk3qoWeY/WDi6MFta9AoMR+zud60mdnbniMcBxRuFJyDt2LdX/14A1UABeqk+Uk+LDfUpvoGKppZA==", "dev": true, "requires": { "debug": "^2.3.3", @@ -998,7 +1068,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -1007,7 +1077,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -1018,7 +1088,7 @@ "extend-shallow": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "integrity": "sha512-BwY5b5Ql4+qZoefgMj2NUmx+tehVTH/Kf4k1ZEtOHNFcm2wSxMRo992l6X3TIgni2eZVTZ85xMOjF31fwZAj6Q==", "dev": true, "requires": { "assign-symbols": "^1.0.0", @@ -1055,7 +1125,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -1064,7 +1134,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -1101,10 +1171,23 @@ } } }, + "fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", + "dev": true + }, + "file-uri-to-path": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", + "dev": true, + "optional": true + }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", + "integrity": "sha512-VcpLTWqWDiTerugjj8e3+esbg+skS3M9e54UuR3iCeIDMXCLTsAH8hTSzDQU/X6/6t3eYkOKoZSef2PlU6U1XQ==", "dev": true, "requires": { "extend-shallow": "^2.0.1", @@ -1116,7 +1199,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -1127,19 +1210,13 @@ "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "integrity": "sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==", "dev": true }, "fragment-cache": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "integrity": "sha512-GMBAbW9antB8iZRHLoGw0b3HANt57diZYFO/HL1JGIC1MjKrdmhxvrJbupnVvpys0zsz7yBApXdQyfepKly2kA==", "dev": true, "requires": { "map-cache": "^0.2.2" @@ -1148,585 +1225,93 @@ "from": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", + "integrity": "sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==", "dev": true }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, "fsevents": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", - "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", + "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", "dev": true, "optional": true, "requires": { - "nan": "^2.12.1", - "node-pre-gyp": "^0.12.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "^2.1.1" - } - }, - "deep-extend": { - "version": "0.6.0", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - } - }, - "glob": { - "version": "7.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.24", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "^3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true, - "optional": true - }, - "minipass": { - "version": "2.3.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "^5.1.2", - "yallist": "^3.0.0" - } - }, - "minizlib": { - "version": "1.2.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "^2.2.1" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.3.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "^4.1.0", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.12.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "^1.0.2", - "mkdirp": "^0.5.1", - "needle": "^2.2.1", - "nopt": "^4.0.1", - "npm-packlist": "^1.1.6", - "npmlog": "^4.0.2", - "rc": "^1.2.7", - "rimraf": "^2.6.1", - "semver": "^5.3.0", - "tar": "^4" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1", - "osenv": "^0.1.4" - } - }, - "npm-bundled": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "^3.0.1", - "npm-bundled": "^1.0.1" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.7.3", - "set-blocking": "~2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "wrappy": "1" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "^1.0.0", - "os-tmpdir": "^1.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "^0.6.0", - "ini": "~1.3.0", - "minimist": "^1.2.0", - "strip-json-comments": "~2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "rimraf": { - "version": "2.6.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.7.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "4.4.8", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "^1.1.1", - "fs-minipass": "^1.2.5", - "minipass": "^2.3.4", - "minizlib": "^1.1.1", - "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.2", - "yallist": "^3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.3", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "yallist": { - "version": "3.0.3", - "bundled": true, - "dev": true, - "optional": true - } + "bindings": "^1.5.0", + "nan": "^2.12.1" } }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "function.prototype.name": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.5.tgz", + "integrity": "sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.0", + "functions-have-names": "^1.2.2" + } + }, + "functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", "dev": true }, + "get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, + "get-intrinsic": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.2.tgz", + "integrity": "sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + } + }, + "get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + } + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", + "integrity": "sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==", "dev": true }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.1", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -1734,7 +1319,7 @@ "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", + "integrity": "sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA==", "dev": true, "requires": { "is-glob": "^3.1.0", @@ -1744,7 +1329,7 @@ "is-glob": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", + "integrity": "sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw==", "dev": true, "requires": { "is-extglob": "^2.1.0" @@ -1753,33 +1338,63 @@ } }, "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", "dev": true }, "has": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", - "integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { - "function-bind": "^1.0.2" + "function-bind": "^1.1.1" } }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "integrity": "sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" } }, + "has-bigints": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.2.tgz", + "integrity": "sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==", + "dev": true + }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.1" + } + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true + }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", + "integrity": "sha512-IBXk4GTsLYdQ7Rvt+GRBrFSVEkmuOUy4re0Xjd9kJSUQpnTrWR4/y9RpfexN9vkAPMFuQoeWKwqzPozRTlasGw==", "dev": true, "requires": { "get-value": "^2.0.6", @@ -1790,7 +1405,7 @@ "has-values": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", + "integrity": "sha512-ODYZC64uqzmtfGMEAX/FvZiRyWLpAC3vYnNunURUnkGVTS+mI0smVsWaPydRBsE3g+ok7h960jChO8mFcWlHaQ==", "dev": true, "requires": { "is-number": "^3.0.0", @@ -1800,7 +1415,7 @@ "kind-of": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", + "integrity": "sha512-24XsCxmEbRwEDbz/qz3stgin8TTzZ1ESR56OMCN0ujYg+vRutNSiOj9bHH9u85DKgXguraugV5sFuvbD4FW/hw==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -1809,28 +1424,52 @@ } }, "hash-base": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-2.0.2.tgz", - "integrity": "sha1-ZuodhW206KVHDK32/OI65SRO8uE=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", + "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", "dev": true, "requires": { - "inherits": "^2.0.1" + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + } } }, "hash.js": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.3.tgz", - "integrity": "sha1-NA3tvmKQGHFRweodd3o0SJNd+EY=", + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", "dev": true, "requires": { "inherits": "^2.0.3", - "minimalistic-assert": "^1.0.0" + "minimalistic-assert": "^1.0.1" } }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", "dev": true, "requires": { "hash.js": "^1.0.3", @@ -1839,39 +1478,39 @@ } }, "hosted-git-info": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz", - "integrity": "sha1-bWDjSzq7yDEwYsO3mO+NkBoHrzw=", + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", "dev": true }, "htmlescape": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", - "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", + "integrity": "sha512-eVcrzgbR4tim7c7soKQKtxa/kQM4TzjnlU83rcZ9bHU6t31ehfV7SktN6McWgwPWg+JYMA/O3qpGxBvFq1z2Jg==", "dev": true }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==", "dev": true }, "ieee754": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", - "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", + "integrity": "sha512-i0G7hLJ1z0DE8dsqJa2rycj9dBmNKgXBvotXtZYXakU9oivfB9Uj2ZBC27qqef2U58/ZLwalxa1X/RDCdkHtVg==", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "dev": true, "requires": { "once": "^1.3.0", @@ -1879,40 +1518,67 @@ } }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "inline-source-map": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", - "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", + "integrity": "sha512-0mVWSSbNDvedDWIN4wxLsdPM4a7cIPcpyMxj3QZ406QRwQ6ePGB1YIHxVPjqpcUGbWQ5C+nHTwGNWAGvt7ggVA==", "dev": true, "requires": { "source-map": "~0.5.3" } }, "insert-module-globals": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.0.1.tgz", - "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.1.tgz", + "integrity": "sha512-ufS5Qq9RZN+Bu899eA9QCAYThY+gGW7oRkmb0vC93Vlyu/CFGcH0OYPEjVkDXA5FEbTt1+VWzdoOD3Ny9N+8tg==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "combine-source-map": "~0.7.1", - "concat-stream": "~1.5.1", + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", - "lexical-scope": "^1.2.0", + "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", "xtend": "^4.0.0" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + } + } + }, + "internal-slot": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", + "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" } }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "integrity": "sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -1921,7 +1587,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -1932,43 +1598,62 @@ "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", "dev": true }, + "is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "requires": { + "has-bigints": "^1.0.1" + } + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "integrity": "sha512-9fRVlXc0uCxEDj1nQzaWONSpbTfx0FmJfzHF7pwlI8DkWGoHBBea4Pg5Ky0ojwwxQmnSifgbKkI06Qv0Ljgj+Q==", "dev": true, "requires": { "binary-extensions": "^1.0.0" } }, + "is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha1-76ouqdqg16suoTqXsritUf776L4=", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, - "is-builtin-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", - "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "is-callable": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", + "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", + "dev": true + }, + "is-core-module": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", "dev": true, "requires": { - "builtin-modules": "^1.0.0" + "has": "^1.0.3" } }, - "is-callable": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz", - "integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=", - "dev": true - }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "integrity": "sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -1977,7 +1662,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -1986,10 +1671,13 @@ } }, "is-date-object": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", - "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=", - "dev": true + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz", + "integrity": "sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } }, "is-descriptor": { "version": "0.1.6", @@ -2013,28 +1701,34 @@ "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", "dev": true }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true }, "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "requires": { "is-extglob": "^2.1.1" } }, + "is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true + }, "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", + "integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -2043,7 +1737,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -2051,6 +1745,15 @@ } } }, + "is-number-object": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.7.tgz", + "integrity": "sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -2061,19 +1764,50 @@ } }, "is-regex": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", - "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-shared-array-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz", + "integrity": "sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } + }, + "is-string": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", "dev": true, "requires": { - "has": "^1.0.1" + "has-tostringtag": "^1.0.0" } }, "is-symbol": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz", - "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", - "dev": true + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + }, + "is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } }, "is-windows": { "version": "1.0.2", @@ -2084,25 +1818,25 @@ "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", "dev": true }, "json-stable-stringify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-0.0.1.tgz", - "integrity": "sha1-YRwj6BTbN1Un34URk9tZ3Sryf0U=", + "integrity": "sha512-nKtD/Qxm7tWdZqJoldEC7fF0S41v0mWbeaXG3637stOWfyGxTgWTYE2wtfKmjzpvxv2MA2xzxsXOIiwUpkX6Qw==", "dev": true, "requires": { "jsonify": "~0.0.0" @@ -2111,53 +1845,35 @@ "jsonify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "integrity": "sha512-trvBk1ki43VZptdBI5rIlG4YOzyeH/WefQt5rj1grasPn4iiZWKet8nkgc4GlsAylaztn0qZfUYOiTsASJFdNA==", "dev": true }, "jsonparse": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", - "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==", "dev": true }, "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, "labeled-stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.0.tgz", - "integrity": "sha1-pS4dE4AkwAuGscDJH2d5GLiuClk=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", + "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", "dev": true, "requires": { "inherits": "^2.0.1", - "isarray": "~0.0.1", "stream-splicer": "^2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } - }, - "lexical-scope": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/lexical-scope/-/lexical-scope-1.2.0.tgz", - "integrity": "sha1-/Ope3HBKSzqHls3KQZw6CvryLfQ=", - "dev": true, - "requires": { - "astw": "^2.0.0" } }, "load-json-file": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "integrity": "sha512-3p6ZOGNbiX4CdvEd1VcE6yi78UrGNpjHO33noGwHCnT/o2fyllJDepsm8+mFFv/DvtwFHht5HIHSyOy5a+ChVQ==", "dev": true, "requires": { "graceful-fs": "^4.1.2", @@ -2169,13 +1885,13 @@ "lodash.memoize": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", - "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", + "integrity": "sha512-eDn9kqrAmVUC1wmZvlQ6Uhde44n+tXpqPrN8olQJbttgh0oKclk+SF54P47VEGE9CEiMeRwAP8BaM7UHvBkz2A==", "dev": true }, "lru-cache": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz", - "integrity": "sha1-Yi4y6CSItJJ5EUpPns9F581rulU=", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, "requires": { "pseudomap": "^1.0.2", @@ -2185,44 +1901,33 @@ "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", + "integrity": "sha512-8y/eV9QQZCiyn1SprXSrCmqJN0yNRATe+PO8ztwqrvrbdRLA3eYJF0yaR0YayLWkMbsQSKWS9N2gPcGEc4UsZg==", "dev": true }, "map-stream": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", + "integrity": "sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==", "dev": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", + "integrity": "sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==", "dev": true, "requires": { "object-visit": "^1.0.0" } }, "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", "dev": true, "requires": { "hash-base": "^3.0.0", - "inherits": "^2.0.1" - }, - "dependencies": { - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - } + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" } }, "micromatch": { @@ -2249,38 +1954,46 @@ "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha1-8IA1HIZbDcViqEYpZtqlNUPHik0=", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", "dev": true, "requires": { "bn.js": "^4.0.0", "brorand": "^1.0.1" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "minimalistic-assert": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.0.tgz", - "integrity": "sha1-cCvi3aazf0g2vLP121ZkG2Sh09M=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", "dev": true }, "minimalistic-crypto-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", "dev": true }, "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "mixin-deep": { @@ -2304,27 +2017,16 @@ } } }, - "mkdirp": { - "version": "0.5.1", - "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } + "mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true }, "module-deps": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-4.1.1.tgz", - "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", + "integrity": "sha512-ze1e77tkYtlJI90RmlJJvTOGe91OAbtNQj34tg26GWlvdDc0dzmlxujTnh85S8feiTB3eBkKAOCD/v5p9v6wHg==", "dev": true, "requires": { "JSONStream": "^1.0.3", @@ -2347,13 +2049,13 @@ "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, "nan": { - "version": "2.14.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", - "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==", + "version": "2.16.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.16.0.tgz", + "integrity": "sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA==", "dev": true, "optional": true }, @@ -2377,13 +2079,13 @@ } }, "normalize-package-data": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", - "integrity": "sha1-EvlaMH1YNSB1oEkHuErIvpisAS8=", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", "dev": true, "requires": { "hosted-git-info": "^2.1.4", - "is-builtin-module": "^1.0.0", + "resolve": "^1.10.0", "semver": "2 || 3 || 4 || 5", "validate-npm-package-license": "^3.0.1" } @@ -2391,7 +2093,7 @@ "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", + "integrity": "sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w==", "dev": true, "requires": { "remove-trailing-separator": "^1.0.1" @@ -2400,7 +2102,7 @@ "npm-run-all": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.0.2.tgz", - "integrity": "sha1-qEZpNI5ttsy+BSIAtM22v+A0pP4=", + "integrity": "sha512-Gl750pNvb9degafaSOFqyKQ8rlLAkXv+2oY54/JmWqSVfuN31CHcyRsrJI6QsAjjacC3unW6rtJYwTev487d4A==", "dev": true, "requires": { "chalk": "^1.1.3", @@ -2412,10 +2114,16 @@ "string.prototype.padend": "^3.0.0" } }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true + }, "object-copy": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", + "integrity": "sha512-79LYn6VAb63zgtmAteVOWo9Vdj71ZVBy3Pbse+VqxDpEP83XuujMrGqHIwAXJ5I/aM0zU7dIyIAhifVTPrNItQ==", "dev": true, "requires": { "copy-descriptor": "^0.1.0", @@ -2426,7 +2134,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -2435,7 +2143,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -2443,25 +2151,43 @@ } } }, + "object-inspect": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.2.tgz", + "integrity": "sha512-z+cPxW0QGUp0mcqcsgQyLVRDoXFQbXOwBaqyF7VIgI4TWNQsDHrBpUQslRmIfAoYWdYzs6UlKJtB2XJpTaNSpQ==", + "dev": true + }, "object-keys": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", - "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", "dev": true }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", + "integrity": "sha512-GBaMwwAVK9qbQN3Scdo0OyvgPW7l3lnaVMj84uTOZlswkX0KpF6fyDBJhtTthf7pymztoN36/KEr1DyhF96zEA==", "dev": true, "requires": { "isobject": "^3.0.0" } }, + "object.assign": { + "version": "4.1.4", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.4.tgz", + "integrity": "sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "has-symbols": "^1.0.3", + "object-keys": "^1.1.1" + } + }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "integrity": "sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==", "dev": true, "requires": { "isobject": "^3.0.1" @@ -2470,7 +2196,7 @@ "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "requires": { "wrappy": "1" @@ -2479,56 +2205,56 @@ "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "integrity": "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==", "dev": true }, "os-shim": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", - "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", + "integrity": "sha512-jd0cvB8qQ5uVt0lvCIexBaROw1KyKm5sbulg2fWOHjETisuCzWyt+eTZKEMs8v6HwzoGs8xik26jg7eCM6pS+A==", "dev": true }, "outpipe": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/outpipe/-/outpipe-1.1.1.tgz", - "integrity": "sha1-UM+GFjZeh+Ax4ppeyTOaPaRyX6I=", + "integrity": "sha512-BnNY/RwnDrkmQdUa9U+OfN/Y7AWmKuUPCCd+hbRclZnnANvYpO72zp/a6Q4n829hPbdqEac31XCcsvlEvb+rtA==", "dev": true, "requires": { "shell-quote": "^1.4.2" } }, "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha1-AQEhG6pwxLykoPY/Igbpe3368lg=", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", "dev": true }, "parents": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", - "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", + "integrity": "sha512-mXKF3xkoUt5td2DoxpLmtOmZvko9VfFpwRwkKDHSNvgmpLAeBo18YDhcPbBzJq+QLCHMbGOfzia2cX4U+0v9Mg==", "dev": true, "requires": { "path-platform": "~0.11.15" } }, "parse-asn1": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.0.tgz", - "integrity": "sha1-N8T5t+06tlx0gXtfJICTf7+XxxI=", + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", "dev": true, "requires": { - "asn1.js": "^4.0.0", + "asn1.js": "^5.2.0", "browserify-aes": "^1.0.0", - "create-hash": "^1.1.0", "evp_bytestokey": "^1.0.0", - "pbkdf2": "^3.0.3" + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" } }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "integrity": "sha512-QR/GGaKCkhwk1ePQNYDRKYZ3mwU9ypsKhB0XyFnLQdomyEqk3e8wpW3V5Jp88zbxK4n5ST1nqo+g9juTpownhQ==", "dev": true, "requires": { "error-ex": "^1.2.0" @@ -2537,25 +2263,25 @@ "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", + "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==", "dev": true }, "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", + "integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==", "dev": true }, "path-dirname": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", + "integrity": "sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q==", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, "path-parse": { @@ -2567,13 +2293,13 @@ "path-platform": { "version": "0.11.15", "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", - "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", + "integrity": "sha512-Y30dB6rab1A/nfEKsZxmr01nUotHX0c/ZiIAsCTatEe1CmS5Pm5He7fZ195bPT7RdquoaL8lLxFCMQi/bS7IJg==", "dev": true }, "path-type": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "integrity": "sha512-dUnb5dXUf+kzhC/W/F4e5/SkluXIFf5VUHolW1Eg1irn1hGWjPGdsRcvYJ1nD6lhk8Ir7VM0bHJKsYTx8Jx9OQ==", "dev": true, "requires": { "pify": "^2.0.0" @@ -2582,16 +2308,16 @@ "pause-stream": { "version": "0.0.11", "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "integrity": "sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==", "dev": true, "requires": { "through": "~2.3" } }, "pbkdf2": { - "version": "3.0.14", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz", - "integrity": "sha1-o14TxkeZsGzhUyD0WcIw5o5zut4=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", "dev": true, "requires": { "create-hash": "^1.1.2", @@ -2604,19 +2330,19 @@ "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", "dev": true }, "posix-character-classes": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", + "integrity": "sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg==", "dev": true }, "pre-commit": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/pre-commit/-/pre-commit-1.2.2.tgz", - "integrity": "sha1-287g7p3nI15X95xW186UZBpp7sY=", + "integrity": "sha512-qokTiqxD6GjODy5ETAIgzsRgnBWWQHQH2ghy86PU7mIn/wuWeTwF3otyNQZxWBwVn8XNr8Tdzj/QfUXpH+gRZA==", "dev": true, "requires": { "cross-spawn": "^5.0.1", @@ -2627,7 +2353,7 @@ "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", - "integrity": "sha1-mofEN48D6CfOyvGs31bHNsAcFOU=", + "integrity": "sha512-16uPglFkRPzgiUXYMi1Jf8Z5EzN1iB4V0ZtMXcHZnwsBtQhhHeCqoWw7tsUY42hJGNDWtUsVLTjakIa5BgAxCw==", "dev": true, "requires": { "isexe": "^2.0.0" @@ -2638,74 +2364,83 @@ "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", "dev": true }, "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", "dev": true }, "ps-tree": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.1.0.tgz", - "integrity": "sha1-tCGyQUDWID8e08dplrRCewjowBQ=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.2.0.tgz", + "integrity": "sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==", "dev": true, "requires": { - "event-stream": "~3.3.0" + "event-stream": "=3.3.4" } }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "integrity": "sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==", "dev": true }, "public-encrypt": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.0.tgz", - "integrity": "sha1-OfaZ86RlYN1eusvKaTyvfGXBjMY=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", "dev": true, "requires": { "bn.js": "^4.1.0", "browserify-rsa": "^4.0.0", "create-hash": "^1.1.0", "parse-asn1": "^5.0.0", - "randombytes": "^2.0.1" + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + }, + "dependencies": { + "bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + } } }, "punycode": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true }, "querystring": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "integrity": "sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==", "dev": true }, "querystring-es3": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "integrity": "sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==", "dev": true }, "randombytes": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.5.tgz", - "integrity": "sha1-3ACaJGuNCaF3tLegrne8Vw9LG3k=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "requires": { "safe-buffer": "^5.1.0" } }, "randomfill": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.3.tgz", - "integrity": "sha1-uWt99YfwHdkXJsQY8wVTsUGOPWI=", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", "dev": true, "requires": { "randombytes": "^2.0.5", @@ -2715,7 +2450,7 @@ "read-only-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", - "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", + "integrity": "sha512-3ALe0bjBVZtkdWKIcThYpQCLbBMd/+Tbh2CDSrAIDO3UsZ4Xs+tnyjv2MjCOMMgBG+AsUOeuP1cgtY1INISc8w==", "dev": true, "requires": { "readable-stream": "^2.0.2" @@ -2724,7 +2459,7 @@ "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "integrity": "sha512-eFIBOPW7FGjzBuk3hdXEuNSiTZS/xEMlH49HxMyzb0hyPfu4EhVjT2DH32K1hSSmVq4sebAWnZuuY5auISUTGA==", "dev": true, "requires": { "load-json-file": "^2.0.0", @@ -2733,18 +2468,35 @@ } }, "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", "dev": true, "requires": { "core-util-is": "~1.0.0", "inherits": "~2.0.3", "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", + "process-nextick-args": "~2.0.0", "safe-buffer": "~5.1.1", - "string_decoder": "~1.0.3", + "string_decoder": "~1.1.1", "util-deprecate": "~1.0.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "readdirp": { @@ -2768,37 +2520,61 @@ "safe-regex": "^1.1.0" } }, + "regexp.prototype.flags": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.3.tgz", + "integrity": "sha512-fjggEOO3slI6Wvgjwflkc4NFRCTZAu5CnNfBd5qOMYhWdn67nJBBu34/TkD++eeFmd8C9r9jfXJ27+nSiRkSUA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "functions-have-names": "^1.2.2" + } + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", + "integrity": "sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw==", "dev": true }, "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.4.tgz", + "integrity": "sha512-LFiNfRcSu7KK3evMyYOuCzv3L10TW7yC1G2/+StMjK8Y6Vqd2MG7r/Qjw4ghtuCOjFvlnms/iMmLqpvW/ES/WQ==", "dev": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==", + "dev": true + }, + "rescript": { + "version": "9.1.4", + "resolved": "https://registry.npmjs.org/rescript/-/rescript-9.1.4.tgz", + "integrity": "sha512-aXANK4IqecJzdnDpJUsU6pxMViCR5ogAxzuqS0mOr8TloMnzAjJFu63fjD6LCkWrKAhlMkFFzQvVQYaAaVkFXw==", "dev": true }, + "rescript-webapi": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/rescript-webapi/-/rescript-webapi-0.6.1.tgz", + "integrity": "sha512-I/eeHOcsUfWbCf6u15zd+rKxMz9awSjjdRa8eFtl2X+HjDNs0mJxoC4uFFK9dIazYcmY2VpuK5TTpOPXvdkhDw==" + }, "resolve": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.5.0.tgz", - "integrity": "sha1-HwmsznlsmnYlefMbLBzEw83fnzY=", + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", "dev": true, "requires": { - "path-parse": "^1.0.5" + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", + "integrity": "sha512-ZuF55hVUQaaczgOIwqWzkEcEidmlD/xl44x1UZnhOXcYuFN2S6+rcxpG+C1N3So0wvNI3DmJICUFfu2SxhBmvg==", "dev": true }, "ret": { @@ -2808,34 +2584,40 @@ "dev": true }, "ripemd160": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz", - "integrity": "sha1-D0WEKVxTo2KK9+bXmsohzlfRxuc=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", "dev": true, "requires": { - "hash-base": "^2.0.0", + "hash-base": "^3.0.0", "inherits": "^2.0.1" } }, "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, "safe-regex": { "version": "1.1.0", - "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", + "integrity": "sha512-aJXcif4xnaNUzvUuC5gcb46oTS7zvg4jpMTnuqtrEPlR3vFr4pxtdTwaF1Qs3Enjn9HK+ZlwQui+a7z0SywIzg==", "dev": true, "requires": { "ret": "~0.1.10" } }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha1-4FnAnYVx8FQII3M0M1BdOi8AsY4=", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "dev": true }, "set-value": { @@ -2853,7 +2635,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -2862,9 +2644,9 @@ } }, "sha.js": { - "version": "2.4.9", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.9.tgz", - "integrity": "sha1-mPZIgEdLdPSji42p08Dy0QRjPn0=", + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -2874,17 +2656,26 @@ "shasum": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/shasum/-/shasum-1.0.2.tgz", - "integrity": "sha1-5wEjENj0F/TetXEhUOVni4euVl8=", + "integrity": "sha512-UTzHm/+AzKfO9RgPgRpDIuMSNie1ubXRaljjlhFMNGYoG7z+rm9AHLPMf70R7887xboDH9Q+5YQbWKObFHEAtw==", "dev": true, "requires": { "json-stable-stringify": "~0.0.0", "sha.js": "~2.4.4" } }, + "shasum-object": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", + "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", + "dev": true, + "requires": { + "fast-safe-stringify": "^2.0.7" + } + }, "shebang-command": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", "dev": true, "requires": { "shebang-regex": "^1.0.0" @@ -2893,21 +2684,32 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", "dev": true }, "shell-quote": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", - "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.3.tgz", + "integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==", + "dev": true + }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", "dev": true, "requires": { - "array-filter": "~0.0.0", - "array-map": "~0.0.0", - "array-reduce": "~0.0.0", - "jsonify": "~0.0.0" + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" } }, + "simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -2927,7 +2729,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -2936,7 +2738,7 @@ "extend-shallow": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", "dev": true, "requires": { "is-extendable": "^0.1.0" @@ -2958,7 +2760,7 @@ "define-property": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "integrity": "sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==", "dev": true, "requires": { "is-descriptor": "^1.0.0" @@ -3007,7 +2809,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -3018,16 +2820,16 @@ "source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "integrity": "sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ==", "dev": true }, "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", + "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", "dev": true, "requires": { - "atob": "^2.1.1", + "atob": "^2.1.2", "decode-uri-component": "^0.2.0", "resolve-url": "^0.2.1", "source-map-url": "^0.4.0", @@ -3035,15 +2837,15 @@ } }, "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", + "integrity": "sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==", "dev": true }, "spawn-sync": { "version": "1.0.15", "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz", - "integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=", + "integrity": "sha512-9DWBgrgYZzNghseho0JOuh+5fg9u6QWhAWa51QC7+U5rCheZ/j1DrEZnyE0RBBRqZ9uEXGPgSSM0nky6burpVw==", "dev": true, "requires": { "concat-stream": "^1.4.7", @@ -3051,30 +2853,41 @@ } }, "spdx-correct": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-1.0.2.tgz", - "integrity": "sha1-SzBz2TP/UfORLwOsVRlJikFQ20A=", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", "dev": true, "requires": { - "spdx-license-ids": "^1.0.2" + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" } }, - "spdx-expression-parse": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz", - "integrity": "sha1-m98vIOH0DtRH++JzJmGR/O1RYmw=", + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", "dev": true }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, "spdx-license-ids": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz", - "integrity": "sha1-yd96NCRZSt5r0RkA1ZZpbcBrrFc=", + "version": "3.0.12", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz", + "integrity": "sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==", "dev": true }, "split": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "integrity": "sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==", "dev": true, "requires": { "through": "2" @@ -3092,7 +2905,7 @@ "static-extend": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", + "integrity": "sha512-72E9+uLc27Mt718pMHt9VMNiAL4LMsmDbBva8mxWUCkT07fSzEGMYUCk0XWY6lp0j6RBAG4cJ3mWuZv2OE3s0g==", "dev": true, "requires": { "define-property": "^0.2.5", @@ -3102,7 +2915,7 @@ "define-property": { "version": "0.2.5", "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", + "integrity": "sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==", "dev": true, "requires": { "is-descriptor": "^0.1.0" @@ -3111,9 +2924,9 @@ } }, "stream-browserify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", - "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.2.tgz", + "integrity": "sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg==", "dev": true, "requires": { "inherits": "~2.0.1", @@ -3123,7 +2936,7 @@ "stream-combiner": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "integrity": "sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==", "dev": true, "requires": { "duplexer": "~0.1.1" @@ -3132,7 +2945,7 @@ "stream-combiner2": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", - "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", + "integrity": "sha512-3PnJbYgS56AeWgtKF5jtJRT6uFJe56Z0Hc5Ngg/6sI6rIt8iiMBTa9cvdyFfpMQjaVHr8dusbNeFGIIonxOvKw==", "dev": true, "requires": { "duplexer2": "~0.1.0", @@ -3140,22 +2953,22 @@ } }, "stream-http": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.7.2.tgz", - "integrity": "sha1-QKBQ7I3DtTsz2ZCUFcAsC/Gr+60=", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", + "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", "dev": true, "requires": { "builtin-status-codes": "^3.0.0", "inherits": "^2.0.1", - "readable-stream": "^2.2.6", + "readable-stream": "^2.3.6", "to-arraybuffer": "^1.0.0", "xtend": "^4.0.0" } }, "stream-splicer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.0.tgz", - "integrity": "sha1-G2O+Q4oTPktnHMGTUZdgAXWRDYM=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", + "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", "dev": true, "requires": { "inherits": "^2.0.1", @@ -3163,29 +2976,59 @@ } }, "string.prototype.padend": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz", - "integrity": "sha1-86rvfBcZ8XDF6rHDK/eA2W4h8vA=", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.3.tgz", + "integrity": "sha512-jNIIeokznm8SD/TZISQsZKYu7RJyheFNt84DUPrh482GC8RVp2MKqm2O5oBRdGxbDQoXrhhWtPIWQOiy20svUg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3", + "es-abstract": "^1.19.1" + } + }, + "string.prototype.trimend": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.5.tgz", + "integrity": "sha512-I7RGvmjV4pJ7O3kdf+LXFpVfdNOxtCW/2C8f6jNiW4+PQchwxkCDzlk1/7p+Wl4bqFIZeF47qAHXLuHHWKAxog==", "dev": true, "requires": { - "define-properties": "^1.1.2", - "es-abstract": "^1.4.3", - "function-bind": "^1.0.2" + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" + } + }, + "string.prototype.trimstart": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.5.tgz", + "integrity": "sha512-THx16TJCGlsN0o6dl2o6ncWUsdgnLRSA23rRE5pyGBw/mLr3Ej/R2LaqCtgP8VNMGZsvMWnf9ooZPyY2bHvUFg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.4", + "es-abstract": "^1.19.5" } }, "string_decoder": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", "dev": true, "requires": { "safe-buffer": "~5.1.0" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } } }, "strip-ansi": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "integrity": "sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg==", "dev": true, "requires": { "ansi-regex": "^2.0.0" @@ -3194,13 +3037,13 @@ "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", "dev": true }, "subarg": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", - "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", + "integrity": "sha512-RIrIdRY0X1xojthNcVtgT9sjpOGagEUKpZdgBUi054OEPFo282yg+zE+t1Rj3+RqKq2xStL7uUHhY+AjbC4BXg==", "dev": true, "requires": { "minimist": "^1.1.0" @@ -3209,38 +3052,44 @@ "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "integrity": "sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==", + "dev": true + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, "syntax-error": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.3.0.tgz", - "integrity": "sha1-HtkmbE1AvnXcVb+bsct3Biu5bKE=", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", "dev": true, "requires": { - "acorn": "^4.0.3" + "acorn-node": "^1.2.0" } }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", "dev": true }, "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", "dev": true, "requires": { - "readable-stream": "^2.1.5", + "readable-stream": "~2.3.6", "xtend": "~4.0.1" } }, "timers-browserify": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", - "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", + "integrity": "sha512-PIxwAupJZiYU4JmVZYwXp9FKsHMXb5h0ZEFyuXTAn8WLHOlcij+FEcbrvDsom1o5dr1YggEtFbECvGCW2sT53Q==", "dev": true, "requires": { "process": "~0.11.0" @@ -3249,13 +3098,13 @@ "to-arraybuffer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", - "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", + "integrity": "sha512-okFlQcoGTi4LQBG/PgSYblw9VOyptsz2KJZqc6qtgGdes8VktzUQkj4BI2blit072iS8VODNcMA+tvnS9dnuMA==", "dev": true }, "to-object-path": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", + "integrity": "sha512-9mWHdnGRuh3onocaHzukyvCZhzvr6tiflAy/JRFXcJX0TjgfWA9pk9t8CMbzmBE4Jfw58pXbkngtBtqYxzNEyg==", "dev": true, "requires": { "kind-of": "^3.0.2" @@ -3264,7 +3113,7 @@ "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==", "dev": true, "requires": { "is-buffer": "^1.1.5" @@ -3287,7 +3136,7 @@ "to-regex-range": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", + "integrity": "sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg==", "dev": true, "requires": { "is-number": "^3.0.0", @@ -3295,23 +3144,48 @@ } }, "tty-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", - "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", "dev": true }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, "umd": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.1.tgz", - "integrity": "sha1-iuVW4RAR9jwllnCKiDclnwGz1g4=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, + "unbox-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.2.tgz", + "integrity": "sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-bigints": "^1.0.2", + "has-symbols": "^1.0.3", + "which-boxed-primitive": "^1.0.2" + } + }, + "undeclared-identifiers": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", + "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", + "dev": true, + "requires": { + "acorn-node": "^1.3.0", + "dash-ast": "^1.0.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + } + }, "union-value": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", @@ -3327,7 +3201,7 @@ "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", + "integrity": "sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==", "dev": true, "requires": { "has-value": "^0.3.1", @@ -3337,7 +3211,7 @@ "has-value": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", + "integrity": "sha512-gpG936j8/MzaeID5Yif+577c17TxaDmhuyVgSwtnL/q8UUTySg8Mecb+8Cf1otgLoD7DDH75axp86ER7LFsf3Q==", "dev": true, "requires": { "get-value": "^2.0.3", @@ -3348,7 +3222,7 @@ "isobject": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", "dev": true, "requires": { "isarray": "1.0.0" @@ -3359,27 +3233,27 @@ "has-values": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", + "integrity": "sha512-J8S0cEdWuQbqD9//tlZxiMuMNmxB8PlEwvYwuxsTmR1G5RXUePEX/SJn7aD0GMLieuZYSwNH0cQuJGwnYunXRQ==", "dev": true } } }, "upath": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", - "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", + "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", "dev": true }, "urix": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", + "integrity": "sha512-Am1ousAhSLBeB9cG/7k7r2R0zj50uDRlZHPGbazid5s9rlF1F/QKYObEKSIunSjIOkJZqwRRLpvewjEkM7pSqg==", "dev": true }, "url": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "integrity": "sha512-kbailJa29QrtXnxgq+DdCEGlbTeYM2eJUxsz6vjZavrCYPMIFHMKQmSKYAIuUK2i7hgPm28a8piX5NTUtM/LKQ==", "dev": true, "requires": { "punycode": "1.3.2", @@ -3389,7 +3263,7 @@ "punycode": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "integrity": "sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw==", "dev": true } } @@ -3401,18 +3275,18 @@ "dev": true }, "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", "dev": true, "requires": { - "inherits": "2.0.1" + "inherits": "2.0.3" }, "dependencies": { "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==", "dev": true } } @@ -3420,23 +3294,23 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", "dev": true }, "validate-npm-package-license": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", - "integrity": "sha1-KAS6vnEq0zeUWaz74kdGqywwP7w=", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { - "spdx-correct": "~1.0.0", - "spdx-expression-parse": "~1.0.0" + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" } }, "vm-browserify": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", + "integrity": "sha512-NyZNR3WDah+NPkjh/YmhuWSsT4a0mF0BJYgUmvrJ70zxjTXh5Y2Asobxlh0Nfs0PCFB5FVpRJft7NozAWFMwLQ==", "dev": true, "requires": { "indexof": "0.0.1" @@ -3457,18 +3331,27 @@ "xtend": "^4.0.0" }, "dependencies": { + "browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "requires": { + "resolve": "^1.17.0" + } + }, "browserify": { - "version": "16.3.0", - "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.3.0.tgz", - "integrity": "sha512-BWaaD7alyGZVEBBwSTYx4iJF5DswIGzK17o8ai9w4iKRbYpk3EOiprRHMRRA8DCZFmFeOdx7A385w2XdFvxWmg==", + "version": "16.5.2", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-16.5.2.tgz", + "integrity": "sha512-TkOR1cQGdmXU9zW4YukWzWVSJwrxmNdADFbqbE3HFgQWe5wqZmOawqZ7J/8MPCwk/W8yY7Y0h+7mOtcZxLP23g==", "dev": true, "requires": { "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", - "browser-resolve": "^1.11.0", + "browser-resolve": "^2.0.0", "browserify-zlib": "~0.2.0", - "buffer": "^5.0.2", + "buffer": "~5.2.1", "cached-path-relative": "^1.0.0", "concat-stream": "^1.6.0", "console-browserify": "^1.1.0", @@ -3486,8 +3369,8 @@ "inherits": "~2.0.1", "insert-module-globals": "^7.0.0", "labeled-stream-splicer": "^2.0.0", - "mkdirp": "^0.5.0", - "module-deps": "^6.0.0", + "mkdirp-classic": "^0.5.2", + "module-deps": "^6.2.3", "os-browserify": "~0.3.0", "parents": "^1.0.1", "path-browserify": "~0.0.0", @@ -3500,7 +3383,7 @@ "shasum": "^1.0.0", "shell-quote": "^1.6.1", "stream-browserify": "^2.0.0", - "stream-http": "^2.0.0", + "stream-http": "^3.0.0", "string_decoder": "^1.1.1", "subarg": "^1.0.0", "syntax-error": "^1.1.1", @@ -3513,6 +3396,16 @@ "xtend": "^4.0.0" } }, + "buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "dev": true, + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, "concat-stream": { "version": "1.6.2", "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", @@ -3526,14 +3419,14 @@ } }, "detective": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", - "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.1.tgz", + "integrity": "sha512-v9XE1zRnz1wRtgurGu0Bs8uHKFSTdteYZNbIPFVhUZ39L/S79ppMpdmVOZAnoz1jfEFodc48n6MX483Xo3t1yw==", "dev": true, "requires": { - "acorn-node": "^1.6.1", + "acorn-node": "^1.8.2", "defined": "^1.0.0", - "minimist": "^1.1.1" + "minimist": "^1.2.6" } }, "domain-browser": { @@ -3549,17 +3442,17 @@ "dev": true }, "module-deps": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.1.tgz", - "integrity": "sha512-UnEn6Ah36Tu4jFiBbJVUtt0h+iXqxpLqDvPS8nllbw5RZFmNJ1+Mz5BjYnM9ieH80zyxHkARGLnMIHlPK5bu6A==", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.3.tgz", + "integrity": "sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA==", "dev": true, "requires": { "JSONStream": "^1.0.3", - "browser-resolve": "^1.7.0", + "browser-resolve": "^2.0.0", "cached-path-relative": "^1.0.2", "concat-stream": "~1.6.0", "defined": "^1.0.0", - "detective": "^5.0.2", + "detective": "^5.2.0", "duplexer2": "^0.1.2", "inherits": "^2.0.1", "parents": "^1.0.0", @@ -3571,54 +3464,86 @@ "xtend": "^4.0.0" } }, - "string_decoder": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", - "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "stream-http": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", + "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", "dev": true, "requires": { - "safe-buffer": "~5.1.0" + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "xtend": "^4.0.2" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } } }, - "tty-browserify": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", - "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", - "dev": true + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } }, "vm-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.0.tgz", - "integrity": "sha512-iq+S7vZJE60yejDYM0ek6zg308+UZsdtPExWP9VZoCFCz1zkJoXFnAX7aZfd/ZwrkidzdUZL0C/ryW+JwAiIGw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", + "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "dev": true } } }, "which": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", - "integrity": "sha1-/wS9/AEO5UfXgL7DjhrBwnd9JTo=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", "dev": true, "requires": { "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true }, "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", "dev": true }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "integrity": "sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==", "dev": true } } diff --git a/package.json b/package.json index 759a3a8..3b95168 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,21 @@ { - "name": "bucklescript-tea", + "name": "rescript-tea", "version": "0.15.0", "description": "TEA for Bucklescript", "main": "index.js", "scripts": { - "clean": "bsb clean", - "clean:all": "bsb -clean-world", - "build": "bsb", - "build:all": "bsb -make-world", - "watch": "bsb -w", + "clean": "rescript clean", + "clean:all": "rescript -clean-world", + "build": "rescript", + "build:all": "rescript clean -with-deps", + "watch": "rescript -w", "build:test:client": "browserify --standalone=Test_client --outfile=lib/js/test-ocaml/app_test_client.js lib/js/test-ocaml/test_client.js", "watch:test:client": "watchify --standalone=Test_client --outfile=lib/js/test-ocaml/app_test_client.js lib/js/test-ocaml/test_client.js", "watch:test": "run-p watch watch:test:*", "prebuild:test": "run-s build", "build:test": "run-p build:test:*", "pretest": "run-s build:test", - "test": "echo \"Error: no test specified\" && exit 1", - "dual-syntax": "bin/dual-syntax" + "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", @@ -34,13 +33,14 @@ }, "homepage": "https://github.com/overminddl1/bucklescript-tea#readme", "devDependencies": { - "browserify": "^14.0.0", - "bs-platform": "^7.1.1", - "npm-run-all": "4.0.2", - "pre-commit": "^1.2.0", + "browserify": "^14.5.0", + "npm-run-all": "^4.0.2", + "pre-commit": "^1.2.2", + "rescript": "^9.1.4", "watchify": "^3.11.1" }, - "pre-commit": [ - "dual-syntax" - ] + "dependencies": { + "@glennsl/rescript-json-combinators": "^1.0.0", + "rescript-webapi": "^0.6.1" + } } diff --git a/src-ocaml/tea_animationframe.ml b/src-ocaml/tea_animationframe.ml deleted file mode 100644 index e9fe791..0000000 --- a/src-ocaml/tea_animationframe.ml +++ /dev/null @@ -1,48 +0,0 @@ - - -type t = - { time : Tea_time.t - ; delta : Tea_time.t - } - -let every ?(key="") tagger = - let open Vdom in - let enableCall callbacks = - (* let () = Js.log ("rAF", "enable") in *) - let lastTime = ref (Web.Date.now ()) in - let id = ref None in - let rec onFrame _time = - let time = Web.Date.now () in - match !id with - | None -> () - | Some _i -> - let ret = - { time = time - ; delta = if time < !lastTime then 0.0 else time -. !lastTime - } in - let () = lastTime := time in - let () = callbacks.enqueue (tagger ret) in - match !id with - | None -> () - | Some _stillActive -> - let () = id := Some (Web.Window.requestAnimationFrame onFrame) in - () in - let () = id := Some (Web.Window.requestAnimationFrame onFrame) in - fun () -> match !id with - | None -> () - | Some i -> - (* let () = Js.log ("rAF", "disable") in *) - let () = Web.Window.cancelAnimationFrame i in - let () = id := None in - () - in Tea_sub.registration key enableCall - - -let times ?(key="") tagger = - every - (fun ev -> tagger ~key:key ev.time) - - -let diffs ?(key="") tagger = - every - (fun ev -> tagger ~key:key ev.delta) diff --git a/src-ocaml/tea_app.ml b/src-ocaml/tea_app.ml deleted file mode 100644 index cd97f15..0000000 --- a/src-ocaml/tea_app.ml +++ /dev/null @@ -1,258 +0,0 @@ -type ('flags, 'model, 'msg) program = - { - init: 'flags -> ('model * 'msg Tea_cmd.t) ; - update: 'model -> 'msg -> ('model * 'msg Tea_cmd.t) ; - view: 'model -> 'msg Vdom.t ; - subscriptions: 'model -> 'msg Tea_sub.t ; - shutdown: 'model -> 'msg Tea_cmd.t } -type ('flags, 'model, 'msg) standardProgram = - { - init: 'flags -> ('model * 'msg Tea_cmd.t) ; - update: 'model -> 'msg -> ('model * 'msg Tea_cmd.t) ; - view: 'model -> 'msg Vdom.t ; - subscriptions: 'model -> 'msg Tea_sub.t } -type ('model, 'msg) beginnerProgram = - { - model: 'model ; - update: 'model -> 'msg -> 'model ; - view: 'model -> 'msg Vdom.t } -type ('model, 'msg) pumpInterface = - { - startup: unit -> unit ; - render_string: 'model -> string ; - handleMsg: 'model -> 'msg -> 'model ; - shutdown: 'msg Tea_cmd.t -> unit } -type 'msg programInterface = - < - pushMsg: 'msg -> unit ;shutdown: unit -> unit ;getHtmlString: unit -> - string - > Js.t -external makeProgramInterface : - pushMsg:('msg -> unit) -> - shutdown:(unit -> unit) -> - getHtmlString:(unit -> string) -> 'msg programInterface = ""[@@bs.obj ] -let programStateWrapper initModel pump shutdown = - let open Vdom in - let model = ref initModel in - let callbacks = - ref - { - enqueue = (fun _msg -> Js.log "INVALID enqueue CALL!"); - on = (fun _ -> ()) - } in - let pumperInterfaceC () = pump callbacks in - let pumperInterface = pumperInterfaceC () in - let pending = ((ref None : 'msg list option ref) : 'msg list option ref) in - let rec handler msg = - match !pending with - | None -> - let () = pending := ((Some ([]))[@explicit_arity ]) in - let newModel = pumperInterface.handleMsg (!model) msg in - let () = model := newModel in - (match !pending with - | None -> - failwith - "INVALID message queue state, should never be None during message processing!" - | ((Some ([]))[@explicit_arity ]) -> pending := None - | ((Some (msgs))[@explicit_arity ]) -> - let () = pending := None in List.iter handler (List.rev msgs)) - | ((Some (msgs))[@explicit_arity ]) -> - pending := ((Some ((msg :: msgs)))[@explicit_arity ]) in - let render_events = ref [] in - let finalizedCBs = - (({ - enqueue = (fun msg -> handler msg); - on = - (function - | Render -> List.iter handler (!render_events) - | ((AddRenderMsg (msg))[@explicit_arity ]) -> - render_events := (List.append (!render_events) [msg]) - | ((RemoveRenderMsg (msg))[@explicit_arity ]) -> - render_events := - (List.filter (fun mg -> msg != mg) (!render_events))) - } : 'msg Vdom.applicationCallbacks) : 'msg Vdom.applicationCallbacks) in - let () = callbacks := finalizedCBs in - let pi_requestShutdown () = - let () = - callbacks := - { - enqueue = - (fun _msg -> Js.log "INVALID message enqueued when shut down"); - on = (fun _ -> ()) - } in - let cmd = shutdown (!model) in - let () = pumperInterface.shutdown cmd in () in - let render_string () = - let rendered = pumperInterface.render_string (!model) in rendered in - let () = pumperInterface.startup () in - makeProgramInterface ~pushMsg:handler ~shutdown:pi_requestShutdown - ~getHtmlString:render_string -let programLoop update view subscriptions initModel initCmd = - function - | None -> - (fun callbacks -> - let oldSub = ref Tea_sub.none in - let handleSubscriptionChange model = - let newSub = subscriptions model in - oldSub := (Tea_sub.run callbacks callbacks (!oldSub) newSub) in - { - startup = - (fun () -> - let () = Tea_cmd.run callbacks initCmd in - let () = handleSubscriptionChange initModel in ()); - render_string = - (fun model -> - let vdom = view model in - let rendered = Vdom.renderToHtmlString vdom in rendered); - handleMsg = - (fun model -> - fun msg -> - let (newModel, cmd) = update model msg in - let () = Tea_cmd.run callbacks cmd in - let () = handleSubscriptionChange newModel in newModel); - shutdown = - (fun cmd -> - let () = Tea_cmd.run callbacks cmd in - let () = - oldSub := - (Tea_sub.run callbacks callbacks (!oldSub) Tea_sub.none) in - ()) - }) - | ((Some (parentNode))[@explicit_arity ]) -> - (fun callbacks -> - let priorRenderedVdom = ref [] in - let latestModel = ref initModel in - let nextFrameID = ref None in - let doRender _delta = - match !nextFrameID with - | None -> () - | ((Some (_id))[@explicit_arity ]) -> - let newVdom = [view (!latestModel)] in - let justRenderedVdom = - Vdom.patchVNodesIntoElement callbacks parentNode - (!priorRenderedVdom) newVdom in - let () = priorRenderedVdom := justRenderedVdom in - let () = (!callbacks).on Render in nextFrameID := None in - let scheduleRender () = - match !nextFrameID with - | Some _ -> () - | None -> - let realtimeRendering = false in - if realtimeRendering - then - let () = nextFrameID := ((Some ((-1)))[@explicit_arity ]) in - doRender 16 - else - (let id = Web.Window.requestAnimationFrame doRender in - let () = nextFrameID := ((Some (id))[@explicit_arity ]) in - ()) in - let clearPnode () = - while (Js.Array.length (Web.Node.childNodes parentNode)) > 0 do - match Js.Null.toOption (Web.Node.firstChild parentNode) with - | None -> () - | ((Some (firstChild))[@explicit_arity ]) -> - let _removedChild = - Web.Node.removeChild parentNode firstChild in - () - done in - let oldSub = ref Tea_sub.none in - let handleSubscriptionChange model = - let newSub = subscriptions model in - oldSub := (Tea_sub.run callbacks callbacks (!oldSub) newSub) in - let handlerStartup () = - let () = clearPnode () in - let () = Tea_cmd.run callbacks initCmd in - let () = handleSubscriptionChange (!latestModel) in - let () = nextFrameID := ((Some ((-1)))[@explicit_arity ]) in - let () = doRender 16 in () in - let render_string model = - let vdom = view model in - let rendered = Vdom.renderToHtmlString vdom in rendered in - let handler model msg = - let (newModel, cmd) = update model msg in - let () = latestModel := newModel in - let () = Tea_cmd.run callbacks cmd in - let () = scheduleRender () in - let () = handleSubscriptionChange newModel in newModel in - let handlerShutdown cmd = - let () = nextFrameID := None in - let () = Tea_cmd.run callbacks cmd in - let () = - oldSub := - (Tea_sub.run callbacks callbacks (!oldSub) Tea_sub.none) in - let () = priorRenderedVdom := [] in let () = clearPnode () in () in - { - startup = handlerStartup; - render_string; - handleMsg = handler; - shutdown = handlerShutdown - }) -let program = - ((fun { init; update; view; subscriptions; shutdown } -> - fun pnode -> - fun flags -> - let () = Web.polyfills () in - let (initModel, initCmd) = init flags in - let opnode = Js.Nullable.toOption pnode in - let pumpInterface = - programLoop update view subscriptions initModel initCmd opnode in - programStateWrapper initModel pumpInterface shutdown : ('flags, - 'model, - 'msg) - program -> - Web.Node.t - Js.null_undefined - -> - 'flags -> - 'msg - programInterface) : - ('flags, 'model, 'msg) program -> - Web.Node.t Js.null_undefined -> 'flags -> 'msg programInterface) -let standardProgram = - ((fun { init; update; view; subscriptions } -> - fun pnode -> - fun args -> - program - { - init; - update; - view; - subscriptions; - shutdown = (fun _model -> Tea_cmd.none) - } pnode args : ('flags, 'model, 'msg) standardProgram -> - Web.Node.t Js.null_undefined -> - 'flags -> 'msg programInterface) : ('flags, - 'model, - 'msg) - standardProgram - -> - Web.Node.t - Js.null_undefined - -> - 'flags -> - 'msg - programInterface) -let beginnerProgram = - ((fun { model; update; view } -> - fun pnode -> - fun () -> - standardProgram - { - init = (fun () -> (model, Tea_cmd.none)); - update = - (fun model -> fun msg -> ((update model msg), Tea_cmd.none)); - view; - subscriptions = (fun _model -> Tea_sub.none) - } pnode () : ('model, 'msg) beginnerProgram -> - Web.Node.t Js.null_undefined -> - unit -> 'msg programInterface) : ('model, - 'msg) - beginnerProgram - -> - Web.Node.t - Js.null_undefined - -> - unit -> - 'msg - programInterface) -let map func vnode = Vdom.map func vnode \ No newline at end of file diff --git a/src-ocaml/tea_cmd.ml b/src-ocaml/tea_cmd.ml deleted file mode 100644 index 4860672..0000000 --- a/src-ocaml/tea_cmd.ml +++ /dev/null @@ -1,33 +0,0 @@ -type 'msg applicationCallbacks = 'msg Vdom.applicationCallbacks -type 'msg t = - | NoCmd: _ t - | Mapper: - ('msg Vdom.applicationCallbacks ref -> 'msgB Vdom.applicationCallbacks ref) - * 'msgB t -> 'msg t - | Batch: 'msg t list -> 'msg t - | EnqueueCall: ('msg applicationCallbacks ref -> unit) -> 'msg t -let none = NoCmd -let batch cmds = ((Batch (cmds))[@explicit_arity ]) -let call call = ((EnqueueCall (call))[@explicit_arity ]) -let fnMsg fnMsg = - let open Vdom in - ((EnqueueCall ((fun callbacks -> (!callbacks).enqueue (fnMsg ())))) - [@explicit_arity ]) -let msg msg = - let open Vdom in - ((EnqueueCall ((fun callbacks -> (!callbacks).enqueue msg))) - [@explicit_arity ]) -let rec run : type msg. msg applicationCallbacks ref -> msg t -> unit = - fun callbacks -> - function - | NoCmd -> () - | ((Mapper (mapper, cmd))[@implicit_arity ]) -> - let subCallbacks = mapper callbacks in run subCallbacks cmd - | ((Batch (cmds))[@explicit_arity ]) -> - List.fold_left (fun () -> fun cmd -> run callbacks cmd) () cmds - | ((EnqueueCall (cb))[@explicit_arity ]) -> cb callbacks -let map : type a b. (a -> b) -> a t -> b t = - fun func -> - fun cmd -> - let mapper = Vdom.wrapCallbacks func in ((Mapper (mapper, cmd)) - [@implicit_arity ]) \ No newline at end of file diff --git a/src-ocaml/tea_debug.ml b/src-ocaml/tea_debug.ml deleted file mode 100644 index 951da27..0000000 --- a/src-ocaml/tea_debug.ml +++ /dev/null @@ -1,402 +0,0 @@ -type 'msg debug_msg = - | ClientMsg of 'msg - | TogglePaused - | SelectHistoryItem of int - | ToggleDetails -let client_msg msg = ClientMsg msg - -type state = - | Running - | Paused of int - -type 'model debug_model = { - history : (string * 'model) list; - state : state; - show_details : bool; -} - - -let debug - (string_of_msg : 'msg -> string) - (update : 'model -> 'msg -> 'model * 'msg Tea_cmd.t) - (view : 'model -> 'msg Vdom.t) - (subscriptions : 'model -> 'msg Tea_sub.t) - (shutdown : 'model -> 'msg Tea_cmd.t) : - ( ('model * 'msg Tea_cmd.t -> 'model debug_model * 'msg debug_msg Tea_cmd.t) * - ('model debug_model -> 'msg debug_msg -> 'model debug_model * 'msg debug_msg Tea_cmd.t) * - ('model debug_model -> 'msg debug_msg Vdom.t) * - ('model debug_model -> 'msg debug_msg Tea_sub.t) * - ('model debug_model -> 'msg debug_msg Tea_cmd.t) - ) - = - let init_debug (cmodel, cmd) = - { - history = ["_init_", cmodel]; - state = Running; - show_details = false; - }, cmd |> Tea_cmd.map client_msg - in - - let update' model = function - | ClientMsg msg -> - if model.state = Running then - let _,cmodel = List.hd model.history in - let cmodel',cmd = update cmodel msg in - let dmodel' = { model with history = (string_of_msg msg, cmodel') :: model.history } in - dmodel', cmd |> Tea_cmd.map client_msg - else - model, Tea_cmd.none - | TogglePaused -> - begin match model.state with - | Paused _ -> { model with state = Running }, Tea_cmd.none - | Running -> { model with state = Paused 0 }, Tea_cmd.none - end - | SelectHistoryItem i -> - { model with state = Paused i }, Tea_cmd.none - | ToggleDetails -> - { model with show_details = not model.show_details }, Tea_cmd.none - in - - let view_styles () = - let open Tea_html2 in - let rule selector properties = - properties |> List.map (fun (k,v) -> k ^ ":" ^ v) |> String.concat ";" |> (fun x -> {j|$(selector) {$(x)}|j}) |> text - in - node "style" [] [ - rule "#debug.paused" [ - "position", "fixed"; "top", "0"; "left", "0"; "width", "100%"; "height", "100%"; "pointer-events", "all"; - "background-color", "rgba(0,0,0,.1)"; - "box-shadow", "inset 0 0 10px #333"; - ]; - rule "#debug nav" [ - "position", "fixed"; "max-width", "50%"; "bottom", "0"; "right", "6px"; - "border-radius", "4px 4px 0 0"; "background-color", "#444"; "color", "#fff"; "font-family", "monospace"; - "box-shadow", "0 0 10px #333"; - ]; - rule "#debug.paused nav" ["height", "50%"; "padding-bottom", "2em"]; - rule "#debug nav .toggle" [ - "padding", "6px"; - "padding-left", "9px"; - "cursor", "pointer"; - "min-width", "24ch"; - "text-align", "center"; - "border-left", "3px solid #333"; - "border-radius", "4px 4px 0 0" - ]; - rule "#debug nav .toggle:before" [ - "content", "' '"; - "position", "absolute"; "left", "0"; "top", "0"; - "width", ".5ch"; "height", "1.8ch"; - "margin", "1.2ch"; - "border", "solid #fff"; - "border-width", "0 .5ch"; - ]; - rule "#debug.paused nav .toggle:before" [ - "border-color", "transparent"; "border-left-color", "#fff"; - "border-width", "1ch"; - "width", "0"; "height", "0"; - ]; - rule "#debug nav .history" [ - "margin", "0"; "padding", "0"; - "height", "100%"; - "overflow-y", "auto"; - "list-style", "none"; - ]; - rule "#debug nav .history li" ["margin", "0"; "padding", "0.2ch"; "border-left", "3px solid #333"]; - rule "#debug nav .history li.selected" ["background-color", "#333"]; - rule "#debug nav .history span.details" [ - "display", "inline-block"; "cursor", "pointer"; - "width", "1ch"; - "margin", "0 1ch"; - "vertical-align", "super"; - ]; - rule "#debug nav .history li.selected span.details:after" ["content", "'\\2026'"]; - rule "#debug nav .history li.selected.show" ["border-left", "3px solid white"]; - rule "#debug nav .history span.message" [ - "display", "inline-block"; "cursor", "pointer"; - "white-space", "nowrap"; "overflow", "hidden"; "text-overflow", "ellipsis"; - "width", "calc(100% - 75px)" - ]; - rule "#debug nav .history span.index" [ - "display", "inline-block"; - "min-width", "3ch"; "margin", "0 1ch"; - "color", "#aaa"; "text-align", "right"; - "float", "right"; - ]; - rule "#debug aside.details" [ - "position", "absolute"; - "width", "40ch"; "top", "0"; "bottom", "0"; "right", "100%"; - "margin-right", "1.5ch"; - "overflow", "scroll"; - "background-color", "#fff"; "color", "#000"; - "box-shadow", "0 0 10px #333"; - "border-radius", "4px 4px 0 0"; - "border", "2px solid #333"; - "padding", "1ch"; - "white-space", "pre"; - ]; - ] - in - - let view_details model = - let open Tea_html2 in - let module A = Tea_html2.Attributes in - let format = [%raw {| - function (v) { - var formatRecord = function (data, labels) { - return data.reduce( - function (acc, cur, index) { - acc[labels[index]] = formatValue(cur) - return acc - }, {}) - } - var listToArray = function (data) { - var result = [] - var cur = data - while (typeof cur !== "number") { - result.push(formatValue(cur[0])) - cur = cur[1] - } - return result - } - var formatVariant = function (data, recordVariant) { - if (recordVariant === "::") { - return listToArray(data) - } - else { - return formatRecord(data, [recordVariant]) - } - } - var formatValue = function (x) { - var recordLabels, recordVariant, recordModule, recordPolyVar - if (x == null) { - return null - } - else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { - return formatRecord(x, recordLabels) - } - else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { - return formatRecord(x, recordModule) - } - else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { - return formatVariant(x, recordVariant) - } - else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { - return x[1] - } - else if (Array.isArray(x)) { - // tuple - return x.map(formatValue) - } - else { - // scalar - return x - } - } - return JSON.stringify(formatValue(v), null, 2); - } - |}] in - aside [A.class' "details"] [model |> format |> text] - in - - let view_history model selected_index = - let open Tea_html2 in - let module A = Tea_html2.Attributes in - let module E = Tea_html2.Events in - let count = List.length model.history in - ul [A.class' "history"] @@ - List.mapi (fun i (msg, cmodel) -> - let selected = i = selected_index in - li [ - E.onClick (SelectHistoryItem i); - A.classList ["selected", selected; "show", selected && model.show_details] - ] [ - span ( - A.classList ["details", true; "show", true] :: - if selected - then [E.onClick ToggleDetails; A.title "toggle details"] - else [A.noProp; A.noProp] - ) [ - if selected && model.show_details - then view_details cmodel - else noNode - ]; - span [A.class' "message"] [text msg]; - span [A.class' "index"] [(count - i) |> string_of_int |> text]; - ] - ) model.history - in - - let view' model = - let open Tea_html2 in - let module A = Tea_html2.Attributes in - let module E = Tea_html2.Events in - let selected_index, selected_model, paused = match model.state with - | Running -> 0, (List.hd model.history |> snd), false - | Paused index -> index, (List.nth model.history index |> snd), true - in - let history_count = List.length model.history in - div [] [ - view selected_model |> Tea_app.map client_msg; - div [A.id "debug"; A.classList ["paused", paused]] [ - view_styles (); - nav [] [ - div [ - A.class' "toggle"; E.onClick TogglePaused; - if paused then A.title "click to resume" - else A.title "click to pause" - ] [ - {j|Explore History ($(history_count))|j} |> text - ]; - if paused then - view_history model selected_index - else - noNode; - ]; - ]; - ] - in - - let subscriptions' model = - model.history |> List.hd |> snd |> subscriptions |> Tea_sub.map client_msg - in - - let shutdown' model = - model.history |> List.hd |> snd |> shutdown |> Tea_cmd.map client_msg - in - - ( init_debug, - update', - view', - subscriptions', - shutdown' - ) - - -let debug_program : - ('msg -> string) -> - ('flags, 'model, 'msg) Tea_app.program -> - ('flags, 'model debug_model, 'msg debug_msg) Tea_app.program - = - fun string_of_msg { init; update; view; subscriptions; shutdown } -> - let (init_debug, update', view', subscriptions', shutdown') = debug - string_of_msg - update - view - subscriptions - shutdown - in - - { - init = (fun flags -> init flags |> init_debug); - update = update'; - view = view'; - subscriptions = subscriptions'; - shutdown = shutdown'; - } - - -let debug_navigation_program : - ('msg -> string) -> - ('flags, 'model, 'msg) Tea_navigation.navigationProgram -> - ('flags, 'model debug_model, 'msg debug_msg) Tea_navigation.navigationProgram - = - fun string_of_msg { init; update; view; subscriptions; shutdown } -> - let (init_debug, update', view', subscriptions', shutdown') = debug - string_of_msg - update - view - subscriptions - shutdown - in - - { - init = (fun flags location -> init flags location |> init_debug); - update = update'; - view = view'; - subscriptions = subscriptions'; - shutdown = shutdown'; - } - - - -let beginnerProgram : - ('model, 'msg) Tea_app.beginnerProgram -> - ('msg -> string) -> - Web.Node.t Js.null_undefined -> - unit -> - 'msg debug_msg Tea_app.programInterface - = fun { model; update; view; } string_of_msg pnode flags -> - let debugged = debug_program - string_of_msg - { - init = (fun () -> model, Tea_cmd.none); - update = (fun model msg -> update model msg, Tea_cmd.none); - view; - subscriptions = (fun _model -> Tea_sub.none); - shutdown = (fun _model -> Tea_cmd.none); - } - in Tea_app.program debugged pnode flags - - -let standardProgram : - ('flags, 'model, 'msg) Tea_app.standardProgram -> - ('msg -> string) -> - Web.Node.t Js.null_undefined -> - 'flags -> - 'msg debug_msg Tea_app.programInterface - = fun { init; update; view; subscriptions } string_of_msg pnode flags -> - let debugged = debug_program - string_of_msg - { - init; - update; - view; - subscriptions; - shutdown = (fun _model -> Tea_cmd.none); - } - in Tea_app.program debugged pnode flags - - -let program : - ('flags, 'model, 'msg) Tea_app.program -> - ('msg -> string) -> - Web.Node.t Js.null_undefined -> - 'flags -> - 'msg debug_msg Tea_app.programInterface - = fun { init; update; view; subscriptions; shutdown } string_of_msg pnode flags -> - let debugged = debug_program - string_of_msg - { - init; - update; - view; - subscriptions; - shutdown; - } - in Tea_app.program debugged pnode flags - - -let navigationProgram : - (Web.Location.location -> 'msg) -> - ('flags, 'model, 'msg) Tea_navigation.navigationProgram -> - ('msg -> string) -> - Web.Node.t Js.null_undefined -> - 'flags -> - 'msg debug_msg Tea_app.programInterface - = fun location_to_msg { init; update; view; subscriptions; shutdown } string_of_msg pnode flags -> - let location = fun location -> - location - |> location_to_msg - |> client_msg - in - let debugged = debug_navigation_program - string_of_msg - { - init; - update; - view; - subscriptions; - shutdown; - } - in Tea_navigation.navigationProgram location debugged pnode flags diff --git a/src-ocaml/tea_ex.ml b/src-ocaml/tea_ex.ml deleted file mode 100644 index 9d2d687..0000000 --- a/src-ocaml/tea_ex.ml +++ /dev/null @@ -1,72 +0,0 @@ -let render_event ?(key= "") msg = - let open Vdom in - let enableCall callbacks = - let () = callbacks.on ((AddRenderMsg (msg))[@explicit_arity ]) in - fun () -> callbacks.on ((RemoveRenderMsg (msg))[@explicit_arity ]) in - Tea_sub.registration key enableCall -module LocalStorage = - struct - open Tea_task - open Tea_result - let length = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.length Web.Window.window with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (value))[@explicit_arity ]) -> - cb ((Ok (value))[@explicit_arity ])) - let clear = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.clear Web.Window.window with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (value))[@explicit_arity ]) -> - cb ((Ok (value))[@explicit_arity ])) - let clearCmd () = Tea_task.attemptOpt (fun _ -> None) clear - let key idx = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.key Web.Window.window idx with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (value))[@explicit_arity ]) -> - cb ((Ok (value))[@explicit_arity ])) - let getItem key = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.getItem Web.Window.window key with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (value))[@explicit_arity ]) -> - cb ((Ok (value))[@explicit_arity ])) - let removeItem key = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.removeItem Web.Window.window key - with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (value))[@explicit_arity ]) -> - cb ((Ok (value))[@explicit_arity ])) - let removeItemCmd key = - Tea_task.attemptOpt (fun _ -> None) (removeItem key) - let setItem key value = - nativeBinding - (fun cb -> - match Web.Window.LocalStorage.setItem Web.Window.window key value - with - | None -> - cb ((Error ("localStorage is not available")) - [@explicit_arity ]) - | ((Some (()))[@explicit_arity ]) -> - cb ((Ok (()))[@explicit_arity ])) - let setItemCmd key value = - Tea_task.attemptOpt (fun _ -> None) (setItem key value) - end \ No newline at end of file diff --git a/src-ocaml/tea_html.ml b/src-ocaml/tea_html.ml deleted file mode 100644 index 3294007..0000000 --- a/src-ocaml/tea_html.ml +++ /dev/null @@ -1,373 +0,0 @@ -open Vdom - -module Cmds = Tea_html_cmds - -let map = Tea_app.map - -(* Nodes *) - -let noNode = noNode - -let text str = text str - -let lazy1 key gen = lazyGen key gen - -let node ?(namespace="") tagName ?(key="") ?(unique="") props nodes = fullnode namespace tagName key unique props nodes - -(* let embedProgram main = custom *) - - -(* HTML Elements *) - -let br props = fullnode "" "br" "br" "br" props [] - -let br' ?(key="") ?(unique="") props nodes = fullnode "" "br" key unique props nodes - -let div ?(key="") ?(unique="") props nodes = fullnode "" "div" key unique props nodes - -let span ?(key="") ?(unique="") props nodes = fullnode "" "span" key unique props nodes - -let p ?(key="") ?(unique="") props nodes = fullnode "" "p" key unique props nodes - -let pre ?(key="") ?(unique="") props nodes = fullnode "" "pre" key unique props nodes - -let a ?(key="") ?(unique="") props nodes = fullnode "" "a" key unique props nodes - -let section ?(key="") ?(unique="") props nodes = fullnode "" "section" key unique props nodes - -let header ?(key="") ?(unique="") props nodes = fullnode "" "header" key unique props nodes - -let footer ?(key="") ?(unique="") props nodes = fullnode "" "footer" key unique props nodes - -let h1 ?(key="") ?(unique="") props nodes = fullnode "" "h1" key unique props nodes - -let h2 ?(key="") ?(unique="") props nodes = fullnode "" "h2" key unique props nodes - -let h3 ?(key="") ?(unique="") props nodes = fullnode "" "h3" key unique props nodes - -let h4 ?(key="") ?(unique="") props nodes = fullnode "" "h4" key unique props nodes - -let h5 ?(key="") ?(unique="") props nodes = fullnode "" "h5" key unique props nodes - -let h6 ?(key="") ?(unique="") props nodes = fullnode "" "h6" key unique props nodes - -let i ?(key="") ?(unique="") props nodes = fullnode "" "i" key unique props nodes - -let strong ?(key="") ?(unique="") props nodes = fullnode "" "strong" key unique props nodes - -let button ?(key="") ?(unique="") props nodes = fullnode "" "button" key unique props nodes - -let input' ?(key="") ?(unique="") props nodes = fullnode "" "input" key unique props nodes - -let textarea ?(key="") ?(unique="") props nodes = fullnode "" "textarea" key unique props nodes - -let label ?(key="") ?(unique="") props nodes = fullnode "" "label" key unique props nodes - -let ul ?(key="") ?(unique="") props nodes = fullnode "" "ul" key unique props nodes - -let ol ?(key="") ?(unique="") props nodes = fullnode "" "ol" key unique props nodes - -let li ?(key="") ?(unique="") props nodes = fullnode "" "li" key unique props nodes - -let table ?(key="") ?(unique="") props nodes = fullnode "" "table" key unique props nodes - -let thead ?(key="") ?(unique="") props nodes = fullnode "" "thead" key unique props nodes - -let tfoot ?(key="") ?(unique="") props nodes = fullnode "" "tfoot" key unique props nodes - -let tbody ?(key="") ?(unique="") props nodes = fullnode "" "tbody" key unique props nodes - -let th ?(key="") ?(unique="") props nodes = fullnode "" "th" key unique props nodes - -let tr ?(key="") ?(unique="") props nodes = fullnode "" "tr" key unique props nodes - -let td ?(key="") ?(unique="") props nodes = fullnode "" "td" key unique props nodes - -let progress ?(key="") ?(unique="") props nodes = fullnode "" "progress" key unique props nodes - -let img ?(key="") ?(unique="") props nodes = fullnode "" "img" key unique props nodes - -let select ?(key="") ?(unique="") props nodes = fullnode "" "select" key unique props nodes - -let option' ?(key="") ?(unique="") props nodes = fullnode "" "option" key unique props nodes - -let form ?(key="") ?(unique="") props nodes = fullnode "" "form" key unique props nodes - -let nav ?(key="") ?(unique="") props nodes = fullnode "" "nav" key unique props nodes - -let main ?(key="") ?(unique="") props nodes = fullnode "" "main" key unique props nodes - -let aside ?(key="") ?(unique="") props nodes = fullnode "" "aside" key unique props nodes - -let article ?(key="") ?(unique="") props nodes = fullnode "" "article" key unique props nodes - -let details ?(key="") ?(unique="") props nodes = fullnode "" "details" key unique props nodes - -let figcaption ?(key="") ?(unique="") props nodes = fullnode "" "figcaption" key unique props nodes - -let figure ?(key="") ?(unique="") props nodes = fullnode "" "figure" key unique props nodes - -let mark ?(key="") ?(unique="") props nodes = fullnode "" "mark" key unique props nodes - -let summary ?(key="") ?(unique="") props nodes = fullnode "" "summary" key unique props nodes - -let time ?(key="") ?(unique="") props nodes = fullnode "" "time" key unique props nodes - -let hr ?(key="") ?(unique="") props nodes = fullnode "" "hr" key unique props nodes - -let blockquote ?(key="") ?(unique="") props nodes = fullnode "" "blockquote" key unique props nodes - -let code ?(key="") ?(unique="") props nodes = fullnode "" "code" key unique props nodes - -let em ?(key="") ?(unique="") props nodes = fullnode "" "em" key unique props nodes - -let b ?(key="") ?(unique="") props nodes = fullnode "" "b" key unique props nodes - -let u ?(key="") ?(unique="") props nodes = fullnode "" "u" key unique props nodes - -let sub ?(key="") ?(unique="") props nodes = fullnode "" "sub" key unique props nodes - -let sup ?(key="") ?(unique="") props nodes = fullnode "" "sup" key unique props nodes - -let dl ?(key="") ?(unique="") props nodes = fullnode "" "dl" key unique props nodes - -let dt ?(key="") ?(unique="") props nodes = fullnode "" "dt" key unique props nodes - -let dd ?(key="") ?(unique="") props nodes = fullnode "" "dd" key unique props nodes - -let iframe ?(key="") ?(unique="") props nodes = fullnode "" "iframe" key unique props nodes - -let canvas ?(key="") ?(unique="") props nodes = fullnode "" "canvas" key unique props nodes - -let address ?(key="") ?(unique="") props nodes = fullnode "" "address" key unique props nodes - -let caption ?(key="") ?(unique="") props nodes = fullnode "" "caption" key unique props nodes - -let colgroup ?(key="") ?(unique="") props nodes = fullnode "" "colgroup" key unique props nodes - -let col ?(key="") ?(unique="") props nodes = fullnode "" "col" key unique props nodes - -let fieldset ?(key="") ?(unique="") props nodes = fullnode "" "fieldset" key unique props nodes - -let legend ?(key="") ?(unique="") props nodes = fullnode "" "legend" key unique props nodes - -let datalist ?(key="") ?(unique="") props nodes = fullnode "" "datalist" key unique props nodes - -let optgroup ?(key="") ?(unique="") props nodes = fullnode "" "optgroup" key unique props nodes - -let output ?(key="") ?(unique="") props nodes = fullnode "" "output" key unique props nodes - -let meter ?(key="") ?(unique="") props nodes = fullnode "" "meter" key unique props nodes - -let audio ?(key="") ?(unique="") props nodes = fullnode "" "audio" key unique props nodes - -let video ?(key="") ?(unique="") props nodes = fullnode "" "video" key unique props nodes - -let source ?(key="") ?(unique="") props nodes = fullnode "" "source" key unique props nodes - -let track ?(key="") ?(unique="") props nodes = fullnode "" "track" key unique props nodes - -let embed ?(key="") ?(unique="") props nodes = fullnode "" "embed" key unique props nodes - -let object' ?(key="") ?(unique="") props nodes = fullnode "" "object" key unique props nodes - -let param ?(key="") ?(unique="") props nodes = fullnode "" "param" key unique props nodes - -let ins ?(key="") ?(unique="") props nodes = fullnode "" "ins" key unique props nodes - -let del ?(key="") ?(unique="") props nodes = fullnode "" "del" key unique props nodes - -let small ?(key="") ?(unique="") props nodes = fullnode "" "small" key unique props nodes - -let cite ?(key="") ?(unique="") props nodes = fullnode "" "cite" key unique props nodes - -let dfn ?(key="") ?(unique="") props nodes = fullnode "" "dfn" key unique props nodes - -let abbr ?(key="") ?(unique="") props nodes = fullnode "" "abbr" key unique props nodes - -let var' ?(key="") ?(unique="") props nodes = fullnode "" "var" key unique props nodes - -let samp ?(key="") ?(unique="") props nodes = fullnode "" "samp" key unique props nodes - -let kbd ?(key="") ?(unique="") props nodes = fullnode "" "kbd" key unique props nodes - -let s ?(key="") ?(unique="") props nodes = fullnode "" "s" key unique props nodes - -let q ?(key="") ?(unique="") props nodes = fullnode "" "q" key unique props nodes - -let rt ?(key="") ?(unique="") props nodes = fullnode "" "rt" key unique props nodes - -let bdi ?(key="") ?(unique="") props nodes = fullnode "" "bdi" key unique props nodes - -let bdo ?(key="") ?(unique="") props nodes = fullnode "" "bdo" key unique props nodes - -let wbr ?(key="") ?(unique="") props nodes = fullnode "" "wbr" key unique props nodes - -let menuitem ?(key="") ?(unique="") props nodes = fullnode "" "menuitem" key unique props nodes - -let menu ?(key="") ?(unique="") props nodes = fullnode "" "menu" key unique props nodes - -(* Properties *) - -let noProp = Vdom.noProp - -let id str = prop "id" str - -(* `href` is actually an attribute, not a property, but need it here for Elm compat... *) -let href str = attribute "" "href" str - -(* `src` is actually an attribute, not a property, but need it here for Elm compat... *) -let src str = attribute "" "src" str - -let title str = attribute "" "title" str - -let class' name = prop "className" name - -let classList classes = - classes - |> List.filter (fun (_fst, snd) -> snd) - |> List.map (fun (fst, _snd) -> fst) - |> String.concat " " - |> class' - -let type' typ = prop "type" typ - -let style key value = style key value - -let styles s = styles s - -let placeholder str = prop "placeholder" str - -let autofocus b = if b then prop "autofocus" "autofocus" else noProp - -let value str = prop "value" str - -let name str = prop "name" str - -let checked b = if b then prop "checked" "checked" else noProp - -let for' str = prop "htmlFor" str - -let hidden b = if b then prop "hidden" "hidden" else noProp - -let target t = prop "target" t - -let action a = prop "action" a - -let method' m = prop "method" m - -(* Events *) - -let onCB eventName key cb = onCB eventName key cb - -let onMsg eventName msg = onMsg eventName msg - -let onInputOpt ?(key="") msg = - onCB "input" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##value with - | None -> None - | Some value -> msg value - ) - -let onInput ?(key="") msg = onInputOpt ~key:key (fun ev -> Some (msg ev)) - -let onChangeOpt ?(key="") msg = - onCB "change" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##value with - | None -> None - | Some value -> msg value - ) - -let onChange ?(key="") msg = onChangeOpt ~key:key (fun ev -> Some (msg ev)) - -let onClick msg = - onMsg "click" msg - -let onDoubleClick msg = - onMsg "dblclick" msg - -let onBlur msg = - onMsg "blur" msg - -let onFocus msg = - onMsg "focus" msg - -let onCheckOpt ?(key="") msg = - onCB "change" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##checked with - | None -> None - | Some value -> msg value - ) - -let onCheck ?(key="") msg = onCheckOpt ~key:key (fun ev -> Some (msg ev)) - -let onMouseDown msg = - onMsg "mousedown" msg - -let onMouseUp msg = - onMsg "mouseup" msg - -let onMouseEnter msg = - onMsg "mouseenter" msg - -let onMouseLeave msg = - onMsg "mouseleave" msg - -let onMouseOver msg = - onMsg "mouseover" msg - -let onMouseOut msg = - onMsg "mouseout" msg - -type options = { - stopPropagation : bool; - preventDefault : bool; -} - -let defaultOptions = { - stopPropagation = false; - preventDefault = false; -} - -let onWithOptions ~(key:string) eventName (options: options) decoder = - onCB eventName key (fun event -> - if options.stopPropagation then event##stopPropagation () |> ignore; - if options.preventDefault then event##preventDefault () |> ignore; - event - |> Tea_json.Decoder.decodeEvent decoder - |> Tea_result.result_to_option - ) - -let on ~(key:string) eventName decoder = onWithOptions ~key eventName defaultOptions decoder - -let targetValue = Tea_json.Decoder.at ["target"; "value"] Tea_json.Decoder.string - -let targetChecked = Tea_json.Decoder.at ["target"; "checked"] Tea_json.Decoder.bool - -let keyCode = Tea_json.Decoder.field "keyCode" Tea_json.Decoder.int - -module Attributes = struct - - let max value = attribute "" "max" value - - let min value = attribute "" "min" value - - let step value = attribute "" "step" value - - let disabled b = if b then attribute "" "disabled" "true" else noProp - - let selected b = if b then attribute "" "selected" "true" else noProp - - let acceptCharset c = attribute "" "accept-charset" c - - let rel value = attribute "" "rel" value -end diff --git a/src-ocaml/tea_html2.ml b/src-ocaml/tea_html2.ml deleted file mode 100644 index f87093e..0000000 --- a/src-ocaml/tea_html2.ml +++ /dev/null @@ -1,592 +0,0 @@ -(** This file is organized roughly in order of popularity. The tags which you'd -expect to use frequently will be closer to the top. *) - -open Vdom - -module Cmds = Tea_html_cmds - -let map = Tea_app.map - -(** {1 Primitives} *) - -let text str = text str - -let node ?(namespace="") tagName ?(key="") ?(unique="") props nodes = fullnode namespace tagName key unique props nodes - -let noNode = noNode - -let lazy1 key gen = lazyGen key gen - -(** {1 Tags} *) - -(** {2 Headers} *) - -let h1 ?(key="") ?(unique="") props nodes = fullnode "" "h1" key unique props nodes - -let h2 ?(key="") ?(unique="") props nodes = fullnode "" "h2" key unique props nodes - -let h3 ?(key="") ?(unique="") props nodes = fullnode "" "h3" key unique props nodes - -let h4 ?(key="") ?(unique="") props nodes = fullnode "" "h4" key unique props nodes - -let h5 ?(key="") ?(unique="") props nodes = fullnode "" "h5" key unique props nodes - -let h6 ?(key="") ?(unique="") props nodes = fullnode "" "h6" key unique props nodes - -(** {2 Grouping Content} *) - -let div ?(key="") ?(unique="") props nodes = fullnode "" "div" key unique props nodes - -let p ?(key="") ?(unique="") props nodes = fullnode "" "p" key unique props nodes - -let hr ?(key="") ?(unique="") props nodes = fullnode "" "hr" key unique props nodes - -let pre ?(key="") ?(unique="") props nodes = fullnode "" "pre" key unique props nodes - -let blockquote ?(key="") ?(unique="") props nodes = fullnode "" "blockquote" key unique props nodes - -(** {2 Text} *) - -let span ?(key="") ?(unique="") props nodes = fullnode "" "span" key unique props nodes - -let a ?(key="") ?(unique="") props nodes = fullnode "" "a" key unique props nodes - -let code ?(key="") ?(unique="") props nodes = fullnode "" "code" key unique props nodes - -let em ?(key="") ?(unique="") props nodes = fullnode "" "em" key unique props nodes - -let strong ?(key="") ?(unique="") props nodes = fullnode "" "strong" key unique props nodes - -let i ?(key="") ?(unique="") props nodes = fullnode "" "i" key unique props nodes - -let b ?(key="") ?(unique="") props nodes = fullnode "" "b" key unique props nodes - -let u ?(key="") ?(unique="") props nodes = fullnode "" "u" key unique props nodes - -let sub ?(key="") ?(unique="") props nodes = fullnode "" "sub" key unique props nodes - -let sup ?(key="") ?(unique="") props nodes = fullnode "" "sup" key unique props nodes - -let br props = fullnode "" "br" "br" "br" props [] - -let br' ?(key="") ?(unique="") props nodes = fullnode "" "br" key unique props nodes - -(** {2 Lists} *) - -let ol ?(key="") ?(unique="") props nodes = fullnode "" "ol" key unique props nodes - -let ul ?(key="") ?(unique="") props nodes = fullnode "" "ul" key unique props nodes - -let li ?(key="") ?(unique="") props nodes = fullnode "" "li" key unique props nodes - -let dl ?(key="") ?(unique="") props nodes = fullnode "" "dl" key unique props nodes - -let dt ?(key="") ?(unique="") props nodes = fullnode "" "dt" key unique props nodes - -let dd ?(key="") ?(unique="") props nodes = fullnode "" "dd" key unique props nodes - -(** {2 Embedded Content} *) - -let img ?(key="") ?(unique="") props nodes = fullnode "" "img" key unique props nodes - -let iframe ?(key="") ?(unique="") props nodes = fullnode "" "iframe" key unique props nodes - -let canvas ?(key="") ?(unique="") props nodes = fullnode "" "canvas" key unique props nodes - -let math ?(key="") ?(unique="") props nodes = fullnode "" "math" key unique props nodes - -(** {2 Form and inputs} *) - -let form ?(key="") ?(unique="") props nodes = fullnode "" "form" key unique props nodes - -let input' ?(key="") ?(unique="") props nodes = fullnode "" "input" key unique props nodes - -let textarea ?(key="") ?(unique="") props nodes = fullnode "" "textarea" key unique props nodes - -let button ?(key="") ?(unique="") props nodes = fullnode "" "button" key unique props nodes - -let select ?(key="") ?(unique="") props nodes = fullnode "" "select" key unique props nodes - -let option' ?(key="") ?(unique="") props nodes = fullnode "" "option" key unique props nodes - -let optgroup ?(key="") ?(unique="") props nodes = fullnode "" "optgroup" key unique props nodes - -let label ?(key="") ?(unique="") props nodes = fullnode "" "label" key unique props nodes - -let fieldset ?(key="") ?(unique="") props nodes = fullnode "" "fieldset" key unique props nodes - -let legend ?(key="") ?(unique="") props nodes = fullnode "" "legend" key unique props nodes - -(** {2 Sections} *) - -let section ?(key="") ?(unique="") props nodes = fullnode "" "section" key unique props nodes - -let nav ?(key="") ?(unique="") props nodes = fullnode "" "nav" key unique props nodes - -let article ?(key="") ?(unique="") props nodes = fullnode "" "article" key unique props nodes - -let aside ?(key="") ?(unique="") props nodes = fullnode "" "aside" key unique props nodes - -let header ?(key="") ?(unique="") props nodes = fullnode "" "header" key unique props nodes - -let footer ?(key="") ?(unique="") props nodes = fullnode "" "footer" key unique props nodes - -let address ?(key="") ?(unique="") props nodes = fullnode "" "address" key unique props nodes - -let main ?(key="") ?(unique="") props nodes = fullnode "" "main" key unique props nodes - -let body ?(key="") ?(unique="") props nodes = fullnode "" "body" key unique props nodes - -(** {2 Figures} *) - -let figure ?(key="") ?(unique="") props nodes = fullnode "" "figure" key unique props nodes - -let figcaption ?(key="") ?(unique="") props nodes = fullnode "" "figcaption" key unique props nodes - -(** {2 Tables} *) - -let table ?(key="") ?(unique="") props nodes = fullnode "" "table" key unique props nodes - -let caption ?(key="") ?(unique="") props nodes = fullnode "" "caption" key unique props nodes - -let colgroup ?(key="") ?(unique="") props nodes = fullnode "" "colgroup" key unique props nodes - -let col ?(key="") ?(unique="") props nodes = fullnode "" "col" key unique props nodes - -let tbody ?(key="") ?(unique="") props nodes = fullnode "" "tbody" key unique props nodes - -let thead ?(key="") ?(unique="") props nodes = fullnode "" "thead" key unique props nodes - -let tfoot ?(key="") ?(unique="") props nodes = fullnode "" "tfoot" key unique props nodes - -let tr ?(key="") ?(unique="") props nodes = fullnode "" "tr" key unique props nodes - -let th ?(key="") ?(unique="") props nodes = fullnode "" "th" key unique props nodes - -let td ?(key="") ?(unique="") props nodes = fullnode "" "td" key unique props nodes - -(** {2 Less common inputs} *) - -let datalist ?(key="") ?(unique="") props nodes = fullnode "" "datalist" key unique props nodes - -let keygen ?(key="") ?(unique="") props nodes = fullnode "" "keygen" key unique props nodes - -let output ?(key="") ?(unique="") props nodes = fullnode "" "output" key unique props nodes - -let progress ?(key="") ?(unique="") props nodes = fullnode "" "progress" key unique props nodes - -let meter ?(key="") ?(unique="") props nodes = fullnode "" "meter" key unique props nodes - -(** {2 Audio and Video} *) - -let audio ?(key="") ?(unique="") props nodes = fullnode "" "audio" key unique props nodes - -let video ?(key="") ?(unique="") props nodes = fullnode "" "video" key unique props nodes - -let source ?(key="") ?(unique="") props nodes = fullnode "" "source" key unique props nodes - -let track ?(key="") ?(unique="") props nodes = fullnode "" "track" key unique props nodes - -(** {2 Embedded objects} *) - -let embed ?(key="") ?(unique="") props nodes = fullnode "" "embed" key unique props nodes - -let object' ?(key="") ?(unique="") props nodes = fullnode "" "object" key unique props nodes - -let param ?(key="") ?(unique="") props nodes = fullnode "" "param" key unique props nodes - -(** {2 Text edits} *) - -let ins ?(key="") ?(unique="") props nodes = fullnode "" "ins" key unique props nodes - -let del ?(key="") ?(unique="") props nodes = fullnode "" "del" key unique props nodes - -(** {2 Semantic text} *) - -let small ?(key="") ?(unique="") props nodes = fullnode "" "small" key unique props nodes - -let cite ?(key="") ?(unique="") props nodes = fullnode "" "cite" key unique props nodes - -let dfn ?(key="") ?(unique="") props nodes = fullnode "" "dfn" key unique props nodes - -let abbr ?(key="") ?(unique="") props nodes = fullnode "" "abbr" key unique props nodes - -let time ?(key="") ?(unique="") props nodes = fullnode "" "time" key unique props nodes - -let var' ?(key="") ?(unique="") props nodes = fullnode "" "var" key unique props nodes - -let samp ?(key="") ?(unique="") props nodes = fullnode "" "samp" key unique props nodes - -let kbd ?(key="") ?(unique="") props nodes = fullnode "" "kbd" key unique props nodes - -let s ?(key="") ?(unique="") props nodes = fullnode "" "s" key unique props nodes - -let q ?(key="") ?(unique="") props nodes = fullnode "" "q" key unique props nodes - -(** {2 Less common text tags} *) - -let mark ?(key="") ?(unique="") props nodes = fullnode "" "mark" key unique props nodes - -let ruby ?(key="") ?(unique="") props nodes = fullnode "" "ruby" key unique props nodes - -let rt ?(key="") ?(unique="") props nodes = fullnode "" "rt" key unique props nodes - -let rp ?(key="") ?(unique="") props nodes = fullnode "" "rp" key unique props nodes - -let bdi ?(key="") ?(unique="") props nodes = fullnode "" "bdi" key unique props nodes - -let bdo ?(key="") ?(unique="") props nodes = fullnode "" "bdo" key unique props nodes - -let wbr ?(key="") ?(unique="") props nodes = fullnode "" "wbr" key unique props nodes - -(** {2 Interactive elements} *) - -let details ?(key="") ?(unique="") props nodes = fullnode "" "details" key unique props nodes - -let summary ?(key="") ?(unique="") props nodes = fullnode "" "summary" key unique props nodes - -let menuitem ?(key="") ?(unique="") props nodes = fullnode "" "menuitem" key unique props nodes - -let menu ?(key="") ?(unique="") props nodes = fullnode "" "menu" key unique props nodes - -(** {2 Header elements} *) - -let meta ?(key="") ?(unique="") props = fullnode "" "meta" key unique props [] - -let style ?(key="") ?(unique="") props content = fullnode "" "style" key unique props [text content] - -let title ?(key="") ?(unique="") props content = fullnode "" "title" key unique props [text content] - -let link ?(key="") ?(unique="") props = fullnode "" "link" key unique props [] - - -(** Helper functions for HTML attributes. They are organized roughly by category. *) -module Attributes = struct - - (** {1 Primitives} *) - - let noProp = Vdom.noProp - - let style key value = Vdom.style key value - - let styles s = Vdom.styles s - - (** {1 Super common attributes} *) - - let class' name = prop "className" name - - let classList classes = - classes - |> List.filter (fun (_fst, snd) -> snd) - |> List.map (fun (fst, _snd) -> fst) - |> String.concat " " - |> class' - - let id str = prop "id" str - - let title str = attribute "" "title" str - - let hidden b = if b then prop "hidden" "hidden" else noProp - - (** {1 Inputs} *) - - let type' typ = prop "type" typ - - let value str = prop "value" str - - let defaultValue str = prop "defaultValue" str - - let checked b = if b then prop "checked" "checked" else noProp - - let placeholder str = prop "placeholder" str - - let selected b = if b then attribute "" "selected" "true" else noProp - - (** {1 Input helpers} *) - - let accept c = attribute "" "accept" c - - let acceptCharset c = attribute "" "accept-charset" c - - let action a = prop "action" a - - let autocomplete b = prop "autocomplete" (if b then "on" else "off") - - let autofocus b = if b then prop "autofocus" "autofocus" else noProp - - let disabled b = if b then attribute "" "disabled" "true" else noProp - - let enctype encoding = attribute "" "enctype" encoding - - let formaction url = attribute "" "formaction" url - - let list value = attribute "" "list" value - - let minlength n = attribute "" "minlength" (string_of_int n) - - let maxlength n = attribute "" "maxlength" (string_of_int n) - - let method' m = prop "method" m - - let multiple b = if b then prop "multiple" "multiple" else noProp - - let name str = prop "name" str - - let novalidate b = if b then prop "novalidate" "novalidate" else noProp - - let pattern p = prop "pattern" p - - let readonly b = if b then attribute "" "readonly" "readonly" else noProp - - let required b = if b then attribute "" "required" "required" else noProp - - let size n = attribute "" "size" (string_of_int n) - - let for' str = prop "htmlFor" str - - let form value = attribute "" "form" value - - (** {1 Input ranges} *) - - let max value = attribute "" "max" value - - let min value = attribute "" "min" value - - let step value = attribute "" "step" value - - (** {1 Textarea} *) - - let cols n = attribute "" "cols" (string_of_int n) - - let rows n = attribute "" "rows" (string_of_int n) - - let wrap value = prop "wrap" value - - (** {1 Links and areas} *) - - (* `href` is actually an attribute, not a property, but need it here for Elm compat... *) - let href str = attribute "" "href" str - - let target t = prop "target" t - - let download b = if b then prop "download" "" else noProp - - let downloadAs name = prop "download" name - - let hreflang code = prop "hreflang" code - - let media value = attribute "" "media" value - - let ping url = prop "ping" url - - let rel value = attribute "" "rel" value - - (** {1 Maps} *) - - let ismap b = if b then prop "ismap" "ismap" else noProp - - let usemap name = prop "usemap" name - - let shape value = prop "shape" value - - let coords value = prop "coords" value - - (** {1 Embedded content} *) - - (* `src` is actually an attribute, not a property, but need it here for Elm compat... *) - let src str = attribute "" "src" str - - let height n = attribute "" "height" (string_of_int n) - - let width n = attribute "" "width" (string_of_int n) - - let alt value = prop "alt" value - - (** {1 Audio and Video} *) - - let autoplay b = if b then prop "autoplay" "autoplay" else noProp - - let controls b = if b then prop "controls" "controls" else noProp - - let loop b = if b then prop "loop" "loop" else noProp - - let preload value = prop "preload" value - - let poster url = prop "poster" url - - let default b = if b then prop "default" "default" else noProp - - let kind value = prop "kind" value - - let srclang code = prop "srclang" code - - (** {1 IFrames} *) - - let sandbox value = prop "sandbox" value - - let seamless b = if b then prop "seamless" "seamless" else noProp - - let srcdoc value = prop "srcdoc" value - - (** {1 Ordered lists} *) - - let reversed b = if b then prop "reversed" "reversed" else noProp - - let start n = prop "start" (string_of_int n) - - (** {1 Tables} *) - - let colspan n = attribute "" "colspan" (string_of_int n) - - let rowspan n = attribute "" "rowspan" (string_of_int n) - - let headers value = prop "headers" value - - let scope value = prop "scope" value - - let align value = prop "align" value - - (** {1 Header stuff} *) - - let async b = if b then prop "async" "async" else noProp - - let charset value = attribute "" "charset" value - - let content value = attribute "" "content" value - - let defer b = if b then prop "defer" "defer" else noProp - - let httpEquiv value = prop "http-equiv" value - - let language value = prop "language" value - - let scoped value = prop "scoped" value - - (** {1 Less common global attributes} *) - - let accesskey ch = prop "accesskey" (String.make 1 ch) - - let contenteditable b = if b then prop "contenteditable" "contenteditable" else noProp - - let contextmenu id = attribute "" "contextmenu" id - - let dir value = prop "dir" value - - let draggable value = attribute "" "draggable" value - - let dropzone value = prop "dropzone" value - - let itemprop value = attribute "" "itemprop" value - - let lang code = prop "lang" code - - let spellcheck b = if b then prop "spellcheck" "spellcheck" else noProp - - let tabindex n = attribute "" "tabindex" (string_of_int n) - - (** {1 Key generation} *) - - let challenge value = attribute "" "challenge" value - - let keytype value = prop "keytype" value - - (** {1 Miscellaneous} *) - - let cite url = prop "cite" url - - let datetime value = attribute "" "datetime" value - - let pubdate value = attribute "" "pubdate" value - - let manifest value = attribute "" "manifest" value - -end - - -module Events = struct - - (** {1 Primitives} *) - - let onCB eventName key cb = onCB eventName key cb - - let onMsg eventName msg = onMsg eventName msg - - let on = Tea_html.on - - let onWithOptions = Tea_html.onWithOptions - - let defaultOptions = Tea_html.defaultOptions - - let targetValue = Tea_html.targetValue - - let targetChecked = Tea_html.targetChecked - - let keyCode = Tea_html.keyCode - - let preventDefaultOn ?(key="") eventName decoder = onWithOptions ~key eventName { defaultOptions with preventDefault = true } decoder - - (** {1 Mouse helpers} *) - - let onClick msg = onMsg "click" msg - - let onDoubleClick msg = onMsg "dblclick" msg - - let onMouseDown msg = onMsg "mousedown" msg - - let onMouseUp msg = onMsg "mouseup" msg - - let onMouseEnter msg = onMsg "mouseenter" msg - - let onMouseLeave msg = onMsg "mouseleave" msg - - let onMouseOver msg = onMsg "mouseover" msg - - let onMouseOut msg = onMsg "mouseout" msg - - (** {1 Form helpers} *) - - let onInputOpt ?(key="") msg = - onCB "input" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##value with - | None -> None - | Some value -> msg value - ) - - let onInput ?(key="") msg = onInputOpt ~key:key (fun ev -> Some (msg ev)) - - let onCheckOpt ?(key="") msg = - onCB "change" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##checked with - | None -> None - | Some value -> msg value - ) - - let onCheck ?(key="") msg = onCheckOpt ~key:key (fun ev -> Some (msg ev)) - - let onChangeOpt ?(key="") msg = - onCB "change" key - (fun ev -> - match Js.Undefined.toOption ev##target with - | None -> None - | Some target -> match Js.Undefined.toOption target##value with - | None -> None - | Some value -> msg value - ) - - let onChange ?(key="") msg = onChangeOpt ~key:key (fun ev -> Some (msg ev)) - - let onSubmit msg = preventDefaultOn "submit" (Tea_json.Decoder.succeed msg) - - (** {1 Focus helpers} *) - - let onBlur msg = onMsg "blur" msg - - let onFocus msg = onMsg "focus" msg - -end diff --git a/src-ocaml/tea_html_cmds.ml b/src-ocaml/tea_html_cmds.ml deleted file mode 100644 index 8758aea..0000000 --- a/src-ocaml/tea_html_cmds.ml +++ /dev/null @@ -1,16 +0,0 @@ -let focus id = - Tea_cmd.call - (fun _enqueue -> - let ecb _ = - match Js.Nullable.toOption (Web.Document.getElementById id) with - | None -> - Js.log ("Attempted to focus a non-existant element of: ", id) - | Some elem -> Web.Node.focus elem - in - (* One to get out of the current render frame*) - let cb _ = ignore (Web.Window.requestAnimationFrame ecb) in - (* And another to properly focus *) - ignore (Web.Window.requestAnimationFrame cb); - ()) - - diff --git a/src-ocaml/tea_http.ml b/src-ocaml/tea_http.ml deleted file mode 100644 index c02b785..0000000 --- a/src-ocaml/tea_http.ml +++ /dev/null @@ -1,282 +0,0 @@ - - -type response_status = - { code : int - ; message : string - } - -type requestBody = Web.XMLHttpRequest.body -type bodyType = Web.XMLHttpRequest.responseType -type responseBody = Web.XMLHttpRequest.responseBody - -type response = - { url : string - ; status : response_status - ; headers : string Map.Make(String).t - ; body : responseBody - } - -type 'parsedata error = - | BadUrl of string - | Timeout - | NetworkError - | Aborted - | BadStatus of response - | BadPayload of 'parsedata * response - -let string_of_error = function - | BadUrl url -> "Bad Url: " ^ url - | Timeout -> "Timeout" - | NetworkError -> "Unknown network error" - | Aborted -> "Request aborted" - | BadStatus resp -> "Bad Status: " ^ resp.url - | BadPayload (_customData, resp) -> "Bad Payload: " ^ resp.url - -type header = Header of string * string - -type 'res expect = - Expect of bodyType * (response -> ('res, string) Tea_result.t) - -type 'msg requestEvents = - { onreadystatechange : ('msg Vdom.applicationCallbacks ref -> (Web.XMLHttpRequest.event_readystatechange -> unit)) option - ; onprogress : ('msg Vdom.applicationCallbacks ref -> (Web.XMLHttpRequest.event_progress -> unit)) option - } - -let emptyRequestEvents = - { onreadystatechange = None - ; onprogress = None - } - -type 'res rawRequest = - { method' : string - ; headers : header list - ; url : string - ; body : requestBody - ; expect : 'res expect - ; timeout : Tea_time.t option - ; withCredentials : bool - } - -type ('msg, 'res) request = - Request of 'res rawRequest * 'msg requestEvents option - -let expectStringResponse func = - let open Web.XMLHttpRequest in - Expect - ( TextResponseType - , ( fun { body; _ } -> - match body with - | TextResponse s -> func s - | _ -> Tea_result.Error "Non-text response returned" - ) - ) - - -let expectString = - expectStringResponse (fun resString -> Tea_result.Ok resString) - - -let request rawRequest = - Request (rawRequest, None) - - -let getString url = - request - { method' = "GET" - ; headers = [] - ; url = url - ; body = Web.XMLHttpRequest.EmptyBody - ; expect = expectString - ; timeout = None - ; withCredentials = false - } - -let toTask (Request (request, _maybeEvents)) = - let module StringMap = Map.Make(String) in - let {method'; headers; url; body; expect; timeout; withCredentials } = request in - let (Expect (typ, responseToResult)) = expect in - Tea_task.nativeBinding (fun cb -> - let enqRes result = fun _ev -> cb result in - let enqResError result = enqRes (Tea_result.Error result) in - let enqResOk result = enqRes (Tea_result.Ok result) in - let xhr = Web.XMLHttpRequest.create () in - let setEvent ev cb = ev cb xhr in - let () = setEvent Web.XMLHttpRequest.set_onerror (enqResError NetworkError) in - let () = setEvent Web.XMLHttpRequest.set_ontimeout (enqResError Timeout) in - let () = setEvent Web.XMLHttpRequest.set_onabort (enqResError Aborted) in - let () = setEvent Web.XMLHttpRequest.set_onload - ( fun _ev -> - let open Web.XMLHttpRequest in - let headers = - match getAllResponseHeadersAsDict xhr with - | Tea_result.Error _e -> StringMap.empty - | Tea_result.Ok headers -> headers in - let response = - { status = { code = get_status xhr; message = get_statusText xhr } - ; headers = headers - ; url = get_responseURL xhr - ; body = get_response xhr - } in - if response.status.code < 200 || 300 <= response.status.code - then enqResError (BadStatus response) () - else match responseToResult response with - | Tea_result.Error error -> enqResError (BadPayload (error, response)) () - | Tea_result.Ok result -> enqResOk result () - ) in - let () = try Web.XMLHttpRequest.open_ method' url xhr - with _ -> enqResError (BadUrl url) () in - let () = - let setHeader (Header (k, v)) = Web.XMLHttpRequest.setRequestHeader k v xhr in - let () = List.iter setHeader headers in - let () = Web.XMLHttpRequest.set_responseType typ xhr in - let () = - match timeout with - | None -> () - | Some t -> Web.XMLHttpRequest.set_timeout t xhr in - let () = Web.XMLHttpRequest.set_withCredentials withCredentials xhr in - () in - let () = Web.XMLHttpRequest.send body xhr in - () - ) - -let send resultToMessage (Request (request, maybeEvents)) = - let module StringMap = Map.Make(String) in - let {method'; headers; url; body; expect; timeout; withCredentials } = request in - let (Expect (typ, responseToResult)) = expect in - Tea_cmd.call (fun callbacks -> - let enqRes result = - fun _ev -> - let open Vdom in - !callbacks.enqueue (resultToMessage result) in - let enqResError result = enqRes (Tea_result.Error result) in - let enqResOk result = enqRes (Tea_result.Ok result) in - let xhr = Web.XMLHttpRequest.create () in - let setEvent ev cb = ev cb xhr in - let () = match maybeEvents with - | None -> () - | Some { onprogress; onreadystatechange } -> - let open Web.XMLHttpRequest in - let mayCB thenDo = function - | None -> () - | Some v -> thenDo (v callbacks) in - let () = mayCB (setEvent set_onreadystatechange) onreadystatechange in - let () = mayCB (setEvent set_onprogress) onprogress in - () in - let () = setEvent Web.XMLHttpRequest.set_onerror (enqResError NetworkError) in - let () = setEvent Web.XMLHttpRequest.set_ontimeout (enqResError Timeout) in - let () = setEvent Web.XMLHttpRequest.set_onabort (enqResError Aborted) in - let () = setEvent Web.XMLHttpRequest.set_onload - ( fun _ev -> - let open Web.XMLHttpRequest in - let headers = - match getAllResponseHeadersAsDict xhr with - | Tea_result.Error _e -> StringMap.empty - | Tea_result.Ok headers -> headers in - let response = - { status = { code = get_status xhr; message = get_statusText xhr } - ; headers = headers - ; url = get_responseURL xhr - ; body = get_response xhr - } in - if response.status.code < 200 || 300 <= response.status.code - then enqResError (BadStatus response) () - else match responseToResult response with - | Tea_result.Error error -> enqResError (BadPayload (error, response)) () - | Tea_result.Ok result -> enqResOk result () - ) in - let () = try Web.XMLHttpRequest.open_ method' url xhr - with _ -> enqResError (BadUrl url) () in - let () = - let setHeader (Header (k, v)) = Web.XMLHttpRequest.setRequestHeader k v xhr in - let () = List.iter setHeader headers in - let () = Web.XMLHttpRequest.set_responseType typ xhr in - let () = - match timeout with - | None -> () - | Some t -> Web.XMLHttpRequest.set_timeout t xhr in - let () = Web.XMLHttpRequest.set_withCredentials withCredentials xhr in - () in - let () = Web.XMLHttpRequest.send body xhr in - () - ) - -external encodeURIComponent : string -> string = "encodeURIComponent" [@@bs.val] - -let encodeUri str = - encodeURIComponent str - -external decodeURIComponent : string -> string = "decodeURIComponent" [@@bs.val] - -let decodeUri str = - try Some (decodeURIComponent str) - with _ -> None - -module Progress = struct - - (* - type bytesProgressed = - { bytes : int - ; bytesExpected : int - } - - type ('data, 'parseFailData) t = - | NoProgress - (* SomeProgress (bytes, bytesExpected) *) - | SomeProgress of bytesProgressed - | FailProgress of 'parseFailData error - | DoneProgress of 'data - - type ('msg, 'parseFailData) trackedRequest = - { request : 'msg rawRequest - ; toProgress : bytesProgressed -> 'msg - ; toError : 'parseFailData error -> 'msg - } - *) - - type t = - { bytes : int - ; bytesExpected : int - } - - let emptyProgress = - { bytes = 0 - ; bytesExpected = 0 - } - - (* Yeah this does not follow the original API, but that original - API is... not extensible... Instead, we have generic event - listener support here so no need to constrain the API. - Might still want to make a subscription variant though... *) - let track toMessage (Request (request, events)) = - let onprogress = Some - ( fun callbacks ev -> - let open Vdom in - let lengthComputable = - let open Tea_json.Decoder in - let open Tea_result in - match decodeValue (field "lengthComputable" bool) ev with - | Error _e -> false - | Ok v -> v in - if lengthComputable then - let open Tea_json.Decoder in - let open Tea_result in - let decoder = - map2 (fun bytes bytesExpected -> {bytes; bytesExpected}) - (field "loaded" int) - (field "total" int) - in - match decodeValue decoder ev with - | Error _e -> () - | Ok t -> - !callbacks.enqueue (toMessage t) - ) in - let events = - match events with - | None -> emptyRequestEvents - | Some e -> e - in Request - (request - , Some { events with onprogress } - ) - -end diff --git a/src-ocaml/tea_json.ml b/src-ocaml/tea_json.ml deleted file mode 100644 index dff9233..0000000 --- a/src-ocaml/tea_json.ml +++ /dev/null @@ -1,553 +0,0 @@ - -module Decoder = struct - - type error = String.t - - module ObjectDict = Map.Make(String) - - type ('input, 'result) t = - Decoder of ('input -> ('result, error) Tea_result.t) - (* - | Parser : (Web.Json.t -> ('result, error) Tea_result.t) -> ('result, error) Tea_result.t t - *) - (* - | Value : (Web.Json.t, error) Tea_result.t t - | Succeed : 'result -> ('result, error) Tea_result.t t - | Fail : error -> (_, error) Tea_result.t t - | Null : 'result -> ('result, error) Tea_result.t t - | String : (string, error) Tea_result.t t - *) - - exception ParseFail of string - - - (* Primitive types *) - - let string = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONString s -> Tea_result.Ok s - | _ -> Tea_result.Error "Non-string value" - ) - - let int = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONNumber n -> - if n > (float_of_int min_int) && n < (float_of_int max_int) - then Tea_result.Ok (int_of_float n) - else Tea_result.Error "number out of int range" - | _ -> Tea_result.Error "Non-int value" - ) - - let float = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONNumber n -> Tea_result.Ok n - | _ -> Tea_result.Error "Non-float-value" - ) - - let bool = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONTrue -> Tea_result.Ok true - | JSONFalse -> Tea_result.Ok false - | _ -> Tea_result.Error "Non-boolean value" - ) - - let null v = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONNull -> Tea_result.Ok v - | _ -> Tea_result.Error "Non-null value" - ) - - (* Compound types *) - - let list (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONArray a -> - ( let parse v = - ( match decoder v with - | Tea_result.Ok r -> r - | Tea_result.Error e -> raise (ParseFail e) - ) in - try Tea_result.Ok (Array.to_list a |> List.map parse) - with ParseFail e -> Tea_result.Error ("list -> " ^ e) - ) - | _ -> Tea_result.Error "Non-list value" - ) - - let array (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONArray a -> - ( let parse v = - ( match decoder v with - | Tea_result.Ok r -> r - | Tea_result.Error e -> raise (ParseFail e) - ) in - try Tea_result.Ok (Array.map parse a) - with ParseFail e -> Tea_result.Error ("array -> " ^ e) - ) - | _ -> Tea_result.Error "Non-array value" - ) - - let keyValuePairs (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONObject o -> - ( let keys = Js.Dict.keys o in - let parse k l = - ( match Js.Dict.get o k with - | None -> raise (ParseFail ("Key is undefined: " ^ k)) - | Some v -> - match decoder v with - | Tea_result.Ok r -> (k, r) :: l - | Tea_result.Error e -> raise (ParseFail e) - ) in - try Tea_result.Ok (Array.fold_right parse keys []) - with ParseFail e -> Tea_result.Error ("Invalid keyValuePair parsing: " ^ e) - ) - | _ -> Tea_result.Error "Non-keyValuePair value" - ) - - let dict (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONObject o -> - ( let keys = Js.Dict.keys o in - let parse k d = - ( match Js.Dict.get o k with - | None -> raise (ParseFail ("Key is undefined: " ^ k)) - | Some v -> - match decoder v with - | Tea_result.Ok r -> ObjectDict.add k r d - | Tea_result.Error e -> raise (ParseFail e) - ) in - let emptyDict = ObjectDict.empty in - try Tea_result.Ok (Array.fold_right parse keys emptyDict) - with ParseFail e -> Tea_result.Error ("Invalid dict parsing: " ^ e) - ) - | _ -> Tea_result.Error "Non-dict value" - ) - - let field key (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONObject o -> - ( match Js.Dict.get o key with - | None -> Tea_result.Error ("Field Value is undefined: " ^ key) - | Some v -> - match decoder v with - | Ok _ as o -> o - | Error e -> Error ("field `" ^ key ^ "` -> " ^ e) - ) - | _ -> Tea_result.Error "Non-fieldable value" - ) - - let at fields dec = - List.fold_right field fields dec - - let index idx (Decoder decoder) = - Decoder - ( fun value -> - let open Web.Json in - match classify value with - | JSONArray a -> - if idx < 0 || idx > (Array.length a) - then Tea_result.Error ("Array index out of range: " ^ (string_of_int idx)) - else decoder a.(idx) - | _ -> Tea_result.Error "Non-array value" - ) - - let maybe (Decoder decoder) = - Decoder - ( fun value -> - match decoder value with - | Tea_result.Ok r -> Tea_result.Ok (Some r) - | Tea_result.Error _ -> Tea_result.Ok None - ) - - let oneOf decoders = - Decoder - ( fun value -> - let rec parse v = function - | [] -> Tea_result.Error "No one-of's matched" - | ((Decoder decoder) :: rest) -> - try - match decoder v with - | Tea_result.Ok _ as ok -> ok - | Tea_result.Error _ -> parse v rest - with _ -> parse v rest - in parse value decoders - ) - - let map mapper - (Decoder decoder1) = - Decoder - ( fun value -> - let open Tea_result in - match decoder1 value with - | Ok v1 -> Ok (mapper v1) - | Error e -> Error ("map " ^ e) - ) - - let map2 mapper - (Decoder decoder1) - (Decoder decoder2) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value - with - | Ok v1, - Ok v2 -> Ok (mapper v1 v2) - | e1, e2 -> - match Tea_result.error_of_first e1 e2 with - | None -> failwith "Impossible case" - | Some e -> Error ("map2 -> " ^ e) - ) - - let map3 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value - with - | Ok v1, - Ok v2, - Ok v3 -> Ok (mapper v1 v2 v3) - | e1, e2, e3 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map3 -> " ^ e) - ) - - let map4 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) - (Decoder decoder4) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value, - decoder4 value - with - | Ok v1, - Ok v2, - Ok v3, - Ok v4 -> Ok (mapper v1 v2 v3 v4) - | e1, e2, e3, e4 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - |> first e4 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map4 -> " ^ e) - ) - - let map5 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) - (Decoder decoder4) - (Decoder decoder5) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value, - decoder4 value, - decoder5 value - with - | Ok v1, - Ok v2, - Ok v3, - Ok v4, - Ok v5 -> Ok (mapper v1 v2 v3 v4 v5) - | e1, e2, e3, e4, e5 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - |> first e4 - |> first e5 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map5 -> " ^ e) - ) - - let map6 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) - (Decoder decoder4) - (Decoder decoder5) - (Decoder decoder6) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value, - decoder4 value, - decoder5 value, - decoder6 value - with - | Ok v1, - Ok v2, - Ok v3, - Ok v4, - Ok v5, - Ok v6 -> Ok (mapper v1 v2 v3 v4 v5 v6) - | e1, e2, e3, e4, e5, e6 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - |> first e4 - |> first e5 - |> first e6 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map6 -> " ^ e) - ) - - let map7 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) - (Decoder decoder4) - (Decoder decoder5) - (Decoder decoder6) - (Decoder decoder7) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value, - decoder4 value, - decoder5 value, - decoder6 value, - decoder7 value - with - | Ok v1, - Ok v2, - Ok v3, - Ok v4, - Ok v5, - Ok v6, - Ok v7 -> Ok (mapper v1 v2 v3 v4 v5 v6 v7) - | e1, e2, e3, e4, e5, e6, e7 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - |> first e4 - |> first e5 - |> first e6 - |> first e7 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map7 -> " ^ e) - ) - - let map8 mapper - (Decoder decoder1) - (Decoder decoder2) - (Decoder decoder3) - (Decoder decoder4) - (Decoder decoder5) - (Decoder decoder6) - (Decoder decoder7) - (Decoder decoder8) = - Decoder - ( fun value -> - let open Tea_result in - match - decoder1 value, - decoder2 value, - decoder3 value, - decoder4 value, - decoder5 value, - decoder6 value, - decoder7 value, - decoder8 value - with - | Ok v1, - Ok v2, - Ok v3, - Ok v4, - Ok v5, - Ok v6, - Ok v7, - Ok v8 -> Ok (mapper v1 v2 v3 v4 v5 v6 v7 v8) - | e1, e2, e3, e4, e5, e6, e7, e8 -> - let open! Tea_result in - match - e1 - |> first e2 - |> first e3 - |> first e4 - |> first e5 - |> first e6 - |> first e7 - |> first e8 - with - | Ok _ -> failwith "Impossible case" - | Error e -> Error ("map8 -> " ^ e) - ) - - - (* Fancy Primitives *) - - let succeed v = - Decoder - ( fun _value -> - Tea_result.Ok v - ) - - let fail e = - Decoder - ( fun _value -> - Tea_result.Error e - ) - - let value = - Decoder - ( fun value -> - Tea_result.Ok value - ) - - let andThen func (Decoder decoder) = - Decoder - ( fun value -> - match decoder value with - | Tea_result.Ok r -> - let (Decoder andThenDecoder) = func r in - andThenDecoder value - | Tea_result.Error _ as err -> err - ) - - let lazy_ func = - andThen func (succeed ()) - - let nullable decoder = - oneOf - [ null None - ; map (fun v -> Some v) decoder - ] - - - (* Decoders *) - - (* TODO: Constrain this value type more *) - let decodeValue (Decoder decoder) value = - try decoder value - with - | ParseFail e -> Tea_result.Error e - | _ -> Tea_result.Error "Unknown JSON parsing error" - - let decodeEvent (Decoder decoder) (value : Web_node.event) = - try decoder (Obj.magic value) - with - | ParseFail e -> Tea_result.Error e - | _ -> Tea_result.Error "Unknown JSON parsing error" - - let decodeString decoder string = - try - let value = Web.Json.parseExn string in - decodeValue decoder value - with - (* | JsException e -> Tea_result.Error ("Given an invalid JSON: " ^ e) *) - | _ -> Tea_result.Error "Invalid JSON string" - -end - - -module Encoder = struct - open Web - - type t = Json.t - - let encode indentLevel value = - Web.Json.string_of_json ~indent:indentLevel (Js.Undefined.return value) - - - (* Encoders *) - - let string (v : string) = Json.of_type Json.String v - - let int (v : int) = Json.of_type Json.Number (float_of_int v) - - let float (v : float) = Json.of_type Json.Number v - - let bool (v : bool) = Json.of_type Json.Boolean v - - let null = Json.of_type Json.Null Json.null - - let object_ v = - let aux o (k, v) = - let () = Js.Dict.set o k v in - o in - let o = List.fold_left aux (Js.Dict.empty ()) v in - Json.of_type Json.Object o - - let array (v : 't array) = Json.of_type Json.Array v - - let list (v : 't list) = Json.of_type Json.Array (Array.of_list v) - -end - - -type t = Web.Json.t diff --git a/src-ocaml/tea_mouse.ml b/src-ocaml/tea_mouse.ml deleted file mode 100644 index 9bdc5f3..0000000 --- a/src-ocaml/tea_mouse.ml +++ /dev/null @@ -1,43 +0,0 @@ - -type position = { - x : int; - y : int; -} - - -let position = - let open Tea_json.Decoder in - map2 (fun x y -> {x; y}) - (field "pageX" int) - (field "pageY" int) - - -let registerGlobal name key tagger = - let open Vdom in - let enableCall callbacks_base = - let callbacks = ref callbacks_base in - let fn = fun ev -> - let open Tea_json.Decoder in - let open Tea_result in - match decodeEvent position ev with - | Error _ -> None - | Ok pos -> Some (tagger pos) in - let handler = EventHandlerCallback (key, fn) in - let elem = Web_node.document_node in - let cache = eventHandler_Register callbacks elem name handler in - fun () -> - let _ = eventHandler_Unregister elem name cache in - () - in Tea_sub.registration key enableCall - -let clicks ?(key="") tagger = - registerGlobal "click" key tagger - -let moves ?(key="") tagger = - registerGlobal "mousemove" key tagger - -let downs ?(key="") tagger = - registerGlobal "mousedown" key tagger - -let ups ?(key="") tagger = - registerGlobal "mouseup" key tagger diff --git a/src-ocaml/tea_navigation.ml b/src-ocaml/tea_navigation.ml deleted file mode 100644 index 15021e3..0000000 --- a/src-ocaml/tea_navigation.ml +++ /dev/null @@ -1,95 +0,0 @@ - -type ('flags, 'model, 'msg) navigationProgram = - { init : 'flags -> Web.Location.location -> 'model * 'msg Tea_cmd.t - ; update : 'model -> 'msg -> 'model * 'msg Tea_cmd.t - ; view : 'model -> 'msg Vdom.t - ; subscriptions : 'model -> 'msg Tea_sub.t - ; shutdown : 'model -> 'msg Tea_cmd.t - } - - -let getLocation () = - Web.Location.asRecord (Web.Document.location ()) - - - -let notifier : (Web.Location.location -> unit) option ref = ref None - -let notifyUrlChange () = - match !notifier with - | None -> () - | Some cb -> - let location = getLocation () in - let () = cb location in - () - - -let subscribe tagger = - let open Vdom in - let enableCall callbacks = - let notifyHandler location = - callbacks.enqueue (tagger location) in - let () = notifier := Some notifyHandler in - let handler : Web.Node.event_cb = fun [@bs] _event -> - notifyUrlChange () in - let () = Web.Window.addEventListener "popstate" handler false in - fun () -> Web.Window.removeEventListener "popstate" handler false - in Tea_sub.registration "navigation" enableCall - - - -let replaceState url = - let _ = Web.Window.History.replaceState Web.Window.window (Js.Json.parseExn "{}") "" url in - () - - -let pushState url = - let _ = Web.Window.History.pushState Web.Window.window (Js.Json.parseExn "{}") "" url in - () - - -let modifyUrl url = - Tea_cmd.call (fun _enqueue -> - let () = replaceState url in - let () = notifyUrlChange () in - () - ) - - -let newUrl url = - Tea_cmd.call (fun _enqueue -> - let () = pushState url in - let () = notifyUrlChange () in - () - ) - - -let go step = - Tea_cmd.call (fun _enqueue -> - let _ = Web.Window.(History.go window) step in - let () = notifyUrlChange () in - () - ) - -let back step = go (-step) -let forward step = go step - - -let navigationProgram locationToMessage stuff = - let init flag = - stuff.init flag (getLocation ()) in - - let subscriptions model = - Tea_sub.batch - [ subscribe locationToMessage - ; stuff.subscriptions model - ] in - - let open! Tea_app in - program - { init = init - ; update = stuff.update - ; view = stuff.view - ; subscriptions = subscriptions - ; shutdown = stuff.shutdown - } diff --git a/src-ocaml/tea_program.ml b/src-ocaml/tea_program.ml deleted file mode 100644 index 304d6de..0000000 --- a/src-ocaml/tea_program.ml +++ /dev/null @@ -1,52 +0,0 @@ - - -type 'msg processMsg = - | PushMsg of 'msg - | Kill - -let spawn initState update shutdown = - let state = ref (Some initState) in - let onMessage procMsg = - match !state with - | None -> () - | Some model -> - ( match procMsg with - | PushMsg msg -> - let () = state := (update model msg) in - () - | Kill -> - let () = shutdown model in - let () = state := None in - () - ) in - onMessage - - - - - -(* let testing0 = - let s = spawn 42 (fun model -> let () = Js.log model in function - | `Inc -> Some (model + 1) - | `Dec -> Some (model - 1) - ) (fun _ -> ()) in - let () = s (PushMsg `Dec) in - let () = s (PushMsg `Dec) in - let () = s Kill in - let () = s (PushMsg `Dec) in - () *) - - - -module type Process = sig - (* This module should be `import`ed into a module that will become a persistent process. - That process should have a handleMsg callback to handle its own message types. - It should call itself - *) - - type msg - - val handleMsg : msg -> unit -end - -let testing1 = 42 diff --git a/src-ocaml/tea_promise.ml b/src-ocaml/tea_promise.ml deleted file mode 100644 index c75a87b..0000000 --- a/src-ocaml/tea_promise.ml +++ /dev/null @@ -1,38 +0,0 @@ - - -let cmd promise tagger = - let open Vdom in - Tea_cmd.call (function callbacks -> - let _ = promise - |> Js.Promise.then_ (function res -> - match tagger res with - | Some msg -> - let () = !callbacks.enqueue msg in - Js.Promise.resolve () - | None -> Js.Promise.resolve () - ) - in - () - ) - - -let result promise msg = - let open Vdom in - Tea_cmd.call (function callbacks -> - let enq result = - !callbacks.enqueue (msg result) - in - let _ = promise - |> Js.Promise.then_ (function res -> - let resolve = enq (Tea_result.Ok res) in - Js.Promise.resolve resolve - ) - |> Js.Promise.catch (function err -> - let err_to_string err = - {j|$err|j} in - let reject = enq (Tea_result.Error (err_to_string err)) in - Js.Promise.resolve reject - ) - in - () - ) diff --git a/src-ocaml/tea_random.ml b/src-ocaml/tea_random.ml deleted file mode 100644 index 13795f1..0000000 --- a/src-ocaml/tea_random.ml +++ /dev/null @@ -1,115 +0,0 @@ - - - -let () = Random.self_init () - - -let minInt = min_int - -let maxInt = max_int - -let minFloat = min_float - -let maxFloat = max_float - - -type 'typ t = - | Generator of (Random.State.t -> 'typ) - - -let bool = - Generator (fun state -> Random.State.bool state) - - -let int min max = - let (min, max) = if min < max then (min, max) else (max, min) in - Generator (fun state -> min + Random.State.int state (max - min + 1)) - - -let float min max = - Generator (fun state -> min +. Random.State.float state (max -. min)) - - -let list count (Generator genCmd) = - let rec buildList state i acc = if i > 0 then buildList state (i - 1) (genCmd state :: acc) else acc in - Generator (fun state -> buildList state count []) - - -let map func (Generator genCmd) = - Generator - (fun state -> - func (genCmd state) - ) - -let map2 func (Generator genCmd1) (Generator genCmd2) = - Generator - (fun state -> - let res1 = genCmd1 state in - let res2 = genCmd2 state in - func res1 res2 - ) - -let map3 func (Generator genCmd1) (Generator genCmd2) (Generator genCmd3) = - Generator - (fun state -> - let res1 = genCmd1 state in - let res2 = genCmd2 state in - let res3 = genCmd3 state in - func res1 res2 res3 - ) - -let map4 func (Generator genCmd1) (Generator genCmd2) (Generator genCmd3) (Generator genCmd4) = - Generator - (fun state -> - let res1 = genCmd1 state in - let res2 = genCmd2 state in - let res3 = genCmd3 state in - let res4 = genCmd4 state in - func res1 res2 res3 res4 - ) - -let map5 func (Generator genCmd1) (Generator genCmd2) (Generator genCmd3) (Generator genCmd4) (Generator genCmd5) = - Generator - (fun state -> - let res1 = genCmd1 state in - let res2 = genCmd2 state in - let res3 = genCmd3 state in - let res4 = genCmd4 state in - let res5 = genCmd5 state in - func res1 res2 res3 res4 res5 - ) - -let andThen func (Generator genCmd) = - Generator - (fun state -> - let res = genCmd state in - let (Generator userGen) = func res in - userGen state - ) - -let pair gen1 gen2 = - map2 (fun a b -> a, b) gen1 gen2 - - - -let generate tagger (Generator genCmd) = - Tea_cmd.call (fun callbacks -> - let state = Random.get_state () in - let genValue = genCmd state in - let () = Random.set_state state in - let open Vdom in - !callbacks.enqueue (tagger genValue) - ) - - -(* Generate Values Manually *) - -type seed = - | Seed of Random.State.t - -let step (Generator genCmd) (Seed state) = - let newState = Random.State.copy state in - genCmd newState, Seed newState - -let initialSeed seed = - Seed (Random.State.make [| seed |]) diff --git a/src-ocaml/tea_result.ml b/src-ocaml/tea_result.ml deleted file mode 100644 index c01c856..0000000 --- a/src-ocaml/tea_result.ml +++ /dev/null @@ -1,60 +0,0 @@ - - -(* TODO: Remove this when Bucklescript is updated to OCaml 4.03 as it includes result *) -type ('a, 'b) t (* result *) = ('a,'b) result = - | Ok of 'a - | Error of 'b - -let result_to_option = function - | Ok a -> Some a - | Error _ -> None - -let option_of_result = function - | Ok a -> Some a - | Error _ -> None - -let ok = function - | Ok a -> Some a - | Error _ -> None - -let error = function - | Ok _ -> None - | Error e -> Some e - -let rec last_of = function - | [] -> failwith "`Tea.Result.do` must never be passed the empty list" - | [last] -> last - | next :: tl -> - match next with - | Error _ as e -> e - | Ok _ -> last_of tl - -let rec accumulate = function - | [] -> Ok [] - | [last] -> - begin match last with - | Error _ as e -> e - | Ok o -> Ok [o] - end - | next :: tl -> - match next with - | Error _ as e -> e - | Ok o -> - match accumulate tl with - | Error _ as e -> e - | Ok os -> Ok (o :: os) - -let first fst = function - | Error _ as e -> e - | Ok _ -> fst - -let rec error_of_any = function - | [] -> None - | hd :: tl -> - match hd with - | Error e -> Some e - | Ok _ -> error_of_any tl - -let error_of_first fst = function - | Error e -> Some e - | Ok _ -> error fst diff --git a/src-ocaml/tea_sub.ml b/src-ocaml/tea_sub.ml deleted file mode 100644 index 1efa327..0000000 --- a/src-ocaml/tea_sub.ml +++ /dev/null @@ -1,91 +0,0 @@ -type 'msg t = - | NoSub: _ t - | Batch: 'msg t list -> 'msg t - | Registration: string * - ('msg Vdom.applicationCallbacks ref -> unit -> unit) * (unit -> unit) - option ref -> 'msg t - | Mapper: - ('msg Vdom.applicationCallbacks ref -> 'msgB Vdom.applicationCallbacks ref) - * 'msgB t -> 'msg t -type 'msg applicationCallbacks = 'msg Vdom.applicationCallbacks -let none = NoSub -let batch subs = ((Batch (subs))[@explicit_arity ]) -let registration key enableCall = - ((Registration - (key, (fun callbacks -> enableCall (!callbacks)), (ref None))) - [@implicit_arity ]) -let map msgMapper sub = - let func callbacks = Vdom.wrapCallbacks msgMapper callbacks in - ((Mapper (func, sub))[@implicit_arity ]) -let mapFunc func sub = ((Mapper (func, sub))[@implicit_arity ]) -let rec run : type msgOld msgNew. - msgOld Vdom.applicationCallbacks ref -> - msgNew Vdom.applicationCallbacks ref -> msgOld t -> msgNew t -> msgNew t - = - fun oldCallbacks -> - fun newCallbacks -> - fun oldSub -> - fun newSub -> - let rec enable : type msg. - msg Vdom.applicationCallbacks ref -> msg t -> unit = - fun callbacks -> - function - | NoSub -> () - | ((Batch ([]))[@explicit_arity ]) -> () - | ((Batch (subs))[@explicit_arity ]) -> - List.iter (enable callbacks) subs - | ((Mapper (mapper, sub))[@implicit_arity ]) -> - let subCallbacks = mapper callbacks in - enable subCallbacks sub - | ((Registration (_key, enCB, diCB))[@implicit_arity ]) -> - diCB := ((Some ((enCB callbacks)))[@explicit_arity ]) in - let rec disable : type msg. - msg Vdom.applicationCallbacks ref -> msg t -> unit = - fun callbacks -> - function - | NoSub -> () - | ((Batch ([]))[@explicit_arity ]) -> () - | ((Batch (subs))[@explicit_arity ]) -> - List.iter (disable callbacks) subs - | ((Mapper (mapper, sub))[@implicit_arity ]) -> - let subCallbacks = mapper callbacks in - disable subCallbacks sub - | ((Registration (_key, _enCB, diCB))[@implicit_arity ]) -> - (match !diCB with - | None -> () - | ((Some (cb))[@explicit_arity ]) -> - let () = diCB := None in cb ()) in - ((match (oldSub, newSub) with - | (NoSub, NoSub) -> newSub - | (((Registration - (oldKey, _oldEnCB, oldDiCB))[@implicit_arity ]), - ((Registration - (newKey, _newEnCB, newDiCB))[@implicit_arity ])) when - oldKey = newKey -> let () = newDiCB := (!oldDiCB) in newSub - | (((Mapper (oldMapper, oldSubSub))[@implicit_arity ]), ((Mapper - (newMapper, newSubSub))[@implicit_arity ])) -> - let olderCallbacks = oldMapper oldCallbacks in - let newerCallbacks = newMapper newCallbacks in - let _newerSubSub = - run olderCallbacks newerCallbacks oldSubSub newSubSub in - newSub - | (((Batch (oldSubs))[@explicit_arity ]), ((Batch - (newSubs))[@explicit_arity ])) -> - let rec aux oldList newList = - match (oldList, newList) with - | ([], []) -> () - | ([], newSubSub::newRest) -> - let () = enable newCallbacks newSubSub in - aux [] newRest - | (oldSubSub::oldRest, []) -> - let () = disable oldCallbacks oldSubSub in - aux oldRest [] - | (oldSubSub::oldRest, newSubSub::newRest) -> - let _newerSubSub = - run oldCallbacks newCallbacks oldSubSub newSubSub in - aux oldRest newRest in - let () = aux oldSubs newSubs in newSub - | (oldS, newS) -> - let () = disable oldCallbacks oldS in - let () = enable newCallbacks newS in newSub) - [@ocaml.warning "-4"]) \ No newline at end of file diff --git a/src-ocaml/tea_svg.ml b/src-ocaml/tea_svg.ml deleted file mode 100644 index 063b0cf..0000000 --- a/src-ocaml/tea_svg.ml +++ /dev/null @@ -1,201 +0,0 @@ -open Vdom - -module Cmds = Tea_html_cmds - -module Attributes = Tea_svg_attributes - -module Events = Tea_svg_events - - -let svgNamespace = "http://www.w3.org/2000/svg" - - -(* Nodes *) - -let noNode = noNode - -let text str = text str - -let lazy1 key gen = lazyGen key gen - -let node tagName ?(key="") ?(unique="") props nodes = fullnode svgNamespace tagName key unique props nodes - -let svg ?(key="") ?(unique="") props nodes = fullnode svgNamespace "svg" key unique props nodes - -(* Animation elements *) - -let foreignObject ?(key="") ?(unique="") props nodes = fullnode svgNamespace "foreignObject" key unique props nodes - -let animate ?(key="") ?(unique="") props nodes = fullnode svgNamespace "animate" key unique props nodes - -let animateColor ?(key="") ?(unique="") props nodes = fullnode svgNamespace "animateColor" key unique props nodes - -let animateMotion ?(key="") ?(unique="") props nodes = fullnode svgNamespace "animateMotion" key unique props nodes - -let animateTransform ?(key="") ?(unique="") props nodes = fullnode svgNamespace "animateTransform" key unique props nodes - -let mpath ?(key="") ?(unique="") props nodes = fullnode svgNamespace "mpath" key unique props nodes - -let set ?(key="") ?(unique="") props nodes = fullnode svgNamespace "set" key unique props nodes - -(* Container elements *) - -let a ?(key="") ?(unique="") props nodes = fullnode svgNamespace "a" key unique props nodes - -let defs ?(key="") ?(unique="") props nodes = fullnode svgNamespace "defs" key unique props nodes - -let g ?(key="") ?(unique="") props nodes = fullnode svgNamespace "g" key unique props nodes - -let marker ?(key="") ?(unique="") props nodes = fullnode svgNamespace "marker" key unique props nodes - -let mask ?(key="") ?(unique="") props nodes = fullnode svgNamespace "mask" key unique props nodes - -let missingGlyph ?(key="") ?(unique="") props nodes = fullnode svgNamespace "missingGlyph" key unique props nodes - -let pattern ?(key="") ?(unique="") props nodes = fullnode svgNamespace "pattern" key unique props nodes - -let switch ?(key="") ?(unique="") props nodes = fullnode svgNamespace "switch" key unique props nodes - -let symbol ?(key="") ?(unique="") props nodes = fullnode svgNamespace "symbol" key unique props nodes - -(* Descriptive elements *) - -let desc ?(key="") ?(unique="") props nodes = fullnode svgNamespace "desc" key unique props nodes - -let metadata ?(key="") ?(unique="") props nodes = fullnode svgNamespace "metadata" key unique props nodes - -let title ?(key="") ?(unique="") props nodes = fullnode svgNamespace "title" key unique props nodes - -(* Filter primitive elements *) - -let feBlend ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feBlend" key unique props nodes - -let feColorMatrix ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feColorMatrix" key unique props nodes - -let feComponentTransfer ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feComponentTransfer" key unique props nodes - -let feComposite ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feComposite" key unique props nodes - -let feConvolveMatrix ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feConvolveMatrix" key unique props nodes - -let feDiffuseLighting ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feDiffuseLighting" key unique props nodes - -let feDisplacementMap ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feDisplacementMap" key unique props nodes - -let feFlood ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feFlood" key unique props nodes - -let feFuncA ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feFuncA" key unique props nodes - -let feFuncB ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feFuncB" key unique props nodes - -let feFuncG ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feFuncG" key unique props nodes - -let feFuncR ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feFuncR" key unique props nodes - -let feGaussianBlur ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feGaussianBlur" key unique props nodes - -let feImage ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feImage" key unique props nodes - -let feMerge ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feMerge" key unique props nodes - -let feMergeNode ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feMergeNode" key unique props nodes - -let feMorphology ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feMorphology" key unique props nodes - -let feOffset ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feOffset" key unique props nodes - -let feSpecularLighting ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feSpecularLighting" key unique props nodes - -let feTile ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feTile" key unique props nodes - -let feTurbulence ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feTurbulence" key unique props nodes - -(* Font elements *) - -let font ?(key="") ?(unique="") props nodes = fullnode svgNamespace "font" key unique props nodes - -let fontFace ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fontFace" key unique props nodes - -let fontFaceFormat ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fontFaceFormat" key unique props nodes - -let fontFaceName ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fontFaceName" key unique props nodes - -let fontFaceSrc ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fontFaceSrc" key unique props nodes - -let fontFaceUri ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fontFaceUri" key unique props nodes - -let hkern ?(key="") ?(unique="") props nodes = fullnode svgNamespace "hkern" key unique props nodes - -let vkern ?(key="") ?(unique="") props nodes = fullnode svgNamespace "vkern" key unique props nodes - -(* Gradient elements *) - -let linearGradient ?(key="") ?(unique="") props nodes = fullnode svgNamespace "linearGradient" key unique props nodes - -let radialGradient ?(key="") ?(unique="") props nodes = fullnode svgNamespace "radialGradient" key unique props nodes - -let stop ?(key="") ?(unique="") props nodes = fullnode svgNamespace "stop" key unique props nodes - -(* Graphics elements *) - -let circle ?(key="") ?(unique="") props nodes = fullnode svgNamespace "circle" key unique props nodes - -let ellipse ?(key="") ?(unique="") props nodes = fullnode svgNamespace "ellipse" key unique props nodes - -let svgimage ?(key="") ?(unique="") props nodes = fullnode svgNamespace "image" key unique props nodes - -let line ?(key="") ?(unique="") props nodes = fullnode svgNamespace "line" key unique props nodes - -let path ?(key="") ?(unique="") props nodes = fullnode svgNamespace "path" key unique props nodes - -let polygon ?(key="") ?(unique="") props nodes = fullnode svgNamespace "polygon" key unique props nodes - -let polyline ?(key="") ?(unique="") props nodes = fullnode svgNamespace "polyline" key unique props nodes - -let rect ?(key="") ?(unique="") props nodes = fullnode svgNamespace "rect" key unique props nodes - -let use ?(key="") ?(unique="") props nodes = fullnode svgNamespace "use" key unique props nodes - -(* Light source elements *) - -let feDistantLight ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feDistantLight" key unique props nodes - -let fePointLight ?(key="") ?(unique="") props nodes = fullnode svgNamespace "fePointLight" key unique props nodes - -let feSpotLight ?(key="") ?(unique="") props nodes = fullnode svgNamespace "feSpotLight" key unique props nodes - -(* Text content elements *) - -let altGlyph ?(key="") ?(unique="") props nodes = fullnode svgNamespace "altGlyph" key unique props nodes - -let altGlyphDef ?(key="") ?(unique="") props nodes = fullnode svgNamespace "altGlyphDef" key unique props nodes - -let altGlyphItem ?(key="") ?(unique="") props nodes = fullnode svgNamespace "altGlyphItem" key unique props nodes - -let glyph ?(key="") ?(unique="") props nodes = fullnode svgNamespace "glyph" key unique props nodes - -let glyphRef ?(key="") ?(unique="") props nodes = fullnode svgNamespace "glyphRef" key unique props nodes - -let textPath ?(key="") ?(unique="") props nodes = fullnode svgNamespace "textPath" key unique props nodes - -let text' ?(key="") ?(unique="") props nodes = fullnode svgNamespace "text" key unique props nodes - -let tref ?(key="") ?(unique="") props nodes = fullnode svgNamespace "tref" key unique props nodes - -let tspan ?(key="") ?(unique="") props nodes = fullnode svgNamespace "tspan" key unique props nodes - -(* Uncategorized elements *) - -let clipPath ?(key="") ?(unique="") props nodes = fullnode svgNamespace "clipPath" key unique props nodes - -let svgcolorProfile ?(key="") ?(unique="") props nodes = fullnode svgNamespace "colorProfile" key unique props nodes - -let cursor ?(key="") ?(unique="") props nodes = fullnode svgNamespace "cursor" key unique props nodes - -let filter ?(key="") ?(unique="") props nodes = fullnode svgNamespace "filter" key unique props nodes - -let script ?(key="") ?(unique="") props nodes = fullnode svgNamespace "script" key unique props nodes - -let style ?(key="") ?(unique="") props nodes = fullnode svgNamespace "style" key unique props nodes - -let view ?(key="") ?(unique="") props nodes = fullnode svgNamespace "view" key unique props nodes diff --git a/src-ocaml/tea_svg_attributes.ml b/src-ocaml/tea_svg_attributes.ml deleted file mode 100644 index 5359ddb..0000000 --- a/src-ocaml/tea_svg_attributes.ml +++ /dev/null @@ -1,1515 +0,0 @@ -open Vdom - -(* Regular attributes *) - -let accentHeight v = attribute "" "accent-height" v - -let accelerate v = attribute "" "accelerate" v - - - -let accumulate v = - attribute "" "accumulate" v - - - - -let additive v = - attribute "" "additive" v - - - - -let alphabetic v = - attribute "" "alphabetic" v - - - - -let allowReorder v = - attribute "" "allowReorder" v - - - - -let amplitude v = - attribute "" "amplitude" v - - - - -let arabicForm v = - attribute "" "arabic-form" v - - - - -let ascent v = - attribute "" "ascent" v - - - - -let attributeName v = - attribute "" "attributeName" v - - - - -let attributeType v = - attribute "" "attributeType" v - - - - -let autoReverse v = - attribute "" "autoReverse" v - - - - -let azimuth v = - attribute "" "azimuth" v - - - - -let baseFrequency v = - attribute "" "baseFrequency" v - - - - -let baseProfile v = - attribute "" "baseProfile" v - - - - -let bbox v = - attribute "" "bbox" v - - - - -let begin' v = - attribute "" "begin" v - - - - -let bias v = - attribute "" "bias" v - - - - -let by v = - attribute "" "by" v - - - - -let calcMode v = - attribute "" "calcMode" v - - - - -let capHeight v = - attribute "" "cap-height" v - - - - -let class' v = - attribute "" "class" v - - - - -let clipPathUnits v = - attribute "" "clipPathUnits" v - - - - -let contentScriptType v = - attribute "" "contentScriptType" v - - - - -let contentStyleType v = - attribute "" "contentStyleType" v - - - - -let cx v = - attribute "" "cx" v - - - - -let cy v = - attribute "" "cy" v - - - - -let d v = - attribute "" "d" v - - - - -let decelerate v = - attribute "" "decelerate" v - - - - -let descent v = - attribute "" "descent" v - - - - -let diffuseConstant v = - attribute "" "diffuseConstant" v - - - - -let divisor v = - attribute "" "divisor" v - - - - -let dur v = - attribute "" "dur" v - - - - -let dx v = - attribute "" "dx" v - - - - -let dy v = - attribute "" "dy" v - - - - -let edgeMode v = - attribute "" "edgeMode" v - - - - -let elevation v = - attribute "" "elevation" v - - - - -let end' v = - attribute "" "end" v - - - - -let exponent v = - attribute "" "exponent" v - - - - -let externalResourcesRequired v = - attribute "" "externalResourcesRequired" v - - - - -let filterRes v = - attribute "" "filterRes" v - - - - -let filterUnits v = - attribute "" "filterUnits" v - - - - -let format v = - attribute "" "format" v - - - - -let from v = - attribute "" "from" v - - - - -let fx v = - attribute "" "fx" v - - - - -let fy v = - attribute "" "fy" v - - - - -let g1 v = - attribute "" "g1" v - - - - -let g2 v = - attribute "" "g2" v - - - - -let glyphName v = - attribute "" "glyph-name" v - - - - -let glyphRef v = - attribute "" "glyphRef" v - - - - -let gradientTransform v = - attribute "" "gradientTransform" v - - - - -let gradientUnits v = - attribute "" "gradientUnits" v - - - - -let hanging v = - attribute "" "hanging" v - - - - -let height v = - attribute "" "height" v - - - - -let horizAdvX v = - attribute "" "horiz-adv-x" v - - - - -let horizOriginX v = - attribute "" "horiz-origin-x" v - - - - -let horizOriginY v = - attribute "" "horiz-origin-y" v - - - - -let id v = - attribute "" "id" v - - - - -let ideographic v = - attribute "" "ideographic" v - - - - -let in' v = - attribute "" "in" v - - - - -let in2 v = - attribute "" "in2" v - - - - -let intercept v = - attribute "" "intercept" v - - - - -let k v = - attribute "" "k" v - - - - -let k1 v = - attribute "" "k1" v - - - - -let k2 v = - attribute "" "k2" v - - - - -let k3 v = - attribute "" "k3" v - - - - -let k4 v = - attribute "" "k4" v - - - - -let kernelMatrix v = - attribute "" "kernelMatrix" v - - - - -let kernelUnitLength v = - attribute "" "kernelUnitLength" v - - - - -let keyPoints v = - attribute "" "keyPoints" v - - - - -let keySplines v = - attribute "" "keySplines" v - - - - -let keyTimes v = - attribute "" "keyTimes" v - - - - -let lang v = - attribute "" "lang" v - - - - -let lengthAdjust v = - attribute "" "lengthAdjust" v - - - - -let limitingConeAngle v = - attribute "" "limitingConeAngle" v - - - - -let local v = - attribute "" "local" v - - - - -let markerHeight v = - attribute "" "markerHeight" v - - - - -let markerUnits v = - attribute "" "markerUnits" v - - - - -let markerWidth v = - attribute "" "markerWidth" v - - - - -let maskContentUnits v = - attribute "" "maskContentUnits" v - - - - -let maskUnits v = - attribute "" "maskUnits" v - - - - -let mathematical v = - attribute "" "mathematical" v - - - - -let max v = - attribute "" "max" v - - - - -let media v = - attribute "" "media" v - - - - -let method' v = - attribute "" "method" v - - - - -let min v = - attribute "" "min" v - - - - -let mode v = - attribute "" "mode" v - - - - -let name v = - attribute "" "name" v - - - - -let numOctaves v = - attribute "" "numOctaves" v - - - - -let offset v = - attribute "" "offset" v - - - - -let operator v = - attribute "" "operator" v - - - - -let order v = - attribute "" "order" v - - - - -let orient v = - attribute "" "orient" v - - - - -let orientation v = - attribute "" "orientation" v - - - - -let origin v = - attribute "" "origin" v - - - - -let overlinePosition v = - attribute "" "overline-position" v - - - - -let overlineThickness v = - attribute "" "overline-thickness" v - - - - -let panose1 v = - attribute "" "panose-1" v - - - - -let path v = - attribute "" "path" v - - - - -let pathLength v = - attribute "" "pathLength" v - - - - -let patternContentUnits v = - attribute "" "patternContentUnits" v - - - - -let patternTransform v = - attribute "" "patternTransform" v - - - - -let patternUnits v = - attribute "" "patternUnits" v - - - - -let pointOrder v = - attribute "" "point-order" v - - - - -let points v = - attribute "" "points" v - - - - -let pointsAtX v = - attribute "" "pointsAtX" v - - - - -let pointsAtY v = - attribute "" "pointsAtY" v - - - - -let pointsAtZ v = - attribute "" "pointsAtZ" v - - - - -let preserveAlpha v = - attribute "" "preserveAlpha" v - - - - -let preserveAspectRatio v = - attribute "" "preserveAspectRatio" v - - - - -let primitiveUnits v = - attribute "" "primitiveUnits" v - - - - -let r v = - attribute "" "r" v - - - - -let radius v = - attribute "" "radius" v - - - - -let refX v = - attribute "" "refX" v - - - - -let refY v = - attribute "" "refY" v - - - - -let renderingIntent v = - attribute "" "rendering-intent" v - - - - -let repeatCount v = - attribute "" "repeatCount" v - - - - -let repeatDur v = - attribute "" "repeatDur" v - - - - -let requiredExtensions v = - attribute "" "requiredExtensions" v - - - - -let requiredFeatures v = - attribute "" "requiredFeatures" v - - - - -let restart v = - attribute "" "restart" v - - - - -let result v = - attribute "" "result" v - - - - -let rotate v = - attribute "" "rotate" v - - - - -let rx v = - attribute "" "rx" v - - - - -let ry v = - attribute "" "ry" v - - - - -let scale v = - attribute "" "scale" v - - - - -let seed v = - attribute "" "seed" v - - - - -let slope v = - attribute "" "slope" v - - - - -let spacing v = - attribute "" "spacing" v - - - - -let specularConstant v = - attribute "" "specularConstant" v - - - - -let specularExponent v = - attribute "" "specularExponent" v - - - - -let speed v = - attribute "" "speed" v - - - - -let spreadMethod v = - attribute "" "spreadMethod" v - - - - -let startOffset v = - attribute "" "startOffset" v - - - - -let stdDeviation v = - attribute "" "stdDeviation" v - - - - -let stemh v = - attribute "" "stemh" v - - - - -let stemv v = - attribute "" "stemv" v - - - - -let stitchTiles v = - attribute "" "stitchTiles" v - - - - -let strikethroughPosition v = - attribute "" "strikethrough-position" v - - - - -let strikethroughThickness v = - attribute "" "strikethrough-thickness" v - - - - -let string v = - attribute "" "string" v - - - - -let style v = - attribute "" "style" v - - - - -let surfaceScale v = - attribute "" "surfaceScale" v - - - - -let systemLanguage v = - attribute "" "systemLanguage" v - - - - -let tableValues v = - attribute "" "tableValues" v - - - - -let target v = - attribute "" "target" v - - - - -let targetX v = - attribute "" "targetX" v - - - - -let targetY v = - attribute "" "targetY" v - - - - -let textLength v = - attribute "" "textLength" v - - - - -let title v = - attribute "" "title" v - - - - -let to' v = - attribute "" "to" v - - - - -let transform v = - attribute "" "transform" v - - - - -let type' v = - attribute "" "type" v - - - - -let u1 v = - attribute "" "u1" v - - - - -let u2 v = - attribute "" "u2" v - - - - -let underlinePosition v = - attribute "" "underline-position" v - - - - -let underlineThickness v = - attribute "" "underline-thickness" v - - - - -let unicode v = - attribute "" "unicode" v - - - - -let unicodeRange v = - attribute "" "unicode-range" v - - - - -let unitsPerEm v = - attribute "" "units-per-em" v - - - - -let vAlphabetic v = - attribute "" "v-alphabetic" v - - - - -let vHanging v = - attribute "" "v-hanging" v - - - - -let vIdeographic v = - attribute "" "v-ideographic" v - - - - -let vMathematical v = - attribute "" "v-mathematical" v - - - - -let values v = - attribute "" "values" v - - - - -let version v = - attribute "" "version" v - - - - -let vertAdvY v = - attribute "" "vert-adv-y" v - - - - -let vertOriginX v = - attribute "" "vert-origin-x" v - - - - -let vertOriginY v = - attribute "" "vert-origin-y" v - - - - -let viewBox v = - attribute "" "viewBox" v - - - - -let viewTarget v = - attribute "" "viewTarget" v - - - - -let width v = - attribute "" "width" v - - - - -let widths v = - attribute "" "widths" v - - - - -let x v = - attribute "" "x" v - - - - -let xHeight v = - attribute "" "x-height" v - - - - -let x1 v = - attribute "" "x1" v - - - - -let x2 v = - attribute "" "x2" v - - - - -let xChannelSelector v = - attribute "" "xChannelSelector" v - - - - -let xlinkActuate v = - attribute "http://www.w3.org/1999/xlink" "xlink:actuate" v - - - - -let xlinkArcrole v = - attribute "http://www.w3.org/1999/xlink" "xlink:arcrole" v - - - - -let xlinkHref v = - attribute "http://www.w3.org/1999/xlink" "xlink:href" v - - - - -let xlinkRole v = - attribute "http://www.w3.org/1999/xlink" "xlink:role" v - - - - -let xlinkShow v = - attribute "http://www.w3.org/1999/xlink" "xlink:show" v - - - - -let xlinkTitle v = - attribute "http://www.w3.org/1999/xlink" "xlink:title" v - - - - -let xlinkType v = - attribute "http://www.w3.org/1999/xlink" "xlink:type" v - - - - -let xmlBase v = - attribute "http://www.w3.org/XML/1998/namespace" "xml:base" v - - - - -let xmlLang v = - attribute "http://www.w3.org/XML/1998/namespace" "xml:lang" v - - - - -let xmlSpace v = - attribute "http://www.w3.org/XML/1998/namespace" "xml:space" v - - - - -let y v = - attribute "" "y" v - - - - -let y1 v = - attribute "" "y1" v - - - - -let y2 v = - attribute "" "y2" v - - - - -let yChannelSelector v = - attribute "" "yChannelSelector" v - - - - -let z v = - attribute "" "z" v - - - - -let zoomAndPan v = - attribute "" "zoomAndPan" v - - - -(* Presentation attributes *) - - - -let alignmentBaseline v = - attribute "" "alignment-baseline" v - - - - -let baselineShift v = - attribute "" "baseline-shift" v - - - - -let clipPath v = - attribute "" "clip-path" v - - - - -let clipRule v = - attribute "" "clip-rule" v - - - - -let clip v = - attribute "" "clip" v - - - - -let colorInterpolationFilters v = - attribute "" "color-interpolation-filters" v - - - - -let colorInterpolation v = - attribute "" "color-interpolation" v - - - - -let colorProfile v = - attribute "" "color-profile" v - - - - -let colorRendering v = - attribute "" "color-rendering" v - - - - -let color v = - attribute "" "color" v - - - - -let cursor v = - attribute "" "cursor" v - - - - -let direction v = - attribute "" "direction" v - - - - -let display v = - attribute "" "display" v - - - - -let dominantBaseline v = - attribute "" "dominant-baseline" v - - - - -let enableBackground v = - attribute "" "enable-background" v - - - - -let fillOpacity v = - attribute "" "fill-opacity" v - - - - -let fillRule v = - attribute "" "fill-rule" v - - - - -let fill v = - attribute "" "fill" v - - - - -let filter v = - attribute "" "filter" v - - - - -let floodColor v = - attribute "" "flood-color" v - - - - -let floodOpacity v = - attribute "" "flood-opacity" v - - - - -let fontFamily v = - attribute "" "font-family" v - - - - -let fontSizeAdjust v = - attribute "" "font-size-adjust" v - - - - -let fontSize v = - attribute "" "font-size" v - - - - -let fontStretch v = - attribute "" "font-stretch" v - - - - -let fontStyle v = - attribute "" "font-style" v - - - - -let fontVariant v = - attribute "" "font-variant" v - - - - -let fontWeight v = - attribute "" "font-weight" v - - - - -let glyphOrientationHorizontal v = - attribute "" "glyph-orientation-horizontal" v - - - - -let glyphOrientationVertical v = - attribute "" "glyph-orientation-vertical" v - - - - -let imageRendering v = - attribute "" "image-rendering" v - - - - -let kerning v = - attribute "" "kerning" v - - - - -let letterSpacing v = - attribute "" "letter-spacing" v - - - - -let lightingColor v = - attribute "" "lighting-color" v - - - - -let markerEnd v = - attribute "" "marker-end" v - - - - -let markerMid v = - attribute "" "marker-mid" v - - - - -let markerStart v = - attribute "" "marker-start" v - - - - -let mask v = - attribute "" "mask" v - - - - -let opacity v = - attribute "" "opacity" v - - - - -let overflow v = - attribute "" "overflow" v - - - - -let pointerEvents v = - attribute "" "pointer-events" v - - - - -let shapeRendering v = - attribute "" "shape-rendering" v - - - - -let stopColor v = - attribute "" "stop-color" v - - - - -let stopOpacity v = - attribute "" "stop-opacity" v - - - - -let strokeDasharray v = - attribute "" "stroke-dasharray" v - - - - -let strokeDashoffset v = - attribute "" "stroke-dashoffset" v - - - - -let strokeLinecap v = - attribute "" "stroke-linecap" v - - - - -let strokeLinejoin v = - attribute "" "stroke-linejoin" v - - - - -let strokeMiterlimit v = - attribute "" "stroke-miterlimit" v - - - - -let strokeOpacity v = - attribute "" "stroke-opacity" v - - - - -let strokeWidth v = - attribute "" "stroke-width" v - - - - -let stroke v = - attribute "" "stroke" v - - - - -let textAnchor v = - attribute "" "text-anchor" v - - - - -let textDecoration v = - attribute "" "text-decoration" v - - - - -let textRendering v = - attribute "" "text-rendering" v - - - - -let unicodeBidi v = - attribute "" "unicode-bidi" v - - - - -let visibility v = - attribute "" "visibility" v - - - - -let wordSpacing v = - attribute "" "word-spacing" v - - - - -let writingMode v = - attribute "" "writing-mode" v diff --git a/src-ocaml/tea_svg_events.ml b/src-ocaml/tea_svg_events.ml deleted file mode 100644 index 214a3c4..0000000 --- a/src-ocaml/tea_svg_events.ml +++ /dev/null @@ -1 +0,0 @@ -(* open Vdom *) diff --git a/src-ocaml/tea_task.ml b/src-ocaml/tea_task.ml deleted file mode 100644 index c0de3db..0000000 --- a/src-ocaml/tea_task.ml +++ /dev/null @@ -1,242 +0,0 @@ -type never - -type ('succeed,'fail) t = - | Task: ((('succeed,'fail) Tea_result.t -> unit) -> unit) -> - ('succeed,'fail) t - -let nothing () = () - -let performOpt (toOptionalMessage : 'value -> 'msg option) - (((Task (task))[@explicit_arity ]) : ('value,never) t) = - (Tea_cmd.call - (fun callbacks -> - let open Tea_result in - let open Vdom in - let cb = - function - | ((Error (_e))[@explicit_arity ]) -> - failwith - (("ERROR: Task perfom returned error of never! Should not happen!") - [@reason.raw_literal - "ERROR: Task perfom returned error of never! Should not happen!"]) - | ((Ok (v))[@explicit_arity ]) -> - (match toOptionalMessage v with - | None -> () - | ((Some (result))[@explicit_arity ]) -> - (!callbacks).enqueue result) in - task cb) : 'msg Tea_cmd.t) - -let perform (toMessage : 'value -> 'msg) (task : ('value,never) t) = - (performOpt (fun v -> ((Some ((toMessage v)))[@explicit_arity ])) task : - 'msg Tea_cmd.t) - -let attemptOpt - (resultToOptionalMessage : ('succeed,'fail) Tea_result.t -> 'msg option) - (((Task (task))[@explicit_arity ]) : ('succeed,'fail) t) = - (Tea_cmd.call - (fun callbacks -> - let open Vdom in - let cb value = - match resultToOptionalMessage value with - | None -> () - | ((Some (result))[@explicit_arity ]) -> - (!callbacks).enqueue result in - task cb) : 'msg Tea_cmd.t) - -let attempt (resultToMessage : ('succeed,'fail) Tea_result.t -> 'msg) - (task : ('succeed,'fail) t) = - (attemptOpt (fun v -> ((Some ((resultToMessage v)))[@explicit_arity ])) - task : 'msg Tea_cmd.t) - -let ignore task = attemptOpt (fun _ -> None) task - -let succeed (value : 'v) = - (((Task ((fun cb -> cb ((Tea_result.Ok (value))[@explicit_arity ])))) - [@explicit_arity ]) : ('v,'e) t) - -let fail (value : 'v) = - (((Task ((fun cb -> cb ((Tea_result.Error (value))[@explicit_arity ])))) - [@explicit_arity ]) : ('e,'v) t) - -let nativeBinding (func : (('succeed,'fail) Tea_result.t -> unit) -> unit) = - (((Task (func))[@explicit_arity ]) : ('succeed,'fail) t) - -let andThen fn ((Task (task))[@explicit_arity ]) = - let open Tea_result in - ((Task - ((fun cb -> - task - (function - | ((Error (_e))[@explicit_arity ]) as err -> cb err - | ((Ok (v))[@explicit_arity ]) -> - let ((Task (nextTask))[@explicit_arity ]) = fn v in - nextTask cb))))[@explicit_arity ]) - -let onError fn ((Task (task))[@explicit_arity ]) = - let open Tea_result in - ((Task - ((fun cb -> - task - (function - | ((Ok (_v))[@explicit_arity ]) as ok -> cb ok - | ((Error (e))[@explicit_arity ]) -> - let ((Task (newTask))[@explicit_arity ]) = fn e in - newTask cb))))[@explicit_arity ]) - -let fromResult : ('success,'failure) Tea_result.t -> ('success,'failure) t = function - | Tea_result.Ok s -> succeed s - | Tea_result.Error err -> fail err - -let mapError func task = task |> (onError (fun e -> fail (func e))) - -let toOption task = - task - |> andThen (fun v -> succeed (Some v)) - |> onError (fun _ -> succeed None) - -let map func task1 = task1 |> (andThen (fun v1 -> succeed (func v1))) - -let map2 func task1 task2 = - task1 |> - (andThen - (fun v1 -> task2 |> (andThen (fun v2 -> succeed (func v1 v2))))) - -let map3 func task1 task2 task3 = - task1 |> - (andThen - (fun v1 -> - task2 |> - (andThen - (fun v2 -> - task3 |> (andThen (fun v3 -> succeed (func v1 v2 v3))))))) - -let map4 func task1 task2 task3 task4 = - task1 |> - (andThen - (fun v1 -> - task2 |> - (andThen - (fun v2 -> - task3 |> - (andThen - (fun v3 -> - task4 |> - (andThen (fun v4 -> succeed (func v1 v2 v3 v4))))))))) - -let map5 func task1 task2 task3 task4 task5 = - task1 |> - (andThen - (fun v1 -> - task2 |> - (andThen - (fun v2 -> - task3 |> - (andThen - (fun v3 -> - task4 |> - (andThen - (fun v4 -> - task5 |> - (andThen - (fun v5 -> - succeed (func v1 v2 v3 v4 v5))))))))))) - -let map6 func task1 task2 task3 task4 task5 task6 = - task1 |> - (andThen - (fun v1 -> - task2 |> - (andThen - (fun v2 -> - task3 |> - (andThen - (fun v3 -> - task4 |> - (andThen - (fun v4 -> - task5 |> - (andThen - (fun v5 -> - task6 |> - (andThen - (fun v6 -> - succeed - (func v1 v2 v3 v4 v5 v6))))))))))))) - -let rec sequence = - function - | [] -> succeed [] - | task::remainingTasks -> - map2 (fun l -> fun r -> l :: r) task (sequence remainingTasks) - -let testing_deop = ref true - -let testing () = - let open Tea_result in - let doTest expected ((Task (task))[@explicit_arity ]) = - let testAssert v = - if v = expected - then - Js.log ((("Passed:")[@reason.raw_literal "Passed:"]), expected, v) - else - Js.log ((("FAILED:")[@reason.raw_literal "FAILED:"]), expected, v) in - task testAssert in - let s = succeed 42 in - let () = doTest ((Ok (42))[@explicit_arity ]) s in - let f = fail 86 in - let () = doTest ((Error (86))[@explicit_arity ]) f in - let r () = if !testing_deop then succeed 42 else fail 3.14 in - let a1 = (succeed 2) |> (andThen (fun n -> succeed (n + 2))) in - let () = doTest ((Ok (4))[@explicit_arity ]) a1 in - let a2 = (succeed 2) |> (andThen (fun n -> succeed (string_of_int n))) in - let () = - doTest ((Ok ((("2")[@reason.raw_literal "2"])))[@explicit_arity ]) a2 in - let m1 = map sqrt (succeed 9.) in - let () = doTest ((Ok (3.))[@explicit_arity ]) m1 in - let m2 = map2 (+) (succeed 9) (succeed 3) in - let () = doTest ((Ok (12))[@explicit_arity ]) m2 in - let m3 = map string_of_int (succeed 9) in - let () = - doTest ((Ok ((("9")[@reason.raw_literal "9"])))[@explicit_arity ]) m3 in - let s0 = sequence [succeed 1; succeed 2] in - let () = doTest ((Ok ([1; 2]))[@explicit_arity ]) s0 in - let s1 = sequence [succeed 1; fail 2.7; r ()] in - let () = doTest ((Error (2.7))[@explicit_arity ]) s1 in - let e0 = - (fail (("file not found")[@reason.raw_literal "file not found"])) |> - (onError (fun _msg -> succeed 42)) in - let () = doTest ((Ok (42))[@explicit_arity ]) e0 in - let e1 = - (fail (("file not found")[@reason.raw_literal "file not found"])) |> - (onError (fun _msg -> fail 42)) in - let () = doTest ((Error (42))[@explicit_arity ]) e1 in - let n0 = - sequence - [mapError string_of_int (fail 42); - mapError Js.Float.toString (fail 3.14)] in - let () = - doTest ((Error ((("42")[@reason.raw_literal "42"])))[@explicit_arity ]) - n0 in - let n1 = - sequence - [mapError string_of_int (succeed 1); - mapError Js.Float.toString (fail 3.14)] in - let () = - doTest - ((Error ((("3.14")[@reason.raw_literal "3.14"])))[@explicit_arity ]) - n1 in - let n2 = - sequence - [mapError string_of_int (succeed 1); - mapError Js.Float.toString (succeed 2)] in - let () = doTest ((Ok ([1; 2]))[@explicit_arity ]) n2 in - - let _c0 = perform (fun _ -> 42) (succeed 18) in - - let () = doTest (Ok 42) (fromResult (Ok 42)) in - let () = doTest (Error "failure") (fromResult (Error "failure")) in - - let () = doTest (Ok None) (fail "for some reason" |> toOption) in - let () = doTest (Ok (Some 42)) (succeed 42 |> toOption) in - - () diff --git a/src-ocaml/tea_time.ml b/src-ocaml/tea_time.ml deleted file mode 100644 index a28d3ab..0000000 --- a/src-ocaml/tea_time.ml +++ /dev/null @@ -1,69 +0,0 @@ - - -type t = float - - -(* type 'msg mySub = - | Every of t * (t -> 'msg) - - -type 'msg myCmd = - | Delay of t * (unit -> 'msg) *) - - -let every ~key interval tagger = - let open Vdom in - let enableCall callbacks = - let id = (Web.Window.setInterval (fun () -> callbacks.enqueue (tagger (Web.Date.now ())) ) interval) in - (* let () = Js.log ("Time.every", "enable", interval, tagger, callbacks) in *) - fun () -> - (* let () = Js.log ("Time.every", "disable", id, interval, tagger, callbacks) in *) - Web.Window.clearTimeout id - in Tea_sub.registration key enableCall - - -let delay msTime msg = - Tea_cmd.call - ( fun callbacks -> - let _unhandledID = - Web.Window.setTimeout - ( fun () -> - let open Vdom in - !callbacks.enqueue msg - ) - msTime - in () - ) - - -(* Generic Helpers *) - -let millisecond = 1.0 - - -let second = - 1000.0 *. millisecond - - -let minute = - 60.0 *. second - - -let hour = - 60.0 *. minute - - -let inMilliseconds t = - t - - -let inSeconds t = - t /. second - - -let inMinutes t = - t /. minute - - -let inHours t = - t /. hour diff --git a/src-ocaml/vdom.ml b/src-ocaml/vdom.ml deleted file mode 100644 index e5be78d..0000000 --- a/src-ocaml/vdom.ml +++ /dev/null @@ -1,612 +0,0 @@ -type 'msg systemMessage = - | Render - | AddRenderMsg of 'msg - | RemoveRenderMsg of 'msg -type 'msg applicationCallbacks = - { - enqueue: 'msg -> unit ; - on: 'msg systemMessage -> unit } -type 'msg eventHandler = - | EventHandlerCallback of string * (Web.Node.event -> 'msg option) - | EventHandlerMsg of 'msg -type 'msg eventCache = - { - handler: Web.Node.event_cb ; - cb: (Web.Node.event -> 'msg option) ref } -type 'msg property = - | NoProp - | RawProp of string * string - | Attribute of string * string * string - | Data of string * string - | Event of string * 'msg eventHandler * 'msg eventCache option ref - | Style of (string * string) list -type 'msg properties = 'msg property list -type 'msg t = - | CommentNode of string - | Text of string - | Node of string * string * string * string * 'msg properties * 'msg t list - - | LazyGen of string * (unit -> 'msg t) * 'msg t ref - | Tagger of - ('msg applicationCallbacks ref -> 'msg applicationCallbacks ref) * 'msg t -let noNode = ((((CommentNode (""))[@explicit_arity ]) : 'msg t) : 'msg t) -let comment (s : string) = (((CommentNode (s))[@explicit_arity ]) : 'msg t) -let text (s : string) = (((Text (s))[@explicit_arity ]) : 'msg t) -let fullnode (namespace : string) (tagName : string) (key : string) - (unique : string) (props : 'msg properties) (vdoms : 'msg t list) = - (((Node (namespace, tagName, key, unique, props, vdoms)) - [@implicit_arity ]) : 'msg t) -let node ?namespace:((namespace : string)= "") (tagName : string) - ?key:((key : string)= "") ?unique:((unique : string)= "") - (props : 'msg properties) (vdoms : 'msg t list) = - (fullnode namespace tagName key unique props vdoms : 'msg t) -let lazyGen (key : string) (fn : unit -> 'msg t) = - (((LazyGen (key, fn, (ref noNode)))[@implicit_arity ]) : 'msg t) -let noProp = ((NoProp : 'msg property) : 'msg property) -let prop (key : string) (value : string) = (((RawProp (key, value)) - [@implicit_arity ]) : 'msg property) -let onCB (name : string) (key : string) (cb : Web.Node.event -> 'msg option) - = - (((Event - (name, ((EventHandlerCallback (key, cb))[@implicit_arity ]), - (ref None))) - [@implicit_arity ]) : 'msg property) -let onMsg (name : string) (msg : 'msg) = - (((Event (name, ((EventHandlerMsg (msg))[@explicit_arity ]), (ref None))) - [@implicit_arity ]) : 'msg property) -let attribute (namespace : string) (key : string) (value : string) = - (((Attribute (namespace, key, value))[@implicit_arity ]) : 'msg property) -let data (key : string) (value : string) = (((Data (key, value)) - [@implicit_arity ]) : 'msg property) -let style (key : string) (value : string) = (((Style ([(key, value)])) - [@explicit_arity ]) : 'msg property) -let styles s = (((Style (s))[@explicit_arity ]) : 'msg property) -let rec renderToHtmlString = - ((function - | ((CommentNode (s))[@explicit_arity ]) -> "") - | ((Text (s))[@explicit_arity ]) -> s - | ((Node - (namespace, tagName, _key, _unique, props, vdoms))[@implicit_arity ]) - -> - let renderProp = - function - | NoProp -> "" - | ((RawProp (k, v))[@implicit_arity ]) -> - String.concat "" [" "; k; "=\""; v; "\""] - | ((Attribute (_namespace, k, v))[@implicit_arity ]) -> - String.concat "" [" "; k; "=\""; v; "\""] - | ((Data (k, v))[@implicit_arity ]) -> - String.concat "" [" data-"; k; "=\""; v; "\""] - | ((Event (_, _, _))[@implicit_arity ]) -> "" - | ((Style (s))[@explicit_arity ]) -> - String.concat "" - [" style=\""; - String.concat ";" - (List.map (fun (k, v) -> String.concat "" [k; ":"; v; ";"]) - s); - "\""] in - String.concat "" - ["<"; - namespace; - if namespace = "" then "" else ":"; - tagName; - String.concat "" (List.map (fun p -> renderProp p) props); - ">"; - String.concat "" (List.map (fun v -> renderToHtmlString v) vdoms); - ""] - | ((LazyGen (_key, gen, _cache))[@implicit_arity ]) -> - let vdom = gen () in renderToHtmlString vdom - | ((Tagger (_tagger, vdom))[@implicit_arity ]) -> renderToHtmlString vdom : - 'msg t -> string) : 'msg t -> string) -let emptyEventHandler = ((((fun _ev -> ()) - [@bs ]) : Web.Node.event_cb) : Web.Node.event_cb) -let emptyEventCB _ev = (None : Web.Node.event_cb option) -let eventHandler (callbacks : 'msg applicationCallbacks ref) - (cb : (Web.Node.event -> 'msg option) ref) = - (((fun ev -> - match (!cb) ev with - | None -> () - | ((Some (msg))[@explicit_arity ]) -> (!callbacks).enqueue msg) - [@bs ]) : Web.Node.event_cb) -let eventHandler_GetCB = - ((function - | ((EventHandlerCallback (_, cb))[@implicit_arity ]) -> cb - | ((EventHandlerMsg (msg))[@explicit_arity ]) -> - (fun _ev -> ((Some (msg))[@explicit_arity ])) : 'msg eventHandler -> - Web.Node.event -> - 'msg option) : - 'msg eventHandler -> Web.Node.event -> 'msg option) -let compareEventHandlerTypes (left : 'msg eventHandler) = - (function - | ((EventHandlerCallback (cb, _))[@implicit_arity ]) -> - (match left with - | ((EventHandlerCallback (lcb, _))[@implicit_arity ]) when cb = lcb - -> true - | _ -> false) - | ((EventHandlerMsg (msg))[@explicit_arity ]) -> - (match left with - | ((EventHandlerMsg (lmsg))[@explicit_arity ]) when msg = lmsg -> - true - | _ -> false) : 'msg eventHandler -> bool) -let eventHandler_Register (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (name : string) (handlerType : 'msg eventHandler) = - (let cb = ref (eventHandler_GetCB handlerType) in - let handler = eventHandler callbacks cb in - let () = Web.Node.addEventListener elem name handler false in - ((Some ({ handler; cb }))[@explicit_arity ]) : 'msg eventCache option) -let eventHandler_Unregister (elem : Web.Node.t) (name : string) = - (function - | None -> None - | ((Some (cache))[@explicit_arity ]) -> - let () = Web.Node.removeEventListener elem name cache.handler false in - None : 'msg eventCache option -> 'msg eventCache option) -let eventHandler_Mutate (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (oldName : string) (newName : string) - (oldHandlerType : 'msg eventHandler) (newHandlerType : 'msg eventHandler) - (oldCache : 'msg eventCache option ref) - (newCache : 'msg eventCache option ref) = - (match !oldCache with - | None -> - newCache := - (eventHandler_Register callbacks elem newName newHandlerType) - | ((Some (oldcache))[@explicit_arity ]) -> - if oldName = newName - then - let () = newCache := (!oldCache) in - (if compareEventHandlerTypes oldHandlerType newHandlerType - then () - else - (let cb = eventHandler_GetCB newHandlerType in - let () = oldcache.cb := cb in ())) - else - (let () = - oldCache := (eventHandler_Unregister elem oldName (!oldCache)) in - let () = - newCache := - (eventHandler_Register callbacks elem newName newHandlerType) in - ()) : unit) -let patchVNodesOnElems_PropertiesApply_Add - (callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) - (_idx : int) = - (function - | NoProp -> () - | ((RawProp (k, v))[@implicit_arity ]) -> Web.Node.setProp elem k v - | ((Attribute (namespace, k, v))[@implicit_arity ]) -> - Web.Node.setAttributeNsOptional elem namespace k v - | ((Data (k, v))[@implicit_arity ]) -> - (Js.log ("TODO: Add Data Unhandled", k, v); - failwith "TODO: Add Data Unhandled") - | ((Event (name, handlerType, cache))[@implicit_arity ]) -> - cache := (eventHandler_Register callbacks elem name handlerType) - | ((Style (s))[@explicit_arity ]) -> - List.fold_left - (fun () -> - fun (k, v) -> Web.Node.setStyleProperty elem k (Js.Null.return v)) - () s : 'msg property -> unit) -let patchVNodesOnElems_PropertiesApply_Remove - (_callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) - (_idx : int) = - (function - | NoProp -> () - | ((RawProp (k, _v))[@implicit_arity ]) -> - Web.Node.setProp elem k Js.Undefined.empty - | ((Attribute (namespace, k, _v))[@implicit_arity ]) -> - Web.Node.removeAttributeNsOptional elem namespace k - | ((Data (k, v))[@implicit_arity ]) -> - (Js.log ("TODO: Remove Data Unhandled", k, v); - failwith "TODO: Remove Data Unhandled") - | ((Event (name, _, cache))[@implicit_arity ]) -> - cache := (eventHandler_Unregister elem name (!cache)) - | ((Style (s))[@explicit_arity ]) -> - List.fold_left - (fun () -> - fun (k, _v) -> Web.Node.setStyleProperty elem k Js.Null.empty) () - s : 'msg property -> unit) -let patchVNodesOnElems_PropertiesApply_RemoveAdd - (callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) (idx : int) - (oldProp : 'msg property) (newProp : 'msg property) = - (let () = - patchVNodesOnElems_PropertiesApply_Remove callbacks elem idx oldProp in - let () = patchVNodesOnElems_PropertiesApply_Add callbacks elem idx newProp in - () : unit) -let patchVNodesOnElems_PropertiesApply_Mutate - (_callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) - (_idx : int) (oldProp : 'msg property) = - (function - | NoProp as _newProp -> - failwith - "This should never be called as all entries through NoProp are gated." - | ((RawProp (k, v))[@implicit_arity ]) as _newProp -> - Web.Node.setProp elem k v - | ((Attribute (namespace, k, v))[@implicit_arity ]) as _newProp -> - Web.Node.setAttributeNsOptional elem namespace k v - | ((Data (k, v))[@implicit_arity ]) as _newProp -> - (Js.log ("TODO: Mutate Data Unhandled", k, v); - failwith "TODO: Mutate Data Unhandled") - | ((Event (_newName, _newHandlerType, _newCache))[@implicit_arity ]) as - _newProp -> failwith "This will never be called because it is gated" - | ((Style (s))[@explicit_arity ]) as _newProp -> - (((match oldProp with - | ((Style (oldS))[@explicit_arity ]) -> - List.fold_left2 - (fun () -> - fun (ok, ov) -> - fun (nk, nv) -> - if ok = nk - then - (if ov = nv - then () - else - Web.Node.setStyleProperty elem nk - (Js.Null.return nv)) - else - (let () = - Web.Node.setStyleProperty elem ok Js.Null.empty in - Web.Node.setStyleProperty elem nk - (Js.Null.return nv))) () oldS s - | _ -> - failwith - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!")) - [@ocaml.warning "-4"]) : 'msg property -> unit) -let rec patchVNodesOnElems_PropertiesApply - (callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) (idx : int) - (oldProperties : 'msg property list) (newProperties : 'msg property list) = - (((match (oldProperties, newProperties) with - | ([], []) -> true - | ([], _newProp::_newRest) -> false - | (_oldProp::_oldRest, []) -> false - | ((NoProp)::oldRest, (NoProp)::newRest) -> - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | ((((RawProp (oldK, oldV))[@implicit_arity ]) as oldProp)::oldRest, - (((RawProp (newK, newV))[@implicit_arity ]) as newProp)::newRest) -> - let () = - if (oldK = newK) && (oldV = newV) - then () - else - patchVNodesOnElems_PropertiesApply_Mutate callbacks elem idx - oldProp newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | ((((Attribute (oldNS, oldK, oldV))[@implicit_arity ]) as oldProp)::oldRest, - (((Attribute (newNS, newK, newV))[@implicit_arity ]) as newProp)::newRest) - -> - let () = - if (oldNS = newNS) && ((oldK = newK) && (oldV = newV)) - then () - else - patchVNodesOnElems_PropertiesApply_Mutate callbacks elem idx - oldProp newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | ((((Data (oldK, oldV))[@implicit_arity ]) as oldProp)::oldRest, - (((Data (newK, newV))[@implicit_arity ]) as newProp)::newRest) -> - let () = - if (oldK = newK) && (oldV = newV) - then () - else - patchVNodesOnElems_PropertiesApply_Mutate callbacks elem idx - oldProp newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | ((((Event (oldName, oldHandlerType, oldCache))[@implicit_arity ]) as - _oldProp)::oldRest, - (((Event (newName, newHandlerType, newCache))[@implicit_arity ]) as - _newProp)::newRest) - -> - let () = - eventHandler_Mutate callbacks elem oldName newName oldHandlerType - newHandlerType oldCache newCache in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | ((((Style (oldS))[@explicit_arity ]) as oldProp)::oldRest, - (((Style (newS))[@explicit_arity ]) as newProp)::newRest) -> - let () = - if oldS = newS - then () - else - patchVNodesOnElems_PropertiesApply_Mutate callbacks elem idx - oldProp newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest - | (oldProp::oldRest, newProp::newRest) -> - let () = - patchVNodesOnElems_PropertiesApply_RemoveAdd callbacks elem idx - oldProp newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx + 1) oldRest - newRest) - [@ocaml.warning "-4"]) : bool) -let patchVNodesOnElems_Properties (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (oldProperties : 'msg property list) - (newProperties : 'msg property list) = - (patchVNodesOnElems_PropertiesApply callbacks elem 0 oldProperties - newProperties : bool) -let genEmptyProps (length : int) = - (let rec aux lst = - function | 0 -> lst | len -> aux (noProp :: lst) (len - 1) in - aux [] length : 'msg property list) -let mapEmptyProps (props : 'msg property list) = - (List.map (fun _ -> noProp) props : 'msg property list) -let rec patchVNodesOnElems_ReplaceNode - (callbacks : 'msg applicationCallbacks ref) (elem : Web.Node.t) - (elems : Web.Node.t array) (idx : int) = - (((function - | ((Node - (newNamespace, newTagName, _newKey, _newUnique, newProperties, - newChildren))[@implicit_arity ]) - -> - let oldChild = elems.(idx) in - let newChild = - Web.Document.createElementNsOptional newNamespace newTagName in - let true = - patchVNodesOnElems_Properties callbacks newChild - (mapEmptyProps newProperties) newProperties[@@ocaml.warning - "-8"] in - let childChildren = Web.Node.childNodes newChild in - let () = - patchVNodesOnElems callbacks newChild childChildren 0 [] - newChildren in - let _attachedChild = Web.Node.insertBefore elem newChild oldChild in - let _removedChild = Web.Node.removeChild elem oldChild in () - | _ -> - failwith - "Node replacement should never be passed anything but a node itself") - [@ocaml.warning "-4"]) : 'msg t -> unit) -and patchVNodesOnElems_CreateElement - (callbacks : 'msg applicationCallbacks ref) = - (function - | ((CommentNode (s))[@explicit_arity ]) -> Web.Document.createComment s - | ((Text (text))[@explicit_arity ]) -> Web.Document.createTextNode text - | ((Node - (newNamespace, newTagName, _newKey, _unique, newProperties, - newChildren))[@implicit_arity ]) - -> - let newChild = - Web.Document.createElementNsOptional newNamespace newTagName in - let true = - patchVNodesOnElems_Properties callbacks newChild - (mapEmptyProps newProperties) newProperties[@@ocaml.warning "-8"] in - let childChildren = Web.Node.childNodes newChild in - let () = - patchVNodesOnElems callbacks newChild childChildren 0 [] newChildren in - newChild - | ((LazyGen (_newKey, newGen, newCache))[@implicit_arity ]) -> - let vdom = newGen () in - let () = newCache := vdom in - patchVNodesOnElems_CreateElement callbacks vdom - | ((Tagger (tagger, vdom))[@implicit_arity ]) -> - patchVNodesOnElems_CreateElement (tagger callbacks) vdom : 'msg t -> - Web.Node.t) -and patchVNodesOnElems_MutateNode (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (elems : Web.Node.t array) (idx : int) - (oldNode : 'msg t) (newNode : 'msg t) = - (match (oldNode, newNode) with - | ((((Node - (_oldNamespace, oldTagName, _oldKey, oldUnique, oldProperties, - oldChildren))[@implicit_arity ]) - as _oldNode), - (((Node - (_newNamespace, newTagName, _newKey, newUnique, newProperties, - newChildren))[@implicit_arity ]) - as newNode)) - -> - if (oldUnique <> newUnique) || (oldTagName <> newTagName) - then patchVNodesOnElems_ReplaceNode callbacks elem elems idx newNode - else - (let child = elems.(idx) in - let childChildren = Web.Node.childNodes child in - let () = - if - patchVNodesOnElems_Properties callbacks child oldProperties - newProperties - then () - else - (let () = - Js.log - "VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved." in - patchVNodesOnElems_ReplaceNode callbacks elem elems idx - newNode) in - patchVNodesOnElems callbacks child childChildren 0 oldChildren - newChildren) - | _ -> failwith "Non-node passed to patchVNodesOnElems_MutateNode" : - unit) -and patchVNodesOnElems (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (elems : Web.Node.t array) (idx : int) - (oldVNodes : 'msg t list) (newVNodes : 'msg t list) = - (((match (oldVNodes, newVNodes) with - | (((Tagger (_oldTagger, oldVdom))[@implicit_arity ])::oldRest, _) -> - patchVNodesOnElems callbacks elem elems idx (oldVdom :: oldRest) - newVNodes - | (oldNode::oldRest, ((Tagger - (newTagger, newVdom))[@implicit_arity ])::newRest) -> - let () = - patchVNodesOnElems (newTagger callbacks) elem elems idx [oldNode] - [newVdom] in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest - | ([], []) -> () - | ([], newNode::newRest) -> - let newChild = patchVNodesOnElems_CreateElement callbacks newNode in - let _attachedChild = Web.Node.appendChild elem newChild in - patchVNodesOnElems callbacks elem elems (idx + 1) [] newRest - | (_oldVnode::oldRest, []) -> - let child = elems.(idx) in - let _removedChild = Web.Node.removeChild elem child in - patchVNodesOnElems callbacks elem elems idx oldRest [] - | (((CommentNode (oldS))[@explicit_arity ])::oldRest, ((CommentNode - (newS))[@explicit_arity ])::newRest) when oldS = newS -> - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest - | (((Text (oldText))[@explicit_arity ])::oldRest, ((Text - (newText))[@explicit_arity ])::newRest) -> - let () = - if oldText = newText - then () - else - (let child = elems.(idx) in Web.Node.set_nodeValue child newText) in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest - | (((LazyGen (oldKey, _oldGen, oldCache))[@implicit_arity ])::oldRest, - ((LazyGen (newKey, newGen, newCache))[@implicit_arity ])::newRest) -> - if oldKey = newKey - then - let () = newCache := (!oldCache) in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest - else - (match (oldRest, newRest) with - | (((LazyGen - (olderKey, _olderGen, _olderCache))[@implicit_arity ])::olderRest, - ((LazyGen - (newerKey, _newerGen, _newerCache))[@implicit_arity ])::newerRest) - when (olderKey = newKey) && (oldKey = newerKey) -> - let firstChild = elems.(idx) in - let secondChild = elems.(idx + 1) in - let _removedChild = Web.Node.removeChild elem secondChild in - let _attachedChild = - Web.Node.insertBefore elem secondChild firstChild in - patchVNodesOnElems callbacks elem elems (idx + 2) olderRest - newerRest - | (((LazyGen - (olderKey, _olderGen, olderCache))[@implicit_arity ])::olderRest, - _) when olderKey = newKey -> - let oldChild = elems.(idx) in - let _removedChild = Web.Node.removeChild elem oldChild in - let oldVdom = !olderCache in - let () = newCache := oldVdom in - patchVNodesOnElems callbacks elem elems (idx + 1) olderRest - newRest - | (_, ((LazyGen - (newerKey, _newerGen, _newerCache))[@implicit_arity ])::_newerRest) - when newerKey = oldKey -> - let oldChild = elems.(idx) in - let newVdom = newGen () in - let () = newCache := newVdom in - let newChild = - patchVNodesOnElems_CreateElement callbacks newVdom in - let _attachedChild = - Web.Node.insertBefore elem newChild oldChild in - patchVNodesOnElems callbacks elem elems (idx + 1) oldVNodes - newRest - | _ -> - let oldVdom = !oldCache in - let newVdom = newGen () in - let () = newCache := newVdom in - patchVNodesOnElems callbacks elem elems idx (oldVdom :: - oldRest) (newVdom :: newRest)) - | ((((Node - (oldNamespace, oldTagName, oldKey, _oldUnique, _oldProperties, - _oldChildren))[@implicit_arity ]) - as oldNode)::oldRest, - (((Node - (newNamespace, newTagName, newKey, _newUnique, _newProperties, - _newChildren))[@implicit_arity ]) - as newNode)::newRest) - -> - if (oldKey = newKey) && (oldKey <> "") - then - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest - else - if (oldKey = "") || (newKey = "") - then - (let () = - patchVNodesOnElems_MutateNode callbacks elem elems idx - oldNode newNode in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest - newRest) - else - (match (oldRest, newRest) with - | (((Node - (olderNamespace, olderTagName, olderKey, _olderUnique, - _olderProperties, _olderChildren))[@implicit_arity ])::olderRest, - ((Node - (newerNamespace, newerTagName, newerKey, _newerUnique, - _newerProperties, _newerChildren))[@implicit_arity ])::newerRest) - when - (olderNamespace = newNamespace) && - ((olderTagName = newTagName) && - ((olderKey = newKey) && - ((oldNamespace = newerNamespace) && - ((oldTagName = newerTagName) && - (oldKey = newerKey))))) - -> - let firstChild = elems.(idx) in - let secondChild = elems.(idx + 1) in - let _removedChild = Web.Node.removeChild elem secondChild in - let _attachedChild = - Web.Node.insertBefore elem secondChild firstChild in - patchVNodesOnElems callbacks elem elems (idx + 2) olderRest - newerRest - | (((Node - (olderNamespace, olderTagName, olderKey, _olderUnique, - _olderProperties, _olderChildren))[@implicit_arity ])::olderRest, - _) when - (olderNamespace = newNamespace) && - ((olderTagName = newTagName) && (olderKey = newKey)) - -> - let oldChild = elems.(idx) in - let _removedChild = Web.Node.removeChild elem oldChild in - patchVNodesOnElems callbacks elem elems (idx + 1) olderRest - newRest - | (_, ((Node - (newerNamespace, newerTagName, newerKey, _newerUnique, - _newerProperties, _newerChildren))[@implicit_arity ])::_newerRest) - when - (oldNamespace = newerNamespace) && - ((oldTagName = newerTagName) && (oldKey = newerKey)) - -> - let oldChild = elems.(idx) in - let newChild = - patchVNodesOnElems_CreateElement callbacks newNode in - let _attachedChild = - Web.Node.insertBefore elem newChild oldChild in - patchVNodesOnElems callbacks elem elems (idx + 1) oldVNodes - newRest - | _ -> - let () = - patchVNodesOnElems_MutateNode callbacks elem elems idx - oldNode newNode in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest - newRest) - | (_oldVnode::oldRest, newNode::newRest) -> - let oldChild = elems.(idx) in - let newChild = patchVNodesOnElems_CreateElement callbacks newNode in - let _attachedChild = Web.Node.insertBefore elem newChild oldChild in - let _removedChild = Web.Node.removeChild elem oldChild in - patchVNodesOnElems callbacks elem elems (idx + 1) oldRest newRest) - [@ocaml.warning "-4"]) : unit) -let patchVNodesIntoElement (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (oldVNodes : 'msg t list) (newVNodes : 'msg t list) = - (let elems = Web.Node.childNodes elem in - let () = patchVNodesOnElems callbacks elem elems 0 oldVNodes newVNodes in - newVNodes : 'msg t list) -let patchVNodeIntoElement (callbacks : 'msg applicationCallbacks ref) - (elem : Web.Node.t) (oldVNode : 'msg t) (newVNode : 'msg t) = - (patchVNodesIntoElement callbacks elem [oldVNode] [newVNode] : 'msg t list) -let wrapCallbacks_On : type a b. - (a -> b) -> a systemMessage -> b systemMessage = - fun func -> - function - | Render -> Render - | ((AddRenderMsg (msg))[@explicit_arity ]) -> - ((AddRenderMsg ((func msg)))[@explicit_arity ]) - | ((RemoveRenderMsg (msg))[@explicit_arity ]) -> - ((RemoveRenderMsg ((func msg)))[@explicit_arity ]) -let wrapCallbacks : type a b. - (a -> b) -> b applicationCallbacks ref -> a applicationCallbacks ref = - fun func -> - fun callbacks -> - Obj.magic ref - { - enqueue = - (fun (msg : a) -> - let new_msg = func msg in (!callbacks).enqueue new_msg); - on = - (fun smsg -> - let new_smsg = wrapCallbacks_On func smsg in - (!callbacks).on new_smsg) - } -let map = - ((fun func -> - fun vdom -> - let tagger = wrapCallbacks func in - ((Tagger ((Obj.magic tagger), (Obj.magic vdom)))[@implicit_arity ]) : - ('a -> 'b) -> 'a t -> 'b t) : ('a -> 'b) -> 'a t -> 'b t) \ No newline at end of file diff --git a/src-ocaml/web_date.ml b/src-ocaml/web_date.ml deleted file mode 100644 index 2e575d8..0000000 --- a/src-ocaml/web_date.ml +++ /dev/null @@ -1,17 +0,0 @@ - - -type t = < -> Js.t - - -type date_obj = < - now : unit -> float [@bs.meth]; -> Js.t - - -external create_date : unit -> t = "Date" [@@bs.new] - -external date_obj : date_obj = "Date" [@@bs.val] - - -let now () = date_obj##now () diff --git a/src-ocaml/web_document.ml b/src-ocaml/web_document.ml deleted file mode 100644 index 9ee2360..0000000 --- a/src-ocaml/web_document.ml +++ /dev/null @@ -1,33 +0,0 @@ - -(* TODO: Polyfill document if it is missing, like on node or in native *) - -type t = < - body : Web_node.t [@bs.get]; - createElement : string -> Web_node.t [@bs.meth]; - createElementNS : string -> string -> Web_node.t [@bs.meth]; - createComment : string -> Web_node.t [@bs.meth]; - createTextNode : string -> Web_node.t [@bs.meth]; - getElementById : string -> Web_node.t Js.null_undefined [@bs.meth]; - location : Web_location.t [@bs.get]; -> Js.t - -external document : t = "document" [@@bs.val] - -let body () = document##body - -let createElement typ = document##createElement typ - -let createElementNS namespace key = document##createElementNS namespace key - -let createComment text = document##createComment text - -let createTextNode text = document##createTextNode text - -let getElementById id = document##getElementById id - -let createElementNsOptional namespace tagName = - match namespace with - | "" -> document##createElement tagName - | ns -> document##createElementNS ns tagName - -let location () = document##location diff --git a/src-ocaml/web_event.ml b/src-ocaml/web_event.ml deleted file mode 100644 index 0cbe91a..0000000 --- a/src-ocaml/web_event.ml +++ /dev/null @@ -1,20 +0,0 @@ -(* type target = < - value : string Js.undefined [@bs.get]; -> Js.t *) - -type 'node t = < - target : 'node Js.undefined [@bs.get]; - keyCode : int [@bs.get]; - preventDefault : unit -> unit [@bs.meth]; - stopPropagation : unit -> unit [@bs.meth]; -> Js.t - -type 'node cb = 'node t -> unit [@bs] - -type options = bool (* false | true (* TODO: Define a javascript record as another option *) *) - - -type popstateEvent = < -> Js.t - -type popstateCb = popstateEvent -> unit [@bs] diff --git a/src-ocaml/web_formdata.ml b/src-ocaml/web_formdata.ml deleted file mode 100644 index 780a7c0..0000000 --- a/src-ocaml/web_formdata.ml +++ /dev/null @@ -1,10 +0,0 @@ - -class type _formdata = object - method append : string -> string -> unit - (* method append_blob : string -> Web_blob.t -> string -> unit *) -end [@bs] -type t = _formdata Js.t - -external create : unit -> t = "FormData" [@@bs.new] - -let append key value f = f##append key value diff --git a/src-ocaml/web_json.ml b/src-ocaml/web_json.ml deleted file mode 100644 index 5acacd4..0000000 --- a/src-ocaml/web_json.ml +++ /dev/null @@ -1,17 +0,0 @@ - -include Js.Json - -type nothingYet -external stringify : 't -> nothingYet Js.null -> int -> string = "JSON.stringify" [@@bs.val] - -let string_of_json ?(indent=2) value = - match Js.Undefined.toOption value with - | None -> "undefined" - | Some v -> - try stringify v Js.Null.empty indent - with _ -> "" - -let of_type (type a) (_v : a kind) (x : a) : t = - Obj.magic x - -let null : Js_types.null_val = Obj.magic Js.null diff --git a/src-ocaml/web_location.ml b/src-ocaml/web_location.ml deleted file mode 100644 index 958a882..0000000 --- a/src-ocaml/web_location.ml +++ /dev/null @@ -1,76 +0,0 @@ - - -type t = < - href : string [@bs.get] [@bs.set]; - protocol : string [@bs.get] [@bs.set]; - host : string [@bs.get] [@bs.set]; - hostname : string [@bs.get] [@bs.set]; - port : string [@bs.get] [@bs.set]; - pathname : string [@bs.get] [@bs.set]; - search : string [@bs.get] [@bs.set]; - hash : string [@bs.get] [@bs.set]; - username : string [@bs.get] [@bs.set]; - password : string [@bs.get] [@bs.set]; - origin : string [@bs.get]; -> Js.t - -let getHref location = location##href -let setHref location value = location##href #= value - -let getProtocol location = location##protocol -let setProtocol location value = location##protocol #= value - -let getHost location = location##host -let setHost location value = location##host #= value - -let getHostname location = location##hostname -let setHostname location value = location##hostname #= value - -let getPort location = location##port -let setPort location value = location##port #= value - -let getPathname location = location##pathname -let setPathname location value = location##pathname #= value - -let getSearch location = location##search -let setSearch location value = location##search #= value - -let getHash location = location##hash -let setHash location value = location##hash #= value - -let getUsername location = location##username -let setUsername location value = location##username #= value - -let getPassword location = location##password -let setPassword location value = location##password #= value - -let getOrigin location = location##origin - - -type location = - { href : string - ; protocol : string - ; host : string - ; hostname : string - ; port : string - ; pathname : string - ; search : string - ; hash : string - ; username : string - ; password : string - ; origin : string - } - -let asRecord location = - { href = location##href - ; protocol = location##protocol - ; host = location##host - ; hostname = location##hostname - ; port = location##port - ; pathname = location##pathname - ; search = location##search - ; hash = location##hash - ; username = location##username - ; password = location##password - ; origin = location##origin - } diff --git a/src-ocaml/web_node.ml b/src-ocaml/web_node.ml deleted file mode 100644 index 6cd8739..0000000 --- a/src-ocaml/web_node.ml +++ /dev/null @@ -1,116 +0,0 @@ - -type style = < - setProperty : Web_json.t Js.undefined [@bs.get]; (* TODO: Revamp this and the next line... *) - setProperty__ : string -> string Js.null -> string Js.null -> unit [@bs.meth]; - > Js.t - -external getStyle : style -> string -> string Js.null = "" [@@bs.get_index] - -external setStyle : style -> string -> string Js.null -> unit = "" [@@bs.set_index] - -type t = < - style : style [@bs.get]; - value : string Js.undefined [@bs.set] [@bs.get]; - checked : bool Js.undefined [@bs.set] [@bs.get]; - childNodes : t Js.Array.t [@bs.get]; - firstChild : t Js.Null.t [@bs.get]; - appendChild : t -> t [@bs.meth]; - removeChild : t -> t [@bs.meth]; - insertBefore : t -> t -> t [@bs.meth]; - remove : unit -> unit [@bs.meth]; - setAttributeNS : string -> string -> string -> unit [@bs.meth]; - setAttribute : string -> string -> unit [@bs.meth]; - removeAttributeNS : string -> string -> unit [@bs.meth]; - removeAttribute : string -> unit [@bs.meth]; - addEventListener : string -> t Web_event.cb -> Web_event.options -> unit [@bs.meth]; - removeEventListener : string -> t Web_event.cb -> Web_event.options -> unit [@bs.meth]; - focus : unit -> unit [@bs.meth]; - (* Text Nodes only *) - nodeValue : string [@bs.set] [@bs.get {null}]; -> Js.t - -external document_node : t = "document" [@@bs.val] - -type event = t Web_event.t - -type event_cb = t Web_event.cb - - -external getProp_asEventListener : t -> 'key -> t Web_event.cb Js.undefined = "" [@@bs.get_index] - -external setProp_asEventListener : t -> 'key -> t Web_event.cb Js.undefined -> unit = "" [@@bs.set_index] - -external getProp : t -> 'key -> 'value = "" [@@bs.get_index] - -external setProp : t -> 'key -> 'value -> unit = "" [@@bs.set_index] - -let style n = n##style - -let getStyle n key = getStyle n##style key - -let setStyle n key value = setStyle n##style key value - -let setStyleProperty n ?(priority=false) key value = - let style = n##style in - match Js.Undefined.toOption style##setProperty with - | None -> setStyle n key value (* TODO: Change this to setAttribute sometime, maybe... *) - | Some _valid -> style##setProperty__ key value (if priority then (Js.Null.return "important") else Js.Null.empty) - -let childNodes n = n##childNodes - -let firstChild n = n##firstChild - -let appendChild n child = n##appendChild child - -let removeChild n child = n##removeChild child - -let insertBefore n child refNode = n##insertBefore child refNode - -let remove n child = n##remove child - -let setAttributeNS n namespace key value = n##setAttributeNS namespace key value - -let setAttribute n key value = n##setAttribute key value - -let setAttributeNsOptional n namespace key value = - match namespace with - | "" -> n##setAttribute key value - | ns -> n##setAttributeNS ns key value - -let removeAttributeNS n namespace key = n##removeAttributeNS namespace key - -let removeAttribute n key = n##removeAttribute key - -let removeAttributeNsOptional n namespace key = - match namespace with - | "" -> n##removeAttribute key - | ns -> n##removeAttributeNS ns key - -let addEventListener n typ listener options = n##addEventListener typ listener options - -let removeEventListener n typ listener options = n##removeEventListener typ listener options - -let focus n = n##focus () - -(* Text Nodes only *) - -let set_nodeValue n text = n##nodeValue #= text - -let get_nodeValue n = n##nodeValue - - -(* Polyfills *) - -let remove_polyfill : unit -> unit = fun () -> - [%bs.raw{| - // remove polyfill - (function() { - if (!('remove' in Element.prototype)) { - Element.prototype.remove = function() { - if (this.parentNode) { - this.parentNode.removeChild(this); - } - }; - }; - }()) - |}] diff --git a/src-ocaml/web_window.ml b/src-ocaml/web_window.ml deleted file mode 100644 index dbb24e6..0000000 --- a/src-ocaml/web_window.ml +++ /dev/null @@ -1,78 +0,0 @@ - -(* TODO: Polyfill window if it is missing, like on node or in native *) - -module History = Web_window_history - -module LocalStorage = Web_window_localstorage - -type timeoutHandlerID = int - -type t = < - history : History.t Js.Undefined.t [@bs.get]; - location : Web_location.t [@bs.get]; - clearTimeout : timeoutHandlerID -> unit [@bs.meth]; - requestAnimationFrame : (float -> unit) -> int [@bs.meth]; - cancelAnimationFrame : int -> unit [@bs.meth]; - setInterval : (unit -> unit) -> float -> timeoutHandlerID [@bs.meth]; - setTimeout : (unit -> unit) -> float -> timeoutHandlerID [@bs.meth]; - addEventListener : string -> Web_node.t Web_event.cb -> Web_event.options -> unit [@bs.meth]; - removeEventListener : string -> Web_node.t Web_event.cb -> Web_event.options -> unit [@bs.meth]; - localStorage : LocalStorage.t Js.Undefined.t [@bs.get]; -> Js.t - -external window : t = "window" [@@bs.val] - - -let history () = window##history - -let localStorage () = window##localStorage - -let location () = window##location - -(* requestAnimationFrame callback is a float timestamp in milliseconds *) -let requestAnimationFrame callback = window##requestAnimationFrame callback - -let cancelAnimationFrame id = window##cancelAnimationFrame id - -let clearTimeout id = window##clearTimeout id - -let setInterval cb msTime = window##setInterval cb msTime - -let setTimeout cb msTime = window##setTimeout cb msTime - -let addEventListener typ listener options = window##addEventListener typ listener options - -let removeEventListener typ listener options = window##removeEventListener typ listener options - - - -(* Polyfills *) - -let requestAnimationFrame_polyfill : unit -> unit = fun () -> - [%bs.raw{| - // requestAnimationFrame polyfill - (function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] - || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - }()) - |}] diff --git a/src-ocaml/web_window_history.ml b/src-ocaml/web_window_history.ml deleted file mode 100644 index 8c59cca..0000000 --- a/src-ocaml/web_window_history.ml +++ /dev/null @@ -1,40 +0,0 @@ - - -type t = < - length : int [@bs.get]; - back : unit -> unit [@bs.meth]; - forward : unit -> unit [@bs.meth]; - go : int -> unit [@bs.meth]; - pushState : Js.Json.t -> string -> string -> unit [@bs.meth]; - replaceState : Js.Json.t -> string -> string -> unit [@bs.meth]; - state : Js.Json.t [@bs.get]; -> Js.t - - -let length window = match Js.Undefined.toOption window##history with - | None -> -1 - | Some history -> history##length - -let back window = match Js.Undefined.toOption window##history with - | None -> () - | Some history -> history##back - -let forward window = match Js.Undefined.toOption window##history with - | None -> () - | Some history -> history##forward - -let go window to' = match Js.Undefined.toOption window##history with - | None -> () - | Some history -> history##go to' - -let pushState window state title url = match Js.Undefined.toOption window##history with - | None -> () - | Some history -> history##pushState state title url - -let replaceState window state title url = match Js.Undefined.toOption window##history with - | None -> () - | Some history -> history##replaceState state title url - -let state window = match Js.Undefined.toOption window##history with - | None -> Js.Undefined.empty - | Some history -> history##state diff --git a/src-ocaml/web_window_localstorage.ml b/src-ocaml/web_window_localstorage.ml deleted file mode 100644 index 427ae07..0000000 --- a/src-ocaml/web_window_localstorage.ml +++ /dev/null @@ -1,41 +0,0 @@ - - -type t = < - length : int [@bs.get]; - clear : unit -> unit [@bs.meth]; - key : int -> string [@bs.meth]; - getItem : string -> string [@bs.meth]; - removeItem : string -> unit [@bs.meth]; - setItem : string -> string -> unit [@bs.meth]; -> Js.t - -let length window = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> Some (localStorage##length) - - -let clear window = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> Some (localStorage##clear ()) - - -let key window idx = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> Some (localStorage##key idx) - - -let getItem window key = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> - try Some (localStorage##getItem key) - with _ -> None - - -let removeItem window key = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> Some (localStorage##removeItem key) - - -let setItem window key value = match Js.Undefined.toOption window##localStorage with - | None -> None - | Some localStorage -> Some (localStorage##setItem key value) diff --git a/src-ocaml/web_xmlhttprequest.ml b/src-ocaml/web_xmlhttprequest.ml deleted file mode 100644 index d7f21b3..0000000 --- a/src-ocaml/web_xmlhttprequest.ml +++ /dev/null @@ -1,265 +0,0 @@ - -type unresolved - -type xmlHttpRequestUpload - -type event_readystatechange = Web_json.t -type event_abort = Web_json.t -type event_error = Web_json.t -type event_load = Web_json.t -type event_loadstart = Web_json.t -type event_progress = Web_json.t -type event_timeout = Web_json.t -type event_loadend = Web_json.t - -class type _xmlhttprequest = object - (* Methods *) - method abort : unit -> unit - method getAllResponseHeaders : unit -> string Js.null - method getResponseHeader : string -> string Js.null - method _open : string -> string -> bool -> string -> string -> unit - method overrideMimeType : string -> unit - method send : unit -> unit - method send__string : string Js.null -> unit - method send__formdata : Web_formdata.t -> unit - method send__document : Web_document.t -> unit - (* method send_blob : Web_blob.t -> unit *) - (* method send_arrayBufferView : Web_arraybuffer_view.t -> unit *) - method setRequestHeader : string -> string -> unit - - (* Properties *) - method onreadystatechange : (event_readystatechange -> unit) [@@bs.get] [@@bs.set] - method readyState : int [@@bs.get] - method responseType : string [@@bs.get] [@@bs.set] - method response : unresolved Js.null [@@bs.get] - method responseText : string [@@bs.get] - method responseURL : string [@@bs.get] - method responseXML : Web_document.t Js.null [@@bs.get] - method status : int [@@bs.get] - method statusText : string [@@bs.get] - method timeout : float [@@bs.get] [@@bs.set] - method upload : xmlHttpRequestUpload [@@bs.get] - method withCredentials : bool [@@bs.get] [@@bs.set] - - (* Base events *) - method onabort : (event_abort -> unit) [@@bs.get] [@@bs.set] - method onerror : (event_error -> unit) [@@bs.get] [@@bs.set] - method onload : (event_load -> unit) [@@bs.get] [@@bs.set] - method onloadstart : (event_loadstart -> unit) [@@bs.get] [@@bs.set] - method onprogress : (event_loadstart -> unit) [@@bs.get] [@@bs.set] - method ontimeout : (event_timeout -> unit) [@@bs.get] [@@bs.set] - method onloadend : (event_loadend -> unit) [@@bs.get] [@@bs.set] -end [@bs] -type t = _xmlhttprequest Js.t - -external create : unit -> t = "XMLHttpRequest" [@@bs.new] - -type errors = - | IncompleteResponse - | NetworkError - -type body = - | EmptyBody - | EmptyStringBody - | StringBody of string - | FormDataBody of Web_formdata.t - | FormListBody of (string * string) list - | DocumentBody of Web_document.t - (* | BlobBody of Web_blob.t *) - (* | ArrayBufferViewBody of Web_arraybuffer_view.t *) - -(* Main interface functions *) - -let abort (x: t) : unit = x##abort () - -let getAllResponseHeaders (x: t) : (string, errors) Tea_result.t = - let open Tea_result in - match Js.Null.toOption (x##getAllResponseHeaders ()) with - | None -> Error IncompleteResponse - | Some "" -> Error NetworkError - | Some s -> Ok s - -let getAllResponseHeadersAsList (x: t) : ((string * string) list, errors) Tea_result.t = - let open Tea_result in - match getAllResponseHeaders x with - | Error _ as err -> err - | Ok s -> Ok - ( s - |> Js.String.split "\r\n" - |> Array.map (Js.String.splitAtMost ": " ~limit:2) - |> Array.to_list - |> List.filter (fun a -> Array.length a == 2) - |> List.map - ( function - | [|key; value|] -> (key, value) - | _ -> failwith "Cannot happen, already checked length" - ) - ) - -let getAllResponseHeadersAsDict (x: t) : (string Map.Make(String).t, errors) Tea_result.t = - let module StringMap = Map.Make(String) in - match getAllResponseHeadersAsList x with - | Tea_result.Error _ as err -> err - | Tea_result.Ok l -> - let insert d (k, v) = StringMap.add k v d in - Tea_result.Ok (List.fold_left insert StringMap.empty l) - -let getResponseHeader key x = Js.Null.toOption (x##getResponse key) - -let open_ (method': string) (url: string) ?(async=true) ?(user="") ?(password="") x = - x##_open method' url async user password - -let overrideMimeType (mimetype: string) (x: t) : unit = - x##overrideMimeType mimetype - -let send (body: body) (x: t) : unit = - match body with - | EmptyBody -> x##send () - | EmptyStringBody -> x##send__string Js.Null.empty - | StringBody s -> x##send__string (Js.Null.return s) - | FormDataBody f -> x##send__formdata f - | FormListBody l -> - let form = - List.fold_left - (fun f (key, value) -> let () = Web_formdata.append key value f in f) - (Web_formdata.create ()) - l in - x##send__formdata form - | DocumentBody d -> x##send__document d - (* | BlobBody b -> x##send_blob b *) - (* | ArrayBufferViewBody a -> x##send_arrayBufferView a *) - -let setRequestHeader (header: string) (value: string) (x: t) = - x##setRequestHeader header value - - -(* Properties *) - -type state = - | Unsent - | Opened - | HeadersReceived - | Loading - | Done - -type responseType = - | StringResponseType - | ArrayBufferResponseType - | BlobResponseType - | DocumentResponseType - | JsonResponseType - | TextResponseType - | RawResponseType of string - -type responseBody = - | NoResponse - | StringResponse of string - | ArrayBufferResponse of unit - | BlobResponse of unit - | DocumentResponse of Web_document.t - | JsonResponse of Web_json.t - | TextResponse of string - | RawResponse of string * unit - -let set_onreadystatechange (cb: event_readystatechange -> unit) (x: t) : unit = - x##onreadystatechange #= cb - -let get_onreadystatechange (x: t) : (event_readystatechange -> unit) = - x##onreadystatechange - -let readyState (x: t) : state = - match x##readyState with - | 0 -> Unsent - | 1 -> Opened - | 2 -> HeadersReceived - | 3 -> Loading - | 4 -> Done - | i -> failwith ("Invalid return from 'readystate' of: " ^ string_of_int i) - -let set_responseType (typ: responseType) (x: t) : unit = - match typ with - | StringResponseType -> x##responseType #= "" - | ArrayBufferResponseType -> x##responseType #= "arraybuffer" - | BlobResponseType -> x##responseType #= "blob" - | DocumentResponseType -> x##responseType #= "document" - | JsonResponseType -> x##responseType #= "json" - | TextResponseType -> x##responseType #= "text" - | RawResponseType s -> x##responseType #= s - -let get_responseType (x: t) : responseType = - match x##responseType with - | "" -> StringResponseType - | "arraybuffer" -> ArrayBufferResponseType - | "blob" -> BlobResponseType - | "document" -> DocumentResponseType - | "json" -> JsonResponseType - | "text" -> TextResponseType - | s -> RawResponseType s - -let get_response (x: t) : responseBody = - match Js.Null.toOption x##response with - | None -> NoResponse - | Some resp -> - match get_responseType x with - | StringResponseType -> StringResponse (Obj.magic resp) - | ArrayBufferResponseType -> ArrayBufferResponse (Obj.magic resp) - | BlobResponseType -> BlobResponse (Obj.magic resp) - | DocumentResponseType -> DocumentResponse (Obj.magic resp) - | JsonResponseType -> JsonResponse (Obj.magic resp) - | TextResponseType -> TextResponse (Obj.magic resp) - | RawResponseType s -> RawResponse (s, Obj.magic resp) - -let get_responseText (x: t) : string = x##responseText - -let get_responseURL (x: t) : string = x##responseURL - -let get_responseXML (x: t) : Web_document.t option = - Js.Null.toOption x##responseXML - -let get_status (x: t) : int = x##status - -let get_statusText (x: t) : string = x##statusText - -let set_timeout (t: float) (x: t) : unit = - x##timeout #= t - -let get_timeout (x: t) : float = x##timeout - -let set_withCredentials (b: bool) (x: t) : unit = - x##withCredentials #= b - -let get_withCredentials (x: t) : bool = x##withCredentials - -let set_onabort (cb: event_abort -> unit) (x: t) : unit = - x##onabort #= cb - -let get_onabort (x: t) : (event_abort -> unit)= x##onabort - -let set_onerror (cb: event_error -> unit) (x: t) : unit = - x##onerror #= cb - -let get_onerror (x: t) : (event_error -> unit)= x##onerror - -let set_onload (cb: event_load -> unit) (x: t) : unit = x##onload #= cb - -let get_onload (x: t) : (event_load -> unit) = x##onload - -let set_onloadstart (cb: event_loadstart -> unit) (x: t) : unit = - x##onloadstart #= cb - -let get_onloadstart (x: t) : (event_loadstart -> unit) = x##onloadstart - -let set_onprogress (cb: event_loadstart -> unit) (x: t) : unit = - x##onprogress #= cb - -let get_onprogress (x: t) : (event_loadstart -> unit)= x##onprogress - -let set_ontimeout (cb: event_timeout -> unit) (x: t) : unit = - x##ontimeout #= cb - -let get_ontimeout (x: t) : (event_timeout -> unit) = x##ontimeout - -let set_onloadend (cb: event_loadend -> unit) (x: t) : unit = - x##onloadend #= cb - -let get_onloadend (x: t) : (event_loadend -> unit) = x##onloadend diff --git a/src-reason/tea.re b/src-reason/tea.re deleted file mode 100644 index a8da3d3..0000000 --- a/src-reason/tea.re +++ /dev/null @@ -1,36 +0,0 @@ -/* TODO: Remove this once Bucklescript upgrade to OCaml 4.03+ as that version include result */ -module Result = Tea_result; - -module Cmd = Tea_cmd; - -module Sub = Tea_sub; - -module App = Tea_app; - -module Debug = Tea_debug; - -module Html = Tea_html; - -module Html2 = Tea_html2; - -module Svg = Tea_svg; - -module Task = Tea_task; - -module Program = Tea_program; - -module Time = Tea_time; - -module Json = Tea_json; - -module Navigation = Tea_navigation; - -module Random = Tea_random; - -module AnimationFrame = Tea_animationframe; - -module Mouse = Tea_mouse; - -module Http = Tea_http; - -module Ex = Tea_ex; diff --git a/src-reason/tea_animationframe.re b/src-reason/tea_animationframe.re deleted file mode 100644 index 2cc851b..0000000 --- a/src-reason/tea_animationframe.re +++ /dev/null @@ -1,52 +0,0 @@ -type t = { - time: Tea_time.t, - delta: Tea_time.t, -}; - -let every = (~key="", tagger) => { - open Vdom; - let enableCall = callbacks => { - /* let () = Js.log ("rAF", "enable") in */ - let lastTime = ref(Web.Date.now()); - let id = ref(None); - let rec onFrame = _time => { - let time = Web.Date.now(); - switch (id^) { - | None => () - | Some(_i) => - let ret = { - time, - delta: - if (time < lastTime^) { - 0.0; - } else { - time -. lastTime^; - }, - }; - let () = lastTime := time; - let () = callbacks.enqueue(tagger(ret)); - switch (id^) { - | None => () - | Some(_stillActive) => - let () = id := Some(Web.Window.requestAnimationFrame(onFrame)); - (); - }; - }; - }; - let () = id := Some(Web.Window.requestAnimationFrame(onFrame)); - () => - switch (id^) { - | None => () - | Some(i) => - /* let () = Js.log ("rAF", "disable") in */ - let () = Web.Window.cancelAnimationFrame(i); - let () = id := None; - (); - }; - }; - Tea_sub.registration(key, enableCall); -}; - -let times = (~key="", tagger) => every(ev => tagger(~key, ev.time)); - -let diffs = (~key="", tagger) => every(ev => tagger(~key, ev.delta)); diff --git a/src-reason/tea_app.re b/src-reason/tea_app.re deleted file mode 100644 index 20224dc..0000000 --- a/src-reason/tea_app.re +++ /dev/null @@ -1,497 +0,0 @@ -/* "OAK-TEA" Maybe? For OCaml Application Kernal TEA */ - -/* TODO: Create a new program interface to make the program type just handle init/update/shutdown and such interface - functionality. Top level should just be a model change handler, what is currently 'view', and multiple programs - that can update their own part of the model, of which the entirety can be accessed by view. Probably should be in a - Tea.AppEx package or something. Unsure how to work with compatability with Tea.App, perhaps have Tea.App delegate to - Tea.AppEx or so as a simple wrapper? */ - -/* module type Program = sig - type flags - type model - type msg - val init : flags -> model - val update : model -> msg -> model * 'msg Tea_cmd.t - val subscriptions : model -> int - (* val view : model -> msg Vdom.t *) - end */ - -/* type 'flags 'model testRec = { - init : 'flags -> 'model - } */ - -/* type ('flags, 'model, 'msg) fullProgram = { - internal : unit -> unit; - init : 'flags -> 'model * 'msg Tea_cmd.t; - update : 'model -> 'msg -> 'model * 'msg Tea_cmd.t; - view : 'model -> 'msg Vdom.t; - } */ - -type program('flags, 'model, 'msg) = { - init: 'flags => ('model, Tea_cmd.t('msg)), - update: ('model, 'msg) => ('model, Tea_cmd.t('msg)), - view: 'model => Vdom.t('msg), - subscriptions: 'model => Tea_sub.t('msg), - shutdown: 'model => Tea_cmd.t('msg), -}; - -type standardProgram('flags, 'model, 'msg) = { - init: 'flags => ('model, Tea_cmd.t('msg)), - update: ('model, 'msg) => ('model, Tea_cmd.t('msg)), - view: 'model => Vdom.t('msg), - subscriptions: 'model => Tea_sub.t('msg), -}; - -type beginnerProgram('model, 'msg) = { - model: 'model, - update: ('model, 'msg) => 'model, - view: 'model => Vdom.t('msg), -}; - -type pumpInterface('model, 'msg) = { - startup: unit => unit, - render_string: 'model => string, - handleMsg: ('model, 'msg) => 'model, - shutdown: Tea_cmd.t('msg) => unit, -}; - -type programInterface('msg) = { - . - "pushMsg": 'msg => unit, - "shutdown": unit => unit, - "getHtmlString": unit => string, -}; - -[@bs.obj] -external makeProgramInterface: - ( - ~pushMsg: 'msg => unit, - ~shutdown: unit => unit, - ~getHtmlString: unit => string - ) => - programInterface('msg); - -/* TODO: Need to refactor the program layers to layer everything properly, things are a bit mixed up right now... */ - -/* let programStateWrapper initModel pump = - let model = ref initModel in - let rec handler msg = - let newModel = pump !model msg in - (model := newModel) in - handler */ - -let programStateWrapper = (initModel, pump, shutdown) => { - /* let programStateWrapper : 'model -> ('msg Vdom.applicationCallbacks ref -> 'model -> 'msg) -> ('msg -> unit) = fun initModel pump -> */ - /* let programStateWrapper : 'model -> ('msg Vdom.applicationCallbacks ref -> 'model -> 'msg -> 'model) -> 'msg programInterface = fun initModel pump -> */ - open Vdom; - let model = ref(initModel); - let callbacks = - ref({enqueue: _msg => Js.log("INVALID enqueue CALL!"), on: _ => ()}); - let pumperInterfaceC = () => pump(callbacks); - let pumperInterface = pumperInterfaceC(); - /* let handler = function - | None -> () - | Some msg -> - let newModel = pumper !model msg in - let () = (model := newModel) in - () in */ - let pending: ref(option(list('msg))) = ( - ref(None): ref(option(list('msg))) - ); - let rec handler = msg => - switch (pending^) { - | None => - let () = pending := Some([]); - /* let () = Js.log ("APP", "mainloop", "pre", !model) in */ - let newModel = pumperInterface.handleMsg(model^, msg); - /* let () = Js.log ("APP", "mainloop", "post", newModel) in */ - let () = model := newModel; - switch (pending^) { - | None => - failwith( - "INVALID message queue state, should never be None during message processing!", - ) - | Some([]) => pending := None - | Some(msgs) => - let () = pending := None; - List.iter(handler, List.rev(msgs)); - }; - | Some(msgs) => pending := Some([msg, ...msgs]) - }; - let render_events = ref([]); - let finalizedCBs: Vdom.applicationCallbacks('msg) = ( - { - enqueue: msg => handler(msg), - on: - fun - | Render => List.iter(handler, render_events^) - | AddRenderMsg(msg) => - render_events := List.append(render_events^, [msg]) - | RemoveRenderMsg(msg) => - render_events := List.filter(mg => msg !== mg, render_events^), - }: - Vdom.applicationCallbacks('msg) - ); - let () = callbacks := finalizedCBs; - let pi_requestShutdown = () => { - let () = - callbacks := - { - enqueue: _msg => Js.log("INVALID message enqueued when shut down"), - on: _ => (), - }; - let cmd = shutdown(model^); - let () = pumperInterface.shutdown(cmd); - (); - }; - let render_string = () => { - let rendered = pumperInterface.render_string(model^); - rendered; - }; - let () = pumperInterface.startup(); - makeProgramInterface( - ~pushMsg=handler, - ~shutdown=pi_requestShutdown, - ~getHtmlString=render_string, - ); -}; - -let programLoop = (update, view, subscriptions, initModel, initCmd) => - fun - | None => ( - callbacks => { - let oldSub = ref(Tea_sub.none); - let handleSubscriptionChange = model => { - /* let open Vdom in */ - let newSub = subscriptions(model); - oldSub := Tea_sub.run(callbacks, callbacks, oldSub^, newSub); - }; - { - startup: () => { - let () = Tea_cmd.run(callbacks, initCmd); - let () = handleSubscriptionChange(initModel); - (); - }, - render_string: model => { - let vdom = view(model); - let rendered = Vdom.renderToHtmlString(vdom); - rendered; - }, - handleMsg: (model, msg) => { - let (newModel, cmd) = update(model, msg); - /* let open Vdom in */ - let () = Tea_cmd.run(callbacks, cmd); - let () = handleSubscriptionChange(newModel); - newModel; - }, - shutdown: cmd => { - let () = Tea_cmd.run(callbacks, cmd); /* TODO: Perhaps add cancelable commands? */ - let () = - oldSub := - Tea_sub.run(callbacks, callbacks, oldSub^, Tea_sub.none); - (); - }, - }; - } - ) - | Some(parentNode) => ( - callbacks => { - /* let priorRenderedVdom = ref [view initModel] in */ - let priorRenderedVdom = ref([]); - /* let lastVdom = ref (!priorRenderedVdom) in */ - let latestModel = ref(initModel); - let nextFrameID = ref(None); - let doRender = _delta => - switch (nextFrameID^) { - | None => () /* The render has been canceled, possibly by shutting down, do nothing */ - | Some(_id) => - let newVdom = [view(latestModel^)]; - let justRenderedVdom = - Vdom.patchVNodesIntoElement( - callbacks, - parentNode, - priorRenderedVdom^, - newVdom, - ); - let () = priorRenderedVdom := justRenderedVdom; - let () = callbacks^.on(Render); - nextFrameID := None; - }; - let scheduleRender = () => - switch (nextFrameID^) { - | Some(_) => () /* A frame is already scheduled, nothing to do */ - | None => - /* Use requestAnimationFrame unless we're trying to benchmark, in which case we use real-time rendering */ - let realtimeRendering = false; - if (realtimeRendering) { - let () = nextFrameID := Some(-1); - doRender(16); - } else { - let id = Web.Window.requestAnimationFrame(doRender); - let () = nextFrameID := Some(id); - (); - }; - }; - - /* let () = Js.log (Vdom.createVNodeIntoElement callbacks !lastVdom parentNode) in */ - /* We own the passed in node, clear it out TODO: Clear it out properly */ - /* let () = Js.log ("Blah", Web.Node.firstChild parentNode, Js.Null.test (Web.Node.firstChild parentNode), false, true) in */ - let clearPnode = () => - while (Js.Array.length(Web.Node.childNodes(parentNode)) > 0) { - switch (Js.Null.toOption(Web.Node.firstChild(parentNode))) { - | None => () - | Some(firstChild) => - let _removedChild = - Web.Node.removeChild(parentNode, firstChild); - (); - }; - }; - /* let () = Vdom.patchVNodesIntoElement callbacks parentNode [] (!lastVdom) in */ - /* let () = Vdom.patchVNodesIntoElement callbacks parentNode [] (!priorRenderedVdom) in */ - /* Initial render */ - let oldSub = ref(Tea_sub.none); - let handleSubscriptionChange = model => { - /* let open Vdom in */ - let newSub = subscriptions(model); - oldSub := Tea_sub.run(callbacks, callbacks, oldSub^, newSub); - }; - let handlerStartup = () => { - let () = clearPnode(); - let () = Tea_cmd.run(callbacks, initCmd); - let () = handleSubscriptionChange(latestModel^); - let () = nextFrameID := Some(-1); - let () = doRender(16); - (); - }; - let render_string = model => { - let vdom = view(model); - let rendered = Vdom.renderToHtmlString(vdom); - rendered; - }; - let handler = (model, msg) => { - let (newModel, cmd) = update(model, msg); - let () = latestModel := newModel; - /* let open Vdom in */ - /* let () = Js.log ("APP", "latestModel", "precmd", !latestModel) in */ - let () = Tea_cmd.run(callbacks, cmd); - /* let () = Js.log ("APP", "latestModel", "postcmd", !latestModel) in */ - /* TODO: Figure out if it is better to get view on update like here, or do it in doRender... */ - /* let newVdom = view newModel in (* Process VDom diffs here with callbacks *) */ - /* let () = Vdom.patchVNodeIntoElement callbacks parentNode !lastVdom newVdom in */ - /* let () = Js.log lastVdom in */ - /* let () = Js.log newVdom in */ - /* let () = Js.log (Vdom.createVNodeIntoElement callbacks newVdom parentNode) in */ - /* let () = lastVdom := [newVdom] in */ - let () = scheduleRender(); - /* let () = Js.log ("APP", "latestModel", "presub", !latestModel) in */ - let () = handleSubscriptionChange(newModel); - /* let () = Js.log ("APP", "latestModel", "postsub", !latestModel) in */ - newModel; - }; - let handlerShutdown = cmd => { - /* let open Vdom in */ - let () = nextFrameID := None; - let () = Tea_cmd.run(callbacks, cmd); - let () = - oldSub := Tea_sub.run(callbacks, callbacks, oldSub^, Tea_sub.none); - let () = priorRenderedVdom := []; - let () = clearPnode(); - (); - }; - { - startup: handlerStartup, - render_string, - handleMsg: handler, - shutdown: handlerShutdown, - }; - } - ); - -let program: - (program('flags, 'model, 'msg), Js.null_undefined(Web.Node.t), 'flags) => - programInterface('msg) = ( - ({init, update, view, subscriptions, shutdown}, pnode, flags) => { - let () = Web.polyfills(); - let (initModel, initCmd) = init(flags); - let opnode = Js.Nullable.toOption(pnode); - let pumpInterface = - programLoop(update, view, subscriptions, initModel, initCmd, opnode); - programStateWrapper(initModel, pumpInterface, shutdown); - }: - (program('flags, 'model, 'msg), Js.null_undefined(Web.Node.t), 'flags) => - programInterface('msg) -); - -let standardProgram: - ( - standardProgram('flags, 'model, 'msg), - Js.null_undefined(Web.Node.t), - 'flags - ) => - programInterface('msg) = ( - ({init, update, view, subscriptions}, pnode, args) => - program( - {init, update, view, subscriptions, shutdown: _model => Tea_cmd.none}, - pnode, - args, - ): - ( - standardProgram('flags, 'model, 'msg), - Js.null_undefined(Web.Node.t), - 'flags - ) => - programInterface('msg) -); - -let beginnerProgram: - (beginnerProgram('model, 'msg), Js.null_undefined(Web.Node.t), unit) => - programInterface('msg) = ( - ({model, update, view}, pnode, ()) => - standardProgram( - { - init: () => (model, Tea_cmd.none), - update: (model, msg) => (update(model, msg), Tea_cmd.none), - view, - subscriptions: _model => Tea_sub.none, - }, - pnode, - (), - ): - (beginnerProgram('model, 'msg), Js.null_undefined(Web.Node.t), unit) => - programInterface('msg) -); - -let map = (func, vnode) => Vdom.map(func, vnode); - -/* let fullProgram program pnode flags = - match Js.Nullable.toOption pnode with - | None -> Web.Document.body () - | Some parentNode -> parentNode */ - -/* class fullProgramClass {internal; init; update; view} pnode flags = object(self) */ -/* class ['msg, 'model] fullProgramClass - (msgHandler : 'model -> 'msg -> 'model * 'msg Tea_cmd.t) - (initModel : 'model) - (initCmd : 'msg Tea_cmd.t) - (view : 'model -> 'msg Vdom.t) - pnode = - object(self) - val mutable model = initModel - val mutable lastView = view initModel - - initializer - Js.log initCmd - - method update (msg : 'msg) = - let (newModel, newCmd) = msgHandler model msg in - model <- newModel; - cmd <- newCmd - end */ - -/* let programStateWrapperInit initModel = - ref initModel - - let programStateWrapper model pump = - let rec handler msg = - let newModel = pump handler !model msg in - (model := newModel) in - handler - - - - let programLoopInit msgHandler view model = function - | None -> None - | Some parentNode -> - let vdom = view model in - let () = Js.log (Vdom.createVNodesIntoElement msgHandler [vdom] parentNode) in - let rvdom = ref vdom in - Some (parentNode, rvdom) - - let programLoop = function - | None -> fun update _view _initModel msgHandler model msg -> - let newModel, _newCmd = update model msg in (* TODO: Process commands to msgHandler *) - newModel - | Some (parentNode, lastVdom) -> fun update view initModel msgHandler -> - let handler model msg = - let newModel, _newCmd = update model msg in (* TODO: Process commands to msgHandler *) - let newVdom = view newModel in (* Process VDom diffs here with msgHandler *) - (* let () = Js.log lastVdom in *) - (* let () = Js.log newVdom in *) - (lastVdom := newVdom); - newModel in - handler - - - let program {init; update; view} pnode flags = - let initModel, initCmd = init flags in - let opnode = Js.Nullable.toOption pnode in - let modelState = programStateWrapperInit initModel in - let rec viewState msgHandler = programLoopInit msgHandler view initModel opnode - and pump_unfixed msgHandler = programLoop viewState update view initModel msgHandler in - (* let rec pump model msg = programLoop opnode update view initModel msgHandler model msg *) - let rec msgHandler msg = programStateWrapper modelState (pump_unfixed msgHandler) msg in - fun msg -> msgHandler msg */ - -/* new fullProgramClass - update - initModel - initCmds - view - (Js.Nullable.toOption pnode) */ - -/* { - internal = (fun () -> Js.log "internal update"); - init = init; - update = update; - view = view; - } (Js.Nullable.toOption pnode) flags */ - -/* match Js.Nullable.toOption pnode with - | None -> Web.Document.body () - | Some parentNode -> parentNode */ - -/* let beginnerProgram program = function - | None -> Js.log 42 - | Some parentNode -> Js.log 84 */ - -/* let beginnerProgram program pnode = match Js.Nullable.toOption pnode with - | None -> Web.Document.body () - | Some node -> node */ - -/* let beginnerPrograms pnode = match Js.Nullable.toOption pnode with - | None -> Web.Document.body () - | Some node -> Web.Node.style node */ - -/* - module type ProgramState = sig - end - - module MakeProgram (Prog : Program) : ProgramState = struct - (* module Program = Prog *) - end - - let makeProgram p = - let module P = (val p : Program) in - (module struct - let x = P.init - let y = 42 - end : ProgramState) - - - module type Main = sig - end - - module type App = sig - end - - (* - module Make (Prog : Program) : App = struct - (* let x = M.x + 1 *) - end *) - - module Make (MainProg : Main) : App = struct - (* let x = M.x + 1 *) - end - - (* let programWithFlags (module Prog : Program) = - 42 *) */ diff --git a/src-reason/tea_cmd.re b/src-reason/tea_cmd.re deleted file mode 100644 index 7f10ff4..0000000 --- a/src-reason/tea_cmd.re +++ /dev/null @@ -1,49 +0,0 @@ -type applicationCallbacks('msg) = Vdom.applicationCallbacks('msg); - -type t('msg) = - | NoCmd: t(_) - | Mapper( - ref(Vdom.applicationCallbacks('msg)) => - ref(Vdom.applicationCallbacks('msgB)), - t('msgB), - ) - : t('msg) - | Batch(list(t('msg))): t('msg) - | EnqueueCall(ref(applicationCallbacks('msg)) => unit): t('msg); - -let none = NoCmd; - -let batch = cmds => Batch(cmds); - -let call = call => EnqueueCall(call); - -let fnMsg = fnMsg => - Vdom.(EnqueueCall(callbacks => callbacks^.enqueue(fnMsg()))); - -let msg = msg => Vdom.(EnqueueCall(callbacks => callbacks^.enqueue(msg))); - -let rec run: type msg. (ref(applicationCallbacks(msg)), t(msg)) => unit = - callbacks => - fun - | NoCmd => () - | [@implicit_arity] Mapper(mapper, cmd) => { - let subCallbacks = mapper(callbacks); - run(subCallbacks, cmd); - } - | Batch(cmds) => - List.fold_left(((), cmd) => run(callbacks, cmd), (), cmds) - | EnqueueCall(cb) => - /* let () = Js.log ("Cmd.run", "enqueue", cb) in */ - cb(callbacks); - -/* let wrapCallbacks func callbacks = */ -/* let open Vdom in */ -/* ref */ -/* { enqueue = (fun msg -> !callbacks.enqueue (func msg)) */ -/* } */ - -let map: type a b. (a => b, t(a)) => t(b) = - (func, cmd) => { - let mapper = Vdom.wrapCallbacks(func); - [@implicit_arity] Mapper(mapper, cmd); - }; diff --git a/src-reason/tea_debug.re b/src-reason/tea_debug.re deleted file mode 100644 index 77057dd..0000000 --- a/src-reason/tea_debug.re +++ /dev/null @@ -1,572 +0,0 @@ -type debug_msg('msg) = - | ClientMsg('msg) - | TogglePaused - | SelectHistoryItem(int) - | ToggleDetails; -let client_msg = msg => ClientMsg(msg); - -type state = - | Running - | Paused(int); - -type debug_model('model) = { - history: list((string, 'model)), - state, - show_details: bool, -}; - -let debug = - ( - string_of_msg: 'msg => string, - update: ('model, 'msg) => ('model, Tea_cmd.t('msg)), - view: 'model => Vdom.t('msg), - subscriptions: 'model => Tea_sub.t('msg), - shutdown: 'model => Tea_cmd.t('msg), - ) - : ( - (('model, Tea_cmd.t('msg))) => - (debug_model('model), Tea_cmd.t(debug_msg('msg))), - (debug_model('model), debug_msg('msg)) => - (debug_model('model), Tea_cmd.t(debug_msg('msg))), - debug_model('model) => Vdom.t(debug_msg('msg)), - debug_model('model) => Tea_sub.t(debug_msg('msg)), - debug_model('model) => Tea_cmd.t(debug_msg('msg)), - ) => { - let init_debug = ((cmodel, cmd)) => ( - {history: [("_init_", cmodel)], state: Running, show_details: false}, - cmd |> Tea_cmd.map(client_msg), - ); - - let update' = model => - fun - | ClientMsg(msg) => - if (model.state == Running) { - let (_, cmodel) = List.hd(model.history); - let (cmodel', cmd) = update(cmodel, msg); - let dmodel' = { - ...model, - history: [(string_of_msg(msg), cmodel'), ...model.history], - }; - (dmodel', cmd |> Tea_cmd.map(client_msg)); - } else { - (model, Tea_cmd.none); - } - | TogglePaused => - switch (model.state) { - | Paused(_) => ({...model, state: Running}, Tea_cmd.none) - | Running => ({...model, state: Paused(0)}, Tea_cmd.none) - } - | SelectHistoryItem(i) => ({...model, state: Paused(i)}, Tea_cmd.none) - | ToggleDetails => ( - {...model, show_details: !model.show_details}, - Tea_cmd.none, - ); - - let view_styles = () => { - open Tea_html2; - let rule = (selector, properties) => - properties - |> List.map(((k, v)) => k ++ ":" ++ v) - |> String.concat(";") - |> (x => {j|$(selector) {$(x)}|j}) - |> text; - - node( - "style", - [], - [ - rule( - "#debug.paused", - [ - ("position", "fixed"), - ("top", "0"), - ("left", "0"), - ("width", "100%"), - ("height", "100%"), - ("pointer-events", "all"), - ("background-color", "rgba(0,0,0,.1)"), - ("box-shadow", "inset 0 0 10px #333"), - ], - ), - rule( - "#debug nav", - [ - ("position", "fixed"), - ("max-width", "50%"), - ("bottom", "0"), - ("right", "6px"), - ("border-radius", "4px 4px 0 0"), - ("background-color", "#444"), - ("color", "#fff"), - ("font-family", "monospace"), - ("box-shadow", "0 0 10px #333"), - ], - ), - rule( - "#debug.paused nav", - [("height", "50%"), ("padding-bottom", "2em")], - ), - rule( - "#debug nav .toggle", - [ - ("padding", "6px"), - ("padding-left", "9px"), - ("cursor", "pointer"), - ("min-width", "24ch"), - ("text-align", "center"), - ("border-left", "3px solid #333"), - ("border-radius", "4px 4px 0 0"), - ], - ), - rule( - "#debug nav .toggle:before", - [ - ("content", "' '"), - ("position", "absolute"), - ("left", "0"), - ("top", "0"), - ("width", ".5ch"), - ("height", "1.8ch"), - ("margin", "1.2ch"), - ("border", "solid #fff"), - ("border-width", "0 .5ch"), - ], - ), - rule( - "#debug.paused nav .toggle:before", - [ - ("border-color", "transparent"), - ("border-left-color", "#fff"), - ("border-width", "1ch"), - ("width", "0"), - ("height", "0"), - ], - ), - rule( - "#debug nav .history", - [ - ("margin", "0"), - ("padding", "0"), - ("height", "100%"), - ("overflow-y", "auto"), - ("list-style", "none"), - ], - ), - rule( - "#debug nav .history li", - [ - ("margin", "0"), - ("padding", "0.2ch"), - ("border-left", "3px solid #333"), - ], - ), - rule( - "#debug nav .history li.selected", - [("background-color", "#333")], - ), - rule( - "#debug nav .history span.details", - [ - ("display", "inline-block"), - ("cursor", "pointer"), - ("width", "1ch"), - ("margin", "0 1ch"), - ("vertical-align", "super"), - ], - ), - rule( - "#debug nav .history li.selected span.details:after", - [("content", "'\\2026'")], - ), - rule( - "#debug nav .history li.selected.show", - [("border-left", "3px solid white")], - ), - rule( - "#debug nav .history span.message", - [ - ("display", "inline-block"), - ("cursor", "pointer"), - ("white-space", "nowrap"), - ("overflow", "hidden"), - ("text-overflow", "ellipsis"), - ("width", "calc(100% - 75px)"), - ], - ), - rule( - "#debug nav .history span.index", - [ - ("display", "inline-block"), - ("min-width", "3ch"), - ("margin", "0 1ch"), - ("color", "#aaa"), - ("text-align", "right"), - ("float", "right"), - ], - ), - rule( - "#debug aside.details", - [ - ("position", "absolute"), - ("width", "40ch"), - ("top", "0"), - ("bottom", "0"), - ("right", "100%"), - ("margin-right", "1.5ch"), - ("overflow", "scroll"), - ("background-color", "#fff"), - ("color", "#000"), - ("box-shadow", "0 0 10px #333"), - ("border-radius", "4px 4px 0 0"), - ("border", "2px solid #333"), - ("padding", "1ch"), - ("white-space", "pre"), - ], - ), - ], - ); - }; - - let view_details = model => { - open Tea_html2; - module A = Tea_html2.Attributes; - let format = [%raw - {| - function (v) { - var formatRecord = function (data, labels) { - return data.reduce( - function (acc, cur, index) { - acc[labels[index]] = formatValue(cur) - return acc - }, {}) - } - var listToArray = function (data) { - var result = [] - var cur = data - while (typeof cur !== "number") { - result.push(formatValue(cur[0])) - cur = cur[1] - } - return result - } - var formatVariant = function (data, recordVariant) { - if (recordVariant === "::") { - return listToArray(data) - } - else { - return formatRecord(data, [recordVariant]) - } - } - var formatValue = function (x) { - var recordLabels, recordVariant, recordModule, recordPolyVar - if (x == null) { - return null - } - else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { - return formatRecord(x, recordLabels) - } - else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { - return formatRecord(x, recordModule) - } - else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { - return formatVariant(x, recordVariant) - } - else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { - return x[1] - } - else if (Array.isArray(x)) { - // tuple - return x.map(formatValue) - } - else { - // scalar - return x - } - } - return JSON.stringify(formatValue(v), null, 2); - } - |} - ]; - aside([A.class'("details")], [model |> format |> text]); - }; - - let view_history = (model, selected_index) => { - open Tea_html2; - module A = Tea_html2.Attributes; - module E = Tea_html2.Events; - let count = List.length(model.history); - ul([A.class'("history")]) @@ - List.mapi( - (i, (msg, cmodel)) => { - let selected = i == selected_index; - li( - [ - E.onClick(SelectHistoryItem(i)), - A.classList([ - ("selected", selected), - ("show", selected && model.show_details), - ]), - ], - [ - span( - [ - A.classList([("details", true), ("show", true)]), - ...if (selected) { - [E.onClick(ToggleDetails), A.title("toggle details")]; - } else { - [A.noProp, A.noProp]; - }, - ], - [ - if (selected && model.show_details) { - view_details(cmodel); - } else { - noNode; - }, - ], - ), - span([A.class'("message")], [text(msg)]), - span( - [A.class'("index")], - [count - i |> string_of_int |> text], - ), - ], - ); - }, - model.history, - ); - }; - - let view' = model => { - open Tea_html2; - module A = Tea_html2.Attributes; - module E = Tea_html2.Events; - let (selected_index, selected_model, paused) = - switch (model.state) { - | Running => (0, List.hd(model.history) |> snd, false) - | Paused(index) => ( - index, - List.nth(model.history, index) |> snd, - true, - ) - }; - - let history_count = List.length(model.history); - div( - [], - [ - view(selected_model) |> Tea_app.map(client_msg), - div( - [A.id("debug"), A.classList([("paused", paused)])], - [ - view_styles(), - nav( - [], - [ - div( - [ - A.class'("toggle"), - E.onClick(TogglePaused), - if (paused) { - A.title("click to resume"); - } else { - A.title("click to pause"); - }, - ], - [{j|Explore History ($(history_count))|j} |> text], - ), - if (paused) { - view_history(model, selected_index); - } else { - noNode; - }, - ], - ), - ], - ), - ], - ); - }; - - let subscriptions' = model => - model.history - |> List.hd - |> snd - |> subscriptions - |> Tea_sub.map(client_msg); - - let shutdown' = model => - model.history |> List.hd |> snd |> shutdown |> Tea_cmd.map(client_msg); - - (init_debug, update', view', subscriptions', shutdown'); -}; - -let debug_program: - ('msg => string, Tea_app.program('flags, 'model, 'msg)) => - Tea_app.program('flags, debug_model('model), debug_msg('msg)) = ( - (string_of_msg, {init, update, view, subscriptions, shutdown}) => { - let (init_debug, update', view', subscriptions', shutdown') = - debug(string_of_msg, update, view, subscriptions, shutdown); - - { - init: flags => init(flags) |> init_debug, - update: update', - view: view', - subscriptions: subscriptions', - shutdown: shutdown', - }; - }: - ('msg => string, Tea_app.program('flags, 'model, 'msg)) => - Tea_app.program('flags, debug_model('model), debug_msg('msg)) -); - -let debug_navigation_program: - ('msg => string, Tea_navigation.navigationProgram('flags, 'model, 'msg)) => - Tea_navigation.navigationProgram( - 'flags, - debug_model('model), - debug_msg('msg), - ) = ( - (string_of_msg, {init, update, view, subscriptions, shutdown}) => { - let (init_debug, update', view', subscriptions', shutdown') = - debug(string_of_msg, update, view, subscriptions, shutdown); - - { - init: (flags, location) => init(flags, location) |> init_debug, - update: update', - view: view', - subscriptions: subscriptions', - shutdown: shutdown', - }; - }: - ( - 'msg => string, - Tea_navigation.navigationProgram('flags, 'model, 'msg) - ) => - Tea_navigation.navigationProgram( - 'flags, - debug_model('model), - debug_msg('msg), - ) -); - -let beginnerProgram: - ( - Tea_app.beginnerProgram('model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - unit - ) => - Tea_app.programInterface(debug_msg('msg)) = ( - ({model, update, view}, string_of_msg, pnode, flags) => { - let debugged = - debug_program( - string_of_msg, - { - init: () => (model, Tea_cmd.none), - update: (model, msg) => (update(model, msg), Tea_cmd.none), - view, - subscriptions: _model => Tea_sub.none, - shutdown: _model => Tea_cmd.none, - }, - ); - Tea_app.program(debugged, pnode, flags); - }: - ( - Tea_app.beginnerProgram('model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - unit - ) => - Tea_app.programInterface(debug_msg('msg)) -); - -let standardProgram: - ( - Tea_app.standardProgram('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) = ( - ({init, update, view, subscriptions}, string_of_msg, pnode, flags) => { - let debugged = - debug_program( - string_of_msg, - {init, update, view, subscriptions, shutdown: _model => Tea_cmd.none}, - ); - Tea_app.program(debugged, pnode, flags); - }: - ( - Tea_app.standardProgram('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) -); - -let program: - ( - Tea_app.program('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) = ( - ( - {init, update, view, subscriptions, shutdown}, - string_of_msg, - pnode, - flags, - ) => { - let debugged = - debug_program( - string_of_msg, - {init, update, view, subscriptions, shutdown}, - ); - Tea_app.program(debugged, pnode, flags); - }: - ( - Tea_app.program('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) -); - -let navigationProgram: - ( - Web.Location.location => 'msg, - Tea_navigation.navigationProgram('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) = ( - ( - location_to_msg, - {init, update, view, subscriptions, shutdown}, - string_of_msg, - pnode, - flags, - ) => { - let location = location => location |> location_to_msg |> client_msg; - - let debugged = - debug_navigation_program( - string_of_msg, - {init, update, view, subscriptions, shutdown}, - ); - Tea_navigation.navigationProgram(location, debugged, pnode, flags); - }: - ( - Web.Location.location => 'msg, - Tea_navigation.navigationProgram('flags, 'model, 'msg), - 'msg => string, - Js.null_undefined(Web.Node.t), - 'flags - ) => - Tea_app.programInterface(debug_msg('msg)) -); diff --git a/src-reason/tea_ex.re b/src-reason/tea_ex.re deleted file mode 100644 index 5b20897..0000000 --- a/src-reason/tea_ex.re +++ /dev/null @@ -1,67 +0,0 @@ -/* Everything here is not in Elm and is purely used as an extension and may vanish at any time if a better API comes out. */ - -let render_event = (~key="", msg) => { - open Vdom; - let enableCall = callbacks => { - let () = callbacks.on(AddRenderMsg(msg)); - () => callbacks.on(RemoveRenderMsg(msg)); - }; - Tea_sub.registration(key, enableCall); -}; - -module LocalStorage = { - open Tea_task; - open Tea_result; - - let length = - nativeBinding(cb => - switch (Web.Window.LocalStorage.length(Web.Window.window)) { - | None => cb(Error("localStorage is not available")) - | Some(value) => cb(Ok(value)) - } - ); - - let clear = - nativeBinding(cb => - switch (Web.Window.LocalStorage.clear(Web.Window.window)) { - | None => cb(Error("localStorage is not available")) - | Some(value) => cb(Ok(value)) - } - ); - let clearCmd = () => Tea_task.attemptOpt(_ => None, clear); - - let key = idx => - nativeBinding(cb => - switch (Web.Window.LocalStorage.key(Web.Window.window, idx)) { - | None => cb(Error("localStorage is not available")) - | Some(value) => cb(Ok(value)) - } - ); - - let getItem = key => - nativeBinding(cb => - switch (Web.Window.LocalStorage.getItem(Web.Window.window, key)) { - | None => cb(Error("localStorage is not available")) - | Some(value) => cb(Ok(value)) - } - ); - - let removeItem = key => - nativeBinding(cb => - switch (Web.Window.LocalStorage.removeItem(Web.Window.window, key)) { - | None => cb(Error("localStorage is not available")) - | Some(value) => cb(Ok(value)) - } - ); - let removeItemCmd = key => Tea_task.attemptOpt(_ => None, removeItem(key)); - - let setItem = (key, value) => - nativeBinding(cb => - switch (Web.Window.LocalStorage.setItem(Web.Window.window, key, value)) { - | None => cb(Error("localStorage is not available")) - | Some () => cb(Ok()) - } - ); - let setItemCmd = (key, value) => - Tea_task.attemptOpt(_ => None, setItem(key, value)); -}; diff --git a/src-reason/tea_html.re b/src-reason/tea_html.re deleted file mode 100644 index ab6ae9d..0000000 --- a/src-reason/tea_html.re +++ /dev/null @@ -1,494 +0,0 @@ -open Vdom; - -module Cmds = Tea_html_cmds; - -let map = Tea_app.map; - -/* Nodes */ - -let noNode = noNode; - -let text = str => text(str); - -let lazy1 = (key, gen) => lazyGen(key, gen); - -let node = (~namespace="", tagName, ~key="", ~unique="", props, nodes) => - fullnode(namespace, tagName, key, unique, props, nodes); - -/* let embedProgram main = custom */ - -/* HTML Elements */ - -let br = props => fullnode("", "br", "br", "br", props, []); - -let br' = (~key="", ~unique="", props, nodes) => - fullnode("", "br", key, unique, props, nodes); - -let div = (~key="", ~unique="", props, nodes) => - fullnode("", "div", key, unique, props, nodes); - -let span = (~key="", ~unique="", props, nodes) => - fullnode("", "span", key, unique, props, nodes); - -let p = (~key="", ~unique="", props, nodes) => - fullnode("", "p", key, unique, props, nodes); - -let pre = (~key="", ~unique="", props, nodes) => - fullnode("", "pre", key, unique, props, nodes); - -let a = (~key="", ~unique="", props, nodes) => - fullnode("", "a", key, unique, props, nodes); - -let section = (~key="", ~unique="", props, nodes) => - fullnode("", "section", key, unique, props, nodes); - -let header = (~key="", ~unique="", props, nodes) => - fullnode("", "header", key, unique, props, nodes); - -let footer = (~key="", ~unique="", props, nodes) => - fullnode("", "footer", key, unique, props, nodes); - -let h1 = (~key="", ~unique="", props, nodes) => - fullnode("", "h1", key, unique, props, nodes); - -let h2 = (~key="", ~unique="", props, nodes) => - fullnode("", "h2", key, unique, props, nodes); - -let h3 = (~key="", ~unique="", props, nodes) => - fullnode("", "h3", key, unique, props, nodes); - -let h4 = (~key="", ~unique="", props, nodes) => - fullnode("", "h4", key, unique, props, nodes); - -let h5 = (~key="", ~unique="", props, nodes) => - fullnode("", "h5", key, unique, props, nodes); - -let h6 = (~key="", ~unique="", props, nodes) => - fullnode("", "h6", key, unique, props, nodes); - -let i = (~key="", ~unique="", props, nodes) => - fullnode("", "i", key, unique, props, nodes); - -let strong = (~key="", ~unique="", props, nodes) => - fullnode("", "strong", key, unique, props, nodes); - -let button = (~key="", ~unique="", props, nodes) => - fullnode("", "button", key, unique, props, nodes); - -let input' = (~key="", ~unique="", props, nodes) => - fullnode("", "input", key, unique, props, nodes); - -let textarea = (~key="", ~unique="", props, nodes) => - fullnode("", "textarea", key, unique, props, nodes); - -let label = (~key="", ~unique="", props, nodes) => - fullnode("", "label", key, unique, props, nodes); - -let ul = (~key="", ~unique="", props, nodes) => - fullnode("", "ul", key, unique, props, nodes); - -let ol = (~key="", ~unique="", props, nodes) => - fullnode("", "ol", key, unique, props, nodes); - -let li = (~key="", ~unique="", props, nodes) => - fullnode("", "li", key, unique, props, nodes); - -let table = (~key="", ~unique="", props, nodes) => - fullnode("", "table", key, unique, props, nodes); - -let thead = (~key="", ~unique="", props, nodes) => - fullnode("", "thead", key, unique, props, nodes); - -let tfoot = (~key="", ~unique="", props, nodes) => - fullnode("", "tfoot", key, unique, props, nodes); - -let tbody = (~key="", ~unique="", props, nodes) => - fullnode("", "tbody", key, unique, props, nodes); - -let th = (~key="", ~unique="", props, nodes) => - fullnode("", "th", key, unique, props, nodes); - -let tr = (~key="", ~unique="", props, nodes) => - fullnode("", "tr", key, unique, props, nodes); - -let td = (~key="", ~unique="", props, nodes) => - fullnode("", "td", key, unique, props, nodes); - -let progress = (~key="", ~unique="", props, nodes) => - fullnode("", "progress", key, unique, props, nodes); - -let img = (~key="", ~unique="", props, nodes) => - fullnode("", "img", key, unique, props, nodes); - -let select = (~key="", ~unique="", props, nodes) => - fullnode("", "select", key, unique, props, nodes); - -let option' = (~key="", ~unique="", props, nodes) => - fullnode("", "option", key, unique, props, nodes); - -let form = (~key="", ~unique="", props, nodes) => - fullnode("", "form", key, unique, props, nodes); - -let nav = (~key="", ~unique="", props, nodes) => - fullnode("", "nav", key, unique, props, nodes); - -let main = (~key="", ~unique="", props, nodes) => - fullnode("", "main", key, unique, props, nodes); - -let aside = (~key="", ~unique="", props, nodes) => - fullnode("", "aside", key, unique, props, nodes); - -let article = (~key="", ~unique="", props, nodes) => - fullnode("", "article", key, unique, props, nodes); - -let details = (~key="", ~unique="", props, nodes) => - fullnode("", "details", key, unique, props, nodes); - -let figcaption = (~key="", ~unique="", props, nodes) => - fullnode("", "figcaption", key, unique, props, nodes); - -let figure = (~key="", ~unique="", props, nodes) => - fullnode("", "figure", key, unique, props, nodes); - -let mark = (~key="", ~unique="", props, nodes) => - fullnode("", "mark", key, unique, props, nodes); - -let summary = (~key="", ~unique="", props, nodes) => - fullnode("", "summary", key, unique, props, nodes); - -let time = (~key="", ~unique="", props, nodes) => - fullnode("", "time", key, unique, props, nodes); - -let hr = (~key="", ~unique="", props, nodes) => - fullnode("", "hr", key, unique, props, nodes); - -let blockquote = (~key="", ~unique="", props, nodes) => - fullnode("", "blockquote", key, unique, props, nodes); - -let code = (~key="", ~unique="", props, nodes) => - fullnode("", "code", key, unique, props, nodes); - -let em = (~key="", ~unique="", props, nodes) => - fullnode("", "em", key, unique, props, nodes); - -let b = (~key="", ~unique="", props, nodes) => - fullnode("", "b", key, unique, props, nodes); - -let u = (~key="", ~unique="", props, nodes) => - fullnode("", "u", key, unique, props, nodes); - -let sub = (~key="", ~unique="", props, nodes) => - fullnode("", "sub", key, unique, props, nodes); - -let sup = (~key="", ~unique="", props, nodes) => - fullnode("", "sup", key, unique, props, nodes); - -let dl = (~key="", ~unique="", props, nodes) => - fullnode("", "dl", key, unique, props, nodes); - -let dt = (~key="", ~unique="", props, nodes) => - fullnode("", "dt", key, unique, props, nodes); - -let dd = (~key="", ~unique="", props, nodes) => - fullnode("", "dd", key, unique, props, nodes); - -let iframe = (~key="", ~unique="", props, nodes) => - fullnode("", "iframe", key, unique, props, nodes); - -let canvas = (~key="", ~unique="", props, nodes) => - fullnode("", "canvas", key, unique, props, nodes); - -let address = (~key="", ~unique="", props, nodes) => - fullnode("", "address", key, unique, props, nodes); - -let caption = (~key="", ~unique="", props, nodes) => - fullnode("", "caption", key, unique, props, nodes); - -let colgroup = (~key="", ~unique="", props, nodes) => - fullnode("", "colgroup", key, unique, props, nodes); - -let col = (~key="", ~unique="", props, nodes) => - fullnode("", "col", key, unique, props, nodes); - -let fieldset = (~key="", ~unique="", props, nodes) => - fullnode("", "fieldset", key, unique, props, nodes); - -let legend = (~key="", ~unique="", props, nodes) => - fullnode("", "legend", key, unique, props, nodes); - -let datalist = (~key="", ~unique="", props, nodes) => - fullnode("", "datalist", key, unique, props, nodes); - -let optgroup = (~key="", ~unique="", props, nodes) => - fullnode("", "optgroup", key, unique, props, nodes); - -let output = (~key="", ~unique="", props, nodes) => - fullnode("", "output", key, unique, props, nodes); - -let meter = (~key="", ~unique="", props, nodes) => - fullnode("", "meter", key, unique, props, nodes); - -let audio = (~key="", ~unique="", props, nodes) => - fullnode("", "audio", key, unique, props, nodes); - -let video = (~key="", ~unique="", props, nodes) => - fullnode("", "video", key, unique, props, nodes); - -let source = (~key="", ~unique="", props, nodes) => - fullnode("", "source", key, unique, props, nodes); - -let track = (~key="", ~unique="", props, nodes) => - fullnode("", "track", key, unique, props, nodes); - -let embed = (~key="", ~unique="", props, nodes) => - fullnode("", "embed", key, unique, props, nodes); - -let object' = (~key="", ~unique="", props, nodes) => - fullnode("", "object", key, unique, props, nodes); - -let param = (~key="", ~unique="", props, nodes) => - fullnode("", "param", key, unique, props, nodes); - -let ins = (~key="", ~unique="", props, nodes) => - fullnode("", "ins", key, unique, props, nodes); - -let del = (~key="", ~unique="", props, nodes) => - fullnode("", "del", key, unique, props, nodes); - -let small = (~key="", ~unique="", props, nodes) => - fullnode("", "small", key, unique, props, nodes); - -let cite = (~key="", ~unique="", props, nodes) => - fullnode("", "cite", key, unique, props, nodes); - -let dfn = (~key="", ~unique="", props, nodes) => - fullnode("", "dfn", key, unique, props, nodes); - -let abbr = (~key="", ~unique="", props, nodes) => - fullnode("", "abbr", key, unique, props, nodes); - -let var' = (~key="", ~unique="", props, nodes) => - fullnode("", "var", key, unique, props, nodes); - -let samp = (~key="", ~unique="", props, nodes) => - fullnode("", "samp", key, unique, props, nodes); - -let kbd = (~key="", ~unique="", props, nodes) => - fullnode("", "kbd", key, unique, props, nodes); - -let s = (~key="", ~unique="", props, nodes) => - fullnode("", "s", key, unique, props, nodes); - -let q = (~key="", ~unique="", props, nodes) => - fullnode("", "q", key, unique, props, nodes); - -let rt = (~key="", ~unique="", props, nodes) => - fullnode("", "rt", key, unique, props, nodes); - -let bdi = (~key="", ~unique="", props, nodes) => - fullnode("", "bdi", key, unique, props, nodes); - -let bdo = (~key="", ~unique="", props, nodes) => - fullnode("", "bdo", key, unique, props, nodes); - -let wbr = (~key="", ~unique="", props, nodes) => - fullnode("", "wbr", key, unique, props, nodes); - -let menuitem = (~key="", ~unique="", props, nodes) => - fullnode("", "menuitem", key, unique, props, nodes); - -let menu = (~key="", ~unique="", props, nodes) => - fullnode("", "menu", key, unique, props, nodes); - -/* Properties */ - -let noProp = Vdom.noProp; - -let id = str => prop("id", str); - -/* `href` is actually an attribute, not a property, but need it here for Elm compat... */ -let href = str => attribute("", "href", str); - -/* `src` is actually an attribute, not a property, but need it here for Elm compat... */ -let src = str => attribute("", "src", str); - -let title = str => attribute("", "title", str); - -let class' = name => prop("className", name); - -let classList = classes => - classes - |> List.filter(((_fst, snd)) => snd) - |> List.map(((fst, _snd)) => fst) - |> String.concat(" ") - |> class'; - -let type' = typ => prop("type", typ); - -let style = (key, value) => style(key, value); - -let styles = s => styles(s); - -let placeholder = str => prop("placeholder", str); - -let autofocus = b => - if (b) { - prop("autofocus", "autofocus"); - } else { - noProp; - }; - -let value = str => prop("value", str); - -let name = str => prop("name", str); - -let checked = b => - if (b) { - prop("checked", "checked"); - } else { - noProp; - }; - -let for' = str => prop("htmlFor", str); - -let hidden = b => - if (b) { - prop("hidden", "hidden"); - } else { - noProp; - }; - -let target = t => prop("target", t); - -let action = a => prop("action", a); - -let method' = m => prop("method", m); - -/* Events */ - -let onCB = (eventName, key, cb) => onCB(eventName, key, cb); - -let onMsg = (eventName, msg) => onMsg(eventName, msg); - -let onInputOpt = (~key="", msg) => - onCB("input", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##value)) { - | None => None - | Some(value) => msg(value) - } - } - ); - -let onInput = (~key="", msg) => onInputOpt(~key, ev => Some(msg(ev))); - -let onChangeOpt = (~key="", msg) => - onCB("change", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##value)) { - | None => None - | Some(value) => msg(value) - } - } - ); - -let onChange = (~key="", msg) => onChangeOpt(~key, ev => Some(msg(ev))); - -let onClick = msg => onMsg("click", msg); - -let onDoubleClick = msg => onMsg("dblclick", msg); - -let onBlur = msg => onMsg("blur", msg); - -let onFocus = msg => onMsg("focus", msg); - -let onCheckOpt = (~key="", msg) => - onCB("change", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##checked)) { - | None => None - | Some(value) => msg(value) - } - } - ); - -let onCheck = (~key="", msg) => onCheckOpt(~key, ev => Some(msg(ev))); - -let onMouseDown = msg => onMsg("mousedown", msg); - -let onMouseUp = msg => onMsg("mouseup", msg); - -let onMouseEnter = msg => onMsg("mouseenter", msg); - -let onMouseLeave = msg => onMsg("mouseleave", msg); - -let onMouseOver = msg => onMsg("mouseover", msg); - -let onMouseOut = msg => onMsg("mouseout", msg); - -type options = { - stopPropagation: bool, - preventDefault: bool, -}; - -let defaultOptions = {stopPropagation: false, preventDefault: false}; - -let onWithOptions = (~key: string, eventName, options: options, decoder) => - onCB( - eventName, - key, - event => { - if (options.stopPropagation) { - event##stopPropagation() |> ignore; - }; - if (options.preventDefault) { - event##preventDefault() |> ignore; - }; - event - |> Tea_json.Decoder.decodeEvent(decoder) - |> Tea_result.result_to_option; - }, - ); - -let on = (~key: string, eventName, decoder) => - onWithOptions(~key, eventName, defaultOptions, decoder); - -let targetValue = - Tea_json.Decoder.at(["target", "value"], Tea_json.Decoder.string); - -let targetChecked = - Tea_json.Decoder.at(["target", "checked"], Tea_json.Decoder.bool); - -let keyCode = Tea_json.Decoder.field("keyCode", Tea_json.Decoder.int); - -module Attributes = { - let max = value => attribute("", "max", value); - - let min = value => attribute("", "min", value); - - let step = value => attribute("", "step", value); - - let disabled = b => - if (b) { - attribute("", "disabled", "true"); - } else { - noProp; - }; - - let selected = b => - if (b) { - attribute("", "selected", "true"); - } else { - noProp; - }; - - let acceptCharset = c => attribute("", "accept-charset", c); - - let rel = value => attribute("", "rel", value); -}; diff --git a/src-reason/tea_html2.re b/src-reason/tea_html2.re deleted file mode 100644 index bd2f8bf..0000000 --- a/src-reason/tea_html2.re +++ /dev/null @@ -1,807 +0,0 @@ -/** This file is organized roughly in order of popularity. The tags which you'd -expect to use frequently will be closer to the top. */; - -open Vdom; - -module Cmds = Tea_html_cmds; - -let map = Tea_app.map; - -/** {1 Primitives} */; - -let text = str => text(str); - -let node = (~namespace="", tagName, ~key="", ~unique="", props, nodes) => - fullnode(namespace, tagName, key, unique, props, nodes); - -let noNode = noNode; - -let lazy1 = (key, gen) => lazyGen(key, gen); - -/** {1 Tags} */; - -/** {2 Headers} */; - -let h1 = (~key="", ~unique="", props, nodes) => - fullnode("", "h1", key, unique, props, nodes); - -let h2 = (~key="", ~unique="", props, nodes) => - fullnode("", "h2", key, unique, props, nodes); - -let h3 = (~key="", ~unique="", props, nodes) => - fullnode("", "h3", key, unique, props, nodes); - -let h4 = (~key="", ~unique="", props, nodes) => - fullnode("", "h4", key, unique, props, nodes); - -let h5 = (~key="", ~unique="", props, nodes) => - fullnode("", "h5", key, unique, props, nodes); - -let h6 = (~key="", ~unique="", props, nodes) => - fullnode("", "h6", key, unique, props, nodes); - -/** {2 Grouping Content} */; - -let div = (~key="", ~unique="", props, nodes) => - fullnode("", "div", key, unique, props, nodes); - -let p = (~key="", ~unique="", props, nodes) => - fullnode("", "p", key, unique, props, nodes); - -let hr = (~key="", ~unique="", props, nodes) => - fullnode("", "hr", key, unique, props, nodes); - -let pre = (~key="", ~unique="", props, nodes) => - fullnode("", "pre", key, unique, props, nodes); - -let blockquote = (~key="", ~unique="", props, nodes) => - fullnode("", "blockquote", key, unique, props, nodes); - -/** {2 Text} */; - -let span = (~key="", ~unique="", props, nodes) => - fullnode("", "span", key, unique, props, nodes); - -let a = (~key="", ~unique="", props, nodes) => - fullnode("", "a", key, unique, props, nodes); - -let code = (~key="", ~unique="", props, nodes) => - fullnode("", "code", key, unique, props, nodes); - -let em = (~key="", ~unique="", props, nodes) => - fullnode("", "em", key, unique, props, nodes); - -let strong = (~key="", ~unique="", props, nodes) => - fullnode("", "strong", key, unique, props, nodes); - -let i = (~key="", ~unique="", props, nodes) => - fullnode("", "i", key, unique, props, nodes); - -let b = (~key="", ~unique="", props, nodes) => - fullnode("", "b", key, unique, props, nodes); - -let u = (~key="", ~unique="", props, nodes) => - fullnode("", "u", key, unique, props, nodes); - -let sub = (~key="", ~unique="", props, nodes) => - fullnode("", "sub", key, unique, props, nodes); - -let sup = (~key="", ~unique="", props, nodes) => - fullnode("", "sup", key, unique, props, nodes); - -let br = props => fullnode("", "br", "br", "br", props, []); - -let br' = (~key="", ~unique="", props, nodes) => - fullnode("", "br", key, unique, props, nodes); - -/** {2 Lists} */; - -let ol = (~key="", ~unique="", props, nodes) => - fullnode("", "ol", key, unique, props, nodes); - -let ul = (~key="", ~unique="", props, nodes) => - fullnode("", "ul", key, unique, props, nodes); - -let li = (~key="", ~unique="", props, nodes) => - fullnode("", "li", key, unique, props, nodes); - -let dl = (~key="", ~unique="", props, nodes) => - fullnode("", "dl", key, unique, props, nodes); - -let dt = (~key="", ~unique="", props, nodes) => - fullnode("", "dt", key, unique, props, nodes); - -let dd = (~key="", ~unique="", props, nodes) => - fullnode("", "dd", key, unique, props, nodes); - -/** {2 Embedded Content} */; - -let img = (~key="", ~unique="", props, nodes) => - fullnode("", "img", key, unique, props, nodes); - -let iframe = (~key="", ~unique="", props, nodes) => - fullnode("", "iframe", key, unique, props, nodes); - -let canvas = (~key="", ~unique="", props, nodes) => - fullnode("", "canvas", key, unique, props, nodes); - -let math = (~key="", ~unique="", props, nodes) => - fullnode("", "math", key, unique, props, nodes); - -/** {2 Form and inputs} */; - -let form = (~key="", ~unique="", props, nodes) => - fullnode("", "form", key, unique, props, nodes); - -let input' = (~key="", ~unique="", props, nodes) => - fullnode("", "input", key, unique, props, nodes); - -let textarea = (~key="", ~unique="", props, nodes) => - fullnode("", "textarea", key, unique, props, nodes); - -let button = (~key="", ~unique="", props, nodes) => - fullnode("", "button", key, unique, props, nodes); - -let select = (~key="", ~unique="", props, nodes) => - fullnode("", "select", key, unique, props, nodes); - -let option' = (~key="", ~unique="", props, nodes) => - fullnode("", "option", key, unique, props, nodes); - -let optgroup = (~key="", ~unique="", props, nodes) => - fullnode("", "optgroup", key, unique, props, nodes); - -let label = (~key="", ~unique="", props, nodes) => - fullnode("", "label", key, unique, props, nodes); - -let fieldset = (~key="", ~unique="", props, nodes) => - fullnode("", "fieldset", key, unique, props, nodes); - -let legend = (~key="", ~unique="", props, nodes) => - fullnode("", "legend", key, unique, props, nodes); - -/** {2 Sections} */; - -let section = (~key="", ~unique="", props, nodes) => - fullnode("", "section", key, unique, props, nodes); - -let nav = (~key="", ~unique="", props, nodes) => - fullnode("", "nav", key, unique, props, nodes); - -let article = (~key="", ~unique="", props, nodes) => - fullnode("", "article", key, unique, props, nodes); - -let aside = (~key="", ~unique="", props, nodes) => - fullnode("", "aside", key, unique, props, nodes); - -let header = (~key="", ~unique="", props, nodes) => - fullnode("", "header", key, unique, props, nodes); - -let footer = (~key="", ~unique="", props, nodes) => - fullnode("", "footer", key, unique, props, nodes); - -let address = (~key="", ~unique="", props, nodes) => - fullnode("", "address", key, unique, props, nodes); - -let main = (~key="", ~unique="", props, nodes) => - fullnode("", "main", key, unique, props, nodes); - -let body = (~key="", ~unique="", props, nodes) => - fullnode("", "body", key, unique, props, nodes); - -/** {2 Figures} */; - -let figure = (~key="", ~unique="", props, nodes) => - fullnode("", "figure", key, unique, props, nodes); - -let figcaption = (~key="", ~unique="", props, nodes) => - fullnode("", "figcaption", key, unique, props, nodes); - -/** {2 Tables} */; - -let table = (~key="", ~unique="", props, nodes) => - fullnode("", "table", key, unique, props, nodes); - -let caption = (~key="", ~unique="", props, nodes) => - fullnode("", "caption", key, unique, props, nodes); - -let colgroup = (~key="", ~unique="", props, nodes) => - fullnode("", "colgroup", key, unique, props, nodes); - -let col = (~key="", ~unique="", props, nodes) => - fullnode("", "col", key, unique, props, nodes); - -let tbody = (~key="", ~unique="", props, nodes) => - fullnode("", "tbody", key, unique, props, nodes); - -let thead = (~key="", ~unique="", props, nodes) => - fullnode("", "thead", key, unique, props, nodes); - -let tfoot = (~key="", ~unique="", props, nodes) => - fullnode("", "tfoot", key, unique, props, nodes); - -let tr = (~key="", ~unique="", props, nodes) => - fullnode("", "tr", key, unique, props, nodes); - -let th = (~key="", ~unique="", props, nodes) => - fullnode("", "th", key, unique, props, nodes); - -let td = (~key="", ~unique="", props, nodes) => - fullnode("", "td", key, unique, props, nodes); - -/** {2 Less common inputs} */; - -let datalist = (~key="", ~unique="", props, nodes) => - fullnode("", "datalist", key, unique, props, nodes); - -let keygen = (~key="", ~unique="", props, nodes) => - fullnode("", "keygen", key, unique, props, nodes); - -let output = (~key="", ~unique="", props, nodes) => - fullnode("", "output", key, unique, props, nodes); - -let progress = (~key="", ~unique="", props, nodes) => - fullnode("", "progress", key, unique, props, nodes); - -let meter = (~key="", ~unique="", props, nodes) => - fullnode("", "meter", key, unique, props, nodes); - -/** {2 Audio and Video} */; - -let audio = (~key="", ~unique="", props, nodes) => - fullnode("", "audio", key, unique, props, nodes); - -let video = (~key="", ~unique="", props, nodes) => - fullnode("", "video", key, unique, props, nodes); - -let source = (~key="", ~unique="", props, nodes) => - fullnode("", "source", key, unique, props, nodes); - -let track = (~key="", ~unique="", props, nodes) => - fullnode("", "track", key, unique, props, nodes); - -/** {2 Embedded objects} */; - -let embed = (~key="", ~unique="", props, nodes) => - fullnode("", "embed", key, unique, props, nodes); - -let object' = (~key="", ~unique="", props, nodes) => - fullnode("", "object", key, unique, props, nodes); - -let param = (~key="", ~unique="", props, nodes) => - fullnode("", "param", key, unique, props, nodes); - -/** {2 Text edits} */; - -let ins = (~key="", ~unique="", props, nodes) => - fullnode("", "ins", key, unique, props, nodes); - -let del = (~key="", ~unique="", props, nodes) => - fullnode("", "del", key, unique, props, nodes); - -/** {2 Semantic text} */; - -let small = (~key="", ~unique="", props, nodes) => - fullnode("", "small", key, unique, props, nodes); - -let cite = (~key="", ~unique="", props, nodes) => - fullnode("", "cite", key, unique, props, nodes); - -let dfn = (~key="", ~unique="", props, nodes) => - fullnode("", "dfn", key, unique, props, nodes); - -let abbr = (~key="", ~unique="", props, nodes) => - fullnode("", "abbr", key, unique, props, nodes); - -let time = (~key="", ~unique="", props, nodes) => - fullnode("", "time", key, unique, props, nodes); - -let var' = (~key="", ~unique="", props, nodes) => - fullnode("", "var", key, unique, props, nodes); - -let samp = (~key="", ~unique="", props, nodes) => - fullnode("", "samp", key, unique, props, nodes); - -let kbd = (~key="", ~unique="", props, nodes) => - fullnode("", "kbd", key, unique, props, nodes); - -let s = (~key="", ~unique="", props, nodes) => - fullnode("", "s", key, unique, props, nodes); - -let q = (~key="", ~unique="", props, nodes) => - fullnode("", "q", key, unique, props, nodes); - -/** {2 Less common text tags} */; - -let mark = (~key="", ~unique="", props, nodes) => - fullnode("", "mark", key, unique, props, nodes); - -let ruby = (~key="", ~unique="", props, nodes) => - fullnode("", "ruby", key, unique, props, nodes); - -let rt = (~key="", ~unique="", props, nodes) => - fullnode("", "rt", key, unique, props, nodes); - -let rp = (~key="", ~unique="", props, nodes) => - fullnode("", "rp", key, unique, props, nodes); - -let bdi = (~key="", ~unique="", props, nodes) => - fullnode("", "bdi", key, unique, props, nodes); - -let bdo = (~key="", ~unique="", props, nodes) => - fullnode("", "bdo", key, unique, props, nodes); - -let wbr = (~key="", ~unique="", props, nodes) => - fullnode("", "wbr", key, unique, props, nodes); - -/** {2 Interactive elements} */; - -let details = (~key="", ~unique="", props, nodes) => - fullnode("", "details", key, unique, props, nodes); - -let summary = (~key="", ~unique="", props, nodes) => - fullnode("", "summary", key, unique, props, nodes); - -let menuitem = (~key="", ~unique="", props, nodes) => - fullnode("", "menuitem", key, unique, props, nodes); - -let menu = (~key="", ~unique="", props, nodes) => - fullnode("", "menu", key, unique, props, nodes); - -/** {2 Header elements} */; - -let meta = (~key="", ~unique="", props) => - fullnode("", "meta", key, unique, props, []); - -let style = (~key="", ~unique="", props, content) => - fullnode("", "style", key, unique, props, [text(content)]); - -let title = (~key="", ~unique="", props, content) => - fullnode("", "title", key, unique, props, [text(content)]); - -let link = (~key="", ~unique="", props) => - fullnode("", "link", key, unique, props, []); - -/** Helper functions for HTML attributes. They are organized roughly by category. */ -module Attributes = { - /** {1 Primitives} */; - - let noProp = Vdom.noProp; - - let style = (key, value) => Vdom.style(key, value); - - let styles = s => Vdom.styles(s); - - /** {1 Super common attributes} */; - - let class' = name => prop("className", name); - - let classList = classes => - classes - |> List.filter(((_fst, snd)) => snd) - |> List.map(((fst, _snd)) => fst) - |> String.concat(" ") - |> class'; - - let id = str => prop("id", str); - - let title = str => attribute("", "title", str); - - let hidden = b => - if (b) { - prop("hidden", "hidden"); - } else { - noProp; - }; - - /** {1 Inputs} */; - - let type' = typ => prop("type", typ); - - let value = str => prop("value", str); - - let defaultValue = str => prop("defaultValue", str); - - let checked = b => - if (b) { - prop("checked", "checked"); - } else { - noProp; - }; - - let placeholder = str => prop("placeholder", str); - - let selected = b => - if (b) { - attribute("", "selected", "true"); - } else { - noProp; - }; - - /** {1 Input helpers} */; - - let accept = c => attribute("", "accept", c); - - let acceptCharset = c => attribute("", "accept-charset", c); - - let action = a => prop("action", a); - - let autocomplete = b => prop("autocomplete", if (b) {"on"} else {"off"}); - - let autofocus = b => - if (b) { - prop("autofocus", "autofocus"); - } else { - noProp; - }; - - let disabled = b => - if (b) { - attribute("", "disabled", "true"); - } else { - noProp; - }; - - let enctype = encoding => attribute("", "enctype", encoding); - - let formaction = url => attribute("", "formaction", url); - - let list = value => attribute("", "list", value); - - let minlength = n => attribute("", "minlength", string_of_int(n)); - - let maxlength = n => attribute("", "maxlength", string_of_int(n)); - - let method' = m => prop("method", m); - - let multiple = b => - if (b) { - prop("multiple", "multiple"); - } else { - noProp; - }; - - let name = str => prop("name", str); - - let novalidate = b => - if (b) { - prop("novalidate", "novalidate"); - } else { - noProp; - }; - - let pattern = p => prop("pattern", p); - - let readonly = b => - if (b) { - attribute("", "readonly", "readonly"); - } else { - noProp; - }; - - let required = b => - if (b) { - attribute("", "required", "required"); - } else { - noProp; - }; - - let size = n => attribute("", "size", string_of_int(n)); - - let for' = str => prop("htmlFor", str); - - let form = value => attribute("", "form", value); - - /** {1 Input ranges} */; - - let max = value => attribute("", "max", value); - - let min = value => attribute("", "min", value); - - let step = value => attribute("", "step", value); - - /** {1 Textarea} */; - - let cols = n => attribute("", "cols", string_of_int(n)); - - let rows = n => attribute("", "rows", string_of_int(n)); - - let wrap = value => prop("wrap", value); - - /** {1 Links and areas} */; - - /* `href` is actually an attribute, not a property, but need it here for Elm compat... */ - let href = str => attribute("", "href", str); - - let target = t => prop("target", t); - - let download = b => - if (b) { - prop("download", ""); - } else { - noProp; - }; - - let downloadAs = name => prop("download", name); - - let hreflang = code => prop("hreflang", code); - - let media = value => attribute("", "media", value); - - let ping = url => prop("ping", url); - - let rel = value => attribute("", "rel", value); - - /** {1 Maps} */; - - let ismap = b => - if (b) { - prop("ismap", "ismap"); - } else { - noProp; - }; - - let usemap = name => prop("usemap", name); - - let shape = value => prop("shape", value); - - let coords = value => prop("coords", value); - - /** {1 Embedded content} */; - - /* `src` is actually an attribute, not a property, but need it here for Elm compat... */ - let src = str => attribute("", "src", str); - - let height = n => attribute("", "height", string_of_int(n)); - - let width = n => attribute("", "width", string_of_int(n)); - - let alt = value => prop("alt", value); - - /** {1 Audio and Video} */; - - let autoplay = b => - if (b) { - prop("autoplay", "autoplay"); - } else { - noProp; - }; - - let controls = b => - if (b) { - prop("controls", "controls"); - } else { - noProp; - }; - - let loop = b => - if (b) { - prop("loop", "loop"); - } else { - noProp; - }; - - let preload = value => prop("preload", value); - - let poster = url => prop("poster", url); - - let default = b => - if (b) { - prop("default", "default"); - } else { - noProp; - }; - - let kind = value => prop("kind", value); - - let srclang = code => prop("srclang", code); - - /** {1 IFrames} */; - - let sandbox = value => prop("sandbox", value); - - let seamless = b => - if (b) { - prop("seamless", "seamless"); - } else { - noProp; - }; - - let srcdoc = value => prop("srcdoc", value); - - /** {1 Ordered lists} */; - - let reversed = b => - if (b) { - prop("reversed", "reversed"); - } else { - noProp; - }; - - let start = n => prop("start", string_of_int(n)); - - /** {1 Tables} */; - - let colspan = n => attribute("", "colspan", string_of_int(n)); - - let rowspan = n => attribute("", "rowspan", string_of_int(n)); - - let headers = value => prop("headers", value); - - let scope = value => prop("scope", value); - - let align = value => prop("align", value); - - /** {1 Header stuff} */; - - let async = b => - if (b) { - prop("async", "async"); - } else { - noProp; - }; - - let charset = value => attribute("", "charset", value); - - let content = value => attribute("", "content", value); - - let defer = b => - if (b) { - prop("defer", "defer"); - } else { - noProp; - }; - - let httpEquiv = value => prop("http-equiv", value); - - let language = value => prop("language", value); - - let scoped = value => prop("scoped", value); - - /** {1 Less common global attributes} */; - - let accesskey = ch => prop("accesskey", String.make(1, ch)); - - let contenteditable = b => - if (b) { - prop("contenteditable", "contenteditable"); - } else { - noProp; - }; - - let contextmenu = id => attribute("", "contextmenu", id); - - let dir = value => prop("dir", value); - - let draggable = value => attribute("", "draggable", value); - - let dropzone = value => prop("dropzone", value); - - let itemprop = value => attribute("", "itemprop", value); - - let lang = code => prop("lang", code); - - let spellcheck = b => - if (b) { - prop("spellcheck", "spellcheck"); - } else { - noProp; - }; - - let tabindex = n => attribute("", "tabindex", string_of_int(n)); - - /** {1 Key generation} */; - - let challenge = value => attribute("", "challenge", value); - - let keytype = value => prop("keytype", value); - - /** {1 Miscellaneous} */; - - let cite = url => prop("cite", url); - - let datetime = value => attribute("", "datetime", value); - - let pubdate = value => attribute("", "pubdate", value); - - let manifest = value => attribute("", "manifest", value); -}; - -module Events = { - /** {1 Primitives} */; - - let onCB = (eventName, key, cb) => onCB(eventName, key, cb); - - let onMsg = (eventName, msg) => onMsg(eventName, msg); - - let on = Tea_html.on; - - let onWithOptions = Tea_html.onWithOptions; - - let defaultOptions = Tea_html.defaultOptions; - - let targetValue = Tea_html.targetValue; - - let targetChecked = Tea_html.targetChecked; - - let keyCode = Tea_html.keyCode; - - let preventDefaultOn = (~key="", eventName, decoder) => - onWithOptions( - ~key, - eventName, - {...defaultOptions, preventDefault: true}, - decoder, - ); - - /** {1 Mouse helpers} */; - - let onClick = msg => onMsg("click", msg); - - let onDoubleClick = msg => onMsg("dblclick", msg); - - let onMouseDown = msg => onMsg("mousedown", msg); - - let onMouseUp = msg => onMsg("mouseup", msg); - - let onMouseEnter = msg => onMsg("mouseenter", msg); - - let onMouseLeave = msg => onMsg("mouseleave", msg); - - let onMouseOver = msg => onMsg("mouseover", msg); - - let onMouseOut = msg => onMsg("mouseout", msg); - - /** {1 Form helpers} */; - - let onInputOpt = (~key="", msg) => - onCB("input", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##value)) { - | None => None - | Some(value) => msg(value) - } - } - ); - - let onInput = (~key="", msg) => onInputOpt(~key, ev => Some(msg(ev))); - - let onCheckOpt = (~key="", msg) => - onCB("change", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##checked)) { - | None => None - | Some(value) => msg(value) - } - } - ); - - let onCheck = (~key="", msg) => onCheckOpt(~key, ev => Some(msg(ev))); - - let onChangeOpt = (~key="", msg) => - onCB("change", key, ev => - switch (Js.Undefined.toOption(ev##target)) { - | None => None - | Some(target) => - switch (Js.Undefined.toOption(target##value)) { - | None => None - | Some(value) => msg(value) - } - } - ); - - let onChange = (~key="", msg) => onChangeOpt(~key, ev => Some(msg(ev))); - - let onSubmit = msg => - preventDefaultOn("submit", Tea_json.Decoder.succeed(msg)); - - /** {1 Focus helpers} */; - - let onBlur = msg => onMsg("blur", msg); - - let onFocus = msg => onMsg("focus", msg); -}; diff --git a/src-reason/tea_html_cmds.re b/src-reason/tea_html_cmds.re deleted file mode 100644 index eeaae3c..0000000 --- a/src-reason/tea_html_cmds.re +++ /dev/null @@ -1,14 +0,0 @@ -let focus = id => - Tea_cmd.call(_enqueue => { - let ecb = _ => - switch (Js.Nullable.toOption(Web.Document.getElementById(id))) { - | None => Js.log(("Attempted to focus a non-existant element of: ", id)) - | Some(elem) => Web.Node.focus(elem) - }; - - /* One to get out of the current render frame*/ - let cb = _ => ignore(Web.Window.requestAnimationFrame(ecb)); - /* And another to properly focus */ - ignore(Web.Window.requestAnimationFrame(cb)); - (); - }); diff --git a/src-reason/tea_http.re b/src-reason/tea_http.re deleted file mode 100644 index d38faee..0000000 --- a/src-reason/tea_http.re +++ /dev/null @@ -1,334 +0,0 @@ -type response_status = { - code: int, - message: string, -}; - -type requestBody = Web.XMLHttpRequest.body; -type bodyType = Web.XMLHttpRequest.responseType; -type responseBody = Web.XMLHttpRequest.responseBody; - -type response = { - url: string, - status: response_status, - headers: Map.Make(String).t(string), - body: responseBody, -}; - -type error('parsedata) = - | BadUrl(string) - | Timeout - | NetworkError - | Aborted - | BadStatus(response) - | BadPayload('parsedata, response); - -let string_of_error = - fun - | BadUrl(url) => "Bad Url: " ++ url - | Timeout => "Timeout" - | NetworkError => "Unknown network error" - | Aborted => "Request aborted" - | BadStatus(resp) => "Bad Status: " ++ resp.url - | [@implicit_arity] BadPayload(_customData, resp) => - "Bad Payload: " ++ resp.url; - -type header = - | Header(string, string); - -type expect('res) = - | Expect(bodyType, response => Tea_result.t('res, string)); - -type requestEvents('msg) = { - onreadystatechange: - option( - ( - ref(Vdom.applicationCallbacks('msg)), - Web.XMLHttpRequest.event_readystatechange - ) => - unit, - ), - onprogress: - option( - ( - ref(Vdom.applicationCallbacks('msg)), - Web.XMLHttpRequest.event_progress - ) => - unit, - ), -}; - -let emptyRequestEvents = {onreadystatechange: None, onprogress: None}; - -type rawRequest('res) = { - method': string, - headers: list(header), - url: string, - body: requestBody, - expect: expect('res), - timeout: option(Tea_time.t), - withCredentials: bool, -}; - -type request('msg, 'res) = - | Request(rawRequest('res), option(requestEvents('msg))); - -let expectStringResponse = func => - Web.XMLHttpRequest.( - [@implicit_arity] - Expect( - TextResponseType, - ({body, _}) => - switch (body) { - | TextResponse(s) => func(s) - | _ => Tea_result.Error("Non-text response returned") - }, - ) - ); - -let expectString = - expectStringResponse(resString => Tea_result.Ok(resString)); - -let request = rawRequest => [@implicit_arity] Request(rawRequest, None); - -let getString = url => - request({ - method': "GET", - headers: [], - url, - body: Web.XMLHttpRequest.EmptyBody, - expect: expectString, - timeout: None, - withCredentials: false, - }); - -let toTask = ([@implicit_arity] Request(request, _maybeEvents)) => { - module StringMap = Map.Make(String); - let {method', headers, url, body, expect, timeout, withCredentials} = request; - let [@implicit_arity] Expect(typ, responseToResult) = expect; - Tea_task.nativeBinding(cb => { - let enqRes = (result, _ev) => cb(result); - let enqResError = result => enqRes(Tea_result.Error(result)); - let enqResOk = result => enqRes(Tea_result.Ok(result)); - let xhr = Web.XMLHttpRequest.create(); - let setEvent = (ev, cb) => ev(cb, xhr); - let () = - setEvent(Web.XMLHttpRequest.set_onerror, enqResError(NetworkError)); - let () = - setEvent(Web.XMLHttpRequest.set_ontimeout, enqResError(Timeout)); - let () = setEvent(Web.XMLHttpRequest.set_onabort, enqResError(Aborted)); - let () = - setEvent( - Web.XMLHttpRequest.set_onload, - _ev => { - open Web.XMLHttpRequest; - let headers = - switch (getAllResponseHeadersAsDict(xhr)) { - | Tea_result.Error(_e) => StringMap.empty - | Tea_result.Ok(headers) => headers - }; - let response = { - status: { - code: get_status(xhr), - message: get_statusText(xhr), - }, - headers, - url: get_responseURL(xhr), - body: get_response(xhr), - }; - if (response.status.code < 200 || 300 <= response.status.code) { - enqResError(BadStatus(response), ()); - } else { - switch (responseToResult(response)) { - | Tea_result.Error(error) => - enqResError([@implicit_arity] BadPayload(error, response), ()) - | Tea_result.Ok(result) => enqResOk(result, ()) - }; - }; - }, - ); - let () = - try (Web.XMLHttpRequest.open_(method', url, xhr)) { - | _ => enqResError(BadUrl(url), ()) - }; - let () = { - let setHeader = ([@implicit_arity] Header(k, v)) => - Web.XMLHttpRequest.setRequestHeader(k, v, xhr); - let () = List.iter(setHeader, headers); - let () = Web.XMLHttpRequest.set_responseType(typ, xhr); - let () = - switch (timeout) { - | None => () - | Some(t) => Web.XMLHttpRequest.set_timeout(t, xhr) - }; - let () = Web.XMLHttpRequest.set_withCredentials(withCredentials, xhr); - (); - }; - let () = Web.XMLHttpRequest.send(body, xhr); - (); - }); -}; - -let send = (resultToMessage, [@implicit_arity] Request(request, maybeEvents)) => { - module StringMap = Map.Make(String); - let {method', headers, url, body, expect, timeout, withCredentials} = request; - let [@implicit_arity] Expect(typ, responseToResult) = expect; - Tea_cmd.call(callbacks => { - let enqRes = (result, _ev) => - Vdom.(callbacks^.enqueue(resultToMessage(result))); - let enqResError = result => enqRes(Tea_result.Error(result)); - let enqResOk = result => enqRes(Tea_result.Ok(result)); - let xhr = Web.XMLHttpRequest.create(); - let setEvent = (ev, cb) => ev(cb, xhr); - let () = - switch (maybeEvents) { - | None => () - | Some({onprogress, onreadystatechange}) => - open Web.XMLHttpRequest; - let mayCB = thenDo => ( - fun - | None => () - | Some(v) => thenDo(v(callbacks)) - ); - let () = mayCB(setEvent(set_onreadystatechange), onreadystatechange); - let () = mayCB(setEvent(set_onprogress), onprogress); - (); - }; - let () = - setEvent(Web.XMLHttpRequest.set_onerror, enqResError(NetworkError)); - let () = - setEvent(Web.XMLHttpRequest.set_ontimeout, enqResError(Timeout)); - let () = setEvent(Web.XMLHttpRequest.set_onabort, enqResError(Aborted)); - let () = - setEvent( - Web.XMLHttpRequest.set_onload, - _ev => { - open Web.XMLHttpRequest; - let headers = - switch (getAllResponseHeadersAsDict(xhr)) { - | Tea_result.Error(_e) => StringMap.empty - | Tea_result.Ok(headers) => headers - }; - let response = { - status: { - code: get_status(xhr), - message: get_statusText(xhr), - }, - headers, - url: get_responseURL(xhr), - body: get_response(xhr), - }; - if (response.status.code < 200 || 300 <= response.status.code) { - enqResError(BadStatus(response), ()); - } else { - switch (responseToResult(response)) { - | Tea_result.Error(error) => - enqResError([@implicit_arity] BadPayload(error, response), ()) - | Tea_result.Ok(result) => enqResOk(result, ()) - }; - }; - }, - ); - let () = - try (Web.XMLHttpRequest.open_(method', url, xhr)) { - | _ => enqResError(BadUrl(url), ()) - }; - let () = { - let setHeader = ([@implicit_arity] Header(k, v)) => - Web.XMLHttpRequest.setRequestHeader(k, v, xhr); - let () = List.iter(setHeader, headers); - let () = Web.XMLHttpRequest.set_responseType(typ, xhr); - let () = - switch (timeout) { - | None => () - | Some(t) => Web.XMLHttpRequest.set_timeout(t, xhr) - }; - let () = Web.XMLHttpRequest.set_withCredentials(withCredentials, xhr); - (); - }; - let () = Web.XMLHttpRequest.send(body, xhr); - (); - }); -}; - -[@bs.val] external encodeURIComponent: string => string = ""; - -let encodeUri = str => encodeURIComponent(str); - -[@bs.val] external decodeURIComponent: string => string = ""; - -let decodeUri = str => - try (Some(decodeURIComponent(str))) { - | _ => None - }; - -module Progress = { - /* - type bytesProgressed = - { bytes : int - ; bytesExpected : int - } - - type ('data, 'parseFailData) t = - | NoProgress - (* SomeProgress (bytes, bytesExpected) *) - | SomeProgress of bytesProgressed - | FailProgress of 'parseFailData error - | DoneProgress of 'data - - type ('msg, 'parseFailData) trackedRequest = - { request : 'msg rawRequest - ; toProgress : bytesProgressed -> 'msg - ; toError : 'parseFailData error -> 'msg - } - */ - - type t = { - bytes: int, - bytesExpected: int, - }; - - let emptyProgress = {bytes: 0, bytesExpected: 0}; - - /* Yeah this does not follow the original API, but that original - API is... not extensible... Instead, we have generic event - listener support here so no need to constrain the API. - Might still want to make a subscription variant though... */ - let track = (toMessage, [@implicit_arity] Request(request, events)) => { - let onprogress = - Some( - (callbacks, ev) => { - open Vdom; - let lengthComputable = - Tea_json.Decoder.( - Tea_result.( - switch (decodeValue(field("lengthComputable", bool), ev)) { - | Error(_e) => false - | Ok(v) => v - } - ) - ); - if (lengthComputable) { - open Tea_json.Decoder; - open Tea_result; - let decoder = - map2( - (bytes, bytesExpected) => {bytes, bytesExpected}, - field("loaded", int), - field("total", int), - ); - - switch (decodeValue(decoder, ev)) { - | Error(_e) => () - | Ok(t) => callbacks^.enqueue(toMessage(t)) - }; - }; - }, - ); - let events = - switch (events) { - | None => emptyRequestEvents - | Some(e) => e - }; - [@implicit_arity] Request(request, Some({...events, onprogress})); - }; -}; diff --git a/src-reason/tea_json.re b/src-reason/tea_json.re deleted file mode 100644 index 4467eac..0000000 --- a/src-reason/tea_json.re +++ /dev/null @@ -1,508 +0,0 @@ -module Decoder = { - type error = String.t; - module ObjectDict = Map.Make(String); - type t('input, 'result) = - | Decoder('input => Tea_result.t('result, error)); - /* - | Parser : (Web.Json.t -> ('result, error) Tea_result.t) -> ('result, error) Tea_result.t t - */ - /* - | Value : (Web.Json.t, error) Tea_result.t t - | Succeed : 'result -> ('result, error) Tea_result.t t - | Fail : error -> (_, error) Tea_result.t t - | Null : 'result -> ('result, error) Tea_result.t t - | String : (string, error) Tea_result.t t - */ - exception ParseFail(string); - /* Primitive types */ - let string = - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONString(s) => Tea_result.Ok(s) - | _ => Tea_result.Error("Non-string value") - } - ), - ); - let int = - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONNumber(n) => - if (n > float_of_int(min_int) && n < float_of_int(max_int)) { - Tea_result.Ok(int_of_float(n)); - } else { - Tea_result.Error("number out of int range"); - } - | _ => Tea_result.Error("Non-int value") - } - ), - ); - let float = - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONNumber(n) => Tea_result.Ok(n) - | _ => Tea_result.Error("Non-float-value") - } - ), - ); - let bool = - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONTrue => Tea_result.Ok(true) - | JSONFalse => Tea_result.Ok(false) - | _ => Tea_result.Error("Non-boolean value") - } - ), - ); - let null = v => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONNull => Tea_result.Ok(v) - | _ => Tea_result.Error("Non-null value") - } - ), - ); - /* Compound types */ - let list = (Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONArray(a) => - let parse = v => - switch (decoder(v)) { - | Tea_result.Ok(r) => r - | Tea_result.Error(e) => raise(ParseFail(e)) - }; - try (Tea_result.Ok(Array.to_list(a) |> List.map(parse))) { - | ParseFail(e) => Tea_result.Error("list -> " ++ e) - }; - | _ => Tea_result.Error("Non-list value") - } - ), - ); - let array = (Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONArray(a) => - let parse = v => - switch (decoder(v)) { - | Tea_result.Ok(r) => r - | Tea_result.Error(e) => raise(ParseFail(e)) - }; - try (Tea_result.Ok(Array.map(parse, a))) { - | ParseFail(e) => Tea_result.Error("array -> " ++ e) - }; - | _ => Tea_result.Error("Non-array value") - } - ), - ); - let keyValuePairs = (Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONObject(o) => - let keys = Js.Dict.keys(o); - let parse = (k, l) => - switch (Js.Dict.get(o, k)) { - | None => raise(ParseFail("Key is undefined: " ++ k)) - | Some(v) => - switch (decoder(v)) { - | Tea_result.Ok(r) => [(k, r), ...l] - | Tea_result.Error(e) => raise(ParseFail(e)) - } - }; - try (Tea_result.Ok(Array.fold_right(parse, keys, []))) { - | ParseFail(e) => - Tea_result.Error("Invalid keyValuePair parsing: " ++ e) - }; - | _ => Tea_result.Error("Non-keyValuePair value") - } - ), - ); - let dict = (Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONObject(o) => - let keys = Js.Dict.keys(o); - let parse = (k, d) => - switch (Js.Dict.get(o, k)) { - | None => raise(ParseFail("Key is undefined: " ++ k)) - | Some(v) => - switch (decoder(v)) { - | Tea_result.Ok(r) => ObjectDict.add(k, r, d) - | Tea_result.Error(e) => raise(ParseFail(e)) - } - }; - let emptyDict = ObjectDict.empty; - try (Tea_result.Ok(Array.fold_right(parse, keys, emptyDict))) { - | ParseFail(e) => Tea_result.Error("Invalid dict parsing: " ++ e) - }; - | _ => Tea_result.Error("Non-dict value") - } - ), - ); - let field = (key, Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONObject(o) => - switch (Js.Dict.get(o, key)) { - | None => Tea_result.Error("Field Value is undefined: " ++ key) - | Some(v) => - switch (decoder(v)) { - | Ok(_) as o => o - | Error(e) => Error("field `" ++ key ++ "` -> " ++ e) - } - } - | _ => Tea_result.Error("Non-fieldable value") - } - ), - ); - let at = (fields, dec) => List.fold_right(field, fields, dec); - let index = (idx, Decoder(decoder)) => - Decoder( - value => - Web.Json.( - switch (classify(value)) { - | JSONArray(a) => - if (idx < 0 || idx > Array.length(a)) { - Tea_result.Error( - "Array index out of range: " ++ string_of_int(idx), - ); - } else { - decoder(a[idx]); - } - | _ => Tea_result.Error("Non-array value") - } - ), - ); - let maybe = (Decoder(decoder)) => - Decoder( - value => - switch (decoder(value)) { - | Tea_result.Ok(r) => Tea_result.Ok(Some(r)) - | Tea_result.Error(_) => Tea_result.Ok(None) - }, - ); - let oneOf = decoders => - Decoder( - value => { - let rec parse = v => - fun - | [] => Tea_result.Error("No one-of's matched") - | [Decoder(decoder), ...rest] => - try ( - switch (decoder(v)) { - | Tea_result.Ok(_) as ok => ok - | Tea_result.Error(_) => parse(v, rest) - } - ) { - | _ => parse(v, rest) - }; - parse(value, decoders); - }, - ); - let map = (mapper, Decoder(decoder1)) => - Decoder( - value => - Tea_result.( - switch (decoder1(value)) { - | Ok(v1) => Ok(mapper(v1)) - | Error(e) => Error("map " ++ e) - } - ), - ); - let map2 = (mapper, Decoder(decoder1), Decoder(decoder2)) => - Decoder( - value => - Tea_result.( - switch (decoder1(value), decoder2(value)) { - | (Ok(v1), Ok(v2)) => Ok(mapper(v1, v2)) - | (e1, e2) => - switch (Tea_result.error_of_first(e1, e2)) { - | None => failwith("Impossible case") - | Some(e) => Error("map2 -> " ++ e) - } - } - ), - ); - let map3 = - (mapper, Decoder(decoder1), Decoder(decoder2), Decoder(decoder3)) => - Decoder( - value => - Tea_result.( - switch (decoder1(value), decoder2(value), decoder3(value)) { - | (Ok(v1), Ok(v2), Ok(v3)) => Ok(mapper(v1, v2, v3)) - | (e1, e2, e3) => - open! Tea_result; - switch (e1 |> first(e2) |> first(e3)) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map3 -> " ++ e) - }; - } - ), - ); - let map4 = - ( - mapper, - Decoder(decoder1), - Decoder(decoder2), - Decoder(decoder3), - Decoder(decoder4), - ) => - Decoder( - value => - Tea_result.( - switch ( - decoder1(value), - decoder2(value), - decoder3(value), - decoder4(value), - ) { - | (Ok(v1), Ok(v2), Ok(v3), Ok(v4)) => Ok(mapper(v1, v2, v3, v4)) - | (e1, e2, e3, e4) => - open! Tea_result; - switch (e1 |> first(e2) |> first(e3) |> first(e4)) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map4 -> " ++ e) - }; - } - ), - ); - let map5 = - ( - mapper, - Decoder(decoder1), - Decoder(decoder2), - Decoder(decoder3), - Decoder(decoder4), - Decoder(decoder5), - ) => - Decoder( - value => - Tea_result.( - switch ( - decoder1(value), - decoder2(value), - decoder3(value), - decoder4(value), - decoder5(value), - ) { - | (Ok(v1), Ok(v2), Ok(v3), Ok(v4), Ok(v5)) => - Ok(mapper(v1, v2, v3, v4, v5)) - | (e1, e2, e3, e4, e5) => - open! Tea_result; - switch (e1 |> first(e2) |> first(e3) |> first(e4) |> first(e5)) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map5 -> " ++ e) - }; - } - ), - ); - let map6 = - ( - mapper, - Decoder(decoder1), - Decoder(decoder2), - Decoder(decoder3), - Decoder(decoder4), - Decoder(decoder5), - Decoder(decoder6), - ) => - Decoder( - value => - Tea_result.( - switch ( - decoder1(value), - decoder2(value), - decoder3(value), - decoder4(value), - decoder5(value), - decoder6(value), - ) { - | (Ok(v1), Ok(v2), Ok(v3), Ok(v4), Ok(v5), Ok(v6)) => - Ok(mapper(v1, v2, v3, v4, v5, v6)) - | (e1, e2, e3, e4, e5, e6) => - open! Tea_result; - switch ( - e1 - |> first(e2) - |> first(e3) - |> first(e4) - |> first(e5) - |> first(e6) - ) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map6 -> " ++ e) - }; - } - ), - ); - let map7 = - ( - mapper, - Decoder(decoder1), - Decoder(decoder2), - Decoder(decoder3), - Decoder(decoder4), - Decoder(decoder5), - Decoder(decoder6), - Decoder(decoder7), - ) => - Decoder( - value => - Tea_result.( - switch ( - decoder1(value), - decoder2(value), - decoder3(value), - decoder4(value), - decoder5(value), - decoder6(value), - decoder7(value), - ) { - | (Ok(v1), Ok(v2), Ok(v3), Ok(v4), Ok(v5), Ok(v6), Ok(v7)) => - Ok(mapper(v1, v2, v3, v4, v5, v6, v7)) - | (e1, e2, e3, e4, e5, e6, e7) => - open! Tea_result; - switch ( - e1 - |> first(e2) - |> first(e3) - |> first(e4) - |> first(e5) - |> first(e6) - |> first(e7) - ) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map7 -> " ++ e) - }; - } - ), - ); - let map8 = - ( - mapper, - Decoder(decoder1), - Decoder(decoder2), - Decoder(decoder3), - Decoder(decoder4), - Decoder(decoder5), - Decoder(decoder6), - Decoder(decoder7), - Decoder(decoder8), - ) => - Decoder( - value => - Tea_result.( - switch ( - decoder1(value), - decoder2(value), - decoder3(value), - decoder4(value), - decoder5(value), - decoder6(value), - decoder7(value), - decoder8(value), - ) { - | (Ok(v1), Ok(v2), Ok(v3), Ok(v4), Ok(v5), Ok(v6), Ok(v7), Ok(v8)) => - Ok(mapper(v1, v2, v3, v4, v5, v6, v7, v8)) - | (e1, e2, e3, e4, e5, e6, e7, e8) => - open! Tea_result; - switch ( - e1 - |> first(e2) - |> first(e3) - |> first(e4) - |> first(e5) - |> first(e6) - |> first(e7) - |> first(e8) - ) { - | Ok(_) => failwith("Impossible case") - | Error(e) => Error("map8 -> " ++ e) - }; - } - ), - ); - /* Fancy Primitives */ - let succeed = v => Decoder(_value => Tea_result.Ok(v)); - let fail = e => Decoder(_value => Tea_result.Error(e)); - let value = Decoder(value => Tea_result.Ok(value)); - let andThen = (func, Decoder(decoder)) => - Decoder( - value => - switch (decoder(value)) { - | Tea_result.Ok(r) => - let Decoder(andThenDecoder) = func(r); - andThenDecoder(value); - | Tea_result.Error(_) as err => err - }, - ); - let lazy_ = func => andThen(func, succeed()); - let nullable = decoder => - oneOf([null(None), map(v => Some(v), decoder)]); - /* Decoders */ - /* TODO: Constrain this value type more */ - let decodeValue = (Decoder(decoder), value) => - try (decoder(value)) { - | ParseFail(e) => Tea_result.Error(e) - | _ => Tea_result.Error("Unknown JSON parsing error") - }; - let decodeEvent = (Decoder(decoder), value: Web_node.event) => - try (decoder(Obj.magic(value))) { - | ParseFail(e) => Tea_result.Error(e) - | _ => Tea_result.Error("Unknown JSON parsing error") - }; - let decodeString = (decoder, string) => - try ( - { - let value = Web.Json.parseExn(string); - decodeValue(decoder, value); - } - ) { - /* | JsException e -> Tea_result.Error ("Given an invalid JSON: " ^ e) */ - | _ => Tea_result.Error("Invalid JSON string") - }; -}; - -module Encoder = { - open Web; - type t = Json.t; - let encode = (indentLevel, value) => - Web.Json.string_of_json(~indent=indentLevel, Js.Undefined.return(value)); - /* Encoders */ - let string = (v: string) => Json.of_type(Json.String, v); - let int = (v: int) => Json.of_type(Json.Number, float_of_int(v)); - let float = (v: float) => Json.of_type(Json.Number, v); - let bool = (v: bool) => Json.of_type(Json.Boolean, v); - let null = Json.of_type(Json.Null, Json.null); - let object_ = v => { - let aux = (o, (k, v)) => { - let () = Js.Dict.set(o, k, v); - o; - }; - let o = List.fold_left(aux, Js.Dict.empty(), v); - Json.of_type(Json.Object, o); - }; - let array = (v: array('t)) => Json.of_type(Json.Array, v); - let list = (v: list('t)) => Json.of_type(Json.Array, Array.of_list(v)); -}; - -type t = Web.Json.t; diff --git a/src-reason/tea_mouse.re b/src-reason/tea_mouse.re deleted file mode 100644 index 85a0d5d..0000000 --- a/src-reason/tea_mouse.re +++ /dev/null @@ -1,41 +0,0 @@ -type position = { - x: int, - y: int, -}; - -let position = - Tea_json.Decoder.( - map2((x, y) => {x, y}, field("pageX", int), field("pageY", int)) - ); - -let registerGlobal = (name, key, tagger) => { - open Vdom; - let enableCall = callbacks_base => { - let callbacks = ref(callbacks_base); - let fn = ev => - Tea_json.Decoder.( - Tea_result.( - switch (decodeEvent(position, ev)) { - | Error(_) => None - | Ok(pos) => Some(tagger(pos)) - } - ) - ); - let handler = [@implicit_arity] EventHandlerCallback(key, fn); - let elem = Web_node.document_node; - let cache = eventHandler_Register(callbacks, elem, name, handler); - () => { - let _ = eventHandler_Unregister(elem, name, cache); - (); - }; - }; - Tea_sub.registration(key, enableCall); -}; - -let clicks = (~key="", tagger) => registerGlobal("click", key, tagger); - -let moves = (~key="", tagger) => registerGlobal("mousemove", key, tagger); - -let downs = (~key="", tagger) => registerGlobal("mousedown", key, tagger); - -let ups = (~key="", tagger) => registerGlobal("mouseup", key, tagger); diff --git a/src-reason/tea_navigation.re b/src-reason/tea_navigation.re deleted file mode 100644 index b2ee832..0000000 --- a/src-reason/tea_navigation.re +++ /dev/null @@ -1,97 +0,0 @@ -type navigationProgram('flags, 'model, 'msg) = { - init: ('flags, Web.Location.location) => ('model, Tea_cmd.t('msg)), - update: ('model, 'msg) => ('model, Tea_cmd.t('msg)), - view: 'model => Vdom.t('msg), - subscriptions: 'model => Tea_sub.t('msg), - shutdown: 'model => Tea_cmd.t('msg), -}; - -let getLocation = () => Web.Location.asRecord(Web.Document.location()); - -let notifier: ref(option(Web.Location.location => unit)) = ref(None); - -let notifyUrlChange = () => - switch (notifier^) { - | None => () - | Some(cb) => - let location = getLocation(); - let () = cb(location); - (); - }; - -let subscribe = tagger => { - open Vdom; - let enableCall = callbacks => { - let notifyHandler = location => callbacks.enqueue(tagger(location)); - let () = notifier := Some(notifyHandler); - let handler: Web.Node.event_cb = (. _event) => notifyUrlChange(); - let () = Web.Window.addEventListener("popstate", handler, false); - () => Web.Window.removeEventListener("popstate", handler, false); - }; - Tea_sub.registration("navigation", enableCall); -}; - -let replaceState = url => { - let _ = - Web.Window.History.replaceState( - Web.Window.window, - Js.Json.parseExn("{}"), - "", - url, - ); - (); -}; - -let pushState = url => { - let _ = - Web.Window.History.pushState( - Web.Window.window, - Js.Json.parseExn("{}"), - "", - url, - ); - (); -}; - -let modifyUrl = url => - Tea_cmd.call(_enqueue => { - let () = replaceState(url); - let () = notifyUrlChange(); - (); - }); - -let newUrl = url => - Tea_cmd.call(_enqueue => { - let () = pushState(url); - let () = notifyUrlChange(); - (); - }); - -let go = step => - Tea_cmd.call(_enqueue => { - let _ = Web.Window.(History.go(window))(step); - let () = notifyUrlChange(); - (); - }); - -let back = step => go(- step); -let forward = step => go(step); - -let navigationProgram = (locationToMessage, stuff) => { - let init = flag => stuff.init(flag, getLocation()); - - let subscriptions = model => - Tea_sub.batch([ - subscribe(locationToMessage), - stuff.subscriptions(model), - ]); - - open! Tea_app; - program({ - init, - update: stuff.update, - view: stuff.view, - subscriptions, - shutdown: stuff.shutdown, - }); -}; diff --git a/src-reason/tea_program.re b/src-reason/tea_program.re deleted file mode 100644 index fb6be88..0000000 --- a/src-reason/tea_program.re +++ /dev/null @@ -1,43 +0,0 @@ -type processMsg('msg) = - | PushMsg('msg) - | Kill; - -let spawn = (initState, update, shutdown) => { - let state = ref(Some(initState)); - let onMessage = procMsg => - switch (state^) { - | None => () - | Some(model) => - switch (procMsg) { - | PushMsg(msg) => - let () = state := update(model, msg); - (); - | Kill => - let () = shutdown(model); - let () = state := None; - (); - } - }; - onMessage; -}; - -/* let testing0 = - let s = spawn 42 (fun model -> let () = Js.log model in function - | `Inc -> Some (model + 1) - | `Dec -> Some (model - 1) - ) (fun _ -> ()) in - let () = s (PushMsg `Dec) in - let () = s (PushMsg `Dec) in - let () = s Kill in - let () = s (PushMsg `Dec) in - () */ -module type Process = { - /* This module should be `import`ed into a module that will become a persistent process. - That process should have a handleMsg callback to handle its own message types. - It should call itself - */ - type msg; - let handleMsg: msg => unit; -}; - -let testing1 = 42; diff --git a/src-reason/tea_random.re b/src-reason/tea_random.re deleted file mode 100644 index 18c5019..0000000 --- a/src-reason/tea_random.re +++ /dev/null @@ -1,123 +0,0 @@ -let () = Random.self_init(); - -let minInt = min_int; - -let maxInt = max_int; - -let minFloat = min_float; - -let maxFloat = max_float; - -type t('typ) = - | Generator(Random.State.t => 'typ); - -let bool = Generator(state => Random.State.bool(state)); - -let int = (min, max) => - let (min, max) = (min < max) ? (min, max) : (max, min); - Generator(state => min + Random.State.int(state, max - min + 1)); - -let float = (min, max) => - Generator(state => min +. Random.State.float(state, max -. min)); - -let list = (count, Generator(genCmd)) => { - let rec buildList = (state, i, acc) => - if (i > 0) { - buildList(state, i - 1, [genCmd(state), ...acc]); - } else { - acc; - }; - Generator(state => buildList(state, count, [])); -}; - -let map = (func, Generator(genCmd)) => - Generator(state => func(genCmd(state))); - -let map2 = (func, Generator(genCmd1), Generator(genCmd2)) => - Generator( - state => { - let res1 = genCmd1(state); - let res2 = genCmd2(state); - func(res1, res2); - }, - ); - -let map3 = - (func, Generator(genCmd1), Generator(genCmd2), Generator(genCmd3)) => - Generator( - state => { - let res1 = genCmd1(state); - let res2 = genCmd2(state); - let res3 = genCmd3(state); - func(res1, res2, res3); - }, - ); - -let map4 = - ( - func, - Generator(genCmd1), - Generator(genCmd2), - Generator(genCmd3), - Generator(genCmd4), - ) => - Generator( - state => { - let res1 = genCmd1(state); - let res2 = genCmd2(state); - let res3 = genCmd3(state); - let res4 = genCmd4(state); - func(res1, res2, res3, res4); - }, - ); - -let map5 = - ( - func, - Generator(genCmd1), - Generator(genCmd2), - Generator(genCmd3), - Generator(genCmd4), - Generator(genCmd5), - ) => - Generator( - state => { - let res1 = genCmd1(state); - let res2 = genCmd2(state); - let res3 = genCmd3(state); - let res4 = genCmd4(state); - let res5 = genCmd5(state); - func(res1, res2, res3, res4, res5); - }, - ); - -let andThen = (func, Generator(genCmd)) => - Generator( - state => { - let res = genCmd(state); - let Generator(userGen) = func(res); - userGen(state); - }, - ); - -let pair = (gen1, gen2) => map2((a, b) => (a, b), gen1, gen2); - -let generate = (tagger, Generator(genCmd)) => - Tea_cmd.call(callbacks => { - let state = Random.get_state(); - let genValue = genCmd(state); - let () = Random.set_state(state); - Vdom.(callbacks^.enqueue(tagger(genValue))); - }); - -/* Generate Values Manually */ - -type seed = - | Seed(Random.State.t); - -let step = (Generator(genCmd), Seed(state)) => { - let newState = Random.State.copy(state); - (genCmd(newState), Seed(newState)); -}; - -let initialSeed = seed => Seed(Random.State.make([|seed|])); diff --git a/src-reason/tea_result.re b/src-reason/tea_result.re deleted file mode 100644 index 68a31f1..0000000 --- a/src-reason/tea_result.re +++ /dev/null @@ -1,71 +0,0 @@ -/* TODO: Remove this when Bucklescript is updated to OCaml 4.03 as it includes result */ -type t /* result */('a, 'b) = - | Ok('a) - | Error('b); - -let result_to_option = - fun - | Ok(a) => Some(a) - | Error(_) => None; - -let option_of_result = - fun - | Ok(a) => Some(a) - | Error(_) => None; - -let ok = - fun - | Ok(a) => Some(a) - | Error(_) => None; - -let error = - fun - | Ok(_) => None - | Error(e) => Some(e); - -let rec last_of = - fun - | [] => failwith("`Tea.Result.do` must never be passed the empty list") - | [last] => last - | [next, ...tl] => - switch (next) { - | Error(_) as e => e - | Ok(_) => last_of(tl) - }; - -let rec accumulate = - fun - | [] => Ok([]) - | [last] => - switch (last) { - | Error(_) as e => e - | Ok(o) => Ok([o]) - } - | [next, ...tl] => - switch (next) { - | Error(_) as e => e - | Ok(o) => - switch (accumulate(tl)) { - | Error(_) as e => e - | Ok(os) => Ok([o, ...os]) - } - }; - -let first = fst => - fun - | Error(_) as e => e - | Ok(_) => fst; - -let rec error_of_any = - fun - | [] => None - | [hd, ...tl] => - switch (hd) { - | Error(e) => Some(e) - | Ok(_) => error_of_any(tl) - }; - -let error_of_first = fst => - fun - | Error(e) => Some(e) - | Ok(_) => error(fst); diff --git a/src-reason/tea_sub.re b/src-reason/tea_sub.re deleted file mode 100644 index 14ee116..0000000 --- a/src-reason/tea_sub.re +++ /dev/null @@ -1,120 +0,0 @@ -type t('msg) = - | NoSub: t(_) - | Batch(list(t('msg))): t('msg) - | Registration( - string, - (ref(Vdom.applicationCallbacks('msg)), unit) => unit, - ref(option(unit => unit)), - ) - : t('msg) - | Mapper( - ref(Vdom.applicationCallbacks('msg)) => - ref(Vdom.applicationCallbacks('msgB)), - t('msgB), - ) - : t('msg); - -type applicationCallbacks('msg) = Vdom.applicationCallbacks('msg); - -let none = NoSub; - -let batch = subs => Batch(subs); - -let registration = (key, enableCall) => - [@implicit_arity] - Registration(key, callbacks => enableCall(callbacks^), ref(None)); - -let map = (msgMapper, sub) => { - let func = callbacks => Vdom.wrapCallbacks(msgMapper, callbacks); - [@implicit_arity] Mapper(func, sub); -}; - -let mapFunc = (func, sub) => [@implicit_arity] Mapper(func, sub); - -let rec run: - type msgOld msgNew. - ( - ref(Vdom.applicationCallbacks(msgOld)), - ref(Vdom.applicationCallbacks(msgNew)), - t(msgOld), - t(msgNew) - ) => - t(msgNew) = - (oldCallbacks, newCallbacks, oldSub, newSub) => { - let rec enable: - type msg. (ref(Vdom.applicationCallbacks(msg)), t(msg)) => unit = - callbacks => - fun - | NoSub => () - | Batch([]) => () - | Batch(subs) => List.iter(enable(callbacks), subs) - | [@implicit_arity] Mapper(mapper, sub) => { - let subCallbacks = mapper(callbacks); - enable(subCallbacks, sub); - } - | [@implicit_arity] Registration(_key, enCB, diCB) => - diCB := Some(enCB(callbacks)); - - let rec disable: - type msg. (ref(Vdom.applicationCallbacks(msg)), t(msg)) => unit = - callbacks => - fun - | NoSub => () - | Batch([]) => () - | Batch(subs) => List.iter(disable(callbacks), subs) - | [@implicit_arity] Mapper(mapper, sub) => { - let subCallbacks = mapper(callbacks); - disable(subCallbacks, sub); - } - | [@implicit_arity] Registration(_key, _enCB, diCB) => - switch (diCB^) { - | None => () - | Some(cb) => - let () = diCB := None; - cb(); - }; - - [@ocaml.warning "-4"] - ( - switch (oldSub, newSub) { - | (NoSub, NoSub) => newSub - | ( - [@implicit_arity] Registration(oldKey, _oldEnCB, oldDiCB), - [@implicit_arity] Registration(newKey, _newEnCB, newDiCB), - ) - when oldKey == newKey => - let () = newDiCB := oldDiCB^; - newSub; - | ( - [@implicit_arity] Mapper(oldMapper, oldSubSub), - [@implicit_arity] Mapper(newMapper, newSubSub), - ) => - let olderCallbacks = oldMapper(oldCallbacks); /* Resolve the type checker */ - let newerCallbacks = newMapper(newCallbacks); - let _newerSubSub = - run(olderCallbacks, newerCallbacks, oldSubSub, newSubSub); - newSub; - | (Batch(oldSubs), Batch(newSubs)) => - let rec aux = (oldList, newList) => - switch (oldList, newList) { - | ([], []) => () - | ([], [newSubSub, ...newRest]) => - let () = enable(newCallbacks, newSubSub); - aux([], newRest); - | ([oldSubSub, ...oldRest], []) => - let () = disable(oldCallbacks, oldSubSub); - aux(oldRest, []); - | ([oldSubSub, ...oldRest], [newSubSub, ...newRest]) => - let _newerSubSub = - run(oldCallbacks, newCallbacks, oldSubSub, newSubSub); - aux(oldRest, newRest); - }; - let () = aux(oldSubs, newSubs); - newSub; - | (oldS, newS) => - let () = disable(oldCallbacks, oldS); - let () = enable(newCallbacks, newS); - newSub; - } - ); - }; diff --git a/src-reason/tea_svg_attributes.re b/src-reason/tea_svg_attributes.re deleted file mode 100644 index 8b33343..0000000 --- a/src-reason/tea_svg_attributes.re +++ /dev/null @@ -1,523 +0,0 @@ -open Vdom; - -/* Regular attributes */ -let accentHeight = v => attribute("", "accent-height", v); - -let accelerate = v => attribute("", "accelerate", v); - -let accumulate = v => attribute("", "accumulate", v); - -let additive = v => attribute("", "additive", v); - -let alphabetic = v => attribute("", "alphabetic", v); - -let allowReorder = v => attribute("", "allowReorder", v); - -let amplitude = v => attribute("", "amplitude", v); - -let arabicForm = v => attribute("", "arabic-form", v); - -let ascent = v => attribute("", "ascent", v); - -let attributeName = v => attribute("", "attributeName", v); - -let attributeType = v => attribute("", "attributeType", v); - -let autoReverse = v => attribute("", "autoReverse", v); - -let azimuth = v => attribute("", "azimuth", v); - -let baseFrequency = v => attribute("", "baseFrequency", v); - -let baseProfile = v => attribute("", "baseProfile", v); - -let bbox = v => attribute("", "bbox", v); - -let begin' = v => attribute("", "begin", v); - -let bias = v => attribute("", "bias", v); - -let by = v => attribute("", "by", v); - -let calcMode = v => attribute("", "calcMode", v); - -let capHeight = v => attribute("", "cap-height", v); - -let class' = v => attribute("", "class", v); - -let clipPathUnits = v => attribute("", "clipPathUnits", v); - -let contentScriptType = v => attribute("", "contentScriptType", v); - -let contentStyleType = v => attribute("", "contentStyleType", v); - -let cx = v => attribute("", "cx", v); - -let cy = v => attribute("", "cy", v); - -let d = v => attribute("", "d", v); - -let decelerate = v => attribute("", "decelerate", v); - -let descent = v => attribute("", "descent", v); - -let diffuseConstant = v => attribute("", "diffuseConstant", v); - -let divisor = v => attribute("", "divisor", v); - -let dur = v => attribute("", "dur", v); - -let dx = v => attribute("", "dx", v); - -let dy = v => attribute("", "dy", v); - -let edgeMode = v => attribute("", "edgeMode", v); - -let elevation = v => attribute("", "elevation", v); - -let end' = v => attribute("", "end", v); - -let exponent = v => attribute("", "exponent", v); - -let externalResourcesRequired = v => - attribute("", "externalResourcesRequired", v); - -let filterRes = v => attribute("", "filterRes", v); - -let filterUnits = v => attribute("", "filterUnits", v); - -let format = v => attribute("", "format", v); - -let from = v => attribute("", "from", v); - -let fx = v => attribute("", "fx", v); - -let fy = v => attribute("", "fy", v); - -let g1 = v => attribute("", "g1", v); - -let g2 = v => attribute("", "g2", v); - -let glyphName = v => attribute("", "glyph-name", v); - -let glyphRef = v => attribute("", "glyphRef", v); - -let gradientTransform = v => attribute("", "gradientTransform", v); - -let gradientUnits = v => attribute("", "gradientUnits", v); - -let hanging = v => attribute("", "hanging", v); - -let height = v => attribute("", "height", v); - -let horizAdvX = v => attribute("", "horiz-adv-x", v); - -let horizOriginX = v => attribute("", "horiz-origin-x", v); - -let horizOriginY = v => attribute("", "horiz-origin-y", v); - -let id = v => attribute("", "id", v); - -let ideographic = v => attribute("", "ideographic", v); - -let in' = v => attribute("", "in", v); - -let in2 = v => attribute("", "in2", v); - -let intercept = v => attribute("", "intercept", v); - -let k = v => attribute("", "k", v); - -let k1 = v => attribute("", "k1", v); - -let k2 = v => attribute("", "k2", v); - -let k3 = v => attribute("", "k3", v); - -let k4 = v => attribute("", "k4", v); - -let kernelMatrix = v => attribute("", "kernelMatrix", v); - -let kernelUnitLength = v => attribute("", "kernelUnitLength", v); - -let keyPoints = v => attribute("", "keyPoints", v); - -let keySplines = v => attribute("", "keySplines", v); - -let keyTimes = v => attribute("", "keyTimes", v); - -let lang = v => attribute("", "lang", v); - -let lengthAdjust = v => attribute("", "lengthAdjust", v); - -let limitingConeAngle = v => attribute("", "limitingConeAngle", v); - -let local = v => attribute("", "local", v); - -let markerHeight = v => attribute("", "markerHeight", v); - -let markerUnits = v => attribute("", "markerUnits", v); - -let markerWidth = v => attribute("", "markerWidth", v); - -let maskContentUnits = v => attribute("", "maskContentUnits", v); - -let maskUnits = v => attribute("", "maskUnits", v); - -let mathematical = v => attribute("", "mathematical", v); - -let max = v => attribute("", "max", v); - -let media = v => attribute("", "media", v); - -let method' = v => attribute("", "method", v); - -let min = v => attribute("", "min", v); - -let mode = v => attribute("", "mode", v); - -let name = v => attribute("", "name", v); - -let numOctaves = v => attribute("", "numOctaves", v); - -let offset = v => attribute("", "offset", v); - -let operator = v => attribute("", "operator", v); - -let order = v => attribute("", "order", v); - -let orient = v => attribute("", "orient", v); - -let orientation = v => attribute("", "orientation", v); - -let origin = v => attribute("", "origin", v); - -let overlinePosition = v => attribute("", "overline-position", v); - -let overlineThickness = v => attribute("", "overline-thickness", v); - -let panose1 = v => attribute("", "panose-1", v); - -let path = v => attribute("", "path", v); - -let pathLength = v => attribute("", "pathLength", v); - -let patternContentUnits = v => attribute("", "patternContentUnits", v); - -let patternTransform = v => attribute("", "patternTransform", v); - -let patternUnits = v => attribute("", "patternUnits", v); - -let pointOrder = v => attribute("", "point-order", v); - -let points = v => attribute("", "points", v); - -let pointsAtX = v => attribute("", "pointsAtX", v); - -let pointsAtY = v => attribute("", "pointsAtY", v); - -let pointsAtZ = v => attribute("", "pointsAtZ", v); - -let preserveAlpha = v => attribute("", "preserveAlpha", v); - -let preserveAspectRatio = v => attribute("", "preserveAspectRatio", v); - -let primitiveUnits = v => attribute("", "primitiveUnits", v); - -let r = v => attribute("", "r", v); - -let radius = v => attribute("", "radius", v); - -let refX = v => attribute("", "refX", v); - -let refY = v => attribute("", "refY", v); - -let renderingIntent = v => attribute("", "rendering-intent", v); - -let repeatCount = v => attribute("", "repeatCount", v); - -let repeatDur = v => attribute("", "repeatDur", v); - -let requiredExtensions = v => attribute("", "requiredExtensions", v); - -let requiredFeatures = v => attribute("", "requiredFeatures", v); - -let restart = v => attribute("", "restart", v); - -let result = v => attribute("", "result", v); - -let rotate = v => attribute("", "rotate", v); - -let rx = v => attribute("", "rx", v); - -let ry = v => attribute("", "ry", v); - -let scale = v => attribute("", "scale", v); - -let seed = v => attribute("", "seed", v); - -let slope = v => attribute("", "slope", v); - -let spacing = v => attribute("", "spacing", v); - -let specularConstant = v => attribute("", "specularConstant", v); - -let specularExponent = v => attribute("", "specularExponent", v); - -let speed = v => attribute("", "speed", v); - -let spreadMethod = v => attribute("", "spreadMethod", v); - -let startOffset = v => attribute("", "startOffset", v); - -let stdDeviation = v => attribute("", "stdDeviation", v); - -let stemh = v => attribute("", "stemh", v); - -let stemv = v => attribute("", "stemv", v); - -let stitchTiles = v => attribute("", "stitchTiles", v); - -let strikethroughPosition = v => attribute("", "strikethrough-position", v); - -let strikethroughThickness = v => attribute("", "strikethrough-thickness", v); - -let string = v => attribute("", "string", v); - -let style = v => attribute("", "style", v); - -let surfaceScale = v => attribute("", "surfaceScale", v); - -let systemLanguage = v => attribute("", "systemLanguage", v); - -let tableValues = v => attribute("", "tableValues", v); - -let target = v => attribute("", "target", v); - -let targetX = v => attribute("", "targetX", v); - -let targetY = v => attribute("", "targetY", v); - -let textLength = v => attribute("", "textLength", v); - -let title = v => attribute("", "title", v); - -let to' = v => attribute("", "to", v); - -let transform = v => attribute("", "transform", v); - -let type' = v => attribute("", "type", v); - -let u1 = v => attribute("", "u1", v); - -let u2 = v => attribute("", "u2", v); - -let underlinePosition = v => attribute("", "underline-position", v); - -let underlineThickness = v => attribute("", "underline-thickness", v); - -let unicode = v => attribute("", "unicode", v); - -let unicodeRange = v => attribute("", "unicode-range", v); - -let unitsPerEm = v => attribute("", "units-per-em", v); - -let vAlphabetic = v => attribute("", "v-alphabetic", v); - -let vHanging = v => attribute("", "v-hanging", v); - -let vIdeographic = v => attribute("", "v-ideographic", v); - -let vMathematical = v => attribute("", "v-mathematical", v); - -let values = v => attribute("", "values", v); - -let version = v => attribute("", "version", v); - -let vertAdvY = v => attribute("", "vert-adv-y", v); - -let vertOriginX = v => attribute("", "vert-origin-x", v); - -let vertOriginY = v => attribute("", "vert-origin-y", v); - -let viewBox = v => attribute("", "viewBox", v); - -let viewTarget = v => attribute("", "viewTarget", v); - -let width = v => attribute("", "width", v); - -let widths = v => attribute("", "widths", v); - -let x = v => attribute("", "x", v); - -let xHeight = v => attribute("", "x-height", v); - -let x1 = v => attribute("", "x1", v); - -let x2 = v => attribute("", "x2", v); - -let xChannelSelector = v => attribute("", "xChannelSelector", v); - -let xlinkActuate = v => - attribute("http://www.w3.org/1999/xlink", "xlink:actuate", v); - -let xlinkArcrole = v => - attribute("http://www.w3.org/1999/xlink", "xlink:arcrole", v); - -let xlinkHref = v => - attribute("http://www.w3.org/1999/xlink", "xlink:href", v); - -let xlinkRole = v => - attribute("http://www.w3.org/1999/xlink", "xlink:role", v); - -let xlinkShow = v => - attribute("http://www.w3.org/1999/xlink", "xlink:show", v); - -let xlinkTitle = v => - attribute("http://www.w3.org/1999/xlink", "xlink:title", v); - -let xlinkType = v => - attribute("http://www.w3.org/1999/xlink", "xlink:type", v); - -let xmlBase = v => - attribute("http://www.w3.org/XML/1998/namespace", "xml:base", v); - -let xmlLang = v => - attribute("http://www.w3.org/XML/1998/namespace", "xml:lang", v); - -let xmlSpace = v => - attribute("http://www.w3.org/XML/1998/namespace", "xml:space", v); - -let y = v => attribute("", "y", v); - -let y1 = v => attribute("", "y1", v); - -let y2 = v => attribute("", "y2", v); - -let yChannelSelector = v => attribute("", "yChannelSelector", v); - -let z = v => attribute("", "z", v); - -let zoomAndPan = v => attribute("", "zoomAndPan", v); - -/* Presentation attributes */ -let alignmentBaseline = v => attribute("", "alignment-baseline", v); - -let baselineShift = v => attribute("", "baseline-shift", v); - -let clipPath = v => attribute("", "clip-path", v); - -let clipRule = v => attribute("", "clip-rule", v); - -let clip = v => attribute("", "clip", v); - -let colorInterpolationFilters = v => - attribute("", "color-interpolation-filters", v); - -let colorInterpolation = v => attribute("", "color-interpolation", v); - -let colorProfile = v => attribute("", "color-profile", v); - -let colorRendering = v => attribute("", "color-rendering", v); - -let color = v => attribute("", "color", v); - -let cursor = v => attribute("", "cursor", v); - -let direction = v => attribute("", "direction", v); - -let display = v => attribute("", "display", v); - -let dominantBaseline = v => attribute("", "dominant-baseline", v); - -let enableBackground = v => attribute("", "enable-background", v); - -let fillOpacity = v => attribute("", "fill-opacity", v); - -let fillRule = v => attribute("", "fill-rule", v); - -let fill = v => attribute("", "fill", v); - -let filter = v => attribute("", "filter", v); - -let floodColor = v => attribute("", "flood-color", v); - -let floodOpacity = v => attribute("", "flood-opacity", v); - -let fontFamily = v => attribute("", "font-family", v); - -let fontSizeAdjust = v => attribute("", "font-size-adjust", v); - -let fontSize = v => attribute("", "font-size", v); - -let fontStretch = v => attribute("", "font-stretch", v); - -let fontStyle = v => attribute("", "font-style", v); - -let fontVariant = v => attribute("", "font-variant", v); - -let fontWeight = v => attribute("", "font-weight", v); - -let glyphOrientationHorizontal = v => - attribute("", "glyph-orientation-horizontal", v); - -let glyphOrientationVertical = v => - attribute("", "glyph-orientation-vertical", v); - -let imageRendering = v => attribute("", "image-rendering", v); - -let kerning = v => attribute("", "kerning", v); - -let letterSpacing = v => attribute("", "letter-spacing", v); - -let lightingColor = v => attribute("", "lighting-color", v); - -let markerEnd = v => attribute("", "marker-end", v); - -let markerMid = v => attribute("", "marker-mid", v); - -let markerStart = v => attribute("", "marker-start", v); - -let mask = v => attribute("", "mask", v); - -let opacity = v => attribute("", "opacity", v); - -let overflow = v => attribute("", "overflow", v); - -let pointerEvents = v => attribute("", "pointer-events", v); - -let shapeRendering = v => attribute("", "shape-rendering", v); - -let stopColor = v => attribute("", "stop-color", v); - -let stopOpacity = v => attribute("", "stop-opacity", v); - -let strokeDasharray = v => attribute("", "stroke-dasharray", v); - -let strokeDashoffset = v => attribute("", "stroke-dashoffset", v); - -let strokeLinecap = v => attribute("", "stroke-linecap", v); - -let strokeLinejoin = v => attribute("", "stroke-linejoin", v); - -let strokeMiterlimit = v => attribute("", "stroke-miterlimit", v); - -let strokeOpacity = v => attribute("", "stroke-opacity", v); - -let strokeWidth = v => attribute("", "stroke-width", v); - -let stroke = v => attribute("", "stroke", v); - -let textAnchor = v => attribute("", "text-anchor", v); - -let textDecoration = v => attribute("", "text-decoration", v); - -let textRendering = v => attribute("", "text-rendering", v); - -let unicodeBidi = v => attribute("", "unicode-bidi", v); - -let visibility = v => attribute("", "visibility", v); - -let wordSpacing = v => attribute("", "word-spacing", v); - -let writingMode = v => attribute("", "writing-mode", v); diff --git a/src-reason/tea_task.re b/src-reason/tea_task.re deleted file mode 100644 index 93a99ca..0000000 --- a/src-reason/tea_task.re +++ /dev/null @@ -1,230 +0,0 @@ -type never; -type t('succeed, 'fail) = - | Task((Tea_result.t('succeed, 'fail) => unit) => unit) - : t('succeed, 'fail); - -let nothing = () => (); - -let performOpt = - ( - toOptionalMessage: 'value => option('msg), - Task(task): t('value, never), - ) - : Tea_cmd.t('msg) => - Tea_cmd.call(callbacks => { - open Tea_result; - open Vdom; - let cb = - fun - | Error(_e) => - failwith( - "ERROR: Task perfom returned error of never! Should not happen!", - ) - | Ok(v) => - switch (toOptionalMessage(v)) { - | None => () - | Some(result) => callbacks^.enqueue(result) - }; - task(cb); - }); -let perform = - (toMessage: 'value => 'msg, task: t('value, never)): Tea_cmd.t('msg) => - performOpt(v => Some(toMessage(v)), task); -let attemptOpt = - ( - resultToOptionalMessage: Tea_result.t('succeed, 'fail) => option('msg), - Task(task): t('succeed, 'fail), - ) - : Tea_cmd.t('msg) => - Tea_cmd.call(callbacks => { - open Vdom; - let cb = value => - switch (resultToOptionalMessage(value)) { - | None => () - | Some(result) => callbacks^.enqueue(result) - }; - task(cb); - }); -let attempt = - ( - resultToMessage: Tea_result.t('succeed, 'fail) => 'msg, - task: t('succeed, 'fail), - ) - : Tea_cmd.t('msg) => - attemptOpt(v => Some(resultToMessage(v)), task); -let ignore = task => attemptOpt(_ => None, task); -let succeed = (value: 'v): t('v, 'e) => - Task(cb => cb(Tea_result.Ok(value))); -let fail = (value: 'v): t('e, 'v) => - Task(cb => cb(Tea_result.Error(value))); -let nativeBinding = - (func: (Tea_result.t('succeed, 'fail) => unit) => unit) - : t('succeed, 'fail) => - Task(func); - -let andThen = (fn, Task(task)) => - Tea_result.( - Task( - cb => - task( - fun - | Error(_e) as err => cb(err) - | Ok(v) => { - let Task(nextTask) = fn(v); - nextTask(cb); - }, - ), - ) - ); -let onError = (fn, Task(task)) => - Tea_result.( - Task( - cb => - task( - fun - | Ok(_v) as ok => cb(ok) - | Error(e) => { - let Task(newTask) = fn(e); - newTask(cb); - }, - ), - ) - ); - -let fromResult: Tea_result.t('success, 'failure) => t('success, 'failure) = - fun - | Tea_result.Ok(s) => succeed(s) - | Tea_result.Error(err) => fail(err); - -let mapError = (func, task) => task |> onError(e => fail(func(e))); - -let map = (func, task1) => task1 |> andThen(v1 => succeed(func(v1))); -let map2 = (func, task1, task2) => - task1 |> andThen(v1 => task2 |> andThen(v2 => succeed(func(v1, v2)))); -let map3 = (func, task1, task2, task3) => - task1 - |> andThen(v1 => - task2 - |> andThen(v2 => task3 |> andThen(v3 => succeed(func(v1, v2, v3)))) - ); -let map4 = (func, task1, task2, task3, task4) => - task1 - |> andThen(v1 => - task2 - |> andThen(v2 => - task3 - |> andThen(v3 => - task4 |> andThen(v4 => succeed(func(v1, v2, v3, v4))) - ) - ) - ); -let map5 = (func, task1, task2, task3, task4, task5) => - task1 - |> andThen(v1 => - task2 - |> andThen(v2 => - task3 - |> andThen(v3 => - task4 - |> andThen(v4 => - task5 - |> andThen(v5 => succeed(func(v1, v2, v3, v4, v5))) - ) - ) - ) - ); -let map6 = (func, task1, task2, task3, task4, task5, task6) => - task1 - |> andThen(v1 => - task2 - |> andThen(v2 => - task3 - |> andThen(v3 => - task4 - |> andThen(v4 => - task5 - |> andThen(v5 => - task6 - |> andThen(v6 => - succeed(func(v1, v2, v3, v4, v5, v6)) - ) - ) - ) - ) - ) - ); -let rec sequence = - fun - | [] => succeed([]) - | [task, ...remainingTasks] => - map2((l, r) => [l, ...r], task, sequence(remainingTasks)); - -let testing_deop = ref(true); - -let testing = () => { - open Tea_result; - let doTest = (expected, Task(task)) => { - let testAssert = v => - if (v == expected) { - Js.log(("Passed:", expected, v)); - } else { - Js.log(("FAILED:", expected, v)); - }; - task(testAssert); - }; - let s = succeed(42); - let () = doTest(Ok(42), s); - let f = fail(86); - let () = doTest(Error(86), f); - let r = () => - if (testing_deop^) { - succeed(42); - } else { - fail(3.14); - }; - let a1 = succeed(2) |> andThen(n => succeed(n + 2)); - let () = doTest(Ok(4), a1); - let a2 = succeed(2) |> andThen(n => succeed(string_of_int(n))); - let () = doTest(Ok("2"), a2); - let m1 = map(sqrt, succeed(9.)); - let () = doTest(Ok(3.), m1); - let m2 = map2((+), succeed(9), succeed(3)); - let () = doTest(Ok(12), m2); - let m3 = map(string_of_int, succeed(9)); - let () = doTest(Ok("9"), m3); - let s0 = sequence([succeed(1), succeed(2)]); - let () = doTest(Ok([1, 2]), s0); - let s1 = sequence([succeed(1), fail(2.7), r()]); - let () = doTest(Error(2.7), s1); - let e0 = fail("file not found") |> onError(_msg => succeed(42)); - let () = doTest(Ok(42), e0); - let e1 = fail("file not found") |> onError(_msg => fail(42)); - let () = doTest(Error(42), e1); - let n0 = - sequence([ - mapError(string_of_int, fail(42)), - mapError(string_of_float, fail(3.14)), - ]); - let () = doTest(Error("42"), n0); - let n1 = - sequence([ - mapError(string_of_int, succeed(1)), - mapError(string_of_float, fail(3.14)), - ]); - let () = doTest(Error("3.14"), n1); - let n2 = - sequence([ - mapError(string_of_int, succeed(1)), - mapError(string_of_float, succeed(2)), - ]); - let () = doTest(Ok([1, 2]), n2); - let _c0 = perform(_ => 42, succeed(18)); - - let () = doTest(Ok(42), fromResult(Ok(42))); - let () = doTest(Error("failure"), fromResult(Error("failure"))); - - let () = doTest(Ok(None), fail("for some reason") |> toOption); - let () = doTest(Ok(Some(42)), succeed(42) |> toOption); - - (); -}; diff --git a/src-reason/tea_time.re b/src-reason/tea_time.re deleted file mode 100644 index 47d1894..0000000 --- a/src-reason/tea_time.re +++ /dev/null @@ -1,49 +0,0 @@ -type t = float; - -/* type 'msg mySub = - | Every of t * (t -> 'msg) - - - type 'msg myCmd = - | Delay of t * (unit -> 'msg) */ - -let every = (~key, interval, tagger) => { - open Vdom; - let enableCall = callbacks => { - let id = - Web.Window.setInterval( - () => callbacks.enqueue(tagger(Web.Date.now())), - interval, - ); - /* let () = Js.log ("Time.every", "enable", interval, tagger, callbacks) in */ - () => - /* let () = Js.log ("Time.every", "disable", id, interval, tagger, callbacks) in */ - Web.Window.clearTimeout(id); - }; - Tea_sub.registration(key, enableCall); -}; - -let delay = (msTime, msg) => - Tea_cmd.call(callbacks => { - let _unhandledID = - Web.Window.setTimeout(() => Vdom.(callbacks^.enqueue(msg)), msTime); - (); - }); - -/* Generic Helpers */ - -let millisecond = 1.0; - -let second = 1000.0 *. millisecond; - -let minute = 60.0 *. second; - -let hour = 60.0 *. minute; - -let inMilliseconds = t => t; - -let inSeconds = t => t /. second; - -let inMinutes = t => t /. minute; - -let inHours = t => t /. hour; diff --git a/src-reason/vdom.re b/src-reason/vdom.re deleted file mode 100644 index 89012b0..0000000 --- a/src-reason/vdom.re +++ /dev/null @@ -1,1185 +0,0 @@ -/* https://github.com/Matt-Esch/virtual-dom/blob/master/docs/vnode.md */ - -type systemMessage('msg) = - | Render - | AddRenderMsg('msg) - | RemoveRenderMsg('msg); - -type applicationCallbacks('msg) = { - enqueue: 'msg => unit, - on: systemMessage('msg) => unit, -}; - -/* Attributes are not properties */ -/* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes */ - -type eventHandler('msg) = - | EventHandlerCallback(string, Web.Node.event => option('msg)) - | EventHandlerMsg('msg); - -type eventCache('msg) = { - handler: Web.Node.event_cb, - cb: ref(Web.Node.event => option('msg)), -}; - -type property('msg) = - | NoProp - | RawProp(string, string) /* TODO: This last string needs to be made something more generic, maybe a function... */ - /* Attribute (namespace, key, value) */ - | Attribute(string, string, string) - | Data(string, string) - /* Event (name, userkey, callback) */ - | Event(string, eventHandler('msg), ref(option(eventCache('msg)))) - | Style(list((string, string))); - -type properties('msg) = list(property('msg)); - -type t('msg) = - | CommentNode(string) - | Text(string) - /* Node (namespace, tagName, key, unique, properties, children) */ - | Node(string, string, string, string, properties('msg), list(t('msg))) - /* LazyGen (key, fnGenerator) */ - | LazyGen(string, unit => t('msg), ref(t('msg))) - /* Tagger (tagger, vdom) */ - | Tagger( - ref(applicationCallbacks('msg)) => ref(applicationCallbacks('msg)), - t('msg), - ); -/* TODO: support Custom */ -/* Custom (key, cbAdd, cbRemove, cbChange, properties, children) */ -/* | Custom of string * (unit -> Web.Node.t) * (Web.Node.t -> unit) * */ - -/* Nodes */ - -let noNode: t('msg) = (CommentNode(""): t('msg)); - -let comment = (s: string): t('msg) => CommentNode(s); - -let text = (s: string): t('msg) => Text(s); - -let fullnode = - ( - namespace: string, - tagName: string, - key: string, - unique: string, - props: properties('msg), - vdoms: list(t('msg)), - ) - : t('msg) => - [@implicit_arity] Node(namespace, tagName, key, unique, props, vdoms); - -let node = - ( - ~namespace: string="", - tagName: string, - ~key: string="", - ~unique: string="", - props: properties('msg), - vdoms: list(t('msg)), - ) - : t('msg) => - fullnode(namespace, tagName, key, unique, props, vdoms); - -let lazyGen = (key: string, fn: unit => t('msg)): t('msg) => - [@implicit_arity] LazyGen(key, fn, ref(noNode)); - -/* Properties */ - -let noProp: property('msg) = (NoProp: property('msg)); - -let prop = (key: string, value: string): property('msg) => - [@implicit_arity] RawProp(key, value); - -let onCB = - (name: string, key: string, cb: Web.Node.event => option('msg)) - : property('msg) => - [@implicit_arity] - Event(name, [@implicit_arity] EventHandlerCallback(key, cb), ref(None)); - -let onMsg = (name: string, msg: 'msg): property('msg) => - [@implicit_arity] Event(name, EventHandlerMsg(msg), ref(None)); - -let attribute = - (namespace: string, key: string, value: string): property('msg) => - [@implicit_arity] Attribute(namespace, key, value); - -let data = (key: string, value: string): property('msg) => - [@implicit_arity] Data(key, value); - -let style = (key: string, value: string): property('msg) => - Style([(key, value)]); - -let styles = (s): property('msg) => Style(s); - -/* Accessors */ - -/* TODO: Need to properly escape and so forth */ -let rec renderToHtmlString: t('msg) => string = ( - fun - | CommentNode(s) => "" - | Text(s) => s - | [@implicit_arity] Node(namespace, tagName, _key, _unique, props, vdoms) => { - let renderProp = ( - fun - | NoProp => "" - | [@implicit_arity] RawProp(k, v) => - String.concat("", [" ", k, "=\"", v, "\""]) - | [@implicit_arity] Attribute(_namespace, k, v) => - String.concat("", [" ", k, "=\"", v, "\""]) - | [@implicit_arity] Data(k, v) => - String.concat("", [" data-", k, "=\"", v, "\""]) - | [@implicit_arity] Event(_, _, _) => "" - | Style(s) => - String.concat( - "", - [ - " style=\"", - String.concat( - ";", - List.map( - ((k, v)) => String.concat("", [k, ":", v, ";"]), - s, - ), - ), - "\"", - ], - ) - ); - - String.concat( - "", - [ - "<", - namespace, - if (namespace == "") { - ""; - } else { - ":"; - }, - tagName, - String.concat("", List.map(p => renderProp(p), props)), - ">", - String.concat("", List.map(v => renderToHtmlString(v), vdoms)), - "", - ], - ); - } - | [@implicit_arity] LazyGen(_key, gen, _cache) => { - let vdom = gen(); - renderToHtmlString(vdom); - } - | [@implicit_arity] Tagger(_tagger, vdom) => renderToHtmlString(vdom): - t('msg) => string -); - -/* TODO: Make a vdom 'patcher' that binds into the actual DOM for hot-loading into an existing template */ - -/* Diffing/Patching */ - -let emptyEventHandler: Web.Node.event_cb = ((. _ev) => (): Web.Node.event_cb); -let emptyEventCB = (_ev): option(Web.Node.event_cb) => None; - -let eventHandler = - ( - callbacks: ref(applicationCallbacks('msg)), - cb: ref(Web.Node.event => option('msg)), - ) - : Web.Node.event_cb => - (. ev) => - switch (cb^(ev)) { - | None => () /* User ignored, do nothing */ - | Some(msg) => callbacks^.enqueue(msg) - }; - -let eventHandler_GetCB: (eventHandler('msg), Web.Node.event) => option('msg) = ( - fun - | [@implicit_arity] EventHandlerCallback(_, cb) => cb - | EventHandlerMsg(msg) => (_ev => Some(msg)): - (eventHandler('msg), Web.Node.event) => option('msg) -); - -let compareEventHandlerTypes = - (left: eventHandler('msg)): (eventHandler('msg) => bool) => - fun - | [@implicit_arity] EventHandlerCallback(cb, _) => - switch (left) { - | [@implicit_arity] EventHandlerCallback(lcb, _) when cb == lcb => true - | _ => false - } - | EventHandlerMsg(msg) => - switch (left) { - | EventHandlerMsg(lmsg) when msg == lmsg => true - | _ => false - }; - -let eventHandler_Register = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - name: string, - handlerType: eventHandler('msg), - ) - : option(eventCache('msg)) => { - let cb = ref(eventHandler_GetCB(handlerType)); - let handler = eventHandler(callbacks, cb); - let () = Web.Node.addEventListener(elem, name, handler, false); - Some({handler, cb}); -}; - -let eventHandler_Unregister = - (elem: Web.Node.t, name: string) - : (option(eventCache('msg)) => option(eventCache('msg))) => - fun - | None => None - | Some(cache) => { - let () = Web.Node.removeEventListener(elem, name, cache.handler, false); - None; - }; - -let eventHandler_Mutate = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - oldName: string, - newName: string, - oldHandlerType: eventHandler('msg), - newHandlerType: eventHandler('msg), - oldCache: ref(option(eventCache('msg))), - newCache: ref(option(eventCache('msg))), - ) - : unit => - switch (oldCache^) { - | None => - newCache := - eventHandler_Register(callbacks, elem, newName, newHandlerType) - | Some(oldcache) => - if (oldName == newName) { - let () = newCache := oldCache^; - if (compareEventHandlerTypes(oldHandlerType, newHandlerType)) { - (); - } else { - let cb = eventHandler_GetCB(newHandlerType); - let () = oldcache.cb := cb; - (); - }; - } else { - let () = oldCache := eventHandler_Unregister(elem, oldName, oldCache^); - let () = - newCache := - eventHandler_Register(callbacks, elem, newName, newHandlerType); - (); - } - }; - -let patchVNodesOnElems_PropertiesApply_Add = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - _idx: int, - ) - : (property('msg) => unit) => - fun - | NoProp => () - | [@implicit_arity] RawProp(k, v) => Web.Node.setProp(elem, k, v) - | [@implicit_arity] Attribute(namespace, k, v) => - Web.Node.setAttributeNsOptional(elem, namespace, k, v) - | [@implicit_arity] Data(k, v) => { - Js.log(("TODO: Add Data Unhandled", k, v)); - failwith("TODO: Add Data Unhandled"); - } - | [@implicit_arity] Event(name, handlerType, cache) => - cache := eventHandler_Register(callbacks, elem, name, handlerType) - | Style(s) => - List.fold_left( - ((), (k, v)) => - Web.Node.setStyleProperty(elem, k, Js.Null.return(v)), - (), - s, - ); - -let patchVNodesOnElems_PropertiesApply_Remove = - ( - _callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - _idx: int, - ) - : (property('msg) => unit) => - fun - | NoProp => () - | [@implicit_arity] RawProp(k, _v) => - Web.Node.setProp(elem, k, Js.Undefined.empty) - | [@implicit_arity] Attribute(namespace, k, _v) => - Web.Node.removeAttributeNsOptional(elem, namespace, k) - | [@implicit_arity] Data(k, v) => { - Js.log(("TODO: Remove Data Unhandled", k, v)); - failwith("TODO: Remove Data Unhandled"); - } - | [@implicit_arity] Event(name, _, cache) => - cache := eventHandler_Unregister(elem, name, cache^) - | Style(s) => - List.fold_left( - ((), (k, _v)) => Web.Node.setStyleProperty(elem, k, Js.Null.empty), - (), - s, - ); - -let patchVNodesOnElems_PropertiesApply_RemoveAdd = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - idx: int, - oldProp: property('msg), - newProp: property('msg), - ) - : unit => { - let () = - patchVNodesOnElems_PropertiesApply_Remove(callbacks, elem, idx, oldProp); - let () = - patchVNodesOnElems_PropertiesApply_Add(callbacks, elem, idx, newProp); - (); -}; - -let patchVNodesOnElems_PropertiesApply_Mutate = - ( - _callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - _idx: int, - oldProp: property('msg), - ) - : (property('msg) => unit) => - fun - | NoProp as _newProp => - failwith( - "This should never be called as all entries through NoProp are gated.", - ) - | [@implicit_arity] RawProp(k, v) as _newProp => - /* let () = Js.log ("Mutating RawProp", elem, oldProp, _newProp) in */ - Web.Node.setProp(elem, k, v) /* Wow setting properties is slow, unsure how to optimize this further though... */ - | [@implicit_arity] Attribute(namespace, k, v) as _newProp => - /* let () = Js.log ("Mutating Attribute", namespace, k, v, elem) in */ - Web.Node.setAttributeNsOptional(elem, namespace, k, v) - | [@implicit_arity] Data(k, v) as _newProp => { - Js.log(("TODO: Mutate Data Unhandled", k, v)); - failwith("TODO: Mutate Data Unhandled"); - } - | [@implicit_arity] Event(_newName, _newHandlerType, _newCache) as _newProp => - failwith("This will never be called because it is gated") - | Style(s) as _newProp => - /* let () = Js.log ("Mutating Style", elem, oldProp, _newProp) in */ - [@ocaml.warning "-4"] - ( - switch (oldProp) { - | Style(oldS) => - List.fold_left2( - ((), (ok, ov), (nk, nv)) => - if (ok == nk) { - if (ov == nv) { - (); - } else { - Web.Node.setStyleProperty(elem, nk, Js.Null.return(nv)); - }; - } else { - let () = Web.Node.setStyleProperty(elem, ok, Js.Null.empty); - Web.Node.setStyleProperty(elem, nk, Js.Null.return(nv)); - }, - (), - oldS, - s, - ) - | _ => - failwith( - "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!", - ) - } - ); - -let rec patchVNodesOnElems_PropertiesApply = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - idx: int, - oldProperties: list(property('msg)), - newProperties: list(property('msg)), - ) - : bool => - /* let () = Js.log ("PROPERTY-APPLY", elem, idx, oldProperties, newProperties) in */ - [@ocaml.warning "-4"] - ( - switch (oldProperties, newProperties) { - | ([], []) => true - | ([], [_newProp, ..._newRest]) => - /* Well this is wrong, the lengths should never differ, recreate node */ - false - /* let () = patchVNodesOnElems_PropertiesApply_Add callbacks elem idx newProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx+1) [] newRest */ - | ([_oldProp, ..._oldRest], []) => - /* Well this is wrong, the lengths should never differ, recreate node */ - false - /* let () = patchVNodesOnElems_PropertiesApply_Remove callbacks elem idx oldProp in - patchVNodesOnElems_PropertiesApply callbacks elem (idx+1) [] oldRest */ - /* NoProp */ - | ([NoProp, ...oldRest], [NoProp, ...newRest]) => - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ) - /* RawProp */ - | ( - [[@implicit_arity] RawProp(oldK, oldV) as oldProp, ...oldRest], - [[@implicit_arity] RawProp(newK, newV) as newProp, ...newRest], - ) => - /* let () = Js.log ("RawProp Test", elem, idx, oldProp, newProp, oldK = newK && oldV = newV, oldRest, newRest) in */ - let () = - if (oldK == newK && oldV == newV) { - (); - } else { - patchVNodesOnElems_PropertiesApply_Mutate( - callbacks, - elem, - idx, - oldProp, - newProp, - ); - }; - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - /* Attribute */ - | ( - [ - [@implicit_arity] Attribute(oldNS, oldK, oldV) as oldProp, - ...oldRest, - ], - [ - [@implicit_arity] Attribute(newNS, newK, newV) as newProp, - ...newRest, - ], - ) => - let () = - if (oldNS == newNS && oldK == newK && oldV == newV) { - (); - } else { - patchVNodesOnElems_PropertiesApply_Mutate( - callbacks, - elem, - idx, - oldProp, - newProp, - ); - }; - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - /* Data */ - | ( - [[@implicit_arity] Data(oldK, oldV) as oldProp, ...oldRest], - [[@implicit_arity] Data(newK, newV) as newProp, ...newRest], - ) => - let () = - if (oldK == newK && oldV == newV) { - (); - } else { - patchVNodesOnElems_PropertiesApply_Mutate( - callbacks, - elem, - idx, - oldProp, - newProp, - ); - }; - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - /* Event */ - | ( - [ - [@implicit_arity] Event(oldName, oldHandlerType, oldCache) as _oldProp, - ...oldRest, - ], - [ - [@implicit_arity] Event(newName, newHandlerType, newCache) as _newProp, - ...newRest, - ], - ) => - let () = - eventHandler_Mutate( - callbacks, - elem, - oldName, - newName, - oldHandlerType, - newHandlerType, - oldCache, - newCache, - ); - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - /* Style */ - | ( - [Style(oldS) as oldProp, ...oldRest], - [Style(newS) as newProp, ...newRest], - ) => - let () = - if (oldS == newS) { - (); - } else { - patchVNodesOnElems_PropertiesApply_Mutate( - callbacks, - elem, - idx, - oldProp, - newProp, - ); - }; - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - | ([oldProp, ...oldRest], [newProp, ...newRest]) => - let () = - patchVNodesOnElems_PropertiesApply_RemoveAdd( - callbacks, - elem, - idx, - oldProp, - newProp, - ); - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - idx + 1, - oldRest, - newRest, - ); - } - ); - -let patchVNodesOnElems_Properties = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - oldProperties: list(property('msg)), - newProperties: list(property('msg)), - ) - : bool => - /* Profiling here show `=` to be very slow, but testing reveals it to be faster than checking through the properties - manually on times when there are few to no changes, which is most of the time, so keeping it for now... */ - /* TODO: Look into if there is a better way to quick test property comparisons, especially since it likely returns - false when events are included regardless of anything else. */ - /* if oldProperties = newProperties then - () - else */ - patchVNodesOnElems_PropertiesApply( - callbacks, - elem, - 0, - oldProperties, - newProperties, - ); - -let genEmptyProps = (length: int): list(property('msg)) => { - let rec aux = lst => - fun - | 0 => lst - | len => aux([noProp, ...lst], len - 1); - aux([], length); -}; - -let mapEmptyProps = (props: list(property('msg))): list(property('msg)) => - List.map(_ => noProp, props); - -let rec patchVNodesOnElems_ReplaceNode = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - elems: array(Web.Node.t), - idx: int, - ) - : (t('msg) => unit) => - [@ocaml.warning "-4"] - ( - fun - | [@implicit_arity] - Node( - newNamespace, - newTagName, - _newKey, - _newUnique, - newProperties, - newChildren, - ) => { - let oldChild = elems[idx]; - let newChild = - Web.Document.createElementNsOptional(newNamespace, newTagName); - [@ocaml.warning "-8"] - let true = - patchVNodesOnElems_Properties( - callbacks, - newChild, - mapEmptyProps(newProperties), - newProperties, - ); - let childChildren = Web.Node.childNodes(newChild); - let () = - patchVNodesOnElems( - callbacks, - newChild, - childChildren, - 0, - [], - newChildren, - ); - let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild); - let _removedChild = Web.Node.removeChild(elem, oldChild); - /* let () = Js.log ("Fullswap happened", oldChild, newChild) in */ - (); - } - | _ => - failwith( - "Node replacement should never be passed anything but a node itself", - ) - ) - -and patchVNodesOnElems_CreateElement = - (callbacks: ref(applicationCallbacks('msg))): (t('msg) => Web.Node.t) => - fun - | CommentNode(s) => Web.Document.createComment(s) - | Text(text) => Web.Document.createTextNode(text) - | [@implicit_arity] - Node( - newNamespace, - newTagName, - _newKey, - _unique, - newProperties, - newChildren, - ) => { - let newChild = - Web.Document.createElementNsOptional(newNamespace, newTagName); - [@ocaml.warning "-8"] - let true = - patchVNodesOnElems_Properties( - callbacks, - newChild, - mapEmptyProps(newProperties), - newProperties, - ); - let childChildren = Web.Node.childNodes(newChild); - let () = - patchVNodesOnElems( - callbacks, - newChild, - childChildren, - 0, - [], - newChildren, - ); - newChild; - } - | [@implicit_arity] LazyGen(_newKey, newGen, newCache) => { - let vdom = newGen(); - let () = newCache := vdom; - patchVNodesOnElems_CreateElement(callbacks, vdom); - } - | [@implicit_arity] Tagger(tagger, vdom) => - /* let () = Js.log ("Tagger", "creating", tagger, vdom) in */ - patchVNodesOnElems_CreateElement(tagger(callbacks), vdom) - -and patchVNodesOnElems_MutateNode = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - elems: array(Web.Node.t), - idx: int, - oldNode: t('msg), - newNode: t('msg), - ) - : unit => - switch (oldNode, newNode) { - | ( - [@implicit_arity] - Node( - _oldNamespace, - oldTagName, - _oldKey, - oldUnique, - oldProperties, - oldChildren, - ) as _oldNode, - [@implicit_arity] - Node( - _newNamespace, - newTagName, - _newKey, - newUnique, - newProperties, - newChildren, - ) as newNode, - ) => - /* We are being ordered to mutate the node, the key's are already handled */ - if (oldUnique != newUnique || oldTagName != newTagName) { - /* let () = Js.log ("Node test", "unique swap", elem, elems.(idx), newNode) in */ - patchVNodesOnElems_ReplaceNode(callbacks, elem, elems, idx, newNode); - } else { - /* let () = Js.log ("Node test", "non-unique mutate", elem, elems.(idx), newNode) in */ - /* Same node type, just mutate things */ - - let child = elems[idx]; - let childChildren = Web.Node.childNodes(child); - let () = - if (patchVNodesOnElems_Properties( - callbacks, - child, - oldProperties, - newProperties, - )) { - (); - } else { - /* Properties mutation failed, full swap and log */ - let () = - Js.log( - "VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved.", - ); - patchVNodesOnElems_ReplaceNode( - callbacks, - elem, - elems, - idx, - newNode, - ); - }; - patchVNodesOnElems( - callbacks, - child, - childChildren, - 0, - oldChildren, - newChildren, - ); - } - | _ => failwith("Non-node passed to patchVNodesOnElems_MutateNode") - } - -and patchVNodesOnElems = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - elems: array(Web.Node.t), - idx: int, - oldVNodes: list(t('msg)), - newVNodes: list(t('msg)), - ) - : unit => - /* let () = Js.log ("patchVNodesOnElems", elem, elems, idx, oldVNodes, newVNodes) in */ - [@ocaml.warning "-4"] - ( - switch (oldVNodes, newVNodes) { - | ([[@implicit_arity] Tagger(_oldTagger, oldVdom), ...oldRest], _) => - /* let () = Js.log ("Tagger", "old", oldTagger, oldVdom) in */ - patchVNodesOnElems( - callbacks, - elem, - elems, - idx, - [oldVdom, ...oldRest], - newVNodes, - ) - | ( - [oldNode, ...oldRest], - [[@implicit_arity] Tagger(newTagger, newVdom), ...newRest], - ) => - /* let () = Js.log ("Tagger", "new", newTagger, newVdom) in */ - let () = - patchVNodesOnElems( - newTagger(callbacks), - elem, - elems, - idx, - [oldNode], - [newVdom], - ); - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - | ([], []) => () - | ([], [newNode, ...newRest]) => - let newChild = patchVNodesOnElems_CreateElement(callbacks, newNode); - let _attachedChild = Web.Node.appendChild(elem, newChild); - patchVNodesOnElems(callbacks, elem, elems, idx + 1, [], newRest); - | ([_oldVnode, ...oldRest], []) => - let child = elems[idx]; - let _removedChild = Web.Node.removeChild(elem, child); - patchVNodesOnElems(callbacks, elem, elems, idx, oldRest, []); /* Not changing idx so we can delete the rest too */ - | ([CommentNode(oldS), ...oldRest], [CommentNode(newS), ...newRest]) - when oldS == newS => - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) - | ([Text(oldText), ...oldRest], [Text(newText), ...newRest]) => - let () = - if (oldText == newText) { - (); - } else { - let child = elems[idx]; - Web.Node.set_nodeValue(child, newText); - }; - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - | ( - [[@implicit_arity] LazyGen(oldKey, _oldGen, oldCache), ...oldRest], - [[@implicit_arity] LazyGen(newKey, newGen, newCache), ...newRest], - ) => - if (oldKey == newKey) { - /* let () = Js.log ("Lazy match!", oldKey, newKey, elem, elems, idx) in */ - let () = newCache := oldCache^; /* Don't forget to pass the cache along... */ - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - } else { - switch (oldRest, newRest) { - | ( - [ - [@implicit_arity] LazyGen(olderKey, _olderGen, _olderCache), - ...olderRest, - ], - [ - [@implicit_arity] LazyGen(newerKey, _newerGen, _newerCache), - ...newerRest, - ], - ) - when olderKey == newKey && oldKey == newerKey => - /* let () = Js.log ("Lazy older newer swap", olderKey, oldKey, newKey, newerKey, elem, elems.(idx)) in */ - /* TODO: Test this branch, it is untested thus far */ - let firstChild = elems[idx]; - let secondChild = elems[idx + 1]; - let _removedChild = Web.Node.removeChild(elem, secondChild); - let _attachedChild = - Web.Node.insertBefore(elem, secondChild, firstChild); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 2, - olderRest, - newerRest, - ); - | ( - [ - [@implicit_arity] LazyGen(olderKey, _olderGen, olderCache), - ...olderRest, - ], - _, - ) - when olderKey == newKey => - /* let () = Js.log ("Lazy older match", olderKey, oldKey, newKey, elem, elems.(idx)) in */ - let oldChild = elems[idx]; - let _removedChild = Web.Node.removeChild(elem, oldChild); - let oldVdom = olderCache^; - let () = newCache := oldVdom; /* Don't forget to pass the cache along... */ - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 1, - olderRest, - newRest, - ); - | ( - _, - [ - [@implicit_arity] LazyGen(newerKey, _newerGen, _newerCache), - ..._newerRest, - ], - ) - when newerKey == oldKey => - /* let () = Js.log ("Lazy newer match", "parse", oldKey, newKey, newerKey, elem, elems.(idx)) in */ - let oldChild = elems[idx]; - let newVdom = newGen(); - let () = newCache := newVdom; /* Don't forget to pass the cache along... */ - let newChild = patchVNodesOnElems_CreateElement(callbacks, newVdom); - let _attachedChild = - Web.Node.insertBefore(elem, newChild, oldChild); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 1, - oldVNodes, - newRest, - ); - | _ => - /* let () = Js.log ("Lazy nomatch", oldKey, newKey, elem, elems.(idx)) in */ - let oldVdom = oldCache^; - let newVdom = newGen(); - let () = newCache := newVdom; /* Don't forget to pass the cache along... */ - patchVNodesOnElems( - callbacks, - elem, - elems, - idx, - [oldVdom, ...oldRest], - [newVdom, ...newRest], - ); - }; - } - | ( - [ - [@implicit_arity] - Node( - oldNamespace, - oldTagName, - oldKey, - _oldUnique, - _oldProperties, - _oldChildren, - ) as oldNode, - ...oldRest, - ], - [ - [@implicit_arity] - Node( - newNamespace, - newTagName, - newKey, - _newUnique, - _newProperties, - _newChildren, - ) as newNode, - ...newRest, - ], - ) => - if (oldKey == newKey && oldKey != "") { - /* let () = Js.log ("Node test", "match", elem, elems.(idx), newNode) in */ - /* Do nothing, they are keyed identically */ - - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - } else if (oldKey == "" || newKey == "") { - let () = - patchVNodesOnElems_MutateNode( - callbacks, - elem, - elems, - idx, - oldNode, - newNode, - ); - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - } else { - /* Keys do not match but do exist */ - switch (oldRest, newRest) { - | ( - [ - [@implicit_arity] - Node( - olderNamespace, - olderTagName, - olderKey, - _olderUnique, - _olderProperties, - _olderChildren, - ), - ...olderRest, - ], - [ - [@implicit_arity] - Node( - newerNamespace, - newerTagName, - newerKey, - _newerUnique, - _newerProperties, - _newerChildren, - ), - ...newerRest, - ], - ) - when - olderNamespace == newNamespace - && olderTagName == newTagName - && olderKey == newKey - && oldNamespace == newerNamespace - && oldTagName == newerTagName - && oldKey == newerKey => - /* let () = Js.log ("Node test", "older newer swap", elem, elems.(idx), newNode) in */ - /* TODO: Test this branch, it is untested thus far */ - let firstChild = elems[idx]; - let secondChild = elems[idx + 1]; - let _removedChild = Web.Node.removeChild(elem, secondChild); - let _attachedChild = - Web.Node.insertBefore(elem, secondChild, firstChild); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 2, - olderRest, - newerRest, - ); - | ( - [ - [@implicit_arity] - Node( - olderNamespace, - olderTagName, - olderKey, - _olderUnique, - _olderProperties, - _olderChildren, - ), - ...olderRest, - ], - _, - ) - when - olderNamespace == newNamespace - && olderTagName == newTagName - && olderKey == newKey => - /* let () = Js.log ("Node test", "older match", elem, elems.(idx), newNode) in */ - let oldChild = elems[idx]; - let _removedChild = Web.Node.removeChild(elem, oldChild); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 1, - olderRest, - newRest, - ); - | ( - _, - [ - [@implicit_arity] - Node( - newerNamespace, - newerTagName, - newerKey, - _newerUnique, - _newerProperties, - _newerChildren, - ), - ..._newerRest, - ], - ) - when - oldNamespace == newerNamespace - && oldTagName == newerTagName - && oldKey == newerKey => - /* let () = Js.log ("Node test", "newer match", elem, elems.(idx), newNode) in */ - let oldChild = elems[idx]; - let newChild = patchVNodesOnElems_CreateElement(callbacks, newNode); - let _attachedChild = - Web.Node.insertBefore(elem, newChild, oldChild); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 1, - oldVNodes, - newRest, - ); - | _ => - let () = - patchVNodesOnElems_MutateNode( - callbacks, - elem, - elems, - idx, - oldNode, - newNode, - ); - patchVNodesOnElems( - callbacks, - elem, - elems, - idx + 1, - oldRest, - newRest, - ); - }; - } - | ([_oldVnode, ...oldRest], [newNode, ...newRest]) => - let oldChild = elems[idx]; - let newChild = patchVNodesOnElems_CreateElement(callbacks, newNode); - let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild); - let _removedChild = Web.Node.removeChild(elem, oldChild); - patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest); - } - ); - -let patchVNodesIntoElement = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - oldVNodes: list(t('msg)), - newVNodes: list(t('msg)), - ) - : list(t('msg)) => { - let elems = Web.Node.childNodes(elem); - let () = - patchVNodesOnElems(callbacks, elem, elems, 0, oldVNodes, newVNodes); /* Planning to return an altered vdom set here instead of using mutation... */ - newVNodes; -}; - -let patchVNodeIntoElement = - ( - callbacks: ref(applicationCallbacks('msg)), - elem: Web.Node.t, - oldVNode: t('msg), - newVNode: t('msg), - ) - : list(t('msg)) => - patchVNodesIntoElement(callbacks, elem, [oldVNode], [newVNode]); - -let wrapCallbacks_On: - type a b. (a => b, systemMessage(a)) => systemMessage(b) = - func => - fun - | Render => Render - | AddRenderMsg(msg) => AddRenderMsg(func(msg)) - | RemoveRenderMsg(msg) => RemoveRenderMsg(func(msg)); - -let wrapCallbacks: - type a b. - (a => b, ref(applicationCallbacks(b))) => ref(applicationCallbacks(a)) = - (func, callbacks) => - Obj.magic( - ref, - { - enqueue: (msg: a) => { - let new_msg = func(msg); - callbacks^.enqueue(new_msg); - }, - on: smsg => { - let new_smsg = wrapCallbacks_On(func, smsg); - callbacks^.on(new_smsg); - }, - }, - ); - -let map: ('a => 'b, t('a)) => t('b) = ( - (func, vdom) => { - let tagger = wrapCallbacks(func); - [@implicit_arity] Tagger(Obj.magic(tagger), Obj.magic(vdom)); - }: - ('a => 'b, t('a)) => t('b) -); diff --git a/src-reason/web.re b/src-reason/web.re deleted file mode 100644 index 6d1d2ad..0000000 --- a/src-reason/web.re +++ /dev/null @@ -1,23 +0,0 @@ -module Event = Web_event; - -module Node = Web_node; - -module Document = Web_document; - -module Date = Web_date; - -module Window = Web_window; - -module Location = Web_location; - -module Json = Web_json; - -module XMLHttpRequest = Web_xmlhttprequest; - -module FormData = Web_formdata; - -let polyfills = () => { - let () = Node.remove_polyfill(); - let () = Window.requestAnimationFrame_polyfill(); - (); -}; diff --git a/src-reason/web_date.re b/src-reason/web_date.re deleted file mode 100644 index 9781e90..0000000 --- a/src-reason/web_date.re +++ /dev/null @@ -1,9 +0,0 @@ -type t = Js.t({.}); - -type date_obj = {. [@bs.meth] "now": unit => float}; - -[@bs.new] external create_date : unit => t = "Date"; - -[@bs.val] external date_obj : date_obj = "Date"; - -let now = () => date_obj##now(); diff --git a/src-reason/web_document.re b/src-reason/web_document.re deleted file mode 100644 index 94d347e..0000000 --- a/src-reason/web_document.re +++ /dev/null @@ -1,34 +0,0 @@ -/* TODO: Polyfill document if it is missing, like on node or in native */ -type t = { - . - [@bs.get] "body": Web_node.t, - [@bs.meth] "createElement": string => Web_node.t, - [@bs.meth] "createElementNS": (string, string) => Web_node.t, - [@bs.meth] "createComment": string => Web_node.t, - [@bs.meth] "createTextNode": string => Web_node.t, - [@bs.meth] "getElementById": string => Js.null_undefined(Web_node.t), - [@bs.get] "location": Web_location.t, -}; - -[@bs.val] external document : t = "document"; - -let body = () => document##body; - -let createElement = typ => document##createElement(typ); - -let createElementNS = (namespace, key) => - document##createElementNS(namespace, key); - -let createComment = text => document##createComment(text); - -let createTextNode = text => document##createTextNode(text); - -let getElementById = id => document##getElementById(id); - -let createElementNsOptional = (namespace, tagName) => - switch (namespace) { - | "" => document##createElement(tagName) - | ns => document##createElementNS(ns, tagName) - }; - -let location = () => document##location; diff --git a/src-reason/web_event.re b/src-reason/web_event.re deleted file mode 100644 index 1becbfb..0000000 --- a/src-reason/web_event.re +++ /dev/null @@ -1,18 +0,0 @@ -/* type target = < - value : string Js.undefined [@bs.get]; - > Js.t */ -type t('node) = { - . - [@bs.get] "target": Js.undefined('node), - [@bs.get] "keyCode": int, - [@bs.meth] "preventDefault": unit => unit, - [@bs.meth] "stopPropagation": unit => unit, -}; - -type cb('node) = (. t('node)) => unit; - -type options = bool; /* false | true (* TODO: Define a javascript record as another option *) */ - -type popstateEvent = Js.t({.}); - -type popstateCb = (. popstateEvent) => unit; diff --git a/src-reason/web_formdata.re b/src-reason/web_formdata.re deleted file mode 100644 index ae55d17..0000000 --- a/src-reason/web_formdata.re +++ /dev/null @@ -1,12 +0,0 @@ -class type _formdata = - [@bs] - { - pub append: (string, string) => unit - }; - /* method append_blob : string -> Web_blob.t -> string -> unit */ - -type t = Js.t(_formdata); - -[@bs.new] external create : unit => t = "FormData"; - -let append = (key, value, f) => f##append(key, value); diff --git a/src-reason/web_json.re b/src-reason/web_json.re deleted file mode 100644 index 779f931..0000000 --- a/src-reason/web_json.re +++ /dev/null @@ -1,20 +0,0 @@ -include Js.Json; - -type nothingYet; - -[@bs.val] -external stringify : ('t, Js.null(nothingYet), int) => string = - "JSON.stringify"; - -let string_of_json = (~indent=2, value) => - switch (Js.Undefined.toOption(value)) { - | None => "undefined" - | Some(v) => - try (stringify(v, Js.Null.empty, indent)) { - | _ => "" - } - }; - -let of_type = (type a, _v: kind(a), x: a) : t => Obj.magic(x); - -let null: Js_types.null_val = Obj.magic(Js.null); diff --git a/src-reason/web_location.re b/src-reason/web_location.re deleted file mode 100644 index 07effe9..0000000 --- a/src-reason/web_location.re +++ /dev/null @@ -1,84 +0,0 @@ -type t = { - . - [@bs.get] [@bs.set] "href": string, - [@bs.get] [@bs.set] "protocol": string, - [@bs.get] [@bs.set] "host": string, - [@bs.get] [@bs.set] "hostname": string, - [@bs.get] [@bs.set] "port": string, - [@bs.get] [@bs.set] "pathname": string, - [@bs.get] [@bs.set] "search": string, - [@bs.get] [@bs.set] "hash": string, - [@bs.get] [@bs.set] "username": string, - [@bs.get] [@bs.set] "password": string, - [@bs.get] "origin": string, -}; - -let getHref = location => location##href; - -let setHref = (location, value) => location##href#=value; - -let getProtocol = location => location##protocol; - -let setProtocol = (location, value) => location##protocol#=value; - -let getHost = location => location##host; - -let setHost = (location, value) => location##host#=value; - -let getHostname = location => location##hostname; - -let setHostname = (location, value) => location##hostname#=value; - -let getPort = location => location##port; - -let setPort = (location, value) => location##port#=value; - -let getPathname = location => location##pathname; - -let setPathname = (location, value) => location##pathname#=value; - -let getSearch = location => location##search; - -let setSearch = (location, value) => location##search#=value; - -let getHash = location => location##hash; - -let setHash = (location, value) => location##hash#=value; - -let getUsername = location => location##username; - -let setUsername = (location, value) => location##username#=value; - -let getPassword = location => location##password; - -let setPassword = (location, value) => location##password#=value; - -let getOrigin = location => location##origin; - -type location = { - href: string, - protocol: string, - host: string, - hostname: string, - port: string, - pathname: string, - search: string, - hash: string, - username: string, - password: string, - origin: string, -}; - -let asRecord = location => { - href: location##href, - protocol: location##protocol, - host: location##host, - hostname: location##hostname, - port: location##port, - pathname: location##pathname, - search: location##search, - hash: location##hash, - username: location##username, - password: location##password, - origin: location##origin, -}; diff --git a/src-reason/web_node.re b/src-reason/web_node.re deleted file mode 100644 index 6310388..0000000 --- a/src-reason/web_node.re +++ /dev/null @@ -1,141 +0,0 @@ -type style = { - . - [@bs.get] "setProperty": Js.undefined(Web_json.t), /* TODO: Revamp this and the next line... */ - [@bs.meth] - "setProperty__": (string, Js.null(string), Js.null(string)) => unit, -}; - -[@bs.get_index] external getStyle : (style, string) => Js.null(string) = ""; - -[@bs.set_index] -external setStyle : (style, string, Js.null(string)) => unit = ""; - -type t = { - . - [@bs.get] "style": style, - [@bs.set] [@bs.get] "value": Js.undefined(string), - [@bs.set] [@bs.get] "checked": Js.undefined(bool), - [@bs.get] "childNodes": Js.Array.t(t), - [@bs.get] "firstChild": Js.Null.t(t), - [@bs.meth] "appendChild": t => t, - [@bs.meth] "removeChild": t => t, - [@bs.meth] "insertBefore": (t, t) => t, - [@bs.meth] "remove": unit => unit, - [@bs.meth] "setAttributeNS": (string, string, string) => unit, - [@bs.meth] "setAttribute": (string, string) => unit, - [@bs.meth] "removeAttributeNS": (string, string) => unit, - [@bs.meth] "removeAttribute": string => unit, - [@bs.meth] - "addEventListener": (string, Web_event.cb(t), Web_event.options) => unit, - [@bs.meth] - "removeEventListener": (string, Web_event.cb(t), Web_event.options) => unit, - [@bs.meth] "focus": unit => unit, - /* Text Nodes only */ - [@bs.set] [@bs.get {null: null}] "nodeValue": string, -}; - -[@bs.val] external document_node : t = "document"; - -type event = Web_event.t(t); - -type event_cb = Web_event.cb(t); - -[@bs.get_index] -external getProp_asEventListener : (t, 'key) => Js.undefined(Web_event.cb(t)) = - ""; - -[@bs.set_index] -external setProp_asEventListener : - (t, 'key, Js.undefined(Web_event.cb(t))) => unit = - ""; - -[@bs.get_index] external getProp : (t, 'key) => 'value = ""; - -[@bs.set_index] external setProp : (t, 'key, 'value) => unit = ""; - -let style = n => n##style; - -let getStyle = (n, key) => getStyle(n##style, key); - -let setStyle = (n, key, value) => setStyle(n##style, key, value); - -let setStyleProperty = (n, ~priority=false, key, value) => { - let style = n##style; - switch (Js.Undefined.toOption(style##setProperty)) { - | None => setStyle(n, key, value) /* TODO: Change this to setAttribute sometime, maybe... */ - | Some(_valid) => - style##setProperty__( - key, - value, - if (priority) { - Js.Null.return("important"); - } else { - Js.Null.empty; - }, - ) - }; -}; - -let childNodes = n => n##childNodes; - -let firstChild = n => n##firstChild; - -let appendChild = (n, child) => n##appendChild(child); - -let removeChild = (n, child) => n##removeChild(child); - -let insertBefore = (n, child, refNode) => n##insertBefore(child, refNode); - -let remove = (n, child) => n##remove(child); - -let setAttributeNS = (n, namespace, key, value) => - n##setAttributeNS(namespace, key, value); - -let setAttribute = (n, key, value) => n##setAttribute(key, value); - -let setAttributeNsOptional = (n, namespace, key, value) => - switch (namespace) { - | "" => n##setAttribute(key, value) - | ns => n##setAttributeNS(ns, key, value) - }; - -let removeAttributeNS = (n, namespace, key) => - n##removeAttributeNS(namespace, key); - -let removeAttribute = (n, key) => n##removeAttribute(key); - -let removeAttributeNsOptional = (n, namespace, key) => - switch (namespace) { - | "" => n##removeAttribute(key) - | ns => n##removeAttributeNS(ns, key) - }; - -let addEventListener = (n, typ, listener, options) => - n##addEventListener(typ, listener, options); - -let removeEventListener = (n, typ, listener, options) => - n##removeEventListener(typ, listener, options); - -let focus = n => n##focus(); - -/* Text Nodes only */ -let set_nodeValue = (n, text) => n##nodeValue#=text; - -let get_nodeValue = n => n##nodeValue; - -/* Polyfills */ -let remove_polyfill: unit => unit = - () => [%bs.raw - {| - // remove polyfill - (function() { - if (!('remove' in Element.prototype)) { - Element.prototype.remove = function() { - if (this.parentNode) { - this.parentNode.removeChild(this); - } - }; - }; - }()) - |} - ]; diff --git a/src-reason/web_window.re b/src-reason/web_window.re deleted file mode 100644 index 5eabead..0000000 --- a/src-reason/web_window.re +++ /dev/null @@ -1,82 +0,0 @@ -/* TODO: Polyfill window if it is missing, like on node or in native */ -module History = Web_window_history; - -module LocalStorage = Web_window_localstorage; - -type timeoutHandlerID = int; - -type t = { - . - [@bs.get] "history": Js.Undefined.t(History.t), - [@bs.get] "location": Web_location.t, - [@bs.meth] "clearTimeout": timeoutHandlerID => unit, - [@bs.meth] "requestAnimationFrame": (float => unit) => int, - [@bs.meth] "cancelAnimationFrame": int => unit, - [@bs.meth] "setInterval": (unit => unit, float) => timeoutHandlerID, - [@bs.meth] "setTimeout": (unit => unit, float) => timeoutHandlerID, - [@bs.meth] - "addEventListener": - (string, Web_event.cb(Web_node.t), Web_event.options) => unit, - [@bs.meth] - "removeEventListener": - (string, Web_event.cb(Web_node.t), Web_event.options) => unit, - [@bs.get] "localStorage": Js.Undefined.t(LocalStorage.t), -}; - -[@bs.val] external window : t = "window"; - -let history = () => window##history; - -let localStorage = () => window##localStorage; - -let location = () => window##location; - -/* requestAnimationFrame callback is a float timestamp in milliseconds */ -let requestAnimationFrame = callback => - window##requestAnimationFrame(callback); - -let cancelAnimationFrame = id => window##cancelAnimationFrame(id); - -let clearTimeout = id => window##clearTimeout(id); - -let setInterval = (cb, msTime) => window##setInterval(cb, msTime); - -let setTimeout = (cb, msTime) => window##setTimeout(cb, msTime); - -let addEventListener = (typ, listener, options) => - window##addEventListener(typ, listener, options); - -let removeEventListener = (typ, listener, options) => - window##removeEventListener(typ, listener, options); - -/* Polyfills */ -let requestAnimationFrame_polyfill: unit => unit = - () => [%bs.raw - {| - // requestAnimationFrame polyfill - (function() { - var lastTime = 0; - var vendors = ['ms', 'moz', 'webkit', 'o']; - for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { - window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] - || window[vendors[x]+'CancelRequestAnimationFrame']; - } - - if (!window.requestAnimationFrame) - window.requestAnimationFrame = function(callback, element) { - var currTime = new Date().getTime(); - var timeToCall = Math.max(0, 16 - (currTime - lastTime)); - var id = window.setTimeout(function() { callback(currTime + timeToCall); }, - timeToCall); - lastTime = currTime + timeToCall; - return id; - }; - - if (!window.cancelAnimationFrame) - window.cancelAnimationFrame = function(id) { - clearTimeout(id); - }; - }()) - |} - ]; diff --git a/src-reason/web_window_history.re b/src-reason/web_window_history.re deleted file mode 100644 index 80d9d44..0000000 --- a/src-reason/web_window_history.re +++ /dev/null @@ -1,52 +0,0 @@ -type t = { - . - [@bs.get] "length": int, - [@bs.meth] "back": unit => unit, - [@bs.meth] "forward": unit => unit, - [@bs.meth] "go": int => unit, - [@bs.meth] "pushState": (Js.Json.t, string, string) => unit, - [@bs.meth] "replaceState": (Js.Json.t, string, string) => unit, - [@bs.get] "state": Js.Json.t, -}; - -let length = window => - switch (Js.Undefined.toOption(window##history)) { - | None => (-1) - | Some(history) => history##length - }; - -let back = window => - switch (Js.Undefined.toOption(window##history)) { - | None => () - | Some(history) => history##back - }; - -let forward = window => - switch (Js.Undefined.toOption(window##history)) { - | None => () - | Some(history) => history##forward - }; - -let go = (window, to') => - switch (Js.Undefined.toOption(window##history)) { - | None => () - | Some(history) => history##go(to') - }; - -let pushState = (window, state, title, url) => - switch (Js.Undefined.toOption(window##history)) { - | None => () - | Some(history) => history##pushState(state, title, url) - }; - -let replaceState = (window, state, title, url) => - switch (Js.Undefined.toOption(window##history)) { - | None => () - | Some(history) => history##replaceState(state, title, url) - }; - -let state = window => - switch (Js.Undefined.toOption(window##history)) { - | None => Js.Undefined.empty - | Some(history) => history##state - }; diff --git a/src-reason/web_window_localstorage.re b/src-reason/web_window_localstorage.re deleted file mode 100644 index 16e70a3..0000000 --- a/src-reason/web_window_localstorage.re +++ /dev/null @@ -1,48 +0,0 @@ -type t = { - . - [@bs.get] "length": int, - [@bs.meth] "clear": unit => unit, - [@bs.meth] "key": int => string, - [@bs.meth] "getItem": string => string, - [@bs.meth] "removeItem": string => unit, - [@bs.meth] "setItem": (string, string) => unit, -}; - -let length = window => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => Some(localStorage##length) - }; - -let clear = window => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => Some(localStorage##clear()) - }; - -let key = (window, idx) => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => Some(localStorage##key(idx)) - }; - -let getItem = (window, key) => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => - try (Some(localStorage##getItem(key))) { - | _ => None - } - }; - -let removeItem = (window, key) => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => Some(localStorage##removeItem(key)) - }; - -let setItem = (window, key, value) => - switch (Js.Undefined.toOption(window##localStorage)) { - | None => None - | Some(localStorage) => Some(localStorage##setItem(key, value)) - }; diff --git a/src-reason/web_xmlhttprequest.re b/src-reason/web_xmlhttprequest.re deleted file mode 100644 index c2427ec..0000000 --- a/src-reason/web_xmlhttprequest.re +++ /dev/null @@ -1,306 +0,0 @@ -type unresolved; - -type xmlHttpRequestUpload; - -type event_readystatechange = Web_json.t; -type event_abort = Web_json.t; -type event_error = Web_json.t; -type event_load = Web_json.t; -type event_loadstart = Web_json.t; -type event_progress = Web_json.t; -type event_timeout = Web_json.t; -type event_loadend = Web_json.t; - -class type _xmlhttprequest = - [@bs] - { - pub abort: unit => unit; - pub getAllResponseHeaders: unit => Js.null(string); - pub getResponseHeader: string => Js.null(string); - pub _open: (string, string, bool, string, string) => unit; - pub overrideMimeType: string => unit; - pub send: unit => unit; - pub send__string: Js.null(string) => unit; - pub send__formdata: Web_formdata.t => unit; - pub send__document: Web_document.t => unit; - /* method send_blob : Web_blob.t -> unit */ - /* method send_arrayBufferView : Web_arraybuffer_view.t -> unit */ - pub setRequestHeader: (string, string) => unit; - /* Properties */ - [@bs.get] - [@bs.set] - pub onreadystatechange: event_readystatechange => unit; - [@bs.get] - pub readyState: int; - [@bs.get] - [@bs.set] - pub responseType: string; - [@bs.get] - pub response: Js.null(unresolved); - [@bs.get] - pub responseText: string; - [@bs.get] - pub responseURL: string; - [@bs.get] - pub responseXML: Js.null(Web_document.t); - [@bs.get] - pub status: int; - [@bs.get] - pub statusText: string; - [@bs.get] - [@bs.set] - pub timeout: float; - [@bs.get] - pub upload: xmlHttpRequestUpload; - [@bs.get] - [@bs.set] - pub withCredentials: bool; - /* Base events */ - [@bs.get] - [@bs.set] - pub onabort: event_abort => unit; - [@bs.get] - [@bs.set] - pub onerror: event_error => unit; - [@bs.get] - [@bs.set] - pub onload: event_load => unit; - [@bs.get] - [@bs.set] - pub onloadstart: event_loadstart => unit; - [@bs.get] - [@bs.set] - pub onprogress: event_loadstart => unit; - [@bs.get] - [@bs.set] - pub ontimeout: event_timeout => unit; - [@bs.get] - [@bs.set] - pub onloadend: event_loadend => unit - }; - /* Methods */ -type t = Js.t(_xmlhttprequest); - -[@bs.new] external create : unit => t = "XMLHttpRequest"; - -type errors = - | IncompleteResponse - | NetworkError; - -type body = - | EmptyBody - | EmptyStringBody - | StringBody(string) - | FormDataBody(Web_formdata.t) - | FormListBody(list((string, string))) - | DocumentBody(Web_document.t); -/* | BlobBody of Web_blob.t */ -/* | ArrayBufferViewBody of Web_arraybuffer_view.t */ - -/* Main interface functions */ - -let abort = (x: t) : unit => x##abort(); - -let getAllResponseHeaders = (x: t) : Tea_result.t(string, errors) => - Tea_result.( - switch (Js.Null.toOption(x##getAllResponseHeaders())) { - | None => Error(IncompleteResponse) - | Some("") => Error(NetworkError) - | Some(s) => Ok(s) - } - ); - -let getAllResponseHeadersAsList = - (x: t) - : Tea_result.t(list((string, string)), errors) => - Tea_result.( - switch (getAllResponseHeaders(x)) { - | Error(_) as err => err - | Ok(s) => - Ok( - s - |> Js.String.split("\r\n") - |> Array.map(Js.String.splitAtMost(": ", ~limit=2)) - |> Array.to_list - |> List.filter(a => Array.length(a) === 2) - |> List.map( - fun - | [|key, value|] => (key, value) - | _ => failwith("Cannot happen, already checked length"), - ), - ) - } - ); - -let getAllResponseHeadersAsDict = - (x: t) - : Tea_result.t(Map.Make(String).t(string), errors) => { - module StringMap = Map.Make(String); - switch (getAllResponseHeadersAsList(x)) { - | Tea_result.Error(_) as err => err - | Tea_result.Ok(l) => - let insert = (d, (k, v)) => StringMap.add(k, v, d); - Tea_result.Ok(List.fold_left(insert, StringMap.empty, l)); - }; -}; - -let getResponseHeader = (key, x) => Js.Null.toOption(x##getResponse(key)); - -let open_ = - (method': string, url: string, ~async=true, ~user="", ~password="", x) => - x##_open(method', url, async, user, password); - -let overrideMimeType = (mimetype: string, x: t) : unit => - x##overrideMimeType(mimetype); - -let send = (body: body, x: t) : unit => - switch (body) { - | EmptyBody => x##send() - | EmptyStringBody => x##send__string(Js.Null.empty) - | StringBody(s) => x##send__string(Js.Null.return(s)) - | FormDataBody(f) => x##send__formdata(f) - | FormListBody(l) => - let form = - List.fold_left( - (f, (key, value)) => { - let () = Web_formdata.append(key, value, f); - f; - }, - Web_formdata.create(), - l, - ); - x##send__formdata(form); - | DocumentBody(d) => x##send__document(d) - }; -/* | BlobBody b -> x##send_blob b */ -/* | ArrayBufferViewBody a -> x##send_arrayBufferView a */ - -let setRequestHeader = (header: string, value: string, x: t) => - x##setRequestHeader(header, value); - -/* Properties */ - -type state = - | Unsent - | Opened - | HeadersReceived - | Loading - | Done; - -type responseType = - | StringResponseType - | ArrayBufferResponseType - | BlobResponseType - | DocumentResponseType - | JsonResponseType - | TextResponseType - | RawResponseType(string); - -type responseBody = - | NoResponse - | StringResponse(string) - | ArrayBufferResponse(unit) - | BlobResponse(unit) - | DocumentResponse(Web_document.t) - | JsonResponse(Web_json.t) - | TextResponse(string) - | RawResponse(string, unit); - -let set_onreadystatechange = (cb: event_readystatechange => unit, x: t) : unit => x##onreadystatechange#=cb; - -let get_onreadystatechange = (x: t) : (event_readystatechange => unit) => x##onreadystatechange; - -let readyState = (x: t) : state => - switch (x##readyState) { - | 0 => Unsent - | 1 => Opened - | 2 => HeadersReceived - | 3 => Loading - | 4 => Done - | i => - failwith("Invalid return from 'readystate' of: " ++ string_of_int(i)) - }; - -let set_responseType = (typ: responseType, x: t) : unit => - switch (typ) { - | StringResponseType => x##responseType#="" - | ArrayBufferResponseType => x##responseType#="arraybuffer" - | BlobResponseType => x##responseType#="blob" - | DocumentResponseType => x##responseType#="document" - | JsonResponseType => x##responseType#="json" - | TextResponseType => x##responseType#="text" - | RawResponseType(s) => x##responseType#=s - }; - -let get_responseType = (x: t) : responseType => - switch (x##responseType) { - | "" => StringResponseType - | "arraybuffer" => ArrayBufferResponseType - | "blob" => BlobResponseType - | "document" => DocumentResponseType - | "json" => JsonResponseType - | "text" => TextResponseType - | s => RawResponseType(s) - }; - -let get_response = (x: t) : responseBody => - switch (Js.Null.toOption(x##response)) { - | None => NoResponse - | Some(resp) => - switch (get_responseType(x)) { - | StringResponseType => StringResponse(Obj.magic(resp)) - | ArrayBufferResponseType => ArrayBufferResponse(Obj.magic(resp)) - | BlobResponseType => BlobResponse(Obj.magic(resp)) - | DocumentResponseType => DocumentResponse(Obj.magic(resp)) - | JsonResponseType => JsonResponse(Obj.magic(resp)) - | TextResponseType => TextResponse(Obj.magic(resp)) - | RawResponseType(s) => [@implicit_arity] RawResponse(s, Obj.magic(resp)) - } - }; - -let get_responseText = (x: t) : string => x##responseText; - -let get_responseURL = (x: t) : string => x##responseURL; - -let get_responseXML = (x: t) : option(Web_document.t) => - Js.Null.toOption(x##responseXML); - -let get_status = (x: t) : int => x##status; - -let get_statusText = (x: t) : string => x##statusText; - -let set_timeout = (t: float, x: t) : unit => x##timeout#=t; - -let get_timeout = (x: t) : float => x##timeout; - -let set_withCredentials = (b: bool, x: t) : unit => x##withCredentials#=b; - -let get_withCredentials = (x: t) : bool => x##withCredentials; - -let set_onabort = (cb: event_abort => unit, x: t) : unit => x##onabort#=cb; - -let get_onabort = (x: t) : (event_abort => unit) => x##onabort; - -let set_onerror = (cb: event_error => unit, x: t) : unit => x##onerror#=cb; - -let get_onerror = (x: t) : (event_error => unit) => x##onerror; - -let set_onload = (cb: event_load => unit, x: t) : unit => x##onload#=cb; - -let get_onload = (x: t) : (event_load => unit) => x##onload; - -let set_onloadstart = (cb: event_loadstart => unit, x: t) : unit => x##onloadstart#=cb; - -let get_onloadstart = (x: t) : (event_loadstart => unit) => x##onloadstart; - -let set_onprogress = (cb: event_loadstart => unit, x: t) : unit => x##onprogress#=cb; - -let get_onprogress = (x: t) : (event_loadstart => unit) => x##onprogress; - -let set_ontimeout = (cb: event_timeout => unit, x: t) : unit => x##ontimeout#=cb; - -let get_ontimeout = (x: t) : (event_timeout => unit) => x##ontimeout; - -let set_onloadend = (cb: event_loadend => unit, x: t) : unit => x##onloadend#=cb; - -let get_onloadend = (x: t) : (event_loadend => unit) => x##onloadend; diff --git a/src/rescript_json_combinators_extended.res b/src/rescript_json_combinators_extended.res new file mode 100644 index 0000000..d011e16 --- /dev/null +++ b/src/rescript_json_combinators_extended.res @@ -0,0 +1,27 @@ +open JsonCombinators + +let rec at = (key_path, decoder) => + switch key_path { + | list{key} => Json.Decode.field(key, decoder) + | list{first, ...rest} => Json.Decode.field(first, at(rest, decoder)) + | list{} => + \"@@"( + raise, + Invalid_argument("Expected key_path to contain at least one element"), + ) + } + + +let decodeString = (decoder, string) => + try { + let value = Js.Json.parseExn(string) + JsonCombinators.Json.Decode.decode(value,decoder) + } catch { + /* | JsException e -> Error ("Given an invalid JSON: " ^ e) */ + | _ => Error("Invalid JSON string") + } + +let succeed = v => Json.Decode.custom((. _value) => v) + +let decodeEvent = (decoder, value: Web_node.event) => + value->Obj.magic->Json.decode(decoder) diff --git a/src/rescript_json_combinators_extended.resi b/src/rescript_json_combinators_extended.resi new file mode 100644 index 0000000..86a0f5d --- /dev/null +++ b/src/rescript_json_combinators_extended.resi @@ -0,0 +1,7 @@ +let at: (list, JsonCombinators.Json.Decode.t<'a>) => JsonCombinators.Json.Decode.t<'a> + +let decodeString: (JsonCombinators.Json.Decode.t<'a>, string) => result<'a, string> + +let succeed: 'a => JsonCombinators.Json.Decode.t<'a> + +let decodeEvent: (JsonCombinators.Json.Decode.t<'a>, Web_node.event) => result<'a, string> diff --git a/src-ocaml/tea.ml b/src/tea.res similarity index 69% rename from src-ocaml/tea.ml rename to src/tea.res index 2b6e54d..b644ae5 100644 --- a/src-ocaml/tea.ml +++ b/src/tea.res @@ -1,5 +1,4 @@ -(* TODO: Remove this once Bucklescript upgrade to OCaml 4.03+ as that version include result *) -module Result = Tea_result +/* TODO: Remove this once Bucklescript upgrade to OCaml 4.03+ as that version include result */ module Cmd = Tea_cmd @@ -11,8 +10,6 @@ module Debug = Tea_debug module Html = Tea_html -module Html2 = Tea_html2 - module Svg = Tea_svg module Task = Tea_task @@ -21,8 +18,6 @@ module Program = Tea_program module Time = Tea_time -module Json = Tea_json - module Navigation = Tea_navigation module Random = Tea_random diff --git a/src/tea_animationframe.res b/src/tea_animationframe.res new file mode 100644 index 0000000..8102417 --- /dev/null +++ b/src/tea_animationframe.res @@ -0,0 +1,49 @@ +type t = { + time: Tea_time.t, + delta: Tea_time.t, +} + +let every = (~key="", tagger) => { + open Vdom + let enableCall = callbacks => { + /* let () = Js.log ("rAF", "enable") in */ + let lastTime = ref(Js.Date.now()) + let id = ref(None) + let rec onFrame = _time => { + let time = Js.Date.now() + switch id.contents { + | None => () + | Some(_i) => + let ret = { + time: time, + delta: if time < lastTime.contents { + 0.0 + } else { + time -. lastTime.contents + }, + } + let () = lastTime := time + let () = callbacks.enqueue(tagger(ret)) + switch id.contents { + | None => () + | Some(_stillActive) => + let () = id := Some(Webapi.requestCancellableAnimationFrame(onFrame)) + } + } + } + let () = id := Some(Webapi.requestCancellableAnimationFrame(onFrame)) + () => + switch id.contents { + | None => () + | Some(i) => + /* let () = Js.log ("rAF", "disable") in */ + let () = Webapi.cancelAnimationFrame(i) + let () = id := None + } + } + Tea_sub.registration(key, enableCall) +} + +let times = (~key="", tagger) => every(ev => tagger(~key, ev.time)) + +let diffs = (~key="", tagger) => every(ev => tagger(~key, ev.delta)) diff --git a/src/tea_animationframe.resi b/src/tea_animationframe.resi new file mode 100644 index 0000000..16e0e27 --- /dev/null +++ b/src/tea_animationframe.resi @@ -0,0 +1,7 @@ +type t = {time: Tea_time.t, delta: Tea_time.t} + +let every: (~key: string=?, t => 'msg) => Tea_sub.t<'msg> + +let times: (~key: string=?, (~key: string, Tea_time.t) => 'msg) => Tea_sub.t<'msg> + +let diffs: (~key: string=?, (~key: string, Tea_time.t) => 'msg) => Tea_sub.t<'msg> diff --git a/src/tea_app.res b/src/tea_app.res new file mode 100644 index 0000000..396f6d7 --- /dev/null +++ b/src/tea_app.res @@ -0,0 +1,264 @@ +type program<'flags, 'model, 'msg> = { + init: 'flags => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, + shutdown: 'model => Tea_cmd.t<'msg>, +} +type standardProgram<'flags, 'model, 'msg> = { + init: 'flags => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, +} +type beginnerProgram<'model, 'msg> = { + model: 'model, + update: ('model, 'msg) => 'model, + view: 'model => Vdom.t<'msg>, +} +type pumpInterface<'model, 'msg> = { + startup: unit => unit, + renderString: 'model => string, + handleMsg: ('model, 'msg) => 'model, + shutdown: Tea_cmd.t<'msg> => unit, +} +type programInterface<'msg> = { + "pushMsg": 'msg => unit, + "shutdown": unit => unit, + "getHtmlString": unit => string, +} +@obj +external makeProgramInterface: ( + ~pushMsg: 'msg => unit, + ~shutdown: unit => unit, + ~getHtmlString: unit => string, +) => programInterface<'msg> = "" +let programStateWrapper = (initModel, pump, shutdown) => { + open Vdom + let model = ref(initModel) + let callbacks = ref({ + enqueue: _msg => Js.log("INVALID enqueue CALL!"), + on: _ => (), + }) + let pumperInterfaceC = () => pump(callbacks) + let pumperInterface = pumperInterfaceC() + let pending: ref>> = (ref(None): ref>>) + let rec handler = msg => + switch pending.contents { + | None => + let () = pending := Some(list{}) + let newModel = pumperInterface.handleMsg(model.contents, msg) + let () = model := newModel + switch pending.contents { + | None => + failwith("INVALID message queue state, should never be None during message processing!") + | Some(list{}) => pending := None + | Some(msgs) => + let () = pending := None + List.iter(handler, List.rev(msgs)) + } + | Some(msgs) => pending := Some(list{msg, ...msgs}) + } + let renderEvents = ref(list{}) + let finalizedCBs: Vdom.applicationCallbacks<'msg> = ( + { + enqueue: msg => handler(msg), + on: x => + switch x { + | Render => List.iter(handler, renderEvents.contents) + | AddRenderMsg(msg) => renderEvents := List.append(renderEvents.contents, list{msg}) + | RemoveRenderMsg(msg) => + renderEvents := List.filter(mg => msg !== mg, renderEvents.contents) + }, + }: Vdom.applicationCallbacks<'msg> + ) + let () = callbacks := finalizedCBs + let piRequestShutdown = () => { + let () = + callbacks := { + enqueue: _msg => Js.log("INVALID message enqueued when shut down"), + on: _ => (), + } + let cmd = shutdown(model.contents) + let () = pumperInterface.shutdown(cmd) + } + let renderString = () => { + let rendered = pumperInterface.renderString(model.contents) + rendered + } + let () = pumperInterface.startup() + makeProgramInterface(~pushMsg=handler, ~shutdown=piRequestShutdown, ~getHtmlString=renderString) +} +let programLoop = (update, view, subscriptions, initModel, initCmd, x) => + switch x { + | None => + callbacks => { + let oldSub = ref(Tea_sub.none) + let handleSubscriptionChange = model => { + let newSub = subscriptions(model) + oldSub := Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub) + } + { + startup: () => { + let () = Tea_cmd.run(callbacks, initCmd) + let () = handleSubscriptionChange(initModel) + }, + renderString: model => { + let vdom = view(model) + let rendered = Vdom.renderToHtmlString(vdom) + rendered + }, + handleMsg: (model, msg) => { + let (newModel, cmd) = update(model, msg) + let () = Tea_cmd.run(callbacks, cmd) + let () = handleSubscriptionChange(newModel) + newModel + }, + shutdown: cmd => { + let () = Tea_cmd.run(callbacks, cmd) + let () = oldSub := Tea_sub.run(callbacks, callbacks, oldSub.contents, Tea_sub.none) + }, + } + } + | Some(parentNode) => + callbacks => { + let priorRenderedVdom = ref(list{}) + let latestModel = ref(initModel) + let nextFrameID = ref(None) + let doRender = _delta => + switch nextFrameID.contents { + | None => () + | Some(_id) => + let newVdom = list{view(latestModel.contents)} + let justRenderedVdom = Vdom.patchVNodesIntoElement( + callbacks, + parentNode, + priorRenderedVdom.contents, + newVdom, + ) + let () = priorRenderedVdom := justRenderedVdom + let () = callbacks.contents.on(Render) + nextFrameID := None + } + let scheduleRender = () => + switch nextFrameID.contents { + | Some(_) => () + | None => + let realtimeRendering = false + if realtimeRendering { + let () = nextFrameID := Some(-1) + doRender(16) + } else { + let id = Web.Window.requestAnimationFrame(doRender) + let () = nextFrameID := Some(id) + } + } + let clearPnode = () => + while Js.Array.length(Web.Node.childNodes(parentNode)) > 0 { + switch Js.Null.toOption(Web.Node.firstChild(parentNode)) { + | None => () + | Some(firstChild) => + let _removedChild = Web.Node.removeChild(parentNode, firstChild) + } + } + let oldSub = ref(Tea_sub.none) + let handleSubscriptionChange = model => { + let newSub = subscriptions(model) + oldSub := Tea_sub.run(callbacks, callbacks, oldSub.contents, newSub) + } + let handlerStartup = () => { + let () = clearPnode() + let () = Tea_cmd.run(callbacks, initCmd) + let () = handleSubscriptionChange(latestModel.contents) + let () = nextFrameID := Some(-1) + let () = doRender(16) + } + let renderString = model => { + let vdom = view(model) + let rendered = Vdom.renderToHtmlString(vdom) + rendered + } + let handler = (model, msg) => { + let (newModel, cmd) = update(model, msg) + let () = latestModel := newModel + let () = Tea_cmd.run(callbacks, cmd) + let () = scheduleRender() + let () = handleSubscriptionChange(newModel) + newModel + } + let handlerShutdown = cmd => { + let () = nextFrameID := None + let () = Tea_cmd.run(callbacks, cmd) + let () = oldSub := Tea_sub.run(callbacks, callbacks, oldSub.contents, Tea_sub.none) + let () = priorRenderedVdom := list{} + let () = clearPnode() + } + { + startup: handlerStartup, + renderString: renderString, + handleMsg: handler, + shutdown: handlerShutdown, + } + } + } +let program: ( + program<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, +) => programInterface<'msg> = ( + ({init, update, view, subscriptions, shutdown}, pnode, flags) => { + let () = Web.polyfills() + let (initModel, initCmd) = init(flags) + let opnode = Js.Nullable.toOption(pnode) + let pumpInterface = programLoop(update, view, subscriptions, initModel, initCmd, opnode) + programStateWrapper(initModel, pumpInterface, shutdown) + }: ( + program<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, + ) => programInterface<'msg> +) +let standardProgram: ( + standardProgram<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, +) => programInterface<'msg> = ( + ({init, update, view, subscriptions}, pnode, args) => + program( + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: _model => Tea_cmd.none, + }, + pnode, + args, + ): ( + standardProgram<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, + ) => programInterface<'msg> +) +let beginnerProgram: ( + beginnerProgram<'model, 'msg>, + Js.null_undefined, + unit, +) => programInterface<'msg> = ( + ({model, update, view}, pnode, ()) => + standardProgram( + { + init: () => (model, Tea_cmd.none), + update: (model, msg) => (update(model, msg), Tea_cmd.none), + view: view, + subscriptions: _model => Tea_sub.none, + }, + pnode, + (), + ): ( + beginnerProgram<'model, 'msg>, + Js.null_undefined, + unit, + ) => programInterface<'msg> +) +let map = (func, vnode) => Vdom.map(func, vnode) diff --git a/src/tea_app.resi b/src/tea_app.resi new file mode 100644 index 0000000..c3de1a6 --- /dev/null +++ b/src/tea_app.resi @@ -0,0 +1,76 @@ +type program<'flags, 'model, 'msg> = { + init: 'flags => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, + shutdown: 'model => Tea_cmd.t<'msg>, +} + +type standardProgram<'flags, 'model, 'msg> = { + init: 'flags => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, +} + +type beginnerProgram<'model, 'msg> = { + model: 'model, + update: ('model, 'msg) => 'model, + view: 'model => Vdom.t<'msg>, +} + +type pumpInterface<'model, 'msg> = { + startup: unit => unit, + renderString: 'model => string, + handleMsg: ('model, 'msg) => 'model, + shutdown: Tea_cmd.t<'msg> => unit, +} + +type programInterface<'msg> = { + "getHtmlString": unit => string, + "pushMsg": 'msg => unit, + "shutdown": unit => unit, +} + +@obj +external makeProgramInterface: ( + ~pushMsg: 'msg => unit, + ~shutdown: unit => unit, + ~getHtmlString: unit => string, +) => programInterface<'msg> = "" + +let programStateWrapper: ( + 'msg, + ref> => pumpInterface<'msg, 'msg>, + 'msg => Tea_cmd.t<'msg>, +) => programInterface<'msg> + +let programLoop: ( + ('msg, 'b) => ('msg, Tea_cmd.t<'b>), + 'msg => Vdom.t<'b>, + 'msg => Tea_sub.t<'b>, + 'msg, + Tea_cmd.t<'b>, + option, + ref>, +) => pumpInterface<'msg, 'b> + +let program: ( + program<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, +) => programInterface<'msg> + +let standardProgram: ( + standardProgram<'flags, 'model, 'msg>, + Js.null_undefined, + 'flags, +) => programInterface<'msg> + +let beginnerProgram: ( + beginnerProgram<'model, 'msg>, + Js.null_undefined, + unit, +) => programInterface<'msg> + +let map: ('msg => 'b, Vdom.t<'msg>) => Vdom.t<'b> diff --git a/src/tea_cmd.res b/src/tea_cmd.res new file mode 100644 index 0000000..b58d163 --- /dev/null +++ b/src/tea_cmd.res @@ -0,0 +1,37 @@ +type applicationCallbacks<'msg> = Vdom.applicationCallbacks<'msg> +type rec t<'msg> = + | NoCmd: t<_> + | Mapper( + ref> => ref>, + t<'msgB>, + ): t<'msg> + | Batch(list>): t<'msg> + | EnqueueCall(ref> => unit): t<'msg> +let none = NoCmd +let batch = cmds => Batch(cmds) +let call = call => EnqueueCall(call) +let fnMsg = fnMsg => { + open Vdom + EnqueueCall(callbacks => callbacks.contents.enqueue(fnMsg())) +} +let msg = msg => { + open Vdom + EnqueueCall(callbacks => callbacks.contents.enqueue(msg)) +} +let rec run: + type msg. (ref>, t) => unit = + (callbacks, x) => + switch x { + | NoCmd => () + | Mapper(mapper, cmd) => + let subCallbacks = mapper(callbacks) + run(subCallbacks, cmd) + | Batch(cmds) => List.fold_left(((), cmd) => run(callbacks, cmd), (), cmds) + | EnqueueCall(cb) => cb(callbacks) + } +let map: + type a b. (a => b, t) => t = + (func, cmd) => { + let mapper = Vdom.wrapCallbacks(func) + Mapper(mapper, cmd) + } diff --git a/src/tea_cmd.resi b/src/tea_cmd.resi new file mode 100644 index 0000000..83f5cd1 --- /dev/null +++ b/src/tea_cmd.resi @@ -0,0 +1,25 @@ +type applicationCallbacks<'msg> = Vdom.applicationCallbacks<'msg> + +type rec t<'msg> = + | NoCmd: t<'msg> + | Mapper( + ref> => ref>, + t<'msgB>, + ): t<'msg> + | Batch(list>): t<'msg> + | EnqueueCall(ref> => unit): t<'msg> + +let none: t<'msg> + +let batch: list> => t<'msg> + +let call: (ref> => unit) => t<'msg> + +let fnMsg: (unit => 'msg) => t<'msg> + +let msg: 'msg => t<'msg> + +let run: (ref>, t<'msg>) => unit + +let map: ('msg => 'b, t<'msg>) => t<'b> + diff --git a/src/tea_debug.res b/src/tea_debug.res new file mode 100644 index 0000000..1397352 --- /dev/null +++ b/src/tea_debug.res @@ -0,0 +1,507 @@ +type debugMsg<'msg> = + | ClientMsg('msg) + | TogglePaused + | SelectHistoryItem(int) + | ToggleDetails +let clientMsg = msg => ClientMsg(msg) + +type state = + | Running + | Paused(int) + +type debug_model<'model> = { + history: list<(string, 'model)>, + state: state, + show_details: bool, +} + +let debug = ( + string_of_msg: 'msg => string, + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, + shutdown: 'model => Tea_cmd.t<'msg>, +): ( + (('model, Tea_cmd.t<'msg>)) => (debug_model<'model>, Tea_cmd.t>), + (debug_model<'model>, debugMsg<'msg>) => (debug_model<'model>, Tea_cmd.t>), + debug_model<'model> => Vdom.t>, + debug_model<'model> => Tea_sub.t>, + debug_model<'model> => Tea_cmd.t>, +) => { + let initDebug = ((cmodel, cmd)) => ( + { + history: list{("_init_", cmodel)}, + state: Running, + show_details: false, + }, + cmd |> Tea_cmd.map(clientMsg), + ) + + let update' = (model, x) => + switch x { + | ClientMsg(msg) => + if model.state == Running { + let (_, cmodel) = List.hd(model.history) + let (cmodel', cmd) = update(cmodel, msg) + let dmodel' = {...model, history: list{(string_of_msg(msg), cmodel'), ...model.history}} + (dmodel', cmd |> Tea_cmd.map(clientMsg)) + } else { + (model, Tea_cmd.none) + } + | TogglePaused => + switch model.state { + | Paused(_) => ({...model, state: Running}, Tea_cmd.none) + | Running => ({...model, state: Paused(0)}, Tea_cmd.none) + } + | SelectHistoryItem(i) => ({...model, state: Paused(i)}, Tea_cmd.none) + | ToggleDetails => ({...model, show_details: !model.show_details}, Tea_cmd.none) + } + + let viewStyles = () => { + open Tea_html + let rule = (selector, properties) => + properties + |> List.map(((k, v)) => k ++ (":" ++ v)) + |> String.concat(";") + |> (x => j`$(selector) {$(x)}`) + |> text + + node( + "style", + list{}, + list{ + rule( + "#debug.paused", + list{ + ("position", "fixed"), + ("top", "0"), + ("left", "0"), + ("width", "100%"), + ("height", "100%"), + ("pointer-events", "all"), + ("background-color", "rgba(0,0,0,.1)"), + ("box-shadow", "inset 0 0 10px #333"), + }, + ), + rule( + "#debug nav", + list{ + ("position", "fixed"), + ("max-width", "50%"), + ("bottom", "0"), + ("right", "6px"), + ("border-radius", "4px 4px 0 0"), + ("background-color", "#444"), + ("color", "#fff"), + ("font-family", "monospace"), + ("box-shadow", "0 0 10px #333"), + }, + ), + rule("#debug.paused nav", list{("height", "50%"), ("padding-bottom", "2em")}), + rule( + "#debug nav .toggle", + list{ + ("padding", "6px"), + ("padding-left", "9px"), + ("cursor", "pointer"), + ("min-width", "24ch"), + ("text-align", "center"), + ("border-left", "3px solid #333"), + ("border-radius", "4px 4px 0 0"), + }, + ), + rule( + "#debug nav .toggle:before", + list{ + ("content", "' '"), + ("position", "absolute"), + ("left", "0"), + ("top", "0"), + ("width", ".5ch"), + ("height", "1.8ch"), + ("margin", "1.2ch"), + ("border", "solid #fff"), + ("border-width", "0 .5ch"), + }, + ), + rule( + "#debug.paused nav .toggle:before", + list{ + ("border-color", "transparent"), + ("border-left-color", "#fff"), + ("border-width", "1ch"), + ("width", "0"), + ("height", "0"), + }, + ), + rule( + "#debug nav .history", + list{ + ("margin", "0"), + ("padding", "0"), + ("height", "100%"), + ("overflow-y", "auto"), + ("list-style", "none"), + }, + ), + rule( + "#debug nav .history li", + list{("margin", "0"), ("padding", "0.2ch"), ("border-left", "3px solid #333")}, + ), + rule("#debug nav .history li.selected", list{("background-color", "#333")}), + rule( + "#debug nav .history span.details", + list{ + ("display", "inline-block"), + ("cursor", "pointer"), + ("width", "1ch"), + ("margin", "0 1ch"), + ("vertical-align", "super"), + }, + ), + rule("#debug nav .history li.selected span.details:after", list{("content", "'\\2026'")}), + rule("#debug nav .history li.selected.show", list{("border-left", "3px solid white")}), + rule( + "#debug nav .history span.message", + list{ + ("display", "inline-block"), + ("cursor", "pointer"), + ("white-space", "nowrap"), + ("overflow", "hidden"), + ("text-overflow", "ellipsis"), + ("width", "calc(100% - 75px)"), + }, + ), + rule( + "#debug nav .history span.index", + list{ + ("display", "inline-block"), + ("min-width", "3ch"), + ("margin", "0 1ch"), + ("color", "#aaa"), + ("text-align", "right"), + ("float", "right"), + }, + ), + rule( + "#debug aside.details", + list{ + ("position", "absolute"), + ("width", "40ch"), + ("top", "0"), + ("bottom", "0"), + ("right", "100%"), + ("margin-right", "1.5ch"), + ("overflow", "scroll"), + ("background-color", "#fff"), + ("color", "#000"), + ("box-shadow", "0 0 10px #333"), + ("border-radius", "4px 4px 0 0"), + ("border", "2px solid #333"), + ("padding", "1ch"), + ("white-space", "pre"), + }, + ), + }, + ) + } + + let viewDetails = model => { + open Tea_html + module A = Tea_html.Attributes + let format = %raw(` + function (v) { + var formatRecord = function (data, labels) { + return data.reduce( + function (acc, cur, index) { + acc[labels[index]] = formatValue(cur) + return acc + }, {}) + } + var listToArray = function (data) { + var result = [] + var cur = data + while (typeof cur !== "number") { + result.push(formatValue(cur[0])) + cur = cur[1] + } + return result + } + var formatVariant = function (data, recordVariant) { + if (recordVariant === "::") { + return listToArray(data) + } + else { + return formatRecord(data, [recordVariant]) + } + } + var formatValue = function (x) { + var recordLabels, recordVariant, recordModule, recordPolyVar + if (x == null) { + return null + } + else if ((recordLabels = x[Symbol.for('BsRecord')]) !== undefined) { + return formatRecord(x, recordLabels) + } + else if ((recordModule = x[Symbol.for('BsLocalModule')]) !== undefined) { + return formatRecord(x, recordModule) + } + else if ((recordVariant = x[Symbol.for('BsVariant')]) !== undefined) { + return formatVariant(x, recordVariant) + } + else if ((recordPolyVar = x[Symbol.for('BsPolyVar')]) !== undefined) { + return x[1] + } + else if (Array.isArray(x)) { + // tuple + return x.map(formatValue) + } + else { + // scalar + return x + } + } + return JSON.stringify(formatValue(v), null, 2); + } + `) + aside(list{A.class("details")}, list{model |> format |> text}) + } + + let viewHistory = (model, selected_index) => { + open Tea_html + module A = Tea_html.Attributes + module E = Tea_html.Events + let count = List.length(model.history) + \"@@"(ul(list{A.class("history")}), List.mapi((i, (msg, cmodel)) => { + let selected = i == selected_index + li( + list{ + E.onClick(SelectHistoryItem(i)), + A.classList(list{("selected", selected), ("show", selected && model.show_details)}), + }, + list{ + span( + list{ + A.classList(list{("details", true), ("show", true)}), + ...if selected { + list{E.onClick(ToggleDetails), A.title("toggle details")} + } else { + list{A.noProp, A.noProp} + }, + }, + list{ + if selected && model.show_details { + viewDetails(cmodel) + } else { + noNode + }, + }, + ), + span(list{A.class("message")}, list{text(msg)}), + span(list{A.class("index")}, list{count - i |> string_of_int |> text}), + }, + ) + }, model.history)) + } + + let view' = model => { + open Tea_html + module A = Tea_html.Attributes + module E = Tea_html.Events + let (selected_index, selected_model, paused) = switch model.state { + | Running => (0, List.hd(model.history) |> snd, false) + | Paused(index) => (index, List.nth(model.history, index) |> snd, true) + } + + let history_count = List.length(model.history) + div( + list{}, + list{ + view(selected_model) |> Tea_app.map(clientMsg), + div( + list{A.id("debug"), A.classList(list{("paused", paused)})}, + list{ + viewStyles(), + nav( + list{}, + list{ + div( + list{ + A.class("toggle"), + E.onClick(TogglePaused), + if paused { + A.title("click to resume") + } else { + A.title("click to pause") + }, + }, + list{j`Explore History ($(history_count))` |> text}, + ), + if paused { + viewHistory(model, selected_index) + } else { + noNode + }, + }, + ), + }, + ), + }, + ) + } + + let subscriptions' = model => + model.history |> List.hd |> snd |> subscriptions |> Tea_sub.map(clientMsg) + + let shutdown' = model => model.history |> List.hd |> snd |> shutdown |> Tea_cmd.map(clientMsg) + + (initDebug, update', view', subscriptions', shutdown') +} + +let debugProgram: ( + 'msg => string, + Tea_app.program<'flags, 'model, 'msg>, +) => Tea_app.program<'flags, debug_model<'model>, debugMsg<'msg>> = ( + string_of_msg, + {init, update, view, subscriptions, shutdown}, +) => { + let (initDebug, update', view', subscriptions', shutdown') = debug( + string_of_msg, + update, + view, + subscriptions, + shutdown, + ) + + { + init: flags => init(flags) |> initDebug, + update: update', + view: view', + subscriptions: subscriptions', + shutdown: shutdown', + } +} + +let debugNavigationProgram: ( + 'msg => string, + Tea_navigation.navigationProgram<'flags, 'model, 'msg>, +) => Tea_navigation.navigationProgram<'flags, debug_model<'model>, debugMsg<'msg>> = ( + string_of_msg, + {init, update, view, subscriptions, shutdown}, +) => { + let (initDebug, update', view', subscriptions', shutdown') = debug( + string_of_msg, + update, + view, + subscriptions, + shutdown, + ) + + { + init: (flags, location) => init(flags, location) |> initDebug, + update: update', + view: view', + subscriptions: subscriptions', + shutdown: shutdown', + } +} + +let beginnerProgram: ( + Tea_app.beginnerProgram<'model, 'msg>, + 'msg => string, + Js.null_undefined, + unit, +) => Tea_app.programInterface> = ( + {model, update, view}, + string_of_msg, + pnode, + flags, +) => { + let debugged = debugProgram( + string_of_msg, + { + init: () => (model, Tea_cmd.none), + update: (model, msg) => (update(model, msg), Tea_cmd.none), + view: view, + subscriptions: _model => Tea_sub.none, + shutdown: _model => Tea_cmd.none, + }, + ) + Tea_app.program(debugged, pnode, flags) +} + +let standardProgram: ( + Tea_app.standardProgram<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> = ( + {init, update, view, subscriptions}, + string_of_msg, + pnode, + flags, +) => { + let debugged = debugProgram( + string_of_msg, + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: _model => Tea_cmd.none, + }, + ) + Tea_app.program(debugged, pnode, flags) +} + +let program: ( + Tea_app.program<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> = ( + {init, update, view, subscriptions, shutdown}, + string_of_msg, + pnode, + flags, +) => { + let debugged = debugProgram( + string_of_msg, + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: shutdown, + }, + ) + Tea_app.program(debugged, pnode, flags) +} + +let navigationProgram: ( + Web.Location.location => 'msg, + Tea_navigation.navigationProgram<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> = ( + location_to_msg, + {init, update, view, subscriptions, shutdown}, + string_of_msg, + pnode, + flags, +) => { + let location = location => location |> location_to_msg |> clientMsg + + let debugged = debugNavigationProgram( + string_of_msg, + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: shutdown, + }, + ) + Tea_navigation.navigationProgram(location, debugged, pnode, flags) +} diff --git a/src/tea_debug.resi b/src/tea_debug.resi new file mode 100644 index 0000000..bfae9f2 --- /dev/null +++ b/src/tea_debug.resi @@ -0,0 +1,60 @@ +type debugMsg<'msg> = ClientMsg('msg) | TogglePaused | SelectHistoryItem(int) | ToggleDetails + +let clientMsg: 'msg => debugMsg<'msg> + +type state = Running | Paused(int) +type debug_model<'model> = {history: list<(string, 'model)>, state: state, show_details: bool} + +let debug: ( + 'msg => string, + ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + 'model => Vdom.t<'msg>, + 'model => Tea_sub.t<'msg>, + 'model => Tea_cmd.t<'msg>, +) => ( + (('model, Tea_cmd.t<'msg>)) => (debug_model<'model>, Tea_cmd.t>), + (debug_model<'model>, debugMsg<'msg>) => (debug_model<'model>, Tea_cmd.t>), + debug_model<'model> => Vdom.t>, + debug_model<'model> => Tea_sub.t>, + debug_model<'model> => Tea_cmd.t>, +) + +let debugProgram: ('msg => string, Tea_app.program<'flags, 'model, 'msg>) => Tea_app.program< + 'flags, + debug_model<'model>, + debugMsg<'msg>, +> + +let debugNavigationProgram: ( + 'msg => string, + Tea_navigation.navigationProgram<'flags, 'model, 'msg>, +) => Tea_navigation.navigationProgram<'flags, debug_model<'model>, debugMsg<'msg>> + +let beginnerProgram: ( + Tea_app.beginnerProgram<'model, 'msg>, + 'msg => string, + Js.null_undefined, + unit, +) => Tea_app.programInterface> + +let standardProgram: ( + Tea_app.standardProgram<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> + +let program: ( + Tea_app.program<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> + +let navigationProgram: ( + Web.Location.location => 'msg, + Tea_navigation.navigationProgram<'flags, 'model, 'msg>, + 'msg => string, + Js.null_undefined, + 'flags, +) => Tea_app.programInterface> diff --git a/src/tea_ex.res b/src/tea_ex.res new file mode 100644 index 0000000..dd8cd98 --- /dev/null +++ b/src/tea_ex.res @@ -0,0 +1,65 @@ +let renderEvent = (~key="", msg) => { + open Vdom + let enableCall = callbacks => { + let () = callbacks.on(AddRenderMsg(msg)) + () => callbacks.on(RemoveRenderMsg(msg)) + } + Tea_sub.registration(key, enableCall) +} +module LocalStorage = { + open Tea_task + + let length = nativeBinding(cb => { + try { + cb(Ok(Dom.Storage.length(Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + }) + + let clear = nativeBinding(cb => + try { + cb(Ok(Dom.Storage.clear(Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + ) + + let clearCmd = () => Tea_task.attemptOpt(_ => None, clear) + let key = idx => + nativeBinding(cb => + try { + cb(Ok(Dom.Storage.key(idx, Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + ) + let getItem = key => + nativeBinding(cb => + try { + cb(Ok(Dom.Storage.getItem(key, Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + ) + + let removeItem = key => + nativeBinding(cb => + try { + cb(Ok(Dom.Storage.removeItem(key, Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + ) + + let removeItemCmd = key => Tea_task.attemptOpt(_ => None, removeItem(key)) + let setItem = (key, value) => + nativeBinding(cb => { + try { + cb(Ok(Dom.Storage.setItem(key, value, Dom.Storage.localStorage))) + } catch { + | _e => cb(Error("localStorage is not available")) + } + }) + let setItemCmd = (key, value) => Tea_task.attemptOpt(_ => None, setItem(key, value)) +} diff --git a/src/tea_ex.resi b/src/tea_ex.resi new file mode 100644 index 0000000..5850d1b --- /dev/null +++ b/src/tea_ex.resi @@ -0,0 +1,13 @@ +let renderEvent: (~key: string=?, 'msg) => Tea_sub.t<'msg> + +module LocalStorage: { + let length: Tea_task.t + let clear: Tea_task.t + let clearCmd: unit => Tea_cmd.t<'msg> + let key: int => Tea_task.t, string> + let getItem: string => Tea_task.t, string> + let removeItem: string => Tea_task.t + let removeItemCmd: string => Tea_cmd.t<'msg> + let setItem: (string, string) => Tea_task.t + let setItemCmd: (string, string) => Tea_cmd.t<'msg> +} diff --git a/src/tea_html.res b/src/tea_html.res new file mode 100644 index 0000000..2f809bf --- /dev/null +++ b/src/tea_html.res @@ -0,0 +1,764 @@ +@@ocaml.text(" This file is organized roughly in order of popularity. The tags which you'd +expect to use frequently will be closer to the top. ") + +open Vdom + +let map = Tea_app.map + +@send external +preventDefault: (Web.Node.event) => unit="preventDefault" +@send external +stopPropagation: (Web.Node.event) => unit="stopPropagation" + +let stopPropagation = t => stopPropagation(t) +let preventDefault = t => preventDefault(t) + +@@ocaml.text(" {1 Primitives} ") + +let text = str => text(str) + +let node = (~namespace="", tagName, ~key="", ~unique="", props, nodes) => + fullnode(namespace, tagName, key, unique, props, nodes) + +let noNode = noNode + +let lazy1 = (key, gen) => lazyGen(key, gen) + +@@ocaml.text(" {1 Tags} ") + +@@ocaml.text(" {2 Headers} ") + +let h1 = (~key="", ~unique="", props, nodes) => fullnode("", "h1", key, unique, props, nodes) + +let h2 = (~key="", ~unique="", props, nodes) => fullnode("", "h2", key, unique, props, nodes) + +let h3 = (~key="", ~unique="", props, nodes) => fullnode("", "h3", key, unique, props, nodes) + +let h4 = (~key="", ~unique="", props, nodes) => fullnode("", "h4", key, unique, props, nodes) + +let h5 = (~key="", ~unique="", props, nodes) => fullnode("", "h5", key, unique, props, nodes) + +let h6 = (~key="", ~unique="", props, nodes) => fullnode("", "h6", key, unique, props, nodes) + +@@ocaml.text(" {2 Grouping Content} ") + +let div = (~key="", ~unique="", props, nodes) => fullnode("", "div", key, unique, props, nodes) + +let p = (~key="", ~unique="", props, nodes) => fullnode("", "p", key, unique, props, nodes) + +let hr = (~key="", ~unique="", props, nodes) => fullnode("", "hr", key, unique, props, nodes) + +let pre = (~key="", ~unique="", props, nodes) => fullnode("", "pre", key, unique, props, nodes) + +let blockquote = (~key="", ~unique="", props, nodes) => + fullnode("", "blockquote", key, unique, props, nodes) + +@@ocaml.text(" {2 Text} ") + +let span = (~key="", ~unique="", props, nodes) => fullnode("", "span", key, unique, props, nodes) + +let a = (~key="", ~unique="", props, nodes) => fullnode("", "a", key, unique, props, nodes) + +let code = (~key="", ~unique="", props, nodes) => fullnode("", "code", key, unique, props, nodes) + +let em = (~key="", ~unique="", props, nodes) => fullnode("", "em", key, unique, props, nodes) + +let strong = (~key="", ~unique="", props, nodes) => + fullnode("", "strong", key, unique, props, nodes) + +let i = (~key="", ~unique="", props, nodes) => fullnode("", "i", key, unique, props, nodes) + +let b = (~key="", ~unique="", props, nodes) => fullnode("", "b", key, unique, props, nodes) + +let u = (~key="", ~unique="", props, nodes) => fullnode("", "u", key, unique, props, nodes) + +let sub = (~key="", ~unique="", props, nodes) => fullnode("", "sub", key, unique, props, nodes) + +let sup = (~key="", ~unique="", props, nodes) => fullnode("", "sup", key, unique, props, nodes) + +let br = props => fullnode("", "br", "br", "br", props, list{}) + +let br' = (~key="", ~unique="", props, nodes) => fullnode("", "br", key, unique, props, nodes) + +@@ocaml.text(" {2 Lists} ") + +let ol = (~key="", ~unique="", props, nodes) => fullnode("", "ol", key, unique, props, nodes) + +let ul = (~key="", ~unique="", props, nodes) => fullnode("", "ul", key, unique, props, nodes) + +let li = (~key="", ~unique="", props, nodes) => fullnode("", "li", key, unique, props, nodes) + +let dl = (~key="", ~unique="", props, nodes) => fullnode("", "dl", key, unique, props, nodes) + +let dt = (~key="", ~unique="", props, nodes) => fullnode("", "dt", key, unique, props, nodes) + +let dd = (~key="", ~unique="", props, nodes) => fullnode("", "dd", key, unique, props, nodes) + +@@ocaml.text(" {2 Embedded Content} ") + +let img = (~key="", ~unique="", props, nodes) => fullnode("", "img", key, unique, props, nodes) + +let iframe = (~key="", ~unique="", props, nodes) => + fullnode("", "iframe", key, unique, props, nodes) + +let canvas = (~key="", ~unique="", props, nodes) => + fullnode("", "canvas", key, unique, props, nodes) + +let math = (~key="", ~unique="", props, nodes) => fullnode("", "math", key, unique, props, nodes) + +@@ocaml.text(" {2 Form and inputs} ") + +let form = (~key="", ~unique="", props, nodes) => fullnode("", "form", key, unique, props, nodes) + +let input' = (~key="", ~unique="", props, nodes) => fullnode("", "input", key, unique, props, nodes) + +let textarea = (~key="", ~unique="", props, nodes) => + fullnode("", "textarea", key, unique, props, nodes) + +let button = (~key="", ~unique="", props, nodes) => + fullnode("", "button", key, unique, props, nodes) + +let select = (~key="", ~unique="", props, nodes) => + fullnode("", "select", key, unique, props, nodes) + +let option = (~key="", ~unique="", props, nodes) => + fullnode("", "option", key, unique, props, nodes) + +let optgroup = (~key="", ~unique="", props, nodes) => + fullnode("", "optgroup", key, unique, props, nodes) + +let label = (~key="", ~unique="", props, nodes) => fullnode("", "label", key, unique, props, nodes) + +let fieldset = (~key="", ~unique="", props, nodes) => + fullnode("", "fieldset", key, unique, props, nodes) + +let legend = (~key="", ~unique="", props, nodes) => + fullnode("", "legend", key, unique, props, nodes) + +@@ocaml.text(" {2 Sections} ") + +let section = (~key="", ~unique="", props, nodes) => + fullnode("", "section", key, unique, props, nodes) + +let nav = (~key="", ~unique="", props, nodes) => fullnode("", "nav", key, unique, props, nodes) + +let article = (~key="", ~unique="", props, nodes) => + fullnode("", "article", key, unique, props, nodes) + +let aside = (~key="", ~unique="", props, nodes) => fullnode("", "aside", key, unique, props, nodes) + +let header = (~key="", ~unique="", props, nodes) => + fullnode("", "header", key, unique, props, nodes) + +let footer = (~key="", ~unique="", props, nodes) => + fullnode("", "footer", key, unique, props, nodes) + +let address = (~key="", ~unique="", props, nodes) => + fullnode("", "address", key, unique, props, nodes) + +let main = (~key="", ~unique="", props, nodes) => fullnode("", "main", key, unique, props, nodes) + +let body = (~key="", ~unique="", props, nodes) => fullnode("", "body", key, unique, props, nodes) + +@@ocaml.text(" {2 Figures} ") + +let figure = (~key="", ~unique="", props, nodes) => + fullnode("", "figure", key, unique, props, nodes) + +let figcaption = (~key="", ~unique="", props, nodes) => + fullnode("", "figcaption", key, unique, props, nodes) + +@@ocaml.text(" {2 Tables} ") + +let table = (~key="", ~unique="", props, nodes) => fullnode("", "table", key, unique, props, nodes) + +let caption = (~key="", ~unique="", props, nodes) => + fullnode("", "caption", key, unique, props, nodes) + +let colgroup = (~key="", ~unique="", props, nodes) => + fullnode("", "colgroup", key, unique, props, nodes) + +let col = (~key="", ~unique="", props, nodes) => fullnode("", "col", key, unique, props, nodes) + +let tbody = (~key="", ~unique="", props, nodes) => fullnode("", "tbody", key, unique, props, nodes) + +let thead = (~key="", ~unique="", props, nodes) => fullnode("", "thead", key, unique, props, nodes) + +let tfoot = (~key="", ~unique="", props, nodes) => fullnode("", "tfoot", key, unique, props, nodes) + +let tr = (~key="", ~unique="", props, nodes) => fullnode("", "tr", key, unique, props, nodes) + +let th = (~key="", ~unique="", props, nodes) => fullnode("", "th", key, unique, props, nodes) + +let td = (~key="", ~unique="", props, nodes) => fullnode("", "td", key, unique, props, nodes) + +@@ocaml.text(" {2 Less common inputs} ") + +let datalist = (~key="", ~unique="", props, nodes) => + fullnode("", "datalist", key, unique, props, nodes) + +let keygen = (~key="", ~unique="", props, nodes) => + fullnode("", "keygen", key, unique, props, nodes) + +let output = (~key="", ~unique="", props, nodes) => + fullnode("", "output", key, unique, props, nodes) + +let progress = (~key="", ~unique="", props, nodes) => + fullnode("", "progress", key, unique, props, nodes) + +let meter = (~key="", ~unique="", props, nodes) => fullnode("", "meter", key, unique, props, nodes) + +@@ocaml.text(" {2 Audio and Video} ") + +let audio = (~key="", ~unique="", props, nodes) => fullnode("", "audio", key, unique, props, nodes) + +let video = (~key="", ~unique="", props, nodes) => fullnode("", "video", key, unique, props, nodes) + +let source = (~key="", ~unique="", props, nodes) => + fullnode("", "source", key, unique, props, nodes) + +let track = (~key="", ~unique="", props, nodes) => fullnode("", "track", key, unique, props, nodes) + +@@ocaml.text(" {2 Embedded objects} ") + +let embed = (~key="", ~unique="", props, nodes) => fullnode("", "embed", key, unique, props, nodes) + +let object = (~key="", ~unique="", props, nodes) => + fullnode("", "object", key, unique, props, nodes) + +let param = (~key="", ~unique="", props, nodes) => fullnode("", "param", key, unique, props, nodes) + +@@ocaml.text(" {2 Text edits} ") + +let ins = (~key="", ~unique="", props, nodes) => fullnode("", "ins", key, unique, props, nodes) + +let del = (~key="", ~unique="", props, nodes) => fullnode("", "del", key, unique, props, nodes) + +@@ocaml.text(" {2 Semantic text} ") + +let small = (~key="", ~unique="", props, nodes) => fullnode("", "small", key, unique, props, nodes) + +let cite = (~key="", ~unique="", props, nodes) => fullnode("", "cite", key, unique, props, nodes) + +let dfn = (~key="", ~unique="", props, nodes) => fullnode("", "dfn", key, unique, props, nodes) + +let abbr = (~key="", ~unique="", props, nodes) => fullnode("", "abbr", key, unique, props, nodes) + +let time = (~key="", ~unique="", props, nodes) => fullnode("", "time", key, unique, props, nodes) + +let var = (~key="", ~unique="", props, nodes) => fullnode("", "var", key, unique, props, nodes) + +let samp = (~key="", ~unique="", props, nodes) => fullnode("", "samp", key, unique, props, nodes) + +let kbd = (~key="", ~unique="", props, nodes) => fullnode("", "kbd", key, unique, props, nodes) + +let s = (~key="", ~unique="", props, nodes) => fullnode("", "s", key, unique, props, nodes) + +let q = (~key="", ~unique="", props, nodes) => fullnode("", "q", key, unique, props, nodes) + +@@ocaml.text(" {2 Less common text tags} ") + +let mark = (~key="", ~unique="", props, nodes) => fullnode("", "mark", key, unique, props, nodes) + +let ruby = (~key="", ~unique="", props, nodes) => fullnode("", "ruby", key, unique, props, nodes) + +let rt = (~key="", ~unique="", props, nodes) => fullnode("", "rt", key, unique, props, nodes) + +let rp = (~key="", ~unique="", props, nodes) => fullnode("", "rp", key, unique, props, nodes) + +let bdi = (~key="", ~unique="", props, nodes) => fullnode("", "bdi", key, unique, props, nodes) + +let bdo = (~key="", ~unique="", props, nodes) => fullnode("", "bdo", key, unique, props, nodes) + +let wbr = (~key="", ~unique="", props, nodes) => fullnode("", "wbr", key, unique, props, nodes) + +@@ocaml.text(" {2 Interactive elements} ") + +let details = (~key="", ~unique="", props, nodes) => + fullnode("", "details", key, unique, props, nodes) + +let summary = (~key="", ~unique="", props, nodes) => + fullnode("", "summary", key, unique, props, nodes) + +let menuitem = (~key="", ~unique="", props, nodes) => + fullnode("", "menuitem", key, unique, props, nodes) + +let menu = (~key="", ~unique="", props, nodes) => fullnode("", "menu", key, unique, props, nodes) + +@@ocaml.text(" {2 Header elements} ") + +let meta = (~key="", ~unique="", props) => fullnode("", "meta", key, unique, props, list{}) + +let style = (~key="", ~unique="", props, content) => + fullnode("", "style", key, unique, props, list{text(content)}) + +let title = (~key="", ~unique="", props, content) => + fullnode("", "title", key, unique, props, list{text(content)}) + +let link = (~key="", ~unique="", props) => fullnode("", "link", key, unique, props, list{}) + +@ocaml.doc(" Helper functions for HTML attributes. They are organized roughly by category. ") +module Attributes = { + @@ocaml.text(" {1 Primitives} ") + + let noProp = Vdom.noProp + + let style = (key, value) => Vdom.style(key, value) + + let styles = s => Vdom.styles(s) + + @@ocaml.text(" {1 Super common attributes} ") + + let class = name => prop("className", name) + + let classList = classes => + classes + |> List.filter(((_fst, snd)) => snd) + |> List.map(((fst, _snd)) => fst) + |> String.concat(" ") + |> class + + let id = str => prop("id", str) + + let title = str => attribute("", "title", str) + + let hidden = b => + if b { + prop("hidden", "hidden") + } else { + noProp + } + + @@ocaml.text(" {1 Inputs} ") + + let type' = typ => prop("type", typ) + + let value = str => prop("value", str) + + let defaultValue = str => prop("defaultValue", str) + + let checked = b => + if b { + prop("checked", "checked") + } else { + noProp + } + + let placeholder = str => prop("placeholder", str) + + let selected = b => + if b { + attribute("", "selected", "true") + } else { + noProp + } + + @@ocaml.text(" {1 Input helpers} ") + + let accept = c => attribute("", "accept", c) + + let acceptCharset = c => attribute("", "accept-charset", c) + + let action = a => prop("action", a) + + let autocomplete = b => + prop( + "autocomplete", + if b { + "on" + } else { + "off" + }, + ) + + let autofocus = b => + if b { + prop("autofocus", "autofocus") + } else { + noProp + } + + let disabled = b => + if b { + attribute("", "disabled", "true") + } else { + noProp + } + + let enctype = encoding => attribute("", "enctype", encoding) + + let formaction = url => attribute("", "formaction", url) + + let list = value => attribute("", "list", value) + + let minlength = n => attribute("", "minlength", string_of_int(n)) + + let maxlength = n => attribute("", "maxlength", string_of_int(n)) + + let method = m => prop("method", m) + + let multiple = b => + if b { + prop("multiple", "multiple") + } else { + noProp + } + + let name = str => prop("name", str) + + let novalidate = b => + if b { + prop("novalidate", "novalidate") + } else { + noProp + } + + let pattern = p => prop("pattern", p) + + let readonly = b => + if b { + attribute("", "readonly", "readonly") + } else { + noProp + } + + let required = b => + if b { + attribute("", "required", "required") + } else { + noProp + } + + let size = n => attribute("", "size", string_of_int(n)) + + let for' = str => prop("htmlFor", str) + + let form = value => attribute("", "form", value) + + @@ocaml.text(" {1 Input ranges} ") + + let max = value => attribute("", "max", value) + + let min = value => attribute("", "min", value) + + let step = value => attribute("", "step", value) + + @@ocaml.text(" {1 Textarea} ") + + let cols = n => attribute("", "cols", string_of_int(n)) + + let rows = n => attribute("", "rows", string_of_int(n)) + + let wrap = value => prop("wrap", value) + + @@ocaml.text(" {1 Links and areas} ") + + /* `href` is actually an attribute, not a property, but need it here for Elm compat... */ + let href = str => attribute("", "href", str) + + let target = t => prop("target", t) + + let download = b => + if b { + prop("download", "") + } else { + noProp + } + + let downloadAs = name => prop("download", name) + + let hreflang = code => prop("hreflang", code) + + let media = value => attribute("", "media", value) + + let ping = url => prop("ping", url) + + let rel = value => attribute("", "rel", value) + + @@ocaml.text(" {1 Maps} ") + + let ismap = b => + if b { + prop("ismap", "ismap") + } else { + noProp + } + + let usemap = name => prop("usemap", name) + + let shape = value => prop("shape", value) + + let coords = value => prop("coords", value) + + @@ocaml.text(" {1 Embedded content} ") + + /* `src` is actually an attribute, not a property, but need it here for Elm compat... */ + let src = str => attribute("", "src", str) + + let height = n => attribute("", "height", string_of_int(n)) + + let width = n => attribute("", "width", string_of_int(n)) + + let alt = value => prop("alt", value) + + @@ocaml.text(" {1 Audio and Video} ") + + let autoplay = b => + if b { + prop("autoplay", "autoplay") + } else { + noProp + } + + let controls = b => + if b { + prop("controls", "controls") + } else { + noProp + } + + let loop = b => + if b { + prop("loop", "loop") + } else { + noProp + } + + let preload = value => prop("preload", value) + + let poster = url => prop("poster", url) + + let default = b => + if b { + prop("default", "default") + } else { + noProp + } + + let kind = value => prop("kind", value) + + let srclang = code => prop("srclang", code) + + @@ocaml.text(" {1 IFrames} ") + + let sandbox = value => prop("sandbox", value) + + let seamless = b => + if b { + prop("seamless", "seamless") + } else { + noProp + } + + let srcdoc = value => prop("srcdoc", value) + + @@ocaml.text(" {1 Ordered lists} ") + + let reversed = b => + if b { + prop("reversed", "reversed") + } else { + noProp + } + + let start = n => prop("start", string_of_int(n)) + + @@ocaml.text(" {1 Tables} ") + + let colspan = n => attribute("", "colspan", string_of_int(n)) + + let rowspan = n => attribute("", "rowspan", string_of_int(n)) + + let headers = value => prop("headers", value) + + let scope = value => prop("scope", value) + + let align = value => prop("align", value) + + @@ocaml.text(" {1 Header stuff} ") + + let async = b => + if b { + prop("async", "async") + } else { + noProp + } + + let charset = value => attribute("", "charset", value) + + let content = value => attribute("", "content", value) + + let defer = b => + if b { + prop("defer", "defer") + } else { + noProp + } + + let httpEquiv = value => prop("http-equiv", value) + + let language = value => prop("language", value) + + let scoped = value => prop("scoped", value) + + @@ocaml.text(" {1 Less common global attributes} ") + + let accesskey = ch => prop("accesskey", String.make(1, ch)) + + let contenteditable = b => + if b { + prop("contenteditable", "contenteditable") + } else { + noProp + } + + let contextmenu = id => attribute("", "contextmenu", id) + + let dir = value => prop("dir", value) + + let draggable = value => attribute("", "draggable", value) + + let dropzone = value => prop("dropzone", value) + + let itemprop = value => attribute("", "itemprop", value) + + let lang = code => prop("lang", code) + + let spellcheck = (b: bool) => Vdom.attribute("", "spellcheck", string_of_bool(b)) + + let tabindex = n => attribute("", "tabindex", string_of_int(n)) + + @@ocaml.text(" {1 Key generation} ") + + let challenge = value => attribute("", "challenge", value) + + let keytype = value => prop("keytype", value) + + @@ocaml.text(" {1 Miscellaneous} ") + + let cite = url => prop("cite", url) + + let datetime = value => attribute("", "datetime", value) + + let pubdate = value => attribute("", "pubdate", value) + + let manifest = value => attribute("", "manifest", value) +} + +module Events = { + @@ocaml.text(" {1 Primitives} ") + + let onCB = (~key,eventName, cb) => onCB(eventName, key, cb) + + let onMsg = (eventName, msg) => onMsg(eventName, msg) + + type options = { + stopPropagation: bool, + preventDefault: bool, + } + + let defaultOptions = { + stopPropagation: false, + preventDefault: false, + } + + let onWithOptions = (~key: string, eventName, options: options, decoder) => + onCB(~key,eventName, event => { + if options.stopPropagation { + stopPropagation(event) |> ignore + } + if options.preventDefault { + preventDefault(event) |> ignore + } + let result = event |> Rescript_json_combinators_extended.decodeEvent(decoder) + switch result { + | Ok(a) => Some(a) + | Error(_) => None + } + }) + + let on = (~key: string, eventName, decoder) => + onWithOptions(~key, eventName, defaultOptions, decoder) + + open JsonCombinators + open Rescript_json_combinators_extended + + let targetValue = at(list{"target", "value"}, Json.Decode.string) + + let targetChecked = at(list{"target", "checked"}, Json.Decode.bool) + + let keyCode = Json.Decode.field("keyCode", Json.Decode.int) + + let preventDefaultOn = (~key="", eventName, decoder) => + onWithOptions(~key, eventName, {...defaultOptions, preventDefault: true}, decoder) + + @@ocaml.text(" {1 Mouse helpers} ") + + let onClick = msg => onMsg("click", msg) + + let onDoubleClick = msg => onMsg("dblclick", msg) + + let onMouseDown = msg => onMsg("mousedown", msg) + + let onMouseUp = msg => onMsg("mouseup", msg) + + let onMouseEnter = msg => onMsg("mouseenter", msg) + + let onMouseLeave = msg => onMsg("mouseleave", msg) + + let onMouseOver = msg => onMsg("mouseover", msg) + + let onMouseOut = msg => onMsg("mouseout", msg) + + @@ocaml.text(" {1 Form helpers} ") + + let onInputOpt = (~key="", msg) => + onCB(~key,"input", ev => + switch Js.Undefined.toOption(ev["target"]) { + | None => None + | Some(target) => + switch Js.Undefined.toOption(target["value"]) { + | None => None + | Some(value) => msg(value) + } + } + ) + + let onInput = (~key="", msg) => onInputOpt(~key, ev => Some(msg(ev))) + + let onCheckOpt = (~key="", msg) => + onCB(~key,"change", ev => + switch Js.Undefined.toOption(ev["target"]) { + | None => None + | Some(target) => + switch Js.Undefined.toOption(target["checked"]) { + | None => None + | Some(value) => msg(value) + } + } + ) + + let onCheck = (~key="", msg) => onCheckOpt(~key, ev => Some(msg(ev))) + + let onChangeOpt = (~key="", msg) => + onCB(~key,"change", ev => + switch Js.Undefined.toOption(ev["target"]) { + | None => None + | Some(target) => + switch Js.Undefined.toOption(target["value"]) { + | None => None + | Some(value) => msg(value) + } + } + ) + + let onChange = (~key="", msg) => onChangeOpt(~key, ev => Some(msg(ev))) + + let onSubmit = msg => preventDefaultOn("submit", Rescript_json_combinators_extended.succeed(msg)) + + @@ocaml.text(" {1 Focus helpers} ") + + let onBlur = msg => onMsg("blur", msg) + + let onFocus = msg => onMsg("focus", msg) +} diff --git a/src/tea_html.resi b/src/tea_html.resi new file mode 100644 index 0000000..383f4d1 --- /dev/null +++ b/src/tea_html.resi @@ -0,0 +1,582 @@ + +let map: ('msg => 'b, Vdom.t<'msg>) => Vdom.t<'b> + +let text: string => Vdom.t<'msg> + +let node: (~namespace: string=?, string, ~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>, ) => Vdom.t<'msg> + +let noNode: Vdom.t<'msg> + +let lazy1: (string, unit => Vdom.t<'msg>) => Vdom.t<'msg> + + + +let h1: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let h2: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let h3: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let h4: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let h5: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let h6: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + +let div: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let p: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let hr: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let pre: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let blockquote: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>,) => Vdom.t<'msg> + + + + +let span: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let a: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let code: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let em: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let strong: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let i: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let b: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let u: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let sub: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let sup: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let br: Vdom.properties<'msg> => Vdom.t<'msg> + +let br': (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let ol: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let ul: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let li: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let dl: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let dt: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let dd: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let img: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let iframe: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let canvas: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let math: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let form: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let input': (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let textarea: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let button: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let select: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let option: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let optgroup: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let label: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let fieldset: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let legend: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let section: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let nav: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let article: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let aside: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let header: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let footer: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let address: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let main: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let body: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let figure: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let figcaption: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>, ) => Vdom.t<'msg> + + + +let table: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let caption: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let colgroup: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let col: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let tbody: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let thead: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let tfoot: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let tr: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let th: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let td: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let datalist: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let keygen: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let output: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let progress: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let meter: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let audio: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let video: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let source: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let track: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let embed: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let object: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let param: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let ins: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let del: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let small: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let cite: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let dfn: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let abbr: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let time: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let var: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let samp: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let kbd: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let s: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let q: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let mark: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let ruby: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let rt: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let rp: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let bdi: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let bdo: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let wbr: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let details: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let summary: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let menuitem: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg,> + +let menu: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let meta: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>) => Vdom.t<'msg> + + + + +let style: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, string) => Vdom.t<'msg> + +let title: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, string) => Vdom.t<'msg> + +let link: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>) => Vdom.t<'msg> + + + + +module Attributes: { + + let noProp: Vdom.property<'msg> + + let style: (string, string) => Vdom.property<'msg> + + let styles: list<(string, string)> => Vdom.property<'msg> + + + + + let class: string => Vdom.property<'msg> + + let classList: list<(string, bool)> => Vdom.property<'msg> + + let id: string => Vdom.property<'msg> + + let title: string => Vdom.property<'msg> + + let hidden: bool => Vdom.property<'msg> + + + + + let type': string => Vdom.property<'msg> + + let value: string => Vdom.property<'msg> + + let defaultValue: string => Vdom.property<'msg> + + let checked: bool => Vdom.property<'msg> + + let placeholder: string => Vdom.property<'msg> + + let selected: bool => Vdom.property<'msg> + + + + + let accept: string => Vdom.property<'msg> + + let acceptCharset: string => Vdom.property<'msg> + + let action: string => Vdom.property<'msg> + + let autocomplete: bool => Vdom.property<'msg> + + let autofocus: bool => Vdom.property<'msg> + + let disabled: bool => Vdom.property<'msg> + + let enctype: string => Vdom.property<'msg> + + let formaction: string => Vdom.property<'msg> + + let list: string => Vdom.property<'msg> + + let minlength: int => Vdom.property<'msg> + + let maxlength: int => Vdom.property<'msg> + + let method: string => Vdom.property<'msg> + + let multiple: bool => Vdom.property<'msg> + + let name: string => Vdom.property<'msg> + + let novalidate: bool => Vdom.property<'msg> + + let pattern: string => Vdom.property<'msg> + + let readonly: bool => Vdom.property<'msg> + + let required: bool => Vdom.property<'msg> + + let size: int => Vdom.property<'msg> + + let for': string => Vdom.property<'msg> + + let form: string => Vdom.property<'msg> + + + + + let max: string => Vdom.property<'msg> + + let min: string => Vdom.property<'msg> + + let step: string => Vdom.property<'msg> + + + + + let cols: int => Vdom.property<'msg> + + let rows: int => Vdom.property<'msg> + + let wrap: string => Vdom.property<'msg> + + let href: string => Vdom.property<'msg> + + + + + let target: string => Vdom.property<'msg> + + let download: bool => Vdom.property<'msg> + + let downloadAs: string => Vdom.property<'msg> + + let hreflang: string => Vdom.property<'msg> + + let media: string => Vdom.property<'msg> + + let ping: string => Vdom.property<'msg> + + let rel: string => Vdom.property<'msg> + + + + + let ismap: bool => Vdom.property<'msg> + + let usemap: string => Vdom.property<'msg> + + let shape: string => Vdom.property<'msg> + + let coords: string => Vdom.property<'msg> + + + + + let src: string => Vdom.property<'msg> + + let height: int => Vdom.property<'msg> + + let width: int => Vdom.property<'msg> + + let alt: string => Vdom.property<'msg> + + + + + let autoplay: bool => Vdom.property<'msg> + + let controls: bool => Vdom.property<'msg> + + let loop: bool => Vdom.property<'msg> + + let preload: string => Vdom.property<'msg> + + let poster: string => Vdom.property<'msg> + + let default: bool => Vdom.property<'msg> + + let kind: string => Vdom.property<'msg> + + let srclang: string => Vdom.property<'msg> + + + + + let sandbox: string => Vdom.property<'msg> + + let seamless: bool => Vdom.property<'msg> + + let srcdoc: string => Vdom.property<'msg> + + + + + let reversed: bool => Vdom.property<'msg> + + let start: int => Vdom.property<'msg> + + + + + let colspan: int => Vdom.property<'msg> + + let rowspan: int => Vdom.property<'msg> + + let headers: string => Vdom.property<'msg> + + let scope: string => Vdom.property<'msg> + + let align: string => Vdom.property<'msg> + + + + + let async: bool => Vdom.property<'msg> + + let charset: string => Vdom.property<'msg> + + let content: string => Vdom.property<'msg> + + let defer: bool => Vdom.property<'msg> + + let httpEquiv: string => Vdom.property<'msg> + + let language: string => Vdom.property<'msg> + + let scoped: string => Vdom.property<'msg> + + + + + let accesskey: char => Vdom.property<'msg> + + let contenteditable: bool => Vdom.property<'msg> + + let contextmenu: string => Vdom.property<'msg> + + let dir: string => Vdom.property<'msg> + + let draggable: string => Vdom.property<'msg> + + let dropzone: string => Vdom.property<'msg> + + let itemprop: string => Vdom.property<'msg> + + let lang: string => Vdom.property<'msg> + + let spellcheck: bool => Vdom.property<'msg> + + + let tabindex: int => Vdom.property<'msg> + + + + + let challenge: string => Vdom.property<'msg> + + let keytype: string => Vdom.property<'msg> + + + + + let cite: string => Vdom.property<'msg> + + let datetime: string => Vdom.property<'msg> + + let pubdate: string => Vdom.property<'msg> + + let manifest: string => Vdom.property<'msg> + +} + + +module Events: { + + let onCB: (~key: string, string, Web.Node.event => option<'msg>) => Vdom.property<'msg> + + let onMsg: (string, 'msg) => Vdom.property<'msg> + + let on: (~key: string, string, JsonCombinators.Json.Decode.t<'b>) => Vdom.property<'b> + + type options = {stopPropagation: bool, preventDefault: bool} + + let onWithOptions: (~key: string, string, options, JsonCombinators.Json.Decode.t<'b>) => Vdom.property<'b> + + let defaultOptions: options + + let targetValue: JsonCombinators.Json.Decode.t + + let targetChecked: JsonCombinators.Json.Decode.t + + let keyCode: JsonCombinators.Json.Decode.t + + let preventDefaultOn: (~key: string=?, string, JsonCombinators.Json.Decode.t<'b>) => Vdom.property<'b> + + + + let onClick: 'msg => Vdom.property<'msg> + + let onDoubleClick: 'msg => Vdom.property<'msg> + + let onMouseDown: 'msg => Vdom.property<'msg> + + let onMouseUp: 'msg => Vdom.property<'msg> + + let onMouseEnter: 'msg => Vdom.property<'msg> + + let onMouseLeave: 'msg => Vdom.property<'msg> + + let onMouseOver: 'msg => Vdom.property<'msg> + + let onMouseOut: 'msg => Vdom.property<'msg> + + + + + let onInputOpt: (~key: string=?, string => option<'msg>) => Vdom.property<'msg> + + let onInput: (~key: string=?, string => 'msg) => Vdom.property<'msg> + + let onCheckOpt: (~key: string=?, bool => option<'msg>) => Vdom.property<'msg> + + let onCheck: (~key: string=?, bool => 'msg) => Vdom.property<'msg> + + let onChangeOpt: (~key: string=?, string => option<'msg>) => Vdom.property<'msg> + + let onChange: (~key: string=?, string => 'msg) => Vdom.property<'msg> + + let onSubmit: 'msg => Vdom.property<'msg> + + + + + let onBlur: 'msg => Vdom.property<'msg> + let onFocus: 'msg => Vdom.property<'msg> + +} diff --git a/src/tea_html_cmds.res b/src/tea_html_cmds.res new file mode 100644 index 0000000..e714c0a --- /dev/null +++ b/src/tea_html_cmds.res @@ -0,0 +1,14 @@ +let focus = id => + Tea_cmd.call(_enqueue => { + let ecb = _ => + switch (Webapi.Dom.Document.getElementById(Webapi.Dom.document,id)->Belt.Option.flatMap(Webapi.Dom.HtmlInputElement.ofElement)){ + | None => Js.log(("Attempted to focus a non-existant element of: ", id)) + | Some(elem) => Webapi.Dom.HtmlInputElement.focus(elem) + } + + /* One to get out of the current render frame */ + let cb = _ => ignore(Webapi.requestAnimationFrame(ecb)) + /* And another to properly focus */ + ignore(Webapi.requestAnimationFrame(cb)) + () + }) diff --git a/src/tea_html_cmds.resi b/src/tea_html_cmds.resi new file mode 100644 index 0000000..e7eb504 --- /dev/null +++ b/src/tea_html_cmds.resi @@ -0,0 +1 @@ +let focus: string => Tea_cmd.t<'msg> diff --git a/src/tea_http.res b/src/tea_http.res new file mode 100644 index 0000000..8b334f4 --- /dev/null +++ b/src/tea_http.res @@ -0,0 +1,286 @@ +type responseStatus = { + code: int, + message: string, +} + +type requestBody = Web.XMLHttpRequest.body +type bodyType = Web.XMLHttpRequest.responseType +type responseBody = Web.XMLHttpRequest.responseBody + +type response = { + url: string, + status: responseStatus, + headers: Belt.Map.String.t, + body: responseBody, +} + +type error<'parsedata> = + | BadUrl(string) + | Timeout + | NetworkError + | Aborted + | BadStatus(response) + | BadPayload('parsedata, response) + +let stringOfError = x => + switch x { + | BadUrl(url) => "Bad Url: " ++ url + | Timeout => "Timeout" + | NetworkError => "Unknown network error" + | Aborted => "Request aborted" + | BadStatus(resp) => "Bad Status: " ++ resp.url + | BadPayload(_customData, resp) => "Bad Payload: " ++ resp.url + } + +type header = Header(string, string) + +type expect<'res> = Expect(bodyType, response => result<'res, string>) + +type requestEvents<'msg> = { + onreadystatechange: option< + (ref>, Web.XMLHttpRequest.event_readystatechange) => unit, + >, + onprogress: option< + (ref>, Web.XMLHttpRequest.event_progress) => unit, + >, +} + +let emptyRequestEvents = { + onreadystatechange: None, + onprogress: None, +} + +type rawRequest<'res> = { + method: string, + headers: list
, + url: string, + body: requestBody, + expect: expect<'res>, + timeout: option, + withCredentials: bool, +} + +type request<'msg, 'res> = Request(rawRequest<'res>, option>) + +let expectStringResponse = func => { + open Web.XMLHttpRequest + Expect( + TextResponseType, + ({body, _}) => + switch body { + | TextResponse(s) => func(s) + | _ => Error("Non-text response returned") + }, + ) +} + +let expectString = expectStringResponse(resString => Ok(resString)) + +let request = rawRequest => Request(rawRequest, None) + +let getString = url => + request({ + method: "GET", + headers: list{}, + url: url, + body: Web.XMLHttpRequest.EmptyBody, + expect: expectString, + timeout: None, + withCredentials: false, + }) + +let toTask = (Request(request, _maybeEvents)) => { + module StringMap = Map.Make(String) + let {method, headers, url, body, expect, timeout, withCredentials} = request + let Expect(typ, responseToResult) = expect + Tea_task.nativeBinding(cb => { + let enqRes = (result, _ev) => cb(result) + let enqResError = result => enqRes(Error(result)) + let enqResOk = result => enqRes(Ok(result)) + let xhr = Web.XMLHttpRequest.create() + let setEvent = (ev, cb) => ev(cb, xhr) + let () = setEvent(Web.XMLHttpRequest.set_onerror, enqResError(NetworkError)) + let () = setEvent(Web.XMLHttpRequest.set_ontimeout, enqResError(Timeout)) + let () = setEvent(Web.XMLHttpRequest.set_onabort, enqResError(Aborted)) + let () = setEvent(Web.XMLHttpRequest.set_onload, _ev => { + open Web.XMLHttpRequest + let headers = switch getAllResponseHeadersAsDict(xhr) { + | Error(_e) => Belt.Map.String.empty + | Ok(headers) => headers + } + let response = { + status: {code: get_status(xhr), message: get_statusText(xhr)}, + headers: headers, + url: get_responseURL(xhr), + body: get_response(xhr), + } + if response.status.code < 200 || 300 <= response.status.code { + enqResError(BadStatus(response), ()) + } else { + switch responseToResult(response) { + | Error(error) => enqResError(BadPayload(error, response), ()) + | Ok(result) => enqResOk(result, ()) + } + } + }) + let () = try Web.XMLHttpRequest.open_(method, url, xhr) catch { + | _ => enqResError(BadUrl(url), ()) + } + let () = { + let setHeader = (Header(k, v)) => Web.XMLHttpRequest.setRequestHeader(k, v, xhr) + let () = List.iter(setHeader, headers) + let () = Web.XMLHttpRequest.set_responseType(typ, xhr) + let () = switch timeout { + | None => () + | Some(t) => Web.XMLHttpRequest.set_timeout(t, xhr) + } + let () = Web.XMLHttpRequest.set_withCredentials(withCredentials, xhr) + } + let () = Web.XMLHttpRequest.send(body, xhr) + }) +} + +let send = (resultToMessage, Request(request, maybeEvents)) => { + module StringMap = Map.Make(String) + let {method, headers, url, body, expect, timeout, withCredentials} = request + let Expect(typ, responseToResult) = expect + Tea_cmd.call(callbacks => { + let enqRes = (result, _ev) => { + open Vdom + callbacks.contents.enqueue(resultToMessage(result)) + } + let enqResError = result => enqRes(Error(result)) + let enqResOk = result => enqRes(Ok(result)) + let xhr = Web.XMLHttpRequest.create() + let setEvent = (ev, cb) => ev(cb, xhr) + let () = switch maybeEvents { + | None => () + | Some({onprogress, onreadystatechange}) => + open Web.XMLHttpRequest + let mayCB = (thenDo, x) => + switch x { + | None => () + | Some(v) => thenDo(v(callbacks)) + } + let () = mayCB(setEvent(set_onreadystatechange), onreadystatechange) + let () = mayCB(setEvent(set_onprogress), onprogress) + } + let () = setEvent(Web.XMLHttpRequest.set_onerror, enqResError(NetworkError)) + let () = setEvent(Web.XMLHttpRequest.set_ontimeout, enqResError(Timeout)) + let () = setEvent(Web.XMLHttpRequest.set_onabort, enqResError(Aborted)) + let () = setEvent(Web.XMLHttpRequest.set_onload, _ev => { + open Web.XMLHttpRequest + let headers = switch getAllResponseHeadersAsDict(xhr) { + | Error(_e) => Belt.Map.String.empty + | Ok(headers) => headers + } + let response = { + status: {code: get_status(xhr), message: get_statusText(xhr)}, + headers: headers, + url: get_responseURL(xhr), + body: get_response(xhr), + } + if response.status.code < 200 || 300 <= response.status.code { + enqResError(BadStatus(response), ()) + } else { + switch responseToResult(response) { + | Error(error) => enqResError(BadPayload(error, response), ()) + | Ok(result) => enqResOk(result, ()) + } + } + }) + let () = try Web.XMLHttpRequest.open_(method, url, xhr) catch { + | _ => enqResError(BadUrl(url), ()) + } + let () = { + let setHeader = (Header(k, v)) => Web.XMLHttpRequest.setRequestHeader(k, v, xhr) + let () = List.iter(setHeader, headers) + let () = Web.XMLHttpRequest.set_responseType(typ, xhr) + let () = switch timeout { + | None => () + | Some(t) => Web.XMLHttpRequest.set_timeout(t, xhr) + } + let () = Web.XMLHttpRequest.set_withCredentials(withCredentials, xhr) + } + let () = Web.XMLHttpRequest.send(body, xhr) + }) +} + +@val external encodeURIComponent: string => string = "encodeURIComponent" + +let encodeUri = str => encodeURIComponent(str) + +@val external decodeURIComponent: string => string = "decodeURIComponent" + +let decodeUri = str => + try Some(decodeURIComponent(str)) catch { + | _ => None + } + +module Progress = { + /* + type bytesProgressed = + { bytes : int + ; bytesExpected : int + } + + type ('data, 'parseFailData) t = + | NoProgress + (* SomeProgress (bytes, bytesExpected) *) + | SomeProgress of bytesProgressed + | FailProgress of 'parseFailData error + | DoneProgress of 'data + + type ('msg, 'parseFailData) trackedRequest = + { request : 'msg rawRequest + ; toProgress : bytesProgressed -> 'msg + ; toError : 'parseFailData error -> 'msg + } + */ + + type t = { + bytes: int, + bytesExpected: int, + } + + let emptyProgress = { + bytes: 0, + bytesExpected: 0, + } + + /* Yeah this does not follow the original API, but that original + API is... not extensible... Instead, we have generic event + listener support here so no need to constrain the API. + Might still want to make a subscription variant though... */ + let track = (toMessage, Request(request, events)) => { + let onprogress = Some( + (callbacks, ev) => { + open Vdom + let lengthComputable = { + open JsonCombinators + switch Json.Decode.decode(ev, Json.Decode.field("lengthComputable", Json.Decode.bool)) { + | Error(_e) => false + | Ok(v) => v + } + } + if lengthComputable { + open JsonCombinators + let decoder = Json.Decode.object(field =>{ + bytes: field.required(. "loaded", Json.Decode.int), + bytesExpected: field.required(. "total", Json.Decode.int), + }) + + switch Json.Decode.decode(ev, decoder) { + | Error(_e) => () + | Ok(t) => callbacks.contents.enqueue(toMessage(t)) + } + } + }, + ) + let events = switch events { + | None => emptyRequestEvents + | Some(e) => e + } + Request(request, Some({...events, onprogress: onprogress})) + } +} diff --git a/src/tea_http.resi b/src/tea_http.resi new file mode 100644 index 0000000..fb5eb4b --- /dev/null +++ b/src/tea_http.resi @@ -0,0 +1,67 @@ +type responseStatus = {code: int, message: string} + +type requestBody = Web.XMLHttpRequest.body +type bodyType = Web.XMLHttpRequest.responseType +type responseBody = Web.XMLHttpRequest.responseBody + +type response = { + url: string, + status: responseStatus, + headers: Belt.Map.String.t, + body: responseBody, +} + +type error<'parsedata> = + | BadUrl(string) + | Timeout + | NetworkError + | Aborted + | BadStatus(response) + | BadPayload('parsedata, response) + +let stringOfError: error<'msg> => string +type header = Header(string, string) +type expect<'res> = Expect(bodyType, response => result<'res, string>) +type requestEvents<'msg> = { + onreadystatechange: option< + (ref>, Web.XMLHttpRequest.event_readystatechange) => unit,>, + onprogress: option< + (ref>, Web.XMLHttpRequest.event_progress) => unit,>, +} + +let emptyRequestEvents: requestEvents<'msg> +type rawRequest<'res> = { + method: string, + headers: list
, + url: string, + body: requestBody, + expect: expect<'res>, + timeout: option, + withCredentials: bool, +} + +type request<'msg, 'res> = Request(rawRequest<'res>, option>) + +let expectStringResponse: (string => result<'msg, string>) => expect<'msg> + +let expectString: expect + +let request: rawRequest<'msg> => request<'b, 'msg> + +let getString: string => request<'msg, string> + +let toTask: request<'msg, 'b> => Tea_task.t<'b, error> + +let send: (result<'msg, error> => 'b, request<'b, 'msg>) => Tea_cmd.t<'b> +@val external encodeURIComponent: string => string = "encodeURIComponent" +let encodeUri: string => string +@val external decodeURIComponent: string => string = "decodeURIComponent" + +let decodeUri: string => option + + +module Progress: { + type t = {bytes: int, bytesExpected: int} + let emptyProgress: t + let track: (t => 'msg, request<'msg, 'b>) => request<'msg, 'b> +} diff --git a/src/tea_mouse.res b/src/tea_mouse.res new file mode 100644 index 0000000..c71673e --- /dev/null +++ b/src/tea_mouse.res @@ -0,0 +1,38 @@ +type position = { + x: int, + y: int, +} + +open JsonCombinators +let position = Json.Decode.object(field => { + x: field.required(. "pageX", Json.Decode.int), + y: field.required(. "pageY", Json.Decode.int), + }) + +let registerGlobal = (name, key, tagger) => { + open Vdom + let enableCall = callbacks_base => { + let callbacks = ref(callbacks_base) + let fn = ev => { + switch Rescript_json_combinators_extended.decodeEvent(position, ev) { + | Error(_) => None + | Ok(pos) => Some(tagger(pos)) + } + } + let handler = EventHandlerCallback(key, fn) + let elem = Web_node.document_node + let cache = eventHandlerRegister(callbacks, elem, name, handler) + () => { + let _ = eventHandlerUnregister(elem, name, cache) + } + } + Tea_sub.registration(key, enableCall) +} + +let clicks = (~key="", tagger) => registerGlobal("click", key, tagger) + +let moves = (~key="", tagger) => registerGlobal("mousemove", key, tagger) + +let downs = (~key="", tagger) => registerGlobal("mousedown", key, tagger) + +let ups = (~key="", tagger) => registerGlobal("mouseup", key, tagger) diff --git a/src/tea_mouse.resi b/src/tea_mouse.resi new file mode 100644 index 0000000..26998b3 --- /dev/null +++ b/src/tea_mouse.resi @@ -0,0 +1,14 @@ +type position = {x: int, y: int} + +let position: JsonCombinators.Json.Decode.t + +let registerGlobal: (string, string, position => 'msg) => Tea_sub.t<'msg> + +let clicks: (~key: string=?, position => 'msg) => Tea_sub.t<'msg> + +let moves: (~key: string=?, position => 'msg) => Tea_sub.t<'msg> + +let downs: (~key: string=?, position => 'msg) => Tea_sub.t<'msg> + +let ups: (~key: string=?, position => 'msg) => Tea_sub.t<'msg> + diff --git a/src/tea_navigation.res b/src/tea_navigation.res new file mode 100644 index 0000000..2782928 --- /dev/null +++ b/src/tea_navigation.res @@ -0,0 +1,79 @@ +type navigationProgram<'flags, 'model, 'msg> = { + init: ('flags, Web.Location.location) => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, + shutdown: 'model => Tea_cmd.t<'msg>, +} + +let getLocation = () => Web.Location.asRecord(Web.Document.location()) + +let notifier: ref unit>> = ref(None) + +let notifyUrlChange = () => + switch notifier.contents { + | None => () + | Some(cb) => + let location = getLocation() + let () = cb(location) + } + +let subscribe = tagger => { + open Vdom + let enableCall = callbacks => { + let notifyHandler = location => callbacks.enqueue(tagger(location)) + let () = notifier := Some(notifyHandler) + let handler: Web.Node.event_cb = (. _event) => notifyUrlChange() + let () = Web.Window.addEventListener("popstate", handler, false) + () => Web.Window.removeEventListener("popstate", handler, false) + } + Tea_sub.registration("navigation", enableCall) +} + +let replaceState = url => { + let _ = Web.Window.History.replaceState(Web.Window.window, Js.Json.parseExn("{}"), "", url) +} + +let pushState = url => { + let _ = Web.Window.History.pushState(Web.Window.window, Js.Json.parseExn("{}"), "", url) +} + +let modifyUrl = url => + Tea_cmd.call(_enqueue => { + let () = replaceState(url) + let () = notifyUrlChange() + }) + +let newUrl = url => + Tea_cmd.call(_enqueue => { + let () = pushState(url) + let () = notifyUrlChange() + }) + +let go = step => + Tea_cmd.call(_enqueue => { + let _ = { + open Web.Window + History.go(window) + }(step) + let () = notifyUrlChange() + }) + +let back = step => go(-step) +let forward = step => go(step) + +let navigationProgram = (locationToMessage, stuff) => { + let init = flag => stuff.init(flag, getLocation()) + + let subscriptions = model => + Tea_sub.batch(list{subscribe(locationToMessage), stuff.subscriptions(model)}) + + open! Tea_app + program({ + init: init, + update: stuff.update, + view: stuff.view, + subscriptions: subscriptions, + shutdown: stuff.shutdown, + }) +} diff --git a/src/tea_navigation.resi b/src/tea_navigation.resi new file mode 100644 index 0000000..db640de --- /dev/null +++ b/src/tea_navigation.resi @@ -0,0 +1,36 @@ +type navigationProgram<'flags, 'model, 'msg> = { + init: ('flags, Web.Location.location) => ('model, Tea_cmd.t<'msg>), + update: ('model, 'msg) => ('model, Tea_cmd.t<'msg>), + view: 'model => Vdom.t<'msg>, + subscriptions: 'model => Tea_sub.t<'msg>, + shutdown: 'model => Tea_cmd.t<'msg>, +} + +let getLocation: unit => Web.Location.location + +let notifier: ref unit>> + +let notifyUrlChange: unit => unit + +let subscribe: (Web.Location.location => 'msg) => Tea_sub.t<'msg> + +let replaceState: string => unit + +let pushState: string => unit + +let modifyUrl: string => Tea_cmd.t<'msg> + +let newUrl: string => Tea_cmd.t<'msg> + +let go: int => Tea_cmd.t<'msg> + +let back: int => Tea_cmd.t<'msg> + +let forward: int => Tea_cmd.t<'msg> + +let navigationProgram: ( + Web.Location.location => 'msg, + navigationProgram<'b, 'c, 'msg>, + Js.null_undefined, + 'b, +) => Tea_app.programInterface<'msg> diff --git a/src/tea_program.res b/src/tea_program.res new file mode 100644 index 0000000..7f1b7b8 --- /dev/null +++ b/src/tea_program.res @@ -0,0 +1,44 @@ +type processMsg<'msg> = + | PushMsg('msg) + | Kill + +let spawn = (initState, update, shutdown) => { + let state = ref(Some(initState)) + let onMessage = procMsg => + switch state.contents { + | None => () + | Some(model) => + switch procMsg { + | PushMsg(msg) => + let () = state := update(model, msg) + | Kill => + let () = shutdown(model) + let () = state := None + } + } + onMessage +} + +/* let testing0 = + let s = spawn 42 (fun model -> let () = Js.log model in function + | `Inc -> Some (model + 1) + | `Dec -> Some (model - 1) + ) (fun _ -> ()) in + let () = s (PushMsg `Dec) in + let () = s (PushMsg `Dec) in + let () = s Kill in + let () = s (PushMsg `Dec) in + () */ + +module type Process = { + /* This module should be `import`ed into a module that will become a persistent process. + That process should have a handleMsg callback to handle its own message types. + It should call itself + */ + + type msg + + let handleMsg: msg => unit +} + +let testing1 = 42 diff --git a/src/tea_program.resi b/src/tea_program.resi new file mode 100644 index 0000000..3dc2e26 --- /dev/null +++ b/src/tea_program.resi @@ -0,0 +1,10 @@ +type processMsg<'msg> = PushMsg('msg) | Kill + +let spawn: ('msg, ('msg, 'b) => option<'msg>, 'msg => unit, processMsg<'b>) => unit + +module type Process = { + type msg + let handleMsg: msg => unit +} + +let testing1: int diff --git a/src/tea_promise.res b/src/tea_promise.res new file mode 100644 index 0000000..296a1e4 --- /dev/null +++ b/src/tea_promise.res @@ -0,0 +1,47 @@ +let cmd = (promise, tagger) => { + open Vdom + Tea_cmd.call(x => + switch x { + | callbacks => + let _ = promise |> Js.Promise.then_(x => + switch x { + | res => + switch tagger(res) { + | Some(msg) => + let () = callbacks.contents.enqueue(msg) + Js.Promise.resolve() + | None => Js.Promise.resolve() + } + } + ) + } + ) +} + +let result = (promise, msg) => { + open Vdom + Tea_cmd.call(x => + switch x { + | callbacks => + let enq = result => callbacks.contents.enqueue(msg(result)) + + let _ = + promise + |> Js.Promise.then_(x => + switch x { + | res => + let resolve = enq(Ok(res)) + Js.Promise.resolve(resolve) + } + ) + |> Js.Promise.catch(x => + switch x { + | err => + let errToString = err => j`$err` + let reject = enq(Error(errToString(err))) + Js.Promise.resolve(reject) + } + ) + } + ) +} diff --git a/src/tea_promise.resi b/src/tea_promise.resi new file mode 100644 index 0000000..aa558e5 --- /dev/null +++ b/src/tea_promise.resi @@ -0,0 +1,3 @@ +let cmd: (Js.Promise.t<'msg>, 'msg => option<'b>) => Tea_cmd.t<'b> + +let result: (Js.Promise.t<'msg>, result<'msg, string> => 'b) => Tea_cmd.t<'b> diff --git a/src/tea_random.res b/src/tea_random.res new file mode 100644 index 0000000..397602e --- /dev/null +++ b/src/tea_random.res @@ -0,0 +1,117 @@ +let () = Random.self_init() + +let minInt = min_int + +let maxInt = max_int + +let minFloat = min_float + +let maxFloat = max_float + +type t<'typ> = Generator(Random.State.t => 'typ) + +let bool = Generator(state => Random.State.bool(state)) + +let int = (min, max) => { + let (min, max) = if min < max { + (min, max) + } else { + (max, min) + } + Generator(state => min + Random.State.int(state, max - min + 1)) +} + +let float = (min, max) => Generator(state => min +. Random.State.float(state, max -. min)) + +let list = (count, Generator(genCmd)) => { + let rec buildList = (state, i, acc) => + if i > 0 { + buildList(state, i - 1, list{genCmd(state), ...acc}) + } else { + acc + } + Generator(state => buildList(state, count, list{})) +} + +let map = (func, Generator(genCmd)) => Generator(state => func(genCmd(state))) + +let map2 = (func, Generator(genCmd1), Generator(genCmd2)) => Generator( + state => { + let res1 = genCmd1(state) + let res2 = genCmd2(state) + func(res1, res2) + }, +) + +let map3 = (func, Generator(genCmd1), Generator(genCmd2), Generator(genCmd3)) => Generator( + state => { + let res1 = genCmd1(state) + let res2 = genCmd2(state) + let res3 = genCmd3(state) + func(res1, res2, res3) + }, +) + +let map4 = ( + func, + Generator(genCmd1), + Generator(genCmd2), + Generator(genCmd3), + Generator(genCmd4), +) => Generator( + state => { + let res1 = genCmd1(state) + let res2 = genCmd2(state) + let res3 = genCmd3(state) + let res4 = genCmd4(state) + func(res1, res2, res3, res4) + }, +) + +let map5 = ( + func, + Generator(genCmd1), + Generator(genCmd2), + Generator(genCmd3), + Generator(genCmd4), + Generator(genCmd5), +) => Generator( + state => { + let res1 = genCmd1(state) + let res2 = genCmd2(state) + let res3 = genCmd3(state) + let res4 = genCmd4(state) + let res5 = genCmd5(state) + func(res1, res2, res3, res4, res5) + }, +) + +let andThen = (func, Generator(genCmd)) => Generator( + state => { + let res = genCmd(state) + let Generator(userGen) = func(res) + userGen(state) + }, +) + +let pair = (gen1, gen2) => map2((a, b) => (a, b), gen1, gen2) + +let generate = (tagger, Generator(genCmd)) => + Tea_cmd.call(callbacks => { + let state = Random.get_state() + let genValue = genCmd(state) + let () = Random.set_state(state) + open Vdom + callbacks.contents.enqueue(tagger(genValue)) + }) + +/* Generate Values Manually */ + +type seed = Seed(Random.State.t) + +let step = (Generator(genCmd), Seed(state)) => { + let newState = Random.State.copy(state) + (genCmd(newState), Seed(newState)) +} + +let initialSeed = seed => Seed(Random.State.make([seed])) diff --git a/src/tea_random.resi b/src/tea_random.resi new file mode 100644 index 0000000..465746b --- /dev/null +++ b/src/tea_random.resi @@ -0,0 +1,41 @@ +let minInt: int + +let maxInt: int + +let minFloat: float + +let maxFloat: float + +type t<'typ> = Generator(Random.State.t => 'typ) + +let bool: t + +let int: (int, int) => t + +let float: (float, float) => t + +let list: (int, t<'msg>) => t> + +let map: ('msg => 'b, t<'msg>) => t<'b> + +let map2: (('msg, 'b) => 'c, t<'msg>, t<'b>) => t<'c> + +let map3: (('msg, 'b, 'c) => 'd, t<'msg>, t<'b>, t<'c>) => t<'d> + +let map4: (('msg, 'b, 'c, 'd) => 'e, t<'msg>, t<'b>, t<'c>, t<'d>) => t<'e> + +let map5: (('msg, 'b, 'c, 'd, 'e) => 'f, t<'msg>, t<'b>, t<'c>, t<'d>, t<'e>) => t<'f> + +let andThen: ('msg => t<'b>, t<'msg>) => t<'b> + +let pair: (t<'msg>, t<'b>) => t<('msg, 'b)> + +let generate: ('msg => 'b, t<'msg>) => Tea_cmd.t<'b> + +type seed = Seed(Random.State.t) + +let step: (t<'msg>, seed) => ('msg, seed) + +let initialSeed: int => seed + + diff --git a/src/tea_result.res b/src/tea_result.res new file mode 100644 index 0000000..34beb09 --- /dev/null +++ b/src/tea_result.res @@ -0,0 +1,12 @@ +let first = (fst, x) => + switch x { + | Error(_) as e => e + | Ok(_) => fst + } + + +let resultToOption = x => + switch x { + | Ok(a) => Some(a) + | Error(_) => None + } \ No newline at end of file diff --git a/src/tea_result.resi b/src/tea_result.resi new file mode 100644 index 0000000..e52688e --- /dev/null +++ b/src/tea_result.resi @@ -0,0 +1,3 @@ +let first: (result<'msg, 'b>, result<'c, 'b>) => result<'msg, 'b> + +let resultToOption: result<'msg, 'b> => option<'msg> diff --git a/src/tea_sub.res b/src/tea_sub.res new file mode 100644 index 0000000..5d916b4 --- /dev/null +++ b/src/tea_sub.res @@ -0,0 +1,99 @@ +type rec t<'msg> = + | NoSub: t<_> + | Batch(list>): t<'msg> + | Registration( + string, + (ref>, unit) => unit, + ref unit>>, + ): t<'msg> + | Mapper( + ref> => ref>, + t<'msgB>, + ): t<'msg> +type applicationCallbacks<'msg> = Vdom.applicationCallbacks<'msg> +let none = NoSub +let batch = subs => Batch(subs) +let registration = (key, enableCall) => +Registration(key, callbacks => enableCall(callbacks.contents), ref(None)) +let map = (msgMapper, sub) => { + let func = callbacks => Vdom.wrapCallbacks(msgMapper, callbacks) + Mapper(func, sub) +} +let mapFunc = (func, sub) => Mapper(func, sub) +let rec run: + type msgOld msgNew. ( + ref>, + ref>, + t, + t, + ) => t = + (oldCallbacks, newCallbacks, oldSub, newSub) => { + let rec enable: + type msg. (ref>, t) => unit = + (callbacks, x) => + switch x { + | NoSub => () + | Batch(list{}) => () + | Batch(subs) => List.iter(enable(callbacks), subs) + | Mapper(mapper, sub) => + let subCallbacks = mapper(callbacks) + enable(subCallbacks, sub) + | Registration(_key, enCB, diCB) => diCB := Some(enCB(callbacks)) + } + let rec disable: + type msg. (ref>, t) => unit = + (callbacks, x) => + switch x { + | NoSub => () + | Batch(list{}) => () + | Batch(subs) => List.iter(disable(callbacks), subs) + | Mapper(mapper, sub) => + let subCallbacks = mapper(callbacks) + disable(subCallbacks, sub) + | Registration(_key, _enCB, diCB) => + switch diCB.contents { + | None => () + | Some(cb) => + let () = diCB := None + cb() + } + } + @ocaml.warning("-4") + switch (oldSub, newSub) { + | (NoSub, NoSub) => newSub + | ( + Registration(oldKey, _oldEnCB, oldDiCB), + Registration(newKey, _newEnCB, newDiCB), + ) if oldKey == newKey => + let () = newDiCB := oldDiCB.contents + newSub + | ( + Mapper(oldMapper, oldSubSub), + Mapper(newMapper, newSubSub), + ) => + let olderCallbacks = oldMapper(oldCallbacks) + let newerCallbacks = newMapper(newCallbacks) + let _newerSubSub = run(olderCallbacks, newerCallbacks, oldSubSub, newSubSub) + newSub + | (Batch(oldSubs), Batch(newSubs)) => + let rec aux = (oldList, newList) => + switch (oldList, newList) { + | (list{}, list{}) => () + | (list{}, list{newSubSub, ...newRest}) => + let () = enable(newCallbacks, newSubSub) + aux(list{}, newRest) + | (list{oldSubSub, ...oldRest}, list{}) => + let () = disable(oldCallbacks, oldSubSub) + aux(oldRest, list{}) + | (list{oldSubSub, ...oldRest}, list{newSubSub, ...newRest}) => + let _newerSubSub = run(oldCallbacks, newCallbacks, oldSubSub, newSubSub) + aux(oldRest, newRest) + } + let () = aux(oldSubs, newSubs) + newSub + | (oldS, newS) => + let () = disable(oldCallbacks, oldS) + let () = enable(newCallbacks, newS) + newSub + } + } diff --git a/src/tea_sub.resi b/src/tea_sub.resi new file mode 100644 index 0000000..73695ec --- /dev/null +++ b/src/tea_sub.resi @@ -0,0 +1,32 @@ +type rec t<'msg> = + | NoSub: t<'msg> + | Batch(list>): t<'msg> + | Registration( + string, + (ref>, unit) => unit, + ref unit>>, + ): t<'msg> + | Mapper( + ref> => ref>, + t<'msgB>, + ): t<'msg> + + +type applicationCallbacks<'msg> = Vdom.applicationCallbacks<'msg> + +let none: t<'msg> + +let batch: list> => t<'msg> + +let registration: (string, (Vdom.applicationCallbacks<'msg>, unit) => unit) => t<'msg> + +let map: ('msg => 'b, t<'msg>) => t<'b> + +let mapFunc: (ref> => ref>, t<'b>) => t<'msg,> + +let run: ( + ref>, + ref>, + t<'msgOld>, + t<'msgNew>, +) => t<'msgNew> diff --git a/src-reason/tea_svg.re b/src/tea_svg.res similarity index 63% rename from src-reason/tea_svg.re rename to src/tea_svg.res index 36673d4..79d98c6 100644 --- a/src-reason/tea_svg.re +++ b/src/tea_svg.res @@ -1,269 +1,280 @@ -open Vdom; +open Vdom -module Cmds = Tea_html_cmds; +module Cmds = Tea_html_cmds -module Attributes = Tea_svg_attributes; +module Attributes = Tea_svg_attributes -module Events = Tea_svg_events; +module Events = Tea_svg_events -let svgNamespace = "http://www.w3.org/2000/svg"; +let svgNamespace = "http://www.w3.org/2000/svg" /* Nodes */ -let noNode = noNode; -let text = str => text(str); +let noNode = noNode -let lazy1 = (key, gen) => lazyGen(key, gen); +let text = str => text(str) + +let lazy1 = (key, gen) => lazyGen(key, gen) let node = (tagName, ~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, tagName, key, unique, props, nodes); + fullnode(svgNamespace, tagName, key, unique, props, nodes) let svg = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "svg", key, unique, props, nodes); + fullnode(svgNamespace, "svg", key, unique, props, nodes) /* Animation elements */ + let foreignObject = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "foreignObject", key, unique, props, nodes); + fullnode(svgNamespace, "foreignObject", key, unique, props, nodes) let animate = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "animate", key, unique, props, nodes); + fullnode(svgNamespace, "animate", key, unique, props, nodes) let animateColor = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "animateColor", key, unique, props, nodes); + fullnode(svgNamespace, "animateColor", key, unique, props, nodes) let animateMotion = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "animateMotion", key, unique, props, nodes); + fullnode(svgNamespace, "animateMotion", key, unique, props, nodes) let animateTransform = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "animateTransform", key, unique, props, nodes); + fullnode(svgNamespace, "animateTransform", key, unique, props, nodes) let mpath = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "mpath", key, unique, props, nodes); + fullnode(svgNamespace, "mpath", key, unique, props, nodes) let set = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "set", key, unique, props, nodes); + fullnode(svgNamespace, "set", key, unique, props, nodes) /* Container elements */ + let a = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "a", key, unique, props, nodes); + fullnode(svgNamespace, "a", key, unique, props, nodes) let defs = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "defs", key, unique, props, nodes); + fullnode(svgNamespace, "defs", key, unique, props, nodes) let g = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "g", key, unique, props, nodes); + fullnode(svgNamespace, "g", key, unique, props, nodes) let marker = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "marker", key, unique, props, nodes); + fullnode(svgNamespace, "marker", key, unique, props, nodes) let mask = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "mask", key, unique, props, nodes); + fullnode(svgNamespace, "mask", key, unique, props, nodes) let missingGlyph = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "missingGlyph", key, unique, props, nodes); + fullnode(svgNamespace, "missingGlyph", key, unique, props, nodes) let pattern = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "pattern", key, unique, props, nodes); + fullnode(svgNamespace, "pattern", key, unique, props, nodes) -let switch_ = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "switch", key, unique, props, nodes); +let switch' = (~key="", ~unique="", props, nodes) => + fullnode(svgNamespace, "switch", key, unique, props, nodes) let symbol = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "symbol", key, unique, props, nodes); + fullnode(svgNamespace, "symbol", key, unique, props, nodes) /* Descriptive elements */ + let desc = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "desc", key, unique, props, nodes); + fullnode(svgNamespace, "desc", key, unique, props, nodes) let metadata = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "metadata", key, unique, props, nodes); + fullnode(svgNamespace, "metadata", key, unique, props, nodes) let title = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "title", key, unique, props, nodes); + fullnode(svgNamespace, "title", key, unique, props, nodes) /* Filter primitive elements */ + let feBlend = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feBlend", key, unique, props, nodes); + fullnode(svgNamespace, "feBlend", key, unique, props, nodes) let feColorMatrix = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feColorMatrix", key, unique, props, nodes); + fullnode(svgNamespace, "feColorMatrix", key, unique, props, nodes) let feComponentTransfer = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feComponentTransfer", key, unique, props, nodes); + fullnode(svgNamespace, "feComponentTransfer", key, unique, props, nodes) let feComposite = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feComposite", key, unique, props, nodes); + fullnode(svgNamespace, "feComposite", key, unique, props, nodes) let feConvolveMatrix = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feConvolveMatrix", key, unique, props, nodes); + fullnode(svgNamespace, "feConvolveMatrix", key, unique, props, nodes) let feDiffuseLighting = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feDiffuseLighting", key, unique, props, nodes); + fullnode(svgNamespace, "feDiffuseLighting", key, unique, props, nodes) let feDisplacementMap = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feDisplacementMap", key, unique, props, nodes); + fullnode(svgNamespace, "feDisplacementMap", key, unique, props, nodes) let feFlood = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feFlood", key, unique, props, nodes); + fullnode(svgNamespace, "feFlood", key, unique, props, nodes) let feFuncA = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feFuncA", key, unique, props, nodes); + fullnode(svgNamespace, "feFuncA", key, unique, props, nodes) let feFuncB = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feFuncB", key, unique, props, nodes); + fullnode(svgNamespace, "feFuncB", key, unique, props, nodes) let feFuncG = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feFuncG", key, unique, props, nodes); + fullnode(svgNamespace, "feFuncG", key, unique, props, nodes) let feFuncR = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feFuncR", key, unique, props, nodes); + fullnode(svgNamespace, "feFuncR", key, unique, props, nodes) let feGaussianBlur = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feGaussianBlur", key, unique, props, nodes); + fullnode(svgNamespace, "feGaussianBlur", key, unique, props, nodes) let feImage = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feImage", key, unique, props, nodes); + fullnode(svgNamespace, "feImage", key, unique, props, nodes) let feMerge = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feMerge", key, unique, props, nodes); + fullnode(svgNamespace, "feMerge", key, unique, props, nodes) let feMergeNode = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feMergeNode", key, unique, props, nodes); + fullnode(svgNamespace, "feMergeNode", key, unique, props, nodes) let feMorphology = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feMorphology", key, unique, props, nodes); + fullnode(svgNamespace, "feMorphology", key, unique, props, nodes) let feOffset = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feOffset", key, unique, props, nodes); + fullnode(svgNamespace, "feOffset", key, unique, props, nodes) let feSpecularLighting = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feSpecularLighting", key, unique, props, nodes); + fullnode(svgNamespace, "feSpecularLighting", key, unique, props, nodes) let feTile = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feTile", key, unique, props, nodes); + fullnode(svgNamespace, "feTile", key, unique, props, nodes) let feTurbulence = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feTurbulence", key, unique, props, nodes); + fullnode(svgNamespace, "feTurbulence", key, unique, props, nodes) /* Font elements */ + let font = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "font", key, unique, props, nodes); + fullnode(svgNamespace, "font", key, unique, props, nodes) let fontFace = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fontFace", key, unique, props, nodes); + fullnode(svgNamespace, "fontFace", key, unique, props, nodes) let fontFaceFormat = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fontFaceFormat", key, unique, props, nodes); + fullnode(svgNamespace, "fontFaceFormat", key, unique, props, nodes) let fontFaceName = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fontFaceName", key, unique, props, nodes); + fullnode(svgNamespace, "fontFaceName", key, unique, props, nodes) let fontFaceSrc = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fontFaceSrc", key, unique, props, nodes); + fullnode(svgNamespace, "fontFaceSrc", key, unique, props, nodes) let fontFaceUri = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fontFaceUri", key, unique, props, nodes); + fullnode(svgNamespace, "fontFaceUri", key, unique, props, nodes) let hkern = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "hkern", key, unique, props, nodes); + fullnode(svgNamespace, "hkern", key, unique, props, nodes) let vkern = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "vkern", key, unique, props, nodes); + fullnode(svgNamespace, "vkern", key, unique, props, nodes) /* Gradient elements */ + let linearGradient = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "linearGradient", key, unique, props, nodes); + fullnode(svgNamespace, "linearGradient", key, unique, props, nodes) let radialGradient = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "radialGradient", key, unique, props, nodes); + fullnode(svgNamespace, "radialGradient", key, unique, props, nodes) let stop = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "stop", key, unique, props, nodes); + fullnode(svgNamespace, "stop", key, unique, props, nodes) /* Graphics elements */ + let circle = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "circle", key, unique, props, nodes); + fullnode(svgNamespace, "circle", key, unique, props, nodes) let ellipse = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "ellipse", key, unique, props, nodes); + fullnode(svgNamespace, "ellipse", key, unique, props, nodes) let svgimage = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "image", key, unique, props, nodes); + fullnode(svgNamespace, "image", key, unique, props, nodes) let line = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "line", key, unique, props, nodes); + fullnode(svgNamespace, "line", key, unique, props, nodes) let path = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "path", key, unique, props, nodes); + fullnode(svgNamespace, "path", key, unique, props, nodes) let polygon = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "polygon", key, unique, props, nodes); + fullnode(svgNamespace, "polygon", key, unique, props, nodes) let polyline = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "polyline", key, unique, props, nodes); + fullnode(svgNamespace, "polyline", key, unique, props, nodes) let rect = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "rect", key, unique, props, nodes); + fullnode(svgNamespace, "rect", key, unique, props, nodes) let use = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "use", key, unique, props, nodes); + fullnode(svgNamespace, "use", key, unique, props, nodes) /* Light source elements */ + let feDistantLight = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feDistantLight", key, unique, props, nodes); + fullnode(svgNamespace, "feDistantLight", key, unique, props, nodes) let fePointLight = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "fePointLight", key, unique, props, nodes); + fullnode(svgNamespace, "fePointLight", key, unique, props, nodes) let feSpotLight = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "feSpotLight", key, unique, props, nodes); + fullnode(svgNamespace, "feSpotLight", key, unique, props, nodes) /* Text content elements */ + let altGlyph = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "altGlyph", key, unique, props, nodes); + fullnode(svgNamespace, "altGlyph", key, unique, props, nodes) let altGlyphDef = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "altGlyphDef", key, unique, props, nodes); + fullnode(svgNamespace, "altGlyphDef", key, unique, props, nodes) let altGlyphItem = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "altGlyphItem", key, unique, props, nodes); + fullnode(svgNamespace, "altGlyphItem", key, unique, props, nodes) let glyph = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "glyph", key, unique, props, nodes); + fullnode(svgNamespace, "glyph", key, unique, props, nodes) let glyphRef = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "glyphRef", key, unique, props, nodes); + fullnode(svgNamespace, "glyphRef", key, unique, props, nodes) let textPath = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "textPath", key, unique, props, nodes); + fullnode(svgNamespace, "textPath", key, unique, props, nodes) let text' = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "text", key, unique, props, nodes); + fullnode(svgNamespace, "text", key, unique, props, nodes) let tref = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "tref", key, unique, props, nodes); + fullnode(svgNamespace, "tref", key, unique, props, nodes) let tspan = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "tspan", key, unique, props, nodes); + fullnode(svgNamespace, "tspan", key, unique, props, nodes) /* Uncategorized elements */ + let clipPath = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "clipPath", key, unique, props, nodes); + fullnode(svgNamespace, "clipPath", key, unique, props, nodes) let svgcolorProfile = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "colorProfile", key, unique, props, nodes); + fullnode(svgNamespace, "colorProfile", key, unique, props, nodes) let cursor = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "cursor", key, unique, props, nodes); + fullnode(svgNamespace, "cursor", key, unique, props, nodes) let filter = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "filter", key, unique, props, nodes); + fullnode(svgNamespace, "filter", key, unique, props, nodes) let script = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "script", key, unique, props, nodes); + fullnode(svgNamespace, "script", key, unique, props, nodes) let style = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "style", key, unique, props, nodes); + fullnode(svgNamespace, "style", key, unique, props, nodes) let view = (~key="", ~unique="", props, nodes) => - fullnode(svgNamespace, "view", key, unique, props, nodes); + fullnode(svgNamespace, "view", key, unique, props, nodes) diff --git a/src/tea_svg.resi b/src/tea_svg.resi new file mode 100644 index 0000000..af28c45 --- /dev/null +++ b/src/tea_svg.resi @@ -0,0 +1,376 @@ +module Cmds = Tea_html_cmds + +module Attributes = Tea_svg_attributes + +module Events = Tea_svg_events + +let svgNamespace: string + + + +let noNode: Vdom.t<'msg> + +let text: string => Vdom.t<'msg> + +let lazy1: (string, unit => Vdom.t<'msg>) => Vdom.t<'msg> + +let node: ( + string, + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let svg: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let foreignObject: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let animate: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let animateColor: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let animateMotion: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let animateTransform: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let mpath: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let set: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let a: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let defs: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let g: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let marker: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let mask: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let missingGlyph: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let pattern: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let switch': (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let symbol: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let desc: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let metadata: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let title: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let feBlend: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feColorMatrix: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feComponentTransfer: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feComposite: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feConvolveMatrix: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feDiffuseLighting: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feDisplacementMap: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feFlood: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + + +let feFuncA: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feFuncB: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feFuncG: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + + +let feFuncR: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feGaussianBlur: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feImage: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feMerge: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feMergeNode: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feMorphology: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feOffset: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let feSpecularLighting: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feTile: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let feTurbulence: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + + + + +let font: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let fontFace: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let fontFaceFormat: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let fontFaceName: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let fontFaceSrc: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let fontFaceUri: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let hkern: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let vkern: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let linearGradient: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let radialGradient: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let stop: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let circle: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let ellipse: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let svgimage: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let line: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let path: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let polygon: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let polyline: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let rect: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let use: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let feDistantLight: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let fePointLight: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let feSpotLight: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + + + + +let altGlyph: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let altGlyphDef: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let altGlyphItem: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let glyph: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let glyphRef: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let textPath: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let text': (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let tref: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let tspan: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + + + + +let clipPath: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t< + 'msg,> + +let svgcolorProfile: ( + ~key: string=?, + ~unique: string=?, + Vdom.properties<'msg>, + list>, +) => Vdom.t<'msg> + +let cursor: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let filter: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let script: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let style: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> + +let view: (~key: string=?, ~unique: string=?, Vdom.properties<'msg>, list>) => Vdom.t<'msg> diff --git a/src/tea_svg_attributes.res b/src/tea_svg_attributes.res new file mode 100644 index 0000000..9306a51 --- /dev/null +++ b/src/tea_svg_attributes.res @@ -0,0 +1,511 @@ +open Vdom + +/* Regular attributes */ + +let accentHeight = v => attribute("", "accent-height", v) + +let accelerate = v => attribute("", "accelerate", v) + +let accumulate = v => attribute("", "accumulate", v) + +let additive = v => attribute("", "additive", v) + +let alphabetic = v => attribute("", "alphabetic", v) + +let allowReorder = v => attribute("", "allowReorder", v) + +let amplitude = v => attribute("", "amplitude", v) + +let arabicForm = v => attribute("", "arabic-form", v) + +let ascent = v => attribute("", "ascent", v) + +let attributeName = v => attribute("", "attributeName", v) + +let attributeType = v => attribute("", "attributeType", v) + +let autoReverse = v => attribute("", "autoReverse", v) + +let azimuth = v => attribute("", "azimuth", v) + +let baseFrequency = v => attribute("", "baseFrequency", v) + +let baseProfile = v => attribute("", "baseProfile", v) + +let bbox = v => attribute("", "bbox", v) + +let begin = v => attribute("", "begin", v) + +let bias = v => attribute("", "bias", v) + +let by = v => attribute("", "by", v) + +let calcMode = v => attribute("", "calcMode", v) + +let capHeight = v => attribute("", "cap-height", v) + +let class = v => attribute("", "class", v) + +let clipPathUnits = v => attribute("", "clipPathUnits", v) + +let contentScriptType = v => attribute("", "contentScriptType", v) + +let contentStyleType = v => attribute("", "contentStyleType", v) + +let cx = v => attribute("", "cx", v) + +let cy = v => attribute("", "cy", v) + +let d = v => attribute("", "d", v) + +let decelerate = v => attribute("", "decelerate", v) + +let descent = v => attribute("", "descent", v) + +let diffuseConstant = v => attribute("", "diffuseConstant", v) + +let divisor = v => attribute("", "divisor", v) + +let dur = v => attribute("", "dur", v) + +let dx = v => attribute("", "dx", v) + +let dy = v => attribute("", "dy", v) + +let edgeMode = v => attribute("", "edgeMode", v) + +let elevation = v => attribute("", "elevation", v) + +let end = v => attribute("", "end", v) + +let exponent = v => attribute("", "exponent", v) + +let externalResourcesRequired = v => attribute("", "externalResourcesRequired", v) + +let filterRes = v => attribute("", "filterRes", v) + +let filterUnits = v => attribute("", "filterUnits", v) + +let format = v => attribute("", "format", v) + +let from = v => attribute("", "from", v) + +let fx = v => attribute("", "fx", v) + +let fy = v => attribute("", "fy", v) + +let g1 = v => attribute("", "g1", v) + +let g2 = v => attribute("", "g2", v) + +let glyphName = v => attribute("", "glyph-name", v) + +let glyphRef = v => attribute("", "glyphRef", v) + +let gradientTransform = v => attribute("", "gradientTransform", v) + +let gradientUnits = v => attribute("", "gradientUnits", v) + +let hanging = v => attribute("", "hanging", v) + +let height = v => attribute("", "height", v) + +let horizAdvX = v => attribute("", "horiz-adv-x", v) + +let horizOriginX = v => attribute("", "horiz-origin-x", v) + +let horizOriginY = v => attribute("", "horiz-origin-y", v) + +let id = v => attribute("", "id", v) + +let ideographic = v => attribute("", "ideographic", v) + +let in' = v => attribute("", "in", v) + +let in2 = v => attribute("", "in2", v) + +let intercept = v => attribute("", "intercept", v) + +let k = v => attribute("", "k", v) + +let k1 = v => attribute("", "k1", v) + +let k2 = v => attribute("", "k2", v) + +let k3 = v => attribute("", "k3", v) + +let k4 = v => attribute("", "k4", v) + +let kernelMatrix = v => attribute("", "kernelMatrix", v) + +let kernelUnitLength = v => attribute("", "kernelUnitLength", v) + +let keyPoints = v => attribute("", "keyPoints", v) + +let keySplines = v => attribute("", "keySplines", v) + +let keyTimes = v => attribute("", "keyTimes", v) + +let lang = v => attribute("", "lang", v) + +let lengthAdjust = v => attribute("", "lengthAdjust", v) + +let limitingConeAngle = v => attribute("", "limitingConeAngle", v) + +let local = v => attribute("", "local", v) + +let markerHeight = v => attribute("", "markerHeight", v) + +let markerUnits = v => attribute("", "markerUnits", v) + +let markerWidth = v => attribute("", "markerWidth", v) + +let maskContentUnits = v => attribute("", "maskContentUnits", v) + +let maskUnits = v => attribute("", "maskUnits", v) + +let mathematical = v => attribute("", "mathematical", v) + +let max = v => attribute("", "max", v) + +let media = v => attribute("", "media", v) + +let method = v => attribute("", "method", v) + +let min = v => attribute("", "min", v) + +let mode = v => attribute("", "mode", v) + +let name = v => attribute("", "name", v) + +let numOctaves = v => attribute("", "numOctaves", v) + +let offset = v => attribute("", "offset", v) + +let operator = v => attribute("", "operator", v) + +let order = v => attribute("", "order", v) + +let orient = v => attribute("", "orient", v) + +let orientation = v => attribute("", "orientation", v) + +let origin = v => attribute("", "origin", v) + +let overlinePosition = v => attribute("", "overline-position", v) + +let overlineThickness = v => attribute("", "overline-thickness", v) + +let panose1 = v => attribute("", "panose-1", v) + +let path = v => attribute("", "path", v) + +let pathLength = v => attribute("", "pathLength", v) + +let patternContentUnits = v => attribute("", "patternContentUnits", v) + +let patternTransform = v => attribute("", "patternTransform", v) + +let patternUnits = v => attribute("", "patternUnits", v) + +let pointOrder = v => attribute("", "point-order", v) + +let points = v => attribute("", "points", v) + +let pointsAtX = v => attribute("", "pointsAtX", v) + +let pointsAtY = v => attribute("", "pointsAtY", v) + +let pointsAtZ = v => attribute("", "pointsAtZ", v) + +let preserveAlpha = v => attribute("", "preserveAlpha", v) + +let preserveAspectRatio = v => attribute("", "preserveAspectRatio", v) + +let primitiveUnits = v => attribute("", "primitiveUnits", v) + +let r = v => attribute("", "r", v) + +let radius = v => attribute("", "radius", v) + +let refX = v => attribute("", "refX", v) + +let refY = v => attribute("", "refY", v) + +let renderingIntent = v => attribute("", "rendering-intent", v) + +let repeatCount = v => attribute("", "repeatCount", v) + +let repeatDur = v => attribute("", "repeatDur", v) + +let requiredExtensions = v => attribute("", "requiredExtensions", v) + +let requiredFeatures = v => attribute("", "requiredFeatures", v) + +let restart = v => attribute("", "restart", v) + +let result = v => attribute("", "result", v) + +let rotate = v => attribute("", "rotate", v) + +let rx = v => attribute("", "rx", v) + +let ry = v => attribute("", "ry", v) + +let scale = v => attribute("", "scale", v) + +let seed = v => attribute("", "seed", v) + +let slope = v => attribute("", "slope", v) + +let spacing = v => attribute("", "spacing", v) + +let specularConstant = v => attribute("", "specularConstant", v) + +let specularExponent = v => attribute("", "specularExponent", v) + +let speed = v => attribute("", "speed", v) + +let spreadMethod = v => attribute("", "spreadMethod", v) + +let startOffset = v => attribute("", "startOffset", v) + +let stdDeviation = v => attribute("", "stdDeviation", v) + +let stemh = v => attribute("", "stemh", v) + +let stemv = v => attribute("", "stemv", v) + +let stitchTiles = v => attribute("", "stitchTiles", v) + +let strikethroughPosition = v => attribute("", "strikethrough-position", v) + +let strikethroughThickness = v => attribute("", "strikethrough-thickness", v) + +let string = v => attribute("", "string", v) + +let style = v => attribute("", "style", v) + +let surfaceScale = v => attribute("", "surfaceScale", v) + +let systemLanguage = v => attribute("", "systemLanguage", v) + +let tableValues = v => attribute("", "tableValues", v) + +let target = v => attribute("", "target", v) + +let targetX = v => attribute("", "targetX", v) + +let targetY = v => attribute("", "targetY", v) + +let textLength = v => attribute("", "textLength", v) + +let title = v => attribute("", "title", v) + +let to = v => attribute("", "to", v) + +let transform = v => attribute("", "transform", v) + +let type' = v => attribute("", "type", v) + +let u1 = v => attribute("", "u1", v) + +let u2 = v => attribute("", "u2", v) + +let underlinePosition = v => attribute("", "underline-position", v) + +let underlineThickness = v => attribute("", "underline-thickness", v) + +let unicode = v => attribute("", "unicode", v) + +let unicodeRange = v => attribute("", "unicode-range", v) + +let unitsPerEm = v => attribute("", "units-per-em", v) + +let vAlphabetic = v => attribute("", "v-alphabetic", v) + +let vHanging = v => attribute("", "v-hanging", v) + +let vIdeographic = v => attribute("", "v-ideographic", v) + +let vMathematical = v => attribute("", "v-mathematical", v) + +let values = v => attribute("", "values", v) + +let version = v => attribute("", "version", v) + +let vertAdvY = v => attribute("", "vert-adv-y", v) + +let vertOriginX = v => attribute("", "vert-origin-x", v) + +let vertOriginY = v => attribute("", "vert-origin-y", v) + +let viewBox = v => attribute("", "viewBox", v) + +let viewTarget = v => attribute("", "viewTarget", v) + +let width = v => attribute("", "width", v) + +let widths = v => attribute("", "widths", v) + +let x = v => attribute("", "x", v) + +let xHeight = v => attribute("", "x-height", v) + +let x1 = v => attribute("", "x1", v) + +let x2 = v => attribute("", "x2", v) + +let xChannelSelector = v => attribute("", "xChannelSelector", v) + +let xlinkActuate = v => attribute("http://www.w3.org/1999/xlink", "xlink:actuate", v) + +let xlinkArcrole = v => attribute("http://www.w3.org/1999/xlink", "xlink:arcrole", v) + +let xlinkHref = v => attribute("http://www.w3.org/1999/xlink", "xlink:href", v) + +let xlinkRole = v => attribute("http://www.w3.org/1999/xlink", "xlink:role", v) + +let xlinkShow = v => attribute("http://www.w3.org/1999/xlink", "xlink:show", v) + +let xlinkTitle = v => attribute("http://www.w3.org/1999/xlink", "xlink:title", v) + +let xlinkType = v => attribute("http://www.w3.org/1999/xlink", "xlink:type", v) + +let xmlBase = v => attribute("http://www.w3.org/XML/1998/namespace", "xml:base", v) + +let xmlLang = v => attribute("http://www.w3.org/XML/1998/namespace", "xml:lang", v) + +let xmlSpace = v => attribute("http://www.w3.org/XML/1998/namespace", "xml:space", v) + +let y = v => attribute("", "y", v) + +let y1 = v => attribute("", "y1", v) + +let y2 = v => attribute("", "y2", v) + +let yChannelSelector = v => attribute("", "yChannelSelector", v) + +let z = v => attribute("", "z", v) + +let zoomAndPan = v => attribute("", "zoomAndPan", v) + +/* Presentation attributes */ + +let alignmentBaseline = v => attribute("", "alignment-baseline", v) + +let baselineShift = v => attribute("", "baseline-shift", v) + +let clipPath = v => attribute("", "clip-path", v) + +let clipRule = v => attribute("", "clip-rule", v) + +let clip = v => attribute("", "clip", v) + +let colorInterpolationFilters = v => attribute("", "color-interpolation-filters", v) + +let colorInterpolation = v => attribute("", "color-interpolation", v) + +let colorProfile = v => attribute("", "color-profile", v) + +let colorRendering = v => attribute("", "color-rendering", v) + +let color = v => attribute("", "color", v) + +let cursor = v => attribute("", "cursor", v) + +let direction = v => attribute("", "direction", v) + +let display = v => attribute("", "display", v) + +let dominantBaseline = v => attribute("", "dominant-baseline", v) + +let enableBackground = v => attribute("", "enable-background", v) + +let fillOpacity = v => attribute("", "fill-opacity", v) + +let fillRule = v => attribute("", "fill-rule", v) + +let fill = v => attribute("", "fill", v) + +let filter = v => attribute("", "filter", v) + +let floodColor = v => attribute("", "flood-color", v) + +let floodOpacity = v => attribute("", "flood-opacity", v) + +let fontFamily = v => attribute("", "font-family", v) + +let fontSizeAdjust = v => attribute("", "font-size-adjust", v) + +let fontSize = v => attribute("", "font-size", v) + +let fontStretch = v => attribute("", "font-stretch", v) + +let fontStyle = v => attribute("", "font-style", v) + +let fontVariant = v => attribute("", "font-variant", v) + +let fontWeight = v => attribute("", "font-weight", v) + +let glyphOrientationHorizontal = v => attribute("", "glyph-orientation-horizontal", v) + +let glyphOrientationVertical = v => attribute("", "glyph-orientation-vertical", v) + +let imageRendering = v => attribute("", "image-rendering", v) + +let kerning = v => attribute("", "kerning", v) + +let letterSpacing = v => attribute("", "letter-spacing", v) + +let lightingColor = v => attribute("", "lighting-color", v) + +let markerEnd = v => attribute("", "marker-end", v) + +let markerMid = v => attribute("", "marker-mid", v) + +let markerStart = v => attribute("", "marker-start", v) + +let mask = v => attribute("", "mask", v) + +let opacity = v => attribute("", "opacity", v) + +let overflow = v => attribute("", "overflow", v) + +let pointerEvents = v => attribute("", "pointer-events", v) + +let shapeRendering = v => attribute("", "shape-rendering", v) + +let stopColor = v => attribute("", "stop-color", v) + +let stopOpacity = v => attribute("", "stop-opacity", v) + +let strokeDasharray = v => attribute("", "stroke-dasharray", v) + +let strokeDashoffset = v => attribute("", "stroke-dashoffset", v) + +let strokeLinecap = v => attribute("", "stroke-linecap", v) + +let strokeLinejoin = v => attribute("", "stroke-linejoin", v) + +let strokeMiterlimit = v => attribute("", "stroke-miterlimit", v) + +let strokeOpacity = v => attribute("", "stroke-opacity", v) + +let strokeWidth = v => attribute("", "stroke-width", v) + +let stroke = v => attribute("", "stroke", v) + +let textAnchor = v => attribute("", "text-anchor", v) + +let textDecoration = v => attribute("", "text-decoration", v) + +let textRendering = v => attribute("", "text-rendering", v) + +let unicodeBidi = v => attribute("", "unicode-bidi", v) + +let visibility = v => attribute("", "visibility", v) + +let wordSpacing = v => attribute("", "word-spacing", v) + +let writingMode = v => attribute("", "writing-mode", v) diff --git a/src/tea_svg_attributes.resi b/src/tea_svg_attributes.resi new file mode 100644 index 0000000..1385470 --- /dev/null +++ b/src/tea_svg_attributes.resi @@ -0,0 +1,505 @@ +let accentHeight: string => Vdom.property<'msg> + +let accelerate: string => Vdom.property<'msg> + +let accumulate: string => Vdom.property<'msg> + +let additive: string => Vdom.property<'msg> + +let alphabetic: string => Vdom.property<'msg> + +let allowReorder: string => Vdom.property<'msg> + +let amplitude: string => Vdom.property<'msg> + +let arabicForm: string => Vdom.property<'msg> + +let ascent: string => Vdom.property<'msg> + +let attributeName: string => Vdom.property<'msg> + +let attributeType: string => Vdom.property<'msg> + +let autoReverse: string => Vdom.property<'msg> + +let azimuth: string => Vdom.property<'msg> + +let baseFrequency: string => Vdom.property<'msg> + +let baseProfile: string => Vdom.property<'msg> + +let bbox: string => Vdom.property<'msg> + +let begin: string => Vdom.property<'msg> + +let bias: string => Vdom.property<'msg> + +let by: string => Vdom.property<'msg> + +let calcMode: string => Vdom.property<'msg> + +let capHeight: string => Vdom.property<'msg> + +let class: string => Vdom.property<'msg> + +let clipPathUnits: string => Vdom.property<'msg> + +let contentScriptType: string => Vdom.property<'msg> + +let contentStyleType: string => Vdom.property<'msg> + +let cx: string => Vdom.property<'msg> + +let cy: string => Vdom.property<'msg> + +let d: string => Vdom.property<'msg> + +let decelerate: string => Vdom.property<'msg> + +let descent: string => Vdom.property<'msg> + +let diffuseConstant: string => Vdom.property<'msg> + +let divisor: string => Vdom.property<'msg> + +let dur: string => Vdom.property<'msg> + +let dx: string => Vdom.property<'msg> + +let dy: string => Vdom.property<'msg> + +let edgeMode: string => Vdom.property<'msg> + +let elevation: string => Vdom.property<'msg> + +let end: string => Vdom.property<'msg> + +let exponent: string => Vdom.property<'msg> + +let externalResourcesRequired: string => Vdom.property<'msg> + +let filterRes: string => Vdom.property<'msg> + +let filterUnits: string => Vdom.property<'msg> + +let format: string => Vdom.property<'msg> + +let from: string => Vdom.property<'msg> + +let fx: string => Vdom.property<'msg> + +let fy: string => Vdom.property<'msg> + +let g1: string => Vdom.property<'msg> + +let g2: string => Vdom.property<'msg> + +let glyphName: string => Vdom.property<'msg> + +let glyphRef: string => Vdom.property<'msg> + +let gradientTransform: string => Vdom.property<'msg> + +let gradientUnits: string => Vdom.property<'msg> + +let hanging: string => Vdom.property<'msg> + +let height: string => Vdom.property<'msg> + +let horizAdvX: string => Vdom.property<'msg> + +let horizOriginX: string => Vdom.property<'msg> + +let horizOriginY: string => Vdom.property<'msg> + +let id: string => Vdom.property<'msg> + +let ideographic: string => Vdom.property<'msg> + +let in': string => Vdom.property<'msg> + +let in2: string => Vdom.property<'msg> + +let intercept: string => Vdom.property<'msg> + +let k: string => Vdom.property<'msg> + +let k1: string => Vdom.property<'msg> + +let k2: string => Vdom.property<'msg> + +let k3: string => Vdom.property<'msg> + +let k4: string => Vdom.property<'msg> + +let kernelMatrix: string => Vdom.property<'msg> + +let kernelUnitLength: string => Vdom.property<'msg> + +let keyPoints: string => Vdom.property<'msg> + +let keySplines: string => Vdom.property<'msg> + +let keyTimes: string => Vdom.property<'msg> + +let lang: string => Vdom.property<'msg> + +let lengthAdjust: string => Vdom.property<'msg> + +let limitingConeAngle: string => Vdom.property<'msg> + +let local: string => Vdom.property<'msg> + +let markerHeight: string => Vdom.property<'msg> + +let markerUnits: string => Vdom.property<'msg> + +let markerWidth: string => Vdom.property<'msg> + +let maskContentUnits: string => Vdom.property<'msg> + +let maskUnits: string => Vdom.property<'msg> + +let mathematical: string => Vdom.property<'msg> + +let max: string => Vdom.property<'msg> + +let media: string => Vdom.property<'msg> + +let method: string => Vdom.property<'msg> + +let min: string => Vdom.property<'msg> + +let mode: string => Vdom.property<'msg> + +let name: string => Vdom.property<'msg> + +let numOctaves: string => Vdom.property<'msg> + +let offset: string => Vdom.property<'msg> + +let operator: string => Vdom.property<'msg> + +let order: string => Vdom.property<'msg> + +let orient: string => Vdom.property<'msg> + +let orientation: string => Vdom.property<'msg> + +let origin: string => Vdom.property<'msg> + +let overlinePosition: string => Vdom.property<'msg> + +let overlineThickness: string => Vdom.property<'msg> + +let panose1: string => Vdom.property<'msg> + +let path: string => Vdom.property<'msg> + +let pathLength: string => Vdom.property<'msg> + +let patternContentUnits: string => Vdom.property<'msg> + +let patternTransform: string => Vdom.property<'msg> + +let patternUnits: string => Vdom.property<'msg> + +let pointOrder: string => Vdom.property<'msg> + +let points: string => Vdom.property<'msg> + +let pointsAtX: string => Vdom.property<'msg> + +let pointsAtY: string => Vdom.property<'msg> + +let pointsAtZ: string => Vdom.property<'msg> + +let preserveAlpha: string => Vdom.property<'msg> + +let preserveAspectRatio: string => Vdom.property<'msg> + +let primitiveUnits: string => Vdom.property<'msg> + +let r: string => Vdom.property<'msg> + +let radius: string => Vdom.property<'msg> + +let refX: string => Vdom.property<'msg> + +let refY: string => Vdom.property<'msg> + +let renderingIntent: string => Vdom.property<'msg> + +let repeatCount: string => Vdom.property<'msg> + +let repeatDur: string => Vdom.property<'msg> + +let requiredExtensions: string => Vdom.property<'msg> + +let requiredFeatures: string => Vdom.property<'msg> + +let restart: string => Vdom.property<'msg> + +let result: string => Vdom.property<'msg> + +let rotate: string => Vdom.property<'msg> + +let rx: string => Vdom.property<'msg> + +let ry: string => Vdom.property<'msg> + +let scale: string => Vdom.property<'msg> + +let seed: string => Vdom.property<'msg> + +let slope: string => Vdom.property<'msg> + +let spacing: string => Vdom.property<'msg> + +let specularConstant: string => Vdom.property<'msg> + +let specularExponent: string => Vdom.property<'msg> + +let speed: string => Vdom.property<'msg> + +let spreadMethod: string => Vdom.property<'msg> + +let startOffset: string => Vdom.property<'msg> + +let stdDeviation: string => Vdom.property<'msg> + +let stemh: string => Vdom.property<'msg> + +let stemv: string => Vdom.property<'msg> + +let stitchTiles: string => Vdom.property<'msg> + +let strikethroughPosition: string => Vdom.property<'msg> + +let strikethroughThickness: string => Vdom.property<'msg> + +let string: string => Vdom.property<'msg> + +let style: string => Vdom.property<'msg> + +let surfaceScale: string => Vdom.property<'msg> + +let systemLanguage: string => Vdom.property<'msg> + +let tableValues: string => Vdom.property<'msg> + +let target: string => Vdom.property<'msg> + +let targetX: string => Vdom.property<'msg> + +let targetY: string => Vdom.property<'msg> + +let textLength: string => Vdom.property<'msg> + +let title: string => Vdom.property<'msg> + +let to: string => Vdom.property<'msg> + +let transform: string => Vdom.property<'msg> + +let type': string => Vdom.property<'msg> + +let u1: string => Vdom.property<'msg> + +let u2: string => Vdom.property<'msg> + +let underlinePosition: string => Vdom.property<'msg> + +let underlineThickness: string => Vdom.property<'msg> + +let unicode: string => Vdom.property<'msg> + +let unicodeRange: string => Vdom.property<'msg> + +let unitsPerEm: string => Vdom.property<'msg> + +let vAlphabetic: string => Vdom.property<'msg> + +let vHanging: string => Vdom.property<'msg> + +let vIdeographic: string => Vdom.property<'msg> + +let vMathematical: string => Vdom.property<'msg> + +let values: string => Vdom.property<'msg> + +let version: string => Vdom.property<'msg> + +let vertAdvY: string => Vdom.property<'msg> + +let vertOriginX: string => Vdom.property<'msg> + +let vertOriginY: string => Vdom.property<'msg> + +let viewBox: string => Vdom.property<'msg> + +let viewTarget: string => Vdom.property<'msg> + +let width: string => Vdom.property<'msg> + +let widths: string => Vdom.property<'msg> + +let x: string => Vdom.property<'msg> + +let xHeight: string => Vdom.property<'msg> + +let x1: string => Vdom.property<'msg> + +let x2: string => Vdom.property<'msg> + +let xChannelSelector: string => Vdom.property<'msg> + +let xlinkActuate: string => Vdom.property<'msg> + +let xlinkArcrole: string => Vdom.property<'msg> + +let xlinkHref: string => Vdom.property<'msg> + +let xlinkRole: string => Vdom.property<'msg> + +let xlinkShow: string => Vdom.property<'msg> + +let xlinkTitle: string => Vdom.property<'msg> + +let xlinkType: string => Vdom.property<'msg> + +let xmlBase: string => Vdom.property<'msg> + +let xmlLang: string => Vdom.property<'msg> + +let xmlSpace: string => Vdom.property<'msg> + +let y: string => Vdom.property<'msg> + +let y1: string => Vdom.property<'msg> + +let y2: string => Vdom.property<'msg> + +let yChannelSelector: string => Vdom.property<'msg> + +let z: string => Vdom.property<'msg> + +let zoomAndPan: string => Vdom.property<'msg> + +let alignmentBaseline: string => Vdom.property<'msg> + +let baselineShift: string => Vdom.property<'msg> + +let clipPath: string => Vdom.property<'msg> + +let clipRule: string => Vdom.property<'msg> + +let clip: string => Vdom.property<'msg> + +let colorInterpolationFilters: string => Vdom.property<'msg> + +let colorInterpolation: string => Vdom.property<'msg> + +let colorProfile: string => Vdom.property<'msg> + +let colorRendering: string => Vdom.property<'msg> + +let color: string => Vdom.property<'msg> + +let cursor: string => Vdom.property<'msg> + +let direction: string => Vdom.property<'msg> + +let display: string => Vdom.property<'msg> + +let dominantBaseline: string => Vdom.property<'msg> + +let enableBackground: string => Vdom.property<'msg> + +let fillOpacity: string => Vdom.property<'msg> + +let fillRule: string => Vdom.property<'msg> + +let fill: string => Vdom.property<'msg> + +let filter: string => Vdom.property<'msg> + +let floodColor: string => Vdom.property<'msg> + +let floodOpacity: string => Vdom.property<'msg> + +let fontFamily: string => Vdom.property<'msg> + +let fontSizeAdjust: string => Vdom.property<'msg> + +let fontSize: string => Vdom.property<'msg> + +let fontStretch: string => Vdom.property<'msg> + +let fontStyle: string => Vdom.property<'msg> + +let fontVariant: string => Vdom.property<'msg> + +let fontWeight: string => Vdom.property<'msg> + +let glyphOrientationHorizontal: string => Vdom.property<'msg> + +let glyphOrientationVertical: string => Vdom.property<'msg> + +let imageRendering: string => Vdom.property<'msg> + +let kerning: string => Vdom.property<'msg> + +let letterSpacing: string => Vdom.property<'msg> + +let lightingColor: string => Vdom.property<'msg> + +let markerEnd: string => Vdom.property<'msg> + +let markerMid: string => Vdom.property<'msg> + +let markerStart: string => Vdom.property<'msg> + +let mask: string => Vdom.property<'msg> + +let opacity: string => Vdom.property<'msg> + +let overflow: string => Vdom.property<'msg> + +let pointerEvents: string => Vdom.property<'msg> + +let shapeRendering: string => Vdom.property<'msg> + +let stopColor: string => Vdom.property<'msg> + +let stopOpacity: string => Vdom.property<'msg> + +let strokeDasharray: string => Vdom.property<'msg> + +let strokeDashoffset: string => Vdom.property<'msg> + +let strokeLinecap: string => Vdom.property<'msg> + +let strokeLinejoin: string => Vdom.property<'msg> + +let strokeMiterlimit: string => Vdom.property<'msg> + +let strokeOpacity: string => Vdom.property<'msg> + +let strokeWidth: string => Vdom.property<'msg> + +let stroke: string => Vdom.property<'msg> + +let textAnchor: string => Vdom.property<'msg> + +let textDecoration: string => Vdom.property<'msg> + +let textRendering: string => Vdom.property<'msg> + +let unicodeBidi: string => Vdom.property<'msg> + +let visibility: string => Vdom.property<'msg> + +let wordSpacing: string => Vdom.property<'msg> + +let writingMode: string => Vdom.property<'msg> diff --git a/src-reason/tea_svg_events.re b/src/tea_svg_events.res similarity index 100% rename from src-reason/tea_svg_events.re rename to src/tea_svg_events.res diff --git a/src/tea_task.res b/src/tea_task.res new file mode 100644 index 0000000..91d50b8 --- /dev/null +++ b/src/tea_task.res @@ -0,0 +1,206 @@ +type never + +type rec t<'succeed, 'fail> = + | Task((result<'succeed, 'fail> => unit) => unit): t<'succeed, 'fail> + +let nothing = () => () + +let performOpt = ( + toOptionalMessage: 'value => option<'msg>, + Task(task): t<'value, never>, +): Tea_cmd.t<'msg> => + Tea_cmd.call(callbacks => { + open Vdom + let cb = x => + switch x { + | Error(_e) => + failwith( + @reason.raw_literal("ERROR: Task perfom returned error of never! Should not happen!") + "ERROR: Task perfom returned error of never! Should not happen!", + ) + | Ok(v) => + switch toOptionalMessage(v) { + | None => () + | Some(result) => callbacks.contents.enqueue(result) + } + } + task(cb) + }) + +let perform = (toMessage: 'value => 'msg, task: t<'value, never>): Tea_cmd.t<'msg> => + performOpt(v => Some(toMessage(v)), task) + +let attemptOpt = ( + resultToOptionalMessage: Belt.Result.t<'succeed, 'fail> => option<'msg>, + Task(task): t<'succeed, 'fail>, +): Tea_cmd.t<'msg> => + Tea_cmd.call(callbacks => { + open Vdom + let cb = value => + switch resultToOptionalMessage(value) { + | None => () + | Some(result) => callbacks.contents.enqueue(result) + } + task(cb) + }) + +let attempt = ( + resultToMessage: result<'succeed, 'fail> => 'msg, + task: t<'succeed, 'fail>, +): Tea_cmd.t<'msg> => attemptOpt(v => Some(resultToMessage(v)), task) + +let ignore = task => attemptOpt(_ => None, task) + +let succeed = (value: 'v): t<'v, 'e> => Task(cb => cb(Belt.Result.Ok(value))) + +let fail = (value: 'v): t<'e, 'v> => Task(cb => cb(Belt.Result.Error(value))) + +let nativeBinding = (func: (Belt.Result.t<'succeed, 'fail> => unit) => unit): t< + 'succeed, + 'fail, +> => Task(func) + +let andThen = (fn, Task(task)) => { + Task( + cb => + task(x => + switch x { + | Error(_e) as err => cb(err) + | Ok(v) => + let Task(nextTask) = fn(v) + nextTask(cb) + } + ), + ) +} + +let onError = (fn, Task(task)) => { + Task( + cb => + task(x => + switch x { + | Ok(_v) as ok => cb(ok) + | Error(e) => + let Task(newTask) = fn(e) + newTask(cb) + } + ), + ) +} + +let fromResult: result<'success, 'failure> => t<'success, 'failure> = x => + switch x { + | Belt.Result.Ok(s) => succeed(s) + | Belt.Result.Error(err) => fail(err) + } + +let mapError = (func, task) => task |> onError(e => fail(func(e))) + +let toOption = task => task |> andThen(v => succeed(Some(v))) |> onError(_ => succeed(None)) + +let map = (func, task1) => task1 |> andThen(v1 => succeed(func(v1))) + +let map2 = (func, task1, task2) => + task1 |> andThen(v1 => task2 |> andThen(v2 => succeed(func(v1, v2)))) + +let map3 = (func, task1, task2, task3) => + task1 |> andThen(v1 => task2 |> andThen(v2 => task3 |> andThen(v3 => succeed(func(v1, v2, v3))))) + +let map4 = (func, task1, task2, task3, task4) => + task1 |> andThen(v1 => + task2 |> andThen(v2 => + task3 |> andThen(v3 => task4 |> andThen(v4 => succeed(func(v1, v2, v3, v4)))) + ) + ) + +let map5 = (func, task1, task2, task3, task4, task5) => + task1 |> andThen(v1 => + task2 |> andThen(v2 => + task3 |> andThen(v3 => + task4 |> andThen(v4 => task5 |> andThen(v5 => succeed(func(v1, v2, v3, v4, v5)))) + ) + ) + ) + +let map6 = (func, task1, task2, task3, task4, task5, task6) => + task1 |> andThen(v1 => + task2 |> andThen(v2 => + task3 |> andThen(v3 => + task4 |> andThen(v4 => + task5 |> andThen(v5 => task6 |> andThen(v6 => succeed(func(v1, v2, v3, v4, v5, v6)))) + ) + ) + ) + ) + +let rec sequence = x => + switch x { + | list{} => succeed(list{}) + | list{task, ...remainingTasks} => map2((l, r) => list{l, ...r}, task, sequence(remainingTasks)) + } + +let testingDeop = ref(true) + +let testing = () => { + let doTest = (expected, Task(task)) => { + let testAssert = v => + if v == expected { + Js.log((@reason.raw_literal("Passed:") "Passed:", expected, v)) + } else { + Js.log((@reason.raw_literal("FAILED:") "FAILED:", expected, v)) + } + task(testAssert) + } + let s = succeed(42) + let () = doTest(Ok(42), s) + let f = fail(86) + let () = doTest(Error(86), f) + let r = () => + if testingDeop.contents { + succeed(42) + } else { + fail(3.14) + } + let a1 = succeed(2) |> andThen(n => succeed(n + 2)) + let () = doTest(Ok(4), a1) + let a2 = succeed(2) |> andThen(n => succeed(string_of_int(n))) + let () = doTest(Ok(@reason.raw_literal("2") "2"), a2) + let m1 = map(sqrt, succeed(9.)) + let () = doTest(Ok(3.), m1) + let m2 = map2(\"+", succeed(9), succeed(3)) + let () = doTest(Ok(12), m2) + let m3 = map(string_of_int, succeed(9)) + let () = doTest(Ok(@reason.raw_literal("9") "9"), m3) + let s0 = sequence(list{succeed(1), succeed(2)}) + let () = doTest(Ok(list{1, 2}), s0) + let s1 = sequence(list{succeed(1), fail(2.7), r()}) + let () = doTest(Error(2.7), s1) + let e0 = + fail(@reason.raw_literal("file not found") "file not found") |> onError(_msg => succeed(42)) + let () = doTest(Ok(42), e0) + let e1 = fail(@reason.raw_literal("file not found") "file not found") |> onError(_msg => fail(42)) + let () = doTest(Error(42), e1) + let n0 = sequence(list{ + mapError(string_of_int, fail(42)), + mapError(Js.Float.toString, fail(3.14)), + }) + let () = doTest(Error(@reason.raw_literal("42") "42"), n0) + let n1 = sequence(list{ + mapError(string_of_int, succeed(1)), + mapError(Js.Float.toString, fail(3.14)), + }) + let () = doTest(Error(@reason.raw_literal("3.14") "3.14"), n1) + let n2 = sequence(list{ + mapError(string_of_int, succeed(1)), + mapError(Js.Float.toString, succeed(2)), + }) + let () = doTest(Ok(list{1, 2}), n2) + + let _c0 = perform(_ => 42, succeed(18)) + + let () = doTest(Ok(42), fromResult(Ok(42))) + let () = doTest(Error("failure"), fromResult(Error("failure"))) + + let () = doTest(Ok(None), fail("for some reason") |> toOption) + let () = doTest(Ok(Some(42)), succeed(42) |> toOption) +} diff --git a/src/tea_task.resi b/src/tea_task.resi new file mode 100644 index 0000000..1db052b --- /dev/null +++ b/src/tea_task.resi @@ -0,0 +1,58 @@ +type never + +type rec t<'succeed, 'fail> = Task((result<'succeed, 'fail> => unit) => unit): t<'succeed, 'fail> + +let nothing: unit => unit + +let performOpt: ('value => option<'msg>, t<'value, never>) => Tea_cmd.t<'msg> + +let perform: ('value => 'msg, t<'value, never>) => Tea_cmd.t<'msg> + +let attemptOpt: (Belt.Result.t<'succeed, 'fail> => option<'msg>, t<'succeed, 'fail>) => Tea_cmd.t< + 'msg,> + +let attempt: (result<'succeed, 'fail> => 'msg, t<'succeed, 'fail>) => Tea_cmd.t<'msg> + +let ignore: t<'msg, 'b> => Tea_cmd.t<'c> + +let succeed: 'v => t<'v, 'e> + +let fail: 'v => t<'e, 'v> + +let nativeBinding: ((Belt.Result.t<'succeed, 'fail> => unit) => unit) => t<'succeed, 'fail> + +let andThen: ('msg => t<'b, 'c>, t<'msg, 'c>) => t<'b, 'c> + +let onError: ('msg => t<'b, 'c>, t<'b, 'msg>) => t<'b, 'c> + +let fromResult: result<'success, 'failure> => t<'success, 'failure> + +let mapError: ('msg => 'b, t<'c, 'msg>) => t<'c, 'b> + +let toOption: t<'msg, 'b> => t, 'c> + +let map: ('msg => 'b, t<'msg, 'c>) => t<'b, 'c> + +let map2: (('msg, 'b) => 'c, t<'msg, 'd>, t<'b, 'd>) => t<'c, 'd> + +let map3: (('msg, 'b, 'c) => 'd, t<'msg, 'e>, t<'b, 'e>, t<'c, 'e>) => t<'d, 'e> + +let map4: (('msg, 'b, 'c, 'd) => 'e, t<'msg, 'f>, t<'b, 'f>, t<'c, 'f>, t<'d, 'f>) => t<'e, 'f> + +let map5: (('msg, 'b, 'c, 'd, 'e) => 'f, t<'msg, 'g>, t<'b, 'g>, t<'c, 'g>, t<'d, 'g>, t<'e, 'g>) => t<'f,'g,> + +let map6: ( + ('msg, 'b, 'c, 'd, 'e, 'f) => 'g, + t<'msg, 'h>, + t<'b, 'h>, + t<'c, 'h>, + t<'d, 'h>, + t<'e, 'h>, + t<'f, 'h>, +) => t<'g, 'h> + +let sequence: list> => t, 'b> + +let testingDeop: ref + +let testing: unit => unit diff --git a/src/tea_time.res b/src/tea_time.res new file mode 100644 index 0000000..c9aba61 --- /dev/null +++ b/src/tea_time.res @@ -0,0 +1,47 @@ +type t = float + +/* type 'msg mySub = + | Every of t * (t -> 'msg) + + +type 'msg myCmd = + | Delay of t * (unit -> 'msg) */ + + +let every = (~key, interval, tagger) => { + open Vdom + let enableCall = callbacks => { + let id = Js.Global.setIntervalFloat(() => callbacks.enqueue(tagger(Js.Date.now())), interval) + /* let () = Js.log ("Time.every", "enable", interval, tagger, callbacks) in */ + () => + /* let () = Js.log ("Time.every", "disable", id, interval, tagger, callbacks) in */ + Js.Global.clearInterval(id) + } + Tea_sub.registration(key, enableCall) +} + +let delay = (msTime, msg) => + Tea_cmd.call(callbacks => { + let _unhandledID = Js.Global.setTimeoutFloat(() => { + open Vdom + callbacks.contents.enqueue(msg) + }, msTime) + }) + +/* Generic Helpers */ + +let millisecond = 1.0 + +let second = 1000.0 *. millisecond + +let minute = 60.0 *. second + +let hour = 60.0 *. minute + +let inMilliseconds = t => t + +let inSeconds = t => t /. second + +let inMinutes = t => t /. minute + +let inHours = t => t /. hour diff --git a/src/tea_time.resi b/src/tea_time.resi new file mode 100644 index 0000000..2f36225 --- /dev/null +++ b/src/tea_time.resi @@ -0,0 +1,21 @@ +type t = float + +let every: (~key: string, float, float => 'msg) => Tea_sub.t<'msg> + +let delay: (float, 'msg) => Tea_cmd.t<'msg> + +let millisecond: float + +let second: float + +let minute: float + +let hour: float + +let inMilliseconds: 'msg => 'msg + +let inSeconds: float => float + +let inMinutes: float => float + +let inHours: float => float diff --git a/src/vdom.res b/src/vdom.res new file mode 100644 index 0000000..9fc4ece --- /dev/null +++ b/src/vdom.res @@ -0,0 +1,688 @@ +type systemMessage<'msg> = + | Render + | AddRenderMsg('msg) + | RemoveRenderMsg('msg) +type applicationCallbacks<'msg> = { + enqueue: 'msg => unit, + on: systemMessage<'msg> => unit, +} +type eventHandler<'msg> = + // The first argument is a key which is used to compare handlers, since functions can not be compared + | EventHandlerCallback(string, Web.Node.event => option<'msg>) + // No key because the msg can be compared + | EventHandlerMsg('msg) +type eventCache<'msg> = { + handler: Web.Node.event_cb, + cb: ref option<'msg>>, +} +type property<'msg> = + | NoProp + | RawProp(string, string) + | Attribute(string, string, string) + | Data(string, string) + | Event(string, eventHandler<'msg>, ref>>) + | Style(list<(string, string)>) +type properties<'msg> = list> +type rec t<'msg> = + | CommentNode(string) + | Text(string) + | Node(string, string, string, string, properties<'msg>, list>) + + | LazyGen(string, unit => t<'msg>, ref>) + | Tagger(ref> => ref>, t<'msg>) +let noNode: t<'msg> = (CommentNode(""): t<'msg>) +let comment = (s: string): t<'msg> => CommentNode(s) +let text = (s: string): t<'msg> => Text(s) +let fullnode = ( + namespace: string, + tagName: string, + key: string, + unique: string, + props: properties<'msg>, + vdoms: list>, +): t<'msg> => Node(namespace, tagName, key, unique, props, vdoms) +let node = ( + ~namespace: string="", + tagName: string, + ~key: string="", + ~unique: string="", + props: properties<'msg>, + vdoms: list>, +): t<'msg> => fullnode(namespace, tagName, key, unique, props, vdoms) +let lazyGen = (key: string, fn: unit => t<'msg>): t<'msg> => +LazyGen(key, fn, ref(noNode)) +let noProp: property<'msg> = (NoProp: property<'msg>) +let prop = (key: string, value: string): property<'msg> => RawProp(key, value) +let onCB = (name: string, key: string, cb: Web.Node.event => option<'msg>): property< + 'msg, +> => Event(name, EventHandlerCallback(key, cb), ref(None)) +let onMsg = ( name: string, msg: 'msg): property<'msg> => +Event(name, EventHandlerMsg(msg), ref(None)) +let attribute = (namespace: string, key: string, value: string): property<'msg> => +Attribute(namespace, key, value) +let data = (key: string, value: string): property<'msg> => Data(key, value) +let style = (key: string, value: string): property<'msg> => Style(list{(key, value)}) +let styles = (s): property<'msg> => Style(s) +let rec renderToHtmlString: t<'msg> => string = ( + x => + switch x { + | CommentNode(s) => "") + | Text(s) => s + | Node(namespace, tagName, _key, _unique, props, vdoms) => + let renderProp = x => + switch x { + | NoProp => "" + | RawProp(k, v) => String.concat("", list{" ", k, "=\"", v, "\""}) + | Attribute(_namespace, k, v) => + String.concat("", list{" ", k, "=\"", v, "\""}) + | Data(k, v) => String.concat("", list{" data-", k, "=\"", v, "\""}) + | Event(_, _, _) => "" + | Style(s) => + String.concat( + "", + list{ + " style=\"", + String.concat(";", List.map(((k, v)) => String.concat("", list{k, ":", v, ";"}), s)), + "\"", + }, + ) + } + String.concat( + "", + list{ + "<", + namespace, + if namespace == "" { + "" + } else { + ":" + }, + tagName, + String.concat("", List.map(p => renderProp(p), props)), + ">", + String.concat("", List.map(v => renderToHtmlString(v), vdoms)), + "", + }, + ) + | LazyGen(_key, gen, _cache) => + let vdom = gen() + renderToHtmlString(vdom) + | Tagger(_tagger, vdom) => renderToHtmlString(vdom) + }: t<'msg> => string +) +let emptyEventHandler: Web.Node.event_cb = (. _ev) => () +let emptyEventCB = (_ev): option => None +let eventHandler = ( + callbacks: ref>, + cb: ref option<'msg>>, +): Web.Node.event_cb => + (. ev) => + switch cb.contents(ev) { + | None => () + | Some(msg) => callbacks.contents.enqueue(msg) + } +let eventHandlerGetCB: (eventHandler<'msg>, Web.Node.event) => option<'msg> = ( + x => + switch x { + | EventHandlerCallback(_, cb) => cb + | EventHandlerMsg(msg) => _ev => Some(msg) + }: (eventHandler<'msg>, Web.Node.event) => option<'msg> +) +let compareEventHandlerTypes = (left: eventHandler<'msg>): (eventHandler<'msg> => bool) => + x => + switch x { + | EventHandlerCallback(key, _) => + switch left { + | EventHandlerCallback(lkey, _) if key == lkey => true + | _ => false + } + | EventHandlerMsg(msg) => + switch left { + | EventHandlerMsg(lmsg) if msg == lmsg => true + | _ => false + } + } +let eventHandlerRegister = ( + callbacks: ref>, + elem: Web.Node.t, + name: string, + handlerType: eventHandler<'msg>, +): option> => { + let cb = ref(eventHandlerGetCB(handlerType)) + let handler = eventHandler(callbacks, cb) + let () = Web.Node.addEventListener(elem, name, handler, false) + Some({handler: handler, cb: cb}) +} +let eventHandlerUnregister = (elem: Web.Node.t, name: string): ( + option> => option> +) => + x => + switch x { + | None => None + | Some(cache) => + let () = Web.Node.removeEventListener(elem, name, cache.handler, false) + None + } +let eventHandlerMutate = ( + callbacks: ref>, + elem: Web.Node.t, + oldName: string, + newName: string, + oldHandlerType: eventHandler<'msg>, + newHandlerType: eventHandler<'msg>, + oldCache: ref>>, + newCache: ref>>, +): unit => + switch oldCache.contents { + | None => newCache := eventHandlerRegister(callbacks, elem, newName, newHandlerType) + | Some(oldcache) => + if oldName == newName { + let () = newCache := oldCache.contents + if compareEventHandlerTypes(oldHandlerType, newHandlerType) { + () + } else { + let cb = eventHandlerGetCB(newHandlerType) + let () = oldcache.cb := cb + } + } else { + let () = oldCache := eventHandlerUnregister(elem, oldName, oldCache.contents) + let () = newCache := eventHandlerRegister(callbacks, elem, newName, newHandlerType) + } + } +let patchVNodesOnElemsPropertiesApplyAdd = ( + callbacks: ref>, + elem: Web.Node.t, + _idx: int, +): (property<'msg> => unit) => + x => + switch x { + | NoProp => () + | RawProp(k, v) => Web.Node.setProp(elem, k, v) + | Attribute(namespace, k, v) => + Web.Node.setAttributeNsOptional(elem, namespace, k, v) + | Data(k, v) => + Js.log(("TODO: Add Data Unhandled", k, v)) + failwith("TODO: Add Data Unhandled") + | Event(name, handlerType, cache) => + cache := eventHandlerRegister(callbacks, elem, name, handlerType) + | Style(s) => + List.fold_left(((), (k, v)) => Web.Node.setStyleProperty(elem, k, Js.Null.return(v)), (), s) + } +let patchVNodesOnElemsPropertiesApplyRemove = ( + _callbacks: ref>, + elem: Web.Node.t, + _idx: int, +): (property<'msg> => unit) => + x => + switch x { + | NoProp => () + | RawProp(k, _v) => Web.Node.setProp(elem, k, Js.Undefined.empty) + | Attribute(namespace, k, _v) => + Web.Node.removeAttributeNsOptional(elem, namespace, k) + | Data(k, v) => + Js.log(("TODO: Remove Data Unhandled", k, v)) + failwith("TODO: Remove Data Unhandled") + | Event(name, _, cache) => + cache := eventHandlerUnregister(elem, name, cache.contents) + | Style(s) => + List.fold_left(((), (k, _v)) => Web.Node.setStyleProperty(elem, k, Js.Null.empty), (), s) + } +let patchVNodesOnElemsPropertiesApplyRemoveAdd = ( + callbacks: ref>, + elem: Web.Node.t, + idx: int, + oldProp: property<'msg>, + newProp: property<'msg>, +): unit => { + let () = patchVNodesOnElemsPropertiesApplyRemove(callbacks, elem, idx, oldProp) + let () = patchVNodesOnElemsPropertiesApplyAdd(callbacks, elem, idx, newProp) +} +let patchVNodesOnElemsPropertiesApplyMutate = ( + _callbacks: ref>, + elem: Web.Node.t, + _idx: int, + oldProp: property<'msg>, +): (property<'msg> => unit) => + x => + switch x { + | NoProp as _newProp => + failwith("This should never be called as all entries through NoProp are gated.") + | RawProp(k, v) as _newProp => Web.Node.setProp(elem, k, v) + | Attribute(namespace, k, v) as _newProp => + Web.Node.setAttributeNsOptional(elem, namespace, k, v) + | Data(k, v) as _newProp => + Js.log(("TODO: Mutate Data Unhandled", k, v)) + failwith("TODO: Mutate Data Unhandled") + | Event(_newName, _newHandlerType, _newCache) as _newProp => + failwith("This will never be called because it is gated") + | Style(s) as _newProp => + @ocaml.warning("-4") + switch oldProp { + | Style(oldS) => List.fold_left2(((), (ok, ov), (nk, nv)) => + if ok == nk { + if ov == nv { + () + } else { + Web.Node.setStyleProperty(elem, nk, Js.Null.return(nv)) + } + } else { + let () = Web.Node.setStyleProperty(elem, ok, Js.Null.empty) + Web.Node.setStyleProperty(elem, nk, Js.Null.return(nv)) + } + , (), oldS, s) + | _ => + failwith( + "Passed a non-Style to a new Style as a Mutations while the old Style is not actually a style!", + ) + } + } +let rec patchVNodesOnElemsPropertiesApply = ( + callbacks: ref>, + elem: Web.Node.t, + idx: int, + oldProperties: list>, + newProperties: list>, +): bool => + @ocaml.warning("-4") + switch (oldProperties, newProperties) { + | (list{}, list{}) => true + | (list{}, list{_newProp, ..._newRest}) => false + | (list{_oldProp, ..._oldRest}, list{}) => false + | (list{NoProp, ...oldRest}, list{NoProp, ...newRest}) => + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | ( + list{RawProp(oldK, oldV) as oldProp, ...oldRest}, + list{RawProp(newK, newV) as newProp, ...newRest}, + ) => + let () = if oldK == newK && oldV == newV { + () + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, oldProp, newProp) + } + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | ( + list{Attribute(oldNS, oldK, oldV) as oldProp, ...oldRest}, + list{Attribute(newNS, newK, newV) as newProp, ...newRest}, + ) => + let () = if oldNS == newNS && (oldK == newK && oldV == newV) { + () + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, oldProp, newProp) + } + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | ( + list{Data(oldK, oldV) as oldProp, ...oldRest}, + list{Data(newK, newV) as newProp, ...newRest}, + ) => + let () = if oldK == newK && oldV == newV { + () + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, oldProp, newProp) + } + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | ( + list{Event(oldName, oldHandlerType, oldCache) as _oldProp, ...oldRest}, + list{Event(newName, newHandlerType, newCache) as _newProp, ...newRest}, + ) => + let () = eventHandlerMutate( + callbacks, + elem, + oldName, + newName, + oldHandlerType, + newHandlerType, + oldCache, + newCache, + ) + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | (list{Style(oldS) as oldProp, ...oldRest}, list{Style(newS) as newProp, ...newRest}) => + let () = if oldS == newS { + () + } else { + patchVNodesOnElemsPropertiesApplyMutate(callbacks, elem, idx, oldProp, newProp) + } + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + | (list{oldProp, ...oldRest}, list{newProp, ...newRest}) => + let () = patchVNodesOnElemsPropertiesApplyRemoveAdd(callbacks, elem, idx, oldProp, newProp) + patchVNodesOnElemsPropertiesApply(callbacks, elem, idx + 1, oldRest, newRest) + } +let patchVNodesOnElemsProperties = ( + callbacks: ref>, + elem: Web.Node.t, + oldProperties: list>, + newProperties: list>, +): bool => patchVNodesOnElemsPropertiesApply(callbacks, elem, 0, oldProperties, newProperties) +let genEmptyProps = (length: int): list> => { + let rec aux = (lst, x) => + switch x { + | 0 => lst + | len => aux(list{noProp, ...lst}, len - 1) + } + aux(list{}, length) +} +let mapEmptyProps = (props: list>): list> => + List.map(_ => noProp, props) +let rec patchVNodesOnElemsReplaceNode = ( + callbacks: ref>, + elem: Web.Node.t, + elems: array, + idx: int, +): (t<'msg> => unit) => + x => + switch x { + | + Node(newNamespace, newTagName, _newKey, _newUnique, newProperties, newChildren) => + let oldChild = elems[idx] + let newChild = Web.Document.createElementNsOptional(newNamespace, newTagName) + @ocaml.warning("-8") + let true = patchVNodesOnElemsProperties( + callbacks, + newChild, + mapEmptyProps(newProperties), + newProperties, + ) + let childChildren = Web.Node.childNodes(newChild) + let () = patchVNodesOnElems(callbacks, newChild, childChildren, 0, list{}, newChildren) + let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild) + let _removedChild = Web.Node.removeChild(elem, oldChild) + | _ => failwith("Node replacement should never be passed anything but a node itself") + } +and patchVNodesOnElemsCreateElement = (callbacks: ref>): ( + t<'msg> => Web.Node.t +) => + x => + switch x { + | CommentNode(s) => Web.Document.createComment(s) + | Text(text) => Web.Document.createTextNode(text) + | + Node(newNamespace, newTagName, _newKey, _unique, newProperties, newChildren) => + let newChild = Web.Document.createElementNsOptional(newNamespace, newTagName) + @ocaml.warning("-8") + let true = patchVNodesOnElemsProperties( + callbacks, + newChild, + mapEmptyProps(newProperties), + newProperties, + ) + let childChildren = Web.Node.childNodes(newChild) + let () = patchVNodesOnElems(callbacks, newChild, childChildren, 0, list{}, newChildren) + newChild + | LazyGen(_newKey, newGen, newCache) => + let vdom = newGen() + let () = newCache := vdom + patchVNodesOnElemsCreateElement(callbacks, vdom) + | Tagger(tagger, vdom) => + patchVNodesOnElemsCreateElement(tagger(callbacks), vdom) + } +and patchVNodesOnElemsMutateNode = ( + callbacks: ref>, + elem: Web.Node.t, + elems: array, + idx: int, + oldNode: t<'msg>, + newNode: t<'msg>, +): unit => + switch (oldNode, newNode) { + | ( + + Node(_oldNamespace, oldTagName, _oldKey, oldUnique, oldProperties, oldChildren) as _oldNode, + + Node(_newNamespace, newTagName, _newKey, newUnique, newProperties, newChildren) as newNode, + ) => + if oldUnique != newUnique || oldTagName != newTagName { + patchVNodesOnElemsReplaceNode(callbacks, elem, elems, idx, newNode) + } else { + let child = elems[idx] + let childChildren = Web.Node.childNodes(child) + let () = if patchVNodesOnElemsProperties(callbacks, child, oldProperties, newProperties) { + () + } else { + let () = Js.log( + "VDom: Failed swapping properties because the property list length changed, use `noProp` to swap properties instead, not by altering the list structure. This is a massive inefficiency until this issue is resolved.", + ) + patchVNodesOnElemsReplaceNode(callbacks, elem, elems, idx, newNode) + } + patchVNodesOnElems(callbacks, child, childChildren, 0, oldChildren, newChildren) + } + | _ => failwith("Non-node passed to patchVNodesOnElemsMutateNode") + } +and patchVNodesOnElems = ( + callbacks: ref>, + elem: Web.Node.t, + elems: array, + idx: int, + oldVNodes: list>, + newVNodes: list>, +): unit => + @ocaml.warning("-4") + switch (oldVNodes, newVNodes) { + | (list{Tagger(_oldTagger, oldVdom), ...oldRest}, _) => + patchVNodesOnElems(callbacks, elem, elems, idx, list{oldVdom, ...oldRest}, newVNodes) + | (list{oldNode, ...oldRest}, list{Tagger(newTagger, newVdom), ...newRest}) => + let () = patchVNodesOnElems( + newTagger(callbacks), + elem, + elems, + idx, + list{oldNode}, + list{newVdom}, + ) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + | (list{}, list{}) => () + | (list{}, list{newNode, ...newRest}) => + let newChild = patchVNodesOnElemsCreateElement(callbacks, newNode) + let _attachedChild = Web.Node.appendChild(elem, newChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, list{}, newRest) + | (list{_oldVnode, ...oldRest}, list{}) => + let child = elems[idx] + let _removedChild = Web.Node.removeChild(elem, child) + patchVNodesOnElems(callbacks, elem, elems, idx, oldRest, list{}) + | (list{CommentNode(oldS), ...oldRest}, list{CommentNode(newS), ...newRest}) if oldS == newS => + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + | (list{Text(oldText), ...oldRest}, list{Text(newText), ...newRest}) => + let () = if oldText == newText { + () + } else { + let child = elems[idx] + Web.Node.set_nodeValue(child, newText) + } + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + | ( + list{LazyGen(oldKey, _oldGen, oldCache), ...oldRest}, + list{LazyGen(newKey, newGen, newCache), ...newRest}, + ) => + if oldKey == newKey { + let () = newCache := oldCache.contents + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + } else { + switch (oldRest, newRest) { + | ( + list{LazyGen(olderKey, _olderGen, _olderCache), ...olderRest}, + list{LazyGen(newerKey, _newerGen, _newerCache), ...newerRest}, + ) if olderKey == newKey && oldKey == newerKey => + let firstChild = elems[idx] + let secondChild = elems[idx + 1] + let _removedChild = Web.Node.removeChild(elem, secondChild) + let _attachedChild = Web.Node.insertBefore(elem, secondChild, firstChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 2, olderRest, newerRest) + | (list{LazyGen(olderKey, _olderGen, olderCache), ...olderRest}, _) + if olderKey == newKey => + let oldChild = elems[idx] + let _removedChild = Web.Node.removeChild(elem, oldChild) + let oldVdom = olderCache.contents + let () = newCache := oldVdom + patchVNodesOnElems(callbacks, elem, elems, idx + 1, olderRest, newRest) + | (_, list{LazyGen(newerKey, _newerGen, _newerCache), ..._newerRest}) + if newerKey == oldKey => + let oldChild = elems[idx] + let newVdom = newGen() + let () = newCache := newVdom + let newChild = patchVNodesOnElemsCreateElement(callbacks, newVdom) + let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldVNodes, newRest) + | _ => + let oldVdom = oldCache.contents + let newVdom = newGen() + let () = newCache := newVdom + patchVNodesOnElems( + callbacks, + elem, + elems, + idx, + list{oldVdom, ...oldRest}, + list{newVdom, ...newRest}, + ) + } + } + | ( + list{ + + Node(oldNamespace, oldTagName, oldKey, _oldUnique, _oldProperties, _oldChildren) as oldNode, + ...oldRest, + }, + list{ + + Node(newNamespace, newTagName, newKey, _newUnique, _newProperties, _newChildren) as newNode, + ...newRest, + }, + ) => + if oldKey == newKey && oldKey != "" { + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + } else if oldKey == "" || newKey == "" { + let () = patchVNodesOnElemsMutateNode(callbacks, elem, elems, idx, oldNode, newNode) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + } else { + switch (oldRest, newRest) { + | ( + list{ + + Node( + olderNamespace, + olderTagName, + olderKey, + _olderUnique, + _olderProperties, + _olderChildren, + ), + ...olderRest, + }, + list{ + + Node( + newerNamespace, + newerTagName, + newerKey, + _newerUnique, + _newerProperties, + _newerChildren, + ), + ...newerRest, + }, + ) + if olderNamespace == newNamespace && + (olderTagName == newTagName && + (olderKey == newKey && + (oldNamespace == newerNamespace && + (oldTagName == newerTagName && oldKey == newerKey)))) => + let firstChild = elems[idx] + let secondChild = elems[idx + 1] + let _removedChild = Web.Node.removeChild(elem, secondChild) + let _attachedChild = Web.Node.insertBefore(elem, secondChild, firstChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 2, olderRest, newerRest) + | ( + list{ + + Node( + olderNamespace, + olderTagName, + olderKey, + _olderUnique, + _olderProperties, + _olderChildren, + ), + ...olderRest, + }, + _, + ) if olderNamespace == newNamespace && (olderTagName == newTagName && olderKey == newKey) => + let oldChild = elems[idx] + let _removedChild = Web.Node.removeChild(elem, oldChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, olderRest, newRest) + | ( + _, + list{ + + Node( + newerNamespace, + newerTagName, + newerKey, + _newerUnique, + _newerProperties, + _newerChildren, + ), + ..._newerRest, + }, + ) if oldNamespace == newerNamespace && (oldTagName == newerTagName && oldKey == newerKey) => + let oldChild = elems[idx] + let newChild = patchVNodesOnElemsCreateElement(callbacks, newNode) + let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldVNodes, newRest) + | _ => + let () = patchVNodesOnElemsMutateNode(callbacks, elem, elems, idx, oldNode, newNode) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + } + } + | (list{_oldVnode, ...oldRest}, list{newNode, ...newRest}) => + let oldChild = elems[idx] + let newChild = patchVNodesOnElemsCreateElement(callbacks, newNode) + let _attachedChild = Web.Node.insertBefore(elem, newChild, oldChild) + let _removedChild = Web.Node.removeChild(elem, oldChild) + patchVNodesOnElems(callbacks, elem, elems, idx + 1, oldRest, newRest) + } +let patchVNodesIntoElement = ( + callbacks: ref>, + elem: Web.Node.t, + oldVNodes: list>, + newVNodes: list>, +): list> => { + let elems = Web.Node.childNodes(elem) + let () = patchVNodesOnElems(callbacks, elem, elems, 0, oldVNodes, newVNodes) + newVNodes +} +let patchVNodeIntoElement = ( + callbacks: ref>, + elem: Web.Node.t, + oldVNode: t<'msg>, + newVNode: t<'msg>, +): list> => patchVNodesIntoElement(callbacks, elem, list{oldVNode}, list{newVNode}) +let wrapCallbacksOn: + type a b. (a => b, systemMessage) => systemMessage = + (func, x) => + switch x { + | Render => Render + | AddRenderMsg(msg) => AddRenderMsg(func(msg)) + | RemoveRenderMsg(msg) => RemoveRenderMsg(func(msg)) + } +let wrapCallbacks: + type a b. (a => b, ref>) => ref> = + (func, callbacks) => + Obj.magic( + ref, + { + enqueue: (msg: a) => { + let newMsg = func(msg) + callbacks.contents.enqueue(newMsg) + }, + on: smsg => { + let newSmsg = wrapCallbacksOn(func, smsg) + callbacks.contents.on(newSmsg) + }, + }, + ) +let map: ('a => 'b, t<'a>) => t<'b> = ( + (func, vdom) => { + let tagger = wrapCallbacks(func) + Tagger(Obj.magic(tagger), Obj.magic(vdom)) + }: ('a => 'b, t<'a>) => t<'b> +) diff --git a/src/vdom.resi b/src/vdom.resi new file mode 100644 index 0000000..9b2439c --- /dev/null +++ b/src/vdom.resi @@ -0,0 +1,190 @@ +type systemMessage<'msg> = Render | AddRenderMsg('msg) | RemoveRenderMsg('msg) + +type applicationCallbacks<'msg> = {enqueue: 'msg => unit, on: systemMessage<'msg> => unit} + +type eventHandler<'msg> = + | EventHandlerCallback(string, Web.Node.event => option<'msg>) + | EventHandlerMsg('msg) + +type eventCache<'msg> = {handler: Web.Node.event_cb, cb: ref option<'msg>>} + +type property<'msg> = + | NoProp + | RawProp(string, string) + | Attribute(string, string, string) + | Data(string, string) + | Event(string, eventHandler<'msg>, ref>>) + | Style(list<(string, string)>) + +type properties<'msg> = list> + +type rec t<'msg> = + | CommentNode(string) + | Text(string) + | Node(string, string, string, string, properties<'msg>, list>) + | LazyGen(string, unit => t<'msg>, ref>) + | Tagger(ref> => ref>, t<'msg>) + +let noNode: t<'msg> + +let comment: string => t<'msg> + +let text: string => t<'msg> + +let fullnode: (string, string, string, string, properties<'msg>, list>) => t<'msg> + +let node: ( + ~namespace: string=?, + string, + ~key: string=?, + ~unique: string=?, + properties<'msg>, + list>, +) => t<'msg> + +let lazyGen: (string, unit => t<'msg>) => t<'msg> + +let noProp: property<'msg> + +let prop: (string, string) => property<'msg> + +let onCB: (string, string, Web.Node.event => option<'msg>) => property<'msg> + +let onMsg: (string, 'msg) => property<'msg> + +let attribute: (string, string, string) => property<'msg> + +let data: (string, string) => property<'msg> + +let style: (string, string) => property<'msg> + +let styles: list<(string, string)> => property<'msg> + +let renderToHtmlString: t<'msg> => string + +let emptyEventHandler: Web.Node.event_cb + +let emptyEventCB: 'msg => option + +let eventHandler: ( + ref>, + ref option<'msg>>, +) => Web.Node.event_cb + +let eventHandlerGetCB: (eventHandler<'msg>, Web.Node.event) => option<'msg> + +let compareEventHandlerTypes: (eventHandler<'msg>, eventHandler<'msg>) => bool + +let eventHandlerRegister: ( + ref>, + Web.Node.t, + string, + eventHandler<'msg>, +) => option> + +let eventHandlerUnregister: (Web.Node.t, string, option>) => option< + eventCache<'msg>,> + +let eventHandlerMutate: ( + ref>, + Web.Node.t, + string, + string, + eventHandler<'msg>, + eventHandler<'msg>, + ref>>, + ref>>, +) => unit + +let patchVNodesOnElemsPropertiesApplyAdd: ( + ref>, + Web.Node.t, + int, + property<'msg>, +) => unit + +let patchVNodesOnElemsPropertiesApplyRemove: ( + ref>, + Web.Node.t, + int, + property<'msg>, +) => unit + +let patchVNodesOnElemsPropertiesApplyRemoveAdd: ( + ref>, + Web.Node.t, + int, + property<'msg>, + property<'msg>, +) => unit + +let patchVNodesOnElemsPropertiesApplyMutate: ( + ref>, + Web.Node.t, + int, + property<'msg>, + property<'msg>, +) => unit + +let patchVNodesOnElemsPropertiesApply: ( + ref>, + Web.Node.t, + int, + list>, + list>, +) => bool + +let patchVNodesOnElemsProperties: ( + ref>, + Web.Node.t, + list>, + list>, +) => bool + +let genEmptyProps: int => list> + +let mapEmptyProps: list> => list> + +let patchVNodesOnElemsReplaceNode: ( + ref>, + Web.Node.t, + array, + int, + t<'msg>, +) => unit + +let patchVNodesOnElemsCreateElement: (ref>, t<'msg>) => Web.Node.t + +let patchVNodesOnElemsMutateNode: ( + ref>, + Web.Node.t, + array, + int, + t<'msg>, + t<'msg>, +) => unit + +let patchVNodesOnElems: ( + ref>, + Web_node.t, + Js.Array.t, + int, + list>, + list>, +) => unit + +let patchVNodesIntoElement: ( + ref>, + Web.Node.t, + list>, + list>, +) => list> + +let patchVNodeIntoElement: (ref>, Web.Node.t, t<'msg>, t<'msg>) => list< + t<'msg>,> + +let wrapCallbacksOn: ('msg => 'b, systemMessage<'msg>) => systemMessage<'b> + +let wrapCallbacks: ('msg => 'b, ref>) => ref> + +let map: ('msg => 'b, t<'msg>) => t<'b> diff --git a/src-ocaml/web.ml b/src/web.res similarity index 67% rename from src-ocaml/web.ml rename to src/web.res index f899104..0e633c0 100644 --- a/src-ocaml/web.ml +++ b/src/web.res @@ -1,32 +1,22 @@ - - module Event = Web_event - module Node = Web_node - module Document = Web_document - module Date = Web_date - module Window = Web_window - module Location = Web_location - module Json = Web_json - module XMLHttpRequest = Web_xmlhttprequest module FormData = Web_formdata - -let polyfills () = - let () = Node.remove_polyfill () in - let () = Window.requestAnimationFrame_polyfill () in - () +let polyfills = () => { + let () = Node.remove_polyfill() + let () = Window.requestAnimationFrame_polyfill() +} diff --git a/src/web.resi b/src/web.resi new file mode 100644 index 0000000..88f5c3b --- /dev/null +++ b/src/web.resi @@ -0,0 +1,19 @@ +module Event = Web_event + +module Node = Web_node + +module Document = Web_document + +module Date = Web_date + +module Window = Web_window + +module Location = Web_location + +module Json = Web_json + +module XMLHttpRequest = Web_xmlhttprequest + +module FormData = Web_formdata + +let polyfills: unit => unit diff --git a/src/web_date.res b/src/web_date.res new file mode 100644 index 0000000..804a6b3 --- /dev/null +++ b/src/web_date.res @@ -0,0 +1,10 @@ +type t = {.} + +type date_obj +@send external now: date_obj => float = "now" + +@new external create_date: unit => t = "Date" + +@val external date_obj: date_obj = "Date" + +let now = () => now (date_obj) diff --git a/src/web_date.resi b/src/web_date.resi new file mode 100644 index 0000000..996e553 --- /dev/null +++ b/src/web_date.resi @@ -0,0 +1,9 @@ +type t = {.} + +type date_obj + +@new external create_date: unit => t = "Date" +@val external date_obj: date_obj = "Date" + +let now: unit => float + diff --git a/src/web_document.res b/src/web_document.res new file mode 100644 index 0000000..15696eb --- /dev/null +++ b/src/web_document.res @@ -0,0 +1,41 @@ +/* TODO: Polyfill document if it is missing, like on node or in native */ + +type t = { + @get + "body": Web_node.t, + @get + "location": Web_location.t, +} + +@send external +createElement: (t,string) => Web_node.t="createElement" +@send external +createElementNS: (t,string, string) => Web_node.t="createElementNS" +@send external +createComment: (t,string) => Web_node.t="createComment" +@send external +createTextNode: (t,string) => Web_node.t="createTextNode" +@send external +getElementById: (t,string) => Js.null_undefined="getElementById" + +@val external document: t = "document" + +let body = () => document["body"] + +let createElement = typ => createElement(document, typ) + +let createElementNS = (namespace, key) => createElementNS(document, namespace, key) + +let createComment = text => createComment(document, text) + +let createTextNode = text => createTextNode(document, text) + +let getElementById = id => getElementById(document, id) + +let createElementNsOptional = (namespace, tagName) => + switch namespace { + | "" => createElement(tagName) + | ns => createElementNS(ns, tagName) + } + +let location = () => document["location"] diff --git a/src/web_document.resi b/src/web_document.resi new file mode 100644 index 0000000..d964671 --- /dev/null +++ b/src/web_document.resi @@ -0,0 +1,20 @@ +type t = {"body": Web_node.t, "location": Web_location.t} + +@val external document: t = "document" + +let body: unit => Web_node.t + +let createElement: string => Web_node.t + +let createElementNS: (string, string) => Web_node.t + +let createComment: string => Web_node.t + +let createTextNode: string => Web_node.t + +let getElementById: string => Js.null_undefined + +let createElementNsOptional: (string, string) => Web_node.t + +let location: unit => Web_location.t + diff --git a/src/web_event.res b/src/web_event.res new file mode 100644 index 0000000..2324733 --- /dev/null +++ b/src/web_event.res @@ -0,0 +1,22 @@ +/* type target = < + value : string Js.undefined [@bs.get]; +> Js.t */ + +type t<'node> = { + @get + "target": Js.undefined<'node>, + @get + "keyCode": int, + @meth + "preventDefault": unit => unit, + @meth + "stopPropagation": unit => unit, +} + +type cb<'node> = (. t<'node>) => unit + +type options = bool /* false | true (* TODO: Define a javascript record as another option *) */ + +type popstateEvent = {.} + +type popstateCb = (. popstateEvent) => unit diff --git a/src/web_event.resi b/src/web_event.resi new file mode 100644 index 0000000..ed62f8b --- /dev/null +++ b/src/web_event.resi @@ -0,0 +1,14 @@ +type t<'node> = { + "keyCode": int, + "preventDefault": Js_OO.Meth.arity0, + "stopPropagation": Js_OO.Meth.arity0, + "target": Js.undefined<'node>, +} + +type cb<'node> = (. t<'node>) => unit + +type options = bool + +type popstateEvent = {.} + +type popstateCb = (. popstateEvent) => unit diff --git a/src/web_formdata.res b/src/web_formdata.res new file mode 100644 index 0000000..46f59a0 --- /dev/null +++ b/src/web_formdata.res @@ -0,0 +1,10 @@ + +type _formdata =() + +@send external append: ((),string, string) => unit="append" + +type t = _formdata + +@new external create: unit => t = "FormData" + +let append = (key, value, f) => append(f,key, value) \ No newline at end of file diff --git a/src/web_formdata.resi b/src/web_formdata.resi new file mode 100644 index 0000000..faf7d6d --- /dev/null +++ b/src/web_formdata.resi @@ -0,0 +1,7 @@ +type _formdata = unit + +type t = _formdata + +@new external create: unit => t = "FormData" + +let append: (string, string, unit) => unit diff --git a/src/web_json.res b/src/web_json.res new file mode 100644 index 0000000..85d6470 --- /dev/null +++ b/src/web_json.res @@ -0,0 +1,17 @@ +include Js.Json + +type nothingYet +@val external stringify: ('t, Js.null, int) => string = "JSON.stringify" + +let string_of_json = (~indent=2, value) => + switch Js.Undefined.toOption(value) { + | None => "undefined" + | Some(v) => + try stringify(v, Js.Null.empty, indent) catch { + | _ => "" + } + } + +let of_type = (type a, _v: kind, x: a): t => Obj.magic(x) + +let null: Js_types.null_val = Obj.magic(Js.null) diff --git a/src/web_location.res b/src/web_location.res new file mode 100644 index 0000000..06ccaf5 --- /dev/null +++ b/src/web_location.res @@ -0,0 +1,84 @@ +type t = { + @get @set + "href": string, + @get @set + "protocol": string, + @get @set + "host": string, + @get @set + "hostname": string, + @get @set + "port": string, + @get @set + "pathname": string, + @get @set + "search": string, + @get @set + "hash": string, + @get @set + "username": string, + @get @set + "password": string, + @get + "origin": string, +} + +let getHref = location => location["href"] +let setHref = (location, value) => location["href"] = value + +let getProtocol = location => location["protocol"] +let setProtocol = (location, value) => location["protocol"] = value + +let getHost = location => location["host"] +let setHost = (location, value) => location["host"] = value + +let getHostname = location => location["hostname"] +let setHostname = (location, value) => location["hostname"] = value + +let getPort = location => location["port"] +let setPort = (location, value) => location["port"] = value + +let getPathname = location => location["pathname"] +let setPathname = (location, value) => location["pathname"] = value + +let getSearch = location => location["search"] +let setSearch = (location, value) => location["search"] = value + +let getHash = location => location["hash"] +let setHash = (location, value) => location["hash"] = value + +let getUsername = location => location["username"] +let setUsername = (location, value) => location["username"] = value + +let getPassword = location => location["password"] +let setPassword = (location, value) => location["password"] = value + +let getOrigin = location => location["origin"] + +type location = { + href: string, + protocol: string, + host: string, + hostname: string, + port: string, + pathname: string, + search: string, + hash: string, + username: string, + password: string, + origin: string, +} + +let asRecord = location => { + href: location["href"], + protocol: location["protocol"], + host: location["host"], + hostname: location["hostname"], + port: location["port"], + pathname: location["pathname"], + search: location["search"], + hash: location["hash"], + username: location["username"], + password: location["password"], + origin: location["origin"], +} diff --git a/src/web_location.resi b/src/web_location.resi new file mode 100644 index 0000000..956b60d --- /dev/null +++ b/src/web_location.resi @@ -0,0 +1,93 @@ +type t = { + "hash": string, + "hash#=": Js_OO.Meth.arity1 unit>, + "host": string, + "host#=": Js_OO.Meth.arity1 unit>, + "hostname": string, + "hostname#=": Js_OO.Meth.arity1 unit>, + "href": string, + "href#=": Js_OO.Meth.arity1 unit>, + "origin": string, + "password": string, + "password#=": Js_OO.Meth.arity1 unit>, + "pathname": string, + "pathname#=": Js_OO.Meth.arity1 unit>, + "port": string, + "port#=": Js_OO.Meth.arity1 unit>, + "protocol": string, + "protocol#=": Js_OO.Meth.arity1 unit>, + "search": string, + "search#=": Js_OO.Meth.arity1 unit>, + "username": string, + "username#=": Js_OO.Meth.arity1 unit>, +} + +let getHref: {.."href": 'msg} => 'msg + +let setHref: ({.."href#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getProtocol: {.."protocol": 'msg} => 'msg + +let setProtocol: ({.."protocol#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getHost: {.."host": 'msg} => 'msg + +let setHost: ({.."host#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getHostname: {.."hostname": 'msg} => 'msg + +let setHostname: ({.."hostname#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getPort: {.."port": 'msg} => 'msg + +let setPort: ({.."port#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getPathname: {.."pathname": 'msg} => 'msg + +let setPathname: ({.."pathname#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getSearch: {.."search": 'msg} => 'msg + +let setSearch: ({.."search#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getHash: {.."hash": 'msg} => 'msg + +let setHash: ({.."hash#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getUsername: {.."username": 'msg} => 'msg + +let setUsername: ({.."username#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getPassword: {.."password": 'msg} => 'msg + +let setPassword: ({.."password#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let getOrigin: {.."origin": 'msg} => 'msg + +type location = { + href: string, + protocol: string, + host: string, + hostname: string, + port: string, + pathname: string, + search: string, + hash: string, + username: string, + password: string, + origin: string, +} + +let asRecord: {.. + "hash": string, + "host": string, + "hostname": string, + "href": string, + "origin": string, + "password": string, + "pathname": string, + "port": string, + "protocol": string, + "search": string, + "username": string, +} => location diff --git a/src/web_node.res b/src/web_node.res new file mode 100644 index 0000000..b160ff1 --- /dev/null +++ b/src/web_node.res @@ -0,0 +1,154 @@ +type style = { + @get + "setProperty": Js.undefined /* TODO: Revamp this and the next line... */, + @meth + "setProperty__": (string, Js.null, Js.null) => unit, +} +@send external +setProperty__: (string, Js.null, Js.null) => unit="setProperty__" + +@get_index external getStyle: (style, string) => Js.null = "" + +@set_index external setStyle: (style, string, Js.null) => unit = "" + +type rec t = { + @get + "style": style, + @set @get + "value": Js.undefined, + @set @get + "checked": Js.undefined, + @get + "childNodes": Js.Array.t, + @get + "firstChild": Js.Null.t, + /* Text Nodes only */ + @set @get({null: null}) + "nodeValue": string, +} + + +@send external +appendChild: (t,t) => t="appendChild" +@send external +removeChild: (t,t) => t="removeChild" +@send external +insertBefore: (t,t, t) => t="insertBefore" +@send external +remove: (t,unit) => unit="remove" +@send external +setAttributeNS: (t,string, string, string) => unit="setAttributeNS" +@send external +setAttribute: (t,string, string) => unit="setAttribute" +@send external +removeAttributeNS: (t,string, string) => unit="removeAttributeNS" +@send external +removeAttribute: (t,string) => unit="removeAttribute" +@send external +focus: t => unit="focus" + +@send external +addEventListener: (t,string, Web_event.cb, Web_event.options) => unit="addEventListener" + +@send external +removeEventListener: (t,string, Web_event.cb, Web_event.options) => unit="removeEventListener" + + + +@val external document_node: t = "document" + +type event = Web_event.t + +type event_cb = Web_event.cb + +@get_index external getProp_asEventListener: (t, 'key) => Js.undefined> = "" + +@set_index external setProp_asEventListener: (t, 'key, Js.undefined>) => unit = "" + +@get_index external getProp: (t, 'key) => 'value = "" + +@set_index external setProp: (t, 'key, 'value) => unit = "" + +let style = n => n["style"] + +let getStyle = (n, key) => getStyle(n["style"], key) + +let setStyle = (n, key, value) => setStyle(n["style"], key, value) + +let setStyleProperty = (n, ~priority=false, key, value) => { + let style = n["style"] + switch Js.Undefined.toOption(style["setProperty"]) { + | None => setStyle(n, key, value) /* TODO: Change this to setAttribute sometime, maybe... */ + | Some(_valid) => + setProperty__( + key, + value, + if priority { + Js.Null.return("important") + } else { + Js.Null.empty + }, + ) + } +} + +let childNodes = n => n["childNodes"] + +let firstChild = n => n["firstChild"] + +let appendChild = (n, child) => appendChild(n,child) + +let removeChild = (n, child) => removeChild(n,child) + +let insertBefore = (n, child, refNode) => insertBefore(n,child, refNode) + +let remove = (n, child) => remove(n,child) + +let setAttributeNS = (n, namespace, key, value) => setAttributeNS(n,namespace, key, value) + +let setAttribute = (n, key, value) => setAttribute(n,key, value) + +let setAttributeNsOptional = (n, namespace, key, value) => + switch namespace { + | "" => setAttribute(n,key, value) + | ns => setAttributeNS(n,ns, key, value) + } + +let removeAttributeNS = (n, namespace, key) => removeAttributeNS(n,namespace, key) + +let removeAttribute = (n, key) => removeAttribute(n,key) + +let removeAttributeNsOptional = (n, namespace, key) => + switch namespace { + | "" => removeAttribute(n,key) + | ns => removeAttributeNS(n,ns, key) + } + +let addEventListener = (n, typ, listener, options) => addEventListener(n,typ, listener, options) + +let removeEventListener = (n, typ, listener, options) => + removeEventListener(n,typ, listener, options) + +let focus = n => focus(n) + +/* Text Nodes only */ + +let set_nodeValue = (n, text) => n["nodeValue"] = text + +let get_nodeValue = n => n["nodeValue"] + +/* Polyfills */ + +let remove_polyfill: unit => unit = () => + %raw(` + // remove polyfill + (function() { + if (!('remove' in Element.prototype)) { + Element.prototype.remove = function() { + if (this.parentNode) { + this.parentNode.removeChild(this); + } + }; + }; + }()) + `) diff --git a/src/web_node.resi b/src/web_node.resi new file mode 100644 index 0000000..fbba6bd --- /dev/null +++ b/src/web_node.resi @@ -0,0 +1,77 @@ +type style = { + "setProperty": Js.undefined, + "setProperty__": Js_OO.Meth.arity3<(string, Js.null, Js.null) => unit>, +} + +@send external +setProperty__: (string, Js.null, Js.null) => unit="setProperty__" + +type rec t = { + "checked": Js.undefined, + "checked#=": Js_OO.Meth.arity1 => unit>, + "childNodes": Js.Array.t, + "firstChild": Js.Null.t, + "nodeValue": Js.null, + "nodeValue#=": Js_OO.Meth.arity1 unit>, + "style": style, + "value": Js.undefined, + "value#=": Js_OO.Meth.arity1 => unit>, +} + +@val external document_node: t = "document" + +type event = Web_event.t + +type event_cb = Web_event.cb + +@get_index external getProp_asEventListener: (t, 'key) => Js.undefined> = "" + +@set_index external setProp_asEventListener: (t, 'key, Js.undefined>) => unit = "" + +@get_index external getProp: (t, 'key) => 'value = "" + +@set_index external setProp: (t, 'key, 'value) => unit = "" + +let style: {.."style": 'msg} => 'msg + +let getStyle: ({.."style": style}, string) => Js.null + +let setStyle: ({.."style": style}, string, Js.null) => unit + +let setStyleProperty: ({.."style": style}, ~priority: bool=?, string, Js.null) => unit + +let childNodes: {.."childNodes": 'msg} => 'msg + +let firstChild: {.."firstChild": 'msg} => 'msg + +let appendChild: (t, t) => t + +let removeChild: (t, t) => t + +let insertBefore: (t, t, t) => t + +let remove: (t, unit) => unit + +let setAttributeNS: (t, string, string, string) => unit + +let setAttribute: (t, string, string) => unit + +let setAttributeNsOptional: (t, string, string, string) => unit + +let removeAttributeNS: (t, string, string) => unit + +let removeAttribute: (t, string) => unit + +let removeAttributeNsOptional: (t, string, string) => unit + +let addEventListener: (t, string, Web_event.cb, Web_event.options) => unit + +let removeEventListener: (t, string, Web_event.cb, Web_event.options) => unit + +let focus: t => unit + +let set_nodeValue: ({.."nodeValue#=": Js_OO.Meth.arity1<'msg => unit>}, 'msg) => unit + +let get_nodeValue: {.."nodeValue": 'msg} => 'msg + +let remove_polyfill: unit => unit diff --git a/src/web_window.res b/src/web_window.res new file mode 100644 index 0000000..dd94aa6 --- /dev/null +++ b/src/web_window.res @@ -0,0 +1,95 @@ +/* TODO: Polyfill window if it is missing, like on node or in native */ + +module History = Web_window_history + +module LocalStorage = Web_window_localstorage + +type timeoutHandlerID = int + +type t = { + @get + "history": Js.Undefined.t, + @get + "location": Web_location.t, + @get + "localStorage": Js.Undefined.t, +} + + +@send external +requestAnimationFrame : (t, float => unit) => int ="requestAnimationFrame" + +@send external +cancelAnimationFrame : (t,int) => unit = "cancelAnimationFrame" + +@send external +setInterval : (t, unit => unit, float) => timeoutHandlerID = "setInterval" + +@send external +clearTimeout : (t,timeoutHandlerID) => unit = "clearTimeout" + +@send external +setTimeout : (t,unit => unit, float) => timeoutHandlerID = "setTimeout" + +@send external +addEventListener: (t,string, Web_event.cb, Web_event.options) => unit="addEventListener" + +@send external +removeEventListener: (t,string, Web_event.cb, Web_event.options) => unit="removeEventListener" + + +@val external window: t = "window" + +let history = () => window["history"] + +let localStorage = () => window["localStorage"] + +let location = () => window["location"] + +/* requestAnimationFrame callback is a float timestamp in milliseconds */ +let requestAnimationFrame = callback => requestAnimationFrame(window, callback) + +let cancelAnimationFrame = id => cancelAnimationFrame(window , id) + +let clearTimeout = id => clearTimeout(window,id) + +let setInterval = (cb, msTime) => setInterval(window,cb, msTime) + +let setTimeout = (cb, msTime) => setTimeout(window, cb, msTime) + +let addEventListener = (typ, listener, options) => + addEventListener(window, typ, listener, options) + +let removeEventListener = (typ, listener, options) => + removeEventListener(window, typ, listener, options) + +/* Polyfills */ + +let requestAnimationFrame_polyfill: unit => unit = () => + %raw(` + // requestAnimationFrame polyfill + (function() { + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] + || window[vendors[x]+'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + if (!window.cancelAnimationFrame) + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; + }()) + `) diff --git a/src/web_window.resi b/src/web_window.resi new file mode 100644 index 0000000..94711c7 --- /dev/null +++ b/src/web_window.resi @@ -0,0 +1,35 @@ +module History = Web_window_history + +module LocalStorage = Web_window_localstorage + +type timeoutHandlerID = int + +type t = { + "history": Js.Undefined.t, + "localStorage": Js.Undefined.t, + "location": Web_location.t, +} + +@val external window: t = "window" + +let history: unit => Js.Undefined.t + +let localStorage: unit => Js.Undefined.t + +let location: unit => Web_location.t + +let requestAnimationFrame: (float => unit) => int + +let cancelAnimationFrame: int => unit + +let clearTimeout: timeoutHandlerID => unit + +let setInterval: (unit => unit, float) => timeoutHandlerID + +let setTimeout: (unit => unit, float) => timeoutHandlerID + +let addEventListener: (string, Web_event.cb, Web_event.options) => unit + +let removeEventListener: (string, Web_event.cb, Web_event.options) => unit + +let requestAnimationFrame_polyfill: unit => unit diff --git a/src/web_window_history.res b/src/web_window_history.res new file mode 100644 index 0000000..0d25c12 --- /dev/null +++ b/src/web_window_history.res @@ -0,0 +1,59 @@ +type t = { + @get + "length": int, + @get + "state": Js.Json.t, +} + +@send external +back: t => unit="back" +@send external +forward: t => unit="forward" +@send external +go: (t,int) => unit="go" +@send external +pushState: (t,Js.Json.t, string, string) => unit="pushState" +@send external +replaceState: (t,Js.Json.t, string, string) => unit="replaceState" + +let length = window => + switch Js.Undefined.toOption(window["history"]) { + | None => -1 + | Some(history) => history["length"] + } + +let back = window => + switch Js.Undefined.toOption(window["history"]) { + | None => () + | Some(history) => back(history) + } + +let forward = window => + switch Js.Undefined.toOption(window["history"]) { + | None => () + | Some(history) => forward(history) + } + +let go = (window, to) => + switch Js.Undefined.toOption(window["history"]) { + | None => () + | Some(history) => go(history,to) + } + +let pushState = (window, state, title, url) => + switch Js.Undefined.toOption(window["history"]) { + | None => () + | Some(history) => pushState(history,state, title, url) + } + +let replaceState = (window, state, title, url) => + switch Js.Undefined.toOption(window["history"]) { + | None => () + | Some(history) => replaceState(history,state, title, url) + } + +let state = window => + switch Js.Undefined.toOption(window["history"]) { + | None => Js.Undefined.empty + | Some(history) => history["state"] + } diff --git a/src/web_window_history.resi b/src/web_window_history.resi new file mode 100644 index 0000000..cf6c42a --- /dev/null +++ b/src/web_window_history.resi @@ -0,0 +1,15 @@ +type t = {"length": int, "state": Js.Json.t} + +let length: {.."history": Js.Undefined.t<{.."length": int}>} => int + +let back: {.."history": Js.Undefined.t} => unit + +let forward: {.."history": Js.Undefined.t} => unit + +let go: ({.."history": Js.Undefined.t}, int) => unit + +let pushState: ({.."history": Js.Undefined.t}, Js.Json.t, string, string) => unit + +let replaceState: ({.."history": Js.Undefined.t}, Js.Json.t, string, string) => unit + +let state: {.."history": Js.Undefined.t<{.."state": Js.Undefined.t<'msg>}>} => Js.Undefined.t<'msg> diff --git a/src/web_window_localstorage.res b/src/web_window_localstorage.res new file mode 100644 index 0000000..3b1a6d1 --- /dev/null +++ b/src/web_window_localstorage.res @@ -0,0 +1,54 @@ +type t = { + @get + "length": int, +} + + @send external + clear: t => unit="clear" + @send external + key: (t,int) => string="key" + @send external + getItem: (t,string) => string="getItem" + @send external + removeItem: (t,string) => unit="removeItem" + @send external + setItem: (t,string, string) => unit="setItem" + +let length = window => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => Some(localStorage["length"]) + } + +let clear = window => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => Some(clear(localStorage)) + } + +let key = (window, idx) => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => Some(key(localStorage,idx)) + } + +let getItem = (window, key) => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => + try Some(getItem(localStorage,key)) catch { + | _ => None + } + } + +let removeItem = (window, key) => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => Some(removeItem(localStorage,key)) + } + +let setItem = (window, key, value) => + switch Js.Undefined.toOption(window["localStorage"]) { + | None => None + | Some(localStorage) => Some(setItem(localStorage,key, value)) + } diff --git a/src/web_window_localstorage.resi b/src/web_window_localstorage.resi new file mode 100644 index 0000000..bd3d129 --- /dev/null +++ b/src/web_window_localstorage.resi @@ -0,0 +1,13 @@ +type t = {"length": int} + +let length: {.."localStorage": Js.Undefined.t<{.."length": 'msg}>} => option<'msg> + +let clear: {.."localStorage": Js.Undefined.t} => option + +let key: ({.."localStorage": Js.Undefined.t}, int) => option + +let getItem: ({.."localStorage": Js.Undefined.t}, string) => option + +let removeItem: ({.."localStorage": Js.Undefined.t}, string) => option + +let setItem: ({.."localStorage": Js.Undefined.t}, string, string) => option diff --git a/src/web_xmlhttprequest.res b/src/web_xmlhttprequest.res new file mode 100644 index 0000000..a1e0861 --- /dev/null +++ b/src/web_xmlhttprequest.res @@ -0,0 +1,292 @@ +type unresolved + +type xmlHttpRequestUpload + +type event_readystatechange = Web_json.t +type event_abort = Web_json.t +type event_error = Web_json.t +type event_load = Web_json.t +type event_loadstart = Web_json.t +type event_progress = Web_json.t +type event_timeout = Web_json.t +type event_loadend = Web_json.t + + type _xmlhttprequest ={ + @set @get + "onreadystatechange": event_readystatechange => unit, + @get + "readyState": int, + @get + @set + "responseType": string, + @get + "response": Js.null, + @get + "responseText": string, + @get + "responseURL": string, + @get + "responseXML": Js.null, + @get + "status": int, + @get + "statusText": string, + @get + @set + "timeout": float, + @get + "upload": xmlHttpRequestUpload, + @get + @set + "withCredentials": bool, + + /* Base events */ + @get + @set + "onabort": event_abort => unit, + @get + @set + "onerror": event_error => unit, + @get + @set + "onload": event_load => unit, + @get + @set + "onloadstart": event_loadstart => unit, + @get + @set + "onprogress": event_loadstart => unit, + @get + @set + "ontimeout": event_timeout => unit, + @get + @set + "onloadend": event_loadend => unit, +}; + +type t = _xmlhttprequest + + @send external abort: t => unit="abort" + @send external getAllResponseHeaders: (t) => Js.null="getAllResponseHeaders" + //@send external getResponseHeader: string => Js.null="getResponseHeader" + @send external _open: (t,string, string, bool, string, string) => unit="_open" + @send external overrideMimeType: (t,string) => unit="overrideMimeType" + @send external send: t => unit="send" + @send external send__string: (t,Js.null) => unit="send__string" + @send external send__formdata : (t,Web_formdata.t) => unit="send__formdata" + @send external send__document : (t,Web_document.t) => unit="send__document" + /* method send_blob : Web_blob.t -> unit */ + /* method send_arrayBufferView : Web_arraybuffer_view.t -> unit */ + @send external setRequestHeader: (t,string, string) => unit="setRequestHeader" + + + +@new external create: unit => t = "XMLHttpRequest" + +type errors = + | IncompleteResponse + | NetworkError + +type body = + | EmptyBody + | EmptyStringBody + | StringBody(string) + | FormDataBody(Web_formdata.t) + | FormListBody(list<(string, string)>) + | DocumentBody(Web_document.t) +/* | BlobBody of Web_blob.t */ +/* | ArrayBufferViewBody of Web_arraybuffer_view.t */ + +/* Main interface functions */ + +let abort = (x: t): unit => abort(x) + +let getAllResponseHeaders = (x: t): result => { + switch Js.Null.toOption(getAllResponseHeaders(x)) { + | None => Error(IncompleteResponse) + | Some("") => Error(NetworkError) + | Some(s) => Ok(s) + } +} + +let getAllResponseHeadersAsList = (x: t): result, errors> => { + switch getAllResponseHeaders(x) { + | Error(_) as err => err + | Ok(s) => + Ok( + s + |> Js.String.split("\r\n") + |> Array.map(Js.String.splitAtMost(": ", ~limit=2)) + |> Array.to_list + |> List.filter(a => Array.length(a) === 2) + |> List.map(x => + switch x { + | [key, value] => (key, value) + | _ => failwith("Cannot happen, already checked length") + } + ), + ) + } +} + +let getAllResponseHeadersAsDict = (x: t): result, errors> => { + module StringMap = Belt.Map.String + switch getAllResponseHeadersAsList(x) { + | Error(_) as err => err + | Ok(l) => + let insert = (d, (k, v)) => StringMap.set(d,k, v) + Ok(List.fold_left(insert, StringMap.empty, l)) + } +} + +let getResponseHeader = (key, x) => Js.Null.toOption(x["getResponse"](key)) + +let open_ = (method: string, url: string, ~async=true, ~user="", ~password="", x) => + _open(x,method, url, async, user, password) + +let overrideMimeType = (mimetype: string, x: t): unit => overrideMimeType(x,mimetype) + +let send = (body: body, x: t): unit => + switch body { + | EmptyBody => send(x) + | EmptyStringBody => send__string(x,Js.Null.empty) + | StringBody(s) => send__string(x,Js.Null.return(s)) + | FormDataBody(f) => send__formdata(x,f) + | FormListBody(l) => + let form = List.fold_left((f, (key, value)) => { + let () = Web_formdata.append(key, value,f) + f + }, Web_formdata.create(), l) + send__formdata(x,form) + | DocumentBody(d) => send__document(x,d) + } +/* | BlobBody b -> x##send_blob b */ +/* | ArrayBufferViewBody a -> x##send_arrayBufferView a */ + +let setRequestHeader = (header: string, value: string, x: t) => setRequestHeader(x,header, value) + +/* Properties */ + +type state = + | Unsent + | Opened + | HeadersReceived + | Loading + | Done + +type responseType = + | StringResponseType + | ArrayBufferResponseType + | BlobResponseType + | DocumentResponseType + | JsonResponseType + | TextResponseType + | RawResponseType(string) + +type responseBody = + | NoResponse + | StringResponse(string) + | ArrayBufferResponse(unit) + | BlobResponse(unit) + | DocumentResponse(Web_document.t) + | JsonResponse(Web_json.t) + | TextResponse(string) + | RawResponse(string, unit) + +let set_onreadystatechange = (cb: event_readystatechange => unit, x: t): unit => + x["onreadystatechange"] = cb + +let get_onreadystatechange = (x: t): (event_readystatechange => unit) => x["onreadystatechange"] + +let readyState = (x: t): state => + switch x["readyState"] { + | 0 => Unsent + | 1 => Opened + | 2 => HeadersReceived + | 3 => Loading + | 4 => Done + | i => failwith("Invalid return from 'readystate' of: " ++ string_of_int(i)) + } + +let set_responseType = (typ: responseType, x: t): unit => + switch typ { + | StringResponseType => x["responseType"] = "" + | ArrayBufferResponseType => x["responseType"] = "arraybuffer" + | BlobResponseType => x["responseType"] = "blob" + | DocumentResponseType => x["responseType"] = "document" + | JsonResponseType => x["responseType"] = "json" + | TextResponseType => x["responseType"] = "text" + | RawResponseType(s) => x["responseType"] = s + } + +let get_responseType = (x: t): responseType => + switch x["responseType"] { + | "" => StringResponseType + | "arraybuffer" => ArrayBufferResponseType + | "blob" => BlobResponseType + | "document" => DocumentResponseType + | "json" => JsonResponseType + | "text" => TextResponseType + | s => RawResponseType(s) + } + +let get_response = (x: t): responseBody => + switch Js.Null.toOption(x["response"]) { + | None => NoResponse + | Some(resp) => + switch get_responseType(x) { + | StringResponseType => StringResponse(Obj.magic(resp)) + | ArrayBufferResponseType => ArrayBufferResponse(Obj.magic(resp)) + | BlobResponseType => BlobResponse(Obj.magic(resp)) + | DocumentResponseType => DocumentResponse(Obj.magic(resp)) + | JsonResponseType => JsonResponse(Obj.magic(resp)) + | TextResponseType => TextResponse(Obj.magic(resp)) + | RawResponseType(s) => RawResponse(s, Obj.magic(resp)) + } + } + +let get_responseText = (x: t): string => x["responseText"] + +let get_responseURL = (x: t): string => x["responseURL"] + +let get_responseXML = (x: t): option => Js.Null.toOption(x["responseXML"]) + +let get_status = (x: t): int => x["status"] + +let get_statusText = (x: t): string => x["statusText"] + +let set_timeout = (t: float, x: t): unit => x["timeout"] = t + +let get_timeout = (x: t): float => x["timeout"] + +let set_withCredentials = (b: bool, x: t): unit => x["withCredentials"] = b + +let get_withCredentials = (x: t): bool => x["withCredentials"] + +let set_onabort = (cb: event_abort => unit, x: t): unit => x["onabort"] = cb + +let get_onabort = (x: t): (event_abort => unit) => x["onabort"] + +let set_onerror = (cb: event_error => unit, x: t): unit => x["onerror"] = cb + +let get_onerror = (x: t): (event_error => unit) => x["onerror"] + +let set_onload = (cb: event_load => unit, x: t): unit => x["onload"] = cb + +let get_onload = (x: t): (event_load => unit) => x["onload"] + +let set_onloadstart = (cb: event_loadstart => unit, x: t): unit => x["onloadstart"] = cb + +let get_onloadstart = (x: t): (event_loadstart => unit) => x["onloadstart"] + +let set_onprogress = (cb: event_loadstart => unit, x: t): unit => x["onprogress"] = cb + +let get_onprogress = (x: t): (event_loadstart => unit) => x["onprogress"] + +let set_ontimeout = (cb: event_timeout => unit, x: t): unit => x["ontimeout"] = cb + +let get_ontimeout = (x: t): (event_timeout => unit) => x["ontimeout"] + +let set_onloadend = (cb: event_loadend => unit, x: t): unit => x["onloadend"] = cb + +let get_onloadend = (x: t): (event_loadend => unit) => x["onloadend"] diff --git a/src/web_xmlhttprequest.resi b/src/web_xmlhttprequest.resi new file mode 100644 index 0000000..ed507b3 --- /dev/null +++ b/src/web_xmlhttprequest.resi @@ -0,0 +1,167 @@ +type unresolved + +type xmlHttpRequestUpload + +type event_readystatechange = Web_json.t + +type event_abort = Web_json.t + +type event_error = Web_json.t + +type event_load = Web_json.t + +type event_loadstart = Web_json.t + +type event_progress = Web_json.t + +type event_timeout = Web_json.t + +type event_loadend = Web_json.t + +type _xmlhttprequest = { + "onabort": event_abort => unit, + "onabort#=": Js_OO.Meth.arity1<(event_abort => unit) => unit>, + "onerror": event_error => unit, + "onerror#=": Js_OO.Meth.arity1<(event_error => unit) => unit>, + "onload": event_load => unit, + "onload#=": Js_OO.Meth.arity1<(event_load => unit) => unit>, + "onloadend": event_loadend => unit, + "onloadend#=": Js_OO.Meth.arity1<(event_loadend => unit) => unit>, + "onloadstart": event_loadstart => unit, + "onloadstart#=": Js_OO.Meth.arity1<(event_loadstart => unit) => unit>, + "onprogress": event_loadstart => unit, + "onprogress#=": Js_OO.Meth.arity1<(event_loadstart => unit) => unit>, + "onreadystatechange": event_readystatechange => unit, + "onreadystatechange#=": Js_OO.Meth.arity1<(event_readystatechange => unit) => unit>, + "ontimeout": event_timeout => unit, + "ontimeout#=": Js_OO.Meth.arity1<(event_timeout => unit) => unit>, + "readyState": int, + "response": Js.null, + "responseText": string, + "responseType": string, + "responseType#=": Js_OO.Meth.arity1 unit>, + "responseURL": string, + "responseXML": Js.null, + "status": int, + "statusText": string, + "timeout": float, + "timeout#=": Js_OO.Meth.arity1 unit>, + "upload": xmlHttpRequestUpload, + "withCredentials": bool, + "withCredentials#=": Js_OO.Meth.arity1 unit>, +} + +type t = _xmlhttprequest + @send external _open: (t,string, string, bool, string, string) => unit="_open" + @send external send__string: (t,Js.null) => unit="send__string" + @send external send__formdata : (t,Web_formdata.t) => unit="send__formdata" + @send external send__document : (t,Web_document.t) => unit="send__document" + +@new external create: unit => t = "XMLHttpRequest" + +type errors = IncompleteResponse | NetworkError + +type body = + | EmptyBody + | EmptyStringBody + | StringBody(string) + | FormDataBody(Web_formdata.t) + | FormListBody(list<(string, string)>) + | DocumentBody(Web_document.t) + +let abort: t => unit + +let getAllResponseHeaders: t => result + +let getAllResponseHeadersAsList: t => result, errors> + +let getAllResponseHeadersAsDict: t => result, errors> + +let getResponseHeader: ('msg, {.."getResponse": 'msg => Js.Null.t<'b>}) => option<'b> + +let open_: (string, string, ~async: bool=?, ~user: string=?, ~password: string=?, t) => unit + +let overrideMimeType: (string, t) => unit + +let send: (body, t) => unit + +let setRequestHeader: (string, string, t) => unit + +type state = Unsent | Opened | HeadersReceived | Loading | Done + +type responseType = + | StringResponseType + | ArrayBufferResponseType + | BlobResponseType + | DocumentResponseType + | JsonResponseType + | TextResponseType + | RawResponseType(string) + +type responseBody = + | NoResponse + | StringResponse(string) + | ArrayBufferResponse(unit) + | BlobResponse(unit) + | DocumentResponse(Web_document.t) + | JsonResponse(Web_json.t) + | TextResponse(string) + | RawResponse(string, unit) + +let set_onreadystatechange: (event_readystatechange => unit, t) => unit + +let get_onreadystatechange: (t, event_readystatechange) => unit + +let readyState: t => state + +let set_responseType: (responseType, t) => unit + +let get_responseType: t => responseType + +let get_response: t => responseBody + +let get_responseText: t => string + +let get_responseURL: t => string + +let get_responseXML: t => option + +let get_status: t => int + +let get_statusText: t => string + +let set_timeout: (float, t) => unit + +let get_timeout: t => float + +let set_withCredentials: (bool, t) => unit + +let get_withCredentials: t => bool + +let set_onabort: (event_abort => unit, t) => unit + +let get_onabort: (t, event_abort) => unit + +let set_onerror: (event_error => unit, t) => unit + +let get_onerror: (t, event_error) => unit + +let set_onload: (event_load => unit, t) => unit + +let get_onload: (t, event_load) => unit + +let set_onloadstart: (event_loadstart => unit, t) => unit + +let get_onloadstart: (t, event_loadstart) => unit + +let set_onprogress: (event_loadstart => unit, t) => unit + +let get_onprogress: (t, event_loadstart) => unit + +let set_ontimeout: (event_timeout => unit, t) => unit + +let get_ontimeout: (t, event_timeout) => unit + +let set_onloadend: (event_loadend => unit, t) => unit + +let get_onloadend: (t, event_loadend) => unit diff --git a/test-ocaml/test_client.ml b/test-ocaml/test_client.ml deleted file mode 100644 index b5363f4..0000000 --- a/test-ocaml/test_client.ml +++ /dev/null @@ -1,9 +0,0 @@ -let counter = let open Test_client_counter in main -let counter_debug_beginner = let open Test_client_counter_debug_beginner in main -let counter_debug_standard = let open Test_client_counter_debug_standard in main -let counter_debug_program = let open Test_client_counter_debug_program in main -let btn_update_span = let open Test_client_btn_update_span in main -let attribute_removal = let open Test_client_attribute_removal in main -let drag = let open Test_client_drag in main -let on_with_options = let open Test_client_on_with_options in main -let http_task = let open Test_client_http_task in main diff --git a/test-ocaml/test_client_attribute_removal.ml b/test-ocaml/test_client_attribute_removal.ml deleted file mode 100644 index 917fb2b..0000000 --- a/test-ocaml/test_client_attribute_removal.ml +++ /dev/null @@ -1,63 +0,0 @@ -open Tea.App -open Tea.Html - -type model = { - selected: string option; - languages: string list -} - -type message = - | Select of string - | Delete -[@@bs.deriving {accessors}] - -let render_selected = function - | Some selected -> - div [] - [ text ("you selected " ^ selected) - ; div [onClick Delete] [text "delete selection"]] - | None -> div [] [text "Nothing selected"] - -(* let lang l is_selected = - * let baseProps = [onClick (Select l); style "color" "blue"] in - * let props = if is_selected == true then (style "border" "1px solid black")::baseProps else baseProps - * in - * li props [text l] *) - -let lang l is_selected = - li - [ onClick (Select l) - ; style "color" "blue" - ; if is_selected then style "border" "1px solid black" else noProp - ; if is_selected then Vdom.attribute "" "lang" l else noProp - ] - [ text l ] - -let render_languages selected languages = - let is_selected selected language = - match selected with - | Some l -> language == l - | None -> false - in - let rendered = List.map (fun l -> lang l (is_selected selected l)) languages in - ul [] rendered - -let update state = function - | Select lang -> { state with selected = Some lang} - | Delete -> { state with selected = None } - -let view state = - div [] - [ render_selected state.selected - ; render_languages state.selected state.languages] - -let main = - let initialState = { - selected = Some "Erlang"; - languages = ["Erlang"; "Ocaml"; "Clojure"] - } in - beginnerProgram { - model = initialState; - update; - view; - } diff --git a/test-ocaml/test_client_btn_update_span.ml b/test-ocaml/test_client_btn_update_span.ml deleted file mode 100644 index cb0578e..0000000 --- a/test-ocaml/test_client_btn_update_span.ml +++ /dev/null @@ -1,34 +0,0 @@ -open Tea.App -open Tea.Html - -type msg = - | Trigger -[@@bs.deriving {accessors}] - -type model = (string option * string option) - -let update' model = function - | Trigger -> - let (left, _) = model in - (left, Some "right") - -let render_model = function - | (Some _, Some _) -> - input' [value "This should be on screen"] [] - | _ -> - span [] [text "nothing"] - -let view' model = - div [] - [ button [onClick Trigger] [text "trigger rerender"] - ; render_model model - ] - - - -let main = - beginnerProgram { - model = (Some "left", None); - update = update'; - view = view' - } diff --git a/test-ocaml/test_client_counter.ml b/test-ocaml/test_client_counter.ml deleted file mode 100644 index 9d8c613..0000000 --- a/test-ocaml/test_client_counter.ml +++ /dev/null @@ -1,51 +0,0 @@ -open Tea.App -open Tea.Html - -type msg = - | Increment - | Decrement - | Reset - | Set of int - -let update model = function - | Increment -> model + 1 - | Decrement -> model - 1 - | Reset -> 0 - | Set v -> v - - -let view_button title msg = - button - [ onClick msg - ] - [ text title - ] - -let view model = - div - [] - [ span - [ style "text-weight" "bold" ] - [ text (string_of_int model) ] - ; br [] - ; view_button "Increment" ( - if model >= 3 then - Decrement - else - Increment - ) - ; br [] - ; view_button "Decrement" Decrement - ; br [] - ; view_button "Set to 42" (Set 42) - ; br [] - ; if model <> 0 then view_button "Reset" Reset else noNode - ] - - -let main = - beginnerProgram { - model = 4; - update; - view; - } diff --git a/test-ocaml/test_client_counter_debug_beginner.ml b/test-ocaml/test_client_counter_debug_beginner.ml deleted file mode 100644 index 1bcd059..0000000 --- a/test-ocaml/test_client_counter_debug_beginner.ml +++ /dev/null @@ -1,56 +0,0 @@ -open Tea.App -open Tea.Html - -type msg = - | Increment - | Decrement - | Reset - | Set of int - -let string_of_msg = function - | Increment -> "Increment" - | Decrement -> "Decrement" - | Reset -> "Reset" - | Set _ -> "Set" - -let update model = function - | Increment -> model + 1 - | Decrement -> model - 1 - | Reset -> 0 - | Set v -> v - - -let view_button title msg = - button - [ onClick msg - ] - [ text title - ] - -let view model = - div - [] - [ span - [ style "text-weight" "bold" ] - [ text (string_of_int model) ] - ; br [] - ; view_button "Increment" ( - if model >= 3 then - Decrement - else - Increment - ) - ; br [] - ; view_button "Decrement" Decrement - ; br [] - ; view_button "Set to 42" (Set 42) - ; br [] - ; if model <> 0 then view_button "Reset" Reset else noNode - ] - -let main = - Tea.Debug.beginnerProgram { - model = 4; - update; - view; - } string_of_msg diff --git a/test-ocaml/test_client_counter_debug_program.ml b/test-ocaml/test_client_counter_debug_program.ml deleted file mode 100644 index fbf27ca..0000000 --- a/test-ocaml/test_client_counter_debug_program.ml +++ /dev/null @@ -1,62 +0,0 @@ -open Tea.App -open Tea.Html - -type msg = - | Increment - | Decrement - | Reset - | Set of int - -let string_of_msg = function - | Increment -> "Increment" - | Decrement -> "Decrement" - | Reset -> "Reset" - | Set _ -> "Set" - -let init () = 4, Tea.Cmd.none - -let subscriptions _ = Tea.Sub.none - -let update model = function - | Increment -> model + 1, Tea.Cmd.none - | Decrement -> model - 1, Tea.Cmd.none - | Reset -> 0, Tea.Cmd.none - | Set v -> v, Tea.Cmd.none - - -let view_button title msg = - button - [ onClick msg - ] - [ text title - ] - -let view model = - div - [] - [ span - [ style "text-weight" "bold" ] - [ text (string_of_int model) ] - ; br [] - ; view_button "Increment" ( - if model >= 3 then - Decrement - else - Increment - ) - ; br [] - ; view_button "Decrement" Decrement - ; br [] - ; view_button "Set to 42" (Set 42) - ; br [] - ; if model <> 0 then view_button "Reset" Reset else noNode - ] - -let main = - Tea.Debug.program { - init; - update; - view; - subscriptions; - shutdown = (fun _model -> Tea.Cmd.none); - } string_of_msg diff --git a/test-ocaml/test_client_counter_debug_standard.ml b/test-ocaml/test_client_counter_debug_standard.ml deleted file mode 100644 index d6320a6..0000000 --- a/test-ocaml/test_client_counter_debug_standard.ml +++ /dev/null @@ -1,61 +0,0 @@ -open Tea.App -open Tea.Html - -type msg = - | Increment - | Decrement - | Reset - | Set of int - -let string_of_msg = function - | Increment -> "Increment" - | Decrement -> "Decrement" - | Reset -> "Reset" - | Set _ -> "Set" - -let init () = 4, Tea.Cmd.none - -let subscriptions _ = Tea.Sub.none - -let update model = function - | Increment -> model + 1, Tea.Cmd.none - | Decrement -> model - 1, Tea.Cmd.none - | Reset -> 0, Tea.Cmd.none - | Set v -> v, Tea.Cmd.none - - -let view_button title msg = - button - [ onClick msg - ] - [ text title - ] - -let view model = - div - [] - [ span - [ style "text-weight" "bold" ] - [ text (string_of_int model) ] - ; br [] - ; view_button "Increment" ( - if model >= 3 then - Decrement - else - Increment - ) - ; br [] - ; view_button "Decrement" Decrement - ; br [] - ; view_button "Set to 42" (Set 42) - ; br [] - ; if model <> 0 then view_button "Reset" Reset else noNode - ] - -let main = - Tea.Debug.standardProgram { - init; - update; - view; - subscriptions; - } string_of_msg diff --git a/test-ocaml/test_client_drag.ml b/test-ocaml/test_client_drag.ml deleted file mode 100644 index 767b04a..0000000 --- a/test-ocaml/test_client_drag.ml +++ /dev/null @@ -1,110 +0,0 @@ -open Tea -open Tea.App -open Tea.Html -open Tea.Mouse - -type msg = - | DragStart of position - | DragAt of position - | DragEnd of position -[@@bs.deriving {accessors}] - - -type drag = - { start : position - ; current : position - } - -type model = - { position : position - ; drag : drag option - } - - -let init () = - ( {position = {x = 200; y = 200}; drag = None}, Cmd.none ) - -let getPosition {position; drag} = - match drag with - | None -> - position - - | Some {start; current} -> - { x = position.x + current.x - start.x - ; y = position.y + current.y - start.y - } - - -let updateHelp ({position} as model) = function - | DragStart xy -> - { position - ; drag = Some {start = xy; current = xy} - } - - | DragAt xy -> - { position - ; drag = match model.drag with - | None -> None - | Some drag -> Some {drag with current = xy} - } - - | DragEnd _ -> - { position = getPosition model - ; drag = None - } - - -let update model msg = - ( updateHelp model msg, Cmd.none ) - - -let subscriptions model = - match model.drag with - | None -> - Sub.none - - | Some _ -> - Sub.batch [ Mouse.moves dragAt; Mouse.ups dragEnd ] - - -let px number = - (string_of_int number) ^ "px" - -let onMouseDown = - onCB "mousedown" "" (fun ev -> - Json.Decoder.decodeEvent (Json.Decoder.map dragStart Mouse.position) ev - |> Result.result_to_option - ) - -let view model = - let realPosition = getPosition model in - div - [ onMouseDown - ; styles - [ "background-color", "#3C8D2F" - ; "cursor", "move" - - ; "width", "100px" - ; "height", "100px" - ; "border-radius", "4px" - ; "position", "absolute" - ; "left", px realPosition.x - ; "top", px realPosition.y - - ; "color", "white" - ; "display", "flex" - ; "align-items", "center" - ; "justify-content", "center" - ] - ] - [ text "Drag Me!" - ] - - -let main = - standardProgram { - init; - update; - view; - subscriptions; - } diff --git a/test-ocaml/test_client_http_task.ml b/test-ocaml/test_client_http_task.ml deleted file mode 100644 index 661943f..0000000 --- a/test-ocaml/test_client_http_task.ml +++ /dev/null @@ -1,39 +0,0 @@ -open Tea -open Tea.Html -type ('ok,'err) result = ('ok,'err) Tea_result.t - -type msg = - | GotResponse of (string, string) result - | Req - [@@bs.deriving accessors] - -let update model = function - | GotResponse (Ok t) -> t, Cmd.none - | GotResponse (Error t) -> t, Cmd.none - | Req -> model, - Http.getString "https://jsonplaceholder.typicode.com/todos/1" |> Http.toTask |> Task.mapError Http.string_of_error - |> Task.andThen (fun res -> Ex.LocalStorage.setItem "todo-1" res) - |> Task.andThen (fun () -> Http.getString "https://jsonplaceholder.typicode.com/todos/2" |> Http.toTask |> Task.mapError Http.string_of_error) - |> Task.andThen (fun res -> Ex.LocalStorage.setItem "todo-2" res) - |> Task.andThen (fun () -> Task.succeed "both saved") - |> Task.attempt gotResponse - - -let view model = - div [] [ - button [onClick Req] [text "execute"]; - text model; - ] - -let som = function - | GotResponse (Ok _) -> "GotResponse Ok" - | GotResponse (Error _) -> "GotResponse Error" - | Req -> "Req" - -let main = - Tea.Debug.standardProgram { - init = (fun () -> "nothing", Cmd.none); - subscriptions = (fun _ -> Sub.none); - update; - view; - } som diff --git a/test-ocaml/test_client_on_with_options.ml b/test-ocaml/test_client_on_with_options.ml deleted file mode 100644 index 0531161..0000000 --- a/test-ocaml/test_client_on_with_options.ml +++ /dev/null @@ -1,39 +0,0 @@ -open Tea.App - -type msg = - | Click - | Set_value of int - [@@bs.deriving {accessors}] - - -let update model = function - | Click -> model + 1 - | Set_value n -> n - - -let view model = - let open Tea.Html2 in - let open Tea.Html2.Attributes in - let open Tea.Html2.Events in - let open Tea.Json in - let clientX = Decoder.field "clientX" Decoder.int in - div [] (List.map (fun e -> div [] [e]) [ - model |> string_of_int |> text; - button [onClick Click] [text "onClick"]; - button [on ~key:"" "click" (Decoder.succeed Click)] [text "on \"click\""]; - a [href "https://www.google.com"] [text "a normal link"]; - a [ - href "https://www.google.com"; - onWithOptions ~key:"" "click" { defaultOptions with preventDefault = true } (Tea.Json.Decoder.succeed Click); - ] [text "a link with prevent default"]; - button [on ~key:"" "click" (Decoder.map set_value clientX)] [text "on \"click\", use clientX value"]; - input' [type' "text"; on ~key:"" "input" (Decoder.map (fun v -> v |> int_of_string |> set_value) targetValue)] []; - ]) - - -let main = - beginnerProgram { - model = 0; - update; - view; - } diff --git a/test-reason/test_client.re b/test-reason/test_client.re deleted file mode 100644 index 0ad049b..0000000 --- a/test-reason/test_client.re +++ /dev/null @@ -1,9 +0,0 @@ -let counter = Test_client_counter.(main); -let counter_debug_beginner = Test_client_counter_debug_beginner.(main); -let counter_debug_standard = Test_client_counter_debug_standard.(main); -let counter_debug_program = Test_client_counter_debug_program.(main); -let btn_update_span = Test_client_btn_update_span.(main); -let attribute_removal = Test_client_attribute_removal.(main); -let drag = Test_client_drag.(main); -let on_with_options = Test_client_on_with_options.(main); -let http_task = Test_client_http_task.(main); diff --git a/test-reason/test_client_attribute_removal.re b/test-reason/test_client_attribute_removal.re deleted file mode 100644 index 5451a75..0000000 --- a/test-reason/test_client_attribute_removal.re +++ /dev/null @@ -1,82 +0,0 @@ -open Tea.App; - -open Tea.Html; - -type model = { - selected: option(string), - languages: list(string), -}; - -[@bs.deriving {accessors: accessors}] -type message = - | Select(string) - | Delete; - -let render_selected = - fun - | Some(selected) => - div( - [], - [ - text("you selected " ++ selected), - div([onClick(Delete)], [text("delete selection")]), - ], - ) - | None => div([], [text("Nothing selected")]); - -/* let lang l is_selected = - * let baseProps = [onClick (Select l); style "color" "blue"] in - * let props = if is_selected == true then (style "border" "1px solid black")::baseProps else baseProps - * in - * li props [text l] */ -let lang = (l, is_selected) => - li( - [ - onClick(Select(l)), - style("color", "blue"), - if (is_selected) { - style("border", "1px solid black"); - } else { - noProp; - }, - if (is_selected) { - Vdom.attribute("", "lang", l); - } else { - noProp; - }, - ], - [text(l)], - ); - -let render_languages = (selected, languages) => { - let is_selected = (selected, language) => - switch (selected) { - | Some(l) => language === l - | None => false - }; - let rendered = - List.map(l => lang(l, is_selected(selected, l)), languages); - ul([], rendered); -}; - -let update = state => - fun - | Select(lang) => {...state, selected: Some(lang)} - | Delete => {...state, selected: None}; - -let view = state => - div( - [], - [ - render_selected(state.selected), - render_languages(state.selected, state.languages), - ], - ); - -let main = { - let initialState = { - selected: Some("Erlang"), - languages: ["Erlang", "Ocaml", "Clojure"], - }; - beginnerProgram({model: initialState, update, view}); -}; diff --git a/test-reason/test_client_btn_update_span.re b/test-reason/test_client_btn_update_span.re deleted file mode 100644 index fb32ee2..0000000 --- a/test-reason/test_client_btn_update_span.re +++ /dev/null @@ -1,37 +0,0 @@ -open Tea.App; - -open Tea.Html; - -[@bs.deriving {accessors: accessors}] -type msg = - | Trigger; - -type model = (option(string), option(string)); - -let update' = model => - fun - | Trigger => { - let (left, _) = model; - (left, Some("right")); - }; - -let render_model = - fun - | (Some(_), Some(_)) => input'([value("This should be on screen")], []) - | _ => span([], [text("nothing")]); - -let view' = model => - div( - [], - [ - button([onClick(Trigger)], [text("trigger rerender")]), - render_model(model), - ], - ); - -let main = - beginnerProgram({ - model: (Some("left"), None), - update: update', - view: view', - }); diff --git a/test-reason/test_client_counter.re b/test-reason/test_client_counter.re deleted file mode 100644 index 5f1c869..0000000 --- a/test-reason/test_client_counter.re +++ /dev/null @@ -1,47 +0,0 @@ -open Tea.App; - -open Tea.Html; - -type msg = - | Increment - | Decrement - | Reset - | Set(int); - -let update = model => - fun - | Increment => model + 1 - | Decrement => model - 1 - | Reset => 0 - | Set(v) => v; - -let view_button = (title, msg) => button([onClick(msg)], [text(title)]); - -let view = model => - div( - [], - [ - span([style("text-weight", "bold")], [text(string_of_int(model))]), - br([]), - view_button( - "Increment", - if (model >= 3) { - Decrement; - } else { - Increment; - }, - ), - br([]), - view_button("Decrement", Decrement), - br([]), - view_button("Set to 42", Set(42)), - br([]), - if (model != 0) { - view_button("Reset", Reset); - } else { - noNode; - }, - ], - ); - -let main = beginnerProgram({model: 4, update, view}); diff --git a/test-reason/test_client_counter_debug_beginner.re b/test-reason/test_client_counter_debug_beginner.re deleted file mode 100644 index a981145..0000000 --- a/test-reason/test_client_counter_debug_beginner.re +++ /dev/null @@ -1,55 +0,0 @@ -open Tea.App; - -open Tea.Html; - -type msg = - | Increment - | Decrement - | Reset - | Set(int); - -let string_of_msg = - fun - | Increment => "Increment" - | Decrement => "Decrement" - | Reset => "Reset" - | Set(_) => "Set"; - -let update = model => - fun - | Increment => model + 1 - | Decrement => model - 1 - | Reset => 0 - | Set(v) => v; - -let view_button = (title, msg) => button([onClick(msg)], [text(title)]); - -let view = model => - div( - [], - [ - span([style("text-weight", "bold")], [text(string_of_int(model))]), - br([]), - view_button( - "Increment", - if (model >= 3) { - Decrement; - } else { - Increment; - }, - ), - br([]), - view_button("Decrement", Decrement), - br([]), - view_button("Set to 42", Set(42)), - br([]), - if (model != 0) { - view_button("Reset", Reset); - } else { - noNode; - }, - ], - ); - -let main = - Tea.Debug.beginnerProgram({model: 4, update, view}, string_of_msg); diff --git a/test-reason/test_client_counter_debug_program.re b/test-reason/test_client_counter_debug_program.re deleted file mode 100644 index 3b4f3be..0000000 --- a/test-reason/test_client_counter_debug_program.re +++ /dev/null @@ -1,62 +0,0 @@ -open Tea.App; - -open Tea.Html; - -type msg = - | Increment - | Decrement - | Reset - | Set(int); - -let string_of_msg = - fun - | Increment => "Increment" - | Decrement => "Decrement" - | Reset => "Reset" - | Set(_) => "Set"; - -let init = () => (4, Tea.Cmd.none); - -let subscriptions = (_) => Tea.Sub.none; - -let update = model => - fun - | Increment => (model + 1, Tea.Cmd.none) - | Decrement => (model - 1, Tea.Cmd.none) - | Reset => (0, Tea.Cmd.none) - | Set(v) => (v, Tea.Cmd.none); - -let view_button = (title, msg) => button([onClick(msg)], [text(title)]); - -let view = model => - div( - [], - [ - span([style("text-weight", "bold")], [text(string_of_int(model))]), - br([]), - view_button( - "Increment", - if (model >= 3) { - Decrement; - } else { - Increment; - }, - ), - br([]), - view_button("Decrement", Decrement), - br([]), - view_button("Set to 42", Set(42)), - br([]), - if (model != 0) { - view_button("Reset", Reset); - } else { - noNode; - }, - ], - ); - -let main = - Tea.Debug.program( - {init, update, view, subscriptions, shutdown: _model => Tea.Cmd.none}, - string_of_msg, - ); diff --git a/test-reason/test_client_counter_debug_standard.re b/test-reason/test_client_counter_debug_standard.re deleted file mode 100644 index 8312582..0000000 --- a/test-reason/test_client_counter_debug_standard.re +++ /dev/null @@ -1,62 +0,0 @@ -open Tea.App; - -open Tea.Html; - -type msg = - | Increment - | Decrement - | Reset - | Set(int); - -let string_of_msg = - fun - | Increment => "Increment" - | Decrement => "Decrement" - | Reset => "Reset" - | Set(_) => "Set"; - -let init = () => (4, Tea.Cmd.none); - -let subscriptions = (_) => Tea.Sub.none; - -let update = model => - fun - | Increment => (model + 1, Tea.Cmd.none) - | Decrement => (model - 1, Tea.Cmd.none) - | Reset => (0, Tea.Cmd.none) - | Set(v) => (v, Tea.Cmd.none); - -let view_button = (title, msg) => button([onClick(msg)], [text(title)]); - -let view = model => - div( - [], - [ - span([style("text-weight", "bold")], [text(string_of_int(model))]), - br([]), - view_button( - "Increment", - if (model >= 3) { - Decrement; - } else { - Increment; - }, - ), - br([]), - view_button("Decrement", Decrement), - br([]), - view_button("Set to 42", Set(42)), - br([]), - if (model != 0) { - view_button("Reset", Reset); - } else { - noNode; - }, - ], - ); - -let main = - Tea.Debug.standardProgram( - {init, update, view, subscriptions}, - string_of_msg, - ); diff --git a/test-reason/test_client_drag.re b/test-reason/test_client_drag.re deleted file mode 100644 index bde3af1..0000000 --- a/test-reason/test_client_drag.re +++ /dev/null @@ -1,95 +0,0 @@ -open Tea; - -open Tea.App; - -open Tea.Html; - -open Tea.Mouse; - -[@bs.deriving {accessors: accessors}] -type msg = - | DragStart(position) - | DragAt(position) - | DragEnd(position); - -type drag = { - start: position, - current: position, -}; - -type model = { - position, - drag: option(drag), -}; - -let init = () => ({ - position: { - x: 200, - y: 200, - }, - drag: None, - }, Cmd.none); - -let getPosition = ({position, drag}) => - switch (drag) { - | None => position - | Some({start, current}) => { - x: position.x + current.x - start.x, - y: position.y + current.y - start.y, - } - }; - -let updateHelp = ({position} as model) => - fun - | DragStart(xy) => {position, drag: Some({start: xy, current: xy})} - | DragAt(xy) => { - position, - drag: - switch (model.drag) { - | None => None - | Some(drag) => Some({...drag, current: xy}) - }, - } - | DragEnd(_) => {position: getPosition(model), drag: None}; - -let update = (model, msg) => (updateHelp(model, msg), Cmd.none); - -let subscriptions = model => - switch (model.drag) { - | None => Sub.none - | Some(_) => Sub.batch([Mouse.moves(dragAt), Mouse.ups(dragEnd)]) - }; - -let px = number => string_of_int(number) ++ "px"; - -let onMouseDown = - onCB("mousedown", "", ev => - Json.Decoder.decodeEvent(Json.Decoder.map(dragStart, Mouse.position), ev) - |> Result.result_to_option - ); - -let view = model => { - let realPosition = getPosition(model); - div( - [ - onMouseDown, - styles([ - ("background-color", "#3C8D2F"), - ("cursor", "move"), - ("width", "100px"), - ("height", "100px"), - ("border-radius", "4px"), - ("position", "absolute"), - ("left", px(realPosition.x)), - ("top", px(realPosition.y)), - ("color", "white"), - ("display", "flex"), - ("align-items", "center"), - ("justify-content", "center"), - ]), - ], - [text("Drag Me!")], - ); -}; - -let main = standardProgram({init, update, view, subscriptions}); diff --git a/test-reason/test_client_http_task.re b/test-reason/test_client_http_task.re deleted file mode 100644 index c435e5b..0000000 --- a/test-reason/test_client_http_task.re +++ /dev/null @@ -1,48 +0,0 @@ -open Tea; -open Tea.Html; -type result('ok, 'err) = Tea_result.t('ok, 'err); - -[@bs.deriving accessors] -type msg = - | GotResponse(result(string, string)) - | Req; - -let update = model => - fun - | GotResponse(Ok(t)) => (t, Cmd.none) - | GotResponse(Error(t)) => (t, Cmd.none) - | Req => ( - model, - Http.getString("https://jsonplaceholder.typicode.com/todos/1") - |> Http.toTask - |> Task.mapError(Http.string_of_error) - |> Task.andThen(res => Ex.LocalStorage.setItem("todo-1", res)) - |> Task.andThen(() => - Http.getString("https://jsonplaceholder.typicode.com/todos/2") - |> Http.toTask - |> Task.mapError(Http.string_of_error) - ) - |> Task.andThen(res => Ex.LocalStorage.setItem("todo-2", res)) - |> Task.andThen(() => Task.succeed("both saved")) - |> Task.attempt(gotResponse), - ); - -let view = model => - div([], [button([onClick(Req)], [text("execute")]), text(model)]); - -let som = - fun - | GotResponse(Ok(_)) => "GotResponse Ok" - | GotResponse(Error(_)) => "GotResponse Error" - | Req => "Req"; - -let main = - Tea.Debug.standardProgram( - { - init: () => ("nothing", Cmd.none), - subscriptions: _ => Sub.none, - update, - view, - }, - som, - ); diff --git a/test-reason/test_client_on_with_options.re b/test-reason/test_client_on_with_options.re deleted file mode 100644 index e0d7d12..0000000 --- a/test-reason/test_client_on_with_options.re +++ /dev/null @@ -1,63 +0,0 @@ -open Tea.App; - -[@bs.deriving {accessors: accessors}] -type msg = - | Click - | Set_value(int); - -let update = model => - fun - | Click => model + 1 - | Set_value(n) => n; - -let view = model => { - open Tea.Html2; - open Tea.Html2.Attributes; - open Tea.Html2.Events; - open Tea.Json; - let clientX = Decoder.field("clientX", Decoder.int); - div( - [], - List.map( - e => div([], [e]), - [ - model |> string_of_int |> text, - button([onClick(Click)], [text("onClick")]), - button( - [on(~key="", "click", Decoder.succeed(Click))], - [text("on \"click\"")], - ), - a([href("https://www.google.com")], [text("a normal link")]), - a( - [ - href("https://www.google.com"), - onWithOptions( - ~key="", - "click", - {...defaultOptions, preventDefault: true}, - Tea.Json.Decoder.succeed(Click), - ), - ], - [text("a link with prevent default")], - ), - button( - [on(~key="", "click", Decoder.map(set_value, clientX))], - [text("on \"click\", use clientX value")], - ), - input'( - [ - type'("text"), - on( - ~key="", - "input", - Decoder.map(v => v |> int_of_string |> set_value, targetValue), - ), - ], - [], - ), - ], - ), - ); -}; - -let main = beginnerProgram({model: 0, update, view}); diff --git a/test-reason/tester.re b/test-reason/tester.re deleted file mode 100644 index 8ca5ca2..0000000 --- a/test-reason/tester.re +++ /dev/null @@ -1 +0,0 @@ -let a = 42; diff --git a/test/counter.res b/test/counter.res new file mode 100644 index 0000000..c968913 --- /dev/null +++ b/test/counter.res @@ -0,0 +1,43 @@ +open Tea.Html +open Tea.Html.Events + + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +type model = int + +let init = () => 4 + +let update = (model, x) => + switch x { + | Increment => model + 1 + | Decrement => model - 1 + | Reset => 0 + | Set(v) => v + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = (lift, model) => + div( + list{Tea.Html.Attributes.styles(list{("display", "inline-block"), ("vertical-align", "top")})}, + list{ + span(list{Tea.Html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button("Increment", lift(Increment)), + br(list{}), + view_button("Decrement", lift(Decrement)), + br(list{}), + view_button("Set to 42", lift(Set(42))), + br(list{}), + if model != 0 { + view_button("Reset", lift(Reset)) + } else { + noNode + }, + }, + ) diff --git a/test/counterParts.res b/test/counterParts.res new file mode 100644 index 0000000..665fa26 --- /dev/null +++ b/test/counterParts.res @@ -0,0 +1,85 @@ +open Tea +open Tea_html +open Tea.Html.Events + +type msg = + | Increment(int) + | Decrement(int) + | Reset(int) + | Set(int, int) + | Shutdown(int) + +module IntMap = Map.Make({ + type t = int + let compare = compare +}) + +type model<'parentMsg> = { + values: IntMap.t, + defaultValue: int, + lift: msg => 'parentMsg, +} + +let init = (defaultValue, lift) => { + values: IntMap.empty, + defaultValue: defaultValue, + lift: lift, +} + +let get_value = (id, model) => + if IntMap.mem(id, model.values) { + IntMap.find(id, model.values) + } else { + model.defaultValue + } + +let put_value = (id, value, model) => { + ...model, + values: IntMap.add(id, value, model.values), +} + +let mutate_value = (id, op, model) => { + let value = get_value(id, model) + put_value(id, op(value), model) +} + +let remove_value = (id, model) => { + ...model, + values: IntMap.remove(id, model.values), +} + +let update = (model, x) => + switch x { + | Increment(id) => mutate_value(id, \"+"(1), model) + | Decrement(id) => mutate_value(id, i => i - 1, model) + | Reset(id) => put_value(id, 0, model) + | Set(id, v) => put_value(id, v, model) + | Shutdown(id) => remove_value(id, model) + } + +let shutdown = (model, id) => Cmd.msg(model.lift(Shutdown(id))) + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = (id, model) => { + let lift = model.lift + let value = get_value(id, model) + div( + list{Tea.Html.Attributes.styles(list{("display", "inline-block"), ("vertical-align", "top")})}, + list{ + span(list{Tea.Html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(value))}), + br(list{}), + view_button("Increment", lift(Increment(id))), + br(list{}), + view_button("Decrement", lift(Decrement(id))), + br(list{}), + view_button("Set to 42", lift(Set(id, 42))), + br(list{}), + if value != 0 { + view_button("Reset", lift(Reset(id))) + } else { + noNode + }, + }, + ) +} diff --git a/test/effect_time.res b/test/effect_time.res new file mode 100644 index 0000000..d66ae9e --- /dev/null +++ b/test/effect_time.res @@ -0,0 +1,17 @@ +open Tea + +type time = float + +type mySub<'msg> = Every(time, time => 'msg) + +type myCmd<'msg> = Delay(time, unit => 'msg) + +let every = (interval, tagger) => Every(interval, tagger) + +let delay = (msTime, msg) => + Cmd.call(callbacks => { + let _unhandledID = Web.Window.setTimeout(() => { + open Vdom + callbacks.contents.enqueue(msg) + }, msTime) + }) diff --git a/test/fib.res b/test/fib.res new file mode 100644 index 0000000..e7fd016 --- /dev/null +++ b/test/fib.res @@ -0,0 +1,9 @@ +let fib = n => { + let rec aux = (n, a, b) => + if n == 0 { + a + } else { + aux(n - 1, b, a + b) + } + aux(n, 1, 1) +} diff --git a/test-ocaml/index.html b/test/index.html similarity index 100% rename from test-ocaml/index.html rename to test/index.html diff --git a/test/main_bookreader.res b/test/main_bookreader.res new file mode 100644 index 0000000..76b7c30 --- /dev/null +++ b/test/main_bookreader.res @@ -0,0 +1,196 @@ +/* https://gist.github.com/pablohirafuji/fa373d07c42016756d5bca28962008c4 */ + +open Tea +open Tea.Html.Events + + +module Progress = Http.Progress + +type model = { + progress: Progress.t, + bookUrl: option, + bookContent: string, +} + +let initModel = { + progress: Progress.emptyProgress, + bookUrl: None, + bookContent: "", +} + +let init = () => (initModel, Cmd.none) + +type msg = + | NoOp + | GetBook(string) + | GetBookProgress(string, Progress.t) + | GetBookDone(string, string) + +let subscriptions = _model => Sub.none + +let progressHelper = b => { + open Progress + {bytes: b, bytesExpected: 1} +} + +let update = (model, x) => + switch x { + | NoOp => (model, Cmd.none) + + | GetBook(url) => + let httpCmd = + Http.getString(url) + |> Http.Progress.track(progress => GetBookProgress(url, progress)) + |> Http.send(x => + switch x { + | Error(_e) => NoOp + | Ok(output) => GetBookDone(url, output) + } + ) + ( + { + ...model, + bookUrl: Some(url), + progress: progressHelper(0), + }, + httpCmd, + ) + + | GetBookProgress(url, progress) => + if Some(url) != model.bookUrl { + (model, Cmd.none) + } else { + ({...model, progress: progress}, Cmd.none) + } + + | GetBookDone(url, bookContent) => + if Some(url) != model.bookUrl { + (model, Cmd.none) + } else { + ({...model, bookContent: bookContent, progress: progressHelper(1)}, Cmd.none) + } + } + +let viewStyle = { + open Tea.Html.Attributes + styles(list{ + ("display", "flex"), + ("flex-direction", "column"), + ("width", "100%"), + ("margin", "0 auto"), + ("font-family", "Arial"), + }) +} + +let bookTextViewStyle = { + open Html.Attributes + styles(list{("height", "400px"), ("width", "100%")}) +} + +let inputRadio = (labelText, url) => { + open Tea_html + open Tea_html.Attributes + div( + list{}, + list{ + label( + list{ + onCheck(isChecked => + if isChecked { + GetBook(url) + } else { + NoOp + } + ), + }, + list{input'(list{type'("radio"), name("book-radio")}, list{}), text(labelText)}, + ), + }, + ) +} + +let progressView = loaded => { + open Tea.Html + open Tea.Html.Attributes + div( + list{}, + list{ + span(list{}, list{text("Progress: ")}), + progress(list{value(loaded), Attributes.max("100")}, list{text(loaded ++ "%")}), + text(loaded ++ "%"), + }, + ) +} + +let progressLoaded = progress => { + open Progress + let bytes = float_of_int(progress.bytes) + let bytesExpected = float_of_int(progress.bytesExpected) + if bytesExpected <= 0.0 { + 100 + } else { + int_of_float(100.0 *. (bytes /. bytesExpected)) + } +} + +let footerView = { + open Tea.Html + open Tea.Html.Attributes + span( + list{}, + list{ + text("Books from "), + a(list{href("http://www.gutenberg.org/"), target("_blank")}, list{text("Project Gutenberg")}), + }, + ) +} + +let bookTextView = valueText => { + open Tea.Html + open Tea.Html.Attributes + div( + list{}, + list{textarea(list{value(valueText), Attributes.disabled(true), bookTextViewStyle}, list{})}, + ) +} + +let view = model => { + open Html + div( + list{viewStyle}, + list{ + h1(list{}, list{text("Book Reader")}), + p( + list{}, + list{ + text("Select a book:"), + inputRadio( + "Essays - Ralph Waldo Emerson", + "https://s3-sa-east-1.amazonaws.com/estadistas/Essays-Ralph-Waldo-Emerson.txt", + ), + inputRadio( + "Leviathan - Thomas Hobbes", + "https://s3-sa-east-1.amazonaws.com/estadistas/Leviathan.txt", + ), + inputRadio( + "The Ethics of Aristotle - Aristotle", + "https://s3-sa-east-1.amazonaws.com/estadistas/The-Ethics-of+Aristotle.txt", + ), + }, + ), + progressView(string_of_int(progressLoaded(model.progress))), + bookTextView(model.bookContent), + footerView, + }, + ) +} + +let main = { + open App + standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, + }) +} diff --git a/test/main_clicker.res b/test/main_clicker.res new file mode 100644 index 0000000..8c7384e --- /dev/null +++ b/test/main_clicker.res @@ -0,0 +1,280 @@ +open Tea +open App +open Html +open Html.Attributes +open Html.Events + +type mathMod = { + baseAdd: float, + mult: float, +} + +type upgradeHow = + | ClickMath(mathMod) + | AddAutoClicker(mathMod) + +type upgradeDef = { + cost: float, + name: string, + math: upgradeHow, +} + +type model = { + startTime: Time.t, + curTime: Time.t, + lastUpdated: Time.t, + credits: float, + clickWorthMath: mathMod, + upgradesRemaining: list, + upgradesUsed: int, + messages: list, + autoClicker: mathMod, +} + +type msg = + | OnFrame(AnimationFrame.t) + | Click + | DoUpgrade(string) + +/* Type helpers */ + +let mathMod = (baseAdd, mult) => {baseAdd: baseAdd, mult: mult} + +/* Init functionality */ + +let init_mathMod = mathMod(1.0, 1.0) + +let empty_mathMod = mathMod(0.0, 1.0) + +let init_upgrade = (cost, name, math) => {cost: cost, name: name, math: math} + +let init_upgrades = List.sort( + (upgradeL, upgradeR) => int_of_float(upgradeL.cost -. upgradeR.cost), + /* Keep the names unique as those are the key */ + list{ + init_upgrade(10.0, "1 more credit per click", ClickMath(mathMod(1.0, 1.0))), + init_upgrade(50.0, "Half a credit more per click", ClickMath(mathMod(0.5, 1.0))), + init_upgrade(100.0, "50% more credits per click", ClickMath(mathMod(0.0, 1.5))), + init_upgrade(150.0, "Finally! An auto-clicker!", AddAutoClicker(mathMod(1.0, 1.0))), + init_upgrade(200.0, "Upgrade the auto-clicker!", AddAutoClicker(mathMod(0.0, 1.5))), + init_upgrade(250.0, "Even 50% more credits per click", ClickMath(mathMod(0.0, 1.5))), + init_upgrade( + 300.0, + "Get another base half-credit per click please?", + ClickMath(mathMod(0.5, 1.0)), + ), + init_upgrade(350.0, "Ooo, double the click value!", ClickMath(mathMod(0.0, 2.0))), + init_upgrade(400.0, "Get another auto-clicker?", AddAutoClicker(mathMod(1.0, 1.0))), + init_upgrade(500.0, "Get yet another auto-clicker!", AddAutoClicker(mathMod(1.0, 1.0))), + init_upgrade(750.0, "Upgrade the auto-clickers?", AddAutoClicker(mathMod(0.0, 1.5))), + init_upgrade(1000.0, "Get another base half-credit per click", ClickMath(mathMod(0.5, 1.0))), + init_upgrade(1250.0, "Found a way to double output of clicks!", ClickMath(mathMod(0.0, 2.0))), + init_upgrade(1500.0, "Upgrade the auto-clickers much more!", AddAutoClicker(mathMod(0.0, 4.0))), + init_upgrade( + 2000.0, + "Both an additional half credit and another 50% more!", + ClickMath(mathMod(0.5, 1.5)), + ), + init_upgrade(5000.0, "Even more 50% more credits per click", ClickMath(mathMod(0.0, 1.5))), + init_upgrade(10000.0, "*2* base credits per click! Wow!", ClickMath(mathMod(2.0, 1.0))), + init_upgrade( + 20000.0, + "Last upgrade! 10x everything! Please submit PR's with more upgrades and adjust this one to be the last. ^.^", + ClickMath(mathMod(0.0, 10.0)), + ), + }, +) + +let init = () => ( + { + startTime: 0.0, + curTime: 0.0, + lastUpdated: 0.0, + credits: 0.0, + clickWorthMath: init_mathMod, + upgradesRemaining: init_upgrades, + upgradesUsed: 0, + messages: list{}, + autoClicker: empty_mathMod, + }, + Cmd.none, +) + +/* Math helpers */ +let calc_mathMod_immediate = (initial, math) => (initial +. math.baseAdd) *. math.mult + +let calc_mathMod_combine = (math1, math2) => { + baseAdd: math1.baseAdd +. math2.baseAdd, + mult: math1.mult *. math2.mult, +} + +let worthString = worth => Js.Float.toString(worth) + +/* Base definitions */ + +let baseWorth_click = 0.000 + +/* Updating functionality */ + +let calcWorth_click = math => calc_mathMod_immediate(baseWorth_click, math) + +let applyUpgrade = (name, model) => { + let rec aux = (model, untouched, x) => + switch x { + | list{} => {...model, upgradesRemaining: List.rev(untouched)} + | list{upgrade, ...rest} if upgrade.name != name => + aux(model, list{upgrade, ...untouched}, rest) + | list{upgrade, ..._rest} if upgrade.cost > model.credits => model + | list{upgrade, ...rest} => + /* let () = Js.log ("Upgrading", upgrade) in */ + let newModel = switch upgrade.math { + | ClickMath(math) => { + ...model, + clickWorthMath: calc_mathMod_combine(model.clickWorthMath, math), + credits: model.credits -. upgrade.cost, + upgradesUsed: model.upgradesUsed + 1, + messages: list{ + "Bought " ++ (upgrade.name ++ (" for " ++ (worthString(upgrade.cost) ++ " credits"))), + ...model.messages, + }, + } + | AddAutoClicker(math) => { + ...model, + autoClicker: calc_mathMod_combine(model.autoClicker, math), + credits: model.credits -. upgrade.cost, + upgradesUsed: model.upgradesUsed + 1, + messages: list{ + "Bought " ++ (upgrade.name ++ (" for " ++ (worthString(upgrade.cost) ++ " credits"))), + ...model.messages, + }, + } + } + { + ...newModel, + upgradesRemaining: List.append(List.rev(untouched), rest), + } + } + aux(model, list{}, model.upgradesRemaining) +} + +let update = model => { + /* let () = Js.log ("Update", model) in */ + open AnimationFrame + + x => + switch x { + | OnFrame(ev) => ( + { + ...model, + startTime: if model.startTime < 1.0 { + ev.time + } else { + model.startTime + }, + curTime: ev.time, + credits: model.credits +. + ev.delta *. + 0.001 *. + calcWorth_click(model.clickWorthMath) *. + model.autoClicker.mult *. + model.autoClicker.baseAdd, + }, + Cmd.none, + ) + | Click => ( + { + ...model, + credits: model.credits +. calcWorth_click(model.clickWorthMath), + }, + Cmd.none, + ) + | DoUpgrade( + name, + ) => /* let () = Js.log ("DoUpgrade", name, model, applyUpgrade name model) in */ + (applyUpgrade(name, model), Cmd.none) + } +} + +let subscriptions = model => + /* let () = Js.log ("Subscriptions", model) in */ + if model.autoClicker.baseAdd > 0.0 || model.startTime < 1.0 { + AnimationFrame.every(ev => OnFrame(ev)) + } else { + Sub.none + } + +/* View handling */ + +let worthStringText = worth => text(worthString(worth)) + +let css_topContainer = styles(list{ + ("background-color", "rgb(0,0,0)"), + ("color", "rgb(255,255,255)"), + ("vertical-align", "top"), + ("height", "100%"), + ("width", "100%"), +}) + +let styles_container = list{ + ("background-color", "rgb(32,16,16)"), + ("color", "rgb(212,212,192)"), + ("vertical-align", "top"), + /* ; "height", "100%" */ + /* ; "padding", "4px" */ +} + +let css_container_top = styles(list{("width", "100%"), ...styles_container}) + +let css_container_bot = styles(list{("width", "100%"), ...styles_container}) + +let css_container_center = styles(list{("width", "100%"), ...styles_container}) + +let view_topBar = model => + tr(list{css_container_top}, list{td(list{}, list{worthStringText(model.credits)})}) + +let view_botBar = model => + tr( + list{css_container_bot}, + list{ + td( + list{}, + List.map(message => div(~key=message, list{}, list{text(message)}), model.messages), + ), + }, + ) + +let rec view_upgrades = (model, x) => + switch x { + | list{upgrade, ...rest} if model.credits >= upgrade.cost => list{ + button(~key=upgrade.name, list{onClick(DoUpgrade(upgrade.name))}, list{text(upgrade.name)}), + ...view_upgrades(model, rest), + } + | _ => list{} + } + +let view_center = model => + tr( + list{css_container_center}, + list{ + td( + list{}, + list{ + button(list{onClick(Click)}, list{text("Click")}), + ...view_upgrades(model, model.upgradesRemaining), + }, + ), + }, + ) + +let view = model => + table( + list{css_topContainer}, + list{tbody(list{}, list{view_topBar(model), view_center(model), view_botBar(model)})}, + ) + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, +}) diff --git a/test/main_clock.res b/test/main_clock.res new file mode 100644 index 0000000..bbda823 --- /dev/null +++ b/test/main_clock.res @@ -0,0 +1,50 @@ +open Tea +open App +open Html + +type model = float + +type msg = + | TestMsg + | Time(float) + +let init = () => (Web.Date.now(), Cmd.none) + +let update = (model, x) => + /* let () = Js.log ("Update", model) in */ + + switch x { + | TestMsg => (model, Cmd.none) + | Time(time) => (time, Cmd.none) + } + +let subscriptions =(_: model) => + /* let () = Js.log ("Subscriptions", model) in */ + Time.every(~key= "", Time.inMilliseconds(16.0), t => Time(t)) + +let view = model => { + let ms = int_of_float(mod_float(model, 1000.0)) + let sec' = int_of_float(model /. 1000.0) + let sec = mod(sec', 60) + let min' = sec' / 60 + let min = mod(min', 60) + let hrs' = min' / 60 + let hrs = mod(hrs', 24) + span( + list{}, + list{ + text( + string_of_int(hrs) ++ + (":" ++ + (string_of_int(min) ++ (":" ++ (string_of_int(sec) ++ ("." ++ string_of_int(ms)))))), + ), + }, + ) +} + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, +}) diff --git a/test/main_clock_svg.res b/test/main_clock_svg.res new file mode 100644 index 0000000..47279e8 --- /dev/null +++ b/test/main_clock_svg.res @@ -0,0 +1,47 @@ +open Tea +open App + +type model = float + +type msg = + | TestMsg + | Time(float) + +let init = () => (0.0, Cmd.none) + +let update = (model, x) => + /* let () = Js.log ("Update", model) in */ + + switch x { + | TestMsg => (model, Cmd.none) + | Time(time) => (time, Cmd.none) + } + +let subscriptions = (_: model) => + /* let () = Js.log ("Subscriptions", model) in */ + Time.every(~key= "", Time.second, t => Time(t)) + +let tau = 8.0 *. atan(1.0) + +let view = model => { + open Svg + open Svg.Attributes + /* Yes, the Elm example uses the wrong calculation here too, doing the same to match, off by 15s... */ + let angle = tau *. Time.inMinutes(model) + let handX = Js.Float.toString(50.0 +. 40.0 *. cos(angle)) + let handY = Js.Float.toString(50.0 +. 40.0 *. sin(angle)) + svg( + list{viewBox("0 0 100 100"), width("300px")}, + list{ + circle(list{cx("50"), cy("50"), r("45"), fill("#0B79CE")}, list{}), + line(list{x1("50"), y1("50"), x2(handX), y2(handY), stroke("#023963")}, list{}), + }, + ) +} + +let main = standardProgram({ + init, + update, + view, + subscriptions, +}) diff --git a/test/main_counter.res b/test/main_counter.res new file mode 100644 index 0000000..455f990 --- /dev/null +++ b/test/main_counter.res @@ -0,0 +1,45 @@ +open Tea.App +open Tea.Html +open Tea.Html.Events + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +let update = (model, x) => + switch x { + | Increment => model + 1 + | Decrement => model - 1 + | Reset => 0 + | Set(v) => v + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Tea_html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button("Increment", Increment), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let main = beginnerProgram({ + model: 4, + update: update, + view: view, +}) diff --git a/test/main_counter_navigation.res b/test/main_counter_navigation.res new file mode 100644 index 0000000..1baecea --- /dev/null +++ b/test/main_counter_navigation.res @@ -0,0 +1,79 @@ +open Tea +open Html +open Html.Events + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + | OnUrlChange(option) + +let toUrl = count => "#/" ++ string_of_int(count) + +let fromUrl = url => + try Some(int_of_string(String.sub(url, 2, String.length(url) - 2))) catch { + | _ => None + } + +let update = (model, x) => + switch x { + | Increment => (model + 1, Navigation.newUrl(toUrl(model + 1))) + | Decrement => (model - 1, Navigation.newUrl(toUrl(model - 1))) + | Reset => (0, Navigation.newUrl(toUrl(0))) + | Set(v) => (v, Navigation.newUrl(toUrl(v))) + | OnUrlChange(loc) => + switch loc { + | None => (0, Navigation.modifyUrl(toUrl(0))) + | Some(v) => (v, Cmd.none) + } + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button("Increment", Increment), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let locationToMessage = location => { + open Web.Location + OnUrlChange(fromUrl(location.hash)) +} + +let init = ((), location) => { + open Web.Location + switch fromUrl(location.hash) { + | None => (0, Navigation.modifyUrl(toUrl(0))) + | Some(v) => (v, Cmd.none) + } +} + +let main = { + open Navigation + navigationProgram( + locationToMessage, + { + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, + shutdown: _model => Cmd.none, + }, + ) +} diff --git a/test/main_embeddedCounters.res b/test/main_embeddedCounters.res new file mode 100644 index 0000000..9de3541 --- /dev/null +++ b/test/main_embeddedCounters.res @@ -0,0 +1,58 @@ +open Tea.App +open Tea.Html +open Tea.Html.Events + + + +type msg = + | Counter(int, Counter.msg) + | AddCounter + | RemoveCounter + +type model = {counters: list} + +let update = (model, x) => + switch x { + | Counter(idx, ms) => + let () = Js.log((model, idx, ms)) + { + /* model with */ + counters: model.counters |> List.mapi((i, m) => + if i != idx { + m + } else { + Counter.update(m, ms) + } + ), + } + | AddCounter => { + /* model with */ + counters: list{Counter.init(), ...model.counters}, + } + | RemoveCounter => { + /* model with */ + counters: List.tl(model.counters), + } + } + +let view_button = (title, msg) => button(list{onClick( msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + button(list{onClick(AddCounter)}, list{text("Prepend a Counter")}), + if List.length(model.counters) == 0 { + noNode + } else { + button(list{onClick(RemoveCounter)}, list{text("Delete a Counter")}) + }, + div(list{}, List.mapi((i, mo) => Counter.view(ms => Counter(i, ms), mo), model.counters)), + }, + ) + +let main = beginnerProgram({ + model: {counters: list{}}, + update: update, + view: view, +}) diff --git a/test/main_embeddedCountersParts.res b/test/main_embeddedCountersParts.res new file mode 100644 index 0000000..d55f4f9 --- /dev/null +++ b/test/main_embeddedCountersParts.res @@ -0,0 +1,83 @@ +open Tea +open App +open Html +open Tea.Html.Events + + +type msg = + | Counters(CounterParts.msg) + | AddCounter + | RemoveCounter + +type model = { + counters: CounterParts.model, + count: int, +} + +let init = () => ( + { + counters: CounterParts.init(4, sm => Counters(sm)), + count: 0, + }, + Cmd.none, +) + +let update = (model, x) => + switch x { + | Counters(cMsg) => + let () = Js.log((model, cMsg)) + ( + { + ...model, + counters: CounterParts.update(model.counters, cMsg), + }, + Cmd.none, + ) + | AddCounter => ( + { + ...model, + count: model.count + 1, + }, + Cmd.none, + ) + | RemoveCounter => ( + { + ...model, + count: model.count - 1, + }, + CounterParts.shutdown(model.counters, model.count), + ) + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => { + let showCounter = () => { + let rec showCountere_rec = (l, a, b) => + if a > b { + l + } else { + showCountere_rec(list{CounterParts.view(b, model.counters), ...l}, a, b - 1) + } + showCountere_rec(list{}, 1, model.count) + } + div( + list{}, + list{ + button(list{onClick(AddCounter)}, list{text("Append a Counter")}), + if model.count == 0 { + noNode + } else { + button(list{onClick(RemoveCounter)}, list{text("Delete a Counter")}) + }, + div(list{}, showCounter()), + }, + ) +} + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, +}) diff --git a/test/main_field.res b/test/main_field.res new file mode 100644 index 0000000..fbb2543 --- /dev/null +++ b/test/main_field.res @@ -0,0 +1,33 @@ +open Tea.App +open Tea.Html +open Tea.Html.Attributes +open Tea.Html.Events + + +type msg = NewContent(string) + +let update = (_oldContent, NewContent(content)) => content + +let myStyle = styles(list{ + ("width", "100%"), + ("height", "40px"), + ("padding", "10px 0"), + ("font-size", "2em"), + ("text-align", "center"), +}) + +let view = content => { + let string_rev = s => { + let len = String.length(s) + String.init(len, i => String.get(s, len - 1 - i)) + } + div( + list{}, + list{ + input'(list{placeholder("Text to reverse"), onInput(s => NewContent(s)), myStyle}, list{}), + div(list{myStyle}, list{text(string_rev(content))}), + }, + ) +} + +let main = beginnerProgram({model: "", view: view, update: update}) diff --git a/test/main_form.res b/test/main_form.res new file mode 100644 index 0000000..fbc3682 --- /dev/null +++ b/test/main_form.res @@ -0,0 +1,68 @@ +open Tea.App +open Tea.Html +open Tea.Html.Attributes +open Tea.Html.Events + + + +/* MODEL */ + +type model = { + name: string, + password: string, + passwordAgain: string, +} + +let model = { + name: "", + password: "", + passwordAgain: "", +} + +/* UPDATE */ + +type msg = + | Name(string) + | Password(string) + | PasswordAgain(string) + +let update = (model, x) => + switch x { + | Name(name) => {...model, name: name} + + | Password(password) => {...model, password: password} + + | PasswordAgain(passwordAgain) => {...model, passwordAgain: passwordAgain} + } + +/* VIEW */ + +let viewValidation = model => { + let (color, message) = if model.password === model.passwordAgain { + ("green", "OK") + } else { + ("red", "Passwords do not match!") + } + + div(list{styles(list{("color", color)})}, list{text(message)}) +} + +let view = model => + div( + list{}, + list{ + input'(list{type'("text"), placeholder("Name"), onInput(s => Name(s))}, list{}), + input'(list{type'("password"), placeholder("Password"), onInput(s => Password(s))}, list{}), + input'( + list{type'("password"), placeholder("Re-enter Password"), onInput(s => PasswordAgain(s))}, + list{}, + ), + viewValidation(model), + }, + ) + +let main = beginnerProgram({ + model: model, + view: view, + update: update, +}) diff --git a/test/main_gg.res b/test/main_gg.res new file mode 100644 index 0000000..8c26a1c --- /dev/null +++ b/test/main_gg.res @@ -0,0 +1,363 @@ +open Tea + +module IntMap = Map.Make({ + type t = int + let compare = compare +}) + +module IntPairMap = Map.Make({ + type t = (int, int) + let compare = compare +}) + +let maxInfluence = 255 + +type objectTypes = + /* Base (team, influenceAmt) */ + | Base(int, int) + +type model = { + map: array>, + influence: array>, + units: IntPairMap.t>, + pTeamResources: int, + nTeamResources: int, +} + +type msg = + | OnUrlChange(array>) + | AITick + | InfluenceTick + +let toUrl = _model => "" + +open Rescript_json_combinators_extended +let fromUrl = url => { + let mapDecoder = { + JsonCombinators.Json.Decode.array(JsonCombinators.Json.Decode.array(JsonCombinators.Json.Decode.int)) + } + switch decodeString(mapDecoder, url) { + | Ok(map) => map + | Error(_) => Array.make_matrix(32, 32, 0) + } +} + +let init = ((), location) => { + open Web.Location + let map = fromUrl(location.hash) + let width = Array.length(map) + let height = Array.length(map[0]) + let units = + IntPairMap.empty + |> IntPairMap.add((4, height - 4), list{Base(1, 12)}) + |> IntPairMap.add((width - 4, 4), list{Base(-1, 12)}) + + let model = { + map: map, + influence: Array.make_matrix(width, height, 0), + units: units, + pTeamResources: 1000, + nTeamResources: 1000, + } + (model, Cmd.none) +} + +let addUnit = (coords, unit, dict) => { + let list = if IntPairMap.mem(coords, dict) { + IntPairMap.find(coords, dict) + } else { + list{} + } + IntPairMap.add(coords, list{unit, ...list}, dict) +} + +let rec mergeUnits = (dict, x) => + switch x { + | list{} => dict + | list{(coords, unit), ...rest} => addUnit(coords, unit, mergeUnits(dict, rest)) + } + +let update = (model, x) => + switch x { + | OnUrlChange(_map) => (model, Cmd.none) + | AITick => + let width = Array.length(model.map) + let height = Array.length(model.map[0]) + let influence = model.influence + let units = model.units + let tickUnit = ((x, y): (int, int), ret, Base(team, inf)) =>{ + + /* Add in test to use up resources when building and to destroy self if not enough influence here */ + let newBase = Base(team, inf) + if + (x > 1) && + (y > 1) && + (influence[x - 1][y - 1] * team > 2) && (false == IntPairMap.mem((x - 1, y - 1), units)) + { + list{((x - 1, y - 1), newBase), ...ret} + } else if ( + x > 1 && + (y < height - 2 && + (influence[x - 1][y + 1] * team > 2 && false == IntPairMap.mem((x - 1, y + 1), units))) + ) { + list{((x - 1, y + 1), newBase), ...ret} + } else if ( + x < width - 2 && + (y > 1 && + (influence[x + 1][y - 1] * team > 2 && false == IntPairMap.mem((x + 1, y - 1), units))) + ) { + list{((x + 1, y - 1), newBase), ...ret} + } else if ( + x < width - 2 && + (y < height - 2 && + (influence[x + 1][y + 1] * team > 2 && false == IntPairMap.mem((x + 1, y + 1), units))) + ) { + list{((x + 1, y + 1), newBase), ...ret} + } else { + ret + }} + + let tickUnits = (coords, units, ret) => List.fold_left(tickUnit(coords), ret, units) + let newUnits = IntPairMap.fold(tickUnits, units, list{}) + let units = mergeUnits(units, newUnits) + ( + { + ...model, + units: units, + }, + Cmd.none, + ) + | InfluenceTick => + let width = Array.length(model.map) + let height = Array.length(model.map[0]) + let influence = Array.copy(model.influence) + let rec addInfluence = ((x, y), rest) => + switch rest { + | list{} => () + | list{Base(team, amt), ...rest} => + let () = influence[x][y] = model.influence[x][y] + amt * team + addInfluence((x, y), rest) + } + /* | _ :: rest -> addInfluence (x, y) rest */ + let () = IntPairMap.iter(addInfluence, model.units) + let processInfY = (x, y, t) => + /* Process this out to changes to read */ + if x == 0 || (x == width - 1 || (y == 0 || y == height - 1)) { + influence[x][y] = 0 + } else if t == 0 { + let inf = model.influence[x][y] + let infXN = model.influence[x - 1][y] + let infXP = model.influence[x + 1][y] + let infYN = model.influence[x][y - 1] + let infYP = model.influence[x][y + 1] + let part = inf / 6 + /* let comp = inf - part in */ + let () = /* if infXN < comp then */ influence[x - 1][y] = infXN + part + let () = /* if infXP < comp then */ influence[x + 1][y] = infXP + part + let () = /* if infYN < comp then */ influence[x][y - 1] = infYN + part + let () = /* if infYP < comp then */ influence[x][y + 1] = infYP + part + influence[x][y] = inf - part * 4 + } else { + () + } + let processX = (x, yArr) => Array.iteri(processInfY(x), yArr) + let reduceInfY = (x, y, i) => + if i < -255 { + influence[x][y] = -255 + } else if i < 0 { + influence[x][y] = i + 1 + } else if i > 255 { + influence[x][y] = 255 + } else if i > 0 { + influence[x][y] = i - 1 + } else { + () + } + let reduceInfX = (x, yArr) => Array.iteri(reduceInfY(x), yArr) + let () = Array.iteri(processX, model.map) + let () = Array.iteri(reduceInfX, influence) + let (scoreN, scoreP) = { + let scoreY = ((sn, sp), inf) => + if inf < -7 { + (sn - inf + 7, sp) + } else if inf > 7 { + (sn, sp + inf - 7) + } else { + (sn, sp) + } + let scoreX = (scores, yArr) => Array.fold_left(scoreY, scores, yArr) + Array.fold_left(scoreX, (0, 0), influence) + } + let nTeamResources = model.nTeamResources + scoreN + let pTeamResources = model.pTeamResources + scoreP + ( + { + ...model, + influence: influence, + nTeamResources: nTeamResources, + pTeamResources: pTeamResources, + }, + Cmd.none, + ) + } + +let subscriptions = _model => + Sub.batch(list{ + Time.every(~key="",Time.inMilliseconds(500.0), _ => InfluenceTick), + Time.every(~key="",Time.inMilliseconds(1100.0), _ => AITick), + }) + +let cellSize = 12 /* Always be an even integral */ +let cellSizeStr = string_of_int(cellSize) +let cellSizeHalf = cellSize / 2 +let cellSizeHalfStr = string_of_int(cellSizeHalf) + +let view = model => { + open Svg + open Svg.Attributes + let mapWidth = Array.length(model.map) + let mapHeight = Array.length(model.map[0]) + let unitsSvg = () => { + let rec unitToSvg = ((coords, units)) => + switch units { + | list{} => list{} + | list{Base(team, _influence), ...rest} => list{ + circle( + list{ + r(cellSizeHalfStr), + fill( + if team < 0 { + "#FF0000" + } else if team > 0 { + "#0000FF" + } else { + "#111111" + }, + ), + stroke("#000000"), + cx(string_of_int(fst(coords) * cellSize + cellSizeHalf)), + cy(string_of_int(snd(coords) * cellSize + cellSizeHalf)), + }, + list{}, + ), + ...unitToSvg((coords, rest)), + } + } + IntPairMap.bindings(model.units) |> List.map(unitToSvg) |> List.flatten + } + let tileToSvg = (cx, cy, value) => { + let key = string_of_int(value) + if cx == 0 || (cx == mapWidth - 1 || (cy == 0 || cy == mapHeight - 1)) { + noNode + } else if value == 0 { + /* Open */ + let v = model.influence[cx][cy] + let fillColor = { + let av = abs(v) + let density = if av >= maxInfluence { + "0" + } else { + string_of_int(255 - av) + } + let color = if v < 0 { + "rgb(255," ++ (density ++ ("," ++ (density ++ ")"))) + } else if v > 0 { + "rgb(" ++ (density ++ ("," ++ (density ++ ",255)"))) + } else { + "rgb(255,255,255)" + } + color + } + rect( + list{ + x(string_of_int(cx * cellSize)), + y(string_of_int(cy * cellSize)), + width(cellSizeStr), + height(cellSizeStr), + fill(fillColor), + stroke( + if v < 0 { + "#FF0000" + } else if v > 0 { + "#0000FF" + } else { + "#FFFFFF" + }, + ), + }, + list{}, + ) + } else if value == 1 { + /* Wall */ + rect( + ~key, + list{ + x(string_of_int(cx * cellSize)), + y(string_of_int(cy * cellSize)), + width(cellSizeStr), + height(cellSizeStr), + fill("#222222"), + stroke("#000000"), + }, + list{}, + ) + } else { + rect( + ~key, + list{ + x(string_of_int(cx * cellSize)), + y(string_of_int(cy * cellSize)), + width(cellSizeStr), + height(cellSizeStr), + fill("#FF88FF"), + stroke("#FF00FF"), + }, + list{}, + ) + } + } + + let tileMapperX = (cx, value) => { + let values = Array.mapi(tileToSvg(cx), value) + Array.to_list(values) + } + let valueArray = Array.mapi(tileMapperX, model.map) + Html.div( + list{}, + list{ + svg( + list{ + viewBox( + "0 0 " ++ + (string_of_int(mapWidth * cellSize) ++ + (" " ++ string_of_int(mapHeight * cellSize))), + ), + width(string_of_int(mapWidth * cellSize) ++ "px"), + }, + list{ + g(list{}, Array.to_list(valueArray) |> List.concat), + lazy1(string_of_int(IntPairMap.cardinal(model.units)), () => g(list{}, unitsSvg())), + }, + ), + }, + ) +} + +let locationToMessage = location => { + open Web.Location + OnUrlChange(fromUrl(location.hash)) +} + +let main = { + open Navigation + navigationProgram( + locationToMessage, + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: _model => Cmd.none, + }, + ) +} diff --git a/test/main_gtpollute.res b/test/main_gtpollute.res new file mode 100644 index 0000000..519efe8 --- /dev/null +++ b/test/main_gtpollute.res @@ -0,0 +1,196 @@ +open Tea + +/* This is a direct conversion from other code, not made to be pretty or to demonstrate how things should be done */ +/* I.E. Ignore this. */ + +type model = { + data: array>, + maxValue: int, + value: int, + tickTime: float, +} + +type msg = + | UpdateValue(string) + | UpdateTickTime(string) + | DoUpdate(Time.t) + +let init = () => ( + { + data: Array.make_matrix(31, 31, 0), + maxValue: 1, + value: 0, + tickTime: 5.0, + }, + Cmd.none, +) + +let update = (model, x) => + switch x { + | UpdateValue(sValue) => + let value = try int_of_string(sValue) catch { + | _ => model.value + } + ({...model, value}, Cmd.none) + | UpdateTickTime(sValue) => + let tickTime = try float_of_string(sValue) catch { + | _ => model.tickTime + } + ({...model, tickTime}, Cmd.none) + | DoUpdate(_) => + let data: array> = { + let data = model.data + let fullX = Array.length(data) + let fullY = Array.length(data[0]) + let halfX = fullX / 2 + let halfY = fullY / 2 + let () = data[halfX][halfY] = data[halfX][halfY] + model.value + let () = { + let () = Array.fill(data[0], 0, fullY, 0) + let () = Array.fill(data[fullX - 2], 0, fullY, 0) + for x in 1 to Array.length(data) - 2 { + let () = data[x][0] = 0 + let () = data[x][fullY - 2] = 0 + for y in 1 to Array.length(data[0]) - 2 { + let () = data[x][y] = data[x][y] - 3000 + let () = if data[x][y] < 0 { + data[x][y] = 0 + } else { + () + } + let processSide = (xx, yy) => + if data[xx][yy] * 12 < data[x][y] * 10 { + let diff = data[x][y] - data[xx][yy] + let diff = diff / 20 + let () = data[xx][yy] = data[xx][yy] + diff + let () = data[x][y] = data[x][y] - diff + } else { + () + } + let () = processSide(x - 1, y) + let () = processSide(x + 1, y) + let () = processSide(x, y - 1) + let () = processSide(x, y + 1) + } + } + } + data + } + let maxValue = { + let inner = (value, arr) => Array.fold_left((maxValue, value) => + if maxValue > value { + maxValue + } else { + value + } + , value, arr) + Array.fold_left(inner, 1, data) + } + ({...model, data, maxValue}, Cmd.none) + } + +let subscriptions = (model: model) => Time.every(~key="",Time.inMilliseconds(model.tickTime), t => DoUpdate(t)) + +let view = model => { + open Svg + open Svg.Attributes + let mapperY = (coordX, coordY, value) => { + let colorHex = { + let red = if value > 2000000 { + "FF" + } else if value > 1000000 { + "40" + } else { + "00" + } + let green = if value > 750000 { + "FF" + } else if value > 550000 { + "80" + } else { + "00" + } + let blue = { + let bVal = value * 255 / model.maxValue + if bVal > 255 { + "FF" + } else if bVal < 0 { + "00" + } else { + `${string_of_int(bVal)}` + } + } + "#" ++ (red ++ (green ++ blue)) + } + let strokeHex = if value > 0 { + "#FFFFFF" + } else { + "#000000" + } + rect( + list{ + x(string_of_int(coordX * 10)), + y(string_of_int(coordY * 10)), + width("10"), + height("10"), + fill(colorHex), + stroke(strokeHex), + }, + list{}, + ) + } + let mapperX = (coordX, value) => { + let values = Array.mapi(mapperY(coordX), value) + Array.to_list(values) + } + let valueArray = Array.mapi(mapperX, model.data) + let valueStep = string_of_int(model.value / 20) + /* if model.value <= 100000 then */ + /* "10000" else */ + /* if model.value <= 1000000 then */ + /* "100000" */ + /* else "1000000" in */ + Html.div( + list{}, + list{ + Html.label(list{}, list{text("Center input value per tick:")}), + Html.input'( + list{ + Html.Attributes.placeholder("Integer value"), + Html.Events.onInput(s => UpdateValue(s)), + Html.Attributes.type'("number"), + Html.Attributes.min("0"), + Html.Attributes.max("100000000"), + Html.Attributes.step(valueStep), + Html.Attributes.value(string_of_int(model.value)), + }, + list{}, + ), + Html.br(list{}), + Html.label(list{}, list{text("Time per tick:")}), + Html.input'( + list{ + Html.Attributes.placeholder("Time per tick (ms)"), + Html.Events.onInput(s => UpdateTickTime(s)), + Html.Attributes.type'("number"), + Html.Attributes.min("5"), + Html.Attributes.step("5"), + Html.Attributes.value(int_of_float(model.tickTime) |> string_of_int), + }, + list{}, + ), + Html.br(list{}), + svg(list{viewBox("0 0 300 300"), width("300px")}, Array.to_list(valueArray) |> List.concat), + }, + ) +} + +let main = { + open App + standardProgram({ + init, + update, + view, + subscriptions, + }) +} diff --git a/test/main_random.res b/test/main_random.res new file mode 100644 index 0000000..0605eda --- /dev/null +++ b/test/main_random.res @@ -0,0 +1,36 @@ +open Tea +open App +open Html +open Tea_html.Events + +type model = {dieFace: int} + +type msg = + | Roll + | NewFace(int) + +let init = () => ({dieFace: 1}, Cmd.none) + +let update = (model, x) => + switch x { + | Roll => (model, Tea.Random.generate(v => NewFace(v), Tea.Random.int(1, 6))) + | NewFace(dieFace) => ({dieFace: dieFace}, Cmd.none) + } + +let subscriptions = _model => Sub.none + +let view = model => + div( + list{}, + list{ + h1(list{}, list{text(string_of_int(model.dieFace))}), + button(list{onClick(Roll)}, list{text("Roll")}), + }, + ) + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, +}) diff --git a/test/main_random_color.res b/test/main_random_color.res new file mode 100644 index 0000000..902b83b --- /dev/null +++ b/test/main_random_color.res @@ -0,0 +1,62 @@ +open Tea +open App +open Html +open Tea_html.Events + +type model = { + r: int, + g: int, + b: int, +} + +type msg = + | Roll + | NewColor(int, int, int) + +let init = () => ({r: 255, g: 255, b: 255}, Cmd.none) + +let update = (model, x) => + switch x { + | Roll => + let genInt = Tea.Random.int(1, 255) + /* Here is how to do it via a list */ + /* let genList3 = Tea.Random.list 3 genInt in + model, Tea.Random.generate (function |[r;g;b] -> NewColor (r,g,b) | v -> failwith "will never happen") genList3 */ + /* And here is how to do it via a mapping */ + let genTuple3 = Tea.Random.map3((r, g, b) => NewColor(r, g, b), genInt, genInt, genInt) + (model, Tea.Random.generate(v => v, genTuple3)) + | NewColor(r, g, b) => ({r: r, g: g, b: b}, Cmd.none) + } + +let subscriptions = _model => Sub.none + +let view = model => { + let r = string_of_int(model.r) + let g = string_of_int(model.g) + let b = string_of_int(model.b) + let isDark = (model.r + model.g + model.b) / 3 > 128 + let rgb = "(" ++ (r ++ ("," ++ (g ++ ("," ++ (b ++ ")"))))) + let altRgb = if isDark { + "(0,0,0)" + } else { + "(255,255,255)" + } + + div( + list{}, + list{ + h1( + list{Tea_html.Attributes.style("background-color", "rgb" ++ rgb), Tea_html.Attributes.style("color", "rgb" ++ altRgb)}, + list{text(rgb)}, + ), + button(list{onClick(Roll)}, list{text("Roll")}), + }, + ) +} + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, +}) diff --git a/test/main_todo.res b/test/main_todo.res new file mode 100644 index 0000000..e5b8386 --- /dev/null +++ b/test/main_todo.res @@ -0,0 +1,356 @@ +/* https://github.com/evancz/react-angular-ember-elm-performance-comparison/blob/master/implementations/elm-0.17/Todo.elm */ +open Tea +open App +open Html +open Html.Events + + +module Cmds = Tea_html_cmds + +/* MODEL */ + +type entry = { + description: string, + completed: bool, + editing: bool, + id: int, +} + +/* The full application state of our todo app. */ +type model = { + entries: list, + field: string, + uid: int, + visibility: string, +} + +let emptyModel = { + entries: list{}, + visibility: "All", + field: "", + uid: 0, +} + +let newEntry = (desc, id) => { + description: desc, + completed: false, + editing: false, + id: id, +} + +let init = () => (emptyModel, Cmd.none) + +/* UPDATE */ + +/* Users of our app can trigger messages by clicking and typing. These +messages are fed into the `update` function as they occur, letting us react +to them. */ +type msg = + | NoOp + | UpdateField(string) + | EditingEntry(int, bool) + | UpdateEntry(int, string) + | Add + | Delete(int) + | DeleteComplete + | Check(int, bool) + | CheckAll(bool) + | ChangeVisibility(string) + +/* How we update our Model on a given Msg? */ +let update = (model, x) => + switch x { + | NoOp => (model, Cmd.none) + + | Add => ( + { + ...model, + uid: model.uid + 1, + field: "", + entries: if model.field == "" { + model.entries + } else { + \"@"(model.entries, list{newEntry(model.field, model.uid)}) + }, + }, + Cmd.none, + ) + + | UpdateField(field) => ({...model, field: field}, Cmd.none) + + | EditingEntry(id, editing) => + let updateEntry = t => + if t.id == id { + {...t, editing: editing} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + if editing { + Cmds.focus("todo-" ++ string_of_int(id)) + } else { + Cmd.none + }, + ) + + | UpdateEntry(id, description) => + let updateEntry = t => + if t.id == id { + {...t, description: description} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | Delete(id) => ( + { + ...model, + entries: List.filter(t => t.id != id, model.entries), + }, + Cmd.none, + ) + + | DeleteComplete => ( + { + ...model, + entries: List.filter(({completed, _}) => !completed, model.entries), + }, + Cmd.none, + ) + + | Check(id, completed) => + let updateEntry = t => + if t.id == id { + {...t, completed: completed} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | CheckAll(completed) => + let updateEntry = t => {...t, completed: completed} + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + | ChangeVisibility(visibility) => ({...model, visibility: visibility}, Cmd.none) + } + +/* View rendering */ + +let onEnter = (~key="", msg) => { + let tagger = ev => + switch ev["keyCode"] { + | 13 => Some(msg) + | _ => None + } + + onCB("keydown", ~key, tagger) +} + +let viewEntry = todo => { + let key = string_of_int(todo.id) + li( + list{Html.Attributes.classList(list{("completed", todo.completed), ("editing", todo.editing)})}, + list{ + div( + list{Html.Attributes.class("view")}, + list{ + input'( + list{ + Html.Attributes.class("toggle"), + Html.Attributes.type'("checkbox"), + Html.Attributes.checked(todo.completed), + onClick( Check(todo.id, !todo.completed)), + }, + list{}, + ), + label( + list{onDoubleClick(EditingEntry(todo.id, true))}, + list{text(todo.description)}, + ), + button(list{Html.Attributes.class("destroy"), onClick(Delete(todo.id))}, list{}), + }, + ), + input'( + list{ + Html.Attributes.class("edit"), + Html.Attributes.value(todo.description), + Html.Attributes.name("title"), + Html.Attributes.id("todo-" ++ string_of_int(todo.id)), + onInput(~key, value => UpdateEntry(todo.id, value)), + onBlur(EditingEntry(todo.id, false)), + onEnter(~key, EditingEntry(todo.id, false)), + }, + list{}, + ), + }, + ) +} + +let viewEntries = (visibility, entries) => { + let isVisible = todo => + switch visibility { + | "Completed" => todo.completed + | "Active" => !todo.completed + | _ => true + } + let allCompleted = List.for_all(({completed, _}) => completed, entries) + let cssVisibility = if list{} == entries { + "hidden" + } else { + "visible" + } + section( + list{Html.Attributes.class("main"), Html.Attributes.style("visibility", cssVisibility)}, + list{ + input'( + list{ + Html.Attributes.class("toggle-all"), + Html.Attributes.type'("checkbox"), + Html.Attributes.name("toggle"), + Html.Attributes.checked(allCompleted), + onClick(CheckAll(!allCompleted)), + }, + list{}, + ), + label(list{Html.Attributes.for'("toggle-all")}, list{text("Mark all as complete")}), + ul(list{Html.Attributes.class("todo-list")}, List.map(viewEntry, List.filter(isVisible, entries))), + }, + ) +} + +let viewInput = task => + header( + list{Html.Attributes.class("header")}, + list{ + h1(list{}, list{text("todos")}), + input'( + list{ + Html.Attributes.class("new-todo"), + Html.Attributes.placeholder("What needs to be done?"), + Html.Attributes.autofocus(true), + Html.Attributes.value(task), + Html.Attributes.name("newTodo"), + onInput(str => UpdateField(str)), + onEnter(Add), + }, + list{}, + ), + }, + ) + +let viewControlsCount = entriesLeft => { + let item_ = if entriesLeft === 1 { + " item" + } else { + " items" + } + span( + list{Html.Attributes.class("todo-count")}, + list{strong(list{}, list{text(string_of_int(entriesLeft))}), text(item_ ++ " left")}, + ) +} + +let visibilitySwap = (uri, visibility, actualVisibility) => + li( + list{onClick(ChangeVisibility(visibility))}, + list{ + a( + list{Html.Attributes.href(uri), Html.Attributes.classList(list{("selected", visibility == actualVisibility)})}, + list{text(visibility)}, + ), + }, + ) + +let viewControlsFilters = visibility => + ul( + list{Html.Attributes.class("filters")}, + list{ + visibilitySwap("#/", "All", visibility), + text(" "), + visibilitySwap("#/active", "Active", visibility), + text(" "), + visibilitySwap("#/completed", "Completed", visibility), + }, + ) + +let viewControlsClear = entriesCompleted => + button( + list{Html.Attributes.class("clear-completed"), Html.Attributes.hidden(entriesCompleted === 0), onClick(DeleteComplete)}, + list{text("Clear completed (" ++ (string_of_int(entriesCompleted) ++ ")"))}, + ) + +let viewControls = (visibility, entries) => { + let entriesCompleted = List.length(List.filter(({completed, _}) => completed, entries)) + let entriesLeft = List.length(entries) - entriesCompleted + footer( + list{Html.Attributes.class("footer"), Html.Attributes.hidden(List.length(entries) == 0)}, + list{ + viewControlsCount(entriesLeft), + viewControlsFilters(visibility), + viewControlsClear(entriesCompleted), + }, + ) +} + +let infoFooter = footer( + list{Html.Attributes.class("info")}, + list{ + p(list{}, list{text("Double-click to edit a todo")}), + p( + list{}, + list{ + text("Written by "), + a(list{Html.Attributes.href("https://github.com/evancz")}, list{text("Evan Czaplicki")}), + text(" and converted by "), + a(list{Html.Attributes.href("https://github.com/overminddl1")}, list{text("OvermindDL1")}), + }, + ), + p(list{}, list{text("Part of "), a(list{Html.Attributes.href("http://todomvc.com")}, list{text("TodoMVC")})}), + }, +) + +let view = model => + div( + list{Html.Attributes.class("todomvc-wrapper"), Html.Attributes.style("visibility", "hidden")}, + list{ + section( + list{Html.Attributes.class("todoapp")}, + list{ + viewInput(model.field), + viewEntries(model.visibility, model.entries), + viewControls(model.visibility, model.entries), + }, + ), + infoFooter, + }, + ) + +/* Main Entrance */ + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, +}) diff --git a/test/main_todo_optimized.res b/test/main_todo_optimized.res new file mode 100644 index 0000000..6247cbb --- /dev/null +++ b/test/main_todo_optimized.res @@ -0,0 +1,380 @@ +/* https://github.com/evancz/react-angular-ember-elm-performance-comparison/blob/master/implementations/elm-0.17/Todo.elm */ +open Tea +open App +open Html +open Html.Events + +module Cmds = Tea_html_cmds + +/* MODEL */ + +type entry = { + description: string, + completed: bool, + editing: bool, + id: int, +} + +/* The full application state of our todo app. */ +type model = { + entries: list, + field: string, + uid: int, + visibility: string, +} + +let emptyModel = { + entries: list{}, + visibility: "All", + field: "", + uid: 0, +} + +let newEntry = (desc, id) => { + description: desc, + completed: false, + editing: false, + id: id, +} + +let init = () => (emptyModel, Cmd.none) + +/* UPDATE */ + +/* Users of our app can trigger messages by clicking and typing. These +messages are fed into the `update` function as they occur, letting us react +to them. */ +type msg = + /* | NoOp */ + | UpdateField(string) + | EditingEntry(int, bool) + | UpdateEntry(int, string) + | Add + | Delete(int) + | DeleteComplete + | Check(int, bool) + | CheckAll(bool) + | ChangeVisibility(string) + +/* How we update our Model on a given Msg? */ +let update = (model, x) => + /* NoOp -> model, Cmd.none */ + + switch x { + | Add => ( + { + ...model, + uid: model.uid + 1, + field: "", + entries: if model.field == "" { + model.entries + } else { + list{newEntry(model.field, model.uid), ...model.entries} + } /* Optimized: Switched to prepending to a list instead of appending, why the heck would you append only?! */, + }, + Cmd.none, + ) + + | UpdateField(field) => ({...model, field: field}, Cmd.none) + + | EditingEntry(id, editing) => + let updateEntry = t => + if t.id == id { + {...t, editing: editing} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + if editing { + Cmds.focus("todo-" ++ string_of_int(id)) + } else { + Cmd.none + }, + ) + + | UpdateEntry(id, description) => + let updateEntry = t => + if t.id == id { + {...t, description: description} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | Delete(id) => ( + { + ...model, + entries: List.filter(t => t.id != id, model.entries), + }, + Cmd.none, + ) + + | DeleteComplete => ( + { + ...model, + entries: List.filter(({completed, _}) => !completed, model.entries), + }, + Cmd.none, + ) + + | Check(id, completed) => + let updateEntry = t => + if t.id == id { + {...t, completed: completed} + } else { + t + } + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | CheckAll(completed) => + let updateEntry = t => {...t, completed: completed} + ( + { + ...model, + entries: List.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | ChangeVisibility(visibility) => ({...model, visibility: visibility}, Cmd.none) + } + +/* View rendering */ + +let onEnter = (~key="", msg) => { + let tagger = ev => + switch ev["keyCode"] { + | 13 => Some(msg) + | _ => None + } + + Tea_html.Events.onCB("keydown", ~key, tagger) +} + +let viewEntry = (todo, ()) => { + open Html.Attributes + let key = string_of_int(todo.id) + let fullkey = key ++ (string_of_bool(todo.completed) ++ string_of_bool(todo.editing)) + /* Optimized: Added a key to the node to early-out if exact match, if key is unspecified then the sub section is + always recursed into, thus this is *not* like elm's keyed nodes but rather more strict. */ + li( + ~key=fullkey, + list{classList(list{("completed", todo.completed), ("editing", todo.editing)})}, + list{ + div( + list{class("view")}, + list{ + input'( + list{ + class("toggle"), + type'("checkbox"), + checked(todo.completed), + onClick( Check(todo.id, !todo.completed)), + }, + list{}, + ), + label( + list{onDoubleClick(EditingEntry(todo.id, true))}, + list{text(todo.description)}, + ), + button(list{class("destroy"), onClick(Delete(todo.id))}, list{}), + }, + ), + input'( + list{ + class("edit"), + value(todo.description), + name("title"), + id("todo-" ++ string_of_int(todo.id)), + onInput(~key, value => UpdateEntry(todo.id, value)), + onBlur(EditingEntry(todo.id, false)), + onEnter(~key, EditingEntry(todo.id, false)), + }, + list{}, + ), + }, + ) +} + +let viewEntries = (visibility, entries) => { + let isVisible = todo => + switch visibility { + | "Completed" => todo.completed + | "Active" => !todo.completed + | _ => true + } + let allCompleted = List.for_all(({completed, _}) => completed, entries) + let cssVisibility = if list{} == entries { + "hidden" + } else { + "visible" + } + section( + list{Html.Attributes.class("main"), Html.Attributes.style("visibility", cssVisibility)}, + list{ + input'( + list{ + Html.Attributes.class("toggle-all"), + Html.Attributes.type'("checkbox"), + Html.Attributes.name("toggle"), + Html.Attributes.checked(allCompleted), + onClick( CheckAll(!allCompleted)), + }, + list{}, + ), + label(list{Html.Attributes.for'("toggle-all")}, list{text("Mark all as complete")}), + ul( + list{Html.Attributes.class("todo-list")}, + List.rev_map( + todo => + lazy1( + string_of_int(todo.id) ++ + (string_of_bool(todo.completed) ++ + string_of_bool(todo.editing)), + viewEntry(todo), + ), + List.filter(isVisible, entries), + ), + ), + }, + ) +} + +let viewInput = (task, ()) => + header( + ~key=task, + list{Html.Attributes.class("header")}, + list{ + h1(list{}, list{text("todos")}), + input'( + list{ + Html.Attributes.class("new-todo"), + Html.Attributes.placeholder("What needs to be done?"), + Html.Attributes.autofocus(true), + Html.Attributes.value(task), + Html.Attributes.name("newTodo"), + onInput(str => UpdateField(str)), + onEnter(Add), + }, + list{}, + ), + }, + ) + +let viewControlsCount = entriesLeft => { + let item_ = if entriesLeft === 1 { + " item" + } else { + " items" + } + let left = string_of_int(entriesLeft) + span( + ~key=left, + list{Html.Attributes.class("todo-count")}, + list{strong(list{}, list{text(left)}), text(item_ ++ " left")}, + ) +} + +let visibilitySwap = (uri, visibility, actualVisibility) => + li( + list{onClick(ChangeVisibility(visibility))}, + list{ + a( + list{Html.Attributes.href(uri), Html.Attributes.classList(list{("selected", visibility == actualVisibility)})}, + list{text(visibility)}, + ), + }, + ) + +let viewControlsFilters = visibility => + ul( + list{Html.Attributes.class("filters")}, + list{ + visibilitySwap("#/", "All", visibility), + text(" "), + visibilitySwap("#/active", "Active", visibility), + text(" "), + visibilitySwap("#/completed", "Completed", visibility), + }, + ) + +let viewControlsClear = entriesCompleted => + button( + list{Html.Attributes.class("clear-completed"), Html.Attributes.hidden(entriesCompleted === 0), onClick(DeleteComplete)}, + list{text("Clear completed (" ++ (string_of_int(entriesCompleted) ++ ")"))}, + ) + +let viewControls = (visibility, entries) => { + let entriesCompleted = List.length(List.filter(({completed, _}) => completed, entries)) + let entriesLeft = List.length(entries) - entriesCompleted + footer( + list{Html.Attributes.class("footer"), Html.Attributes.hidden(List.length(entries) == 0)}, + list{ + viewControlsCount(entriesLeft), + viewControlsFilters(visibility), + viewControlsClear(entriesCompleted), + }, + ) +} + +let infoFooter = () => + footer( + ~key="1", + list{Html.Attributes.class("info")}, + list{ + p(list{}, list{text("Double-click to edit a todo")}), + p( + list{}, + list{ + text("Written by "), + a(list{Html.Attributes.href("https://github.com/evancz")}, list{text("Evan Czaplicki")}), + text(" and converted by "), + a(list{Html.Attributes.href("https://github.com/overminddl1")}, list{text("OvermindDL1")}), + }, + ), + p(list{}, list{text("Part of "), a(list{Html.Attributes.href("http://todomvc.com")}, list{text("TodoMVC")})}), + }, + ) + +let view = model => + div( + list{Html.Attributes.class("todomvc-wrapper"), Html.Attributes.style("visibility", "hidden")}, + list{ + section( + list{Html.Attributes.class("todoapp")}, + /* [ viewInput model.field () */ + /* Optimization: Set the input as a lazy field */ + list{ + lazy1(model.field, viewInput(model.field)), + viewEntries(model.visibility, model.entries), + viewControls(model.visibility, model.entries), + }, + ), + lazy1("", infoFooter), + }, + ) + +/* Main Entrance */ + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, +}) diff --git a/test/main_todo_optimizedarray.res b/test/main_todo_optimizedarray.res new file mode 100644 index 0000000..e6ce3a4 --- /dev/null +++ b/test/main_todo_optimizedarray.res @@ -0,0 +1,391 @@ +/* https://github.com/evancz/react-angular-ember-elm-performance-comparison/blob/master/implementations/elm-0.17/Todo.elm */ +open Tea +open App +open Html +open Html.Events + + + +module Cmds = Tea_html_cmds + +/* MODEL */ + +type entry = { + description: string, + completed: bool, + editing: bool, + id: int, +} + +/* The full application state of our todo app. */ +type model = { + entries: array< + entry, + > /* Optimization: Use a better data structure that actually exists in OCaml */, + field: string, + uid: int, + visibility: string, +} + +let emptyModel = { + entries: [], + visibility: "All", + field: "", + uid: 0, +} + +let newEntry = (desc, id) => { + description: desc, + completed: false, + editing: false, + id: id, +} + +let init = () => (emptyModel, Cmd.none) + +/* UPDATE */ + +/* Users of our app can trigger messages by clicking and typing. These +messages are fed into the `update` function as they occur, letting us react +to them. */ +type msg = + /* | NoOp */ + | UpdateField(string) + | EditingEntry(int, bool) + | UpdateEntry(int, string) + | Add + | Delete(int) + | DeleteComplete + | Check(int, bool) + | CheckAll(bool) + | ChangeVisibility(string) + +/* How we update our Model on a given Msg? */ +let update = (model, x) => + /* NoOp -> model, Cmd.none */ + + switch x { + | Add => ( + { + ...model, + uid: model.uid + 1, + field: "", + entries: if model.field == "" { + model.entries + } else { + Array.concat(list{model.entries, [newEntry(model.field, model.uid)]}) + }, + }, + Cmd.none, + ) + + | UpdateField(field) => ({...model, field: field}, Cmd.none) + + | EditingEntry(id, editing) => + let updateEntry = t => + if t.id == id { + {...t, editing: editing} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + if editing { + Cmds.focus("todo-" ++ string_of_int(id)) + } else { + Cmd.none + }, + ) + + | UpdateEntry(id, description) => + let updateEntry = t => + if t.id == id { + {...t, description: description} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | Delete(id) => ( + { + ...model, + entries: List.filter(t => t.id != id, Array.to_list(model.entries)) |> Array.of_list, + }, + Cmd.none, + ) + + | DeleteComplete => ( + { + ...model, + entries: List.filter( + ({completed, _}) => !completed, + Array.to_list(model.entries), + ) |> Array.of_list, + }, + Cmd.none, + ) + + | Check(id, completed) => + let updateEntry = t => + if t.id == id { + {...t, completed: completed} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | CheckAll(completed) => + let updateEntry = t => {...t, completed: completed} + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | ChangeVisibility(visibility) => ({...model, visibility: visibility}, Cmd.none) + } + +/* View rendering */ + +let onEnter = (~key="", msg) => { + let tagger = ev => + switch ev["keyCode"] { + | 13 => Some(msg) + | _ => None + } + + onCB("keydown", ~key, tagger) +} + +let viewEntry = (todo, ()) => { + let key = string_of_int(todo.id) + let fullkey = key ++ (string_of_bool(todo.completed) ++ string_of_bool(todo.editing)) + /* Optimized: Added a key to the node to early-out if exact match, if key is unspecified then the sub section is + always recursed into, thus this is *not* like elm's keyed nodes but rather more strict. */ + li( + ~key=fullkey, + list{Html.Attributes.classList(list{("completed", todo.completed), ("editing", todo.editing)})}, + list{ + div( + list{Html.Attributes.class("view")}, + list{ + input'( + list{ + Html.Attributes.class("toggle"), + Html.Attributes.type'("checkbox"), + Html.Attributes.checked(todo.completed), + onClick(Check(todo.id, !todo.completed)), + }, + list{}, + ), + label( + list{onDoubleClick(EditingEntry(todo.id, true))}, + list{text(todo.description)}, + ), + button(list{Html.Attributes.class("destroy"), onClick(Delete(todo.id))}, list{}), + }, + ), + input'( + list{ + Html.Attributes.class("edit"), + Html.Attributes.value(todo.description), + Html.Attributes.name("title"), + Html.Attributes.id("todo-" ++ string_of_int(todo.id)), + onInput(~key, value => UpdateEntry(todo.id, value)), + onBlur(EditingEntry(todo.id, false)), + onEnter(~key, EditingEntry(todo.id, false)), + }, + list{}, + ), + }, + ) +} + +let viewEntries = (visibility, entries) => { + let isVisible = todo => + switch visibility { + | "Completed" => todo.completed + | "Active" => !todo.completed + | _ => true + } + let allCompleted = Array.fold_left((b, {completed, _}) => b && completed, true, entries) + let cssVisibility = if Array.length(entries) == 0 { + "hidden" + } else { + "visible" + } + section( + list{Html.Attributes.class("main"), Html.Attributes.style("visibility", cssVisibility)}, + list{ + input'( + list{ + Html.Attributes.class("toggle-all"), + Html.Attributes.type'("checkbox"), + Html.Attributes.name("toggle"), + Html.Attributes.checked(allCompleted), + onClick(CheckAll(!allCompleted)), + }, + list{}, + ), + label(list{Html.Attributes.for'("toggle-all")}, list{text("Mark all as complete")}), + ul(list{Html.Attributes.class("todo-list")}, Array.map(todo => + if isVisible(todo) { + lazy1( + string_of_int(todo.id) ++ + (string_of_bool(todo.completed) ++ + string_of_bool(todo.editing)), + viewEntry(todo), + ) + } else { + noNode + } + , entries) |> Array.to_list), + }, + ) +} + +let viewInput = (task, ()) => + header( + ~key=task, + list{Html.Attributes.class("header")}, + list{ + h1(list{}, list{text("todos")}), + input'( + list{ + Html.Attributes.class("new-todo"), + Html.Attributes.placeholder("What needs to be done?"), + Html.Attributes.autofocus(true), + Html.Attributes.value(task), + Html.Attributes.name("newTodo"), + onInput(str => UpdateField(str)), + onEnter(Add), + }, + list{}, + ), + }, + ) + +let viewControlsCount = entriesLeft => { + let item_ = if entriesLeft === 1 { + " item" + } else { + " items" + } + let left = string_of_int(entriesLeft) + span( + ~key=left, + list{Html.Attributes.class("todo-count")}, + list{strong(list{}, list{text(left)}), text(item_ ++ " left")}, + ) +} + +let visibilitySwap = (uri, visibility, actualVisibility) => + li( + list{onClick(ChangeVisibility(visibility))}, + list{ + a( + list{Html.Attributes.href(uri), Html.Attributes.classList(list{("selected", visibility == actualVisibility)})}, + list{text(visibility)}, + ), + }, + ) + +let viewControlsFilters = visibility => + ul( + list{Html.Attributes.class("filters")}, + list{ + visibilitySwap("#/", "All", visibility), + text(" "), + visibilitySwap("#/active", "Active", visibility), + text(" "), + visibilitySwap("#/completed", "Completed", visibility), + }, + ) + +let viewControlsClear = entriesCompleted => + button( + list{Html.Attributes.class("clear-completed"), Html.Attributes.hidden(entriesCompleted === 0), onClick(DeleteComplete)}, + list{text("Clear completed (" ++ (string_of_int(entriesCompleted) ++ ")"))}, + ) + +let viewControls = (visibility, entries) => { + let entriesCompleted = Array.fold_left((c, {completed, _}) => + if completed { + c + 1 + } else { + c + } + , 0, entries) + let entriesLeft = Array.length(entries) - entriesCompleted + footer( + list{Html.Attributes.class("footer"), Html.Attributes.hidden(Array.length(entries) == 0)}, + list{ + viewControlsCount(entriesLeft), + viewControlsFilters(visibility), + viewControlsClear(entriesCompleted), + }, + ) +} + +let infoFooter = () => + footer( + ~key="1", + list{Html.Attributes.class("info")}, + list{ + p(list{}, list{text("Double-click to edit a todo")}), + p( + list{}, + list{ + text("Written by "), + a(list{Html.Attributes.href("https://github.com/evancz")}, list{text("Evan Czaplicki")}), + text(" and converted by "), + a(list{Html.Attributes.href("https://github.com/overminddl1")}, list{text("OvermindDL1")}), + }, + ), + p(list{}, list{text("Part of "), a(list{Html.Attributes.href("http://todomvc.com")}, list{text("TodoMVC")})}), + }, + ) + +let view = model => + div( + list{Html.Attributes.class("todomvc-wrapper"), Html.Attributes.style("visibility", "hidden")}, + list{ + section( + list{Html.Attributes.class("todoapp")}, + /* [ viewInput model.field () */ + /* Optimization: Set the input as a lazy field */ + list{ + lazy1(model.field, viewInput(model.field)), + viewEntries(model.visibility, model.entries), + viewControls(model.visibility, model.entries), + }, + ), + lazy1("", infoFooter), + }, + ) + +/* Main Entrance */ + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, +}) diff --git a/test/main_todo_optimizedmap.res b/test/main_todo_optimizedmap.res new file mode 100644 index 0000000..350296b --- /dev/null +++ b/test/main_todo_optimizedmap.res @@ -0,0 +1,410 @@ +/* https://github.com/evancz/react-angular-ember-elm-performance-comparison/blob/master/implementations/elm-0.17/Todo.elm */ +open Tea +open App +open Html +open Html.Events + + +module Cmds = Tea_html_cmds + +/* module IntMap = Map.Make(struct type t = int let compare = compare end) */ +module IntMap = Map.Make({ + type t = int + let compare: (int, int) => int = compare +}) + +/* MODEL */ + +type entry = { + description: string, + completed: bool, + editing: bool, + id: int, +} + +/* The full application state of our todo app. */ +type model = { + entries: IntMap.t< + entry, + > /* Optimization: Use a better data structure that actually exists in OCaml */, + field: string, + uid: int, + visibility: string, +} + +let emptyModel = { + entries: IntMap.empty, + visibility: "All", + field: "", + uid: 0, +} + +let newEntry = (desc, id) => { + description: desc, + completed: false, + editing: false, + id: id, +} + +let init = () => (emptyModel, Cmd.none) + +/* UPDATE */ + +/* Users of our app can trigger messages by clicking and typing. These +messages are fed into the `update` function as they occur, letting us react +to them. */ +type msg = + /* | NoOp */ + | UpdateField(string) + | EditingEntry(int, bool) + | UpdateEntry(int, string) + | Add + | Delete(int) + | DeleteComplete + | Check(int, bool) + | CheckAll(bool) + | ChangeVisibility(string) + +/* How we update our Model on a given Msg? */ +let update = (model, x) => + /* NoOp -> model, Cmd.none */ + + switch x { + | Add => ( + { + ...model, + uid: model.uid + 1, + field: "", + entries: if model.field == "" { + model.entries + } else { + IntMap.add(model.uid, newEntry(model.field, model.uid), model.entries) + }, + }, + Cmd.none, + ) + + | UpdateField(field) => ({...model, field: field}, Cmd.none) + + | EditingEntry(id, editing) => + let updateEntry = t => + if t.id == id { + {...t, editing: editing} + } else { + t + } + ( + { + ...model, + entries: if IntMap.mem(id, model.entries) { + IntMap.add(id, updateEntry(IntMap.find(id, model.entries)), model.entries) + } else { + model.entries + }, + /* entries = Array.map updateEntry model.entries */ + }, + if editing { + Cmds.focus("todo-" ++ string_of_int(id)) + } else { + Cmd.none + }, + ) + + | UpdateEntry(id, description) => + let updateEntry = t => + if t.id == id { + {...t, description: description} + } else { + t + } + ( + { + ...model, + entries: if IntMap.mem(id, model.entries) { + IntMap.add(id, updateEntry(IntMap.find(id, model.entries)), model.entries) + } else { + model.entries + }, + }, + Cmd.none, + ) + + | Delete(id) => ( + { + ...model, + entries: IntMap.remove(id, model.entries), + }, + Cmd.none, + ) + + | DeleteComplete => ( + { + ...model, + entries: IntMap.filter((_id, {completed, _}) => !completed, model.entries), + }, + Cmd.none, + ) + + | Check(id, completed) => + let updateEntry = t => + if t.id == id { + {...t, completed: completed} + } else { + t + } + ( + { + ...model, + entries: if IntMap.mem(id, model.entries) { + IntMap.add(id, updateEntry(IntMap.find(id, model.entries)), model.entries) + } else { + model.entries + }, + }, + Cmd.none, + ) + + | CheckAll(completed) => + let updateEntry = t => {...t, completed: completed} + ( + { + ...model, + entries: IntMap.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | ChangeVisibility(visibility) => ({...model, visibility: visibility}, Cmd.none) + } + +/* View rendering */ + +let onEnter = (~key="", msg) => { + let tagger = ev => + switch ev["keyCode"] { + | 13 => Some(msg) + | _ => None + } + + onCB("keydown", ~key, tagger) +} + +let viewEntry = (todo, ()) => { + let key = string_of_int(todo.id) + let fullkey = key ++ (string_of_bool(todo.completed) ++ string_of_bool(todo.editing)) + /* Optimized: Added a key to the node to early-out if exact match, if key is unspecified then the sub section is + always recursed into, thus this is *not* like elm's keyed nodes but rather more strict. */ + li( + ~key=fullkey, + list{Html.Attributes.classList(list{("completed", todo.completed), ("editing", todo.editing)})}, + list{ + div( + list{Html.Attributes.class("view")}, + list{ + input'( + list{ + Html.Attributes.class("toggle"), + Html.Attributes.type'("checkbox"), + Html.Attributes.checked(todo.completed), + onClick(Check(todo.id, !todo.completed)), + }, + list{}, + ), + label( + list{onDoubleClick(EditingEntry(todo.id, true))}, + list{text(todo.description)}, + ), + button(list{Html.Attributes.class("destroy"), onClick(Delete(todo.id))}, list{}), + }, + ), + input'( + list{ + Html.Attributes.class("edit"), + Html.Attributes.value(todo.description), + Html.Attributes.name("title"), + Html.Attributes.id("todo-" ++ string_of_int(todo.id)), + onInput(~key, value => UpdateEntry(todo.id, value)), + onBlur(EditingEntry(todo.id, false)), + onEnter(~key, EditingEntry(todo.id, false)), + }, + list{}, + ), + }, + ) +} + +let viewEntries = (visibility, entries) => { + let isVisible = todo => + switch visibility { + | "Completed" => todo.completed + | "Active" => !todo.completed + | _ => true + } + let allCompleted = IntMap.for_all((_id, {completed, _}) => completed, entries) + let cssVisibility = if IntMap.is_empty(entries) { + "hidden" + } else { + "visible" + } + section( + list{Html.Attributes.class("main"), Html.Attributes.style("visibility", cssVisibility)}, + list{ + input'( + list{ + Html.Attributes.class("toggle-all"), + Html.Attributes.type'("checkbox"), + Html.Attributes.name("toggle"), + Html.Attributes.checked(allCompleted), + onClick(CheckAll(!allCompleted)), + }, + list{}, + ), + label(list{Html.Attributes.for'("toggle-all")}, list{text("Mark all as complete")}), + ul( + list{Html.Attributes.class("todo-list")}, + IntMap.bindings(entries) |> List.map(((_id, todo)) => + if isVisible(todo) { + lazy1( + string_of_int(todo.id) ++ + (string_of_bool(todo.completed) ++ + string_of_bool(todo.editing)), + viewEntry(todo), + ) + } else { + noNode + } + ), + ), + }, + ) +} + +let viewInput = (task, ()) => + header( + ~key=task, + list{Html.Attributes.class("header")}, + list{ + h1(list{}, list{text("todos")}), + input'( + list{ + Html.Attributes.class("new-todo"), + Html.Attributes.placeholder("What needs to be done?"), + Html.Attributes.autofocus(true), + Html.Attributes.value(task), + Html.Attributes.name("newTodo"), + onInput(str => UpdateField(str)), + onEnter(Add), + }, + list{}, + ), + }, + ) + +let viewControlsCount = entriesLeft => { + let item_ = if entriesLeft === 1 { + " item" + } else { + " items" + } + let left = string_of_int(entriesLeft) + span( + ~key=left, + list{Html.Attributes.class("todo-count")}, + list{strong(list{}, list{text(left)}), text(item_ ++ " left")}, + ) +} + +let visibilitySwap = (uri, visibility, actualVisibility) => + li( + list{onClick(ChangeVisibility(visibility))}, + list{ + a( + list{Html.Attributes.href(uri), Html.Attributes.classList(list{("selected", visibility == actualVisibility)})}, + list{text(visibility)}, + ), + }, + ) + +let viewControlsFilters = visibility => + ul( + list{Html.Attributes.class("filters")}, + list{ + visibilitySwap("#/", "All", visibility), + text(" "), + visibilitySwap("#/active", "Active", visibility), + text(" "), + visibilitySwap("#/completed", "Completed", visibility), + }, + ) + +let viewControlsClear = entriesCompleted => + button( + list{Html.Attributes.class("clear-completed"), Html.Attributes.hidden(entriesCompleted === 0), onClick(DeleteComplete)}, + list{text("Clear completed (" ++ (string_of_int(entriesCompleted) ++ ")"))}, + ) + +let viewControls = (visibility, entries) => { + let entriesCompleted = IntMap.fold((_id, {completed, _}, c) => + if completed { + c + 1 + } else { + c + } + , entries, 0) + let len = IntMap.cardinal(entries) + let entriesLeft = len - entriesCompleted + footer( + list{Html.Attributes.class("footer"), Html.Attributes.hidden(len == 0)}, + list{ + viewControlsCount(entriesLeft), + viewControlsFilters(visibility), + viewControlsClear(entriesCompleted), + }, + ) +} + +let infoFooter = () => + footer( + ~key="1", + list{Html.Attributes.class("info")}, + list{ + p(list{}, list{text("Double-click to edit a todo")}), + p( + list{}, + list{ + text("Written by "), + a(list{Html.Attributes.href("https://github.com/evancz")}, list{text("Evan Czaplicki")}), + text(" and converted by "), + a(list{Html.Attributes.href("https://github.com/overminddl1")}, list{text("OvermindDL1")}), + }, + ), + p(list{}, list{text("Part of "), a(list{Html.Attributes.href("http://todomvc.com")}, list{text("TodoMVC")})}), + }, + ) + +let view = model => + div( + list{Html.Attributes.class("todomvc-wrapper"), Html.Attributes.style("visibility", "hidden")}, + list{ + section( + list{Html.Attributes.class("todoapp")}, + /* [ viewInput model.field () */ + /* Optimization: Set the input as a lazy field */ + list{ + lazy1(model.field, viewInput(model.field)), + viewEntries(model.visibility, model.entries), + viewControls(model.visibility, model.entries), + }, + ), + lazy1("", infoFooter), + }, + ) + +/* Main Entrance */ + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: _model => Sub.none, +}) diff --git a/test/main_todoarray.res b/test/main_todoarray.res new file mode 100644 index 0000000..0e9cfa4 --- /dev/null +++ b/test/main_todoarray.res @@ -0,0 +1,542 @@ +/* https://github.com/evancz/react-angular-ember-elm-performance-comparison/blob/master/implementations/elm-0.17/Todo.elm */ +open Tea +open App +open Html +open Html.Events + + +module Cmds = Tea_html_cmds +/* MODEL */ + +type entry = { + description: string, + completed: bool, + editing: bool, + id: int, +} + +/* The full application state of our todo app. */ +type model = { + entries: array, + field: string, + uid: int, + visibility: string, +} + +let emptyModel = { + entries: [], + visibility: "All", + field: "", + uid: 0, +} + +let newEntry = (desc, id) => { + description: desc, + completed: false, + editing: false, + id: id, +} + +let init = () => (emptyModel, Cmd.none) + +/* UPDATE */ + +/* Users of our app can trigger messages by clicking and typing. These +messages are fed into the `update` function as they occur, letting us react +to them. */ +type msg = + | NoOp + | UpdateField(string) + | EditingEntry(int, bool) + | UpdateEntry(int, string) + | Add + | Delete(int) + | DeleteComplete + | Check(int, bool) + | CheckAll(bool) + | ChangeVisibility(string) + +/* How we update our Model on a given Msg? */ +let update = (model, x) => + switch x { + | NoOp => (model, Cmd.none) + + | Add => ( + { + ...model, + uid: model.uid + 1, + field: "", + entries: if model.field == "" { + model.entries + } else { + Array.concat(list{model.entries, [newEntry(model.field, model.uid)]}) + }, + }, + Cmd.none, + ) + + | UpdateField(field) => ({...model, field: field}, Cmd.none) + + | EditingEntry(id, editing) => + let updateEntry = t => + if t.id == id { + {...t, editing: editing} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + if editing { + Cmds.focus("todo-" ++ string_of_int(id)) + } else { + Cmd.none + }, + ) + + | UpdateEntry(id, description) => + let updateEntry = t => + if t.id == id { + {...t, description: description} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | Delete(id) => ( + { + ...model, + entries: List.filter(t => t.id != id, Array.to_list(model.entries)) |> Array.of_list, + }, + Cmd.none, + ) + + | DeleteComplete => ( + { + ...model, + entries: List.filter( + ({completed, _}) => !completed, + Array.to_list(model.entries), + ) |> Array.of_list, + }, + Cmd.none, + ) + + | Check(id, completed) => + let updateEntry = t => + if t.id == id { + {...t, completed: completed} + } else { + t + } + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + + | CheckAll(completed) => + let updateEntry = t => {...t, completed: completed} + ( + { + ...model, + entries: Array.map(updateEntry, model.entries), + }, + Cmd.none, + ) + | ChangeVisibility(visibility) => ({...model, visibility: visibility}, Cmd.none) + } + +/* View rendering */ + +let onEnter = (~key="", msg) => { + let tagger = ev => + switch ev["keyCode"] { + | 13 => Some(msg) + | _ => None + } + + onCB("keydown", ~key, tagger) +} + +let viewEntry = todo => { + let key = string_of_int(todo.id) + li( + list{Html.Attributes.classList(list{("completed", todo.completed), ("editing", todo.editing)})}, + list{ + div( + list{Html.Attributes.class("view")}, + list{ + input'( + list{ + Html.Attributes.class("toggle"), + Html.Attributes.type'("checkbox"), + Html.Attributes.checked(todo.completed), + onClick(Check(todo.id, !todo.completed)), + }, + list{}, + ), + label( + list{onDoubleClick(EditingEntry(todo.id, true))}, + list{text(todo.description)}, + ), + button(list{Html.Attributes.class("destroy"), onClick(Delete(todo.id))}, list{}), + }, + ), + input'( + list{ + Html.Attributes.class("edit"), + Html.Attributes.value(todo.description), + Html.Attributes.name("title"), + Html.Attributes.id("todo-" ++ string_of_int(todo.id)), + onInput(~key, value => UpdateEntry(todo.id, value)), + onBlur(EditingEntry(todo.id, false)), + onEnter(~key, EditingEntry(todo.id, false)), + }, + list{}, + ), + }, + ) +} + +let viewEntries = (visibility, entries) => { + let isVisible = todo => + switch visibility { + | "Completed" => todo.completed + | "Active" => !todo.completed + | _ => true + } + let allCompleted = Array.fold_left((b, {completed, _}) => b && completed, true, entries) + let cssVisibility = if Array.length(entries) == 0 { + "hidden" + } else { + "visible" + } + section( + list{Html.Attributes.class("main"), Html.Attributes.style("visibility", cssVisibility)}, + list{ + input'( + list{ + Html.Attributes.class("toggle-all"), + Html.Attributes.type'("checkbox"), + Html.Attributes.name("toggle"), + Html.Attributes.checked(allCompleted), + onClick( CheckAll(!allCompleted)), + }, + list{}, + ), + label(list{Html.Attributes.for'("toggle-all")}, list{text("Mark all as complete")}), + ul( + list{Html.Attributes.class("todo-list")}, + List.map(viewEntry, List.filter(isVisible, Array.to_list(entries))), + ), + }, + ) +} + +let viewInput = task => + header( + list{Html.Attributes.class("header")}, + list{ + h1(list{}, list{text("todos")}), + input'( + list{ + Html.Attributes.class("new-todo"), + Html.Attributes.placeholder("What needs to be done?"), + Html.Attributes.autofocus(true), + Html.Attributes.value(task), + Html.Attributes.name("newTodo"), + onInput(str => UpdateField(str)), + onEnter(Add), + }, + list{}, + ), + }, + ) + +let viewControlsCount = entriesLeft => { + let item_ = if entriesLeft === 1 { + " item" + } else { + " items" + } + span( + list{Html.Attributes.class("todo-count")}, + list{strong(list{}, list{text(string_of_int(entriesLeft))}), text(item_ ++ " left")}, + ) +} + +let visibilitySwap = (uri, visibility, actualVisibility) => + li( + list{onClick(ChangeVisibility(visibility))}, + list{ + a( + list{Html.Attributes.href(uri), Html.Attributes.classList(list{("selected", visibility == actualVisibility)})}, + list{text(visibility)}, + ), + }, + ) + +let viewControlsFilters = visibility => + ul( + list{Html.Attributes.class("filters")}, + list{ + visibilitySwap("#/", "All", visibility), + text(" "), + visibilitySwap("#/active", "Active", visibility), + text(" "), + visibilitySwap("#/completed", "Completed", visibility), + }, + ) + +let viewControlsClear = entriesCompleted => + button( + list{Html.Attributes.class("clear-completed"), Html.Attributes.hidden(entriesCompleted === 0), onClick(DeleteComplete)}, + list{text("Clear completed (" ++ (string_of_int(entriesCompleted) ++ ")"))}, + ) + +let viewControls = (visibility, entries) => { + let entriesCompleted = Array.fold_left((c, {completed, _}) => + if completed { + c + 1 + } else { + c + } + , 0, entries) + let entriesLeft = Array.length(entries) - entriesCompleted + footer( + list{Html.Attributes.class("footer"), Html.Attributes.hidden(Array.length(entries) == 0)}, + list{ + viewControlsCount(entriesLeft), + viewControlsFilters(visibility), + viewControlsClear(entriesCompleted), + }, + ) +} + +let infoFooter = footer( + list{Html.Attributes.class("info")}, + list{ + p(list{}, list{text("Double-click to edit a todo")}), + p( + list{}, + list{ + text("Written by "), + a(list{Html.Attributes.href("https://github.com/evancz")}, list{text("Evan Czaplicki")}), + text(" and converted by "), + a(list{Html.Attributes.href("https://github.com/overminddl1")}, list{text("OvermindDL1")}), + }, + ), + p(list{}, list{text("Part of "), a(list{Html.Attributes.href("http://todomvc.com")}, list{text("TodoMVC")})}), + }, +) + +let view = model => + div( + list{Html.Attributes.class("todomvc-wrapper"), Html.Attributes.style("visibility", "hidden")}, + list{ + section( + list{Html.Attributes.class("todoapp")}, + list{ + viewInput(model.field), + viewEntries(model.visibility, model.entries), + viewControls(model.visibility, model.entries), + }, + ), + infoFooter, + }, + ) + +/* +let array_viewEntry todo = + let open Vdom in + let key = string_of_int todo.id in + arraynode "" "li" "" "" + [| classList + [ ("completed", todo.completed) + ; ("editing", todo.editing) + ] + |] + [| arraynode "" "div" "" "" + [| class "view" |] + [| arraynode "" "input" "" "" + [| class "toggle" + ; type' "checkbox" + ; checked todo.completed + ; onClick ~key:(key ^ string_of_bool todo.completed) (Check (todo.id, not todo.completed)) + |] + [||] + ; arraynode "" "label" "" "" + [| onDoubleClick ~key:key (EditingEntry (todo.id, true)) |] + [| text todo.description |] + ; arraynode "" "button" "" "" + [| class "destroy" + ; onClick ~key:key (Delete todo.id) + |] + [||] + |] + ; arraynode "" "input" "" "" + [| class "edit" + ; value todo.description + ; name "title" + ; id ("todo-" ^ string_of_int todo.id) + ; onInput ~key:key (fun value -> UpdateEntry (todo.id, value)) + ; onBlur ~key:key (EditingEntry (todo.id, false)) + ; onEnter ~key:key (EditingEntry (todo.id, false)) + |] + [||] + |] + +let array_viewEntries visibility entries = + let open Vdom in + let isVisible todo = + match visibility with + | "Completed" -> todo.completed + | "Active" -> not todo.completed + | _ -> true in + let allCompleted = + Array.fold_left (fun b {completed} -> b && completed) true entries in + let cssVisibility = + if Array.length entries = 0 then "hidden" else "visible" in + arraynode "" "section" "" "" + [| class "main" + ; style "visibility" cssVisibility + |] + [| arraynode "" "input" "" "" + [| class "toggle-all" + ; type' "checkbox" + ; name "toggle" + ; checked allCompleted + ; onClick ~key:(string_of_bool allCompleted) (CheckAll (not allCompleted)) + |] + [||] + ; arraynode "" "label" "" "" + [| for' "toggle-all" |] + [| text "Mark all as complete" |] + ; arraynode "" "ul" "" "" [| class "todo-list" |] (Array.map (fun todo -> if isVisible todo then array_viewEntry todo else noNode) entries) + |] + +let array_viewInput task = + let open Vdom in + arraynode "" "header" "" "" + [| class "header" |] + [| arraynode "" "h1" "" "" [||] [| text "todos" |] + ; arraynode "" "input" "" "" + [| class "new-todo" + ; placeholder "What needs to be done?" + ; autofocus true + ; value task + ; name "newTodo" + ; onInput (fun str -> (UpdateField str)) + ; onEnter Add + |] + [||] + |] + +let array_viewControlsCount entriesLeft = + let open Vdom in + let item_ = + if entriesLeft == 1 then " item" else " items" in + arraynode "" "span" "" "" + [| class "todo-count" |] + [| arraynode "" "strong" "" "" [||] [| text (string_of_int entriesLeft) |] + ; text (item_ ^ " left") + |] + +let array_visibilitySwap uri visibility actualVisibility = + let open Vdom in + arraynode "" "li" "" "" + [| onClick ~key:visibility (ChangeVisibility visibility) |] + [| arraynode "" "a" "" "" [| href uri; classList [("selected", visibility = actualVisibility)] |] + [| text visibility |] + |] + +let array_viewControlsFilters visibility = + let open Vdom in + arraynode "" "ul" "" "" + [| class "filters" |] + [| visibilitySwap "#/" "All" visibility + ; text " " + ; visibilitySwap "#/active" "Active" visibility + ; text " " + ; visibilitySwap "#/completed" "Completed" visibility + |] + +let array_viewControlsClear entriesCompleted = + let open Vdom in + arraynode "" "button" "" "" + [| class "clear-completed" + ; hidden (entriesCompleted == 0) + ; onClick DeleteComplete + |] + [| text ("Clear completed (" ^ string_of_int entriesCompleted ^ ")") + |] + +let array_viewControls visibility entries = + let open Vdom in + let entriesCompleted = + Array.fold_left (fun c {completed} -> if completed then c + 1 else c) 0 entries in + let entriesLeft = + Array.length entries - entriesCompleted in + arraynode "" "footer" "" "" + [| class "footer" + ; hidden (Array.length entries = 0) + |] + [| array_viewControlsCount entriesLeft + ; array_viewControlsFilters visibility + ; array_viewControlsClear entriesCompleted + |] + +let array_infoFooter = + let open Vdom in + arraynode "" "footer" "" "" [| class "info" |] + [| arraynode "" "p" "" "" [||] [| text "Double-click to edit a todo" |] + ; arraynode "" "p" "" "" [||] + [| text "Written by " + ; arraynode "" "a" "" "" [| href "https://github.com/evancz" |] [| text "Evan Czaplicki" |] + ; text " and converted by " + ; arraynode "" "a" "" "" [| href "https://github.com/overminddl1" |] [| text "OvermindDL1" |] + |] + ; arraynode "" "p" "" "" [||] + [| text "Part of " + ; arraynode "" "a" "" "" [| href "http://todomvc.com" |] [| text "TodoMVC" |] + |] + |] +let view_array model = + let open Vdom in + arraynode "" "div" "" "" + [| class "todomvc-wrapper" + ; style "visibility" "hidden" + |] + [| arraynode "" "section" "" "" + [| class "todoapp" |] + [| array_viewInput model.field + ; array_viewEntries model.visibility model.entries + ; array_viewControls model.visibility model.entries + |] + ; array_infoFooter + |] */ + +/* let s = ref noNode */ +let viewNew = model => + /* let () = s := view_array model in */ + view(model) + +/* Main Entrance */ + +let main = standardProgram({ + init: init, + update: update, + view: view /* = viewNew */, + subscriptions: _model => Sub.none, +}) diff --git a/test/test_client.res b/test/test_client.res new file mode 100644 index 0000000..4836de6 --- /dev/null +++ b/test/test_client.res @@ -0,0 +1,36 @@ +let counter = { + open Test_client_counter + main +} +let counter_debug_beginner = { + open Test_client_counter_debug_beginner + main +} +let counter_debug_standard = { + open Test_client_counter_debug_standard + main +} +let counter_debug_program = { + open Test_client_counter_debug_program + main +} +let btn_update_span = { + open Test_client_btn_update_span + main +} +let attribute_removal = { + open Test_client_attribute_removal + main +} +let drag = { + open Test_client_drag + main +} +let on_with_options = { + open Test_client_on_with_options + main +} +let http_task = { + open Test_client_http_task + main +} diff --git a/test/test_client_attribute_removal.res b/test/test_client_attribute_removal.res new file mode 100644 index 0000000..eb6b416 --- /dev/null +++ b/test/test_client_attribute_removal.res @@ -0,0 +1,87 @@ +open Tea.App +open Tea.Html +open Tea_html.Events + + +type model = { + selected: option, + languages: list, +} + +@deriving({accessors: accessors}) +type message = + | Select(string) + | Delete + +let render_selected = x => + switch x { + | Some(selected) => + div( + list{}, + list{ + text("you selected " ++ selected), + div(list{onClick(Delete)}, list{text("delete selection")}), + }, + ) + | None => div(list{}, list{text("Nothing selected")}) + } + +/* let lang l is_selected = + * let baseProps = [onClick (Select l); style "color" "blue"] in + * let props = if is_selected == true then (style "border" "1px solid black")::baseProps else baseProps + * in + * li props [text l] */ + +let lang = (l, is_selected) => + li( + list{ + onClick(Select(l)), + Tea_html.Attributes.style("color", "blue"), + if is_selected { + Tea_html.Attributes.style("border", "1px solid black") + } else { + Tea_html.Attributes.noProp + }, + if is_selected { + Vdom.attribute("", "lang", l) + } else { + Tea_html.Attributes.noProp + }, + }, + list{text(l)}, + ) + +let render_languages = (selected, languages) => { + let is_selected = (selected, language) => + switch selected { + | Some(l) => language === l + | None => false + } + + let rendered = List.map(l => lang(l, is_selected(selected, l)), languages) + ul(list{}, rendered) +} + +let update = (state, x) => + switch x { + | Select(lang) => {...state, selected: Some(lang)} + | Delete => {...state, selected: None} + } + +let view = state => + div( + list{}, + list{render_selected(state.selected), render_languages(state.selected, state.languages)}, + ) + +let main = { + let initialState = { + selected: Some("Erlang"), + languages: list{"Erlang", "Ocaml", "Clojure"}, + } + beginnerProgram({ + model: initialState, + update: update, + view: view, + }) +} diff --git a/test/test_client_btn_update_span.res b/test/test_client_btn_update_span.res new file mode 100644 index 0000000..af5bd86 --- /dev/null +++ b/test/test_client_btn_update_span.res @@ -0,0 +1,33 @@ +open Tea.App +open Tea_html.Events +open Tea_html.Attributes +open Tea.Html + +@deriving({accessors: accessors}) type msg = Trigger + +type model = (option, option) + +let update' = (model, x) => + switch x { + | Trigger => + let (left, _) = model + (left, Some("right")) + } + +let render_model = x => + switch x { + | (Some(_), Some(_)) => input'(list{value("This should be on screen")}, list{}) + | _ => span(list{}, list{text("nothing")}) + } + +let view' = model => + div( + list{}, + list{button(list{onClick(Trigger)}, list{text("trigger rerender")}), render_model(model)}, + ) + +let main = beginnerProgram({ + model: (Some("left"), None), + update: update', + view: view', +}) diff --git a/test/test_client_counter.res b/test/test_client_counter.res new file mode 100644 index 0000000..5b60a63 --- /dev/null +++ b/test/test_client_counter.res @@ -0,0 +1,52 @@ +open Tea.App +open Tea.Html +open Tea_html.Events + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +let update = (model, x) => + switch x { + | Increment => model + 1 + | Decrement => model - 1 + | Reset => 0 + | Set(v) => v + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Tea_html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button( + "Increment", + if model >= 3 { + Decrement + } else { + Increment + }, + ), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let main = beginnerProgram({ + model: 4, + update: update, + view: view, +}) diff --git a/test/test_client_counter_debug_beginner.res b/test/test_client_counter_debug_beginner.res new file mode 100644 index 0000000..f076da4 --- /dev/null +++ b/test/test_client_counter_debug_beginner.res @@ -0,0 +1,63 @@ +open Tea.App +open Tea.Html +open Tea_html.Events + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +let string_of_msg = x => + switch x { + | Increment => "Increment" + | Decrement => "Decrement" + | Reset => "Reset" + | Set(_) => "Set" + } + +let update = (model, x) => + switch x { + | Increment => model + 1 + | Decrement => model - 1 + | Reset => 0 + | Set(v) => v + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Tea_html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button( + "Increment", + if model >= 3 { + Decrement + } else { + Increment + }, + ), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let main = Tea.Debug.beginnerProgram( + { + model: 4, + update: update, + view: view, + }, + string_of_msg, +) diff --git a/test/test_client_counter_debug_program.res b/test/test_client_counter_debug_program.res new file mode 100644 index 0000000..a58b589 --- /dev/null +++ b/test/test_client_counter_debug_program.res @@ -0,0 +1,69 @@ +open Tea.App +open Tea.Html +open Tea_html.Events + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +let string_of_msg = x => + switch x { + | Increment => "Increment" + | Decrement => "Decrement" + | Reset => "Reset" + | Set(_) => "Set" + } + +let init = () => (4, Tea.Cmd.none) + +let subscriptions = _ => Tea.Sub.none + +let update = (model, x) => + switch x { + | Increment => (model + 1, Tea.Cmd.none) + | Decrement => (model - 1, Tea.Cmd.none) + | Reset => (0, Tea.Cmd.none) + | Set(v) => (v, Tea.Cmd.none) + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Tea_html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button( + "Increment", + if model >= 3 { + Decrement + } else { + Increment + }, + ), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let main = Tea.Debug.program( + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + shutdown: _model => Tea.Cmd.none, + }, + string_of_msg, +) diff --git a/test/test_client_counter_debug_standard.res b/test/test_client_counter_debug_standard.res new file mode 100644 index 0000000..8499f93 --- /dev/null +++ b/test/test_client_counter_debug_standard.res @@ -0,0 +1,69 @@ +open Tea.App +open Tea.Html +open Tea_html.Events + + +type msg = + | Increment + | Decrement + | Reset + | Set(int) + +let string_of_msg = x => + switch x { + | Increment => "Increment" + | Decrement => "Decrement" + | Reset => "Reset" + | Set(_) => "Set" + } + +let init = () => (4, Tea.Cmd.none) + +let subscriptions = _ => Tea.Sub.none + +let update = (model, x) => + switch x { + | Increment => (model + 1, Tea.Cmd.none) + | Decrement => (model - 1, Tea.Cmd.none) + | Reset => (0, Tea.Cmd.none) + | Set(v) => (v, Tea.Cmd.none) + } + +let view_button = (title, msg) => button(list{onClick(msg)}, list{text(title)}) + +let view = model => + div( + list{}, + list{ + span(list{Tea_html.Attributes.style("text-weight", "bold")}, list{text(string_of_int(model))}), + br(list{}), + view_button( + "Increment", + if model >= 3 { + Decrement + } else { + Increment + }, + ), + br(list{}), + view_button("Decrement", Decrement), + br(list{}), + view_button("Set to 42", Set(42)), + br(list{}), + if model != 0 { + view_button("Reset", Reset) + } else { + noNode + }, + }, + ) + +let main = Tea.Debug.standardProgram( + { + init: init, + update: update, + view: view, + subscriptions: subscriptions, + }, + string_of_msg, +) diff --git a/test/test_client_drag.res b/test/test_client_drag.res new file mode 100644 index 0000000..fc98df3 --- /dev/null +++ b/test/test_client_drag.res @@ -0,0 +1,104 @@ +open Tea +open Tea.App +open Tea_html.Attributes +open Tea_html.Events +open Tea.Html +open Tea.Mouse + +@deriving({accessors: accessors}) +type msg = + | DragStart(position) + | DragAt(position) + | DragEnd(position) + +type drag = { + start: position, + current: position, +} + +type model = { + position: position, + drag: option, +} + +let init = () => ({position: {x: 200, y: 200}, drag: None}, Cmd.none) + +let getPosition = ({position, drag}) => + switch drag { + | None => position + + | Some({start, current}) => { + x: position.x + current.x - start.x, + y: position.y + current.y - start.y, + } + } + +let updateHelp = ({position} as model, x) => + switch x { + | DragStart(xy) => { + position: position, + drag: Some({start: xy, current: xy}), + } + + | DragAt(xy) => { + position: position, + drag: switch model.drag { + | None => None + | Some(drag) => Some({...drag, current: xy}) + }, + } + + | DragEnd(_) => { + position: getPosition(model), + drag: None, + } + } + +let update = (model, msg) => (updateHelp(model, msg), Cmd.none) + +let subscriptions = model => + switch model.drag { + | None => Sub.none + + | Some(_) => Sub.batch(list{Mouse.moves(dragAt), Mouse.ups(dragEnd)}) + } + +let px = number => string_of_int(number) ++ "px" + +let onMouseDown = onCB("mousedown", ~key= "", ev => + Rescript_json_combinators_extended.decodeEvent( + JsonCombinators.Json.Decode.map(Mouse.position, (. v)=> dragStart(v)), + ev, + ) |> Tea_result.resultToOption +) + +let view = model => { + let realPosition = getPosition(model) + div( + list{ + onMouseDown, + styles(list{ + ("background-color", "#3C8D2F"), + ("cursor", "move"), + ("width", "100px"), + ("height", "100px"), + ("border-radius", "4px"), + ("position", "absolute"), + ("left", px(realPosition.x)), + ("top", px(realPosition.y)), + ("color", "white"), + ("display", "flex"), + ("align-items", "center"), + ("justify-content", "center"), + }), + }, + list{text("Drag Me!")}, + ) +} + +let main = standardProgram({ + init: init, + update: update, + view: view, + subscriptions: subscriptions, +}) diff --git a/test/test_client_http_task.res b/test/test_client_http_task.res new file mode 100644 index 0000000..cade210 --- /dev/null +++ b/test/test_client_http_task.res @@ -0,0 +1,50 @@ +open Tea +open Tea.Html +open Tea_html.Events +type result<'ok, 'err> = result<'ok, 'err> + +@deriving(accessors) +type msg = + | GotResponse(result) + | Req + +let update = (model, x) => + switch x { + | GotResponse(Ok(t)) => (t, Cmd.none) + | GotResponse(Error(t)) => (t, Cmd.none) + | Req => ( + model, + Http.getString("https://jsonplaceholder.typicode.com/todos/1") + |> Http.toTask + |> Task.mapError(Http.stringOfError) + |> Task.andThen(res => Ex.LocalStorage.setItem("todo-1", res)) + |> Task.andThen(() => + Http.getString("https://jsonplaceholder.typicode.com/todos/2") + |> Http.toTask + |> Task.mapError(Http.stringOfError) + ) + |> Task.andThen(res => Ex.LocalStorage.setItem("todo-2", res)) + |> Task.andThen(() => Task.succeed("both saved")) + |> Task.attempt(gotResponse), + ) + } + +let view = model => + div(list{}, list{button(list{onClick(Req)}, list{text("execute")}), text(model)}) + +let som = x => + switch x { + | GotResponse(Ok(_)) => "GotResponse Ok" + | GotResponse(Error(_)) => "GotResponse Error" + | Req => "Req" + } + +let main = Tea.Debug.standardProgram( + { + init: () => ("nothing", Cmd.none), + subscriptions: _ => Sub.none, + update: update, + view: view, + }, + som, +) diff --git a/test/test_client_on_with_options.res b/test/test_client_on_with_options.res new file mode 100644 index 0000000..baba2e2 --- /dev/null +++ b/test/test_client_on_with_options.res @@ -0,0 +1,61 @@ +open Tea.App + +@deriving({accessors: accessors}) +type msg = + | Click + | Set_value(int) + +let update = (model, x) => + switch x { + | Click => model + 1 + | Set_value(n) => n + } + +let view = model => { + open Tea.Html + open Tea.Html.Attributes + open Tea.Html.Events + open JsonCombinators + let clientX = Json.Decode.field("clientX", Json.Decode.int) + div( + list{}, + List.map( + e => div(list{}, list{e}), + list{ + model |> string_of_int |> text, + button(list{onClick(Click)}, list{text("onClick")}), + button(list{on(~key="", "click", Rescript_json_combinators_extended.succeed(Click))}, list{text("on \"click\"")}), + a(list{href("https://www.google.com")}, list{text("a normal link")}), + a( + list{ + href("https://www.google.com"), + onWithOptions( + ~key="", + "click", + {...defaultOptions, preventDefault: true}, + Rescript_json_combinators_extended.succeed(Click), + ), + }, + list{text("a link with prevent default")}, + ), + button( + list{on(~key="", "click", Json.Decode.map(clientX,(. v)=> set_value(v)))}, + list{text("on \"click\", use clientX value")}, + ), + input'( + list{ + type'("text"), + on(~key="", "input",((. v) => v |> int_of_string |> set_value)|> Json.Decode.map(targetValue)), + }, + list{}, + ), + }, + ), + ) +} + +let main = beginnerProgram({ + model: 0, + update: update, + view: view, +}) diff --git a/test-ocaml/tester.ml b/test/tester.res similarity index 100% rename from test-ocaml/tester.ml rename to test/tester.res diff --git a/test/testering.res b/test/testering.res new file mode 100644 index 0000000..2d3f3c9 --- /dev/null +++ b/test/testering.res @@ -0,0 +1,3 @@ +type person = {name: string, age: int} +let somePerson = {name: "Guy", age: 30} +let {name: n, age: a} = somePerson