Skip to content

Commit 4f3d0e7

Browse files
committed
fix bindings to lzstring
1 parent b91fb6f commit 4f3d0e7

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"highlight.js": "^11.11.1",
4242
"highlightjs-rescript": "^0.2.2",
4343
"isbot": "^5",
44-
"lz-string": "^1.4.4",
44+
"lz-string": "^1.5.0",
4545
"mdast-util-from-markdown": "^2.0.2",
4646
"mdast-util-toc": "^7.1.0",
4747
"react": "^19.1.0",
@@ -76,4 +76,4 @@
7676
"vite-plugin-devtools-json": "^1.0.0",
7777
"vite-plugin-env-compatible": "^2.0.1"
7878
}
79-
}
79+
}

src/Playground.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ let make = (~bundleBaseUrl: string, ~versions: array<string>) => {
15481548
->Option.mapOr([], str => str->String.split(",")->Array.map(String.trim))
15491549

15501550
let initialContent = switch (searchParams->Object.get((Code :> string)), initialLang) {
1551-
| (Some(compressedCode), _) => LzString.decompressToEncodedURIComponent(compressedCode)
1551+
| (Some(compressedCode), _) => LzString.lzString.decompressToEncodedURIComponent(compressedCode)
15521552
| (None, Reason) => initialReContent
15531553
| (None, Res) =>
15541554
switch initialVersion {

src/common/CompilerManagerHook.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ let createUrl = (pathName, ready) => {
219219
}
220220

221221
// Put code last as it is the longest param.
222-
Array.push(params, (Code, ready.code->LzString.compressToEncodedURIComponent))
222+
Array.push(params, (Code, ready.code->LzString.lzString.compressToEncodedURIComponent))
223223

224224
let querystring =
225225
params->Array.map(((key, value)) => (key :> string) ++ "=" ++ value)->Array.join("&")

src/common/LzString.res

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Used for compressing / decompressing code for url sharing
22

3-
@module("lz-string")
4-
external compressToEncodedURIComponent: string => string = "compressToEncodedURIComponent"
3+
type t = {
4+
compressToEncodedURIComponent: string => string,
5+
decompressToEncodedURIComponent: string => string,
6+
}
57

68
@module("lz-string")
7-
external decompressToEncodedURIComponent: string => string = "decompressFromEncodedURIComponent"
9+
external lzString: t = "default"

src/components/CodeExample.res

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,15 @@ module Toggle = {
247247
open ReactRouter
248248
let playgroundLinkButton =
249249
tab->isReScript
250-
? <Link.Path
251-
to={
252-
pathname: #"/try",
253-
search: `?code=${encodeURIComponent(tab.code)}`,
254-
}
250+
? <Link.String
251+
to={`/try?code=${LzString.lzString.compressToEncodedURIComponent(tab.code)}`}
255252
target="_blank"
256253
>
257254
// ICON Link to PLAYGROUND
258255
<Icon.ExternalLink
259256
className="text-gray-30 mt-px hover:cursor-pointer hover:text-gray-60 hover:bg-gray-30 w-6 h-6 p-1 rounded transition-all duration-300 ease-in-out"
260257
/>
261-
</Link.Path>
258+
</Link.String>
262259
: React.null
263260

264261
let copyButton = <CopyButton code={tab.code} />

0 commit comments

Comments
 (0)