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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Switch from LoaderFunction to LoaderArgs (#697)
Bogdan Chadkina82eee9c4bc0
diff --git a/apps/designer/.gitignore b/apps/designer/.gitignoreindex 92b1c7ada8..2fb241ff74 100644--- a/apps/designer/.gitignore+++ b/apps/designer/.gitignore@@ -7,5 +7,6 @@/public/build/api/index.js/api/index.js.map+/api/_assets/public/uploads/public/s/uploadsdiff --git a/apps/designer/app/routes/$.tsx b/apps/designer/app/routes/$.tsxindex a9f2202a95..706239efee 100644--- a/apps/designer/app/routes/$.tsx+++ b/apps/designer/app/routes/$.tsx@@ -1,9 +1,5 @@-import { redirect, json } from "@remix-run/node";-import type {- MetaFunction,- LoaderFunction,- ErrorBoundaryComponent,-} from "@remix-run/node";+import { redirect, json, LoaderArgs } from "@remix-run/node";+import type { MetaFunction, ErrorBoundaryComponent } from "@remix-run/node";import { useLoaderData } from "@remix-run/react";import djb2a from "djb2a";import { InstanceRoot, Root } from "@webstudio-is/react-sdk";@@ -51,7 +47,7 @@ export const meta: MetaFunction = ({ data }: { data: Data }) => {return { title: page.title, ...page.meta };};-export const loader: LoaderFunction = async ({ request }): Promise<Data> => {+export const loader = async ({ request }: LoaderArgs): Promise<Data> => {const buildParams = getBuildParams(request);if (buildParams === undefined) {diff --git a/apps/designer/app/routes/auth/dev.tsx b/apps/designer/app/routes/auth/dev.tsxindex b6da7294eb..ee5e6751cc 100644--- a/apps/designer/app/routes/auth/dev.tsx+++ b/apps/designer/app/routes/auth/dev.tsx@@ -1,4 +1,4 @@-import { ActionFunction, redirect } from "@remix-run/node";+import { type ActionArgs, redirect } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { dashboardPath, loginPath } from "~/shared/router-utils";import { AUTH_PROVIDERS } from "~/shared/session";@@ -7,7 +7,7 @@ export default function Dev() {return null;}-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {try {return await authenticator.authenticate("dev", request, {successRedirect: dashboardPath(),diff --git a/apps/designer/app/routes/auth/github.tsx b/apps/designer/app/routes/auth/github.tsxindex f6b80386e0..049c726d98 100644--- a/apps/designer/app/routes/auth/github.tsx+++ b/apps/designer/app/routes/auth/github.tsx@@ -1,4 +1,4 @@-import { ActionFunction, redirect } from "@remix-run/node";+import { type ActionArgs, redirect } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { dashboardPath, loginPath } from "~/shared/router-utils";import { sentryException } from "~/shared/sentry";@@ -8,7 +8,7 @@ export default function GH() {return null;}-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {try {return await authenticator.authenticate("github", request, {successRedirect: dashboardPath(),diff --git a/apps/designer/app/routes/auth/github/callback.tsx b/apps/designer/app/routes/auth/github/callback.tsxindex 6eed9c0839..8443f068a2 100644--- a/apps/designer/app/routes/auth/github/callback.tsx+++ b/apps/designer/app/routes/auth/github/callback.tsx@@ -1,9 +1,9 @@-import { LoaderFunction, redirect } from "@remix-run/node";+import { type LoaderArgs, redirect } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { dashboardPath, loginPath } from "~/shared/router-utils";import { AUTH_PROVIDERS } from "~/shared/session";-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {const url = new URL(request.url);const error = url.searchParams.get("error");const errorDescription = url.searchParams.get("error_description");diff --git a/apps/designer/app/routes/auth/google.tsx b/apps/designer/app/routes/auth/google.tsxindex 5d8b5982bc..cdf037d639 100644--- a/apps/designer/app/routes/auth/google.tsx+++ b/apps/designer/app/routes/auth/google.tsx@@ -1,4 +1,4 @@-import { ActionFunction, LoaderFunction, redirect } from "@remix-run/node";+import { type ActionArgs, type LoaderArgs, redirect } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { dashboardPath, loginPath } from "~/shared/router-utils";import { sentryException } from "~/shared/sentry";@@ -8,9 +8,9 @@ export default function Google() {return null;}-export const loader: LoaderFunction = () => redirect("/login");+export const loader = (_args: LoaderArgs) => redirect("/login");-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {try {return await authenticator.authenticate("google", request, {successRedirect: dashboardPath(),diff --git a/apps/designer/app/routes/auth/google/callback.tsx b/apps/designer/app/routes/auth/google/callback.tsxindex 54b4713352..c840bb3aa3 100644--- a/apps/designer/app/routes/auth/google/callback.tsx+++ b/apps/designer/app/routes/auth/google/callback.tsx@@ -1,8 +1,8 @@-import { LoaderFunction } from "@remix-run/node";+import type { LoaderArgs } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { dashboardPath, loginPath } from "~/shared/router-utils";-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {return authenticator.authenticate("google", request, {successRedirect: dashboardPath(),failureRedirect: loginPath({}),diff --git a/apps/designer/app/routes/dashboard.tsx b/apps/designer/app/routes/dashboard.tsxindex 4a0cb028ab..35ca4c2cbc 100644--- a/apps/designer/app/routes/dashboard.tsx+++ b/apps/designer/app/routes/dashboard.tsx@@ -1,9 +1,9 @@-import type { LoaderFunction, MetaFunction } from "@remix-run/node";+import type { LoaderArgs, MetaFunction } from "@remix-run/node";import { Root } from "~/shared/remix";import env from "~/env.server";import { getThemeData } from "~/shared/theme";-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {return {env,theme: await getThemeData(request),diff --git a/apps/designer/app/routes/dashboard/index.tsx b/apps/designer/app/routes/dashboard/index.tsxindex 382f842862..c96c906204 100644--- a/apps/designer/app/routes/dashboard/index.tsx+++ b/apps/designer/app/routes/dashboard/index.tsx@@ -1,10 +1,6 @@import { useLoaderData } from "@remix-run/react";-import {- type ActionFunction,- json,- type LoaderFunction,- redirect,-} from "@remix-run/node";+import type { ActionArgs, LoaderArgs } from "@remix-run/node";+import { json, redirect } from "@remix-run/node";import { Dashboard, links } from "~/dashboard";import { db } from "@webstudio-is/project/server";import { ensureUserCookie } from "~/shared/session";@@ -27,7 +23,7 @@ type Data = {user: User;};-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {const { project: title } = schema.parse(await request.formData());const { userId, headers } = await ensureUserCookie(request);@@ -46,7 +42,7 @@ export const action: ActionFunction = async ({ request }) => {return { errors: "Unexpected error" };};-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {const user = await findAuthenticatedUser(request);if (!user) {return redirect(loginPath({}));diff --git a/apps/designer/app/routes/designer.tsx b/apps/designer/app/routes/designer.tsxindex 44e8680655..429a9a5a2e 100644--- a/apps/designer/app/routes/designer.tsx+++ b/apps/designer/app/routes/designer.tsx@@ -1,9 +1,9 @@-import type { LoaderFunction, MetaFunction } from "@remix-run/node";+import type { LoaderArgs, MetaFunction } from "@remix-run/node";import { Root } from "~/shared/remix";import env from "~/env.server";import { getThemeData } from "~/shared/theme";-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {return {env,theme: await getThemeData(request),diff --git a/apps/designer/app/routes/designer/$projectId.tsx b/apps/designer/app/routes/designer/$projectId.tsxindex 52ffcc5cea..40de33a232 100644--- a/apps/designer/app/routes/designer/$projectId.tsx+++ b/apps/designer/app/routes/designer/$projectId.tsx@@ -1,5 +1,5 @@import { useLoaderData } from "@remix-run/react";-import type { ErrorBoundaryComponent, LoaderFunction } from "@remix-run/node";+import type { ErrorBoundaryComponent, LoaderArgs } from "@remix-run/node";import { type DesignerProps, Designer, links } from "~/designer";import { db } from "@webstudio-is/project/server";import { ErrorMessage } from "~/shared/error";@@ -8,10 +8,10 @@ import { getBuildOrigin } from "~/shared/router-utils";export { links };-export const loader: LoaderFunction = async ({+export const loader = async ({params,request,-}): Promise<DesignerProps> => {+}: LoaderArgs): Promise<DesignerProps> => {if (params.projectId === undefined) {throw new Error("Project id undefined");}diff --git a/apps/designer/app/routes/index.tsx b/apps/designer/app/routes/index.tsxindex 1c4b439020..31bd6ff760 100644--- a/apps/designer/app/routes/index.tsx+++ b/apps/designer/app/routes/index.tsx@@ -5,7 +5,7 @@import type {ErrorBoundaryComponent,- LoaderFunction,+ LoaderArgs,MetaFunction,} from "@remix-run/node";import CatchAllContnet, {@@ -19,7 +19,7 @@ import CatchAllContnet, {// If they are the same, Remix may get confused, and don't load data on page transitions.export const meta: MetaFunction = (args) => catchAllmeta(args);-export const loader: LoaderFunction = (args) => catchAllloader(args);+export const loader = (args: LoaderArgs) => catchAllloader(args);export const handle = catchAllHandle;export const ErrorBoundary: ErrorBoundaryComponent = ({ error }) => (<CatchAllErrorBoundary error={error} />diff --git a/apps/designer/app/routes/login.tsx b/apps/designer/app/routes/login.tsxindex a76cc559f8..756a3d865c 100644--- a/apps/designer/app/routes/login.tsx+++ b/apps/designer/app/routes/login.tsx@@ -1,9 +1,9 @@-import { LoaderFunction, MetaFunction } from "@remix-run/node";+import type { LoaderArgs, MetaFunction } from "@remix-run/node";import { Root } from "~/shared/remix";import env from "~/env.server";import { getThemeData } from "~/shared/theme";-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {return {env,theme: await getThemeData(request),diff --git a/apps/designer/app/routes/login/index.tsx b/apps/designer/app/routes/login/index.tsxindex e48215965e..573b941256 100644--- a/apps/designer/app/routes/login/index.tsx+++ b/apps/designer/app/routes/login/index.tsx@@ -1,4 +1,4 @@-import { LoaderFunction, redirect } from "@remix-run/node";+import { type LoaderArgs, redirect } from "@remix-run/node";import { findAuthenticatedUser } from "~/services/auth.server";import env from "~/env.server";@@ -9,7 +9,7 @@ import { dashboardPath } from "~/shared/router-utils";export { links };-export const loader: LoaderFunction = async ({ request }) => {+export const loader = async ({ request }: LoaderArgs) => {const user = await findAuthenticatedUser(request);if (user) {return redirect(dashboardPath());diff --git a/apps/designer/app/routes/logout.tsx b/apps/designer/app/routes/logout.tsxindex d7f80db096..2c88769f82 100644--- a/apps/designer/app/routes/logout.tsx+++ b/apps/designer/app/routes/logout.tsx@@ -1,4 +1,4 @@-import { ActionFunction } from "@remix-run/node";+import type { ActionArgs } from "@remix-run/node";import { authenticator } from "~/services/auth.server";import { loginPath } from "~/shared/router-utils";@@ -6,6 +6,6 @@ export default function Logout() {return null;}-export const loader: ActionFunction = async ({ request }) => {+export const loader = async ({ request }: ActionArgs) => {await authenticator.logout(request, { redirectTo: loginPath({}) });};diff --git a/apps/designer/app/routes/rest/assets.$projectId.tsx b/apps/designer/app/routes/rest/assets.$projectId.tsxindex a57683c3bb..7acd1dd261 100644--- a/apps/designer/app/routes/rest/assets.$projectId.tsx+++ b/apps/designer/app/routes/rest/assets.$projectId.tsx@@ -1,4 +1,4 @@-import { ActionFunction, LoaderFunction } from "@remix-run/node";+import type { ActionArgs, LoaderArgs } from "@remix-run/node";import { useActionData } from "@remix-run/react";import type { Asset } from "@webstudio-is/asset-uploader";import {@@ -16,19 +16,17 @@ const DeleteAssets = zfd.formData({assetId: zfd.repeatableOfType(zfd.text()),});-export const loader: LoaderFunction = async ({- params,-}): Promise<Array<Asset>> => {+export const loader = async ({ params }: LoaderArgs): Promise<Array<Asset>> => {if (params.projectId === undefined) {throw new Error("Project id undefined");}return await loadByProject(params.projectId);};-export const action: ActionFunction = async ({+export const action = async ({request,params,-}): Promise<ActionData | undefined> => {+}: ActionArgs): Promise<ActionData | undefined> => {if (params.projectId === undefined) {throw new Error("Project id undefined");}diff --git a/apps/designer/app/routes/rest/breakpoints.$projectId.ts b/apps/designer/app/routes/rest/breakpoints.$projectId.tsindex 1398151476..e9d70fb221 100644--- a/apps/designer/app/routes/rest/breakpoints.$projectId.ts+++ b/apps/designer/app/routes/rest/breakpoints.$projectId.ts@@ -1,4 +1,4 @@-import type { LoaderFunction } from "@remix-run/node";+import type { LoaderArgs } from "@remix-run/node";import type { Breakpoint } from "@webstudio-is/css-data";import { db } from "@webstudio-is/project/server";@@ -6,9 +6,9 @@ export type ErrorData = {errors: string;};-export const loader: LoaderFunction = async ({+export const loader = async ({params,-}): Promise<Array<Breakpoint> | ErrorData> => {+}: LoaderArgs): Promise<Array<Breakpoint> | ErrorData> => {try {if (params.projectId === undefined) {throw new Error(`Project ID required`);diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.tsindex 3c200eb1b6..635e47d793 100644--- a/apps/designer/app/routes/rest/pages.$projectId.ts+++ b/apps/designer/app/routes/rest/pages.$projectId.ts@@ -1,4 +1,4 @@-import { LoaderFunction, ActionFunction } from "@remix-run/node";+import type { LoaderArgs, ActionArgs } from "@remix-run/node";import { db } from "@webstudio-is/project/server";import { type Pages, utils, pathValidators } from "@webstudio-is/project";import { zfd } from "zod-form-data";@@ -125,10 +125,10 @@ const handleDelete = async (return { status: "ok" };};-export const action: ActionFunction = async ({+export const action = async ({request,params,-}): Promise<FetcherData<unknown>> => {+}: ActionArgs): Promise<FetcherData<unknown>> => {try {if (params.projectId === undefined) {throw new Error(`Project ID required`);@@ -160,9 +160,9 @@ export type ErrorData = {errors: string;};-export const loader: LoaderFunction = async ({+export const loader = async ({params,-}): Promise<Pages | ErrorData> => {+}: LoaderArgs): Promise<Pages | ErrorData> => {try {if (params.projectId === undefined) {throw new Error(`Project ID required`);diff --git a/apps/designer/app/routes/rest/patch.ts b/apps/designer/app/routes/rest/patch.tsindex 930e8f110f..e9a8d44cf1 100644--- a/apps/designer/app/routes/rest/patch.ts+++ b/apps/designer/app/routes/rest/patch.ts@@ -1,5 +1,5 @@-import { type ActionFunction } from "@remix-run/node";-import { type Build } from "@webstudio-is/project";+import type { ActionArgs } from "@remix-run/node";+import type { Build } from "@webstudio-is/project";import { db as projectDb } from "@webstudio-is/project/server";import { db as designTokensDb } from "@webstudio-is/design-tokens/server";import { type SyncItem } from "immerhin";@@ -11,7 +11,7 @@ type PatchData = {buildId: Build["id"];};-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {const { treeId, buildId, transactions }: PatchData = await request.json();if (treeId === undefined) {return { errors: "Tree id required" };diff --git a/apps/designer/app/routes/rest/project.$projectId.tsx b/apps/designer/app/routes/rest/project.$projectId.tsxindex fc2f06bbfd..a3dc520492 100644--- a/apps/designer/app/routes/rest/project.$projectId.tsx+++ b/apps/designer/app/routes/rest/project.$projectId.tsx@@ -1,4 +1,4 @@-import { LoaderFunction, json } from "@remix-run/node";+import { json, type LoaderArgs } from "@remix-run/node";import env from "~/env.server";import { db } from "@webstudio-is/project/server";import { sentryException } from "~/shared/sentry";@@ -7,7 +7,7 @@ import type { CanvasData } from "@webstudio-is/project";type PagesDetails = Array<CanvasData | undefined>;-export const loader: LoaderFunction = async ({ request, params }) => {+export const loader = async ({ params }: LoaderArgs) => {try {const projectId = params.projectId ?? undefined;const pages: PagesDetails = [];diff --git a/apps/designer/app/routes/rest/project/clone.$domain.ts b/apps/designer/app/routes/rest/project/clone.$domain.tsindex 34274ce5cf..38857daba3 100644--- a/apps/designer/app/routes/rest/project/clone.$domain.ts+++ b/apps/designer/app/routes/rest/project/clone.$domain.ts@@ -1,4 +1,4 @@-import { type LoaderFunction, redirect } from "@remix-run/node";+import { redirect, type LoaderArgs } from "@remix-run/node";import type { User } from "@webstudio-is/prisma-client";import { db as projectDb } from "@webstudio-is/project/server";import { type Project } from "@webstudio-is/project";@@ -30,7 +30,7 @@ const ensureProject = async ({* 2. Clone the project by domain if user doesn't have any projects yet* 3. Redirect user to the designer with the cloned project*/-export const loader: LoaderFunction = async ({ request, params }) => {+export const loader = async ({ request, params }: LoaderArgs) => {if (params.domain === undefined) {return { errors: "Domain required" };}diff --git a/apps/designer/app/routes/rest/props.$projectId.ts b/apps/designer/app/routes/rest/props.$projectId.tsindex 1eee527dfd..908287c19c 100644--- a/apps/designer/app/routes/rest/props.$projectId.ts+++ b/apps/designer/app/routes/rest/props.$projectId.ts@@ -1,5 +1,5 @@-import { type LoaderFunction } from "@remix-run/node";-import { type InstanceProps } from "@webstudio-is/react-sdk";+import type { LoaderArgs } from "@remix-run/node";+import type { InstanceProps } from "@webstudio-is/react-sdk";import { db } from "@webstudio-is/project/server";import { utils } from "@webstudio-is/project";@@ -7,9 +7,9 @@ type ErrorData = {errors: string;};-export const loader: LoaderFunction = async ({+export const loader = async ({params,-}): Promise<Array<InstanceProps> | ErrorData> => {+}: LoaderArgs): Promise<Array<InstanceProps> | ErrorData> => {try {if (params.projectId === undefined) {throw new Error(`Project ID required`);diff --git a/apps/designer/app/routes/rest/publish.ts b/apps/designer/app/routes/rest/publish.tsindex e376c5823b..75c4c5b5cf 100644--- a/apps/designer/app/routes/rest/publish.ts+++ b/apps/designer/app/routes/rest/publish.ts@@ -1,4 +1,4 @@-import { type ActionFunction } from "@remix-run/node";+import type { ActionArgs } from "@remix-run/node";import { zfd } from "zod-form-data";import * as db from "~/shared/db";@@ -7,7 +7,7 @@ const schema = zfd.formData({projectId: zfd.text(),});-export const action: ActionFunction = async ({ request }) => {+export const action = async ({ request }: ActionArgs) => {const { domain, projectId } = schema.parse(await request.formData());try {await db.misc.publish({ projectId, domain });diff --git a/apps/designer/app/routes/rest/theme.$setting.ts b/apps/designer/app/routes/rest/theme.$setting.tsindex eae98b218b..3ad5b0dfdd 100644--- a/apps/designer/app/routes/rest/theme.$setting.ts+++ b/apps/designer/app/routes/rest/theme.$setting.ts@@ -1,7 +1,7 @@-import { json, type LoaderFunction } from "@remix-run/node";+import { json, type LoaderArgs } from "@remix-run/node";import { themeCookieParser } from "~/shared/theme";-export const loader: LoaderFunction = async ({ params }) => {+export const loader = async ({ params }: LoaderArgs) => {const { setting } = params;const headers = {"Set-Cookie": await themeCookieParser.serialize(setting),diff --git a/apps/designer/app/routes/rest/tree.$projectId.ts b/apps/designer/app/routes/rest/tree.$projectId.tsindex 6f7074be46..6af48e597b 100644--- a/apps/designer/app/routes/rest/tree.$projectId.ts+++ b/apps/designer/app/routes/rest/tree.$projectId.ts@@ -1,4 +1,4 @@-import { type LoaderFunction } from "@remix-run/node";+import type { LoaderArgs } from "@remix-run/node";import type { Tree } from "@webstudio-is/react-sdk";import { db } from "@webstudio-is/project/server";import { utils } from "@webstudio-is/project";@@ -7,9 +7,9 @@ export type ErrorData = {errors: string;};-export const loader: LoaderFunction = async ({+export const loader = async ({params,-}): Promise<Tree | null | ErrorData> => {+}: LoaderArgs): Promise<Tree | null | ErrorData> => {try {if (params.projectId === undefined) {throw new Error(`Project ID required`);diff --git a/apps/designer/app/routes/s/css.ts b/apps/designer/app/routes/s/css.tsindex 6b6a42bf44..3b52bb0ce8 100644--- a/apps/designer/app/routes/s/css.ts+++ b/apps/designer/app/routes/s/css.ts@@ -1,11 +1,11 @@-import { ActionFunction, json } from "@remix-run/node";+import { type ActionArgs, json } from "@remix-run/node";import { getBuildParams } from "~/shared/router-utils";import env from "~/env.server";import { sentryException } from "~/shared/sentry";import { generateCssText } from "~/shared/css-utils";-export const loader: ActionFunction = async ({ request }) => {+export const loader = async ({ request }: ActionArgs) => {try {const buildParams = getBuildParams(request);