improve(plugin): basic impls of file storage api for specific plugin context

This commit is contained in:
charlie
2021-07-09 15:19:13 +08:00
committed by Tienson Qin
parent e2a047c1ac
commit 661bb064f7
12 changed files with 234 additions and 17 deletions

View File

@@ -1,6 +1,7 @@
import { StyleString, UIOptions } from './LSPlugin'
import { PluginLocal } from './LSPlugin.core'
import { snakeCase } from 'snake-case'
import * as path from 'path'
interface IObject {
[key: string]: any;
@@ -13,6 +14,31 @@ declare global {
}
}
export const IS_DEV = process.env.NODE_ENV === 'development'
let _appPathRoot
export async function getAppPathRoot () {
if (_appPathRoot) {
return _appPathRoot
}
return (_appPathRoot =
await invokeHostExportedApi('_callApplication', 'getAppPath')
)
}
export async function getSDKPathRoot () {
if (IS_DEV) {
// TODO: cache in preference file
return localStorage.getItem('LSP_DEV_SDK_ROOT') || 'http://localhost:8080'
}
const appPathRoot = await getAppPathRoot()
return path.join(appPathRoot, 'js')
}
export function isObject (item: any) {
return (item === Object(item) && !Array.isArray(item))
}