mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
fix: fix app expr break
This commit is contained in:
@@ -271,7 +271,8 @@
|
||||
$mode == 'dnd',
|
||||
$componentControl,
|
||||
$worldStore,
|
||||
$runnableComponents
|
||||
$runnableComponents,
|
||||
false
|
||||
)
|
||||
error = ''
|
||||
return r
|
||||
@@ -295,7 +296,8 @@
|
||||
$mode == 'dnd',
|
||||
$componentControl,
|
||||
$worldStore,
|
||||
$runnableComponents
|
||||
$runnableComponents,
|
||||
false
|
||||
)
|
||||
error = ''
|
||||
return r
|
||||
|
||||
@@ -258,7 +258,8 @@
|
||||
isEditor,
|
||||
$componentControl,
|
||||
$worldStore,
|
||||
$runnableComponents
|
||||
$runnableComponents,
|
||||
true
|
||||
)
|
||||
|
||||
await setResult(r, job, setRunnableJobEditorPanel)
|
||||
@@ -459,7 +460,8 @@
|
||||
isEditor,
|
||||
$componentControl,
|
||||
$worldStore,
|
||||
$runnableComponents
|
||||
$runnableComponents,
|
||||
true
|
||||
)
|
||||
return transformerResult
|
||||
} catch (err) {
|
||||
|
||||
@@ -18,7 +18,11 @@ export function computeGlobalContext(world: World | undefined, extraContext: any
|
||||
}
|
||||
}
|
||||
|
||||
function create_context_function_template(eval_string: string, contextKeys: string[]) {
|
||||
function create_context_function_template(
|
||||
eval_string: string,
|
||||
contextKeys: string[],
|
||||
noReturn: boolean
|
||||
) {
|
||||
let hasReturnAsLastLine = eval_string.split('\n').some((x) => x.startsWith('return '))
|
||||
return `
|
||||
return async function (context, state, goto, setTab, recompute, getAgGrid, setValue, setSelectedIndex, openModal, closeModal, open, close, validate, invalidate, validateAll, clearFiles, showToast) {
|
||||
@@ -29,7 +33,7 @@ ${
|
||||
: ``
|
||||
}
|
||||
${
|
||||
hasReturnAsLastLine
|
||||
hasReturnAsLastLine || noReturn
|
||||
? eval_string
|
||||
: `
|
||||
return ${eval_string.startsWith('return ') ? eval_string.substring(7) : eval_string}`
|
||||
@@ -60,12 +64,12 @@ type WmFunctor = (
|
||||
) => Promise<any>
|
||||
|
||||
let functorCache: Record<number, WmFunctor> = {}
|
||||
function make_context_evaluator(eval_string, contextKeys: string[]): WmFunctor {
|
||||
function make_context_evaluator(eval_string, contextKeys: string[], noReturn: boolean): WmFunctor {
|
||||
let cacheKey = hashCode(JSON.stringify({ eval_string, contextKeys }))
|
||||
if (functorCache[cacheKey]) {
|
||||
return functorCache[cacheKey]
|
||||
}
|
||||
let template = create_context_function_template(eval_string, contextKeys)
|
||||
let template = create_context_function_template(eval_string, contextKeys, noReturn)
|
||||
let functor = Function(template)
|
||||
let r = functor()
|
||||
functorCache[cacheKey] = r
|
||||
@@ -139,7 +143,8 @@ export async function eval_like(
|
||||
}
|
||||
>,
|
||||
worldStore: World | undefined,
|
||||
runnableComponents: Record<string, { cb?: (() => void)[] }>
|
||||
runnableComponents: Record<string, { cb?: (() => void)[] }>,
|
||||
noReturn: boolean
|
||||
) {
|
||||
const proxiedState = new Proxy(state, {
|
||||
set(target, key, value) {
|
||||
@@ -157,7 +162,7 @@ export async function eval_like(
|
||||
}
|
||||
})
|
||||
|
||||
let evaluator = make_context_evaluator(text, Object.keys(context ?? {}))
|
||||
let evaluator = make_context_evaluator(text, Object.keys(context ?? {}), noReturn)
|
||||
// console.log(i, j)
|
||||
return await evaluator(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user