plugins: api.misc
Massimo Melina committed
Jun 27, 2024 at 12:57 UTC
367097876e2abf22294707f6cb04218c609e6db7
2 files changed
+10
-1
dev-plugins.md
+8
-1
@@ -129,7 +129,9 @@ Currently, these properties are supported:
129
- `defaultValue: any` value to be used when nothing is set.
130
- `helperText: string` extra text printed next to the field.
131
- `frontend: boolean` expose this setting on the frontend, so that javascript can access it
132
- using `HFS.getPluginConfig()[CONFIG_KEY]` but also css can access it as `var(--PLUGIN_NAME-CONFIG_KEY)`
132
+ using `HFS.getPluginConfig()[CONFIG_KEY]` but also css can access it as `var(--PLUGIN_NAME-CONFIG_KEY)`.
133
+ Hint: if you need to use a numeric config in CSS but you need to add a unit (like `em`),
134
+ the trick is to use something like this `calc(var(--plugin-something) * 1em)`.
135
136
Based on `type`, other properties are supported:
137
- `string`
@@ -216,6 +218,10 @@ The `api` object you get as parameter of the `init` contains the following:
218
219
- `notifyClient(channel: string, eventName: string, data?: any)` send a message to those frontends that are on the same channel.
220
221
+- `misc` many functions and constants available in [misc.ts](https://github.com/rejetto/hfs/blob/main/src/misc.ts).
222
+ These are not documented, probably never will, and are subject to change without notifications,
223
+ but you can study the sources if you are interested in using them. It's just a shorter version of `api.require('./misc')`
224
+
225
## Front-end specific
226
227
The following information applies to the default front-end, and may not apply to a custom one.
@@ -623,6 +629,7 @@ If you want to override a text regardless of the language, use the special langu
629
- 8.9 (v0.54.0)
630
- frontend event: showPlay
631
- api.addBlock
632
+ - api.misc
633
- 8.891 (v0.53.0)
634
- api.openDb
635
- frontend event: menuZip
src/plugins.ts
+2
@@ -11,6 +11,7 @@ import {
11
adjustStaticPathForGlob, callable, Callback, debounceAsync, Dict, getOrSet, objSameKeys, onlyTruthy,
12
PendingPromise, pendingPromise, Promisable, same, tryJson, wait, waitFor, wantArray, watchDir
13
} from './misc'
14
+import * as misc from './misc'
15
import { defineConfig, getConfig } from './config'
16
import { DirEntry } from './api.get_file_list'
17
import { VfsNode } from './vfs'
@@ -115,6 +116,7 @@ async function initPlugin<T>(pl: any, morePassedToInit?: T) {
116
customApiCall,
117
notifyClient,
118
addBlock,
119
+ misc,
120
...morePassedToInit
121
}))
122
}