Skip to content

Commit

Permalink
Merge branch 'logseq:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Bad3r authored Aug 30, 2023
2 parents fb3cafa + 92ad2e4 commit 8851b46
Show file tree
Hide file tree
Showing 54 changed files with 2,490 additions and 2,179 deletions.
25 changes: 15 additions & 10 deletions docs/develop-logseq-on-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

This is a guide on setting up Logseq development dependencies on Windows. Once these dependencies are installed, you can follow the [develop-logseq](develop-logseq.md) docs for build instructions.

## [scoop](https://scoop.sh/)

Scoop provides a `clojure.exe` shim which works in Command Prompt and Powershell windows.

```
scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure
scoop bucket add extras
scoop bucket add java
scoop install java/openjdk clj-deps babashka leiningen nodejs-lts
```

## Winget

Winget is a package manager installed by default on windows.
Expand All @@ -19,6 +30,10 @@ An installer for clojure is available from [casselc/clj-msi](https://github.com/

## [chocolatey](https://chocolatey.org/)

Chocolatey installs Clojure as a PowerShell module and alias, and does not provide `clojure` for `cmd.exe`.

[@andelf has written a wrapper utility](https://github.com/andelf/clojure-cli) which you can install with `cargo install --git https://github.com/andelf/clojure-cli.git` instead.

```
choco install nvm
nvm install 18
Expand All @@ -29,16 +44,6 @@ choco install javaruntime
choco install clojure
```


## [scoop](https://scoop.sh/)

```
scoop bucket add scoop-clojure https://github.com/littleli/scoop-clojure
scoop bucket add extras
scoop bucket add java
scoop install java/openjdk clojure clj-deps babashka leiningen nodejs-lts
```

## Troubleshooting

### Configuring a proxy for internet access
Expand Down
1 change: 1 addition & 0 deletions libs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"dependencies": {
"csstype": "3.1.0",
"debug": "4.3.4",
"deepmerge": "4.3.1",
"dompurify": "2.3.8",
"eventemitter3": "4.0.7",
"fast-deep-equal": "3.1.3",
Expand Down
15 changes: 10 additions & 5 deletions libs/src/LSPlugin.caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,23 @@ class LSPluginCaller extends EventEmitter {
let { width, height, left, top, vw, vh } = mainLayoutInfo

left = Math.max(left, 0)
left = (typeof vw === 'number') ?
`${Math.min(left * 100 / vw, 99)}%` : `${left}px`
left =
typeof vw === 'number'
? `${Math.min((left * 100) / vw, 99)}%`
: `${left}px`

// 45 is height of headbar
top = Math.max(top, 45)
top = (typeof vh === 'number') ?
`${Math.min(top * 100 / vh, 99)}%` : `${top}px`
top =
typeof vh === 'number'
? `${Math.min((top * 100) / vh, 99)}%`
: `${top}px`

Object.assign(cnt.style, {
width: width + 'px',
height: height + 'px',
left, top
left,
top,
})
}
} catch (e) {
Expand Down
73 changes: 41 additions & 32 deletions libs/src/LSPlugin.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class PluginSettings extends EventEmitter<'change' | 'reset'> {
if (this._settings[k] == v) return
this._settings[k] = v
} else if (isObject(k)) {
deepMerge(this._settings, k)
this._settings = deepMerge(this._settings, k)
} else {
return
}
Expand Down Expand Up @@ -395,11 +395,9 @@ class ExistedImportedPluginPackageError extends Error {
/**
* Host plugin for local
*/
class PluginLocal extends EventEmitter<'loaded'
| 'unloaded'
| 'beforeunload'
| 'error'
| string> {
class PluginLocal extends EventEmitter<
'loaded' | 'unloaded' | 'beforeunload' | 'error' | string
> {
private _sdk: Partial<PluginLocalSDKMetadata> = {}
private _disposes: Array<() => Promise<any>> = []
private _id: PluginLocalIdentity
Expand Down Expand Up @@ -534,7 +532,7 @@ class PluginLocal extends EventEmitter<'loaded'
const localRoot = (this._localRoot = safetyPathNormalize(url))
const logseq: Partial<LSPluginPkgConfig> = pkg.logseq || {}

// Pick legal attrs
// Pick legal attrs
;[
'name',
'author',
Expand Down Expand Up @@ -594,7 +592,9 @@ class PluginLocal extends EventEmitter<'loaded'
// Validate id
const { registeredPlugins, isRegistering } = this._ctx
if (isRegistering && registeredPlugins.has(this.id)) {
throw new ExistedImportedPluginPackageError('Registered plugin package Error')
throw new ExistedImportedPluginPackageError(
'Registered plugin package Error'
)
}

return async () => {
Expand Down Expand Up @@ -642,10 +642,10 @@ class PluginLocal extends EventEmitter<'loaded'
<meta charset="UTF-8">
<title>logseq plugin entry</title>
${
IS_DEV
? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
: `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
}
IS_DEV
? `<script src="${sdkPathRoot}/lsplugin.user.js?v=${tag}"></script>`
: `<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${tag}"></script>`
}
</head>
<body>
Expand Down Expand Up @@ -924,7 +924,7 @@ class PluginLocal extends EventEmitter<'loaded'
)
this.emit('beforeunload', eventBeforeUnload)
} catch (e) {
this.logger.error('[beforeunload Error]', e)
this.logger.error('[beforeunload]', e)
}

await this.dispose()
Expand Down Expand Up @@ -1103,7 +1103,8 @@ class LSPluginCore
| 'beforereload'
| 'reloaded'
>
implements ILSPluginThemeManager {
implements ILSPluginThemeManager
{
private _isRegistering = false
private _readyIndicator?: DeferredActor
private readonly _hostMountedActor: DeferredActor = deferred()
Expand All @@ -1117,8 +1118,10 @@ class LSPluginCore
externals: [],
}
private readonly _registeredThemes = new Map<PluginLocalIdentity, Theme[]>()
private readonly _registeredPlugins = new Map<PluginLocalIdentity,
PluginLocal>()
private readonly _registeredPlugins = new Map<
PluginLocalIdentity,
PluginLocal
>()
private _currentTheme: {
pid: PluginLocalIdentity
opt: Theme | LegacyTheme
Expand Down Expand Up @@ -1194,14 +1197,18 @@ class LSPluginCore
return
}

const perfTable = new Map<string,
{ o: PluginLocal; s: number; e: number }>()
const perfTable = new Map<
string,
{ o: PluginLocal; s: number; e: number }
>()
const debugPerfInfo = () => {
const data: any = Array.from(perfTable.values()).reduce((ac, it) => {
const { id, options, status, disabled } = it.o

if (disabled !== true &&
(options.entry || (!options.name && !options.entry))) {
if (
disabled !== true &&
(options.entry || (!options.name && !options.entry))
) {
ac[id] = {
name: options.name,
entry: options.entry,
Expand Down Expand Up @@ -1234,17 +1241,19 @@ class LSPluginCore
// valid externals
if (externals?.size) {
try {
const validatedExternals: Record<string, boolean> = await invokeHostExportedApi(
'validate_external_plugins', [...externals]
)
const validatedExternals: Record<string, boolean> =
await invokeHostExportedApi('validate_external_plugins', [
...externals,
])

externals = new Set([...Object.entries(validatedExternals)].reduce(
(a, [k, v]) => {
externals = new Set(
[...Object.entries(validatedExternals)].reduce((a, [k, v]) => {
if (v) {
a.push(k)
}
return a
}, []))
}, [])
)
} catch (e) {
console.error('[validatedExternals Error]', e)
}
Expand Down Expand Up @@ -1557,12 +1566,12 @@ class LSPluginCore
await this.saveUserPreferences(
theme.mode
? {
themes: {
...this._userPreferences.themes,
mode: theme.mode,
[theme.mode]: theme,
},
}
themes: {
...this._userPreferences.themes,
mode: theme.mode,
[theme.mode]: theme,
},
}
: { theme: theme }
)
}
Expand Down
Loading

0 comments on commit 8851b46

Please sign in to comment.