From 0e266bf8a62d0183709a75e94da8199d52d3ec9f Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 15 Sep 2022 12:29:48 +0200 Subject: [PATCH 1/2] fix project package imports --- .../designer/app/designer/features/breakpoints/breakpoints.tsx | 2 +- .../designer/features/breakpoints/use-subscribe-breakpoints.ts | 2 +- .../designer/features/breakpoints/use-subscribe-shortcuts.ts | 2 +- .../app/designer/features/breakpoints/width-setting.tsx | 2 +- apps/designer/app/routes/dashboard/index.tsx | 2 +- apps/designer/app/routes/designer/$id.tsx | 2 +- apps/designer/app/routes/index.tsx | 2 +- apps/designer/app/routes/rest/breakpoints.$projectId.ts | 2 +- apps/designer/app/routes/rest/pages.$projectId.ts | 2 +- apps/designer/app/routes/rest/patch.ts | 2 +- apps/designer/app/routes/rest/project/clone.$domain.ts | 3 ++- apps/designer/app/routes/rest/props.$projectId.ts | 2 +- apps/designer/app/routes/rest/tree.$projectId.ts | 2 +- apps/designer/app/shared/db/canvas.server.ts | 2 +- apps/designer/app/shared/db/misc.server.ts | 2 +- packages/project/src/db/project.ts | 2 +- 16 files changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx index 99437785bc..e5201a0ec9 100644 --- a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx +++ b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx @@ -25,7 +25,7 @@ import { } from "./use-subscribe-shortcuts"; import { ConfirmationDialog } from "./confirmation-dialog"; import { useBreakpoints } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project"; +import { utils } from "@webstudio-is/project/index.server"; declare module "~/shared/pubsub" { export interface PubsubMap { diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts index e989d856ef..d4349cb38c 100644 --- a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts +++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts @@ -2,7 +2,7 @@ import { useEffect } from "react"; import { useSubscribe } from "~/shared/pubsub"; import { useSelectedBreakpoint } from "~/designer/shared/nano-states"; import { useBreakpoints } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project"; +import { utils } from "@webstudio-is/project/index.server"; export const useSubscribeBreakpoints = () => { const [breakpoints, setBreakpoints] = useBreakpoints(); const [selectedBreakpoint, setSelectedBreakpoint] = useSelectedBreakpoint(); diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts index 8849e6a5ad..5c7c7c9a82 100644 --- a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts +++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts @@ -2,7 +2,7 @@ import { useSubscribe } from "~/shared/pubsub"; import { useBreakpoints } from "~/shared/nano-states"; import { useZoom, useSelectedBreakpoint } from "../../shared/nano-states"; import { minZoom } from "./zoom-setting"; -import { utils } from "@webstudio-is/project"; +import { utils } from "@webstudio-is/project/index.server"; export const useSubscribeSelectBreakpointFromShortcut = () => { const [breakpoints] = useBreakpoints(); diff --git a/apps/designer/app/designer/features/breakpoints/width-setting.tsx b/apps/designer/app/designer/features/breakpoints/width-setting.tsx index 4d69bab986..fbdc194126 100644 --- a/apps/designer/app/designer/features/breakpoints/width-setting.tsx +++ b/apps/designer/app/designer/features/breakpoints/width-setting.tsx @@ -5,7 +5,7 @@ import { } from "~/designer/shared/nano-states"; import { __DEPRECATED__Text, Flex, Slider } from "@webstudio-is/design-system"; import { useBreakpoints, useIsPreviewMode } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project"; +import { utils } from "@webstudio-is/project/index.server"; // Doesn't make sense to allow resizing the canvas lower/higher than this. export const minWidth = 50; diff --git a/apps/designer/app/routes/dashboard/index.tsx b/apps/designer/app/routes/dashboard/index.tsx index 4cd69bafc3..65bd2c066e 100644 --- a/apps/designer/app/routes/dashboard/index.tsx +++ b/apps/designer/app/routes/dashboard/index.tsx @@ -6,7 +6,7 @@ import { redirect, } from "@remix-run/node"; import { Dashboard, links } from "~/dashboard"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; import config, { type Config } from "~/config"; import { ensureUserCookie } from "~/shared/session"; import { authenticator } from "~/services/auth.server"; diff --git a/apps/designer/app/routes/designer/$id.tsx b/apps/designer/app/routes/designer/$id.tsx index d9ec4d91c8..5c28bb95fa 100644 --- a/apps/designer/app/routes/designer/$id.tsx +++ b/apps/designer/app/routes/designer/$id.tsx @@ -1,7 +1,7 @@ import { useLoaderData } from "@remix-run/react"; import { LoaderFunction } from "@remix-run/node"; import { Designer, links } from "~/designer"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; import type { Project } from "@webstudio-is/project"; import config from "~/config"; import env from "~/env.server"; diff --git a/apps/designer/app/routes/index.tsx b/apps/designer/app/routes/index.tsx index 7b0e662eee..2374667e69 100644 --- a/apps/designer/app/routes/index.tsx +++ b/apps/designer/app/routes/index.tsx @@ -2,7 +2,7 @@ import { type LoaderFunction, redirect } from "@remix-run/node"; import { useLoaderData } from "@remix-run/react"; import { type Data, InstanceRoot, Root } from "@webstudio-is/react-sdk"; import config from "~/config"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; import env, { Env } from "~/env.server"; // @todo all this subdomain logic is very hacky diff --git a/apps/designer/app/routes/rest/breakpoints.$projectId.ts b/apps/designer/app/routes/rest/breakpoints.$projectId.ts index 5074f48411..9fbef0acfc 100644 --- a/apps/designer/app/routes/rest/breakpoints.$projectId.ts +++ b/apps/designer/app/routes/rest/breakpoints.$projectId.ts @@ -1,6 +1,6 @@ import type { LoaderFunction } from "@remix-run/node"; import { Breakpoint } from "@webstudio-is/react-sdk"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; export type ErrorData = { errors: string; diff --git a/apps/designer/app/routes/rest/pages.$projectId.ts b/apps/designer/app/routes/rest/pages.$projectId.ts index 39dced94fe..4c3995df6a 100644 --- a/apps/designer/app/routes/rest/pages.$projectId.ts +++ b/apps/designer/app/routes/rest/pages.$projectId.ts @@ -1,6 +1,6 @@ import type { LoaderFunction } from "@remix-run/node"; import type { Breakpoint } from "@webstudio-is/react-sdk"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; export type ErrorData = { errors: string; diff --git a/apps/designer/app/routes/rest/patch.ts b/apps/designer/app/routes/rest/patch.ts index abc739d53b..d11b8acd59 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 { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; import { type SyncItem } from "immerhin"; import { type Tree } from "@webstudio-is/react-sdk"; import { type Project } from "@webstudio-is/prisma-client"; diff --git a/apps/designer/app/routes/rest/project/clone.$domain.ts b/apps/designer/app/routes/rest/project/clone.$domain.ts index ad77915d64..583d02a779 100644 --- a/apps/designer/app/routes/rest/project/clone.$domain.ts +++ b/apps/designer/app/routes/rest/project/clone.$domain.ts @@ -1,6 +1,7 @@ import { type LoaderFunction, redirect } from "@remix-run/node"; import type { User } from "@webstudio-is/prisma-client"; -import { db as projectDb, type Project } from "@webstudio-is/project"; +import { db as projectDb } from "@webstudio-is/project/index.server"; +import { type Project } from "@webstudio-is/project"; import * as userDb from "~/shared/db"; import { ensureUserCookie } from "~/shared/session"; import config from "~/config"; diff --git a/apps/designer/app/routes/rest/props.$projectId.ts b/apps/designer/app/routes/rest/props.$projectId.ts index 8422272748..75f7596919 100644 --- a/apps/designer/app/routes/rest/props.$projectId.ts +++ b/apps/designer/app/routes/rest/props.$projectId.ts @@ -1,6 +1,6 @@ import { type LoaderFunction } from "@remix-run/node"; import { type InstanceProps } from "@webstudio-is/react-sdk"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; type ErrorData = { errors: string; }; diff --git a/apps/designer/app/routes/rest/tree.$projectId.ts b/apps/designer/app/routes/rest/tree.$projectId.ts index 46da582ada..14dd94e2e0 100644 --- a/apps/designer/app/routes/rest/tree.$projectId.ts +++ b/apps/designer/app/routes/rest/tree.$projectId.ts @@ -1,6 +1,6 @@ import { type LoaderFunction } from "@remix-run/node"; import type { Tree } from "@webstudio-is/react-sdk"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; export type ErrorData = { errors: string; }; diff --git a/apps/designer/app/shared/db/canvas.server.ts b/apps/designer/app/shared/db/canvas.server.ts index 26db70052f..7c556c8c3c 100644 --- a/apps/designer/app/shared/db/canvas.server.ts +++ b/apps/designer/app/shared/db/canvas.server.ts @@ -1,5 +1,5 @@ import { type Data } from "@webstudio-is/react-sdk"; -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; import type { Project } from "@webstudio-is/project"; export type CanvasData = Data & { project: Project }; diff --git a/apps/designer/app/shared/db/misc.server.ts b/apps/designer/app/shared/db/misc.server.ts index 9238ec88ad..a149cd3959 100644 --- a/apps/designer/app/shared/db/misc.server.ts +++ b/apps/designer/app/shared/db/misc.server.ts @@ -1,4 +1,4 @@ -import { db } from "@webstudio-is/project"; +import { db } from "@webstudio-is/project/index.server"; /** * Conceptually publishing is cloning all data that affects user site diff --git a/packages/project/src/db/project.ts b/packages/project/src/db/project.ts index e67c58fc71..e95eef15f2 100644 --- a/packages/project/src/db/project.ts +++ b/packages/project/src/db/project.ts @@ -7,7 +7,7 @@ import { Prisma, Project as BaseProject, } from "@webstudio-is/prisma-client"; -import { formatAsset } from "@webstudio-is/asset-uploader"; +import { formatAsset } from "@webstudio-is/asset-uploader/index.server"; import * as db from "./index"; import type { Project } from "../index"; const TreeHistorySchema = z.array(z.string()); From 921387f78e47fe354b3b3a8c3998522e4f1ceb9a Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 15 Sep 2022 13:41:43 +0200 Subject: [PATCH 2/2] fix; imports/exports --- .../designer/app/designer/features/breakpoints/breakpoints.tsx | 2 +- .../designer/features/breakpoints/use-subscribe-breakpoints.ts | 2 +- .../designer/features/breakpoints/use-subscribe-shortcuts.ts | 2 +- .../app/designer/features/breakpoints/width-setting.tsx | 2 +- packages/project/index.server.ts | 2 +- packages/project/src/db/types.ts | 2 +- packages/project/src/index.server.ts | 2 ++ packages/project/src/index.ts | 3 --- 8 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 packages/project/src/index.server.ts diff --git a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx index e5201a0ec9..99437785bc 100644 --- a/apps/designer/app/designer/features/breakpoints/breakpoints.tsx +++ b/apps/designer/app/designer/features/breakpoints/breakpoints.tsx @@ -25,7 +25,7 @@ import { } from "./use-subscribe-shortcuts"; import { ConfirmationDialog } from "./confirmation-dialog"; import { useBreakpoints } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project/index.server"; +import { utils } from "@webstudio-is/project"; declare module "~/shared/pubsub" { export interface PubsubMap { diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts index d4349cb38c..e989d856ef 100644 --- a/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts +++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-breakpoints.ts @@ -2,7 +2,7 @@ import { useEffect } from "react"; import { useSubscribe } from "~/shared/pubsub"; import { useSelectedBreakpoint } from "~/designer/shared/nano-states"; import { useBreakpoints } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project/index.server"; +import { utils } from "@webstudio-is/project"; export const useSubscribeBreakpoints = () => { const [breakpoints, setBreakpoints] = useBreakpoints(); const [selectedBreakpoint, setSelectedBreakpoint] = useSelectedBreakpoint(); diff --git a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts index 5c7c7c9a82..8849e6a5ad 100644 --- a/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts +++ b/apps/designer/app/designer/features/breakpoints/use-subscribe-shortcuts.ts @@ -2,7 +2,7 @@ import { useSubscribe } from "~/shared/pubsub"; import { useBreakpoints } from "~/shared/nano-states"; import { useZoom, useSelectedBreakpoint } from "../../shared/nano-states"; import { minZoom } from "./zoom-setting"; -import { utils } from "@webstudio-is/project/index.server"; +import { utils } from "@webstudio-is/project"; export const useSubscribeSelectBreakpointFromShortcut = () => { const [breakpoints] = useBreakpoints(); diff --git a/apps/designer/app/designer/features/breakpoints/width-setting.tsx b/apps/designer/app/designer/features/breakpoints/width-setting.tsx index fbdc194126..4d69bab986 100644 --- a/apps/designer/app/designer/features/breakpoints/width-setting.tsx +++ b/apps/designer/app/designer/features/breakpoints/width-setting.tsx @@ -5,7 +5,7 @@ import { } from "~/designer/shared/nano-states"; import { __DEPRECATED__Text, Flex, Slider } from "@webstudio-is/design-system"; import { useBreakpoints, useIsPreviewMode } from "~/shared/nano-states"; -import { utils } from "@webstudio-is/project/index.server"; +import { utils } from "@webstudio-is/project"; // Doesn't make sense to allow resizing the canvas lower/higher than this. export const minWidth = 50; diff --git a/packages/project/index.server.ts b/packages/project/index.server.ts index e910bb060c..ad6dde9958 100644 --- a/packages/project/index.server.ts +++ b/packages/project/index.server.ts @@ -1 +1 @@ -export * from "./src/index"; +export * from "./src/index.server"; diff --git a/packages/project/src/db/types.ts b/packages/project/src/db/types.ts index 1dd7e6d83d..0ae05d8b90 100644 --- a/packages/project/src/db/types.ts +++ b/packages/project/src/db/types.ts @@ -1,5 +1,5 @@ import { z } from "zod"; -import { Project as BaseProject } from "@webstudio-is/prisma-client"; +import { type Project as BaseProject } from "@webstudio-is/prisma-client"; import type { Asset } from "@webstudio-is/asset-uploader"; const TreeHistorySchema = z.array(z.string()); diff --git a/packages/project/src/index.server.ts b/packages/project/src/index.server.ts new file mode 100644 index 0000000000..a89f5bdf70 --- /dev/null +++ b/packages/project/src/index.server.ts @@ -0,0 +1,2 @@ +import * as dbFunctions from "./db"; +export const db = dbFunctions; diff --git a/packages/project/src/index.ts b/packages/project/src/index.ts index 77721d7ddc..0f425bcc05 100644 --- a/packages/project/src/index.ts +++ b/packages/project/src/index.ts @@ -1,8 +1,5 @@ -import * as dbFunctions from "./db"; import * as breakpointsUtils from "./shared/breakpoints"; import * as treeUtils from "./shared/tree-utils"; export const utils = { breakpoints: breakpointsUtils, tree: treeUtils }; -export const db = dbFunctions; - export * from "./db/types";