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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -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",
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Up @@ -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": [
{
Expand All @@ -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
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions src/ApiDocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -474,6 +474,7 @@ let processStaticProps = (~slug: array<string>, ~version: string) => {
})

Variant({items: items})->Null.make
| Signature(_) => Null.null
}
| None => Null.null
}
Expand Down
4 changes: 2 additions & 2 deletions src/Blog.res
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/CommunityContent.res
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
2 changes: 1 addition & 1 deletion src/ConsolePanel.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions src/SyntaxLookup.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)

{
Expand Down
8 changes: 3 additions & 5 deletions src/Try.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/bindings/RescriptCompilerApi.res
Original file line number Diff line number Diff line change
Expand Up @@ -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, _),
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/common/Ansi.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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, ";") {
Expand Down Expand Up @@ -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(", ")

Expand All @@ -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}}) =>
Expand Down
2 changes: 1 addition & 1 deletion src/common/BlogApi.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
16 changes: 8 additions & 8 deletions src/common/BlogFrontmatter.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/Semver.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading
Loading