-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stream changes from go-next proj to master (#1347)
* stream changes from go-next proj to master * format * tsx -> ts
- Loading branch information
Showing
75 changed files
with
2,785 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage", | ||
"importSource": "@emotion/react" | ||
} | ||
] | ||
], | ||
"plugins": ["@emotion/babel-plugin"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# gi-art-scanner | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test gi-art-scanner` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "gi-art-scanner", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/gi-art-scanner/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": { | ||
"lint": { | ||
"executor": "@nx/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["libs/gi-art-scanner/**/*.{ts,tsx,js,jsx}"] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './lib/ScanningQueue' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import type { Outstanding, Processed } from './processImg' | ||
import { processEntry } from './processImg' | ||
|
||
export type ScanningData = { | ||
processedNum: number | ||
outstandingNum: number | ||
scanningNum: number | ||
} | ||
export type { Processed } | ||
|
||
const maxProcessingCount = 3, | ||
maxProcessedCount = 16 | ||
|
||
type textsFromImageFunc = ( | ||
imageData: ImageData, | ||
options?: object | undefined | ||
) => Promise<string[]> | ||
|
||
export class ScanningQueue { | ||
private debug: boolean | ||
private textsFromImage: textsFromImageFunc | ||
constructor(textsFromImage: textsFromImageFunc, debug = false) { | ||
this.textsFromImage = textsFromImage | ||
this.debug = debug | ||
} | ||
private processed = [] as Processed[] | ||
private outstanding = [] as Outstanding[] | ||
private scanning = [] as Promise<Processed>[] | ||
callback = (() => {}) as (data: ScanningData) => void | ||
|
||
addFiles(files: Outstanding[]) { | ||
this.outstanding.push(...files) | ||
this.processQueue() | ||
} | ||
processQueue() { | ||
const numProcessing = Math.min( | ||
maxProcessedCount - this.processed.length - this.scanning.length, | ||
maxProcessingCount - this.scanning.length, | ||
this.outstanding.length | ||
) | ||
numProcessing && | ||
this.outstanding.splice(0, numProcessing).map((p) => { | ||
const prom = processEntry(p, this.textsFromImage, this.debug) | ||
this.scanning.push(prom) | ||
prom.then((procesResult) => { | ||
const index = this.scanning.indexOf(prom) | ||
if (index === -1) return // probably because the queue has been cleared. | ||
this.scanning.splice(index, 1) | ||
this.processed.push(procesResult) | ||
this.processQueue() | ||
}) | ||
}) | ||
this.callCB() | ||
} | ||
private callCB() { | ||
this.callback({ | ||
processedNum: this.processed.length, | ||
outstandingNum: this.outstanding.length, | ||
scanningNum: this.scanning.length, | ||
}) | ||
} | ||
shiftProcessed(): Processed | undefined { | ||
const procesesd = this.processed.shift() | ||
this.processQueue() | ||
return procesesd | ||
} | ||
clearQueue() { | ||
this.processed = [] | ||
this.outstanding = [] | ||
this.scanning = [] | ||
this.callCB() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Color } from '@genshin-optimizer/img-util' | ||
|
||
/** | ||
* "golden" title | ||
* light: bc6832 rgb(188, 104, 50) | ||
* dark: 915128 rgb(145, 81, 40) | ||
*/ | ||
export const goldenTitleDarkerColor: Color = { | ||
r: 145, | ||
g: 81, | ||
b: 40, | ||
} | ||
export const goldenTitleLighterColor: Color = { | ||
r: 188, | ||
g: 104, | ||
b: 50, | ||
} | ||
|
||
// The "baige" background of artifact card, ebe4d8 rgb(235, 228, 216) | ||
export const cardWhite: Color = { | ||
r: 235, | ||
g: 228, | ||
b: 216, | ||
} | ||
|
||
// the yellow bottom for equipment color rgb(255, 231, 186) | ||
export const equipColor: Color = { | ||
r: 255, | ||
g: 231, | ||
b: 186, | ||
} | ||
|
||
// Greentext color | ||
// greenest rgb(93, 178, 87) | ||
// lightgreen rgb(185, 210, 170) | ||
export const greenTextColor: Color = { | ||
r: 93, | ||
g: 178, | ||
b: 87, | ||
} | ||
|
||
export const starColor = { r: 255, g: 204, b: 50 } // #FFCC32 | ||
|
||
export const textColorLight = { r: 131, g: 131, b: 130 } // rgb(131, 131, 130) | ||
export const textColorDark = { r: 74, g: 81, b: 102 } // rgb(74, 81, 102) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { ElementWithPhyKey } from '@genshin-optimizer/consts' | ||
|
||
// Store the english translations to use with artifact scanner | ||
|
||
const elementalData: Record<ElementWithPhyKey, string> = { | ||
physical: 'Physical', | ||
anemo: 'Anemo', | ||
geo: 'Geo', | ||
electro: 'Electro', | ||
hydro: 'Hydro', | ||
pyro: 'Pyro', | ||
cryo: 'Cryo', | ||
dendro: 'Dendro', | ||
} as const | ||
|
||
export const statMap = { | ||
hp: 'HP', | ||
hp_: 'HP', | ||
atk: 'ATK', | ||
atk_: 'ATK', | ||
def: 'DEF', | ||
def_: 'DEF', | ||
eleMas: 'Elemental Mastery', | ||
enerRech_: 'Energy Recharge', | ||
critRate_: 'Crit Rate', | ||
critDMG_: 'Crit DMG', | ||
heal_: 'Healing Bonus', | ||
} as Record<string, string> | ||
|
||
Object.entries(elementalData).forEach(([e, name]) => { | ||
statMap[`${e}_dmg_`] = `${name} DMG Bonus` | ||
}) | ||
|
||
export const artSlotNames = { | ||
flower: 'Flower of Life', | ||
plume: 'Plume of Death', | ||
sands: 'Sands of Eon', | ||
goblet: 'Goblet of Eonothem', | ||
circlet: 'Circlet of Logos', | ||
} |
Oops, something went wrong.