Skip to content

Commit d582a96

Browse files
committed
Add share link button functionality
Also remove build time metric
1 parent 2841ee9 commit d582a96

File tree

5 files changed

+265
-138
lines changed

5 files changed

+265
-138
lines changed

bindings/Next.re

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ module Router = {
102102
route: string,
103103
asPath: string,
104104
events: Events.t,
105+
query: Js.Dict.t(string),
105106
};
106107

107-
[@bs.send] external push: (router, string ) => unit = "push";
108+
[@bs.send] external push: (router, string) => unit = "push";
108109

109110
[@bs.module "next/router"] external useRouter: unit => router = "useRouter";
111+
[@bs.send] external replace: (router, string) => unit = "replace";
110112
};
111113

112114
module Head = {

common/CompilerManagerHook.re

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ type ready = {
142142
type state =
143143
| Init
144144
| SetupFailed(string)
145-
| SwitchingCompiler(ready, string, array(string))
145+
| SwitchingCompiler(ready, string, array(string)) // (ready, targetId, libraries)
146146
| Ready(ready)
147147
| Compiling(ready, (Lang.t, string));
148148

@@ -159,13 +159,19 @@ type action =
159159
| CompileCode(Lang.t, string)
160160
| UpdateConfig(Config.t);
161161

162-
// onAction: This function is especially useful if you want to maintain
163-
// state that depends on any action happening in the compiler, no
164-
// matter if a state transition happened, or not.
165-
// We need that for a ActivityIndicator component to give feedback
166-
// to the user that an action happened (useful in cases where the output
167-
// didn't visually change)
168-
let useCompilerManager = (~onAction: option(action => unit)=?, ()) => {
162+
// ~initialLang:
163+
// The target language the compiler should be set to during
164+
// playground initialization. If the compiler doesn't support the language, it
165+
// will default to ReScript syntax
166+
//
167+
// ~onAction:
168+
// This function is especially useful if you want to maintain state that
169+
// depends on any action happening in the compiler, no matter if a state
170+
// transition happened, or not. We need that for a ActivityIndicator
171+
// component to give feedback to the user that an action happened (useful in
172+
// cases where the output didn't visually change)
173+
let useCompilerManager =
174+
(~initialLang: Lang.t=Res, ~onAction: option(action => unit)=?, ()) => {
169175
let (state, setState) = React.useState(_ => Init);
170176

171177
// Dispatch method for the public interface
@@ -365,10 +371,17 @@ let useCompilerManager = (~onAction: option(action => unit)=?, ()) => {
365371
instance,
366372
};
367373

374+
let targetLang =
375+
Version.availableLanguages(apiVersion)
376+
->Js.Array2.find(l => {l === initialLang})
377+
->Belt.Option.getWithDefault(
378+
Version.defaultTargetLang(apiVersion),
379+
);
380+
368381
setState(_ => {
369382
Ready({
370383
selected,
371-
targetLang: Version.defaultTargetLang(apiVersion),
384+
targetLang,
372385
versions,
373386
errors: [||],
374387
result: FinalResult.Nothing,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"glob": "^7.1.4",
2121
"gray-matter": "^4.0.2",
2222
"highlight.js": "^9.15.10",
23+
"lz-string": "^1.4.4",
2324
"next": "^9.5.1",
2425
"next-transpile-modules": "^2.3.1",
2526
"prettier": "^1.18.2",

0 commit comments

Comments
 (0)