fix compile

This commit is contained in:
Ruben Fiszel
2023-03-13 20:59:27 +01:00
parent c958480ce8
commit 5662fa0d09
5 changed files with 24 additions and 22 deletions

View File

@@ -9,9 +9,7 @@
...new Set(
workers
.filter((worker) => {
const date = new Date().getTime() - 300 * 60
const ping_at = new Date(worker.ping_at).getTime()
return worker.ip != 'unretrievable IP' && ping_at > date
return worker.ip != 'unretrievable IP' && worker.last_ping && worker.last_ping < 300
})
.map((worker) => worker.ip)
)

View File

@@ -27,7 +27,7 @@
export let fields: Record<string, AppInput> = {}
export let syncFields: boolean = false
const { runnableComponents, stateId, worldStore } =
const { runnableComponents, stateId, worldStore, state } =
getContext<AppViewerContext>('AppViewerContext')
let editor: Editor
@@ -82,7 +82,7 @@
$: extraLib =
inlineScript.language == 'frontend' && worldStore
? buildExtraLib($worldStore?.outputsById ?? {}, id, false)
? buildExtraLib($worldStore?.outputsById ?? {}, id, false, $state, true)
: undefined
</script>

View File

@@ -40,7 +40,8 @@
selectedComponent,
worldStore,
focusedGrid,
stateId
stateId,
state
} = getContext<AppViewerContext>('AppViewerContext')
const { history } = getContext<AppEditorContext>('AppEditorContext')
@@ -70,7 +71,7 @@
$: extraLib =
component?.componentInput?.type === 'template' && $worldStore
? buildExtraLib($worldStore?.outputsById ?? {}, component?.id, false)
? buildExtraLib($worldStore?.outputsById ?? {}, component?.id, false, $state, false)
: undefined
function keydown(event: KeyboardEvent) {

View File

@@ -10,13 +10,13 @@
export let id: string
export let hasRows: boolean = false
const { onchange, worldStore } = getContext<AppViewerContext>('AppViewerContext')
const { onchange, worldStore, state } = getContext<AppViewerContext>('AppViewerContext')
$: componentInput && onchange?.()
$: extraLib =
componentInput?.expr && $worldStore
? buildExtraLib($worldStore?.outputsById ?? {}, id, hasRows)
? buildExtraLib($worldStore?.outputsById ?? {}, id, hasRows, $state, false)
: undefined
</script>

View File

@@ -162,21 +162,24 @@ export function toStatic(
export function buildExtraLib(
components: Record<string, Record<string, Output<any>>>,
idToExclude: string,
hasRows: boolean
hasRows: boolean,
state: Record<string, any>,
goto: boolean
): string {
return (
Object.entries(components)
.filter(([k, v]) => k != idToExclude)
.map(([k, v]) => [k, Object.fromEntries(Object.entries(v).map(([k, v]) => [k, v.peak()]))])
.map(
([k, v]) => `
declare const ${k} = ${JSON.stringify(v)};
const cs = Object.entries(components)
.filter(([k, v]) => k != idToExclude)
.map(([k, v]) => [k, Object.fromEntries(Object.entries(v).map(([k, v]) => [k, v.peak()]))])
.map(
([k, v]) => `declare const ${k}: ${JSON.stringify(v)};
`
)
.join('\n')
return `${cs}
${hasRows ? 'declare const row: Record<string, any>;' : ''}
${goto ? 'declare const goto: async (path: string) => void)' : ''}
declare const state: ${JSON.stringify(state)};
`
)
.join('\n') + (hasRows ? 'declare const row: Record<string, any>;' : '')
)
}
export function getAllScriptNames(app: App): string[] {