diff --git a/app/db/prisma/schema.prisma b/app/db/prisma/schema.prisma index c4384a69..35102d4e 100644 --- a/app/db/prisma/schema.prisma +++ b/app/db/prisma/schema.prisma @@ -36,7 +36,6 @@ model component_group { id String @id(map: "site_comp_group_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid name String shared Boolean @default(false) - code_comp code_comp[] component component[] component_site component_site[] } @@ -224,7 +223,6 @@ model site { is_deleted Boolean @default(false) responsive String @default("all") npm_cache String @default(" ") @db.VarChar - code code[] component_site component_site[] npm_site npm_site[] page page[] @@ -277,43 +275,3 @@ model user { org_user org_user[] site site[] } - -model code { - id String @id(map: "code_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid - name String @db.Uuid - id_site String @db.Uuid - use_in_site Boolean - site site @relation(fields: [id_site], references: [id], onDelete: NoAction, onUpdate: NoAction) - code_comp code_comp[] - code_file code_file[] - code_npm code_npm[] -} - -model code_comp { - id_code String @db.Uuid - id_comp_group String @db.Uuid - code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction) - component_group component_group @relation(fields: [id_comp_group], references: [id], onDelete: NoAction, onUpdate: NoAction) - - @@id([id_code, id_comp_group], map: "code_comp_id_code_id_comp_group") -} - -model code_npm { - id String @id(map: "code_npm_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid - module String - version String - bundled Boolean - import_as Json @default("{\"main\": {\"mode\": \"default\", \"name\": \"\"}, \"names\": []}") - id_code String @db.Uuid - code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction) -} - -/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments -model code_file { - id String @id(map: "code_src_id") @default(dbgenerated("gen_random_uuid()")) @db.Uuid - name String - src String - id_code String @db.Uuid - type String @default("f") @db.Char(1) - code code @relation(fields: [id_code], references: [id], onDelete: NoAction, onUpdate: NoAction, map: "code_src_id_code_fkey") -} diff --git a/app/web/src/render/ed/ed-base.tsx b/app/web/src/render/ed/ed-base.tsx index b2e38ad7..c011204e 100644 --- a/app/web/src/render/ed/ed-base.tsx +++ b/app/web/src/render/ed/ed-base.tsx @@ -11,6 +11,7 @@ import { EdPopCompGroup } from "./panel/popup/comp/comp-group"; import { EdPopSite } from "./panel/popup/site/site"; import { EdScriptInit } from "./panel/script/monaco/init"; import { EdRight } from "./ed-right"; +import { EdPopCode } from "./panel/popup/code/code"; export const EdBase = () => { const p = useGlobal(EDGlobal, "EDITOR"); @@ -45,6 +46,7 @@ export const EdBase = () => { <> + diff --git a/app/web/src/render/ed/logic/ed-global.ts b/app/web/src/render/ed/logic/ed-global.ts index c76a57cb..eafe06b9 100644 --- a/app/web/src/render/ed/logic/ed-global.ts +++ b/app/web/src/render/ed/logic/ed-global.ts @@ -93,9 +93,6 @@ export const EDGlobal = { list: {} as Record, group: {} as Record>>, }, - code: { - doc: null as null | DCode, - }, ui: { layout: { left: parseInt(localStorage.getItem("prasi-layout-left") || "250"), diff --git a/app/web/src/render/ed/panel/popup/code/code.tsx b/app/web/src/render/ed/panel/popup/code/code.tsx index 7919478b..563702fa 100644 --- a/app/web/src/render/ed/panel/popup/code/code.tsx +++ b/app/web/src/render/ed/panel/popup/code/code.tsx @@ -1,12 +1,42 @@ import { useGlobal } from "web-utils"; import { EDGlobal } from "../../../logic/ed-global"; +import { Modal } from "../../../../../utils/ui/modal"; export const EdPopCode = () => { const p = useGlobal(EDGlobal, "EDITOR"); - if (!p.ui.popup.code) { - return null; - } - - return <>; + return ( + { + if (!open) { + p.ui.popup.code.open = false; + p.render(); + } + }} + > +
+
+
+
`, + }} + >
+
Site
+
+
+ +
+
+ ); }; diff --git a/app/web/src/render/ed/panel/script/site.tsx b/app/web/src/render/ed/panel/script/site.tsx deleted file mode 100644 index 638b2cff..00000000 --- a/app/web/src/render/ed/panel/script/site.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { compress } from "wasm-gzip"; -import { useGlobal, useLocal } from "web-utils"; -import { jscript } from "../../../../utils/script/jscript"; -import { EDGlobal } from "../../logic/ed-global"; -import { EdUserConn } from "../activity/user-conn"; -import { EdMonaco } from "./monaco/monaco"; - -export const EdScriptSite = () => { - const p = useGlobal(EDGlobal, "EDITOR"); - const local = useLocal({ timeout: null as any }); - const userOpened = Object.keys(p.activity.page.site?.js || {}); - - // if (!p.ui.script.site) { - // return null; - // } - - return ( - 1 ? ( -
- WARNING: - e !== p.user.client_id)} - /> - also open this script. Editing may cause conflicts. -
- ) : undefined - } - monaco={{ - value: p.site.js, - onChange: async (v) => { - if (jscript.build) { - const src = v || ""; - const built = await jscript.build("site.tsx", src); - - p.site.js = src; - p.site.js_compiled = built; - - clearTimeout(local.timeout); - local.timeout = setTimeout(async () => { - await p.sync.site.update(p.site.id, { - js: Buffer.from(compress(src)), - js_compiled: Buffer.from(compress(built)), - }); - }, 1000); - } - }, - }} - prop={{ - types: { - exports: "any", - types: "any", - render: "()=>void", - }, - }} - onClose={() => { - // p.ui.script.site = false; - // p.sync.activity( - // { page_id: p.page.cur.id, item_id: "site" }, - // "js", - // Activity.Null - // ); - // p.render(); - }} - /> - ); -}; diff --git a/app/web/src/render/site/site.tsx b/app/web/src/render/site/site.tsx index 81328845..476495e4 100644 --- a/app/web/src/render/site/site.tsx +++ b/app/web/src/render/site/site.tsx @@ -1,8 +1,13 @@ +import structuredClone from "@ungap/structured-clone"; import { FC, useState } from "react"; import { createRoot } from "react-dom/client"; import { GlobalContext, defineReact, defineWindow } from "web-utils"; import { siteLoader } from "./site-loader"; +if (!("structuredClone" in (window as any))) { + (window as any).structuredClone = structuredClone; +} + const w = window as unknown as { prasiContext: any; rootRender: any; diff --git a/bun.lockb b/bun.lockb index 91ef701c..edc0dbec 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index c51020f3..8c9790fa 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,8 @@ "typescript": "^5.0.0" }, "dependencies": { + "@types/ungap__structured-clone": "^0.3.1", + "@ungap/structured-clone": "^1.2.0", "brotli-wasm": "^2.0.1", "fdir": "^6.1.0" }