Finishing link up of logs.
This commit is contained in:
parent
28958f5a1c
commit
d3a2306787
|
@ -12,7 +12,7 @@
|
|||
decodeJSBinding,
|
||||
encodeJSBinding,
|
||||
processObjectSync,
|
||||
processStringSync,
|
||||
processStringWithLogsSync,
|
||||
} from "@budibase/string-templates"
|
||||
import { readableToRuntimeBinding } from "@/dataBinding"
|
||||
import CodeEditor from "../CodeEditor/CodeEditor.svelte"
|
||||
|
@ -41,6 +41,7 @@
|
|||
InsertAtPositionFn,
|
||||
JSONValue,
|
||||
} from "@budibase/types"
|
||||
import type { Log } from "@budibase/string-templates"
|
||||
import type { CompletionContext } from "@codemirror/autocomplete"
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
@ -66,6 +67,7 @@
|
|||
let insertAtPos: InsertAtPositionFn | undefined
|
||||
let targetMode: BindingMode | null = null
|
||||
let expressionResult: string | undefined
|
||||
let expressionLogs: Log[] | undefined
|
||||
let expressionError: string | undefined
|
||||
let evaluating = false
|
||||
|
||||
|
@ -157,7 +159,7 @@
|
|||
(expression: string | null, context: any, snippets: Snippet[]) => {
|
||||
try {
|
||||
expressionError = undefined
|
||||
expressionResult = processStringSync(
|
||||
const output = processStringWithLogsSync(
|
||||
expression || "",
|
||||
{
|
||||
...context,
|
||||
|
@ -167,6 +169,8 @@
|
|||
noThrow: false,
|
||||
}
|
||||
)
|
||||
expressionResult = output.result
|
||||
expressionLogs = output.logs
|
||||
} catch (err: any) {
|
||||
expressionResult = undefined
|
||||
expressionError = err
|
||||
|
@ -421,6 +425,7 @@
|
|||
<EvaluationSidePanel
|
||||
{expressionResult}
|
||||
{expressionError}
|
||||
{expressionLogs}
|
||||
{evaluating}
|
||||
expression={editorValue ? editorValue : ""}
|
||||
/>
|
||||
|
|
|
@ -4,20 +4,21 @@
|
|||
import { Helpers } from "@budibase/bbui"
|
||||
import { fade } from "svelte/transition"
|
||||
import { UserScriptError } from "@budibase/string-templates"
|
||||
import type { Log } from "@budibase/string-templates"
|
||||
import type { JSONValue } from "@budibase/types"
|
||||
|
||||
// this can be essentially any primitive response from the JS function
|
||||
export let expressionResult: JSONValue | undefined = undefined
|
||||
export let expressionError: string | undefined = undefined
|
||||
export let expressionLogs: Log[] = []
|
||||
export let evaluating = false
|
||||
export let expression: string | null = null
|
||||
export let logging: { log: string; line?: number }[] = []
|
||||
|
||||
$: error = expressionError != null
|
||||
$: empty = expression == null || expression?.trim() === ""
|
||||
$: success = !error && !empty
|
||||
$: highlightedResult = highlight(expressionResult)
|
||||
$: highlightedLogs = logging.map(l => ({
|
||||
$: highlightedLogs = expressionLogs.map(l => ({
|
||||
log: highlight(l.log),
|
||||
line: l.line,
|
||||
}))
|
||||
|
|
|
@ -18,6 +18,7 @@ import manifest from "./manifest.json"
|
|||
import { Log, ProcessOptions } from "./types"
|
||||
import { UserScriptError } from "./errors"
|
||||
|
||||
export type { Log } from "./types"
|
||||
export { helpersToRemoveForJs, getJsHelperList } from "./helpers/list"
|
||||
export { FIND_ANY_HBS_REGEX } from "./utilities"
|
||||
export { setJSRunner, setOnErrorLog } from "./helpers/javascript"
|
||||
|
|
Loading…
Reference in New Issue