Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

refactor: cleanup shared modules (#3119)

Bogdan Chadkinc596da612703
diff --git a/apps/builder/app/entry.server.tsx b/apps/builder/app/entry.server.tsx
index 2ba50a51f9..424af2e611 100644
--- a/apps/builder/app/entry.server.tsx
+++ b/apps/builder/app/entry.server.tsx
@@ -1,7 +1,7 @@
import { renderToString } from "react-dom/server";
import type { EntryContext } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
-import { handleRequest as handleRequestBuilder } from "./shared/remix";
+import { handleRequest as handleRequestBuilder } from "./shared/remix/handle-request.server";
import { isCanvas } from "./shared/router-utils";
const handleRequestCanvas = (
diff --git a/apps/builder/app/routes/builder.tsx b/apps/builder/app/routes/builder.tsx
index 83dcdbe0df..cf6dc07961 100644
--- a/apps/builder/app/routes/builder.tsx
+++ b/apps/builder/app/routes/builder.tsx
@@ -1,5 +1,5 @@
import type { ServerRuntimeMetaFunction as MetaFunction } from "@remix-run/server-runtime";
-import { Root } from "~/shared/remix";
+import { Root } from "~/shared/remix/root";
import type { ShouldRevalidateFunction } from "@remix-run/react";
export const meta: MetaFunction = () => {
diff --git a/apps/builder/app/routes/dashboard.tsx b/apps/builder/app/routes/dashboard.tsx
index 67b4800b4c..047a37eef7 100644
--- a/apps/builder/app/routes/dashboard.tsx
+++ b/apps/builder/app/routes/dashboard.tsx
@@ -1,5 +1,5 @@
import type { ServerRuntimeMetaFunction as MetaFunction } from "@remix-run/server-runtime";
-import { Root } from "~/shared/remix";
+import { Root } from "~/shared/remix/root";
export const meta: MetaFunction = () => {
return [{ title: "Webstudio Dashboard" }];
diff --git a/apps/builder/app/routes/login.tsx b/apps/builder/app/routes/login.tsx
index a010e0e7ca..c30c0559f4 100644
--- a/apps/builder/app/routes/login.tsx
+++ b/apps/builder/app/routes/login.tsx
@@ -1,5 +1,5 @@
import type { ServerRuntimeMetaFunction as MetaFunction } from "@remix-run/server-runtime";
-import { Root } from "~/shared/remix";
+import { Root } from "~/shared/remix/root";
export const meta: MetaFunction = () => {
return [{ title: "Webstudio Login" }];
diff --git a/apps/builder/app/routes/n8n.tsx b/apps/builder/app/routes/n8n.tsx
index d95f07ce0d..6590c7a342 100644
--- a/apps/builder/app/routes/n8n.tsx
+++ b/apps/builder/app/routes/n8n.tsx
@@ -1,5 +1,5 @@
import type { ServerRuntimeMetaFunction as MetaFunction } from "@remix-run/server-runtime";
-import { Root } from "~/shared/remix";
+import { Root } from "~/shared/remix/root";
export const meta: MetaFunction = () => {
return [{ title: "Webstudio" }];
diff --git a/apps/builder/app/routes/vercel-deploy-workaround.tsx b/apps/builder/app/routes/vercel-deploy-workaround.tsx
index 928c386065..970e03a52a 100644
--- a/apps/builder/app/routes/vercel-deploy-workaround.tsx
+++ b/apps/builder/app/routes/vercel-deploy-workaround.tsx
@@ -1,6 +1,6 @@
import type { LinksFunction } from "@remix-run/server-runtime";
-import { Root } from "~/shared/remix";
+import { Root } from "~/shared/remix/root";
import interFont from "@fontsource-variable/inter/index.css";
import manropeVariableFont from "@fontsource-variable/manrope/index.css";
import robotoMonoFont from "@fontsource/roboto-mono/index.css";
diff --git a/apps/builder/app/shared/crypto/crypto-json.server.ts b/apps/builder/app/shared/crypto/crypto-json.server.ts
deleted file mode 100644
index 4af4ef678e..0000000000
--- a/apps/builder/app/shared/crypto/crypto-json.server.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import * as jose from "jose";
-import { webcrypto as crypto } from "node:crypto";
-
-const getSecretKey = async (secret: string) => {
- const secretBuffer = await crypto.subtle.digest(
- "SHA-256",
- new TextEncoder().encode(secret)
- );
-
- return new Uint8Array(secretBuffer);
-};
-
-export const encode = async (json: Record<string, unknown>, secret: string) => {
- const secretKey = await getSecretKey(secret);
-
- const jwt = await new jose.EncryptJWT(json)
- .setProtectedHeader({ alg: "dir", enc: "A128CBC-HS256" })
- .encrypt(secretKey);
-
- return jwt;
-};
-
-export const decode = async (
- token: string,
- secret: string
-): Promise<Record<string, unknown>> => {
- const secretKey = await getSecretKey(secret);
-
- const jwt = await jose.jwtDecrypt(token, secretKey);
-
- return jwt.payload;
-};
diff --git a/apps/builder/app/shared/remix/constants.ts b/apps/builder/app/shared/remix/constants.ts
deleted file mode 100644
index b5ddbd71f5..0000000000
--- a/apps/builder/app/shared/remix/constants.ts
+++ /dev/null
@@ -1 +0,0 @@
-export const CRITICAL_CSS_MARKER = "__CRITICAL_CSS__";
diff --git a/apps/builder/app/shared/remix/index.ts b/apps/builder/app/shared/remix/index.ts
deleted file mode 100644
index 444dfb6c40..0000000000
--- a/apps/builder/app/shared/remix/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./handle-request.server";
-export * from "./root";
diff --git a/apps/builder/app/shared/remix/insert-critical-css.ts b/apps/builder/app/shared/remix/insert-critical-css.ts
deleted file mode 100644
index fda5504048..0000000000
--- a/apps/builder/app/shared/remix/insert-critical-css.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { flushCss } from "@webstudio-is/design-system";
-import { CRITICAL_CSS_MARKER } from "./constants";
-
-export const insertCriticalCss = (markup: string): string => {
- return markup.replace(CRITICAL_CSS_MARKER, `<style>${flushCss()}</style>`);
-};
diff --git a/apps/builder/package.json b/apps/builder/package.json
index 2a03a7561d..8ea9bdb692 100644
--- a/apps/builder/package.json
+++ b/apps/builder/package.json
@@ -87,7 +87,6 @@
"hyphenate-style-name": "^1.0.4",
"immer": "^10.0.3",
"immerhin": "^0.9.0",
- "jose": "^4.11.2",
"lexical": "^0.14.3",
"match-sorter": "^6.3.1",
"mdast-util-from-markdown": "^2.0.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 149ea287d0..330bf04582 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -263,9 +263,6 @@ importers:
immerhin:
specifier: ^0.9.0
version: 0.9.0
- jose:
- specifier: ^4.11.2
- version: 4.11.2
lexical:
specifier: ^0.14.3
version: 0.14.3
@@ -12087,10 +12084,6 @@ packages:
hasBin: true
dev: true
- resolution: {integrity: sha512-njj0VL2TsIxCtgzhO+9RRobBvws4oYyCM8TpvoUQwl/MbIM3NFJRR9+e6x0sS5xXaP1t6OCBkaBME98OV9zU5A==}
- dev: false
-
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}