Skip to content

Commit 6edf995

Browse files
committed
Merge branch 'master' of github.com:rescript-lang/rescript-lang.org into vlk/fix-sidebarlayout-overflow
2 parents d3ecaeb + 50f1807 commit 6edf995

File tree

8 files changed

+89
-49
lines changed

8 files changed

+89
-49
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ lib/
2424
.vercel
2525

2626
src/**/*.mjs
27+
src/**/*.jsx
2728
scripts/gendocs.mjs
2829
scripts/generate_*.mjs
30+
scripts/gendocs.jsx
31+
scripts/generate_*.jsx
2932

3033
# Generated via generate-llms script
3134
public/llms/manual/**/llm*.txt
@@ -42,7 +45,9 @@ build
4245
mdx-manifest.json
4346

4447
app/**/*.mjs
48+
app/**/*.jsx
4549
!_shims.mjs
50+
!_shims.jsx
4651

4752
# Yarn
4853
.yarn/*
@@ -51,3 +56,6 @@ app/**/*.mjs
5156
!.yarn/releases
5257
!.yarn/sdks
5358
!.yarn/versions
59+
60+
# Scripts generated from rolldown to convert them from .jsx files to .mjs files
61+
_scripts

app/routes.res

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,25 @@ let beltPaths = {
2323
}
2424

2525
let stdlibRoutes =
26-
stdlibPaths->Array.map(path => route(path, "./routes/ApiRoute.mjs", ~options={id: path}))
26+
stdlibPaths->Array.map(path => route(path, "./routes/ApiRoute.jsx", ~options={id: path}))
2727

2828
let beltRoutes =
29-
beltPaths->Array.map(path => route(path, "./routes/ApiRoute.mjs", ~options={id: path}))
29+
beltPaths->Array.map(path => route(path, "./routes/ApiRoute.jsx", ~options={id: path}))
3030

3131
let default = [
32-
index("./routes/LandingPageRoute.mjs"),
33-
route("packages", "./routes/PackagesRoute.mjs"),
34-
route("try", "./routes/TryRoute.mjs"),
35-
route("syntax-lookup", "./routes/SyntaxLookupRoute.mjs", ~options={id: "syntax-lookup"}),
36-
route("blog", "./routes/BlogRoute.mjs", ~options={id: "blog-index"}),
37-
route("blog/archived", "./routes/BlogRoute.mjs", ~options={id: "blog-archived"}),
38-
route("docs", "./routes/DocsOverview.mjs", ~options={id: "docs-overview"}),
39-
route("docs/manual/api/stdlib", "./routes/ApiRoute.mjs", ~options={id: "api-stdlib"}),
40-
route("docs/manual/api/introduction", "./routes/ApiRoute.mjs", ~options={id: "api-intro"}),
41-
route("docs/manual/api/belt", "./routes/ApiRoute.mjs", ~options={id: "api-belt"}),
42-
route("docs/manual/api/dom", "./routes/ApiRoute.mjs", ~options={id: "api-dom"}),
32+
index("./routes/LandingPageRoute.jsx"),
33+
route("packages", "./routes/PackagesRoute.jsx"),
34+
route("try", "./routes/TryRoute.jsx"),
35+
route("syntax-lookup", "./routes/SyntaxLookupRoute.jsx", ~options={id: "syntax-lookup"}),
36+
route("blog", "./routes/BlogRoute.jsx", ~options={id: "blog-index"}),
37+
route("blog/archived", "./routes/BlogRoute.jsx", ~options={id: "blog-archived"}),
38+
route("docs", "./routes/DocsOverview.jsx", ~options={id: "docs-overview"}),
39+
route("docs/manual/api/stdlib", "./routes/ApiRoute.jsx", ~options={id: "api-stdlib"}),
40+
route("docs/manual/api/introduction", "./routes/ApiRoute.jsx", ~options={id: "api-intro"}),
41+
route("docs/manual/api/belt", "./routes/ApiRoute.jsx", ~options={id: "api-belt"}),
42+
route("docs/manual/api/dom", "./routes/ApiRoute.jsx", ~options={id: "api-dom"}),
4343
...stdlibRoutes,
4444
...beltRoutes,
45-
...mdxRoutes("./routes/MdxRoute.mjs"),
46-
route("*", "./routes/NotFoundRoute.mjs"),
45+
...mdxRoutes("./routes/MdxRoute.jsx"),
46+
route("*", "./routes/NotFoundRoute.jsx"),
4747
]

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
"res:watch": "rescript watch",
1515
"res:clean": "rescript clean",
1616
"res:build": "rescript build",
17-
"build": "rescript build && yarn update-index && react-router build",
17+
"build": "rescript build && yarn build-scripts && yarn update-index && react-router build",
1818
"test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs",
19-
"reanalyze": "reanalyze -all-cmt .",
20-
"update-index": "yarn generate-llms && node scripts/generate_feed.mjs > public/blog/feed.xml",
19+
"update-index": "yarn generate-llms && node _scripts/generate_feed.mjs > public/blog/feed.xml",
20+
"reanalyze": "rescript-tools reanalyze -all-cmt .",
2121
"sync-bundles": "node scripts/sync-playground-bundles.mjs",
22-
"generate-llms": "node scripts/generate_llms.mjs",
22+
"generate-llms": "node _scripts/generate_llms.mjs",
2323
"format": "prettier . --write --experimental-cli && rescript format",
2424
"ci:format": "prettier . --check --experimental-cli",
2525
"preview": "yarn build && static-server build/client",
26-
"convert-images": "auto-convert-images"
26+
"convert-images": "auto-convert-images",
27+
"build-scripts": "yarn dlx tsdown scripts/*.jsx -d _scripts --no-clean --ext .mjs"
2728
},
2829
"dependencies": {
2930
"@babel/generator": "^7.24.7",
@@ -84,7 +85,6 @@
8485
"jsdom": "^26.1.0",
8586
"lightningcss": "^1.30.1",
8687
"prettier": "^3.6.2",
87-
"reanalyze": "^2.16.0",
8888
"remark-cli": "^12.0.1",
8989
"search-insights": "^2.17.3",
9090
"tailwindcss": "^4",
@@ -95,4 +95,4 @@
9595
"vite-plugin-env-compatible": "^2.0.1",
9696
"vite-plugin-page-reload": "^0.2.2"
9797
}
98-
}
98+
}

react-router.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const mdx = init({
1111
aliases: ["blog", "docs", "community", "syntax-lookup"],
1212
});
1313

14-
const { stdlibPaths } = await import("./app/routes.mjs");
14+
const { stdlibPaths } = await import("./app/routes.jsx");
1515

1616
export default {
1717
ssr: false,

rescript.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "rescript-lang.org",
33
"namespace": false,
44
"jsx": {
5+
"preserve": true,
56
"version": 4
67
},
78
"dependencies": ["@rescript/react", "@rescript/webapi"],
@@ -27,7 +28,7 @@
2728
"warnings": {
2829
"error": "+8"
2930
},
30-
"suffix": ".mjs",
31+
"suffix": ".jsx",
3132
"gentypeconfig": {
3233
"language": "untyped",
3334
"shims": [],

src/components/CodeMirror.res

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,35 @@ module Error = {
4646
}
4747

4848
module HoverHint = {
49-
type position = {
50-
line: int,
51-
col: int,
49+
module Position = {
50+
type t = {
51+
line: int,
52+
col: int,
53+
}
54+
let compareLineCol = (pos1, pos2) => {
55+
if pos1.line < pos2.line {
56+
Ordering.less
57+
} else if pos1.line > pos2.line {
58+
Ordering.greater
59+
} // same line, compare column
60+
else if pos1.col < pos2.col {
61+
Ordering.less
62+
} else if pos1.col > pos2.col {
63+
Ordering.greater
64+
} else {
65+
Ordering.equal
66+
}
67+
}
68+
// let \"<" = (pos1, pos2) => compareLineCol(pos1, pos2) === Ordering.less
69+
let \"<=" = (pos1, pos2) => compareLineCol(pos1, pos2) !== Ordering.greater
70+
// let \">" = (pos1, pos2) => compareLineCol(pos1, pos2) === Ordering.greater
71+
let \">=" = (pos1, pos2) => compareLineCol(pos1, pos2) !== Ordering.less
72+
// let \"==" = (pos1, pos2) => compareLineCol(pos1, pos2) === Ordering.equal
5273
}
5374

5475
type t = {
55-
start: position,
56-
end: position,
76+
start: Position.t,
77+
end: Position.t,
5778
hint: string,
5879
}
5980
}
@@ -178,9 +199,14 @@ module CM6 = {
178199
@module("@codemirror/view")
179200
external dropCursor: unit => extension = "dropCursor"
180201

202+
module HoverTooltipOptions = {
203+
type t = {hoverTime?: int, hideOnChange?: bool}
204+
}
181205
@module("@codemirror/view")
182-
external hoverTooltip: ((editorView, int, Side.t) => null<Tooltip.t>) => extension =
183-
"hoverTooltip"
206+
external hoverTooltip: (
207+
(editorView, int, Side.t) => null<Tooltip.t>,
208+
~options: HoverTooltipOptions.t=?,
209+
) => extension = "hoverTooltip"
184210

185211
module UpdateListener = {
186212
type update
@@ -604,12 +630,25 @@ let createLinterExtension = (errors: array<Error.t>): CM6.extension => {
604630
}
605631

606632
let createHoverHintExtension = (hoverHints: array<HoverHint.t>) => {
607-
CM6.EditorView.hoverTooltip((view, pos, _side) => {
633+
CM6.EditorView.hoverTooltip(~options={hoverTime: 100}, (view, pos, _side) => {
608634
let doc = view->CM6.EditorView.state->CM6.EditorState.doc
609635
let {number: line, from} = doc->CM6.Text.lineAt(pos)
610636
let col = pos - from
611-
let found = hoverHints->Array.find(({start, end}) => {
612-
line >= start.line && line <= end.line && col >= start.col && col <= end.col
637+
let mousePos = {HoverHint.Position.line, col}
638+
639+
let found = Array.reduce(hoverHints, None, (prev, currentHint) => {
640+
open! HoverHint.Position
641+
let currentHintIncludesMousePos = currentHint.start <= mousePos && currentHint.end >= mousePos
642+
switch prev {
643+
| None if currentHintIncludesMousePos => Some(currentHint)
644+
| Some(prevHint)
645+
if currentHintIncludesMousePos &&
646+
(currentHint.start >= prevHint.start &&
647+
currentHint.end <= prevHint.end) =>
648+
Some(currentHint)
649+
| None
650+
| Some(_) => prev
651+
}
613652
})
614653
switch found {
615654
| Some({hint, start, end}) =>

src/components/CodeMirror.resi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ module Error: {
1818
}
1919

2020
module HoverHint: {
21-
type position = {
22-
line: int,
23-
col: int,
21+
module Position: {
22+
type t = {
23+
line: int,
24+
col: int,
25+
}
2426
}
2527

2628
type t = {
27-
start: position,
28-
end: position,
29+
start: Position.t,
30+
end: Position.t,
2931
hint: string,
3032
}
3133
}

yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8151,15 +8151,6 @@ __metadata:
81518151
languageName: node
81528152
linkType: hard
81538153

8154-
"reanalyze@npm:^2.16.0":
8155-
version: 2.23.0
8156-
resolution: "reanalyze@npm:2.23.0"
8157-
bin:
8158-
reanalyze: reanalyze.exe
8159-
checksum: 10c0/b8b05f47d17b21175f9bf1b650c1c3d2888ebcf82601f0260d499a40f8ea52b7db0ab9fa5e93fb12b440e0a25025b203bb4fe600bba69d4ae671b61775b1620f
8160-
languageName: node
8161-
linkType: hard
8162-
81638154
"recma-build-jsx@npm:^1.0.0":
81648155
version: 1.0.0
81658156
resolution: "recma-build-jsx@npm:1.0.0"
@@ -8460,7 +8451,6 @@ __metadata:
84608451
react-router: "npm:^7.9.4"
84618452
react-router-dom: "npm:^7.9.4"
84628453
react-router-mdx: "patch:react-router-mdx@npm%3A1.0.8#~/.yarn/patches/react-router-mdx-npm-1.0.8-d4402c3003.patch"
8463-
reanalyze: "npm:^2.16.0"
84648454
rehype-slug: "npm:^6.0.0"
84658455
rehype-stringify: "npm:^10.0.1"
84668456
remark: "npm:^15.0.1"

0 commit comments

Comments
 (0)