Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(scripts/preact): address review
Elian Doran1554085d7a0b
diff --git a/apps/client/src/services/bundle.ts b/apps/client/src/services/bundle.tsindex 9dd11b6840..a56139d369 100644--- a/apps/client/src/services/bundle.ts+++ b/apps/client/src/services/bundle.ts@@ -1,6 +1,5 @@import { h, VNode } from "preact";-import Component from "../components/component.js";import BasicWidget, { ReactWrappedWidget } from "../widgets/basic_widget.js";import RightPanelWidget from "../widgets/right_panel_widget.js";import froca from "./froca.js";diff --git a/apps/client/src/services/frontend_script_api.ts b/apps/client/src/services/frontend_script_api.tsindex 12d34832d3..a76a09d557 100644--- a/apps/client/src/services/frontend_script_api.ts+++ b/apps/client/src/services/frontend_script_api.ts@@ -538,7 +538,6 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, origreturn `!@#Function: ${p.toString()}`;}return p;-});}@@ -567,7 +566,6 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, origreturn ret.executionResult;}throw new Error(`server error: ${ret.error}`);-};this.runOnBackend = async (func, params = []) => {diff --git a/apps/client/src/services/frontend_script_api_preact.ts b/apps/client/src/services/frontend_script_api_preact.tsindex e762f04d96..2829ca101e 100644--- a/apps/client/src/services/frontend_script_api_preact.ts+++ b/apps/client/src/services/frontend_script_api_preact.ts@@ -9,9 +9,9 @@ import Collapsible from "../widgets/react/Collapsible";import Dropdown from "../widgets/react/Dropdown";import FormCheckbox from "../widgets/react/FormCheckbox";import FormDropdownList from "../widgets/react/FormDropdownList";-import { FormFileUploadActionButton,FormFileUploadButton } from "../widgets/react/FormFileUpload";+import { FormFileUploadActionButton, FormFileUploadButton } from "../widgets/react/FormFileUpload";import FormGroup from "../widgets/react/FormGroup";-import { FormDropdownDivider, FormDropdownSubmenu,FormListItem } from "../widgets/react/FormList";+import { FormDropdownDivider, FormDropdownSubmenu, FormListItem } from "../widgets/react/FormList";import FormRadioGroup from "../widgets/react/FormRadioGroup";import FormText from "../widgets/react/FormText";import FormTextArea from "../widgets/react/FormTextArea";diff --git a/apps/client/src/widgets/basic_widget.ts b/apps/client/src/widgets/basic_widget.tsindex 9b2c03d4ec..eb6b55b0d6 100644--- a/apps/client/src/widgets/basic_widget.ts+++ b/apps/client/src/widgets/basic_widget.ts@@ -57,9 +57,8 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedComponoptChild(condition: boolean, ...components: (T | VNode)[]) {if (condition) {return this.child(...components);- }+ }return this;-}id(id: string) {@@ -246,9 +245,8 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompongetClosestNtxId() {if (this.$widget) {return this.$widget.closest("[data-ntx-id]").attr("data-ntx-id");- }+ }return null;-}cleanup() {}diff --git a/apps/client/src/widgets/react/FormCheckbox.tsx b/apps/client/src/widgets/react/FormCheckbox.tsxindex 70fea856f1..839fa4b957 100644--- a/apps/client/src/widgets/react/FormCheckbox.tsx+++ b/apps/client/src/widgets/react/FormCheckbox.tsx@@ -1,7 +1,6 @@import { Tooltip } from "bootstrap";-import { ComponentChildren } from "preact";-import { CSSProperties, memo } from "preact/compat";-import { useCallback,useEffect, useMemo, useRef } from "preact/hooks";+import { ComponentChildren, CSSProperties } from "preact";+import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";import { escapeQuotes } from "../../services/utils";import { useUniqueName } from "./hooks";diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex a79280645b..1ac0394062 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -2,7 +2,7 @@import "./RightPanelContainer.css";import Split from "@triliumnext/split.js";-import { isValidElement, VNode } from "preact";+import { VNode } from "preact";import { useEffect, useRef } from "preact/hooks";import appContext from "../../components/app_context";@@ -10,7 +10,6 @@ import { WidgetsByParent } from "../../services/bundle";import { t } from "../../services/i18n";import options from "../../services/options";import { DEFAULT_GUTTER_SIZE } from "../../services/resizer";-import BasicWidget from "../basic_widget";import Button from "../react/Button";import { useActiveNoteContext, useLegacyWidget, useNoteProperty, useTriliumOptionBool, useTriliumOptionJson } from "../react/hooks";import Icon from "../react/Icon";@@ -67,7 +66,7 @@ function useItems(rightPaneVisible: boolean, widgetsByParent: WidgetsByParent) {el: <HighlightsList />,enabled: noteType === "text" && highlightsList.length > 0,},- ...widgetsByParent.getLegacyWidgets("right-pane").map((widget, i) => ({+ ...widgetsByParent.getLegacyWidgets("right-pane").map((widget) => ({el: <CustomLegacyWidget key={widget._noteId} originalWidget={widget as LegacyRightPanelWidget} />,enabled: true,position: widget.positiondiff --git a/apps/server/src/becca/entities/bnote.ts b/apps/server/src/becca/entities/bnote.tsindex abdeead4bf..4eb92c80d9 100644--- a/apps/server/src/becca/entities/bnote.ts+++ b/apps/server/src/becca/entities/bnote.ts@@ -360,7 +360,6 @@ class BNote extends AbstractBeccaEntity<BNote> {return this.__attributeCache.filter((attr) => attr.name === name);}return this.__attributeCache;-}private __ensureAttributeCacheIsAvailable() {@@ -697,7 +696,6 @@ class BNote extends AbstractBeccaEntity<BNote> {return this.ownedAttributes.filter((attr) => attr.name === name);}return this.ownedAttributes;-}/**@@ -750,7 +748,6 @@ class BNote extends AbstractBeccaEntity<BNote> {return 1;}return 0;-});this.parents = this.parentBranches.map((branch) => branch.parentNote).filter((note) => !!note) as BNote[];@@ -1183,7 +1180,6 @@ class BNote extends AbstractBeccaEntity<BNote> {return a.isHidden ? 1 : -1;}return a.notePath.length - b.notePath.length;-});return notePaths;@@ -1722,7 +1718,6 @@ class BNote extends AbstractBeccaEntity<BNote> {return "bx bx-data";}return NOTE_TYPE_ICONS[this.type];-}// TODO: Deduplicate with fnotediff --git a/apps/server/src/services/script.ts b/apps/server/src/services/script.tsindex e6d88d4b64..97dd99898a 100644--- a/apps/server/src/services/script.ts+++ b/apps/server/src/services/script.ts@@ -114,7 +114,6 @@ function getParams(params?: ScriptParams) {return p.substr(13);}return JSON.stringify(p);-}).join(",");}@@ -227,10 +226,10 @@ export function buildJsx(contentRaw: string | Buffer) {production: true});- let code = output.code;+ let code = output.code;// Rewrite ESM-like exports to `module.exports =`.- code = output.code.replaceAll(+ code = code.replaceAll(/\bexports\s*\.\s*default\s*=\s*/g,'module.exports = ');@@ -241,7 +240,7 @@ export function buildJsx(contentRaw: string | Buffer) {'const $1 = api.preact;');- // Rewrite ESM-like imports to internal API, to `const { foo } = api.preact`+ // Rewrite ESM-like imports to internal API, to `const { foo } = api`code = code.replaceAll(/(?:var|let|const)\s+(\w+)\s*=\s*require\(['"]trilium:api['"]\);?/g,'const $1 = api;'