enhance: IAppProxy, IEditorProxy, BlockEntity and PageEntity have strict interfaces (#9520)

* types: remove problematic Record<string, any>

* types: remove `[key: string]: any` which clobbers all other type info

* fix: support alternative dev entrypoint

* fix: normalize boolean value to string

* fix: identify field used for legacy themes (?)

* fix: add missing `effect` and `iir` properties, which are likely internal only

* docs: move comment to JS Doc so it should show up in docs

* fix: add missing internal `lsr` field

* bump package to 0.1.15 to indicate breaking API change

* fix: ensure that Plugins can access their settings... if they exist

* Revert "bump package to 0.1.15 to indicate breaking API change"

This reverts commit 6e0d1094f2.

---------

Co-authored-by: Gabriel Horner <97210743+logseq-cldwalker@users.noreply.github.com>
This commit is contained in:
Phil Denhoff
2023-06-20 13:59:55 -07:00
committed by GitHub
parent 1b0403bbaf
commit ec658d1e67
2 changed files with 25 additions and 21 deletions

View File

@@ -233,7 +233,7 @@ function initMainUIHandlers(pluginLocal: PluginLocal) {
pluginLocal.on(_('attrs'), (attrs: Partial<UIContainerAttrs>) => {
const el = pluginLocal.getMainUIContainer()
Object.entries(attrs).forEach(([k, v]) => {
el?.setAttribute(k, v)
el?.setAttribute(k, String(v))
if (k === 'draggable' && v) {
pluginLocal._dispose(
pluginLocal._setupDraggableContainer(el, {

View File

@@ -33,8 +33,6 @@ export type StyleOptions = {
export type UIContainerAttrs = {
draggable: boolean
resizable: boolean
[key: string]: any
}
export type UIBaseOptions = {
@@ -75,20 +73,34 @@ export interface LSPluginPkgConfig {
mode: 'shadow' | 'iframe'
themes: Theme[]
icon: string
[key: string]: any
/**
* Alternative entrypoint for development.
*/
devEntry: unknown
/**
* For legacy themes, do not use.
*/
theme: unknown
}
export interface LSPluginBaseInfo {
id: string // should be unique
/**
* Must be unique.
*/
id: string
mode: 'shadow' | 'iframe'
settings: {
disabled: boolean
[key: string]: any
}
[key: string]: any
} & Record<string, unknown>
effect: boolean
/**
* For internal use only. Indicates if plugin is installed in dot root.
*/
iir: boolean
/**
* For internal use only.
*/
lsr: string
}
export type IHookEvent = {
@@ -146,8 +158,6 @@ export interface AppUserConfigs {
showBracket: boolean
enabledFlashcards: boolean
enabledJournals: boolean
[key: string]: any
}
/**
@@ -157,8 +167,6 @@ export interface AppGraphInfo {
name: string
url: string
path: string
[key: string]: any
}
/**
@@ -184,8 +192,6 @@ export interface BlockEntity {
level?: number
meta?: { timestamps: any; properties: any; startPos: number; endPos: number }
title?: Array<any>
[key: string]: any
}
/**
@@ -205,8 +211,6 @@ export interface PageEntity {
format?: 'markdown' | 'org'
journalDay?: number
updatedAt?: number
[key: string]: any
}
export type BlockIdentity = BlockUUID | Pick<BlockEntity, 'uuid'>
@@ -1078,8 +1082,8 @@ export interface ILSPluginUser extends EventEmitter<LSPluginUserEvents> {
resolveResourceFullUrl(filePath: string): string
App: IAppProxy & Record<string, any>
Editor: IEditorProxy & Record<string, any>
App: IAppProxy
Editor: IEditorProxy
DB: IDBProxy
Git: IGitProxy
UI: IUIProxy