From 0b0a4832793f28e06fb4cc1f4872db69cb2378fd Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Thu, 30 Jul 2026 17:00:09 -0400 Subject: [PATCH 1/6] eng-519-human-readable-label-for-node-type-Claude-nodeTypeIdPropertyWidget --- apps/obsidian/src/index.ts | 6 ++ .../src/utils/nodeTypeIdPropertyWidget.ts | 69 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts diff --git a/apps/obsidian/src/index.ts b/apps/obsidian/src/index.ts index d5f57e27c..f539e478a 100644 --- a/apps/obsidian/src/index.ts +++ b/apps/obsidian/src/index.ts @@ -39,6 +39,10 @@ import { } from "~/utils/relationsStore"; import { migrateImportFolderMetadata } from "./utils/importFolderMetadata"; import { registerTemplateSettingsSync } from "~/utils/templateSettingsSync"; +import { + registerNodeTypeIdPropertyWidget, + unregisterNodeTypeIdPropertyWidget, +} from "~/utils/nodeTypeIdPropertyWidget"; export default class DiscourseGraphPlugin extends Plugin { settings: Settings = { ...DEFAULT_SETTINGS }; @@ -68,6 +72,7 @@ export default class DiscourseGraphPlugin extends Plugin { }); registerTemplateSettingsSync(this); + registerNodeTypeIdPropertyWidget(this); if (this.settings.syncModeEnabled === true) { void initializeSupabaseSync(this).catch((error) => { @@ -437,6 +442,7 @@ export default class DiscourseGraphPlugin extends Plugin { } onunload() { + unregisterNodeTypeIdPropertyWidget(this); this.activeNodePopover?.close(); this.activeNodePopover = null; this.cleanupViewActions(); diff --git a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts new file mode 100644 index 000000000..9041c0a8f --- /dev/null +++ b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts @@ -0,0 +1,69 @@ +import type { + MetadataTypeManager, + PropertyWidget, + PropertyWidgetComponentBase, +} from "obsidian-typings"; +import type DiscourseGraphPlugin from "~/index"; +import { getNodeTypeById } from "~/utils/typeUtils"; + +export const NODE_TYPE_ID_PROPERTY_KEY = "nodeTypeId"; +const WIDGET_TYPE = "dg-node-type-id"; + +/** + * Obsidian's frontmatter Properties UI (reading view + live preview) renders each + * property via a widget looked up by `metadataTypeManager`. This is unofficial/ + * internal API (see `obsidian-typings`), so it degrades gracefully: if Obsidian + * ever drops support, the widget type is simply unrecognized and the property + * renders as its raw text value, same as before this widget existed. + */ +const createWidget = ( + plugin: DiscourseGraphPlugin, +): PropertyWidget => ({ + type: WIDGET_TYPE, + icon: "shapes", + name: () => "Discourse node type", + validate: (value: unknown) => typeof value === "string", + render: (containerEl: HTMLElement, data: unknown) => { + const nodeTypeId = typeof data === "string" ? data : String(data ?? ""); + const nodeType = getNodeTypeById(plugin, nodeTypeId); + + const el = containerEl.createSpan({ + cls: "dg-node-type-id-value", + text: nodeType?.name ?? nodeTypeId, + }); + el.setAttr("title", nodeTypeId); + el.tabIndex = 0; + + return { + type: WIDGET_TYPE, + focus: () => el.focus(), + }; + }, +}); + +export const registerNodeTypeIdPropertyWidget = ( + plugin: DiscourseGraphPlugin, +): void => { + const metadataTypeManager = ( + plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } + ).metadataTypeManager; + + metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE] = createWidget(plugin); + void metadataTypeManager.setType(NODE_TYPE_ID_PROPERTY_KEY, WIDGET_TYPE); +}; + +export const unregisterNodeTypeIdPropertyWidget = ( + plugin: DiscourseGraphPlugin, +): void => { + const metadataTypeManager = ( + plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } + ).metadataTypeManager; + + if ( + metadataTypeManager.getAssignedWidget(NODE_TYPE_ID_PROPERTY_KEY) === + WIDGET_TYPE + ) { + void metadataTypeManager.unsetType(NODE_TYPE_ID_PROPERTY_KEY); + } + delete metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE]; +}; From db4605f9d6ff6c4de2ca863076585913683a9405 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Mon, 3 Aug 2026 23:01:08 -0400 Subject: [PATCH 2/6] add try-catch clauses --- .../src/utils/nodeTypeIdPropertyWidget.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts index 9041c0a8f..51312ac14 100644 --- a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts +++ b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts @@ -48,8 +48,13 @@ export const registerNodeTypeIdPropertyWidget = ( plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } ).metadataTypeManager; - metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE] = createWidget(plugin); - void metadataTypeManager.setType(NODE_TYPE_ID_PROPERTY_KEY, WIDGET_TYPE); + try { + metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE] = + createWidget(plugin); + void metadataTypeManager.setType(NODE_TYPE_ID_PROPERTY_KEY, WIDGET_TYPE); + } catch (error) { + console.error(error); + } }; export const unregisterNodeTypeIdPropertyWidget = ( @@ -59,11 +64,15 @@ export const unregisterNodeTypeIdPropertyWidget = ( plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } ).metadataTypeManager; - if ( - metadataTypeManager.getAssignedWidget(NODE_TYPE_ID_PROPERTY_KEY) === - WIDGET_TYPE - ) { - void metadataTypeManager.unsetType(NODE_TYPE_ID_PROPERTY_KEY); + try { + if ( + metadataTypeManager.getAssignedWidget(NODE_TYPE_ID_PROPERTY_KEY) === + WIDGET_TYPE + ) { + void metadataTypeManager.unsetType(NODE_TYPE_ID_PROPERTY_KEY); + } + delete metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE]; + } catch (error) { + console.error(error); } - delete metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE]; }; From fd3f3637fca072d4c1fd545ad7bb06b67c128816 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Wed, 5 Aug 2026 08:19:41 -0400 Subject: [PATCH 3/6] obsidianUnofficialTypes --- apps/obsidian/src/services/QueryEngine.ts | 14 +- .../src/utils/nodeTypeIdPropertyWidget.ts | 31 +-- .../src/utils/obsidianUnofficialTypes.ts | 252 ++++++++++++++++++ apps/obsidian/src/utils/supabaseContext.ts | 4 +- apps/obsidian/src/utils/templates.ts | 13 +- 5 files changed, 291 insertions(+), 23 deletions(-) create mode 100644 apps/obsidian/src/utils/obsidianUnofficialTypes.ts diff --git a/apps/obsidian/src/services/QueryEngine.ts b/apps/obsidian/src/services/QueryEngine.ts index 0edee84e6..eeca29d6c 100644 --- a/apps/obsidian/src/services/QueryEngine.ts +++ b/apps/obsidian/src/services/QueryEngine.ts @@ -1,8 +1,9 @@ -import { TFile, App } from "obsidian"; +import { TFile, App, Plugin } from "obsidian"; import type DiscourseGraphPlugin from "~/index"; import { BulkImportPattern, BulkImportCandidate, DiscourseNode } from "~/types"; import { getDiscourseNodeFormatExpression } from "~/utils/getDiscourseNodeFormatExpression"; import { extractContentFromTitle } from "~/utils/extractContentFromTitle"; +import { AppWithUnofficialApis } from "~/utils/obsidianUnofficialTypes"; // This is a workaround to get the datacore API. // TODO: Remove once we can use datacore npm package @@ -31,10 +32,15 @@ export class QueryEngine { private readonly MIN_QUERY_LENGTH = 2; constructor(app: App) { - const appWithPlugins = app as AppWithPlugins; - this.dc = appWithPlugins.plugins?.plugins?.["datacore"]?.api as - | { query: (query: string) => DatacorePage[] } + const appWithPlugins = app as AppWithUnofficialApis; + const datacorePlugin = appWithPlugins.plugins?.plugins?.["datacore"] as + | (Plugin & { + api: { + query: (query: string) => DatacorePage[]; + }; + }) | undefined; + this.dc = datacorePlugin?.api; this.app = app; } diff --git a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts index 51312ac14..c0b4907f8 100644 --- a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts +++ b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts @@ -1,8 +1,9 @@ import type { - MetadataTypeManager, + AppWithUnofficialApis, PropertyWidget, PropertyWidgetComponentBase, -} from "obsidian-typings"; + MetadataTypeManager, +} from "./obsidianUnofficialTypes"; import type DiscourseGraphPlugin from "~/index"; import { getNodeTypeById } from "~/utils/typeUtils"; @@ -60,19 +61,19 @@ export const registerNodeTypeIdPropertyWidget = ( export const unregisterNodeTypeIdPropertyWidget = ( plugin: DiscourseGraphPlugin, ): void => { - const metadataTypeManager = ( - plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } - ).metadataTypeManager; + const metadataTypeManager = (plugin.app as AppWithUnofficialApis) + .metadataTypeManager; - try { - if ( - metadataTypeManager.getAssignedWidget(NODE_TYPE_ID_PROPERTY_KEY) === - WIDGET_TYPE - ) { - void metadataTypeManager.unsetType(NODE_TYPE_ID_PROPERTY_KEY); + if (metadataTypeManager) + try { + if ( + metadataTypeManager.getAssignedWidget(NODE_TYPE_ID_PROPERTY_KEY) === + WIDGET_TYPE + ) { + void metadataTypeManager.unsetType(NODE_TYPE_ID_PROPERTY_KEY); + } + delete metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE]; + } catch (error) { + console.error(error); } - delete metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE]; - } catch (error) { - console.error(error); - } }; diff --git a/apps/obsidian/src/utils/obsidianUnofficialTypes.ts b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts new file mode 100644 index 000000000..fc7c67ff9 --- /dev/null +++ b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts @@ -0,0 +1,252 @@ +import { App, Events, Debouncer, Plugin, Component } from "obsidian"; + +// extracted the MetaadataTypeManager from "obsidian-types", +// and parts of internalPlugins, plugins. + +type FocusMode = "both" | "end" | "start"; + +export type PropertyWidgetComponentBase = { + /** + * The type of the property widget. + */ + type: string; + /** + * Focus the property widget. + * + * @param mode - The focus mode. + */ + focus(mode?: FocusMode): void; +}; + +type PropertyRenderContext = { + /** + * Reference to the app. + */ + app: App; + /** + * Key of the property field. + */ + key: string; + /** + * Determine the source path of current context. + */ + sourcePath: string; + /** + * Callback called on property field unfocus. + */ + blur(): void; + /** + * Callback called on property value change. + * + * @param value - The new property value. + */ + onChange(value: unknown): void; +}; + +export type PropertyWidget< + ComponentType extends + PropertyWidgetComponentBase = PropertyWidgetComponentBase, +> = { + /** + * Lucide-dev icon associated with the widget. + */ + icon: string; + /** + * Reserved keys for the widget. + */ + reservedKeys?: string[]; + /** + * Identifier for the widget. + */ + type: string; + /** + * Returns the I18N name of the widget. + * + * @returns The localized name of the widget. + */ + name(): string; + /** + * Render function for the widget on field container given context and data. + * + * @param containerEl - The container element to render the widget into. + * @param data - The property data to render. + * @param context - The rendering context for the property. + * @returns The rendered widget component. + */ + render( + containerEl: HTMLElement, + data: unknown, + context: PropertyRenderContext, + ): ComponentType; + /** + * Validate whether the input value to the widget is correct. + * + * @param value - The value to validate. + * @returns Whether the value is valid. + */ + validate(value: unknown): boolean; +}; + +export type PropertyWidgetEntry = { + /** + * Display name of the property widget. + */ + name: string; + /** + * The property widget type. + */ + widget: string; +}; + +type PropertyInfo = { + /** + * Name of property. + */ + name: string; + /** + * Usage count of property. + */ + occurrences: number; + /** + * Type of property. + */ + widget: string; +}; + +type TypeInfo = { + /** + * The explicitly assigned property widget type. + */ + expected: PropertyWidget; + /** + * The property widget type inferred from the value. + */ + inferred: PropertyWidget; +}; + +type PropertyWidgetType = string; + +export type MetadataTypeManager = { + /** + * Reference to the {@link obsidian#App}. + */ + app: App; + /** + * Associated widget types for each property. + */ + assignedWidgets: Record; + /** + * Unix timestamp of the last save + */ + lastSave: number; + /** + * Debounced handler for property type config file changes on disk. + */ + onConfigFileChange: Debouncer<[], Promise>; + /** + * Registered properties of the vault. + */ + properties: Record; + /** + * Registered type widgets. + */ + registeredTypeWidgets: Record; + /** + * Get all registered properties of the vault. + * + * @returns Record of property names to their info. + */ + getAllProperties(): Record; + /** + * Get assigned widget type for property. + * + * @param property - Property name. + * @returns The assigned widget type, or `null`. + */ + getAssignedWidget(property: string): null | PropertyWidgetType; + /** + * Get info for property. + * + * @param property - Property name. + * @returns Information about the property. + */ + getPropertyInfo(property: string): PropertyInfo; + /** + * Get expected widget type for property and the one inferred from the property value. + * + * @param property - Property name. + * @param value - Property value. + * @returns Type information for the property. + */ + getTypeInfo(property: string, value: unknown): TypeInfo; + /** + * Get property widget. + * + * @param type - Widget type name. + * @returns The property widget. + */ + getWidget(type: string): PropertyWidget; + /** + * Load metadata type configuration. + */ + load(): Promise; + /** + * Load property types from config. + * + * @returns A promise that resolves when the property types are loaded. + */ + loadData(): Promise; + /** + * Handle raw file system change events for the property type config. + * + * @param e - The raw file system change event. + */ + onRaw(e: unknown): void; + /** + * Register event listeners for property type config file changes. + */ + registerListeners(): void; + /** + * Save property types to config. + * + * @returns A promise that resolves when the property types are saved. + */ + save(): Promise; + /** + * Set widget type for property. + * + * @param property - Property name. + * @param type - Widget type to assign. + * @returns A promise that resolves when the widget type is set. + */ + setType(property: string, type: PropertyWidgetType): Promise; + /** + * Unset widget type for property. + * + * @param property - Property name. + * @returns A promise that resolves when the widget type is unset. + */ + unsetType(property: string): Promise; + /** + * Updates `this.properties` to match the {@link obsidian#MetadataCache} + */ + updatePropertyInfoCache(): void; +} & Events; + +export type InternalPluginInstance = { + plugin: InternalPlugin; +}; + +type InternalPlugin = { + enabled: boolean; + instance: InternalPluginInstance; +} & Component; + +export type AppWithUnofficialApis = App & { + appId: string; + metadataTypeManager?: MetadataTypeManager; + plugins?: Events & { plugins?: Record }; + internalPlugins?: Events & { + plugins?: Record; + }; +}; diff --git a/apps/obsidian/src/utils/supabaseContext.ts b/apps/obsidian/src/utils/supabaseContext.ts index d52ce351b..77bdc31cf 100644 --- a/apps/obsidian/src/utils/supabaseContext.ts +++ b/apps/obsidian/src/utils/supabaseContext.ts @@ -7,7 +7,7 @@ import { FatalError, } from "@repo/database/lib/contextFunctions"; import type DiscourseGraphPlugin from "~/index"; - +import type { AppWithUnofficialApis } from "./obsidianUnofficialTypes"; type Platform = Enums<"Platform">; export type SupabaseContext = { @@ -58,7 +58,7 @@ const getOrCreateAccountLocalId = async ( * @see https://help.obsidian.md/Extending+Obsidian/Obsidian+URI */ export const getVaultId = (app: DiscourseGraphPlugin["app"]): string => { - return (app as unknown as { appId: string }).appId; + return (app as AppWithUnofficialApis).appId; }; /** Canonical space URL for an Obsidian vault; stored as Space.url in the DB. */ diff --git a/apps/obsidian/src/utils/templates.ts b/apps/obsidian/src/utils/templates.ts index cc69b1c22..af4247364 100644 --- a/apps/obsidian/src/utils/templates.ts +++ b/apps/obsidian/src/utils/templates.ts @@ -6,6 +6,10 @@ import { getFrontMatterInfo, } from "obsidian"; import type { Settings } from "~/types"; +import type { + AppWithUnofficialApis, + InternalPluginInstance, +} from "./obsidianUnofficialTypes"; type TemplatePluginInfo = { isEnabled: boolean; @@ -47,13 +51,18 @@ const mergeFrontmatter = ( export const getTemplatePluginInfo = (app: App): TemplatePluginInfo => { try { - const templatesPlugin = (app as any).internalPlugins?.plugins?.templates; + const templatesPlugin = (app as AppWithUnofficialApis).internalPlugins + ?.plugins?.templates; if (!templatesPlugin || !templatesPlugin.enabled) { return { isEnabled: false, folderPath: "" }; } - const folderPath = templatesPlugin.instance?.options?.folder || ""; + const instance = templatesPlugin.instance as InternalPluginInstance & { + options?: { folder?: string }; + }; + + const folderPath = instance.options?.folder || ""; return { isEnabled: true, From 96c67a149171eaee4436c62f610ce50a096e6f17 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Wed, 5 Aug 2026 10:33:37 -0400 Subject: [PATCH 4/6] consistent registration --- .../src/utils/nodeTypeIdPropertyWidget.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts index c0b4907f8..965a6ad3a 100644 --- a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts +++ b/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts @@ -45,17 +45,17 @@ const createWidget = ( export const registerNodeTypeIdPropertyWidget = ( plugin: DiscourseGraphPlugin, ): void => { - const metadataTypeManager = ( - plugin.app as unknown as { metadataTypeManager: MetadataTypeManager } - ).metadataTypeManager; + const metadataTypeManager = (plugin.app as AppWithUnofficialApis) + .metadataTypeManager; - try { - metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE] = - createWidget(plugin); - void metadataTypeManager.setType(NODE_TYPE_ID_PROPERTY_KEY, WIDGET_TYPE); - } catch (error) { - console.error(error); - } + if (metadataTypeManager) + try { + metadataTypeManager.registeredTypeWidgets[WIDGET_TYPE] = + createWidget(plugin); + void metadataTypeManager.setType(NODE_TYPE_ID_PROPERTY_KEY, WIDGET_TYPE); + } catch (error) { + console.error(error); + } }; export const unregisterNodeTypeIdPropertyWidget = ( From e05dfa6b74ca075435ed1411351f3e753c6ff58b Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Wed, 5 Aug 2026 10:43:02 -0400 Subject: [PATCH 5/6] move widget to components. Remove unused exports. Name the widget types. --- .../{utils => components}/nodeTypeIdPropertyWidget.ts | 10 +++++++--- apps/obsidian/src/index.ts | 2 +- apps/obsidian/src/utils/obsidianUnofficialTypes.ts | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) rename apps/obsidian/src/{utils => components}/nodeTypeIdPropertyWidget.ts (91%) diff --git a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts b/apps/obsidian/src/components/nodeTypeIdPropertyWidget.ts similarity index 91% rename from apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts rename to apps/obsidian/src/components/nodeTypeIdPropertyWidget.ts index 965a6ad3a..001ec298a 100644 --- a/apps/obsidian/src/utils/nodeTypeIdPropertyWidget.ts +++ b/apps/obsidian/src/components/nodeTypeIdPropertyWidget.ts @@ -2,14 +2,18 @@ import type { AppWithUnofficialApis, PropertyWidget, PropertyWidgetComponentBase, - MetadataTypeManager, -} from "./obsidianUnofficialTypes"; +} from "~/utils/obsidianUnofficialTypes"; import type DiscourseGraphPlugin from "~/index"; import { getNodeTypeById } from "~/utils/typeUtils"; export const NODE_TYPE_ID_PROPERTY_KEY = "nodeTypeId"; const WIDGET_TYPE = "dg-node-type-id"; +type NodeTypeIdPropertyWidgetComponent = PropertyWidgetComponentBase; + +type NodeTypeIdPropertyWidget = + PropertyWidget; + /** * Obsidian's frontmatter Properties UI (reading view + live preview) renders each * property via a widget looked up by `metadataTypeManager`. This is unofficial/ @@ -19,7 +23,7 @@ const WIDGET_TYPE = "dg-node-type-id"; */ const createWidget = ( plugin: DiscourseGraphPlugin, -): PropertyWidget => ({ +): NodeTypeIdPropertyWidget => ({ type: WIDGET_TYPE, icon: "shapes", name: () => "Discourse node type", diff --git a/apps/obsidian/src/index.ts b/apps/obsidian/src/index.ts index f539e478a..e4291109d 100644 --- a/apps/obsidian/src/index.ts +++ b/apps/obsidian/src/index.ts @@ -42,7 +42,7 @@ import { registerTemplateSettingsSync } from "~/utils/templateSettingsSync"; import { registerNodeTypeIdPropertyWidget, unregisterNodeTypeIdPropertyWidget, -} from "~/utils/nodeTypeIdPropertyWidget"; +} from "~/components/nodeTypeIdPropertyWidget"; export default class DiscourseGraphPlugin extends Plugin { settings: Settings = { ...DEFAULT_SETTINGS }; diff --git a/apps/obsidian/src/utils/obsidianUnofficialTypes.ts b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts index fc7c67ff9..22f682132 100644 --- a/apps/obsidian/src/utils/obsidianUnofficialTypes.ts +++ b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts @@ -87,7 +87,7 @@ export type PropertyWidget< validate(value: unknown): boolean; }; -export type PropertyWidgetEntry = { +type PropertyWidgetEntry = { /** * Display name of the property widget. */ @@ -126,7 +126,7 @@ type TypeInfo = { type PropertyWidgetType = string; -export type MetadataTypeManager = { +type MetadataTypeManager = { /** * Reference to the {@link obsidian#App}. */ From 3776d1a984949bc9478c84ed8d81ebd1b9b279bc Mon Sep 17 00:00:00 2001 From: Marc-Antoine Parent Date: Wed, 5 Aug 2026 10:47:49 -0400 Subject: [PATCH 6/6] use bare minimum from MetadataTypeManager --- .../src/utils/obsidianUnofficialTypes.ts | 78 ------------------- 1 file changed, 78 deletions(-) diff --git a/apps/obsidian/src/utils/obsidianUnofficialTypes.ts b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts index 22f682132..f6f531364 100644 --- a/apps/obsidian/src/utils/obsidianUnofficialTypes.ts +++ b/apps/obsidian/src/utils/obsidianUnofficialTypes.ts @@ -127,36 +127,10 @@ type TypeInfo = { type PropertyWidgetType = string; type MetadataTypeManager = { - /** - * Reference to the {@link obsidian#App}. - */ - app: App; - /** - * Associated widget types for each property. - */ - assignedWidgets: Record; - /** - * Unix timestamp of the last save - */ - lastSave: number; - /** - * Debounced handler for property type config file changes on disk. - */ - onConfigFileChange: Debouncer<[], Promise>; - /** - * Registered properties of the vault. - */ - properties: Record; /** * Registered type widgets. */ registeredTypeWidgets: Record; - /** - * Get all registered properties of the vault. - * - * @returns Record of property names to their info. - */ - getAllProperties(): Record; /** * Get assigned widget type for property. * @@ -164,54 +138,6 @@ type MetadataTypeManager = { * @returns The assigned widget type, or `null`. */ getAssignedWidget(property: string): null | PropertyWidgetType; - /** - * Get info for property. - * - * @param property - Property name. - * @returns Information about the property. - */ - getPropertyInfo(property: string): PropertyInfo; - /** - * Get expected widget type for property and the one inferred from the property value. - * - * @param property - Property name. - * @param value - Property value. - * @returns Type information for the property. - */ - getTypeInfo(property: string, value: unknown): TypeInfo; - /** - * Get property widget. - * - * @param type - Widget type name. - * @returns The property widget. - */ - getWidget(type: string): PropertyWidget; - /** - * Load metadata type configuration. - */ - load(): Promise; - /** - * Load property types from config. - * - * @returns A promise that resolves when the property types are loaded. - */ - loadData(): Promise; - /** - * Handle raw file system change events for the property type config. - * - * @param e - The raw file system change event. - */ - onRaw(e: unknown): void; - /** - * Register event listeners for property type config file changes. - */ - registerListeners(): void; - /** - * Save property types to config. - * - * @returns A promise that resolves when the property types are saved. - */ - save(): Promise; /** * Set widget type for property. * @@ -227,10 +153,6 @@ type MetadataTypeManager = { * @returns A promise that resolves when the widget type is unset. */ unsetType(property: string): Promise; - /** - * Updates `this.properties` to match the {@link obsidian#MetadataCache} - */ - updatePropertyInfoCache(): void; } & Events; export type InternalPluginInstance = {