Skip to content

Commit

Permalink
fix: online deploy
Browse files Browse the repository at this point in the history
- no schemaFiles in worker
- no variants in menu
- NON-variant options will be updated on F4 schema change an should
  be ignored
  • Loading branch information
eagleoflqj committed Jun 1, 2023
1 parent 8f17314 commit af21761
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { PlaywrightTestConfig } from '@playwright/test'

const config: PlaywrightTestConfig = {
expect: { timeout: 10000 },
retries: 3,
webServer: {
command: 'pnpm run preview',
Expand Down
2 changes: 1 addition & 1 deletion src/components/MyMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ init(getQueryString('schemaId'), getQueryString('variantName')).then(() => {
})
const variantLabel = computed(() => showVariant.value && !deployed.value ? variant.value.name : '')
const singleVariant = computed(() => variants.value.length === 1)
const singleVariant = computed(() => !deployed.value && variants.value.length === 1)
watchEffect(() => {
localStorage.setItem('schemaId', ime.value)
Expand Down
2 changes: 1 addition & 1 deletion src/components/MyPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function insert (toInsert: string) {
async function input (rimeKey: string) {
const textarea = getTextarea(textareaSelector)
const result = JSON.parse(await process(rimeKey)) as RIME_RESULT
if (result.updatedOptions) {
if (!('updatedSchema' in result) && result.updatedOptions) {
syncOptions(result.updatedOptions)
}
if (result.state === 0) { // COMMITTED
Expand Down
17 changes: 15 additions & 2 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function getURL (target: string, name: string) {

const lazyCache = new LazyCache('ime')

async function setIME (schemaId: string) {
async function fetchPrebuilt (schemaId: string) {
const fetched: string[] = []
function getFiles (key: string) {
if (fetched.includes(key)) {
Expand Down Expand Up @@ -59,6 +59,12 @@ async function setIME (schemaId: string) {
Module.FS.writeFile(path, new Uint8Array(ab))
}
}))
}

async function setIME (schemaId: string) {
if (!deployed) {
await fetchPrebuilt(schemaId)
}
Module.ccall('set_ime', 'null', ['string'], [schemaId])
}

Expand All @@ -73,8 +79,15 @@ const readyPromise = loadWasm('rime.js', {
}
})

let deployed = false
const deployStatus = control('deployStatus')
// @ts-ignore
globalThis._deployStatus = control('deployStatus') // called from api.cpp
globalThis._deployStatus = (status: 'start' | 'failure' | 'success', schemas: string) => { // called from api.cpp
if (status === 'success') {
deployed = true
}
deployStatus(status, schemas)
}

expose({
fsOperate,
Expand Down

0 comments on commit af21761

Please sign in to comment.