Skip to content

Commit

Permalink
prepare 2.2.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Dec 9, 2023
1 parent 824e48f commit 614d4ee
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 57 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ format-check: ## Checks if format is correct
build-playground: ## Builds the playground
$(DUNE) build @playground-assets
cd playground && yarn && yarn build

.PHONY: move-v2.2.0-tag
move-v2.2.0-tag: ## Moves the v2.2.0 tag to the latest commit, useful to publish the v2.2.0 docs
git push origin :refs/tags/v2.2.0
git tag -fa v2.2.0
git push origin --tags
4 changes: 2 additions & 2 deletions docs/communicate-with-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -2763,15 +2763,15 @@ type pet = { name : string } [@@deriving accessors]
let pets = [| { name = "Brutus" }; { name = "Mochi" } |]
let () = pets |. Belt.Array.map name |. Js.Array.join ~sep:"&" |. Js.log
let () = pets |. Belt.Array.map name |. Js.Array2.joinWith "&" |. Js.log
```
```reasonml
[@deriving accessors]
type pet = {name: string};
let pets = [|{name: "Brutus"}, {name: "Mochi"}|];
let () = pets->(Belt.Array.map(name))->(Js.Array.join(~sep="&"))->Js.log;
let () = pets->(Belt.Array.map(name))->(Js.Array2.joinWith("&"))->Js.log;
```

Melange will generate a function for each field defined in the record. In this
Expand Down
6 changes: 2 additions & 4 deletions documentation-site.opam
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ depends: [
]
dev-repo: "git+https://github.com/melange-re/melange-re.github.io.git"
pin-depends: [
[ "melange.dev" "git+https://github.com/melange-re/melange.git#7bec5dd58dbc0b20c9821c5b80c88c6d02df52e0" ]
[ "melange-playground.dev" "git+https://github.com/melange-re/melange.git#7bec5dd58dbc0b20c9821c5b80c88c6d02df52e0" ]
[ "reason-react.dev" "git+https://github.com/reasonml/reason-react.git#2a43311df12eb3988fd9729098928e6b03cfaa07" ]
[ "reason-react-ppx.dev" "git+https://github.com/reasonml/reason-react.git#2a43311df12eb3988fd9729098928e6b03cfaa07" ]
[ "melange.dev" "git+https://github.com/melange-re/melange.git#97ebd7d3d3f8fb66dbbf4df6691b0cf4b95dc153" ]
[ "melange-playground.dev" "git+https://github.com/melange-re/melange.git#97ebd7d3d3f8fb66dbbf4df6691b0cf4b95dc153" ]
[ "cmarkit.dev" "git+https://github.com/dbuenzli/cmarkit.git#f37c8ea86fd0be8dba7a8babcee3682e0e047d91" ]
]
build: [
Expand Down
47 changes: 14 additions & 33 deletions playground/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function Sidebar({ onExampleClick }) {
<div className="Versions">
<span className="Version">
<span className="Text-xs">{"Melange"}</span>
<span className="Text-xs Number">{"dev"}</span>
<span className="Text-xs Number">{"2.2.0"}</span>
</span>
<span className="Version">
<span className="Text-xs">{"OCaml"}</span>
Expand All @@ -149,7 +149,7 @@ function Sidebar({ onExampleClick }) {
</span>
<span className="Version">
<span className="Text-xs">{"ReasonReact"}</span>
<span className="Text-xs Number">{"dev"}</span>
<span className="Text-xs Number">{"0.13.0"}</span>
</span>
</div>
</div>) : null}
Expand Down Expand Up @@ -241,7 +241,7 @@ function ConsolePanel({ logs, clearLogs }) {
)
}

function ProblemsPanel({ problems, warnings }) {
function ProblemsPanel({ problems }) {
const defaultState = false;
const [isCollapsed, setIsCollapsed] = React.useState(defaultState);
const ref = React.useRef(null);
Expand All @@ -263,24 +263,14 @@ function ProblemsPanel({ problems, warnings }) {
? problems.map((v) => v.msg).join("\n")
: "";

const warningsString =
warnings && warnings.length > 0
? warnings.map((v) => v.msg).join("\n")
: "";

return (
<>
<div className="ProblemsHeader">
<span className="Text-xs">Problems</span>
<button className="IconButton" onClick={toggle}>{isCollapsed ? <ArrowUpFromLine /> : <ArrowDownToLine />}</button>
</div>
<Panel collapsible={true} defaultSize={20} collapsedSize={10} minSize={10} ref={ref}>
{(problems && problems.length > 0)
? <div className="Problems Scrollbar">{problemsString}</div>
: (warnings && warnings.length > 0)
? <div className="Problems Scrollbar">{warningsString}</div>
: <div className="Problems Empty">No problems!</div>
}
{problems && problems.length > 0 ? (<div className="Problems Scrollbar">{problemsString}</div>) : <div className="Problems Empty">No problems!</div>}
</Panel>
</>
)
Expand Down Expand Up @@ -389,14 +379,14 @@ function OutputEditor({ language, value }) {
}

const problemFromCompile = ({
js_warning_error_msg,
js_error_msg,
row,
column,
endRow,
endColumn,
text,
}) => ({
msg: js_warning_error_msg,
msg: js_error_msg,
loc: {
row: row + 1,
column: column + 1,
Expand All @@ -406,13 +396,13 @@ const problemFromCompile = ({
},
});

const toMonaco = (severity) => (problem) => ({
const toMonaco = (problem) => ({
startLineNumber: problem.loc.row,
startColumn: problem.loc.column,
endLineNumber: problem.loc.endRow,
endColumn: problem.loc.endColumn,
message: problem.msg,
severity: severity,
severity: monaco.MarkerSeverity.Error,
});

const compile = (language, code) => {
Expand All @@ -422,20 +412,19 @@ const compile = (language, code) => {
? ocaml.compileRE(code)
: ocaml.compileML(code);
} catch (error) {
compilation = { js_warning_error_msg: error.message };
compilation = { js_error_msg: error.message };
}

if (compilation) {
let problems = undefined;
if (compilation.js_warning_error_msg) {
if (compilation.js_error_msg) {
problems = [problemFromCompile(compilation)];
} else if (compilation.warning_errors) {
problems = compilation.warning_errors.map(problemFromCompile);
}
if (problems) {
return {
typeHints: [],
warnings: [],
problems: problems,
}
} else {
Expand All @@ -460,16 +449,14 @@ const compile = (language, code) => {
}
}),
javascriptCode: compilation.js_code,
warnings: compilation.warnings.map(problemFromCompile),
}
}
} else {
return {
typeHints: [],
warnings: [],
problems: [
{
js_warning_error_msg: "No result was returned from compilation",
js_error_msg: "No result was returned from compilation",
row,
column,
endRow,
Expand All @@ -488,13 +475,7 @@ function updateMarkers(monaco, editorRef, compilation) {
monaco.editor.setModelMarkers(
editorRef.current.getModel(),
owner,
compilation.problems.map(toMonaco(monaco.MarkerSeverity.Error))
);
} else if (compilation?.warnings) {
monaco.editor.setModelMarkers(
editorRef.current.getModel(),
owner,
compilation.warnings.map(toMonaco(monaco.MarkerSeverity.Warning))
compilation.problems.map(toMonaco)
);
} else {
monaco.editor.removeAllMarkers(owner);
Expand Down Expand Up @@ -618,7 +599,7 @@ function App() {

React.useEffect(() => {
updateMarkers(monaco, editorRef, compilation)
}, [monaco, compilation?.problems, compilation?.warnings]);
}, [monaco, compilation?.problems]);

React.useEffect(() => {
if (workerState.bundledCode) {
Expand Down Expand Up @@ -717,7 +698,7 @@ function App() {
</div>
</Panel>
<PanelResizeHandle className="ResizeHandle" />
<ProblemsPanel warnings={compilation?.warnings} problems={compilation?.problems} />
<ProblemsPanel problems={compilation?.problems} />
</PanelGroup>
</Panel>
<PanelResizeHandle className="ResizeHandle" />
Expand Down
2 changes: 1 addition & 1 deletion scripts/add_canonical.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let replace_in_file ~orig_path file_path search_str =
in
let canonical_link =
Printf.sprintf
"<link rel=\"canonical\" href=\"https://melange.re/v2.1.0/api/%s\" \
"<link rel=\"canonical\" href=\"https://melange.re/v2.2.0/api/%s\" \
/></head>"
(String.escaped relative_file_path)
in
Expand Down
32 changes: 16 additions & 16 deletions scripts/add_canonical.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Test add_canonical exe
$ add_canonical .

$ cat foo.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/foo.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/foo.html" /></head>


$ mkdir -p melange/Js/Global
Expand Down Expand Up @@ -98,46 +98,46 @@ Test add_canonical exe
$ add_canonical .

$ cat ./melange/Js/Global/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Js/Global/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Js/Global/index.html" /></head>

$ cat ./melange/Node/Foo/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Node/Foo/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Node/Foo/index.html" /></head>

$ cat ./melange/Dom/Storage2/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Dom/Storage2/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Dom/Storage2/index.html" /></head>

$ cat ./melange/Belt/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Belt/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Belt/index.html" /></head>

$ cat ./melange/Belt/List/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Belt/List/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Belt/List/index.html" /></head>

$ cat ./melange/Stdlib/Int/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Stdlib/Int/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Stdlib/Int/index.html" /></head>

$ cat ./melange/Js/Typed_array/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Js/Typed_array/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Js/Typed_array/index.html" /></head>

$ cat ./melange/Js/TypedArray2/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Js/TypedArray2/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Js/TypedArray2/index.html" /></head>

$ cat ./melange/Js/WeakSet/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Js/WeakSet/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Js/WeakSet/index.html" /></head>

$ cat ./melange/Js/Fn/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Js/Fn/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Js/Fn/index.html" /></head>

$ cat ./melange/Belt/Set/String/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Belt/Set/String/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Belt/Set/String/index.html" /></head>

$ cat ./melange/Belt/Map/Dict/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Belt/Map/Dict/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Belt/Map/Dict/index.html" /></head>

$ cat ./melange/Belt/SortArray/Int/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Belt/SortArray/Int/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Belt/SortArray/Int/index.html" /></head>

$ cat ./melange/Melange_ppx/Ast_literal/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Melange_ppx/Ast_literal/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Melange_ppx/Ast_literal/index.html" /></head>

$ cat ./melange/Melange_ppx/External/index.html
<head><link rel="canonical" href="https://melange.re/v2.1.0/api/melange/Melange_ppx/External/index.html" /></head>
<head><link rel="canonical" href="https://melange.re/v2.2.0/api/melange/Melange_ppx/External/index.html" /></head>
2 changes: 1 addition & 1 deletion scripts/communicate-with-javascript.t
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ file. To update the tests, run `dune build @extract-code-blocks`.
>
> let pets = [| { name = "Brutus" }; { name = "Mochi" } |]
>
> let () = pets |. Belt.Array.map name |. Js.Array.join ~sep:"&" |. Js.log
> let () = pets |. Belt.Array.map name |. Js.Array2.joinWith "&" |. Js.log
> EOF

$ dune build @melange
Expand Down

0 comments on commit 614d4ee

Please sign in to comment.