chore: upgrade to react 19 beta and next 14 canary

This commit is contained in:
2024-05-19 14:53:00 +02:00
parent fe429295ef
commit 63e0be09e6
65 changed files with 2626 additions and 1898 deletions

View File

@@ -1,3 +1,4 @@
import { PropsWithChildren } from "react";
import { Metadata } from "next";
import { toolGroups } from "@/config/tools";
@@ -12,6 +13,6 @@ export const metadata: Metadata = {
},
};
export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -1,6 +1,6 @@
"use client";
import { useCallback, useState } from "react";
import { useState } from "react";
import { decode, encode, isValid } from "js-base64";
import { toolGroups } from "@/config/tools";
@@ -16,28 +16,28 @@ export default function Page() {
encoded: "8J+YgPCfmILwn6Sj",
});
const setFormByDecoded = useCallback((text: string) => {
const setFormByDecoded = (text: string) => {
setForm({
decoded: text,
encoded: encode(text),
});
}, []);
};
const setFormByEncoded = useCallback((text: string) => {
const setFormByEncoded = (text: string) => {
const newDecoded = decode(text);
setForm({
decoded: isValid(text) && !newDecoded.includes("<22>") ? newDecoded : "",
encoded: text,
});
}, []);
};
const clearBoth = useCallback(() => {
const clearBoth = () => {
setForm({
decoded: "",
encoded: "",
});
}, []);
};
const onDecodedChange: TextareaProps["onChange"] = e => setFormByDecoded(e.currentTarget.value);
const onEncodedChange: TextareaProps["onChange"] = e => setFormByEncoded(e.currentTarget.value);

View File

@@ -1,3 +1,4 @@
import { PropsWithChildren } from "react";
import { Metadata } from "next";
import { toolGroups } from "@/config/tools";
@@ -12,6 +13,6 @@ export const metadata: Metadata = {
},
};
export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -1,6 +1,6 @@
"use client";
import { useCallback, useState } from "react";
import { useState } from "react";
import { escape, unescape } from "html-escaper";
import { toolGroups } from "@/config/tools";
@@ -16,26 +16,26 @@ export default function Page() {
encoded: "&gt; It&#39;s &quot;HTML escaping&quot;.",
});
const setFormByDecoded = useCallback((text: string) => {
const setFormByDecoded = (text: string) => {
setForm({
decoded: text,
encoded: escape(text),
});
}, []);
};
const setFormByEncoded = useCallback((text: string) => {
const setFormByEncoded = (text: string) => {
setForm({
decoded: unescape(text),
encoded: text,
});
}, []);
};
const clearBoth = useCallback(() => {
const clearBoth = () => {
setForm({
decoded: "",
encoded: "",
});
}, []);
};
const onDecodedChange: TextareaProps["onChange"] = e => setFormByDecoded(e.currentTarget.value);
const onEncodedChange: TextareaProps["onChange"] = e => setFormByEncoded(e.currentTarget.value);

View File

@@ -1,3 +1,4 @@
import { PropsWithChildren } from "react";
import { Metadata } from "next";
import { toolGroups } from "@/config/tools";
@@ -12,6 +13,6 @@ export const metadata: Metadata = {
},
};
export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -1,6 +1,6 @@
"use client";
import { useCallback, useState } from "react";
import { useState } from "react";
import { toolGroups } from "@/config/tools";
import { decode } from "@/lib/jwt";
@@ -20,7 +20,7 @@ export default function Page() {
const header = h.map(x => JSON.stringify(x, null, 2)).unwrapOr("");
const payload = p.map(x => JSON.stringify(x, null, 2)).unwrapOr("");
const clearJwt = useCallback(() => setJwt(""), []);
const clearJwt = () => setJwt("");
const onJwtChange: TextareaProps["onChange"] = e => setJwt(e.currentTarget.value);
@@ -49,9 +49,11 @@ export default function Page() {
</PageSection>
<div className="flex flex-col gap-3">
<PageSection title="Header" control={heaederControl}>
{/* @ts-expect-error react 19 beta error */}
<Editor height={180} language="json" value={header} options={{ readOnly: true }} />
</PageSection>
<PageSection title="Payload" control={payloadControl}>
{/* @ts-expect-error react 19 beta error */}
<Editor height={180} language="json" value={payload} options={{ readOnly: true }} />
</PageSection>
</div>

View File

@@ -1,3 +1,4 @@
import { PropsWithChildren } from "react";
import { Metadata } from "next";
import { toolGroups } from "@/config/tools";
@@ -11,6 +12,6 @@ export const metadata: Metadata = {
},
};
export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -1,3 +1,4 @@
import { PropsWithChildren } from "react";
import { Metadata } from "next";
import { toolGroups } from "@/config/tools";
@@ -12,6 +13,6 @@ export const metadata: Metadata = {
},
};
export default function Layout({ children }: { children: React.ReactNode }) {
export default function Layout({ children }: PropsWithChildren) {
return children;
}

View File

@@ -1,6 +1,6 @@
"use client";
import { useCallback, useState } from "react";
import { useState } from "react";
import { toolGroups } from "@/config/tools";
import { safeDecodeURIComponent, safeEncodeURIComponent } from "@/lib/uri";
@@ -16,26 +16,26 @@ export default function Page() {
encoded: "%3E%20It's%20%22URL%20encoding%22%3F",
});
const setFormByDecoded = useCallback((text: string) => {
const setFormByDecoded = (text: string) => {
setForm({
decoded: text,
encoded: safeEncodeURIComponent(text).unwrapOr(""),
});
}, []);
};
const setFormByEncoded = useCallback((text: string) => {
const setFormByEncoded = (text: string) => {
setForm({
decoded: safeDecodeURIComponent(text).unwrapOr(""),
encoded: text,
});
}, []);
};
const clearBoth = useCallback(() => {
const clearBoth = () => {
setForm({
decoded: "",
encoded: "",
});
}, []);
};
const onDecodedChange: TextareaProps["onChange"] = e => setFormByDecoded(e.currentTarget.value);
const onEncodedChange: TextareaProps["onChange"] = e => setFormByEncoded(e.currentTarget.value);