diff --git a/packages/rescript-relay-router/cli/RescriptRelayRouterCli.bundle.mjs b/packages/rescript-relay-router/cli/RescriptRelayRouterCli.bundle.mjs index c4c1210..4c766e6 100755 --- a/packages/rescript-relay-router/cli/RescriptRelayRouterCli.bundle.mjs +++ b/packages/rescript-relay-router/cli/RescriptRelayRouterCli.bundle.mjs @@ -1,10 +1,6 @@ #!/usr/bin/env node -import * as Caml_option from 'rescript/lib/es6/caml_option.js'; -import * as Caml_js_exceptions from 'rescript/lib/es6/caml_js_exceptions.js'; import * as Fs from 'fs'; import * as Path from 'path'; -import * as Js_exn from 'rescript/lib/es6/js_exn.js'; -import * as Caml_exceptions from 'rescript/lib/es6/caml_exceptions.js'; import FastGlob from 'fast-glob'; import * as FastFuzzy from 'fast-fuzzy'; import * as JsoncParser$1 from 'jsonc-parser'; @@ -15,11 +11,47 @@ import * as Url from 'url'; import Chokidar from 'chokidar'; import * as VscodeJsonrpc from 'vscode-jsonrpc'; import * as MessagesJs from 'vscode-jsonrpc/lib/messages.js'; -import * as Caml_obj from 'rescript/lib/es6/caml_obj.js'; import * as Os from 'os'; import * as Child_process from 'child_process'; import Chalk from 'chalk'; +function some(x) { + if (x === undefined) { + return { + BS_PRIVATE_NESTED_SOME_NONE: 0 + }; + } else if (x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return { + BS_PRIVATE_NESTED_SOME_NONE: x.BS_PRIVATE_NESTED_SOME_NONE + 1 | 0 + }; + } else { + return x; + } +} + +function nullable_to_opt(x) { + if (x == null) { + return ; + } else { + return some(x); + } +} + +function valFromOption(x) { + if (!(x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined)) { + return x; + } + var depth = x.BS_PRIVATE_NESTED_SOME_NONE; + if (depth === 0) { + return ; + } else { + return { + BS_PRIVATE_NESTED_SOME_NONE: depth - 1 | 0 + }; + } +} +/* No side effect */ + // Generated by ReScript, PLEASE EDIT WITH CARE @@ -35,7 +67,7 @@ function filterMap$1(a, f) { var v = a[i]; var v$1 = f(v); if (v$1 !== undefined) { - r[j] = Caml_option.valFromOption(v$1); + r[j] = valFromOption(v$1); j = j + 1 | 0; } @@ -45,26 +77,66 @@ function filterMap$1(a, f) { } /* No side effect */ +var idMap = new Map(); + +function create(str) { + var v = idMap.get(str); + var id; + if (v !== undefined) { + var id$1 = v + 1 | 0; + idMap.set(str, id$1); + id = id$1; + } else { + idMap.set(str, 1); + id = 1; + } + return str + ("/" + id); +} + +function is_extension(e) { + if (e == null) { + return false; + } else { + return typeof e.RE_EXN_ID === "string"; + } +} +/* idMap Not a pure module */ + +function internalToOCamlException(e) { + if (is_extension(e)) { + return e; + } else { + return { + RE_EXN_ID: "JsError", + _1: e + }; + } +} +/* Caml_exceptions Not a pure module */ + +var $$Error$1 = "JsError"; +/* No side effect */ + // Generated by ReScript, PLEASE EDIT WITH CARE function forEach(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return f(valFromOption(opt)); } } function flatMap(opt, f) { if (opt !== undefined) { - return f(Caml_option.valFromOption(opt)); + return f(valFromOption(opt)); } } function getOr(opt, $$default) { if (opt !== undefined) { - return Caml_option.valFromOption(opt); + return valFromOption(opt); } else { return $$default; } @@ -487,7 +559,7 @@ function copyAuxWitFilterMap(f, _cellX, _prec) { var h = f(cellX.hd); if (h !== undefined) { var next = { - hd: Caml_option.valFromOption(h), + hd: valFromOption(h), tl: /* [] */0 }; prec.tl = next; @@ -647,7 +719,7 @@ function find(_xs, p) { } var x = xs.hd; if (p(x)) { - return Caml_option.some(x); + return some(x); } _xs = xs.tl; continue ; @@ -683,7 +755,7 @@ function filterMap(_xs, p) { var h = p(xs.hd); if (h !== undefined) { var cell = { - hd: Caml_option.valFromOption(h), + hd: valFromOption(h), tl: /* [] */0 }; copyAuxWitFilterMap(p, t, cell); @@ -2068,7 +2140,7 @@ var CosmiConfig = { // Generated by ReScript, PLEASE EDIT WITH CARE -var Invalid_config = /* @__PURE__ */Caml_exceptions.create("RescriptRelayRouterCli__Utils.Invalid_config"); +var Invalid_config = /* @__PURE__ */create("RescriptRelayRouterCli__Utils.Invalid_config"); function resolveFullPath(path, filepath) { return Path.resolve(Path.dirname(filepath), path); @@ -2122,7 +2194,7 @@ function load() { } function exists() { - return isSome(Caml_option.nullable_to_opt(CosmiConfig.make().search())); + return isSome(nullable_to_opt(CosmiConfig.make().search())); } var Config = { @@ -2280,7 +2352,7 @@ function rawRouteToMatchable(route) { } function matchRoutesCli(prim0, prim1) { - return Caml_option.nullable_to_opt(matchRoutes(prim0, prim1)); + return nullable_to_opt(matchRoutes(prim0, prim1)); } function routeChildrenToPrintable(routeChildren) { @@ -2331,7 +2403,7 @@ function parsedToPrintable(routeEntry) { }; } -var Decode_error = /* @__PURE__ */Caml_exceptions.create("RescriptRelayRouterCli__Utils.Decode_error"); +var Decode_error = /* @__PURE__ */create("RescriptRelayRouterCli__Utils.Decode_error"); function readRouteStructure(config) { var routeStructure = readRouteStructure$1(config, (function (fileName) { @@ -2342,8 +2414,8 @@ function readRouteStructure(config) { }; } catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Js_exn.$$Error) { + var exn = internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === $$Error$1) { return { TAG: "Error", _0: exn._1 @@ -2646,6 +2718,285 @@ function routeNameFromRouteRendererFileName(routeRendererFileName) { } /* No side effect */ +function int_compare(x, y) { + if (x < y) { + return -1; + } else if (x === y) { + return 0; + } else { + return 1; + } +} + +function bool_compare(x, y) { + if (x) { + if (y) { + return 0; + } else { + return 1; + } + } else if (y) { + return -1; + } else { + return 0; + } +} + +function 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 string_compare(s1, s2) { + if (s1 === s2) { + return 0; + } else if (s1 < s2) { + return -1; + } else { + return 1; + } +} +/* No side effect */ + +var for_in = (function(o,foo){ + for (var x in o) { foo(x); }}); + +function compare(a, b) { + if (a === b) { + return 0; + } + var a_type = typeof a; + var b_type = typeof b; + switch (a_type) { + case "bigint" : + if (b_type === "bigint") { + return float_compare(a, b); + } + break; + case "boolean" : + if (b_type === "boolean") { + return bool_compare(a, b); + } + break; + case "function" : + if (b_type === "function") { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "compare: functional value", + Error: new Error() + }; + } + break; + case "number" : + if (b_type === "number") { + return float_compare(a, b); + } + break; + case "string" : + if (b_type === "string") { + return string_compare(a, b); + } else { + return 1; + } + case "undefined" : + return -1; + + } + switch (b_type) { + case "string" : + return -1; + case "undefined" : + return 1; + default: + if (a_type === "boolean") { + return 1; + } + if (b_type === "boolean") { + return -1; + } + if (a_type === "function") { + return 1; + } + if (b_type === "function") { + return -1; + } + if (a_type === "number") { + if (b === null || b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return 1; + } else { + return -1; + } + } + if (b_type === "number") { + if (a === null || a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return -1; + } else { + return 1; + } + } + if (a === null) { + if (b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return 1; + } else { + return -1; + } + } + if (b === null) { + if (a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return -1; + } else { + return 1; + } + } + if (a.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + if (b.BS_PRIVATE_NESTED_SOME_NONE !== undefined) { + return aux_obj_compare(a, b); + } else { + return -1; + } + } + var tag_a = a.TAG; + var tag_b = b.TAG; + if (tag_a === 248) { + return int_compare(a[1], b[1]); + } + if (tag_a === 251) { + throw { + RE_EXN_ID: "Invalid_argument", + _1: "equal: abstract value", + Error: new Error() + }; + } + if (tag_a !== tag_b) { + if (tag_a < tag_b) { + return -1; + } else { + return 1; + } + } + var len_a = a.length | 0; + var len_b = b.length | 0; + if (len_a === len_b) { + if (Array.isArray(a)) { + var _i = 0; + while(true) { + var i = _i; + if (i === len_a) { + return 0; + } + var res = compare(a[i], b[i]); + if (res !== 0) { + return res; + } + _i = i + 1 | 0; + continue ; + } } else if ((a instanceof Date && b instanceof Date)) { + return (a - b); + } else { + return aux_obj_compare(a, b); + } + } else if (len_a < len_b) { + var _i$1 = 0; + while(true) { + var i$1 = _i$1; + if (i$1 === len_a) { + return -1; + } + var res$1 = compare(a[i$1], b[i$1]); + if (res$1 !== 0) { + return res$1; + } + _i$1 = i$1 + 1 | 0; + continue ; + } } else { + var _i$2 = 0; + while(true) { + var i$2 = _i$2; + if (i$2 === len_b) { + return 1; + } + var res$2 = compare(a[i$2], b[i$2]); + if (res$2 !== 0) { + return res$2; + } + _i$2 = i$2 + 1 | 0; + continue ; + } } + } +} + +function aux_obj_compare(a, 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 (!(!Object.prototype.hasOwnProperty.call(b, key) || compare(param[0][key], b[key]) > 0)) { + return ; + } + var mk = min_key.contents; + if (mk !== undefined && key >= mk) { + return ; + } else { + min_key.contents = key; + return ; + } + }; + var partial_arg = [ + a, + b, + min_key_rhs + ]; + var do_key_a = function (param) { + return do_key(partial_arg, param); + }; + var partial_arg$1 = [ + b, + a, + min_key_lhs + ]; + var do_key_b = function (param) { + return do_key(partial_arg$1, param); + }; + for_in(a, do_key_a); + for_in(b, do_key_b); + var match = min_key_lhs.contents; + var match$1 = min_key_rhs.contents; + if (match !== undefined) { + if (match$1 !== undefined) { + return string_compare(match, match$1); + } else { + return -1; + } + } else if (match$1 !== undefined) { + return 1; + } else { + return 0; + } +} + +function lessequal(a, b) { + if ((typeof a === "number" || typeof a === "bigint") && (typeof b === "number" || typeof b === "bigint")) { + return a <= b; + } else { + return compare(a, b) <= 0; + } +} +/* No side effect */ + // Generated by ReScript, PLEASE EDIT WITH CARE @@ -2701,8 +3052,8 @@ function hasPos(range, pos) { posEnd_0, posEnd_1 ]; - if (Caml_obj.lessequal(posStart, pos$1)) { - return Caml_obj.lessequal(pos$1, posEnd); + if (lessequal(posStart, pos$1)) { + return lessequal(pos$1, posEnd); } else { return false; } @@ -3319,8 +3670,8 @@ function start(mode, config) { }; } catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); - if (exn.RE_EXN_ID === Js_exn.$$Error) { + var exn = internalToOCamlException(raw_exn); + if (exn.RE_EXN_ID === $$Error$1) { return { TAG: "Error", _0: exn._1 @@ -3400,7 +3751,7 @@ function start(mode, config) { var getFreshModuleDepsCache = function () { var match = rebuildingDepsCachePromise.contents; if (match !== undefined) ; else { - rebuildingDepsCachePromise.contents = Caml_option.some(doRebuildDepsCacheIfNeeded().then(function (res) { + rebuildingDepsCachePromise.contents = some(doRebuildDepsCacheIfNeeded().then(function (res) { rebuildingDepsCachePromise.contents = undefined; return res; })); @@ -3507,7 +3858,7 @@ function start(mode, config) { if (match$4) { if (match$5 === "shutdown") { if (shutdownRequestAlreadyReceived.contents === true) { - var msg$1 = make$2(msg.id, Caml_option.some(make("InvalidRequest", "Language server already received the shutdown request.")), undefined); + var msg$1 = make$2(msg.id, some(make("InvalidRequest", "Language server already received the shutdown request.")), undefined); return sendFn.contents(msg$1); } shutdownRequestAlreadyReceived.contents = true; @@ -3535,7 +3886,7 @@ function start(mode, config) { routeFileNames: ctx$1.routeFileNames }); var result = hover$1 !== undefined ? hover$1 : null; - var msg$4 = make$2(msg.id, undefined, Caml_option.some(result)); + var msg$4 = make$2(msg.id, undefined, some(result)); return sendFn.contents(msg$4); case "CodeLens" : var params$5 = params$3._0; @@ -3549,7 +3900,7 @@ function start(mode, config) { routeFileNames: ctx$1.routeFileNames }); var result$1 = codeLenses !== undefined ? codeLenses : null; - var msg$5 = make$2(msg.id, undefined, Caml_option.some(result$1)); + var msg$5 = make$2(msg.id, undefined, some(result$1)); return sendFn.contents(msg$5); case ".res" : var fileName = Path.basename(params$5.textDocument.uri); @@ -3567,12 +3918,12 @@ function start(mode, config) { } else { result$2 = null; } - var msg$6 = make$2(msg.id, undefined, Caml_option.some(result$2)); + var msg$6 = make$2(msg.id, undefined, some(result$2)); return sendFn.contents(msg$6); } var promise = getFreshModuleDepsCache(); if (promise !== undefined) { - Caml_option.valFromOption(promise).then(function (res) { + valFromOption(promise).then(function (res) { if (res.TAG !== "Ok") { return ; } @@ -3620,7 +3971,7 @@ function start(mode, config) { })))) ]; - var msg$7 = make$2(msg.id, undefined, Caml_option.some(result)); + var msg$7 = make$2(msg.id, undefined, some(result)); sendFn.contents(msg$7); }); return ; @@ -3642,7 +3993,7 @@ function start(mode, config) { routeFileNames: ctx$1.routeFileNames }); var result$3 = documentLinks$1 !== undefined ? documentLinks$1 : null; - var msg$7 = make$2(msg.id, undefined, Caml_option.some(result$3)); + var msg$7 = make$2(msg.id, undefined, some(result$3)); return sendFn.contents(msg$7); case "Completion" : var params$7 = params$3._0; @@ -3654,7 +4005,7 @@ function start(mode, config) { routeFileNames: ctx$1.routeFileNames }); var result$4 = completionItems !== undefined ? completionItems : null; - var msg$8 = make$2(msg.id, undefined, Caml_option.some(result$4)); + var msg$8 = make$2(msg.id, undefined, some(result$4)); return sendFn.contents(msg$8); } var msg$9 = make$2(msg.id, undefined, null); @@ -3669,7 +4020,7 @@ function start(mode, config) { routeFileNames: ctx$1.routeFileNames }); var result$5 = codeActions$1 !== undefined ? codeActions$1 : null; - var msg$10 = make$2(msg.id, undefined, Caml_option.some(result$5)); + var msg$10 = make$2(msg.id, undefined, some(result$5)); return sendFn.contents(msg$10); } var msg$11 = make$2(msg.id, undefined, null); @@ -3678,7 +4029,7 @@ function start(mode, config) { var thisModuleName = params$3._0; var promise$1 = getFreshModuleDepsCache(); if (promise$1 !== undefined) { - Caml_option.valFromOption(promise$1).then(function (res) { + valFromOption(promise$1).then(function (res) { if (res.TAG !== "Ok") { return ; } @@ -3702,7 +4053,7 @@ function start(mode, config) { } })); - var msg$12 = make$2(msg.id, undefined, Caml_option.some(result)); + var msg$12 = make$2(msg.id, undefined, some(result)); sendFn.contents(msg$12); }); return ; @@ -3735,23 +4086,23 @@ function start(mode, config) { routeRendererFilePath: pathInRoutesFolder(ctx$1.config, RouteName.getRouteRendererName(routeEntry.name) + ".res") }; }); - var msg$12 = make$2(msg.id, undefined, Caml_option.some(result$6)); + var msg$12 = make$2(msg.id, undefined, some(result$6)); return sendFn.contents(msg$12); } break; } } - var msg$13 = make$2(msg.id, Caml_option.some(make("InvalidRequest", "Unrecognized editor request.")), undefined); + var msg$13 = make$2(msg.id, some(make("InvalidRequest", "Unrecognized editor request.")), undefined); return sendFn.contents(msg$13); } if (match$5 !== "initialize") { - var msg$14 = make$2(msg.id, Caml_option.some(make("ServerNotInitialized", "Server not initialized.")), undefined); + var msg$14 = make$2(msg.id, some(make("ServerNotInitialized", "Server not initialized.")), undefined); return sendFn.contents(msg$14); } if (match$5 === "initialize") { initialized.contents = true; - var msg$15 = make$2(msg.id, undefined, Caml_option.some(make$1("Full", true, { + var msg$15 = make$2(msg.id, undefined, some(make$1("Full", true, { triggerCharacters: [ "\"", "=" @@ -3759,7 +4110,7 @@ function start(mode, config) { }, true, true, true))); return sendFn.contents(msg$15); } - var msg$16 = make$2(msg.id, Caml_option.some(make("InvalidRequest", "Unrecognized editor request.")), undefined); + var msg$16 = make$2(msg.id, some(make("InvalidRequest", "Unrecognized editor request.")), undefined); sendFn.contents(msg$16); }; if (mode === "NodeRpc") { @@ -4449,7 +4800,7 @@ function init() { } catch (raw_exn){ - var exn = Caml_js_exceptions.internalToOCamlException(raw_exn); + var exn = internalToOCamlException(raw_exn); if (exn.RE_EXN_ID === Invalid_config) { console.log("[init] Config existed, but was misconfigured. Re-configure it and rerun this command."); process.exit(0); @@ -4501,8 +4852,8 @@ function runCli(args) { return generateRoutes(scaffoldAfterGenerating, deleteRemoved, config$1); } catch (raw_e){ - var e = Caml_js_exceptions.internalToOCamlException(raw_e); - if (e.RE_EXN_ID === Js_exn.$$Error) { + var e = internalToOCamlException(raw_e); + if (e.RE_EXN_ID === $$Error$1) { console.error(e._1); return ; } else if (e.RE_EXN_ID === Decode_error) { @@ -4558,7 +4909,7 @@ function runCli(args) { console.log("Done!"); } catch (raw_routeStructure){ - var routeStructure = Caml_js_exceptions.internalToOCamlException(raw_routeStructure); + var routeStructure = internalToOCamlException(raw_routeStructure); if (routeStructure.RE_EXN_ID === Decode_error) { printDiagnostics(routeStructure._1, config$3); } else { @@ -4588,7 +4939,7 @@ try { runCli(args); } catch (raw_message){ - var message = Caml_js_exceptions.internalToOCamlException(raw_message); + var message = internalToOCamlException(raw_message); if (message.RE_EXN_ID === Invalid_config) { console.log("Error: " + message._1); } else { diff --git a/packages/rescript-relay-router/rollup.config.js b/packages/rescript-relay-router/rollup.config.js index 54c8da6..3ae56a9 100644 --- a/packages/rescript-relay-router/rollup.config.js +++ b/packages/rescript-relay-router/rollup.config.js @@ -8,7 +8,7 @@ export default [ format: "esm", name: "RescriptRelayRouterCli", }, - plugins: [resolve({ resolveOnly: [/^@rescript\/.*$/] })], + plugins: [resolve({ resolveOnly: ["@rescript/core", "rescript"] })], external: ["fsevents"], }, {