From 7e39e7dbf0ebdf674dbee10f3a1b194637c980b0 Mon Sep 17 00:00:00 2001 From: Rizky Date: Thu, 18 Jan 2024 14:56:42 +0800 Subject: [PATCH] wip fix --- app/web/src/base/load/api/api-proxy.tsx | 21 ++++++++++++------- .../src/nova/ed/panel/popup/api/api-utils.ts | 11 +++++----- .../src/nova/vi/render/script/eval-script.tsx | 3 +++ 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/web/src/base/load/api/api-proxy.tsx b/app/web/src/base/load/api/api-proxy.tsx index 9d8dd09c..e8ec16c6 100644 --- a/app/web/src/base/load/api/api-proxy.tsx +++ b/app/web/src/base/load/api/api-proxy.tsx @@ -30,26 +30,31 @@ export const apiProxy = (api_url: string) => { ) { return new Promise(async (resolve, reject) => { try { - let api_def = w.prasiApi[base_url]; + let api_ref = w.prasiApi[base_url]; - if (!api_def) { + if ( + !api_ref && + apiProxyLoaded && + typeof apiProxyLoaded[base_url] === "object" + ) { await apiProxyLoaded[base_url]; + api_ref = w.prasiApi[base_url]; } - if (api_def) { - if (!api_def.apiEntry) api_def.apiEntry = {}; - if (api_def.apiEntry && !api_def.apiEntry[actionName]) { + if (api_ref) { + if (!api_ref.apiEntry) api_ref.apiEntry = {}; + if (api_ref.apiEntry && !api_ref.apiEntry[actionName]) { reject( `API ${actionName.toString()} not found, existing API: \n - ${Object.keys( - api_def || {} + api_ref || {} ).join("\n - ")}` ); return; } } - let actionUrl = api_def.apiEntry[actionName].url; - const actionParams = api_def.apiEntry[actionName].args; + let actionUrl = api_ref.apiEntry[actionName].url; + const actionParams = api_ref.apiEntry[actionName].args; if (actionUrl && actionParams) { if (rest.length > 0 && actionParams.length > 0) { for (const [idx, p] of Object.entries(rest)) { diff --git a/app/web/src/nova/ed/panel/popup/api/api-utils.ts b/app/web/src/nova/ed/panel/popup/api/api-utils.ts index 3f02ff67..62d9eb9e 100644 --- a/app/web/src/nova/ed/panel/popup/api/api-utils.ts +++ b/app/web/src/nova/ed/panel/popup/api/api-utils.ts @@ -1,7 +1,9 @@ -import { loadApiProxyDef } from "../../../../../base/load/api/api-proxy-def"; +import { apiProxy } from "../../../../../base/load/api/api-proxy"; import { w } from "../../../../../utils/types/general"; import { PG } from "../../../logic/ed-global"; +export const apiRef = {} as Record; + export const dev = JSON.parse(localStorage.getItem("prasi-dev") || "{}") as { enabled: boolean; url: string; @@ -49,10 +51,9 @@ export const checkAPI = async (p: PG) => { if (!url) return "offline"; try { - if (!w.prasiApi[url]) { - await loadApiProxyDef(url, true); - } - const capi = w.prasiApi[url] as any; + if (!apiRef[url]) apiRef[url] = apiProxy(url) as any; + + const capi = apiRef[url]; if (!capi) { console.error(`Cannot initialize API for ${url}.`, w.prasiApi[url]); } else { diff --git a/app/web/src/nova/vi/render/script/eval-script.tsx b/app/web/src/nova/vi/render/script/eval-script.tsx index db7a837a..87b801f6 100644 --- a/app/web/src/nova/vi/render/script/eval-script.tsx +++ b/app/web/src/nova/vi/render/script/eval-script.tsx @@ -97,6 +97,9 @@ export const replacement = { "stroke-width": "strokeWidth", "fill-rule": "fillRule", "clip-rule": "clipRule", + "stroke-linejoin": "strokeLinejoin", + "stroke-linecap": "strokeLinecap", + "clip-path": "clipPath", }; export const replaceWithObject = (tpl: string, data: any) => {