From 7edc231e89e75456afca9036e52c4faa32d6cb6b Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Mon, 27 Feb 2023 23:19:19 -0500 Subject: [PATCH] feat(directory): removed portrait and add cache for image and audio --- Version | 2 +- aklive2d.js | 5 +- config/_template.yaml | 3 +- config/chen.yaml | 3 +- config/chongyue.yaml | 3 +- config/dusk.yaml | 3 +- config/dusk_everything_is_a_miracle.yaml | 3 +- config/gavial.yaml | 3 +- config/lee_trust_your_eyes.yaml | 3 +- config/ling.yaml | 3 +- config/ling_it_does_wash_the_strings.yaml | 3 +- config/mizuki_summer_feast.yaml | 3 +- config/nearl.yaml | 3 +- config/nearl_relight.yaml | 3 +- config/nian.yaml | 3 +- config/nian_unfettered_freedom.yaml | 3 +- config/passager_dream_in_a_moment.yaml | 3 +- config/phatom_focus.yaml | 3 +- config/pozemka_snowy_plains_in_words.yaml | 3 +- config/rosmontis.yaml | 3 +- config/rosmontis_become_anew.yaml | 3 +- config/skadi.yaml | 3 +- config/skadi_sublimation.yaml | 3 +- config/specter.yaml | 3 +- config/surtr_colorful_wonderland.yaml | 3 +- config/texas_the_omertosa.yaml | 3 +- config/w.yaml | 3 +- config/w_wonder.yaml | 3 +- directory/.env | 2 +- directory/Version | 2 +- directory/src/context/useHeaderContext.jsx | 6 +- directory/src/db/index.js | 9 ++ directory/src/i18n.json | 4 - directory/src/routes/path/home.css | 5 - directory/src/routes/path/home.jsx | 134 +++++++++------------ directory/src/routes/root.jsx | 8 +- libs/assets_processor.js | 5 +- libs/directory.js | 3 - package.json | 3 +- pnpm-lock.yaml | 44 ++++--- vite.config.js | 1 - 41 files changed, 127 insertions(+), 184 deletions(-) create mode 100644 directory/src/db/index.js diff --git a/Version b/Version index f9f89f5..a8bf53a 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -3.3.10 \ No newline at end of file +3.3.11 \ No newline at end of file diff --git a/aklive2d.js b/aklive2d.js index 3539aa3..247577f 100644 --- a/aklive2d.js +++ b/aklive2d.js @@ -120,10 +120,7 @@ async function main() { const assetsProcessor = new AssetsProcessor(OPERATOR_NAME, OPERATOR_SHARE_FOLDER) assetsProcessor.process(EXTRACTED_FOLDER).then((content) => { - write(JSON.stringify(content.landscape.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets.json`)) - if (__config.operators[OPERATOR_NAME].portrait) { - write(JSON.stringify(content.portrait.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets_portrait.json`)) - } + write(JSON.stringify(content.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets.json`)) }) const filesToCopy = [ diff --git a/config/_template.yaml b/config/_template.yaml index 1d13bc1..bf145b7 100644 --- a/config/_template.yaml +++ b/config/_template.yaml @@ -10,5 +10,4 @@ invert_filter: false color: rgba(14, 126, 239, 0.85) codename: zh-CN: 假日威龙陈 - en-US: Ch'en/Chen the Holungday -portrait: null \ No newline at end of file + en-US: Ch'en/Chen the Holungday \ No newline at end of file diff --git a/config/chen.yaml b/config/chen.yaml index 1d13bc1..bf145b7 100644 --- a/config/chen.yaml +++ b/config/chen.yaml @@ -10,5 +10,4 @@ invert_filter: false color: rgba(14, 126, 239, 0.85) codename: zh-CN: 假日威龙陈 - en-US: Ch'en/Chen the Holungday -portrait: null \ No newline at end of file + en-US: Ch'en/Chen the Holungday \ No newline at end of file diff --git a/config/chongyue.yaml b/config/chongyue.yaml index 3be46a1..fedd4ab 100644 --- a/config/chongyue.yaml +++ b/config/chongyue.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(255, 133, 34) codename: zh-CN: 重岳 - en-US: Chongyue -portrait: null \ No newline at end of file + en-US: Chongyue \ No newline at end of file diff --git a/config/dusk.yaml b/config/dusk.yaml index 1641ae3..e3b25f3 100644 --- a/config/dusk.yaml +++ b/config/dusk.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(9, 212, 208) codename: zh-CN: 夕 - en-US: Dusk -portrait: null \ No newline at end of file + en-US: Dusk \ No newline at end of file diff --git a/config/dusk_everything_is_a_miracle.yaml b/config/dusk_everything_is_a_miracle.yaml index fd3c47b..723f9f4 100644 --- a/config/dusk_everything_is_a_miracle.yaml +++ b/config/dusk_everything_is_a_miracle.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(78, 201, 187) codename: zh-CN: 染尘烟 · 夕 - en-US: Everything is a Miracle / Dusk -portrait: dyn_portrait_char_2015_dusk_nian#7 \ No newline at end of file + en-US: Everything is a Miracle / Dusk \ No newline at end of file diff --git a/config/gavial.yaml b/config/gavial.yaml index 7bac9b9..ee6a766 100644 --- a/config/gavial.yaml +++ b/config/gavial.yaml @@ -10,5 +10,4 @@ invert_filter: false color: rgb(29, 185, 53) codename: zh-CN: 百练嘉维尔 - en-US: Gavial the Invincible -portrait: null \ No newline at end of file + en-US: Gavial the Invincible \ No newline at end of file diff --git a/config/lee_trust_your_eyes.yaml b/config/lee_trust_your_eyes.yaml index 666dc6d..4053417 100644 --- a/config/lee_trust_your_eyes.yaml +++ b/config/lee_trust_your_eyes.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(206, 0, 0) codename: zh-CN: 手到牌来 · 老鲤 - en-US: Trust Your Eyes / Lee -portrait: dyn_portrait_char_322_lmlee_witch#3 \ No newline at end of file + en-US: Trust Your Eyes / Lee \ No newline at end of file diff --git a/config/ling.yaml b/config/ling.yaml index 76ba06d..143565e 100644 --- a/config/ling.yaml +++ b/config/ling.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(15, 206, 216) codename: zh-CN: 令 - en-US: Ling -portrait: null \ No newline at end of file + en-US: Ling \ No newline at end of file diff --git a/config/ling_it_does_wash_the_strings.yaml b/config/ling_it_does_wash_the_strings.yaml index 3a5d8a6..8dc8cfa 100644 --- a/config/ling_it_does_wash_the_strings.yaml +++ b/config/ling_it_does_wash_the_strings.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(37, 148, 197) codename: zh-CN: 濯缨 · 令 - en-US: It Does Wash the Strings / Ling -portrait: dyn_portrait_char_2023_ling_nian#9 \ No newline at end of file + en-US: It Does Wash the Strings / Ling \ No newline at end of file diff --git a/config/mizuki_summer_feast.yaml b/config/mizuki_summer_feast.yaml index d59a2e8..529b2a6 100644 --- a/config/mizuki_summer_feast.yaml +++ b/config/mizuki_summer_feast.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(156, 210, 246) codename: zh-CN: 夏日餮宴 · 水月 - en-US: Summer Feast / Mizuki -portrait: null \ No newline at end of file + en-US: Summer Feast / Mizuki \ No newline at end of file diff --git a/config/nearl.yaml b/config/nearl.yaml index 881e72b..efc8a5f 100644 --- a/config/nearl.yaml +++ b/config/nearl.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgba(253, 236, 189, 0.95) codename: zh-CN: 耀骑士临光 - en-US: Nearl the Radiant Knight -portrait: null \ No newline at end of file + en-US: Nearl the Radiant Knight \ No newline at end of file diff --git a/config/nearl_relight.yaml b/config/nearl_relight.yaml index 5620a26..05a8fc0 100644 --- a/config/nearl_relight.yaml +++ b/config/nearl_relight.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(141, 213, 228) codename: zh-CN: 复现荣光 · 耀骑士临光 - en-US: Relight / Nearl -portrait: dyn_portrait_char_1014_nearl2_epoque#17 \ No newline at end of file + en-US: Relight / Nearl \ No newline at end of file diff --git a/config/nian.yaml b/config/nian.yaml index 766bdbf..7ce2dfd 100644 --- a/config/nian.yaml +++ b/config/nian.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(255, 48, 0) codename: zh-CN: 年 - en-US: Nian -portrait: null \ No newline at end of file + en-US: Nian \ No newline at end of file diff --git a/config/nian_unfettered_freedom.yaml b/config/nian_unfettered_freedom.yaml index 51591d4..29deb34 100644 --- a/config/nian_unfettered_freedom.yaml +++ b/config/nian_unfettered_freedom.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(187, 163, 106) codename: zh-CN: 乐逍遥 · 年 - en-US: Unfettered Freedom / Nian -portrait: dyn_portrait_char_2014_nian_nian#4 \ No newline at end of file + en-US: Unfettered Freedom / Nian \ No newline at end of file diff --git a/config/passager_dream_in_a_moment.yaml b/config/passager_dream_in_a_moment.yaml index 9c4184a..bf15daf 100644 --- a/config/passager_dream_in_a_moment.yaml +++ b/config/passager_dream_in_a_moment.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(231, 166, 144) codename: zh-CN: 今昔须臾之梦 · 异客 - en-US: Dream in a Moment / Passager -portrait: dyn_portrait_char_472_pasngr_epoque#17 \ No newline at end of file + en-US: Dream in a Moment / Passager \ No newline at end of file diff --git a/config/phatom_focus.yaml b/config/phatom_focus.yaml index 75044f3..0653420 100644 --- a/config/phatom_focus.yaml +++ b/config/phatom_focus.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(158, 2, 2) codename: zh-CN: 焦点 · 傀影 - en-US: Focus / Phatom -portrait: null \ No newline at end of file + en-US: Focus / Phatom \ No newline at end of file diff --git a/config/pozemka_snowy_plains_in_words.yaml b/config/pozemka_snowy_plains_in_words.yaml index c07af25..faa87b7 100644 --- a/config/pozemka_snowy_plains_in_words.yaml +++ b/config/pozemka_snowy_plains_in_words.yaml @@ -10,5 +10,4 @@ invert_filter: false color: rgb(145, 220, 253) codename: zh-CN: 字句中的雪原 · 鸿雪 - en-US: Snowy Plains in Words / Позёмка -portrait: dyn_portrait_char_4055_bgsnow_wild#7 \ No newline at end of file + en-US: Snowy Plains in Words / Позёмка \ No newline at end of file diff --git a/config/rosmontis.yaml b/config/rosmontis.yaml index 856582a..bb5450d 100644 --- a/config/rosmontis.yaml +++ b/config/rosmontis.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(23, 210, 236) codename: zh-CN: 迷迭香 - en-US: Rosmontis -portrait: null \ No newline at end of file + en-US: Rosmontis \ No newline at end of file diff --git a/config/rosmontis_become_anew.yaml b/config/rosmontis_become_anew.yaml index 04c44a4..20824fa 100644 --- a/config/rosmontis_become_anew.yaml +++ b/config/rosmontis_become_anew.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(116, 177, 222) codename: zh-CN: 拥抱新生 · 迷迭香 - en-US: Become Anew / Rosmontis -portrait: dyn_portrait_char_391_rosmon_epoque#17 \ No newline at end of file + en-US: Become Anew / Rosmontis \ No newline at end of file diff --git a/config/skadi.yaml b/config/skadi.yaml index 971871d..aec5627 100644 --- a/config/skadi.yaml +++ b/config/skadi.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(226, 96, 96) codename: zh-CN: 浊心斯卡蒂 - en-US: Skadi the Corrupting Heart -portrait: null \ No newline at end of file + en-US: Skadi the Corrupting Heart \ No newline at end of file diff --git a/config/skadi_sublimation.yaml b/config/skadi_sublimation.yaml index b09c68f..c505de0 100644 --- a/config/skadi_sublimation.yaml +++ b/config/skadi_sublimation.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgba(95, 116, 187, 0.74) codename: zh-CN: 升华 · 浊心斯卡蒂 - en-US: Sublimation / Skadi the Corrupting Heart -portrait: dyn_portrait_char_1012_skadi2_boc#4 \ No newline at end of file + en-US: Sublimation / Skadi the Corrupting Heart \ No newline at end of file diff --git a/config/specter.yaml b/config/specter.yaml index d9c1e50..9b67de6 100644 --- a/config/specter.yaml +++ b/config/specter.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgba(14, 124, 203, 0.86) codename: zh-CN: 归溟幽灵鲨 - en-US: Specter the Unchained -portrait: null \ No newline at end of file + en-US: Specter the Unchained \ No newline at end of file diff --git a/config/surtr_colorful_wonderland.yaml b/config/surtr_colorful_wonderland.yaml index c77d7cb..d9e028b 100644 --- a/config/surtr_colorful_wonderland.yaml +++ b/config/surtr_colorful_wonderland.yaml @@ -10,5 +10,4 @@ invert_filter: false color: rgb(177, 226, 249) codename: zh-CN: 缤纷奇境 CW03 · 史尔特尔 - en-US: Colorful Wonderland CW03 / Surtr -portrait: dyn_portrait_char_350_surtr_summer#9 \ No newline at end of file + en-US: Colorful Wonderland CW03 / Surtr \ No newline at end of file diff --git a/config/texas_the_omertosa.yaml b/config/texas_the_omertosa.yaml index 3928803..e29b708 100644 --- a/config/texas_the_omertosa.yaml +++ b/config/texas_the_omertosa.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgba(34, 37, 255, 0.9) codename: zh-CN: 缄默德克萨斯 - en-US: Texas the Omertosa -portrait: null \ No newline at end of file + en-US: Texas the Omertosa \ No newline at end of file diff --git a/config/w.yaml b/config/w.yaml index 0383fb4..bc86100 100644 --- a/config/w.yaml +++ b/config/w.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgb(228, 54, 56) codename: zh-CN: W - en-US: W -portrait: null \ No newline at end of file + en-US: W \ No newline at end of file diff --git a/config/w_wonder.yaml b/config/w_wonder.yaml index 3d07e88..9ee8532 100644 --- a/config/w_wonder.yaml +++ b/config/w_wonder.yaml @@ -10,5 +10,4 @@ invert_filter: true color: rgba(0, 0, 0, 0.83) codename: zh-CN: 恍惚 · W - en-US: Wonder / W -portrait: dyn_portrait_char_113_cqbw_epoque#7 \ No newline at end of file + en-US: Wonder / W \ No newline at end of file diff --git a/directory/.env b/directory/.env index 8229cde..e8878ab 100644 --- a/directory/.env +++ b/directory/.env @@ -1,3 +1,3 @@ VITE_APP_TITLE=AKLive2D -VITE_VERSION=0.5.5 +VITE_VERSION=0.5.7 VITE_APP_VOICE_URL=jp/CN_037.ogg \ No newline at end of file diff --git a/directory/Version b/directory/Version index ad83b1b..b35b9dd 100644 --- a/directory/Version +++ b/directory/Version @@ -1 +1 @@ -0.5.6 \ No newline at end of file +0.5.8 \ No newline at end of file diff --git a/directory/src/context/useHeaderContext.jsx b/directory/src/context/useHeaderContext.jsx index 28a97a9..9223dd2 100644 --- a/directory/src/context/useHeaderContext.jsx +++ b/directory/src/context/useHeaderContext.jsx @@ -16,7 +16,8 @@ export function HeaderProvider(props) { i18n } = useContext(LanguageContext) const [tabs, setTabs] = useState(null) - const [currentTab, setCurrentTab] = useState(null) + const [currentTab, setCurrentTab] = useState([]) + const [appbarExtraArea, setAppbarExtraArea] = useState([]) useEffect(() => { let newTitle = key @@ -31,7 +32,8 @@ export function HeaderProvider(props) { {props.children} diff --git a/directory/src/db/index.js b/directory/src/db/index.js new file mode 100644 index 0000000..fb22e62 --- /dev/null +++ b/directory/src/db/index.js @@ -0,0 +1,9 @@ +import Dexie from 'dexie'; + +const db = new Dexie('aklive2dDatabase'); +db.version(2).stores({ + image: '++key, blob', + voice: '++key, blob', +}); + +export default db; \ No newline at end of file diff --git a/directory/src/i18n.json b/directory/src/i18n.json index be4f900..0add8bb 100644 --- a/directory/src/i18n.json +++ b/directory/src/i18n.json @@ -51,10 +51,6 @@ "zh-CN": "语音", "en-US": "Voice" }, - "live2d": { - "zh-CN": "Live2D", - "en-US": "Live2D" - }, "zh-CN": { "zh-CN": "简体中文", "en-US": "Chinese (Simplified)" diff --git a/directory/src/routes/path/home.css b/directory/src/routes/path/home.css index 73e4aa4..75ab331 100644 --- a/directory/src/routes/path/home.css +++ b/directory/src/routes/path/home.css @@ -87,11 +87,6 @@ background-color: var(--home-item-hover-background-color); } -.home .item-group .item .item-img .live2d { - width: 100%; - height: 360px; -} - .home .item-group .item .item-info { white-space: nowrap; position: relative; diff --git a/directory/src/routes/path/home.jsx b/directory/src/routes/path/home.jsx index e4626ea..1c11982 100644 --- a/directory/src/routes/path/home.jsx +++ b/directory/src/routes/path/home.jsx @@ -2,11 +2,10 @@ import { useState, useEffect, useContext, - useRef + useCallback } from 'react' import { Link, - useOutletContext, } from "react-router-dom"; import './home.css' import { ConfigContext } from '@/context/useConfigContext'; @@ -16,16 +15,17 @@ import CharIcon from '@/component/char_icon'; import MainBorder from '@/component/main_border'; import useUmami from '@parcellab/react-use-umami'; import Switch from '@/component/switch'; -import spine from '!/libs/spine-player'; -import '!/libs/spine-player.css'; +import db from '@/db'; + +const audioEl = new Audio() export default function Home() { const _trackEvt = useUmami('/') - const { setAppbarExtraArea } = useOutletContext() const { setTitle, setTabs, - currentTab, setCurrentTab + currentTab, setCurrentTab, + setAppbarExtraArea } = useContext(HeaderContext) const { config } = useContext(ConfigContext) const { @@ -36,11 +36,6 @@ export default function Home() { } = useContext(LanguageContext) const [content, setContent] = useState([]) const [voiceOn, setVoiceOn] = useState(false) - const [live2dOn, setLive2dOn] = useState(false) - const [audioUrl, setAudioUrl] = useState('') - const audioEl = new Audio(audioUrl) - const live2dRefObject = useRef({}) - const live2dSpineObject = useRef({}) useEffect(() => { setTitle('dynamic_compile') @@ -65,7 +60,6 @@ export default function Home() { const toggleVoice = () => { setVoiceOn(!voiceOn) - setAudioUrl('') } useEffect(() => { @@ -77,82 +71,46 @@ export default function Home() { on={voiceOn} handleOnClick={() => toggleVoice()} /> - // ), ( - // setLive2dOn(!live2dOn)} - // /> ) ]) - }, [voiceOn, live2dOn]) + }, [voiceOn, language]) const isShown = (type) => currentTab === 'all' || currentTab === type - const playVoice = (link) => { - if (!voiceOn) return - audioEl.src = `/${link}/assets/voice/${import.meta.env.VITE_APP_VOICE_URL}` + const playVoice = useCallback((blob) => { + const audioUrl = URL.createObjectURL(blob) + audioEl.src = audioUrl let startPlayPromise = audioEl.play() if (startPlayPromise !== undefined) { startPlayPromise .then(() => { - return + const audioEndedFunc = () => { + audioEl.removeEventListener('ended', audioEndedFunc) + URL.revokeObjectURL(audioUrl) + } + audioEl.addEventListener('ended', audioEndedFunc) }) .catch(() => { return }) } - } + }, []) - const getLive2d = (link) => { - const reactEl =
{ - live2dRefObject.current[link] = ref - }}>
- return reactEl - } - - useEffect(() => { - if (live2dOn) { - Object.keys(live2dRefObject.current).forEach((link) => { - const ref = live2dRefObject.current[link] - if (ref) { - if (live2dSpineObject.current[link]) { - return - } - fetch(`/_assets/dyn_portrait_char_2014_nian_nian%234.json`) - .then((res) => res.json()) - .then((data) => { - live2dSpineObject.current[link] = new spine.SpinePlayer(ref, { - skelUrl: `./assets/dyn_portrait_char_2014_nian_nian%234.skel`, - atlasUrl: `./assets/dyn_portrait_char_2014_nian_nian%234.atlas`, - rawDataURIs: data, - animation: "Idle", - premultipliedAlpha: true, - alpha: true, - backgroundColor: "#00000000", - viewport: { - debugRender: false, - padLeft: `0%`, - padRight: `0%`, - padTop: `0%`, - padBottom: `0%`, - x: 0, - y: 0, - }, - showControls: false, - touch: false, - fps: 60, - defaultMix: 0, - success: function (widget) { - - }, + const loadVoice = (link) => { + if (!voiceOn) return + db.voice.get({ key: link }).then((v) => { + if (v === undefined) { + fetch(`/${link}/assets/voice/${import.meta.env.VITE_APP_VOICE_URL}`) + .then(res => res.blob()) + .then(blob => { + db.voice.put({ key: link, blob: blob }) + playVoice(blob) }) - }) - } - }) - } - }, [live2dOn]) + } else { + playVoice(v.blob) + } + }) + } return (
@@ -170,16 +128,15 @@ export default function Home() { className="item" key={item.link} hidden={!isShown(item.type)} - onMouseEnter={(e) => playVoice(item.link)} + onMouseEnter={() => loadVoice(item.link)} >
- {live2dOn && item.portrait !== null ? ( - getLive2d(item.link) - ) : ( - {item.codename[language]} - )} +
@@ -211,4 +168,25 @@ export default function Home() { }
) +} + +function ImageElement({ item, language }) { + const [blobUrl, setBlobUrl] = useState(null) + + useEffect(() => { + db.image.get({ key: item.link }).then((v) => { + if (v === undefined) { + fetch(`/${item.link}/assets/${item.fallback_name.replace("#", "%23")}_portrait.png`) + .then(res => res.blob()) + .then(blob => { + db.image.put({ key: item.link, blob: blob }) + setBlobUrl(URL.createObjectURL(blob)) + }) + } else { + setBlobUrl(URL.createObjectURL(v.blob)) + } + }) + }, [item.link]) + + return blobUrl ? {item.codename[language]} : null } \ No newline at end of file diff --git a/directory/src/routes/root.jsx b/directory/src/routes/root.jsx index dcfd9cc..a6a51f8 100644 --- a/directory/src/routes/root.jsx +++ b/directory/src/routes/root.jsx @@ -30,12 +30,12 @@ export default function Root(props) { const { title, tabs, - currentTab, setCurrentTab + currentTab, setCurrentTab, + appbarExtraArea } = useContext(HeaderContext) const [drawerDestinations, setDrawerDestinations] = useState(null) const currentYear = new Date().getFullYear() const [headerTabs, setHeaderTabs] = useState(null) - const [appbarExtraArea, setAppbarExtraArea] = useState(null) const renderHeaderTabs = (tabs) => { setHeaderTabs(tabs?.map((item) => { @@ -157,7 +157,7 @@ export default function Root(props) { }} /> - + diff --git a/libs/assets_processor.js b/libs/assets_processor.js index e718044..40d30db 100644 --- a/libs/assets_processor.js +++ b/libs/assets_processor.js @@ -36,10 +36,7 @@ export default class AssetsProcessor { const croppedBuffer = await this.#alphaCompositer.crop(portraitBuffer, rect) await write(croppedBuffer, path.join(this.#operatorSourceFolder, this.#operatorName, `${fallback_name}_portrait.png`)) - return { - landscape: await this.#generateAssets(__config.operators[this.#operatorName].filename, extractedDir), - portrait: __config.operators[this.#operatorName].portrait ? await this.#generateAssets(__config.operators[this.#operatorName].portrait, extractedDir) : null - } + return await this.#generateAssets(__config.operators[this.#operatorName].filename, extractedDir) } async #generateAssets(filename, extractedDir) { diff --git a/libs/directory.js b/libs/directory.js index bb2c6db..17126d8 100644 --- a/libs/directory.js +++ b/libs/directory.js @@ -28,8 +28,5 @@ export default function () { writeSync(JSON.stringify(directoryJson, null), path.join(targetFolder, "directory.json")) filesToCopy.forEach((key) => { copy(path.join(sourceFolder, key, 'assets.json'), path.join(targetFolder, `${__config.operators[key].filename}.json`)) - if (__config.operators[key].portrait) { - copy(path.join(sourceFolder, key, 'assets_portrait.json'), path.join(targetFolder, `${__config.operators[key].portrait}.json`)) - } }) } diff --git a/package.json b/package.json index 7cbf9f2..dac2884 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,8 @@ }, "dependencies": { "@parcellab/react-use-umami": "^2.0.1", - "@react-hook/cache": "^1.1.1", + "dexie": "^3.2.3", + "dexie-react-hooks": "^1.1.1", "dotenv": "^16.0.3", "node-fetch": "^3.3.0", "react": "^18.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 17b48ab..e9809ce 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,10 +2,11 @@ lockfileVersion: 5.4 specifiers: '@parcellab/react-use-umami': ^2.0.1 - '@react-hook/cache': ^1.1.1 '@types/react': ^18.0.28 '@types/react-dom': ^18.0.11 '@vitejs/plugin-react-swc': ^3.2.0 + dexie: ^3.2.3 + dexie-react-hooks: ^1.1.1 dotenv: ^16.0.3 node-fetch: ^3.3.0 react: ^18.2.0 @@ -19,7 +20,8 @@ specifiers: dependencies: '@parcellab/react-use-umami': 2.0.1_react@18.2.0 - '@react-hook/cache': 1.1.1_react@18.2.0 + dexie: 3.2.3 + dexie-react-hooks: 1.1.1_oyoivydq6d62bcmmdhna6akh5q dotenv: 16.0.3 node-fetch: 3.3.0 react: 18.2.0 @@ -244,23 +246,6 @@ packages: react: 18.2.0 dev: false - /@react-hook/cache/1.1.1_react@18.2.0: - resolution: {integrity: sha512-FY0Bwvxsv9Gu6pUbVdNylh4jyWPtQRegQM9G6yVx3l2cYjbxzaJwEXticLfsRcciCbnk7iyZfJn6mZ4N4+q9qA==} - peerDependencies: - react: '>=16.8' - dependencies: - '@react-hook/latest': 1.0.3_react@18.2.0 - react: 18.2.0 - dev: false - - /@react-hook/latest/1.0.3_react@18.2.0: - resolution: {integrity: sha512-dy6duzl+JnAZcDbNTfmaP3xHiKtbXYOaz3G51MGVljh548Y8MWzTr+PHLOfvpypEVW9zwvl+VyKjbWKEVbV1Rg==} - peerDependencies: - react: '>=16.8' - dependencies: - react: 18.2.0 - dev: false - /@remix-run/router/1.3.2: resolution: {integrity: sha512-t54ONhl/h75X94SWsHGQ4G/ZrCEguKSRQr7DrjTciJXW0YU1QhlwYeycvK5JgkzlxmvrK7wq1NB/PLtHxoiDcA==} engines: {node: '>=14'} @@ -375,7 +360,6 @@ packages: /@types/prop-types/15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - dev: true /@types/react-dom/18.0.11: resolution: {integrity: sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw==} @@ -389,11 +373,9 @@ packages: '@types/prop-types': 15.7.5 '@types/scheduler': 0.16.2 csstype: 3.1.1 - dev: true /@types/scheduler/0.16.2: resolution: {integrity: sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==} - dev: true /@vitejs/plugin-react-swc/3.2.0_vite@4.1.4: resolution: {integrity: sha512-IcBoXL/mcH7JdQr/nfDlDwTdIaH8Rg7LpfQDF4nAht+juHWIuv6WhpKPCSfY4+zztAaB07qdBoFz1XCZsgo3pQ==} @@ -455,7 +437,6 @@ packages: /csstype/3.1.1: resolution: {integrity: sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==} - dev: true /data-uri-to-buffer/4.0.1: resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} @@ -479,6 +460,23 @@ packages: engines: {node: '>=8'} dev: false + /dexie-react-hooks/1.1.1_oyoivydq6d62bcmmdhna6akh5q: + resolution: {integrity: sha512-Cam5JP6PxHN564RvWEoe8cqLhosW0O4CAZ9XEVYeGHJBa6KEJlOpd9CUpV3kmU9dm2MrW97/lk7qkf1xpij7gA==} + peerDependencies: + '@types/react': '>=16' + dexie: '>=3.1.0-alpha.1 <5.0.0' + react: '>=16' + dependencies: + '@types/react': 18.0.28 + dexie: 3.2.3 + react: 18.2.0 + dev: false + + /dexie/3.2.3: + resolution: {integrity: sha512-iHayBd4UYryDCVUNa3PMsJMEnd8yjyh5p7a+RFeC8i8n476BC9wMhVvqiImq5zJZJf5Tuer+s4SSj+AA3x+ZbQ==} + engines: {node: '>=6.0'} + dev: false + /dotenv/16.0.3: resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} engines: {node: '>=12'} diff --git a/vite.config.js b/vite.config.js index 2f9d41f..5c97360 100644 --- a/vite.config.js +++ b/vite.config.js @@ -161,7 +161,6 @@ class ViteRunner { resolve: { alias: { '@': path.resolve(directoryDir, './src'), - '!': path.resolve(__projetRoot, './src'), }, }, build: {