fix hub compatible export

This commit is contained in:
Ruben Fiszel
2023-04-11 18:33:45 +02:00
parent 6c091b4a12
commit 104229c01d
6 changed files with 30 additions and 13 deletions
@@ -1,5 +1,5 @@
<script lang="ts">
import { getContext } from 'svelte'
import { getContext, onMount } from 'svelte'
import { initOutput } from '../../editor/appUtils'
import type {
ConnectedAppInput,
@@ -16,13 +16,20 @@
export let fields: Record<string, StaticAppInput | ConnectedAppInput | RowAppInput | UserAppInput>
export let recomputeOnInputChanged: boolean
export let recomputableByRefreshButton: boolean
export let noBackendValue: any = undefined
let result: any = undefined
const { worldStore, staticExporter, noBackend } = getContext<AppViewerContext>('AppViewerContext')
const { worldStore } = getContext<AppViewerContext>('AppViewerContext')
let result: any = noBackend ? noBackendValue : undefined
onMount(() => {
$staticExporter[id] = () => {
return result
}
})
let outputs = initOutput($worldStore, id, {
result: undefined,
result: result,
loading: false
})
</script>
@@ -53,7 +53,9 @@
result = componentInput?.['value']
}
onMount(() => {
$staticExporter[id] = () => result
$staticExporter[id] = () => {
return result
}
})
function isRunnableDefined(componentInput) {
@@ -172,6 +172,7 @@
fields={script.fields}
recomputeOnInputChanged={script.recomputeOnInputChanged ?? true}
recomputableByRefreshButton={script.autoRefresh ?? false}
noBackendValue={script.noBackendValue}
/>
{/if}
{/each}
@@ -53,13 +53,14 @@ export function selectId(
app: App
) {
// this ensure handleClickOutside are triggered
window.dispatchEvent(
new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
})
)
let event = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true,
relatedTarget: e.target
})
window.dispatchEvent(event)
if (e.shiftKey) {
selectedComponent.update((old) => {
if (old && old?.[0]) {
@@ -117,6 +117,7 @@ export type App = {
//deprecated and to be removed after migration
doNotRecomputeOnInputChanged?: boolean
recomputeOnInputChanged?: boolean
noBackendValue?: any
}>
css?: Partial<Record<AppCssItemName, Record<string, ComponentCssProperty>>>
subgrids?: Record<string, GridItem[]>
+6 -1
View File
@@ -160,12 +160,17 @@ export function toStatic(
summary: string
): { app: App; summary: string } {
const newApp: App = JSON.parse(JSON.stringify(app))
newApp.grid.forEach((x) => {
allItems(newApp.grid, newApp.subgrids).forEach((x) => {
let c: AppComponent = x.data
if (c.componentInput?.type == 'runnable') {
c.componentInput.value = staticExporter[x.id]()
}
})
newApp.hiddenInlineScripts?.forEach((x, i) => {
x.noBackendValue = staticExporter[`bg_` + i]()
})
return { app: newApp, summary }
}