dx: resolved build-time warning
Massimo Melina committed
Sep 4, 2025 at 15:41 UTC
8a3d7907fc94db85153bbb9b102b87586e6fc591
2 files changed
+10
-6
admin/src/InstalledPlugins.ts
+8
-4
@@ -22,10 +22,14 @@ import { Btn, Flex, hTooltip, IconBtn, iconTooltip, NetmaskField, usePauseButton
22
import VfsPathField from './VfsPathField'
23
import { DateTimeField } from './DateTimeField'
24
25
+function evalWrapper(s: string) {
26
+ return eval(s)
27
+}
28
+
29
// updates=true will show the "check updates" version of the page
30
export default function InstalledPlugins({ updates }: { updates?: true }) {
31
const { list, error, setList, initializing } = useApiList(updates ? 'get_plugin_updates' : 'get_plugins', {}, {
28
- map(x: any) { x.config &&= tryJson(x.config, s => eval('()=>('+s+')')()) }
32
+ map(x: any) { x.config &&= tryJson(x.config, s => evalWrapper('()=>('+s+')')()) }
33
})
34
useEffect(() => {
35
setList(list =>
@@ -252,9 +256,9 @@ function makeFields(config: any, values: any) {
256
if (!o) return
257
let { type, defaultValue, frontend, showIf, ...rest } = o
258
try {
255
- rest.getError = eval(rest.getError)
259
+ rest.getError = evalWrapper(rest.getError)
260
if (typeof showIf === 'string') // compile once
257
- rest.showIf = showIf = eval(showIf) // eval is normally considered a threat, but this code is coming from a plugin that's already running on your server, so you already decided to trust it. Here it will run in your browser, and inside the page that administrating the same server.
261
+ rest.showIf = showIf = evalWrapper(showIf) // eval is normally considered a threat, but this code is coming from a plugin that's already running on your server, so you already decided to trust it. Here it will run in your browser, and inside the page that administrating the same server.
262
if (showIf && !showIf(values))
263
return
264
}
@@ -267,7 +271,7 @@ function makeFields(config: any, values: any) {
271
let {fields} = rest
272
rest.valuesForAdd = newObj(callable(fields, false), x => x.defaultValue)
273
if (typeof fields === 'string')
270
- fields = eval(fields)
274
+ fields = evalWrapper(fields)
275
rest.details ??= false
276
rest.fields = (values: unknown) => _.map(makeFields(callable(fields, values), values), (v,k) => v && ({ k, ...v, defaultValue: undefined })).filter(Boolean)
277
}
frontend/vite.config.ts
+2
-2
@@ -6,7 +6,7 @@ export default defineConfig({
6
build: {
7
outDir: '../dist/frontend',
8
emptyOutDir: true,
9
- target: "chrome69",
9
+ //target: "chrome69",
10
},
11
server: {
12
port: 3005,
@@ -24,7 +24,7 @@ export default defineConfig({
24
legacy({
25
renderModernChunks: false, // single version, legacy one
26
polyfills: false, // keeping polyfills at a minimum, manually
27
- targets: ['firefox 40'],
27
+ targets: ['firefox 40', 'chrome 69'],
28
}),
29
],
30
})