From 536828b7a345c59407d6005859167f2f82d50fee Mon Sep 17 00:00:00 2001 From: Mohd Salman Date: Sat, 17 Feb 2024 15:16:42 +0530 Subject: [PATCH 1/3] feat: add js object to typescript converter (#392) --- pages/js-object-to-typescript.tsx | 74 +++++++++++++++++++++++++++++++ utils/routes.tsx | 7 ++- 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 pages/js-object-to-typescript.tsx diff --git a/pages/js-object-to-typescript.tsx b/pages/js-object-to-typescript.tsx new file mode 100644 index 00000000..2923be05 --- /dev/null +++ b/pages/js-object-to-typescript.tsx @@ -0,0 +1,74 @@ +import * as React from "react"; +import { useCallback } from "react"; +import ConversionPanel, { Transformer } from "@components/ConversionPanel"; +import { useSettings } from "@hooks/useSettings"; +import { EditorPanelProps } from "@components/EditorPanel"; +import { Settings } from "@constants/svgoConfig"; +import Form, { InputType } from "@components/Form"; + +const formFields = [ + { + type: InputType.SWITCH, + key: "typealias", + label: "Create Mono Type" + } +]; + +export default function JsObjectToTypescript() { + const name = "JS Object to Typescript"; + + const [settings, setSettings] = useSettings(name, { + typealias: false + }); + + const transformer = useCallback( + async ({ value }) => { + const result = JSON.stringify + (eval("(" + + value + + ")"), null, 2); + + const { run } = await import("json_typegen_wasm"); + + return run( + "Root", + result, + JSON.stringify({ + output_mode: settings.typealias + ? "typescript/typealias" + : "typescript" + }) + ); + }, + [settings] + ); + + const getSettingsElement = useCallback( + ({ open, toggle }) => { + return ( + + title={name} + onSubmit={setSettings} + open={open} + toggle={toggle} + formsFields={formFields} + initialValues={settings} + /> + ); + }, + [] + ); + + return ( + + ); +} diff --git a/utils/routes.tsx b/utils/routes.tsx index 2d1bb2d0..cb19f16f 100644 --- a/utils/routes.tsx +++ b/utils/routes.tsx @@ -217,7 +217,12 @@ export const categorizedRoutes = [ label: "to JSON", path: "/js-object-to-json", desc: "An online REPL for converting JS Object to JSON." - } + }, + { + label: "to Typescript", + path: "/js-object-to-typescript", + desc: "An online REPL for converting JS Object to Typescript." + }, ] }, { From e129420895e9ed4b17f8b5792e18719db853adee Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 17 Feb 2024 15:25:44 +0530 Subject: [PATCH 2/3] docs: add salman0ansari as a contributor for code (#394) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] --------- Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 12 +++++++++++- README.md | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 02b2604a..5b8bf0e1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -347,8 +347,18 @@ "contributions": [ "code" ] + }, + { + "login": "salman0ansari", + "name": "Mohd Salman", + "avatar_url": "https://avatars.githubusercontent.com/u/30106022?v=4", + "profile": "https://github.com/salman0ansari", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, - "skipCi": true + "skipCi": true, + "commitType": "docs" } diff --git a/README.md b/README.md index 8f57849f..c3355c1e 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds Jack Sutton
Jack Sutton

💻 Salakhutdinov Salavat
Salakhutdinov Salavat

💻 + Mohd Salman
Mohd Salman

💻 From ff7557939be351706f4dc6f71cc375e3bc64c225 Mon Sep 17 00:00:00 2001 From: Gan Kai Date: Wed, 28 Jan 2026 22:55:27 +0800 Subject: [PATCH 3/3] chore: update build requirements to Node 20 (#431) * remove svg-to-dataurl dependency * chore: update package.json for build command and node version - Modified the build command to include NODE_OPTIONS for legacy OpenSSL support. - Updated the Node.js engine requirement to >=20.17.0. - Added packageManager field for Yarn version. * chore: update now.json for build environment and Node.js version - Added NODE_OPTIONS for OpenSSL legacy support in the build environment. - Specified Node.js engine version to 20.x. * chore: remove Node.js engine specification from now.json - Removed the Node.js engine version specification from the configuration file. * chore: remove now.json configuration file - Deleted the now.json file, which contained build environment settings and redirects. --------- Co-authored-by: madflow Co-authored-by: Ritesh Kumar --- components/SvgConverter.tsx | 12 +++++++++++- package.json | 8 ++++---- now.json => vercel.json | 6 +++++- yarn.lock | 5 ----- 4 files changed, 20 insertions(+), 11 deletions(-) rename now.json => vercel.json (81%) diff --git a/components/SvgConverter.tsx b/components/SvgConverter.tsx index 9e1f3094..56ccfedb 100644 --- a/components/SvgConverter.tsx +++ b/components/SvgConverter.tsx @@ -4,7 +4,17 @@ import { EditorPanelProps } from "@components/EditorPanel"; import Form from "@components/Form"; import ConversionPanel, { Transformer } from "@components/ConversionPanel"; import { Alert, Badge, Heading, Pane } from "evergreen-ui"; -import svgToDataUrl from "svg-to-dataurl"; + +const svgToDataUrl = (svgStr: string) => { + const encoded = encodeURIComponent(svgStr) + .replace(/'/g, "%27") + .replace(/"/g, "%22"); + + const header = "data:image/svg+xml,"; + const dataUrl = header + encoded; + + return dataUrl; +}; interface SvgConverterProps { name: string; diff --git a/package.json b/package.json index 11a62302..33da7d3d 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,13 @@ "dev": "next dev", "start": "next start", "format": "prettier --write '**/*.ts' '**/*.tsx'", - "build": "next build", + "build": "NODE_OPTIONS=--openssl-legacy-provider next build", "now-build": "next build", "postinstall": "patch-package", "build:analyze": "ANALYZE=true yarn build" }, "engines": { - "node": "16.x" + "node": "20.x" }, "dependencies": { "@babel/plugin-transform-flow-strip-types": "^7.16.0", @@ -89,7 +89,6 @@ "rust-keywords": "^1.1.0", "sha1": "^1.1.1", "stringify-object": "^3.3.0", - "svg-to-dataurl": "^1.0.0", "svgo": "^1.3.2", "tempy": "^1.0.1", "text-encoding-utf-8": "^1.0.2", @@ -125,5 +124,6 @@ "./assets/*/*.svg": [ "imagemin-lint-staged" ] - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/now.json b/vercel.json similarity index 81% rename from now.json rename to vercel.json index 5752e8b2..4a4c7e8c 100644 --- a/now.json +++ b/vercel.json @@ -1,5 +1,9 @@ { - "version": 2, + "build": { + "env": { + "NODE_OPTIONS": "--openssl-legacy-provider" + } + }, "redirects": [ { "source": "/svg-to-jsx", diff --git a/yarn.lock b/yarn.lock index 94155dce..ad737c1d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9429,11 +9429,6 @@ svg-parser@^2.0.2: resolved "https://registry.yarnpkg.com/svg-parser/-/svg-parser-2.0.4.tgz#fdc2e29e13951736140b76cb122c8ee6630eb6b5" integrity sha512-e4hG1hRwoOdRb37cIMSgzNsxyzKfayW6VOflrwvR+/bzrkyxY/31WkbgnQpgtrNp1SdpJvpUAGTa/ZoiPNDuRQ== -svg-to-dataurl@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/svg-to-dataurl/-/svg-to-dataurl-1.0.0.tgz#343f21a5dc3e051ae413c590cf478b7cf7a5f070" - integrity sha512-WrPB9vdd4RO0BjcPN6NJ9ofj3Zt8de16TJZ+JVJ4LnE2OKNGz+HjgGv6rE5Hp3s+OnM56X9i64mfJDU9uf4ZqQ== - svgo@^1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/svgo/-/svgo-1.3.2.tgz#b6dc511c063346c9e415b81e43401145b96d4167"