Skip to content

Update codebase to rescript v12.0.0-alpha.9 #990

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 13 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -23,9 +23,7 @@
"@docsearch/react": "^3.5.2",
"@headlessui/react": "^1.2.0",
"@mdx-js/loader": "^3.1.0",
"@rescript/core": "^1.4.0",
"@rescript/react": "^0.12.0-alpha.3",
"@rescript/tools": "^0.5.0",
"codemirror": "^5.54.0",
"docson": "^2.1.0",
"escodegen": "^2.1.0",
@@ -52,7 +50,7 @@
"remark-rehype": "^11.1.1",
"remark-stringify": "^11.0.0",
"request": "^2.88.0",
"rescript": "^11.1.0",
"rescript": "^12.0.0-alpha.9",
"stringify-object": "^3.3.0",
"unified": "^11.0.5",
"vfile-matter": "^5.0.0"
@@ -80,4 +78,4 @@
"simple-functional-loader": "^1.2.1",
"tailwindcss": "^3.3.3"
}
}
}
11 changes: 2 additions & 9 deletions rescript.json
Original file line number Diff line number Diff line change
@@ -5,14 +5,7 @@
"version": 4
},
"bs-dependencies": [
"@rescript/react",
"@rescript/tools",
"@rescript/core"
],
"uncurried": true,
"ppx-flags": [],
"bsc-flags": [
"-open RescriptCore"
"@rescript/react"
],
"sources": [
{
@@ -38,4 +31,4 @@
"shims": [],
"module": "es6"
}
}
}
9 changes: 7 additions & 2 deletions scripts/gendocs.res
Original file line number Diff line number Diff line change
@@ -115,7 +115,9 @@ let docs = docsDecoded->Array.map(doc => {
let rec getModules = (lst: list<Docgen.item>, moduleNames: list<module_>) =>
switch lst {
| list{
Module({id, items, name, docstrings}) | ModuleAlias({id, items, name, docstrings}),
Module({id, items, name, docstrings})
| ModuleAlias({id, items, name, docstrings})
| ModuleType({id, items, name, docstrings}),
...rest,
} =>
if Array.includes(hiddenModules, id) {
@@ -255,7 +257,10 @@ let () = {
}
let rec getModules = (lst: list<Docgen.item>, moduleNames, path) => {
switch lst {
| list{Module({id, items, name}) | ModuleAlias({id, items, name}), ...rest} =>
| list{
Module({id, items, name}) | ModuleAlias({id, items, name}) | ModuleType({id, items, name}),
...rest,
} =>
if Array.includes(hiddenModules, id) {
getModules(rest, moduleNames, path)
} else {
5 changes: 3 additions & 2 deletions src/ApiDocs.res
Original file line number Diff line number Diff line change
@@ -307,7 +307,7 @@ let default = (props: props) => {
let valuesAndType = items->Array.map(item => {
switch item {
| Value({name, signature, docstrings, deprecated}) =>
let code = String.replaceRegExp(signature, %re("/\\n/g"), "\n")
let code = String.replaceRegExp(signature, /\\n/g, "\n")
let slugPrefix = "value-" ++ name
<>
<H2 id=slugPrefix> {name->React.string} </H2>
@@ -316,7 +316,7 @@ let default = (props: props) => {
<DocstringsStylize docstrings slugPrefix />
</>
| Type({name, signature, docstrings, deprecated}) =>
let code = String.replaceRegExp(signature, %re("/\\n/g"), "\n")
let code = String.replaceRegExp(signature, /\\n/g, "\n")
let slugPrefix = "type-" ++ name
<>
<H2 id=slugPrefix> {name->React.string} </H2>
@@ -474,6 +474,7 @@ let processStaticProps = (~slug: array<string>, ~version: string) => {
})

Variant({items: items})->Null.make
| Signature(_) => Null.null
}
| None => Null.null
}
4 changes: 2 additions & 2 deletions src/Blog.res
Original file line number Diff line number Diff line change
@@ -95,8 +95,8 @@ module BlogCard = {
{
let className = "absolute top-0 h-full w-full object-cover"
switch previewImg {
| Some(src) => <img className src loading={#"lazy"} />
| None => <img className src=defaultPreviewImg loading={#"lazy"} />
| Some(src) => <img className src loading={#lazy} />
| None => <img className src=defaultPreviewImg loading={#lazy} />
}
}
</Link>
2 changes: 1 addition & 1 deletion src/CommunityContent.res
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ module LinkCard = {
let make = (~link, ~index) => {
let loading = switch index {
| 0 => #eager
| _ => #"lazy"
| _ => #lazy
}
<div className="rounded-lg hover:text-fire overflow-hidden bg-gray-10 border-2 border-gray-30">
<a href=link.url className="flex flex-col h-full">
2 changes: 1 addition & 1 deletion src/ConsolePanel.res
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ let make = (~logs, ~appendLog) => {
->Array.mapWithIndex(({level: logLevel, content: log}, i) => {
let log = Array.join(log, " ")
<pre
key={RescriptCore.Int.toString(i)}
key={Int.toString(i)}
className={switch logLevel {
| #log => ""
| #warn => "text-orange"
12 changes: 6 additions & 6 deletions src/SyntaxLookup.res
Original file line number Diff line number Diff line change
@@ -151,14 +151,14 @@ type params = {slug: string}

let decode = (json: JSON.t) => {
open Json.Decode
let id = json->(field("id", string, _))
let keywords = json->(field("keywords", array(string, ...), _))
let name = json->(field("name", string, _))
let summary = json->(field("summary", string, _))
let category = json->field("category", string, _)->Category.fromString
let id = json->field("id", string, _)
let keywords = json->field("keywords", array(string, ...), _)
let name = json->field("name", string, _)
let summary = json->field("summary", string, _)
let category = json->(field("category", string, _))->Category.fromString
let status =
json
->optional(field("status", string, _), _)
->(optional(field("status", string, _), _))
->Option.mapOr(Status.Active, Status.fromString)

{
8 changes: 3 additions & 5 deletions src/Try.res
Original file line number Diff line number Diff line change
@@ -37,11 +37,9 @@ let getStaticProps: Next.GetStaticProps.t<props, _> = async _ => {
switch line->String.startsWith("<a href") {
| true =>
// Adapted from https://semver.org/
let semverRe = %re(
"/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/"
)
switch Re.exec(semverRe, line) {
| Some(result) => Re.Result.fullMatch(result)->Some
let semverRe = /v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/
switch RegExp.exec(semverRe, line) {
| Some(result) => RegExp.Result.fullMatch(result)->Some
| None => None
}
| false => None
12 changes: 6 additions & 6 deletions src/bindings/RescriptCompilerApi.res
Original file line number Diff line number Diff line change
@@ -97,12 +97,12 @@ module LocMsg = {
let decode = (json): t => {
open Json.Decode
{
fullMsg: json->(field("fullMsg", string, _)),
shortMsg: json->(field("shortMsg", string, _)),
row: json->(field("row", int, _)),
column: json->(field("column", int, _)),
endRow: json->(field("endRow", int, _)),
endColumn: json->(field("endColumn", int, _)),
fullMsg: json->field("fullMsg", string, _),
shortMsg: json->field("shortMsg", string, _),
row: json->field("row", int, _),
column: json->field("column", int, _),
endRow: json->field("endRow", int, _),
endColumn: json->field("endColumn", int, _),
}
}

10 changes: 5 additions & 5 deletions src/common/Ansi.res
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ module Sgr = {

let esc = `\u001B`

let isAscii = (c: string) => Re.test(%re(`/[\x40-\x7F]/`), c)
let isAscii = (c: string) => RegExp.test(/[\x40-\x7F]/, c)

module Location = {
type t = {
@@ -177,9 +177,9 @@ module Lexer = {

let loc = {startPos, endPos: startPos + String.length(raw) - 1}

let token = switch Re.exec(%re(`/\[([0-9;]+)([\x40-\x7F])/`), raw) {
let token = switch RegExp.exec(/\[([0-9;]+)([\x40-\x7F])/, raw) {
| Some(result) =>
let groups = Re.Result.matches(result)
let groups = RegExp.Result.matches(result)
switch groups[1] {
| Some(str) =>
switch String.split(str, ";") {
@@ -318,7 +318,7 @@ module SgrString = {
let toString = (e: t): string => {
let content = {
open String
replaceRegExp(e.content, %re("/\n/g"), "\\n")->replace(esc, "")
replaceRegExp(e.content, /\n/g, "\\n")->replace(esc, "")
}
let params = Array.map(e.params, Sgr.paramToString)->Array.join(", ")

@@ -334,7 +334,7 @@ module Printer = {
| Text({content, loc: {startPos, endPos}}) =>
let content = {
open String
replaceRegExp(content, %re("/\n/g"), "\\n")->replace(esc, "")
replaceRegExp(content, /\n/g, "\\n")->replace(esc, "")
}
`Text "${content}" (${startPos->Int.toString} to ${endPos->Int.toString})`
| Sgr({params, raw, loc: {startPos, endPos}}) =>
2 changes: 1 addition & 1 deletion src/common/BlogApi.res
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ type post = {
}

let blogPathToSlug = path => {
path->String.replaceRegExp(%re(`/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/`), "$2")
path->String.replaceRegExp(/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/, "$2")
}

let mdxFiles = dir => {
16 changes: 8 additions & 8 deletions src/common/BlogFrontmatter.res
Original file line number Diff line number Diff line change
@@ -134,16 +134,16 @@ let authorDecoder = (~fieldName: string, ~authors) => {
let decode = (json: JSON.t): result<t, string> => {
open Json.Decode
switch {
author: json->field("author", string, _)->decodeAuthor(~fieldName="author", ~authors),
author: json->(field("author", string, _))->decodeAuthor(~fieldName="author", ~authors),
co_authors: json
->optional(field("co-authors", authorDecoder(~fieldName="co-authors", ~authors), ...), _)
->(optional(field("co-authors", authorDecoder(~fieldName="co-authors", ~authors), ...), _))
->Option.getOr([]),
date: json->field("date", string, _)->DateStr.fromString,
badge: json->optional(j => field("badge", string, j)->decodeBadge, _)->Null.fromOption,
previewImg: json->optional(field("previewImg", string, ...), _)->Null.fromOption,
articleImg: json->optional(field("articleImg", string, ...), _)->Null.fromOption,
title: json->(field("title", string, _)),
description: json->(nullable(field("description", string, ...), _)),
date: json->(field("date", string, _))->DateStr.fromString,
badge: json->(optional(j => field("badge", string, j)->decodeBadge, _))->Null.fromOption,
previewImg: json->(optional(field("previewImg", string, ...), _))->Null.fromOption,
articleImg: json->(optional(field("articleImg", string, ...), _))->Null.fromOption,
title: json->field("title", string, _),
description: json->nullable(field("description", string, ...), _),
} {
| fm => Ok(fm)
| exception DecodeError(str) => Error(str)
3 changes: 1 addition & 2 deletions src/common/DateStr.res
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
type t = string

// Used to prevent issues with webkit based date representations
let parse = (dateStr: string): Date.t =>
dateStr->String.replaceRegExp(%re("/-/g"), "/")->Date.fromString
let parse = (dateStr: string): Date.t => dateStr->String.replaceRegExp(/-/g, "/")->Date.fromString

let fromDate = date => Date.toString(date)
let toDate = dateStr => parse(dateStr)
2 changes: 1 addition & 1 deletion src/common/Semver.res
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ let parse = (versionStr: string) => {
}

// Some version contain a suffix. Example: v11.0.0-alpha.5, v11.0.0-beta.1
let isPrerelease = versionStr->String.search(%re("/-/")) != -1
let isPrerelease = versionStr->String.search(/-/) != -1

// Get the first part i.e vX.Y.Z
let versionNumber = versionStr->String.split("-")->Array.get(0)->Option.getOr(versionStr)
2 changes: 1 addition & 1 deletion src/common/Url.res
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ let prettyString = (str: string) => {
let parse = (route: string): t => {
let fullpath = route->String.split("/")->Array.filter(s => s !== "")
let foundVersionIndex = Array.findIndex(fullpath, chunk => {
Re.test(%re(`/latest|next|v\d+(\.\d+)?(\.\d+)?/`), chunk)
RegExp.test(/latest|next|v\d+(\.\d+)?(\.\d+)?/, chunk)
})

let (version, base, pagepath) = if foundVersionIndex == -1 {
2 changes: 1 addition & 1 deletion src/components/Button.res
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ let make = (
~kind: kind=PrimaryRed,
~size: size=Large,
~children,
~onClick: option<JsxEventU.Mouse.t => unit>=?,
~onClick: option<JsxEvent.Mouse.t => unit>=?,
) => {
let bgColor = switch kind {
| PrimaryRed => "bg-fire hover:bg-fire-70 text-white"
2 changes: 1 addition & 1 deletion src/components/Button.resi
Original file line number Diff line number Diff line change
@@ -6,5 +6,5 @@ let make: (
~kind: kind=?,
~size: size=?,
~children: React.element,
~onClick: JsxEventU.Mouse.t => unit=?,
~onClick: JsxEvent.Mouse.t => unit=?,
) => React.element
46 changes: 12 additions & 34 deletions src/components/CodeMirror.res
Original file line number Diff line number Diff line change
@@ -66,46 +66,24 @@ module CM = {
}

@module("codemirror")
external onMouseOver: (
Dom.element,
@as("mouseover") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "on"
external onMouseOver: (Dom.element, @as("mouseover") _, ReactEvent.Mouse.t => unit) => unit = "on"

@module("codemirror")
external onMouseMove: (
Dom.element,
@as("mousemove") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "on"
external onMouseMove: (Dom.element, @as("mousemove") _, ReactEvent.Mouse.t => unit) => unit = "on"

@module("codemirror")
external offMouseOver: (
Dom.element,
@as("mouseover") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "off"
external offMouseOver: (Dom.element, @as("mouseover") _, ReactEvent.Mouse.t => unit) => unit =
"off"

@module("codemirror")
external offMouseOut: (
Dom.element,
@as("mouseout") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "off"
external offMouseOut: (Dom.element, @as("mouseout") _, ReactEvent.Mouse.t => unit) => unit = "off"

@module("codemirror")
external offMouseMove: (
Dom.element,
@as("mousemove") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "off"
external offMouseMove: (Dom.element, @as("mousemove") _, ReactEvent.Mouse.t => unit) => unit =
"off"

@module("codemirror")
external onMouseOut: (
Dom.element,
@as("mouseout") _,
@uncurry ReactEvent.Mouse.t => unit,
) => unit = "on"
external onMouseOut: (Dom.element, @as("mouseout") _, ReactEvent.Mouse.t => unit) => unit = "on"

@module("codemirror")
external fromTextArea: (Dom.element, Options.t) => t = "fromTextArea"
@@ -122,7 +100,7 @@ module CM = {
@send external refresh: t => unit = "refresh"

@send
external onChange: (t, @as("change") _, @uncurry t => unit) => unit = "on"
external onChange: (t, @as("change") _, t => unit) => unit = "on"

@send external toTextArea: t => unit = "toTextArea"

@@ -131,7 +109,7 @@ module CM = {
@send external getValue: t => string = "getValue"

@send
external operation: (t, @uncurry unit => unit) => unit = "operation"
external operation: (t, unit => unit) => unit = "operation"

@send
external setGutterMarker: (t, int, string, Dom.element) => unit = "setGutterMarker"
@@ -485,7 +463,7 @@ let extractRowColFromId = (id: string): option<(int, int)> =>
| _ => None
}

module ErrorHash = Belt.Id.MakeHashableU({
module ErrorHash = Belt.Id.MakeHashable({
type t = int
let hash = a => a
let eq = (a, b) => a == b
@@ -536,7 +514,7 @@ let updateErrors = (~state: state, ~onMarkerFocus=?, ~onMarkerFocusLeave=?, ~cm:
(),
),
)
->Array.push(state.marked, _)
->(Array.push(state.marked, _))
->ignore
()
}
8 changes: 4 additions & 4 deletions src/components/Markdown.res
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ module Code = {
String.split(metastring, " ")
->Array.find(s => String.startsWith(s, "{") && String.endsWith(s, "}"))
->Option.map(str => {
let nums = String.replaceRegExp(str, %re("/[\{\}]/g"), "")->parseNumericRange
let nums = String.replaceRegExp(str, /[\{\}]/g, "")->parseNumericRange
nums
})
->Option.getOr([])
@@ -248,9 +248,9 @@ module Code = {

let highlightedLines = parseNumericRangeMeta(metastring)

if List.has(metaSplits, "example", \"=") {
if List.has(metaSplits, "example", String.equal) {
<CodeExample code lang />
} else if List.has(metaSplits, "sig", \"=") {
} else if List.has(metaSplits, "sig", String.equal) {
<CodeExample code lang showLabel=false />
} else {
<CodeExample highlightedLines code lang />
@@ -374,7 +374,7 @@ module A = {
// Ideally one would check if this link is relative first,
// but it's very unlikely we'd refer to an absolute URL ending
// with .md
let regex = %re("/\.md(x)?|\.html$/")
let regex = /\.md(x)?|\.html$/
let href = switch String.split(href, "#") {
| [pathname, anchor] => String.replaceRegExp(pathname, regex, "") ++ ("#" ++ anchor)
| [pathname] => String.replaceRegExp(pathname, regex, "")
2 changes: 1 addition & 1 deletion src/vendor/Json_decode.res
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ let string = json =>
let char = json => {
let s = string(json)
if String.length(s) == 1 {
OCamlCompat.String.get(s, 0)
String.getUnsafe(s, 0)->Obj.magic
} else {
\"@@"(raise, DecodeError("Expected single-character string, got " ++ JSON.stringify(json)))
}
2 changes: 1 addition & 1 deletion src/vendor/Json_encode.res
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ external float: float => JSON.t = "%identity"
external int: int => JSON.t = "%identity"
external bool: bool => JSON.t = "%identity"

let char = c => string(OCamlCompat.String.make(1, c))
let char = c => string(String.make(c))

let date = d => string(Date.toJSON(d)->Option.getUnsafe)