Skip to content

Commit 90119ae

Browse files
authored
Upgrade codemirror to v6 (#1133)
* another try at upgrading to CM6 * fix expected static flag missing * remove unused CM5 modes * remove unused focused row * remove unused props * use the same highlight style for string and special string * simplify codemirror styling * use CM editor for the source of truth of code allows formatting without losing cursor position * add an error message when compiler versions can't be loaded * add back hover hints * style playground closer to V5 version * use rescript-lezer from npm * remove unused codemirror theme * format * update package lock * remove unused file * remove ansi colors from linter messages * use dict for more type safe theme * improve selection style * improve JSX intrinsic element highlighting Also highlights parameters and JSX attributes * highlight async/await, `and` and bitwise operators * improve selection match styling * set the theme as dark * update llms.mdx * improve highlighting of record/object definition and field access
1 parent 753504b commit 90119ae

File tree

16 files changed

+1968
-2262
lines changed

16 files changed

+1968
-2262
lines changed

app/routes/TryRoute.res

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,26 @@ let loader = async () => {
2222
)
2323
}
2424

25-
let versions = {
26-
let response = await fetch(versionsBaseUrl + "/playground-bundles/versions.json")
27-
let json = await WebAPI.Response.json(response)
28-
json
29-
->JSON.Decode.array
30-
->Option.getOrThrow
31-
->Array.map(json => json->JSON.Decode.string->Option.getOrThrow)
32-
}
25+
try {
26+
let versions = {
27+
let response = await fetch(versionsBaseUrl + "/playground-bundles/versions.json")
28+
let json = await WebAPI.Response.json(response)
29+
json
30+
->JSON.Decode.array
31+
->Option.getOrThrow
32+
->Array.map(json => json->JSON.Decode.string->Option.getOrThrow)
33+
}
3334

34-
{
35-
bundleBaseUrl,
36-
versions,
35+
Some({
36+
bundleBaseUrl,
37+
versions,
38+
})
39+
} catch {
40+
| JsExn(e) =>
41+
Console.error2("error while fetching compiler versions", e)
42+
None
3743
}
3844
}
39-
4045
module ClientOnly = {
4146
@react.component
4247
let make = (~bundleBaseUrl, ~versions) => {
@@ -47,12 +52,19 @@ module ClientOnly = {
4752
}
4853

4954
let default = () => {
50-
let {bundleBaseUrl, versions} = ReactRouter.useLoaderData()
55+
let data = ReactRouter.useLoaderData()
5156
<>
5257
<Meta
5358
title="ReScript Playground" description="Try ReScript in the browser" ogImage="/og/try.png"
5459
/>
5560

56-
<ClientOnly bundleBaseUrl versions />
61+
{switch data {
62+
| Some({bundleBaseUrl, versions}) => <ClientOnly bundleBaseUrl versions />
63+
| None =>
64+
<div className="mt-16 p-5 text-xl text-red-500 self-center">
65+
<h1> {React.string("Oops an error occurred!")} </h1>
66+
{React.string("The playground cannot be loaded, please try again in a few moments.")}
67+
</div>
68+
}}
5769
</>
5870
}

app/routes/TryRoute.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ type props = {
33
versions: array<string>,
44
}
55

6-
let loader: unit => promise<props>
6+
let loader: unit => promise<option<props>>
77

88
let default: unit => React.element

markdown-pages/docs/manual/llms.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "LLMs"
33
description: "Documentation for LLMs"
44
canonical: "/docs/manual/llms"
55
section: "Overview"
6-
order: 5
6+
order: 4
77
---
88

99
# Documentation for LLMs
@@ -12,13 +12,13 @@ We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentati
1212

1313
Currently, we have the following files...
1414

15-
- [/manual/llms.txt](/llms/manual/llms.txt) — a list of the available files for ReScript language.
16-
- [/manual/llm-full.txt](/llms/manual/llm-full.txt) — complete documentation for ReScript language.
17-
- [/manual/llm-small.txt](/llms/manual/llm-small.txt) — compressed version of the former, without examples.
15+
- [/docs/manual/llms.txt](/llms/manual//llms.txt) — a list of the available files for ReScript language.
16+
- [/docs/manual/llm-full.txt](/llms/manual//llm-full.txt) — complete documentation for ReScript language.
17+
- [/docs/manual/llm-small.txt](/llms/manual//llm-small.txt) — compressed version of the former, without examples.
1818

1919
...and package-level documentation:
2020

21-
- [/react/llms](../react/llms.mdx) — the LLms documentation for ReScript React.
21+
- [/docs/react/llms](../react/llms.mdx) — the LLms documentation for ReScript React.
2222

2323
## Notes
2424

markdown-pages/docs/react/llms.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentati
1111

1212
Currently, we have the following files...
1313

14-
- [/react/llms.txt](/llms/react/llms.txt) — a list of the available files for ReScript React.
15-
- [/react/llms-full.txt](/llms/react/llms-full.txt) — complete documentation for ReScript React.
16-
- [/react/llms-small.txt](/llms/react/llms-small.txt) — compressed version of the former, without examples for ReScript React.
14+
- [/docs/react/llms.txt](/llms/react/llms.txt) — a list of the available files for ReScript React.
15+
- [/docs/react/llms-full.txt](/llms/react/llm-full.txt) — complete documentation for ReScript React.
16+
- [/docs/react/llms-small.txt](/llms/react/llm-small.txt) — compressed version of the former, without examples for ReScript React.
1717

1818
...and the language documentation:
1919

20-
- [/manual/llms](../manual/llms.mdx) — the LLms documentation for ReScript.
20+
- [/docs/manual/llms](../manual/llms.mdx) — the LLms documentation for ReScript.
2121

2222
## Notes
2323

0 commit comments

Comments
 (0)