Skip to content

Commit

Permalink
0.9.9: sync rime-emoji
Browse files Browse the repository at this point in the history
- sync micro plum 0.2.0
  • Loading branch information
eagleoflqj committed Aug 25, 2023
1 parent d31828f commit f9c769a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 26 deletions.
4 changes: 2 additions & 2 deletions checksum
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
1af97e7578a6b23af1aff33269acf462 public/rime.data
f73f21d42788c637e143c42d0e963fab public/rime.js
f6a0288a806954b8c0f1d34148aa43e1 public/rime.data
b5b59a5c5fa068d6c05643328ddf088a public/rime.js
d33690333f83dda1e42f6efa2e6b2e0c public/rime.wasm
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libreservice/my-rime",
"version": "0.9.8",
"version": "0.9.9",
"files": [
"dist"
],
Expand Down Expand Up @@ -43,7 +43,7 @@
"devDependencies": {
"@codemirror/legacy-modes": "^6.3.3",
"@libreservice/lazy-cache": "^0.1.1",
"@libreservice/micro-plum": "^0.1.10",
"@libreservice/micro-plum": "^0.2.0",
"@libreservice/my-widget": "^0.1.4",
"@libreservice/my-worker": "^0.4.2",
"@libreservice/wasm-code": "^0.1.2",
Expand All @@ -61,7 +61,7 @@
"client-zip": "^2.4.4",
"emoji-regex": "^10.2.1",
"esbuild": "^0.19.2",
"eslint": "^8.47.0",
"eslint": "^8.48.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.0.2",
Expand All @@ -79,7 +79,7 @@
"textarea-caret": "^3.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-pwa": "^0.16.4",
"vite-plugin-run": "^0.4.1",
Expand Down
13 changes: 8 additions & 5 deletions scripts/install_schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { spawnSync } from 'child_process'
import { readFileSync, writeFileSync, mkdirSync, copyFileSync, readdirSync, cpSync, rmSync } from 'fs'
import { cwd, chdir, exit } from 'process'
import yaml from 'js-yaml'
import { Recipe } from '@libreservice/micro-plum'
import {
Recipe,
GitHubDownloader
} from '@libreservice/micro-plum'
import { rf, utf8, ensure, md5sum } from './util.js'
import packageJson from '../package.json' assert { type: 'json' }
import schemas from '../schemas.json' assert { type: 'json' }
Expand Down Expand Up @@ -89,7 +92,7 @@ mkdirSync(`${RIME_DIR}/opencc`, { recursive: true })
for (const fileName of readdirSync('rime-config')) {
cpSync(`rime-config/${fileName}`, `${RIME_DIR}/${fileName}`, { recursive: true })
}
await Promise.all(['prelude', 'essay', 'emoji'].map(target => install(new Recipe(target))))
await Promise.all(['prelude', 'essay', 'emoji'].map(target => install(new Recipe(new GitHubDownloader(target)))))

// remove emoji_category as I don't want to visit a zoo when I type 东吴
const emojiJson = `${RIME_DIR}/opencc/emoji.json`
Expand All @@ -101,8 +104,8 @@ writeFileSync(emojiJson, JSON.stringify(emojiContent))
rmSync(emojiCategory, rf)

for (const schema of schemas) {
const recipe = new Recipe(schema.target, { schemaIds: [schema.id] })
const target = recipe.repo.match(/(rime\/rime-)?(.*)/)![2]
const recipe = new Recipe(new GitHubDownloader(schema.target, [schema.id]))
const target = recipe.loader.repo.match(/(rime\/rime-)?(.*)/)![2]
if (!(target in targetManifest)) {
targetManifest[target] = []
targetFiles[target] = []
Expand All @@ -122,7 +125,7 @@ for (const schema of schemas) {
if (schema.family) {
// @ts-ignore
for (const { id, name, disabled } of schema.family) {
recipe.schemaIds.push(id)
recipe.loader.schemaIds.push(id)
ids.push(id)
schemaTarget[id] = target
if (disabled) {
Expand Down
16 changes: 11 additions & 5 deletions src/components/micro-plum/InstallPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {
NIcon
} from 'naive-ui'
import { Add12Regular } from '@vicons/fluent'
import { normalizeTarget, Recipe } from '@libreservice/micro-plum'
import {
normalizeTarget,
Recipe,
GitHubDownloader,
JsDelivrDownloader
} from '@libreservice/micro-plum'
import {
prerequisites,
install,
Expand Down Expand Up @@ -97,18 +102,19 @@ async function onClick () {
}
downloading.value = true
try {
const Downloader = source.value === 'jsDelivr' ? JsDelivrDownloader : GitHubDownloader
if (installPrerequisites.value) {
installedPrerequisites.value = true
await Promise.all(prerequisites.map(prerequisite => install(prerequisite)))
await Promise.all(prerequisites.map(prerequisite => install(new Downloader(prerequisite))))
}
let recipe: Recipe | undefined
if (mode.value === 'plum' && target.value) {
recipe = await install(target.value, { schemaIds: schemas.value, source: source.value })
recipe = await install(new Downloader(target.value, schemas.value))
} else if (mode.value === 'schema' && schemaURL.value) {
recipe = await install(schemaURL.value, { source: source.value })
recipe = await install(new Downloader(schemaURL.value))
}
if (recipe) {
preSelectedSchemas.value = recipe.schemaIds
preSelectedSchemas.value = recipe.loader.schemaIds
}
tab.value = 'deploy'
} catch (e) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/micro-plum/ManifestPane.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
CHILD_INDEX
} from 'rppi'
import { LazyCache } from '@libreservice/lazy-cache'
import { GitHubDownloader } from '@libreservice/micro-plum'
import {
prerequisites,
install
Expand Down Expand Up @@ -157,14 +158,14 @@ updateIndex()
function installRepo (repo: string) {
const recipe = keyRecipeMap[repoKeyMap[repo]]
const target = recipe.branch ? `${repo}@${recipe.branch}` : repo
return install(target, { schemaIds: recipe.schemas })
return install(new GitHubDownloader(target, recipe.schemas))
}
async function onClick () {
downloading.value = true
try {
if (!installedPrerequisites.value) {
await Promise.all(prerequisites.map(prerequisite => install(prerequisite)))
await Promise.all(prerequisites.map(prerequisite => install(new GitHubDownloader(prerequisite))))
installedPrerequisites.value = true
}
const { repo, dependencies } = keyRecipeMap[selectedKey.value!]
Expand Down
5 changes: 3 additions & 2 deletions src/control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
customizeDefault,
getAvailableSchemas
} from './micro-plum'
import { GitHubDownloader } from '@libreservice/micro-plum'

const text = ref<string>('')

Expand Down Expand Up @@ -243,9 +244,9 @@ async function installFromQueryString () {
}
if (plum.length) {
if (missing) {
await Promise.all(prerequisites.map(prerequisite => install(prerequisite)))
await Promise.all(prerequisites.map(prerequisite => install(new GitHubDownloader(prerequisite))))
for (const { target, schemaIds } of plum) {
await install(target, { schemaIds })
await install(new GitHubDownloader(target, schemaIds))
}
}
await customizeDefault(plum.flatMap(({ schemaIds }) => schemaIds))
Expand Down
13 changes: 7 additions & 6 deletions src/micro-plum.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useMessage } from 'naive-ui'
import yaml from 'js-yaml'
import { Recipe } from '@libreservice/micro-plum'
import {
Downloader,
Recipe
} from '@libreservice/micro-plum'
import { FS } from './workerAPI'

const RIME_PATH = '/rime'
Expand Down Expand Up @@ -28,11 +31,9 @@ async function ensureDir (path: string) {
}
}

async function install (target: string, options?: { schemaIds?: string[], source?: 'GitHub' | 'jsDelivr' }) {
const recipe = new Recipe(target, {
source: options?.source,
schemaIds: options?.schemaIds,
onDownloadFailure (url: string, reason: number | string) {
async function install (downloader: Downloader) {
const recipe = new Recipe(downloader, {
onLoadFailure (url: string, reason: number | string) {
message.error(`Fail to download ${url.slice(url.lastIndexOf('/') + 1)}: ${reason}`)
}
})
Expand Down

0 comments on commit f9c769a

Please sign in to comment.