wip upgrading pkgs

This commit is contained in:
Rizky 2023-12-23 17:17:37 +07:00
parent 7c8d772d3f
commit 2a711fca78
17 changed files with 91 additions and 50 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "db", "name": "db",
"dependencies": { "dependencies": {
"@prisma/client": "^5.6.0", "@prisma/client": "^5.7.1",
"prisma": "^5.6.0" "prisma": "^5.7.1"
} }
} }

View File

@ -4,7 +4,7 @@ generator client {
datasource db { datasource db {
provider = "postgresql" provider = "postgresql"
url = "postgresql://postgres:a5f64103e7ba098d@web.andromedia.co.id:5446/prasi?schema=public" url = env("DATABASE_URL")
} }
model billing_account { model billing_account {

View File

@ -6,16 +6,16 @@
"@hyrious/esbuild-plugin-style": "^0.3.5", "@hyrious/esbuild-plugin-style": "^0.3.5",
"@node-rs/argon2": "^1.5.2", "@node-rs/argon2": "^1.5.2",
"@paralleldrive/cuid2": "^2.2.2", "@paralleldrive/cuid2": "^2.2.2",
"@types/mime-types": "^2.1.2", "@types/mime-types": "^2.1.4",
"recast": "^0.23.4", "recast": "^0.23.4",
"esbuild": "^0.19.4", "esbuild": "^0.19.10",
"lmdb": "^2.8.5", "lmdb": "^2.9.2",
"mime-types": "^2.1.35", "mime-types": "^2.1.35",
"msgpackr": "^1.9.9", "msgpackr": "^1.10.0",
"radix3": "^1.1.0", "radix3": "^1.1.0",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"y-pojo": "^0.0.8", "y-pojo": "^0.0.8",
"yjs": "^13.6.8", "yjs": "^13.6.10",
"yjs-types": "^0.0.1" "yjs-types": "^0.0.1"
} }
} }

View File

@ -37,10 +37,12 @@ export const user = {
}, },
async getOrCreate(user_id: string) { async getOrCreate(user_id: string) {
let res = this.db.get(user_id); let res = this.db.get(user_id);
if (!res) { if (!res) {
await this.db.put(user_id, structuredClone(defaultConf)); await this.db.put(user_id, structuredClone(defaultConf));
res = this.db.get(user_id); res = this.db.get(user_id);
} }
return res as UserConf; return res as UserConf;
}, },
get(user_id: string) { get(user_id: string) {

View File

@ -47,8 +47,8 @@ export const syncHandler: WebSocketHandler<WSData> = {
const msg = packr.unpack(Buffer.from(raw)); const msg = packr.unpack(Buffer.from(raw));
if (msg.type === SyncType.UserID) { if (msg.type === SyncType.UserID) {
const { user_id, page_id, site_id } = msg; const { user_id, page_id, site_id } = msg;
conn.user_id = user_id; conn.user_id = user_id;
conn.user = await db.user.findFirst({ where: { id: user_id } }); conn.user = await db.user.findFirst({ where: { id: user_id } });
let conf = await user.conf.getOrCreate(user_id); let conf = await user.conf.getOrCreate(user_id);
if (site_id) { if (site_id) {
@ -57,7 +57,6 @@ export const syncHandler: WebSocketHandler<WSData> = {
} else if (!conf.site_id) { } else if (!conf.site_id) {
await loadDefaultSite(user_id); await loadDefaultSite(user_id);
} }
conn.conf = new Proxy(conf, { conn.conf = new Proxy(conf, {
get(_, p) { get(_, p) {
const conf = user.conf.get(user_id); const conf = user.conf.get(user_id);
@ -85,7 +84,6 @@ export const syncHandler: WebSocketHandler<WSData> = {
} }
if (baseAction) { if (baseAction) {
const action = baseAction.bind(conn); const action = baseAction.bind(conn);
sendWS(ws, { sendWS(ws, {
type: SyncType.ActionResult, type: SyncType.ActionResult,
argid: msg.argid, argid: msg.argid,

View File

@ -6,9 +6,9 @@
"maxParallelRequests": 20 "maxParallelRequests": 20
}, },
"dependencies": { "dependencies": {
"@babel/parser": "^7.23.0", "@babel/parser": "^7.23.6",
"@floating-ui/react": "^0.26.1", "@floating-ui/react": "^0.26.4",
"@leeoniya/ufuzzy": "^1.0.11", "@leeoniya/ufuzzy": "^1.0.14",
"@minoru/react-dnd-treeview": "^3.4.4", "@minoru/react-dnd-treeview": "^3.4.4",
"@monaco-editor/react": "^4.6.0", "@monaco-editor/react": "^4.6.0",
"@paralleldrive/cuid2": "2.2.2", "@paralleldrive/cuid2": "2.2.2",
@ -17,12 +17,13 @@
"@parcel/service-worker": "^2.10.3", "@parcel/service-worker": "^2.10.3",
"recast": "^0.23.4", "recast": "^0.23.4",
"@qiwi/deep-proxy": "^2.0.3", "@qiwi/deep-proxy": "^2.0.3",
"algoliasearch": "^4.20.0", "algoliasearch": "^4.22.0",
"date-fns": "^2.30.0", "date-fns": "^2.30.0",
"fast-safe-stringify": "^2.1.1",
"dbgen": "workspace:*", "dbgen": "workspace:*",
"downshift": "^8.2.2", "downshift": "^8.2.3",
"esbuild-wasm": "^0.19.5", "esbuild-wasm": "^0.19.10",
"hash-wasm": "^4.10.0", "hash-wasm": "^4.11.0",
"idb-keyval": "^6.2.1", "idb-keyval": "^6.2.1",
"immer": "^10.0.3", "immer": "^10.0.3",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
@ -42,9 +43,9 @@
"lodash.uniq": "^4.5.0", "lodash.uniq": "^4.5.0",
"lodash.uniqby": "^4.7.0", "lodash.uniqby": "^4.7.0",
"monaco-jsx-syntax-highlight-v2": "^1.2.2", "monaco-jsx-syntax-highlight-v2": "^1.2.2",
"msgpackr": "^1.9.9", "msgpackr": "^1.10.0",
"polywasm": "^0.1.4", "polywasm": "^0.1.4",
"prettier": "3.0.3", "prettier": "3.1.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"quill-delta": "^5.1.0", "quill-delta": "^5.1.0",
"radix3": "^1.1.0", "radix3": "^1.1.0",
@ -53,19 +54,18 @@
"react-dnd": "^16.0.1", "react-dnd": "^16.0.1",
"react-dom": "18.2.0", "react-dom": "18.2.0",
"react-is": "^18.2.0", "react-is": "^18.2.0",
"react-select": "^5.7.7",
"react-use-error-boundary": "^3.0.0", "react-use-error-boundary": "^3.0.0",
"react-virtuoso": "^4.6.2", "react-virtuoso": "^4.6.2",
"safe-stable-stringify": "^2.4.3", "safe-stable-stringify": "^2.4.3",
"svgo": "^3.0.2", "svgo": "^3.1.0",
"textdiff-create": "^1.1.10", "textdiff-create": "^1.1.10",
"tinycolor2": "^1.6.0", "tinycolor2": "^1.6.0",
"ua-parser-js": "^1.0.36", "ua-parser-js": "^1.0.37",
"uuid": "9.0.1", "uuid": "9.0.1",
"wasm-gzip": "^2.0.3", "wasm-gzip": "^2.0.3",
"web-utils": "workspace:*", "web-utils": "workspace:*",
"y-pojo": "^0.0.8", "y-pojo": "^0.0.8",
"yjs": "^13.6.8", "yjs": "^13.6.10",
"yjs-types": "^0.0.1" "yjs-types": "^0.0.1"
}, },
"devDependencies": { "devDependencies": {

View File

@ -20,8 +20,12 @@ const start = async () => {
const base_url = `${cur.protocol}//${cur.host}`; const base_url = `${cur.protocol}//${cur.host}`;
w.db = dbProxy(base_url); w.db = dbProxy(base_url);
try {
await loadApiProxyDef(base_url, false); await loadApiProxyDef(base_url, false);
w.api = apiProxy(base_url); w.api = apiProxy(base_url);
} catch (e) {
console.warn("Failed to load API:", base_url);
}
w.serverurl = base; w.serverurl = base;

View File

@ -3,7 +3,6 @@ import { ESite, PG } from "./ed-global";
import { reloadPage } from "./ed-route"; import { reloadPage } from "./ed-route";
export const loadSite = async (p: PG, site: ESite, note: string) => { export const loadSite = async (p: PG, site: ESite, note: string) => {
console.log("note", note);
const old_layout_id = p.site.layout.id; const old_layout_id = p.site.layout.id;
const layout_changed = p.site.layout.id !== site.layout.id; const layout_changed = p.site.layout.id !== site.layout.id;
p.site = site; p.site = site;

View File

@ -147,6 +147,7 @@ export const mainPerItemVisit = (
active.hover.renderTree(); active.hover.renderTree();
}; };
parts.props.onPointerDown = (e) => { parts.props.onPointerDown = (e) => {
console.log(p);
e.stopPropagation(); e.stopPropagation();
if ((meta.item as IContent).type === "text") { if ((meta.item as IContent).type === "text") {

View File

@ -1,23 +1,27 @@
import { IMeta, PG } from "../../../../logic/ed-global"; import { IMeta, PG } from "../../../../logic/ed-global";
export const extractExportImport = (p: PG, m: IMeta, imports: string[]) => { export const extractExportImport = (p: PG, m: IMeta, imports: string[]) => {
let _export = {}; const new_imports = [...imports];
const def = m.scope.def; const def = m.scope.def;
if (def) { if (def) {
let res: null | ReturnType<typeof extractLocal> = null;
if (def.local) { if (def.local) {
const local = extractLocal(p, m, def, imports); res = extractLocal(p, m, def, imports);
if (local) { } else if (def.passprop) {
for (const [k, v] of Object.entries(local)) { res = extractPassProp(p, m, def, imports);
} else if (def.props) {
res = extractProps(p, m, def, imports);
}
if (res) {
for (const [k, v] of Object.entries(res)) {
v.names.forEach((n) => v.names.forEach((n) =>
imports.push(`import { ${n} } from "./${k}";`) new_imports.push(`import { ${n} } from "./${k}";`)
); );
} }
} }
} }
}
return _export; return { imports: new_imports };
}; };
const extractLocal = ( const extractLocal = (

View File

@ -1,5 +1,5 @@
import { IMeta, PG, active } from "../../../../logic/ed-global"; import { IMeta, PG, active } from "../../../../logic/ed-global";
import { addScope } from "./add-scope"; import { extractExportImport } from "./extract-exim";
import { Monaco } from "./type"; import { Monaco } from "./type";
export const defineScopeParent = (p: PG, meta: IMeta, monaco: Monaco) => { export const defineScopeParent = (p: PG, meta: IMeta, monaco: Monaco) => {
@ -18,7 +18,12 @@ export const defineScopeParent = (p: PG, meta: IMeta, monaco: Monaco) => {
} }
} }
let i = 0;
let next_parent = parents[i + 1];
const imports = {} as Record<string, any>;
for (const m of parents) { for (const m of parents) {
next_parent = parents[i + 1];
if (active.comp_id && m.parent?.id === "root" && active.instance) { if (active.comp_id && m.parent?.id === "root" && active.instance) {
const meta = p.page.meta[active.instance.item_id]; const meta = p.page.meta[active.instance.item_id];
if (meta) { if (meta) {
@ -29,10 +34,12 @@ export const defineScopeParent = (p: PG, meta: IMeta, monaco: Monaco) => {
const def = m.scope.def; const def = m.scope.def;
if (def) { if (def) {
if (def.local) { if (!imports[m.item.id]) imports[m.item.id] = [];
} else if (def.passprop) { const res = extractExportImport(p, m, imports[m.item.id]);
} else if (def.props) { if (next_parent) {
imports[next_parent.item.id] = res.imports;
} }
} }
i++;
} }
}; };

View File

@ -36,7 +36,7 @@ export const EdTreeSearch = () => {
> >
<div className="flex items-stretch h-[24px] "> <div className="flex items-stretch h-[24px] ">
<input <input
name="search" name="search-tree"
ref={(ref) => { ref={(ref) => {
local.sref = ref; local.sref = ref;
}} }}
@ -117,7 +117,7 @@ export const doTreeSearch = (p: PG) => {
let i = 0; let i = 0;
let ptree = p.page.tree; let ptree = p.page.tree;
if (active.comp_id && p.comp.list[active.comp_id].tree) { if (active.comp_id && p.comp.list[active.comp_id]?.tree) {
ptree = p.comp.list[active.comp_id].tree; ptree = p.comp.list[active.comp_id].tree;
} }

View File

@ -39,7 +39,13 @@ export const viLoadLegacy = async (vi: {
let api_url = vi.site.api_url; let api_url = vi.site.api_url;
if (!api_url) api_url = ((site.config as any) || {}).api_url || ""; if (!api_url) api_url = ((site.config as any) || {}).api_url || "";
if (api_url) {
try {
await loadApiProxyDef(api_url, true); await loadApiProxyDef(api_url, true);
} catch (e) {
console.warn("Failed to load API:", api_url);
}
}
const path = `/npm/site/${vi.site.id}/site.js`; const path = `/npm/site/${vi.site.id}/site.js`;
await importModule(path); await importModule(path);

View File

@ -2,7 +2,12 @@
"compilerOptions": { "compilerOptions": {
"target": "ESNext", "target": "ESNext",
"useDefineForClassFields": true, "useDefineForClassFields": true,
"lib": ["WebWorker", "DOM", "DOM.Iterable", "ESNext"], "lib": [
"WebWorker",
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": false, "allowJs": false,
"skipLibCheck": false, "skipLibCheck": false,
"esModuleInterop": false, "esModuleInterop": false,
@ -16,7 +21,12 @@
// "noEmit": true, // "noEmit": true,
"jsx": "react-jsx", "jsx": "react-jsx",
"paths": { "paths": {
"dbgen": ["../../node_modules/.prisma/client/index.d.ts"], "dbgen": [
} "../../node_modules/.prisma/client/index.d.ts"
],
},
"types": [
"bun-types" // add Bun global
],
} }
} }

BIN
bun.lockb

Binary file not shown.

View File

@ -27,6 +27,7 @@
"dependencies": { "dependencies": {
"brotli-wasm": "^2.0.1", "brotli-wasm": "^2.0.1",
"fdir": "^6.1.0", "fdir": "^6.1.0",
"react-select": "^5.8.0",
"typescript": "^5.2.2" "typescript": "^5.2.2"
} }
} }

View File

@ -0,0 +1,9 @@
const w = (typeof window !== "undefined" ? window : {}) as unknown as {
globalValueID?: WeakMap<any, string>;
};
export const hydrateGlobal = (
global_ref: any,
key: string,
initial_data: any
) => {};