poi-plugin-quest-info-2 0.10.3 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.babelrc.json +18 -0
  2. package/.eslintrc.js +2 -3
  3. package/.nvmrc +1 -0
  4. package/CHANGELOG.md +13 -0
  5. package/build/kcQuestsData/DATA_VERSION +1 -1
  6. package/build/kcQuestsData/index.ts +1 -1
  7. package/build/kcQuestsData/quests-scn-new.json +7 -12
  8. package/build/kcQuestsData/quests-scn.json +1287 -1921
  9. package/build/kcanotifyGamedata/DATA_VERSION +1 -1
  10. package/build/kcanotifyGamedata/index.ts +1 -1
  11. package/build/kcanotifyGamedata/quests-en.json +220 -40
  12. package/build/kcanotifyGamedata/quests-jp.json +231 -42
  13. package/build/kcanotifyGamedata/quests-ko.json +228 -42
  14. package/build/kcanotifyGamedata/quests-scn.json +227 -42
  15. package/build/kcanotifyGamedata/quests-tcn.json +227 -42
  16. package/build/prePostQuest.json +118 -49
  17. package/build/questCategory.json +9 -9
  18. package/build/questCodeMap.json +8 -8
  19. package/package.json +25 -19
  20. package/shims/poi.d.ts +2 -2
  21. package/src/Toolbar.tsx +8 -8
  22. package/src/__tests__/__snapshots__/questCategory.spec.ts.snap +138 -128
  23. package/src/__tests__/__snapshots__/questHelper.spec.ts.snap +13 -5
  24. package/src/__tests__/kcanotifyData.spec.ts +9 -9
  25. package/src/__tests__/kcwikiData.spec.ts +5 -5
  26. package/src/__tests__/questCategory.spec.ts +3 -3
  27. package/src/components/QuestCard/index.tsx +5 -4
  28. package/src/patch.ts +2 -2
  29. package/src/poi/hooks.ts +2 -2
  30. package/src/poi/store.ts +5 -5
  31. package/src/poi/types.ts +1 -1
  32. package/src/questHelper.ts +6 -6
  33. package/src/reducer.ts +1 -1
  34. package/src/store/filterTags.ts +6 -6
  35. package/src/store/gameQuest.tsx +1 -1
  36. package/src/store/kcwiki.ts +1 -1
  37. package/src/store/quest.ts +2 -2
  38. package/src/store/search.ts +24 -3
  39. package/src/store/store.tsx +1 -1
  40. package/src/tags.tsx +1 -1
@@ -1,9 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`questHelper should 101 locked quests match snapshot 1`] = `
4
- Object {
4
+ {
5
5
  "1001": true,
6
- "1002": true,
7
6
  "102": true,
8
7
  "103": true,
9
8
  "104": true,
@@ -19,19 +18,26 @@ Object {
19
18
  "1104": true,
20
19
  "1105": true,
21
20
  "1106": true,
21
+ "1108": true,
22
22
  "1109": true,
23
23
  "111": true,
24
+ "1110": true,
24
25
  "1111": true,
25
26
  "1113": true,
26
27
  "1116": true,
27
28
  "1117": true,
28
29
  "1118": true,
29
30
  "112": true,
31
+ "1120": true,
30
32
  "1127": true,
31
33
  "1128": true,
32
34
  "1129": true,
33
35
  "113": true,
34
36
  "1130": true,
37
+ "1131": true,
38
+ "1132": true,
39
+ "1133": true,
40
+ "1134": true,
35
41
  "114": true,
36
42
  "115": true,
37
43
  "116": true,
@@ -414,6 +420,7 @@ Object {
414
420
  "947": true,
415
421
  "948": true,
416
422
  "949": true,
423
+ "958": true,
417
424
  "961": true,
418
425
  "966": true,
419
426
  "967": true,
@@ -431,6 +438,7 @@ Object {
431
438
  "982": true,
432
439
  "983": true,
433
440
  "989": true,
441
+ "992": true,
434
442
  "993": true,
435
443
  "994": true,
436
444
  "995": true,
@@ -440,7 +448,7 @@ Object {
440
448
  `;
441
449
 
442
450
  exports[`questHelper should 196 getLockedQuest correct 1`] = `
443
- Object {
451
+ {
444
452
  "197": true,
445
453
  "346": true,
446
454
  "892": true,
@@ -449,7 +457,7 @@ Object {
449
457
  `;
450
458
 
451
459
  exports[`questHelper should 236 getCompletedQuest correct 1`] = `
452
- Object {
460
+ {
453
461
  "101": true,
454
462
  "102": true,
455
463
  "103": true,
@@ -478,7 +486,7 @@ Object {
478
486
  `;
479
487
 
480
488
  exports[`questHelper should getCompletedQuest quest match snapshot 1`] = `
481
- Object {
489
+ {
482
490
  "101": true,
483
491
  "102": true,
484
492
  "103": true,
@@ -1,19 +1,19 @@
1
1
  import { version, QuestData } from '../../build/kcanotifyGamedata'
2
2
 
3
3
  test('should Kcanotify Game data version correct', () => {
4
- expect(version).toMatchInlineSnapshot(`"2023082801"`)
4
+ expect(version).toMatchInlineSnapshot(`"2023102201"`)
5
5
  })
6
6
 
7
7
  test('should Kcanotify Game data keys correct', () => {
8
8
  expect(Object.keys(QuestData)).toMatchInlineSnapshot(`
9
- Array [
10
- "zh-CN",
11
- "zh-TW",
12
- "ja-JP",
13
- "en-US",
14
- "ko-KR",
15
- ]
16
- `)
9
+ [
10
+ "zh-CN",
11
+ "zh-TW",
12
+ "ja-JP",
13
+ "en-US",
14
+ "ko-KR",
15
+ ]
16
+ `)
17
17
  })
18
18
 
19
19
  describe('should format correct', () => {
@@ -4,16 +4,16 @@ import newQuestData from '../../build/kcQuestsData/quests-scn-new.json'
4
4
  describe('should version correct', () => {
5
5
  test('should KcwikiQuestData Game data version correct', () => {
6
6
  expect(version).toMatchInlineSnapshot(
7
- `"6e87c9c0c3d9cf9694950eef49efd82ed0bc8752"`
7
+ `"793e277cd7bff779f322e8b8a5b99fee0c631e93"`,
8
8
  )
9
9
  })
10
10
 
11
11
  test('should KcwikiQuestData Game data keys correct', () => {
12
12
  expect(Object.keys(KcwikiQuestData)).toMatchInlineSnapshot(`
13
- Array [
14
- "zh-CN",
15
- ]
16
- `)
13
+ [
14
+ "zh-CN",
15
+ ]
16
+ `)
17
17
  })
18
18
  })
19
19
 
@@ -7,9 +7,9 @@ describe('should questCategory correct', () => {
7
7
  expect(questCategory.dailyQuest.length).toMatchInlineSnapshot(`23`)
8
8
  expect(questCategory.weeklyQuest.length).toMatchInlineSnapshot(`17`)
9
9
  expect(questCategory.monthlyQuest.length).toMatchInlineSnapshot(`11`)
10
- expect(questCategory.quarterlyQuest.length).toMatchInlineSnapshot(`25`)
10
+ expect(questCategory.quarterlyQuest.length).toMatchInlineSnapshot(`27`)
11
11
  expect(questCategory.yearlyQuest.length).toMatchInlineSnapshot(`45`)
12
- expect(questCategory.singleQuest.length).toMatchInlineSnapshot(`470`)
12
+ expect(questCategory.singleQuest.length).toMatchInlineSnapshot(`468`)
13
13
  })
14
14
 
15
15
  test('snapshot', () => {
@@ -27,7 +27,7 @@ describe('should questCategory correct', () => {
27
27
  code: mergeData[String(gameId) as keyof typeof mergeData].code,
28
28
  name: mergeData[String(gameId) as keyof typeof mergeData].name,
29
29
  })),
30
- ])
30
+ ]),
31
31
  )
32
32
 
33
33
  expect(humanReadableData).toMatchSnapshot({
@@ -1,5 +1,6 @@
1
1
  import { Card, Elevation, H5 } from '@blueprintjs/core'
2
2
  import React, { forwardRef } from 'react'
3
+ // https://github.com/bvaughn/react-highlight-words
3
4
  import Highlighter from 'react-highlight-words'
4
5
  import type { StyledComponentProps } from 'styled-components'
5
6
  import { usePluginTranslation } from '../../poi/hooks'
@@ -86,7 +87,7 @@ export const QuestCard = forwardRef<
86
87
  <H5>
87
88
  <Highlighter
88
89
  searchWords={searchWords}
89
- autoEscape={false}
90
+ autoEscape={true}
90
91
  textToHighlight={[code, name]
91
92
  .filter((i) => i != undefined)
92
93
  .join(' - ')}
@@ -94,14 +95,14 @@ export const QuestCard = forwardRef<
94
95
  </H5>
95
96
  <Highlighter
96
97
  searchWords={searchWords}
97
- autoEscape={false}
98
+ autoEscape={true}
98
99
  textToHighlight={desc}
99
100
  />
100
101
  {tip2 && (
101
102
  <b>
102
103
  <Highlighter
103
104
  searchWords={searchWords}
104
- autoEscape={false}
105
+ autoEscape={true}
105
106
  textToHighlight={tip2}
106
107
  />
107
108
  </b>
@@ -110,7 +111,7 @@ export const QuestCard = forwardRef<
110
111
  <i>
111
112
  <Highlighter
112
113
  searchWords={searchWords}
113
- autoEscape={false}
114
+ autoEscape={true}
114
115
  textToHighlight={tip}
115
116
  />
116
117
  </i>
package/src/patch.ts CHANGED
@@ -46,7 +46,7 @@ const getQuestState = (maybeLanguage: string) => {
46
46
  wiki_id: data.code,
47
47
  condition: [(data as any).memo2, data.desc].filter(Boolean).join(' | '),
48
48
  },
49
- ])
49
+ ]),
50
50
  )
51
51
  }
52
52
 
@@ -72,7 +72,7 @@ export const patchLegacyQuestPluginReducer = async () => {
72
72
 
73
73
  const reducer = (
74
74
  state = initState,
75
- action: { type: string; [x: string]: any }
75
+ action: { type: string; [x: string]: any },
76
76
  ) => {
77
77
  switch (action.type) {
78
78
  case '@@Config':
package/src/poi/hooks.ts CHANGED
@@ -60,7 +60,7 @@ const useActiveTab = () => {
60
60
  // poooi/poi/views/redux/ui.es
61
61
  return observePoiStore(
62
62
  listener,
63
- (state) => state?.ui?.activeMainTab ?? UNKNOWN_TAB
63
+ (state) => state?.ui?.activeMainTab ?? UNKNOWN_TAB,
64
64
  )
65
65
  }, [])
66
66
 
@@ -88,7 +88,7 @@ export const useStateExporter = () => {
88
88
  throw new Error('Failed to export quest data! questList not found!')
89
89
  }
90
90
  return navigator.clipboard.writeText(
91
- JSON.stringify(state?.ext[PACKAGE_NAME]._.questList)
91
+ JSON.stringify(state?.ext[PACKAGE_NAME]._.questList),
92
92
  )
93
93
  }
94
94
  const importAsPoiState = (stateString: string) => {
package/src/poi/store.ts CHANGED
@@ -9,7 +9,7 @@ import type { PoiState, Store } from './types'
9
9
  const observeStore = <State, SelectedState = State>(
10
10
  store: Store<State>,
11
11
  onChange: (state: SelectedState) => void,
12
- selector: (s: State) => SelectedState = id as any
12
+ selector: (s: State) => SelectedState = id as any,
13
13
  ) => {
14
14
  let currentState: SelectedState
15
15
 
@@ -28,7 +28,7 @@ const observeStore = <State, SelectedState = State>(
28
28
 
29
29
  export const observePoiStore = <SelectedState = PoiState>(
30
30
  onChange: (state: SelectedState) => void,
31
- selector: (state: PoiState) => SelectedState = id as any
31
+ selector: (state: PoiState) => SelectedState = id as any,
32
32
  ) => {
33
33
  let valid = true
34
34
  let unsubscribe = noop
@@ -47,14 +47,14 @@ export const observePoiStore = <SelectedState = PoiState>(
47
47
 
48
48
  export const observePluginStore = <SelectedState = PluginState>(
49
49
  onChange: (state: SelectedState) => void,
50
- selector: (state: PluginState) => SelectedState = id as any
50
+ selector: (state: PluginState) => SelectedState = id as any,
51
51
  ) => observePoiStore(onChange, (s) => selector(s?.ext[PACKAGE_NAME]))
52
52
 
53
53
  const genFallbackStore = (state?: PoiState) =>
54
54
  ({
55
55
  getState: () => state,
56
56
  subscribe: () => (() => {}) as () => () => void,
57
- } as Store<PoiState>)
57
+ }) as Store<PoiState>
58
58
 
59
59
  let globalStore: Store<PoiState> | null = null
60
60
  /**
@@ -80,7 +80,7 @@ export const getPoiStore: () => Promise<Store<PoiState>> = async () => {
80
80
  export const exportPoiState = async () => {
81
81
  if (!IN_POI) {
82
82
  throw new Error(
83
- 'Failed export state from poi! You are not currently in the poi environment!'
83
+ 'Failed export state from poi! You are not currently in the poi environment!',
84
84
  )
85
85
  }
86
86
  const { getState } = await getPoiStore()
package/src/poi/types.ts CHANGED
@@ -54,7 +54,7 @@ export type GameQuest = {
54
54
  api_kind: number
55
55
  api_mst_id: number
56
56
  api_no: number
57
- }[]
57
+ }[],
58
58
  ]
59
59
  api_voice_id: 0
60
60
  api_bonus_flag: 1
@@ -158,8 +158,8 @@ export const getCategory = (api_category: number) => {
158
158
  * See https://wikiwiki.jp/kancolle/
159
159
  */
160
160
  export const guessQuestCategory = (
161
- wikiId: string
162
- ): typeof CategoryMap[keyof typeof CategoryMap] => {
161
+ wikiId: string,
162
+ ): (typeof CategoryMap)[keyof typeof CategoryMap] => {
163
163
  if (!wikiId || !wikiId.length) {
164
164
  return CategoryMap[QUEST_CATEGORY.Unknown]
165
165
  }
@@ -230,7 +230,7 @@ export const getPostQuestIds = (gameId: number): number[] =>
230
230
 
231
231
  const calcQuestMap = (
232
232
  inProgressQuests: number[],
233
- next: (gameId: number) => number[]
233
+ next: (gameId: number) => number[],
234
234
  ) => {
235
235
  const map: Record<number, true> = {}
236
236
  const queue: number[] = inProgressQuests.flatMap(next)
@@ -260,7 +260,7 @@ export const getCompletedQuest = moize(
260
260
  }
261
261
  return cacheKeyArg === keyArg
262
262
  },
263
- }
263
+ },
264
264
  )
265
265
 
266
266
  export const getLockedQuest = moize(
@@ -275,11 +275,11 @@ export const getLockedQuest = moize(
275
275
  }
276
276
  return cacheKeyArg === keyArg
277
277
  },
278
- }
278
+ },
279
279
  )
280
280
 
281
281
  export const questApiStateToQuestStatus = (
282
- state: QUEST_API_STATE | undefined
282
+ state: QUEST_API_STATE | undefined,
283
283
  ): QUEST_STATUS => {
284
284
  switch (state) {
285
285
  case QUEST_API_STATE.DEFAULT:
package/src/reducer.ts CHANGED
@@ -9,7 +9,7 @@ export type PluginState = { _: typeof initState }
9
9
 
10
10
  export const reducer = (
11
11
  state = initState,
12
- action: PoiAction
12
+ action: PoiAction,
13
13
  ): typeof initState => {
14
14
  switch (action.type) {
15
15
  case '@@Response/kcsapi/api_get_member/questlist': {
@@ -11,10 +11,10 @@ export const useFilterTags = () => {
11
11
  updateStore,
12
12
  } = useStore()
13
13
  const setCategoryTags = useCallback(
14
- (tagName: typeof CATEGORY_TAGS[number]['name']) => {
14
+ (tagName: (typeof CATEGORY_TAGS)[number]['name']) => {
15
15
  updateStore({ categoryTags: { [tagName]: true } })
16
16
  },
17
- [updateStore]
17
+ [updateStore],
18
18
  )
19
19
 
20
20
  const setCategoryTagsAll = useCallback(() => {
@@ -22,16 +22,16 @@ export const useFilterTags = () => {
22
22
  }, [setCategoryTags])
23
23
 
24
24
  const setTypeTags = useCallback(
25
- (tagName: typeof TYPE_TAGS[number]['name']) => {
25
+ (tagName: (typeof TYPE_TAGS)[number]['name']) => {
26
26
  updateStore({ typeTags: { [tagName]: true } })
27
27
  },
28
- [updateStore]
28
+ [updateStore],
29
29
  )
30
30
  const setMultiTypeTags = useCallback(
31
31
  (data: Record<string, boolean>) => {
32
32
  updateStore({ typeTags: data })
33
33
  },
34
- [updateStore]
34
+ [updateStore],
35
35
  )
36
36
 
37
37
  const setTypeTagsAll = useCallback(() => {
@@ -63,7 +63,7 @@ export const useFilterProgressTag = () => {
63
63
  }
64
64
  updateStore({ progressTag: tag })
65
65
  },
66
- [progressTag, updateStore]
66
+ [progressTag, updateStore],
67
67
  )
68
68
 
69
69
  return {
@@ -28,7 +28,7 @@ export const GameQuestContext = createContext<{
28
28
  const useQuestStatusQuery = (inProgressQuests: GameQuest[]) => {
29
29
  const gameQuestIds = inProgressQuests.map((quest) => quest.api_no)
30
30
  const unlockedGameQuest = Object.fromEntries(
31
- inProgressQuests.map((quest) => [quest.api_no, quest])
31
+ inProgressQuests.map((quest) => [quest.api_no, quest]),
32
32
  )
33
33
  const alreadyCompletedQuest = getCompletedQuest(gameQuestIds)
34
34
  const lockedQuest = getLockedQuest(gameQuestIds)
@@ -12,7 +12,7 @@ export const usePreferKcwiki = () => {
12
12
  }
13
13
 
14
14
  export const checkIsKcwikiSupportedLanguages = (
15
- lang: string
15
+ lang: string,
16
16
  ): lang is keyof typeof kcwikiQuestData => {
17
17
  const kcwikiQuestData = getKcwikiQuestData()
18
18
  return lang in kcwikiQuestData
@@ -12,14 +12,14 @@ import { checkIsKcwikiSupportedLanguages, useKcwikiData } from './kcwiki'
12
12
  const DEFAULT_LANG = 'ja-JP'
13
13
 
14
14
  const checkIsKcanotifySupportedLanguages = (
15
- lang: string
15
+ lang: string,
16
16
  ): lang is keyof typeof kcaQuestData => {
17
17
  const kcaQuestData = getKcanotifyQuestData()
18
18
  return lang in kcaQuestData
19
19
  }
20
20
 
21
21
  export const isSupportedLanguages = (
22
- lang: string
22
+ lang: string,
23
23
  ): lang is keyof ReturnType<typeof getKcanotifyQuestData> =>
24
24
  checkIsKcanotifySupportedLanguages(lang) ||
25
25
  checkIsKcwikiSupportedLanguages(lang)
@@ -1,7 +1,28 @@
1
- import { useCallback } from 'react'
2
- import { useThrottle } from 'react-use'
1
+ import { useCallback, useEffect, useRef, useState } from 'react'
3
2
  import { useStore } from './store'
4
3
 
4
+ // Fix https://github.com/streamich/react-use/issues/2488
5
+ // Ported from https://hooks-guide.netlify.app/community/useThrottle
6
+ const useThrottle = <T>(value: T, limit = 200) => {
7
+ const [throttledValue, setThrottledValue] = useState(value)
8
+ const lastRan = useRef(Date.now())
9
+ useEffect(() => {
10
+ const handler = setTimeout(
11
+ function () {
12
+ if (Date.now() - lastRan.current >= limit) {
13
+ setThrottledValue(value)
14
+ lastRan.current = Date.now()
15
+ }
16
+ },
17
+ limit - (Date.now() - lastRan.current),
18
+ )
19
+ return () => {
20
+ clearTimeout(handler)
21
+ }
22
+ }, [value, limit])
23
+ return throttledValue
24
+ }
25
+
5
26
  export const useSearchInput = () => {
6
27
  const {
7
28
  store: { searchInput },
@@ -9,7 +30,7 @@ export const useSearchInput = () => {
9
30
  } = useStore()
10
31
  const setSearchInput = useCallback(
11
32
  (value: string) => updateStore({ searchInput: value }),
12
- [updateStore]
33
+ [updateStore],
13
34
  )
14
35
  return {
15
36
  searchInput,
@@ -97,7 +97,7 @@ export const useStore = () => {
97
97
  (newStore: Partial<State>) => {
98
98
  setStore((previousStore) => ({ ...previousStore, ...newStore }))
99
99
  },
100
- [setStore]
100
+ [setStore],
101
101
  )
102
102
 
103
103
  return { store, setStore, updateStore }
package/src/tags.tsx CHANGED
@@ -173,7 +173,7 @@ export const TypeTags = () => {
173
173
  const { progressTag } = useFilterProgressTag()
174
174
 
175
175
  const inProgressQuest = gameQuests.filter((gameQuest) =>
176
- isInProgressQuest(gameQuest)
176
+ isInProgressQuest(gameQuest),
177
177
  )
178
178
  const { typeTags, setTypeTags } = useFilterTags()
179
179