refactor(libs): rename helpers.ts to common.ts and update imports

This commit is contained in:
charlie
2026-01-26 19:09:01 +08:00
parent 185125de52
commit 28a4474810
5 changed files with 6 additions and 29 deletions

View File

@@ -2,7 +2,7 @@ import Debug from 'debug'
import { Postmate, Model, ParentAPI, ChildAPI } from './postmate'
import EventEmitter from 'eventemitter3'
import { PluginLocal } from './LSPlugin.core'
import { deferred, IS_DEV } from './helpers'
import { deferred, IS_DEV } from './common'
import { LSPluginShadowFrame } from './LSPlugin.shadow'
const debug = Debug('LSPlugin:caller')

View File

@@ -21,8 +21,8 @@ import {
injectTheme,
cleanInjectedUI,
PluginLogger,
} from './helpers'
import * as pluginHelpers from './helpers'
} from './common'
import * as pluginHelpers from './common'
import DOMPurify from 'dompurify'
import Debug from 'debug'
import {

View File

@@ -5,7 +5,7 @@ import {
PluginLogger,
safeSnakeCase,
safetyPathJoin, normalizeKeyStr,
} from './helpers'
} from './common'
import { LSPluginCaller } from './LSPlugin.caller'
import * as callableAPIs from './callable.apis'
import {

View File

@@ -21,7 +21,7 @@ export const PROTOCOL_FILE = 'file://'
export const PROTOCOL_LSP = 'lsp://'
export const URL_LSP = PROTOCOL_LSP + 'logseq.io/'
let _appPathRoot
let _appPathRoot: string
// TODO: snakeCase of lodash is incompatible with `snake-case`
export const safeSnakeCase = snakeCase
@@ -169,10 +169,6 @@ export function safetyPathNormalize(basePath: string) {
return basePath
}
/**
* @param timeout milliseconds
* @param tag string
*/
export function deferred<T = any>(timeout?: number, tag?: string) {
let resolve: any, reject: any
let settled = false
@@ -242,25 +238,6 @@ export function invokeHostExportedApi(method: string, ...args: Array<any>) {
return typeof fn !== 'function' ? fn : fn.apply(this, args)
}
export function setupIframeSandbox(
props: Record<string, any>,
target: HTMLElement
) {
const iframe = document.createElement('iframe')
iframe.classList.add('lsp-iframe-sandbox')
Object.entries(props).forEach(([k, v]) => {
iframe.setAttribute(k, v)
})
target.appendChild(iframe)
return async () => {
target.removeChild(iframe)
}
}
export function setupInjectedStyle(
style: StyleString,
attrs: Record<string, any>

View File

@@ -1,6 +1,6 @@
import { LSPluginUser } from '../LSPlugin.user'
import { PluginLocal } from '../LSPlugin.core'
import { safeSnakeCase } from '../helpers'
import { safeSnakeCase } from '../common'
/**
* WARN: These are some experience features and might be adjusted at any time.