mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
refactor(libs): rename helpers.ts to common.ts and update imports
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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>
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user