-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
440 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Files from gdspx/spx output while useless for Go+ Builder | ||
diff.zip | ||
favicon.png | ||
game.zip | ||
index.html | ||
logo.svg | ||
manifest.json | ||
offline.html | ||
service-worker.js | ||
|
||
# For now it costs time to build the wasm file, we commit them to simplify the deployment | ||
# TODO: Build wasm files on the fly | ||
!*.wasm |
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file not shown.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Runner Public Files | ||
|
||
These files collectively function as the "project runner". | ||
|
||
They are expected to be included in the releases of [gdspx](https://github.com/realdream-ai/gdspx) and [spx](https://github.com/goplus/spx/tree/dev). Currently, we manually copy and paste the versioned files from @JiepengTan. TODO: We plan to automate this process in the future. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,40 @@ | ||
<template> | ||
<div class="iframe-container"> | ||
<IframeDisplay v-if="zipData" :zip-data="zipData" @console="handleConsole" @loaded="loading = false" /> | ||
<UIImg v-show="zipData == null || loading" class="thumbnail" :src="thumbnailUrl" :loading="thumbnailUrlLoading" /> | ||
<UILoading :visible="loading" cover /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import IframeDisplay, { preload } from './IframeDisplay.vue' | ||
export { preload } | ||
</script> | ||
|
||
<script lang="ts" setup> | ||
import { onUnmounted, ref } from 'vue' | ||
import { registerPlayer } from '@/utils/player-registry' | ||
import { useFileUrl } from '@/utils/file' | ||
import { Project } from '@/models/project' | ||
import { UIImg, UILoading } from '@/components/ui' | ||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { getSpxVersion, useLocalStorage } from '@/utils/utils' | ||
import type { Project } from '@/models/project' | ||
import ProjectRunnerV1 from './v1/ProjectRunnerV1.vue' | ||
import ProjectRunnerV2 from './v2/ProjectRunnerV2.vue' | ||
const props = defineProps<{ project: Project }>() | ||
const zipData = ref<ArrayBuffer | null>(null) | ||
const loading = ref(false) | ||
const emit = defineEmits<{ | ||
console: [type: 'log' | 'warn', args: unknown[]] | ||
}>() | ||
const [thumbnailUrl, thumbnailUrlLoading] = useFileUrl(() => props.project.thumbnail) | ||
const projectRunnerRef = ref<InstanceType<typeof ProjectRunnerV1> | InstanceType<typeof ProjectRunnerV2>>() | ||
const handleConsole = (type: 'log' | 'warn', args: unknown[]) => { | ||
function handleConsole(type: 'log' | 'warn', args: unknown[]) { | ||
emit('console', type, args) | ||
} | ||
const registered = registerPlayer(() => { | ||
// For now we don't need to implement stop handler here because there's no chance for | ||
// the user to activate another audio player when `ProjectRunner` visible. | ||
// If you see this warning in console, you need to think what the proper behavior is. | ||
console.warn('unexpected call') | ||
}) | ||
onUnmounted(() => { | ||
registered.onStopped() | ||
}) | ||
const version = useLocalStorage('spx-gui-runner', 'v1') | ||
const specifiedVersion = getSpxVersion() | ||
if (specifiedVersion != null) version.value = specifiedVersion | ||
defineExpose({ | ||
async run() { | ||
loading.value = true | ||
registered.onStart() | ||
const gbpFile = await props.project.exportGbpFile() | ||
zipData.value = await gbpFile.arrayBuffer() | ||
run() { | ||
projectRunnerRef.value?.run() | ||
}, | ||
stop() { | ||
zipData.value = null | ||
registered.onStopped() | ||
projectRunnerRef.value?.stop() | ||
}, | ||
rerun() { | ||
this.stop() | ||
return this.run() | ||
projectRunnerRef.value?.rerun() | ||
} | ||
}) | ||
</script> | ||
<style scoped lang="scss"> | ||
.iframe-container { | ||
position: relative; | ||
aspect-ratio: 4 / 3; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.thumbnail { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
} | ||
</style> | ||
<template> | ||
<ProjectRunnerV2 v-if="version === 'v2'" ref="projectRunnerRef" v-bind="props" @console="handleConsole" /> | ||
<ProjectRunnerV1 v-else v-bind="props" ref="projectRunnerRef" @console="handleConsole" /> | ||
</template> |
File renamed without changes.
80 changes: 80 additions & 0 deletions
80
spx-gui/src/components/project/runner/v1/ProjectRunnerV1.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<template> | ||
<div class="iframe-container"> | ||
<IframeDisplay v-if="zipData" :zip-data="zipData" @console="handleConsole" @loaded="loading = false" /> | ||
<UIImg v-show="zipData == null || loading" class="thumbnail" :src="thumbnailUrl" :loading="thumbnailUrlLoading" /> | ||
<UILoading :visible="loading" cover /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { onMounted, onUnmounted, ref } from 'vue' | ||
import { registerPlayer } from '@/utils/player-registry' | ||
import { useFileUrl } from '@/utils/file' | ||
import { Project } from '@/models/project' | ||
import { UIImg, UILoading } from '@/components/ui' | ||
import IframeDisplay, { preload } from './IframeDisplay.vue' | ||
const props = defineProps<{ project: Project }>() | ||
const zipData = ref<ArrayBuffer | null>(null) | ||
const loading = ref(false) | ||
const emit = defineEmits<{ | ||
console: [type: 'log' | 'warn', args: unknown[]] | ||
}>() | ||
const [thumbnailUrl, thumbnailUrlLoading] = useFileUrl(() => props.project.thumbnail) | ||
const handleConsole = (type: 'log' | 'warn', args: unknown[]) => { | ||
emit('console', type, args) | ||
} | ||
onMounted(() => { | ||
preload() | ||
}) | ||
const registered = registerPlayer(() => { | ||
// For now we don't need to implement stop handler here because there's no chance for | ||
// the user to activate another audio player when `ProjectRunner` visible. | ||
// If you see this warning in console, you need to think what the proper behavior is. | ||
console.warn('unexpected call') | ||
}) | ||
onUnmounted(() => { | ||
registered.onStopped() | ||
}) | ||
defineExpose({ | ||
async run() { | ||
loading.value = true | ||
registered.onStart() | ||
const gbpFile = await props.project.exportGbpFile() | ||
zipData.value = await gbpFile.arrayBuffer() | ||
}, | ||
stop() { | ||
zipData.value = null | ||
registered.onStopped() | ||
}, | ||
rerun() { | ||
this.stop() | ||
return this.run() | ||
} | ||
}) | ||
</script> | ||
<style scoped lang="scss"> | ||
.iframe-container { | ||
position: relative; | ||
aspect-ratio: 4 / 3; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.thumbnail { | ||
position: absolute; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
} | ||
</style> |
Oops, something went wrong.