An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Improve database automation rule management https://github.com/siyuan-note/siyuan/issues/20643
Danielbf0ec10fce84
diff --git a/app/src/protyle/render/av/automation.test.ts b/app/src/protyle/render/av/automation.test.tsindex a51c7e21f5..f7823057bf 100644--- a/app/src/protyle/render/av/automation.test.ts+++ b/app/src/protyle/render/av/automation.test.ts@@ -134,7 +134,9 @@ test("empty automation settings persist an incomplete rule disabled on editing aconst listeners = new Map<string, (event: unknown) => void>();const transactions: Array<{perform: IOperation[], undo: IOperation[]}> = [];const status = {textContent: "", classList: {toggle() {}}};- const select = {selectedOptions: [{textContent: ""}]};+ const select = {textContent: ""};+ let renameRule: (id: string, name: string) => void;+ let removeRule: (id: string) => void;const enabled = {checked: false};const list = {innerHTML: "", querySelectorAll: (): HTMLElement[] => []};const conditions = {innerHTML: "", querySelector: (selector: string) => selector === "[data-conditions]" ? list : {addEventListener() {}}};@@ -142,7 +144,7 @@ test("empty automation settings persist an incomplete rule disabled on editing aaddEventListener: (type: string, listener: (event: unknown) => void) => listeners.set(type, listener),querySelectorAll: (): HTMLElement[] => [],querySelector: (selector: string) => ({"[data-source-conditions]": conditions, "[data-status]": status,- "[data-rule]": select, "[data-enabled]": enabled})[selector] || list};+ "[data-rule-name]": select, "[data-enabled]": enabled})[selector] || list};const panel = {isConnected: true, addEventListener() {}, querySelector: (selector: string) => selector === "[data-body]" ? body : {addEventListener: (_type: string, listener: (event: unknown) => void) => listeners.set(selector, listener),}};@@ -156,6 +158,8 @@ test("empty automation settings persist an incomplete rule disabled on editing aLute: {NewNodeID: () => "draft-rule"},window: {siyuan: {config: {}, languages: {databaseAutomations: "Automations", fields: "Fields", automationIncomplete: "Incomplete: ${1}"}}},require: (name: string) => name === "./capabilities" || name === "../capabilities" ? capabilities : (({+ "./automationRules": {openAutomationRules: (_target: HTMLElement, _rules: unknown, _current: string,+ _select: unknown, rename: typeof renameRule, remove: typeof removeRule) => { renameRule = rename; removeRule = remove; }},"./automationTemplate": {automationTimeZone: () => "UTC"},"../../../util/escape": {escapeAttr: String, escapeHtml: String},"../../../util/fetch": {fetchSyncPost: async () => ({code: 0, data: {av: database}})},@@ -167,15 +171,14 @@ test("empty automation settings persist an incomplete rule disabled on editing aawait methods.openAutomationMenu({protyle: {options: {}} as IProtyle,blockElement: {dataset: {nodeId: "carrier"}} as unknown as HTMLElement, avID: "source",menuElement: menu as unknown as HTMLElement, onResize() {}});- assert.match(body.innerHTML, /data-name/);+ assert.match(body.innerHTML, /data-action="rules"/);+ assert.doesNotMatch(body.innerHTML, /data-name/);assert.match(body.innerHTML, /data-trigger/);assert.match(list.innerHTML, /data-action="add-field"/);assert.equal(transactions.length, 0);assert.equal(database.automations.rules.length, 0);- const nameInput = {value: "Draft", matches: (selector: string) => selector === "[data-name]", closest: (): HTMLElement => null};- listeners.get("input")({target: nameInput});- assert.equal(transactions.length, 0);- listeners.get("blur")({target: nameInput});+ listeners.get("click")({target: {closest: () => ({dataset: {action: "rules"}, closest: (): HTMLElement => null})}});+ renameRule("draft-rule", "Draft");assert.equal(transactions.length, 1);const saved = JSON.parse(JSON.stringify(transactions[0].perform[0]));const undo = JSON.parse(JSON.stringify(transactions[0].undo[0]));@@ -188,16 +191,16 @@ test("empty automation settings persist an incomplete rule disabled on editing alisteners.get("change")({target: {checked: true, matches: (selector: string) => selector === "[data-enabled]", closest: (): HTMLElement => null}});assert.equal(transactions.length, 1);assert.equal(enabled.checked, false);- listeners.get("click")({target: {closest: () => ({dataset: {action: "remove-rule"}, closest: (): HTMLElement => null})}});+ removeRule("draft-rule");assert.equal(transactions.length, 2);assert.equal(JSON.parse(JSON.stringify(transactions[1].perform[0].data)).rules.length, 0);assert.deepEqual(transactions[1].undo[0].data, transactions[0].perform[0].data);await new Promise(resolve => setImmediate(resolve));- assert.match(body.innerHTML, /data-name/);+ assert.match(body.innerHTML, /data-action="rules"/);assert.match(body.innerHTML, /data-trigger/);assert.match(list.innerHTML, /data-action="add-field"/);assert.equal(transactions.length, 2);- listeners.get("click")({target: {closest: () => ({dataset: {action: "remove-rule"}, closest: (): HTMLElement => null})}});+ removeRule("draft-rule");assert.equal(transactions.length, 2);});diff --git a/app/src/protyle/render/av/automation.ts b/app/src/protyle/render/av/automation.tsindex b1d9fe6f75..c2c01715c5 100644--- a/app/src/protyle/render/av/automation.ts+++ b/app/src/protyle/render/av/automation.ts@@ -11,6 +11,7 @@ import {createAVLocationReplacement} from "./locationValue";import {openSearchAV} from "./relation";import {collectionSourceIncomplete, mountBlockCollectionSource, openBlockCollectionPreview} from "./blockCollection";import {automationTimeZone, mountAutomationTemplate} from "./automationTemplate";+import {openAutomationRules} from "./automationRules";interface AutomationValue extends Omit<AVAutomationValueInput, "value"> {value?: IAVCellValue;@@ -309,8 +310,8 @@ export const openAutomationMenu = async (options: {}const scrollTop = scrollElement.scrollTop;body.innerHTML = `<div class="ft__on-surface ft__smaller av__automation-tip">${lang.automationTip}</div>-<div class="av__automation-row">${rule ? `<label class="av__automation-control fn__flex-1"><span class="ft__on-surface av__automation-control-label">${lang.automationRule}</span><select class="b3-select av__automation-rule-select" data-rule>${rules.map((item, i) => optionHTML(String(i), item.name, String(index))).join("")}</select></label>` : ""}<div class="av__automation-row av__automation-tools">${iconButton("add-rule", "iconAdd", lang.new)}${rule ? iconButton("remove-rule", "iconTrashcan", lang.delete, true) : ""}</div></div>-${rule ? `<div class="av__automation-row"><label class="av__automation-control fn__flex-1"><span class="ft__on-surface av__automation-control-label">${lang.name}</span><input class="b3-text-field av__automation-rule-name" data-name value="${escapeAttr(rule.name)}"></label><label class="av__automation-row av__automation-enabled"><input type="checkbox" class="b3-switch ariaLabel" aria-label="${escapeAttr(lang.enable)}" data-position="north" data-enabled${rule.enabled ? " checked" : ""}></label></div>+<div class="av__automation-row">${rule ? `<button type="button" class="b3-button b3-button--cancel fn__flex-1 av__automation-source-action" data-action="rules" aria-label="${escapeAttr(lang.automationRule)}"><span class="fn__ellipsis" data-rule-name>${escapeHtml(rule.name)}</span><svg><use xlink:href="#iconDown"></use></svg></button><input type="checkbox" class="b3-switch ariaLabel" aria-label="${escapeAttr(lang.enable)}" data-position="north" data-enabled${rule.enabled ? " checked" : ""}>` : ""}${iconButton("add-rule", "iconAdd", lang.new)}</div>+${rule ? `<div class="ft__on-surface ft__smaller av__automation-tip">${lang.automationAutoSaveTip}</div><div class="ft__on-surface ft__smaller fn__none av__automation-status" role="status" data-status></div><section class="av__automation-section"><div class="av__automation-row ft__b"><span class="ft__on-surface av__automation-section-index">1</span><span class="av__automation-section-title">${lang.automationWhen}</span></div>@@ -389,36 +390,11 @@ ${iconButton("remove-field", "iconClose", lang.delete, true, true)}`;// 重建期间内容高度可能暂时变小,所有字段挂载并完成定位后再恢复滚动位置。scrollElement.scrollTop = scrollTop;};- body.addEventListener("input", event => {- if ((event.target as HTMLElement).matches("[data-name]")) {- rules[index].name = (event.target as HTMLInputElement).value;- body.querySelector<HTMLSelectElement>("[data-rule]").selectedOptions[0].textContent = rules[index].name;- }- });- body.addEventListener("blur", event => {- const target = event.target as HTMLInputElement;- if (target.matches("[data-name]")) {- rules[index].name = target.value.trim() || lang.databaseAutomations;- target.value = rules[index].name;- body.querySelector<HTMLSelectElement>("[data-rule]").selectedOptions[0].textContent = target.value;- save();- }- }, true);body.addEventListener("change", event => {const target = event.target as HTMLInputElement;const rule = rules[index];const action = rule?.actions[Number(target.closest<HTMLElement>("[data-index]")?.dataset.index)];- if (target.matches("[data-rule]")) {- index = Number(target.value);- void render();- return;- } else if (target.matches("[data-name]")) {- rule.name = target.value.trim() || lang.databaseAutomations;- target.value = rule.name;- body.querySelector<HTMLSelectElement>("[data-rule]").selectedOptions[0].textContent = rule.name;- save();- return;- } else if (target.matches("[data-enabled]")) {+ if (target.matches("[data-enabled]")) {rule.enabled = target.checked;save();const preview = body.querySelector<HTMLButtonElement>('[data-action="preview-collection"]');@@ -497,6 +473,24 @@ ${iconButton("remove-field", "iconClose", lang.delete, true, true)}`;const actionIndex = Number(target.closest<HTMLElement>("[data-index]")?.dataset.index);const action = rule?.actions[actionIndex];switch (target.dataset.action) {+ case "rules":+ openAutomationRules(target, rules, rule.id, id => {+ index = rules.findIndex(item => item.id === id);+ void render();+ }, (id, name) => {+ const renamed = rules.find(item => item.id === id);+ renamed.name = name;+ save(null);+ body.querySelector("[data-rule-name]").textContent = rules[index].name;+ }, id => {+ const currentID = rules[index].id;+ rules.splice(rules.findIndex(item => item.id === id), 1);+ index = Math.max(0, rules.findIndex(item => item.id === currentID));+ save(null);+ if (!rules.length) { rules.push(createRule()); }+ void render();+ });+ return;case "preview-collection":void openBlockCollectionPreview(protyle, avID, blockElement.dataset.nodeId, rule.id);return;@@ -504,16 +498,6 @@ ${iconButton("remove-field", "iconClose", lang.delete, true, true)}`;rules.push(createRule());index = rules.length - 1;break;- case "remove-rule":- rules.splice(index, 1);- index = Math.min(index, rules.length - 1);- save(null);- if (!rules.length) {- rules.push(createRule());- index = 0;- }- void render();- return;case "add-action":rule.actions.push({type: "edit", target: "current", fields: {}});break;diff --git a/app/src/protyle/render/av/automationRules.ts b/app/src/protyle/render/av/automationRules.tsnew file mode 100644index 0000000000..b6d1c41987--- /dev/null+++ b/app/src/protyle/render/av/automationRules.ts@@ -0,0 +1,96 @@+import {Menu} from "../../../plugin/Menu";+import {escapeAttr, escapeHtml} from "../../../util/escape";+import {isMobile} from "../../../util/functions";+import {toggleMenu} from "../../../menus/menuToggle";++interface RuleSummary {+ id: string;+ name: string;+ enabled: boolean;+}++export const openAutomationRules = (target: HTMLElement, rules: RuleSummary[], currentID: string,+ select: (id: string) => void, rename: (id: string, name: string) => void,+ remove: (id: string) => void) => {+ const lang = window.siyuan.languages;+ let menu: Menu;+ toggleMenu({target, build: () => {+ menu = new Menu();+ menu.addItem({type: "empty", label: `<div class="b3-menu__filter fn__flex-column">+<input class="b3-text-field" data-search placeholder="${escapeAttr(lang.searchPlaceholder)}" aria-label="${escapeAttr(lang.search)}">+<div class="fn__hr"></div><div class="b3-list b3-list--background fn__flex-1" data-rules></div></div>`, bind: element => {+ const search = element.querySelector<HTMLInputElement>("[data-search]");+ const list = element.querySelector<HTMLElement>("[data-rules]");+ const render = () => {+ const keyword = search.value.trim().toLowerCase();+ list.innerHTML = rules.filter(rule => rule.name.toLowerCase().includes(keyword)).map(rule =>+ `<div class="b3-list-item${isMobile() ? "" : " b3-list-item--hide-action"}${rule.id === currentID ? " b3-list-item--focus" : ""}" data-id="${escapeAttr(rule.id)}" tabindex="0">+<svg class="b3-list-item__graphic ariaLabel" aria-label="${escapeAttr(rule.enabled ? lang.enable : lang.disable)}"><use xlink:href="#${rule.enabled ? "iconPlay" : "iconPause"}"></use></svg>+<span class="b3-list-item__text ariaLabel" aria-label="${escapeAttr(rule.name)}">${escapeHtml(rule.name)}</span>+<span class="b3-list-item__action ariaLabel" data-rename role="button" tabindex="0" aria-label="${escapeAttr(lang.rename)}"><svg><use xlink:href="#iconEdit"></use></svg></span>+<span class="b3-list-item__action ariaLabel" data-more role="button" tabindex="0" aria-label="${escapeAttr(lang.more)}"><svg><use xlink:href="#iconMore"></use></svg><div class="b3-menu__submenu"><div class="b3-menu__items"><button class="b3-menu__item b3-menu__item--warning" data-delete><svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg><span class="b3-menu__label">${lang.delete}</span></button></div></div></span>+${rule.id === currentID ? '<svg class="b3-menu__checked"><use xlink:href="#iconSelect"></use></svg>' : ""}</div>`).join("") || `<div class="b3-list--empty">${lang.emptyContent}</div>`;+ };+ search.addEventListener("input", render);+ element.addEventListener("click", event => {+ event.stopPropagation();+ const clicked = event.target as Element;+ const row = clicked.closest<HTMLElement>("[data-id]");+ if (!row || clicked.closest("input")) { return; }+ const id = row.dataset.id;+ if (clicked.closest("[data-delete]")) {+ remove(id);+ menu.close();+ } else if (clicked.closest("[data-more]")) {+ const submenu = row.querySelector<HTMLElement>(".b3-menu__submenu");+ const open = submenu.style.display !== "block";+ list.querySelectorAll<HTMLElement>(".b3-menu__submenu").forEach(item => item.style.display = "none");+ submenu.style.display = open ? "block" : "none";+ menu.showSubMenu(submenu);+ } else if (clicked.closest("[data-rename]")) {+ if (row.querySelector("input")) { return; }+ const rule = rules.find(item => item.id === id);+ const title = row.querySelector<HTMLElement>(".b3-list-item__text");+ const input = document.createElement("input");+ input.className = "b3-text-field b3-text-field--small fn__flex-1";+ input.value = rule.name;+ input.setAttribute("aria-label", lang.rename);+ title.replaceWith(input);+ let finished = false;+ const finish = (cancel = false) => {+ if (finished) { return; }+ finished = true;+ const name = input.value.trim() || rule.name;+ if (!cancel && name !== rule.name) { rename(id, name); }+ render();+ };+ input.addEventListener("blur", () => finish(), {once: true});+ input.addEventListener("keydown", event => {+ event.stopPropagation();+ if (event.isComposing) { return; }+ if (event.key === "Escape") { event.preventDefault(); finish(true); }+ if (event.key === "Enter") { event.preventDefault(); finish(); }+ });+ input.focus();+ input.select();+ } else {+ menu.close();+ select(id);+ }+ });+ element.addEventListener("keydown", event => {+ event.stopPropagation();+ if (event.isComposing || (event.target as Element).matches("input")) { return; }+ if (event.key === "Enter" || event.key === " ") {+ event.preventDefault();+ (event.target as HTMLElement).click();+ }+ });+ render();+ }});+ }, show: () => {+ const rect = target.getBoundingClientRect();+ menu.open({x: rect.left, y: rect.bottom, h: rect.height, target});+ if (!isMobile()) { menu.element.querySelector<HTMLInputElement>("[data-search]").focus(); }+ }});+};diff --git a/app/tests/automationPanel.test.js b/app/tests/automationPanel.test.jsindex b335fad2d9..c5389d6ab1 100644--- a/app/tests/automationPanel.test.js+++ b/app/tests/automationPanel.test.js@@ -42,7 +42,21 @@ const runCases = async (sources, css, mobile) => {window.siyuan = {languages: lang, config: {}, notebooks: [], zIndex: 0, menus: {menu: {remove() {}}}};const mocks = {"menus/menuToggle": {toggleMenu: options => {options.build(); options.show();}},- "plugin/Menu": {Menu: class {items = []; addItem(item) {this.items.push(item);} open() {fieldMenu = {items: this.items};}}},+ "plugin/Menu": {Menu: class {+ items = [];+ element = document.createElement("div");+ addItem(item) {+ this.items.push(item);+ if (item.bind) {+ this.element.innerHTML = item.label;+ item.bind(this.element);+ }+ }+ open() { this.element.className = "b3-menu"; document.body.append(this.element); fieldMenu = {items: this.items, element: this.element}; }+ close() { this.element.remove(); }+ showSubMenu() {}+ }},+ "util/functions": {isMobile: () => mobile},"util/fetch": {fetchSyncPost: async (url, request) => url.includes("previewAttributeViewTemplate") ?(templatePreviews.push(request), {code: 0, data: {type: "date", date: {content: 1792713600000, isNotEmpty: true, isNotTime: true}}}) : url.includes("getHPathByID") ? {code: 0, data: "/Tasks"} :{code: 0, data: {av: request.id === "source" ? database : targetDatabase}},@@ -93,23 +107,44 @@ const runCases = async (sources, css, mobile) => {assert.ok(sections[0].contains(get("[data-trigger]")));assert.ok(sections[1].contains(get("[data-source-conditions]")));assert.ok(sections[2].contains(get("[data-actions]")));- assert.equal(get("[data-rule]").labels[0].textContent.includes(lang.automationRule), true);- assert.equal(get("[data-enabled]").labels[0].textContent.trim(), "");+ assert.equal(get('[data-action="rules"]').getAttribute("aria-label"), lang.automationRule);assert.equal(get("[data-enabled]").getAttribute("aria-label"), lang.enable);assert.ok(get("[data-enabled]").classList.contains("ariaLabel"), "the enable switch exposes its label as a tooltip");assert.equal(get("[data-trigger-field] option").textContent, lang.automationAnyField);assert.equal(get("[data-status]").textContent, lang.automationReady);assert.equal(transactions.length, 0, "opening settings must preserve the stored rule");- const nameRect = get("[data-name]").getBoundingClientRect();+ const nameRect = get('[data-action="rules"]').getBoundingClientRect();const enabledRect = get("[data-enabled]").getBoundingClientRect();assert.ok(Math.abs((nameRect.top + nameRect.bottom) / 2 - (enabledRect.top + enabledRect.bottom) / 2) <= 1,- "the enable switch aligns with the name input rather than its label");- const ruleRect = get("[data-rule]").getBoundingClientRect();- for (const action of ["add-rule", "remove-rule"]) {+ "the enable switch aligns with the rule name");+ const ruleRect = nameRect;+ for (const action of ["add-rule"]) {const button = get(`[data-action="${action}"]`).getBoundingClientRect();assert.ok(Math.abs((ruleRect.top + ruleRect.bottom) / 2 - (button.top + button.bottom) / 2) <= 1,"rule actions align with the selector rather than its label");}+ await click('[data-action="rules"]');+ const rulePopup = fieldMenu.element;+ rulePopup.querySelector("[data-rename]").click();+ const renameInput = rulePopup.querySelector("[data-rules] input");+ renameInput.value = "Cancelled";+ renameInput.dispatchEvent(new KeyboardEvent("keydown", {key: "Escape", bubbles: true}));+ assert.equal(transactions.length, 0, "Escape cancels renaming");+ rulePopup.querySelector("[data-rename]").click();+ const nextName = rulePopup.querySelector("[data-rules] input");+ nextName.value = "Renamed completion";+ nextName.dispatchEvent(new KeyboardEvent("keydown", {key: "Enter", bubbles: true}));+ assert.equal(latest().name, "Renamed completion");+ assert.equal(transactions.at(-1).undo[0].data.rules[0].name, "Record completion time");+ const searchRules = rulePopup.querySelector("[data-search]");+ searchRules.value = "missing";+ searchRules.dispatchEvent(new Event("input"));+ assert.equal(rulePopup.querySelectorAll("[data-id]").length, 0);+ searchRules.value = "renamed";+ searchRules.dispatchEvent(new Event("input"));+ assert.equal(rulePopup.querySelectorAll("[data-id]").length, 1);+ rulePopup.querySelector(".b3-list-item__text").click();+ await tick();const removals = [['[data-source-conditions] [data-condition="0"]', '[data-source-conditions] [data-action="remove-condition"]'],['[data-actions] [data-index="0"]', '[data-actions] [data-action="remove-action"]'],@@ -347,10 +382,7 @@ const runCases = async (sources, css, mobile) => {for (const fontSize of ["", "28px"]) {menu.style.fontSize = fontSize;await tick();- const selectorRect = get("[data-rule]").getBoundingClientRect();- const nameInputRect = get("[data-name]").getBoundingClientRect();- assert.ok(Math.abs(selectorRect.left - nameInputRect.left) <= 1 && Math.abs(selectorRect.right - nameInputRect.right) <= 1,- `${mobile}/${width}/${fontSize}: rule selector and name input share their left and right edges`);+ assert.ok(get('[data-action="rules"]').getBoundingClientRect().width > 0);for (const element of [menu, get(".av__automation-body"), ...menu.querySelectorAll("section, [data-index]")]) {assert.ok(element.scrollWidth <= element.clientWidth + 1, `${mobile}/${width}/${fontSize}: content overflows`);}@@ -420,6 +452,22 @@ const runCases = async (sources, css, mobile) => {assert.deepEqual(latest().blockSource.attributes, [{name: "custom-status", operator: "equals", value: "ready"}]);await click('[data-remove="attribute"]');assert.equal(latest().blockSource.attributes.length, 0);+ await click('[data-action="add-rule"]');+ const secondID = transactions.at(-1).perform[0].data.rules[1].id;+ await click('[data-action="rules"]');+ fieldMenu.element.querySelector('[data-id="rule"] [data-more]').click();+ assert.equal(fieldMenu.element.querySelector('[data-id="rule"] .b3-menu__submenu').style.display, "block");+ fieldMenu.element.querySelector('[data-id="rule"] [data-delete]').click();+ await tick();+ assert.equal(transactions.at(-1).perform[0].data.rules.length, 1);+ assert.equal(transactions.at(-1).perform[0].data.rules[0].id, secondID, "deleting another rule preserves the current rule");+ assert.equal(transactions.at(-1).undo[0].data.rules.length, 2);+ await click('[data-action="rules"]');+ fieldMenu.element.querySelector("[data-delete]").click();+ await tick();+ assert.equal(transactions.at(-1).perform[0].data.rules.length, 0);+ assert.ok(get('[data-action="rules"]'), "deleting the current rule opens a fresh disabled draft");+ assert.equal(get("[data-enabled]").checked, false);window.removeEventListener("resize", resizeMenu);};@@ -445,7 +493,7 @@ if (process.versions.electron && process.type === "browser") {const sass = require("sass");const sources = {icons: fs.readFileSync(path.join(__dirname, "../appearance/icons/litheness/icon.js"), "utf8"),languages: JSON.parse(fs.readFileSync(path.join(__dirname, "../appearance/langs/zh-CN.json"), "utf8"))};- for (const name of ["automation", "automationPosition", "automationTemplate", "capabilities", "capabilities.generated", "filter", "filterTree", "fieldValueEditor", "blockCollection", "selectPosition", "filterDropdown"]) {+ for (const name of ["automation", "automationRules", "automationPosition", "automationTemplate", "capabilities", "capabilities.generated", "filter", "filterTree", "fieldValueEditor", "blockCollection", "selectPosition", "filterDropdown"]) {sources[`protyle/render/av/${name}`] = ts.transpileModule(fs.readFileSync(path.join(__dirname, `../src/protyle/render/av/${name}.ts`), "utf8"), {compilerOptions: {module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022},}).outputText;