poi-plugin-quest-info-2
Advanced tools
Comparing version 0.13.3 to 0.14.0
{ | ||
"$schema": "https://unpkg.com/@changesets/config@2.2.0/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ | ||
"repo": "lawvs/poi-plugin-quest-2" | ||
} | ||
], | ||
"commit": false, | ||
@@ -5,0 +10,0 @@ "fixed": [], |
@@ -0,6 +1,6 @@ | ||
import en_US from './quests-en.json' | ||
import ja_JP from './quests-jp.json' | ||
import ko_KR from './quests-ko.json' | ||
import zh_CN from './quests-scn.json' | ||
import zh_TW from './quests-tcn.json' | ||
import ja_JP from './quests-jp.json' | ||
import en_US from './quests-en.json' | ||
import ko_KR from './quests-ko.json' | ||
@@ -15,2 +15,40 @@ export const QuestData = { | ||
export const kcanotifyGameData = [ | ||
{ | ||
name: '简体中文 - Kcanotify', | ||
key: 'zh-Hans-kcanotify', | ||
lang: 'zh-CN', | ||
flagEmoji: '🇨🇳', | ||
res: zh_CN, | ||
}, | ||
{ | ||
name: '正體中文 - Kcanotify', | ||
key: 'zh-TW-kcanotify', | ||
lang: 'zh-TW', | ||
flagEmoji: '🇹🇼', | ||
res: zh_TW, | ||
}, | ||
{ | ||
name: '日本語 - Kcanotify', | ||
key: 'ja-JP-kcanotify', | ||
lang: 'ja-JP', | ||
flagEmoji: '🇯🇵', | ||
res: ja_JP, | ||
}, | ||
{ | ||
name: 'English - Kcanotify', | ||
key: 'en-US-kcanotify', | ||
lang: 'en-US', | ||
flagEmoji: '🇺🇸', | ||
res: en_US, | ||
}, | ||
{ | ||
name: '한국어 - 시제 깡들리티', | ||
key: 'ko-KR-kcanotify', | ||
lang: 'ko-KR', | ||
flagEmoji: '🇰🇷', | ||
res: ko_KR, | ||
}, | ||
] as const | ||
export const version = '2024092801' |
@@ -7,2 +7,10 @@ import zh_CN from './quests-scn.json' | ||
export const version = 'c918251c6b68dfc9666a3230fd39b36c777da911' | ||
export const kcwikiGameData = { | ||
name: '简体中文 - Kcwiki', | ||
key: 'zh-Hans-kcwiki', | ||
lang: 'zh-CN', | ||
flagEmoji: '🇨🇳', | ||
res: zh_CN, | ||
} as const | ||
export const version = 'bc32e86b9b41367faf31d796b6f534ee8c61e151' |
@@ -2279,7 +2279,16 @@ { | ||
], | ||
"post": [] | ||
"post": [ | ||
"2409B1" | ||
] | ||
}, | ||
"375": { | ||
"pre": [], | ||
"post": [ | ||
"By15", | ||
"F128" | ||
] | ||
}, | ||
"376": { | ||
"pre": [ | ||
"by15" | ||
"By15" | ||
], | ||
@@ -4858,3 +4867,3 @@ "post": [] | ||
"pre": [ | ||
"2049B1" | ||
"2409B1" | ||
], | ||
@@ -4865,9 +4874,11 @@ "post": [] | ||
"pre": [ | ||
"cy15" | ||
"Cy15" | ||
], | ||
"post": [] | ||
"post": [ | ||
"C77" | ||
] | ||
}, | ||
"1020": { | ||
"pre": [ | ||
"2049C1" | ||
"2409C1" | ||
], | ||
@@ -5129,4 +5140,4 @@ "post": [ | ||
"pre": [ | ||
"2049B1", | ||
"cy15" | ||
"Cy15", | ||
"2409B1" | ||
], | ||
@@ -5133,0 +5144,0 @@ "post": [] |
@@ -595,2 +595,3 @@ { | ||
1017, | ||
1019, | ||
1020, | ||
@@ -597,0 +598,0 @@ 1101, |
@@ -575,3 +575,3 @@ { | ||
"By15": 1018, | ||
"2049B1": 1020, | ||
"2409B1": 1020, | ||
"F96": 1101, | ||
@@ -578,0 +578,0 @@ "F97": 1102, |
# poi-plugin-quest-info-2 | ||
## 0.14.0 | ||
### Minor Changes | ||
- [#161](https://github.com/lawvs/poi-plugin-quest-2/pull/161) [`e3fcef0`](https://github.com/lawvs/poi-plugin-quest-2/commit/e3fcef0887ac122af365e456f62a91020b5e2086) Thanks [@lawvs](https://github.com/lawvs)! - Support for switching data sources | ||
### Patch Changes | ||
- [#158](https://github.com/lawvs/poi-plugin-quest-2/pull/158) [`2f5cc37`](https://github.com/lawvs/poi-plugin-quest-2/commit/2f5cc37255e9648400504dbf02bf8d209128207d) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update quest data | ||
## 0.13.3 | ||
@@ -4,0 +14,0 @@ |
@@ -45,3 +45,6 @@ { | ||
"Star project, support the author": "Star project, support the author", | ||
"Data Source": "Data Source", | ||
"Auto detect": "Auto detect", | ||
"Report issue": "Report issue", | ||
"": "" | ||
} |
@@ -40,3 +40,6 @@ { | ||
"Star project, support the author": "Starプロジェクト、著者をサポート", | ||
"Data Source": "データソース", | ||
"Auto detect": "自動検出", | ||
"Report issue": "問題を報告する", | ||
"": "" | ||
} |
@@ -24,3 +24,6 @@ { | ||
"Star project, support the author": "스타 프로젝트, 작가 지원", | ||
"Data Source": "데이터 소스", | ||
"Auto detect": "자동 감지", | ||
"Report issue": "문제 보고", | ||
"": "" | ||
} |
@@ -40,3 +40,6 @@ { | ||
"Star project, support the author": "Star 项目,支持作者", | ||
"Data Source": "数据源", | ||
"Auto detect": "自动检测", | ||
"Report issue": "报告问题", | ||
"": "" | ||
} |
@@ -40,3 +40,6 @@ { | ||
"Star project, support the author": "Star項目,支持作者", | ||
"Data Source": "資料來源", | ||
"Auto detect": "自動偵測", | ||
"Report issue": "報告問題", | ||
"": "" | ||
} |
{ | ||
"name": "poi-plugin-quest-info-2", | ||
"version": "0.13.3", | ||
"version": "0.14.0", | ||
"private": false, | ||
@@ -54,2 +54,3 @@ "description": "show quest info", | ||
"@blueprintjs/core": "^4.19.5", | ||
"@changesets/changelog-github": "^0.5.0", | ||
"@changesets/cli": "^2.27.7", | ||
@@ -56,0 +57,0 @@ "@storybook/addon-actions": "^7.5.2", |
import type { i18n } from 'i18next' | ||
import { QuestData } from '../build/kcanotifyGamedata' | ||
import { KcwikiQuestData } from '../build/kcQuestsData' | ||
import { QUEST_DATA } from '../build' | ||
import { importFromPoi, PACKAGE_NAME } from './poi/env' | ||
import { getPoiStore } from './poi/store' | ||
import { | ||
checkIsKcwikiSupportedLanguages, | ||
getStorage, | ||
isSupportedLanguages, | ||
} from './store' | ||
import { getStorage } from './store' | ||
@@ -30,14 +25,10 @@ const LEGACY_QUEST_PLUGIN_ID = 'poi-plugin-quest-info' | ||
const getQuestState = (maybeLanguage: string) => { | ||
const supported = isSupportedLanguages(maybeLanguage) | ||
if (!supported) { | ||
const dataSource = getStorage()?.dataSource | ||
const sourceData = QUEST_DATA.find((i) => i.key === dataSource) | ||
const defaultData = QUEST_DATA.find((i) => i.lang === maybeLanguage) | ||
const data = (sourceData ?? defaultData)?.res | ||
if (!data) { | ||
return {} | ||
} | ||
const preferKcwikiData = getStorage()?.preferKcwikiData ?? true | ||
const kcwikiSupported = checkIsKcwikiSupportedLanguages(maybeLanguage) | ||
const data = | ||
preferKcwikiData && kcwikiSupported | ||
? KcwikiQuestData[maybeLanguage] | ||
: QuestData[maybeLanguage] | ||
return Object.fromEntries( | ||
@@ -44,0 +35,0 @@ Object.entries(data).map(([apiNo, d]) => { |
import moize from 'moize' | ||
import { KcwikiQuestData } from '../build/kcQuestsData' | ||
import newQuestData from '../build/kcQuestsData/quests-scn-new.json' | ||
import { QuestData } from '../build/kcanotifyGamedata' | ||
import prePostQuest from '../build/prePostQuest.json' | ||
@@ -48,5 +46,2 @@ import questCategory from '../build/questCategory.json' | ||
export const getKcwikiQuestData = () => KcwikiQuestData | ||
export const getKcanotifyQuestData = () => QuestData | ||
const dailyQuest = new Set(questCategory.dailyQuest) | ||
@@ -53,0 +48,0 @@ const weeklyQuest = new Set(questCategory.weeklyQuest) |
@@ -5,3 +5,3 @@ import { useCallback } from 'react' | ||
import { QuestTab } from '../poi/types' | ||
import { CATEGORY_TAGS, TYPE_TAGS } from '../tags' | ||
import type { CATEGORY_TAGS, TYPE_TAGS } from '../tags' | ||
import { ALL_CATEGORY_TAG, ALL_TYPE_TAG, PROGRESS_TAG, useStore } from './store' | ||
@@ -8,0 +8,0 @@ |
@@ -0,3 +1,2 @@ | ||
export * from './quest' | ||
export * from './store' | ||
export * from './quest' | ||
export * from './kcwiki' |
@@ -0,5 +1,5 @@ | ||
import { QUEST_DATA } from '../../build' | ||
import { usePluginTranslation } from '../poi/hooks' | ||
import { | ||
DocQuest, | ||
getKcanotifyQuestData, | ||
getQuestIdByCode, | ||
@@ -10,37 +10,37 @@ QUEST_STATUS, | ||
import { useGlobalGameQuest, useGlobalQuestStatusQuery } from './gameQuest' | ||
import { checkIsKcwikiSupportedLanguages, useKcwikiData } from './kcwiki' | ||
import { DataSource, useStore } from './store' | ||
const DEFAULT_LANG = 'ja-JP' | ||
const checkIsKcanotifySupportedLanguages = ( | ||
lang: string, | ||
): lang is keyof typeof kcaQuestData => { | ||
const kcaQuestData = getKcanotifyQuestData() | ||
return lang in kcaQuestData | ||
} | ||
export const isSupportedLanguages = ( | ||
lang: string, | ||
): lang is keyof ReturnType<typeof getKcanotifyQuestData> => | ||
checkIsKcanotifySupportedLanguages(lang) || | ||
checkIsKcwikiSupportedLanguages(lang) | ||
export const useLanguage = () => { | ||
const useLanguage = () => { | ||
const { | ||
i18n: { language }, | ||
} = usePluginTranslation() | ||
const lang = checkIsKcanotifySupportedLanguages(language) | ||
? language | ||
: DEFAULT_LANG | ||
return lang | ||
return language | ||
} | ||
export const useDataSource = () => { | ||
const { | ||
store: { dataSource }, | ||
updateStore, | ||
} = useStore() | ||
const lang = useLanguage() | ||
const setDataSource = (val: DataSource | null) => | ||
updateStore({ dataSource: val }) | ||
const isValid = | ||
dataSource && Object.values(QUEST_DATA).find((i) => i.key === dataSource) | ||
const normalizedDataSource = isValid | ||
? dataSource | ||
: (QUEST_DATA.find((i) => i.lang === lang)?.key ?? QUEST_DATA[0].key) | ||
return { dataSource: normalizedDataSource, setDataSource } | ||
} | ||
const useQuestMap = (): Record<string, DocQuest> => { | ||
const lang = useLanguage() | ||
const kcwikiData = useKcwikiData(lang) | ||
if (kcwikiData) { | ||
return kcwikiData | ||
const { dataSource } = useDataSource() | ||
if (!QUEST_DATA.length) { | ||
throw new Error('QUEST_DATA is empty') | ||
} | ||
const kcaQuestData = getKcanotifyQuestData() | ||
return kcaQuestData[lang] | ||
const data = QUEST_DATA.find((i) => i.key === dataSource) | ||
if (!data) { | ||
return QUEST_DATA[0].res | ||
} | ||
return data.res | ||
} | ||
@@ -47,0 +47,0 @@ |
@@ -47,3 +47,3 @@ { | ||
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ | ||
// "importsNotUsedAsValues": "error", | ||
"importsNotUsedAsValues": "error", | ||
@@ -50,0 +50,0 @@ /* Module Resolution Options */ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2348957
79283
42