@kotenbu135/genshin-calc-wasm 0.2.4
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.
- package/LICENSE +21 -0
- package/README.md +110 -0
- package/genshin_calc_wasm.d.ts +197 -0
- package/genshin_calc_wasm.js +789 -0
- package/genshin_calc_wasm_bg.wasm +0 -0
- package/package.json +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kotenbu135
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# @kotenbu135/genshin-calc-wasm
|
|
2
|
+
|
|
3
|
+
Genshin Impact damage calculator — WASM bindings for the browser.
|
|
4
|
+
|
|
5
|
+
Built on [genshin-calc](https://crates.io/crates/genshin-calc-core), a Rust-based calculation engine.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @kotenbu135/genshin-calc-wasm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import init, {
|
|
17
|
+
game_version,
|
|
18
|
+
find_character,
|
|
19
|
+
calculate_damage,
|
|
20
|
+
calculate_transformative,
|
|
21
|
+
calculate_lunar,
|
|
22
|
+
resolve_team_stats,
|
|
23
|
+
import_good,
|
|
24
|
+
} from "@kotenbu135/genshin-calc-wasm";
|
|
25
|
+
|
|
26
|
+
// Initialize the WASM module first
|
|
27
|
+
await init();
|
|
28
|
+
|
|
29
|
+
// Game data version
|
|
30
|
+
console.log(game_version()); // "5.8"
|
|
31
|
+
|
|
32
|
+
// Look up a character
|
|
33
|
+
const diluc = find_character("diluc");
|
|
34
|
+
console.log(diluc.name); // "Diluc"
|
|
35
|
+
|
|
36
|
+
// Calculate damage
|
|
37
|
+
const result = calculate_damage(
|
|
38
|
+
{
|
|
39
|
+
character_level: 90,
|
|
40
|
+
stats: {
|
|
41
|
+
hp: 20000,
|
|
42
|
+
atk: 2000,
|
|
43
|
+
def: 800,
|
|
44
|
+
elemental_mastery: 100,
|
|
45
|
+
crit_rate: 0.75,
|
|
46
|
+
crit_dmg: 1.5,
|
|
47
|
+
energy_recharge: 1.2,
|
|
48
|
+
dmg_bonus: 0.466,
|
|
49
|
+
},
|
|
50
|
+
talent_multiplier: 1.76,
|
|
51
|
+
scaling_stat: "Atk",
|
|
52
|
+
damage_type: "Skill",
|
|
53
|
+
element: "Pyro",
|
|
54
|
+
reaction: null,
|
|
55
|
+
reaction_bonus: 0,
|
|
56
|
+
flat_dmg: 0,
|
|
57
|
+
},
|
|
58
|
+
{ level: 90, resistance: 0.1, def_reduction: 0 }
|
|
59
|
+
);
|
|
60
|
+
console.log(result); // { non_crit, crit, average, reaction }
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
### Data Lookup
|
|
66
|
+
|
|
67
|
+
| Function | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `game_version()` | Returns the game data version string |
|
|
70
|
+
| `find_character(id)` | Find character by ID (e.g. `"hu_tao"`) |
|
|
71
|
+
| `find_weapon(id)` | Find weapon by ID (e.g. `"wolfs_gravestone"`) |
|
|
72
|
+
| `find_artifact_set(id)` | Find artifact set by ID (e.g. `"crimson_witch"`) |
|
|
73
|
+
| `find_enemy(id)` | Find enemy by ID (e.g. `"hilichurl"`) |
|
|
74
|
+
| `characters_by_element(el)` | List characters by element (e.g. `"pyro"`) |
|
|
75
|
+
| `weapons_by_type(type)` | List weapons by type (e.g. `"claymore"`) |
|
|
76
|
+
|
|
77
|
+
### Calculation
|
|
78
|
+
|
|
79
|
+
| Function | Description |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `calculate_damage(input, enemy)` | Standard damage (ATK/HP/DEF scaling) |
|
|
82
|
+
| `calculate_transformative(input, enemy)` | Transformative reactions (overloaded, swirl, etc.) |
|
|
83
|
+
| `calculate_lunar(input, enemy)` | Lunar reactions (Nod-Krai crittable reactions) |
|
|
84
|
+
| `resolve_team_stats(members, target_index)` | Resolve team buffs into final stats |
|
|
85
|
+
|
|
86
|
+
### GOOD Format Import
|
|
87
|
+
|
|
88
|
+
| Function | Description |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `import_good(json)` | Import GOOD JSON string → `GoodImport` with character builds |
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// Import from Genshin Optimizer, Scanner tools, etc.
|
|
94
|
+
const goodJson = '{"format":"GOOD","source":"GenshinOptimizer","version":2,...}';
|
|
95
|
+
const imported = import_good(goodJson);
|
|
96
|
+
console.log(imported.builds); // Array of CharacterBuild objects
|
|
97
|
+
console.log(imported.warnings); // Any import warnings
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## TypeScript
|
|
101
|
+
|
|
102
|
+
Type definitions for all input/output objects are available at `types.ts`.
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
import type { DamageInput, Enemy, DamageResult } from "@kotenbu135/genshin-calc-wasm/types";
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Calculates final stats for a character build with conditional buff activations.
|
|
6
|
+
*
|
|
7
|
+
* Unlike `build_stats_from_good`, this function resolves weapon and artifact
|
|
8
|
+
* conditional buffs (toggles, stacks) via TeamMemberBuilder.
|
|
9
|
+
*
|
|
10
|
+
* # Arguments
|
|
11
|
+
* * `json` - GOOD format JSON string
|
|
12
|
+
* * `character_id` - Character ID (e.g. "diluc")
|
|
13
|
+
* * `weapon_activations` - JS array of {name, active, stacks?} for weapon buffs
|
|
14
|
+
* * `artifact_activations` - JS array of {name, active, stacks?} for artifact set buffs
|
|
15
|
+
*
|
|
16
|
+
* # Returns
|
|
17
|
+
* Stats as a JS object, or null if character not found.
|
|
18
|
+
*/
|
|
19
|
+
export function build_stats(json: string, character_id: string, weapon_activations: any, artifact_activations: any): any;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Calculates final stats for a character from a GOOD JSON export.
|
|
23
|
+
*
|
|
24
|
+
* # Arguments
|
|
25
|
+
* * `json` - GOOD format JSON string (same as `import_good`)
|
|
26
|
+
* * `character_id` - Character ID to find (e.g. "hu_tao")
|
|
27
|
+
*
|
|
28
|
+
* # Returns
|
|
29
|
+
* Stats with per-element DMG bonuses in separate fields.
|
|
30
|
+
* Returns null if the character is not found in the GOOD data.
|
|
31
|
+
*/
|
|
32
|
+
export function build_stats_from_good(json: string, character_id: string): any;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Calculates standard damage (ATK/HP/DEF scaling with crit, defense, resistance).
|
|
36
|
+
*
|
|
37
|
+
* # Arguments
|
|
38
|
+
* * `input` - DamageInput as a JS object (PascalCase enum variants, e.g. element: "Pyro")
|
|
39
|
+
* * `enemy` - Enemy as a JS object
|
|
40
|
+
*
|
|
41
|
+
* # Returns
|
|
42
|
+
* DamageResult as a JS object with non_crit, crit, average, reaction fields.
|
|
43
|
+
*
|
|
44
|
+
* # Errors
|
|
45
|
+
* Throws JsError on invalid input or calculation error.
|
|
46
|
+
*/
|
|
47
|
+
export function calculate_damage(input: any, enemy: any): any;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Calculates lunar reaction damage (Nod-Krai exclusive crittable reactions).
|
|
51
|
+
*
|
|
52
|
+
* # Arguments
|
|
53
|
+
* * `input` - LunarInput as a JS object
|
|
54
|
+
* * `enemy` - Enemy as a JS object
|
|
55
|
+
*
|
|
56
|
+
* # Returns
|
|
57
|
+
* LunarResult as a JS object with non_crit, crit, average, damage_element fields.
|
|
58
|
+
*/
|
|
59
|
+
export function calculate_lunar(input: any, enemy: any): any;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Calculates transformative reaction damage (overloaded, superconduct, swirl, etc.).
|
|
63
|
+
*
|
|
64
|
+
* # Arguments
|
|
65
|
+
* * `input` - TransformativeInput as a JS object
|
|
66
|
+
* * `enemy` - Enemy as a JS object
|
|
67
|
+
*
|
|
68
|
+
* # Returns
|
|
69
|
+
* TransformativeResult as a JS object with damage and damage_element fields.
|
|
70
|
+
*/
|
|
71
|
+
export function calculate_transformative(input: any, enemy: any): any;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns all characters with the given element.
|
|
75
|
+
* Element is a lowercase string: "pyro", "hydro", "electro", "cryo", "anemo", "geo", "dendro".
|
|
76
|
+
*/
|
|
77
|
+
export function characters_by_element(element: string): any;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Finds an artifact set by ID (lowercase, e.g. "crimson_witch").
|
|
81
|
+
* Returns the artifact set data as a JS object, or null if not found.
|
|
82
|
+
*/
|
|
83
|
+
export function find_artifact_set(id: string): any;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Finds a character by ID (lowercase, e.g. "diluc", "hu_tao").
|
|
87
|
+
* Returns the character data as a JS object, or null if not found.
|
|
88
|
+
*/
|
|
89
|
+
export function find_character(id: string): any;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Finds an enemy by ID (lowercase, e.g. "hilichurl").
|
|
93
|
+
* Returns the enemy data as a JS object, or null if not found.
|
|
94
|
+
*/
|
|
95
|
+
export function find_enemy(id: string): any;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Finds a weapon by ID (lowercase, e.g. "wolfs_gravestone").
|
|
99
|
+
* Returns the weapon data as a JS object, or null if not found.
|
|
100
|
+
*/
|
|
101
|
+
export function find_weapon(id: string): any;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns the current game data version.
|
|
105
|
+
*/
|
|
106
|
+
export function game_version(): string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Imports a GOOD (Genshin Open Object Description) JSON string and returns parsed character builds.
|
|
110
|
+
*
|
|
111
|
+
* # Arguments
|
|
112
|
+
* * `json` - GOOD format JSON string (e.g. exported from Genshin Optimizer, Scanner tools)
|
|
113
|
+
*
|
|
114
|
+
* # Returns
|
|
115
|
+
* GoodImport object with source, version, builds array, and warnings.
|
|
116
|
+
*
|
|
117
|
+
* # Errors
|
|
118
|
+
* Throws JsError on invalid JSON or unsupported GOOD format.
|
|
119
|
+
*/
|
|
120
|
+
export function import_good(json: string): any;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Initialize panic hook for better error messages in browser console.
|
|
124
|
+
*/
|
|
125
|
+
export function init(): void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resolves team buffs and returns final stats for the target member.
|
|
129
|
+
*
|
|
130
|
+
* # Arguments
|
|
131
|
+
* * `members` - Array of TeamMember objects
|
|
132
|
+
* * `target_index` - Index of the DPS/target member (0-based)
|
|
133
|
+
*
|
|
134
|
+
* # Returns
|
|
135
|
+
* Stats as a JS object with hp, atk, def, elemental_mastery, crit_rate,
|
|
136
|
+
* crit_dmg, energy_recharge, dmg_bonus, pyro_dmg_bonus, hydro_dmg_bonus,
|
|
137
|
+
* electro_dmg_bonus, cryo_dmg_bonus, dendro_dmg_bonus, anemo_dmg_bonus,
|
|
138
|
+
* geo_dmg_bonus, physical_dmg_bonus.
|
|
139
|
+
*/
|
|
140
|
+
export function resolve_team_stats(members: any, target_index: number): any;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Returns all weapons of the given type.
|
|
144
|
+
* Weapon type is a lowercase string: "sword", "claymore", "polearm", "bow", "catalyst".
|
|
145
|
+
*/
|
|
146
|
+
export function weapons_by_type(weapon_type: string): any;
|
|
147
|
+
|
|
148
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
149
|
+
|
|
150
|
+
export interface InitOutput {
|
|
151
|
+
readonly memory: WebAssembly.Memory;
|
|
152
|
+
readonly build_stats: (a: number, b: number, c: number, d: number, e: any, f: any) => [number, number, number];
|
|
153
|
+
readonly build_stats_from_good: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
154
|
+
readonly calculate_damage: (a: any, b: any) => [number, number, number];
|
|
155
|
+
readonly calculate_lunar: (a: any, b: any) => [number, number, number];
|
|
156
|
+
readonly calculate_transformative: (a: any, b: any) => [number, number, number];
|
|
157
|
+
readonly characters_by_element: (a: number, b: number) => [number, number, number];
|
|
158
|
+
readonly find_artifact_set: (a: number, b: number) => [number, number, number];
|
|
159
|
+
readonly find_character: (a: number, b: number) => [number, number, number];
|
|
160
|
+
readonly find_enemy: (a: number, b: number) => [number, number, number];
|
|
161
|
+
readonly find_weapon: (a: number, b: number) => [number, number, number];
|
|
162
|
+
readonly game_version: () => [number, number];
|
|
163
|
+
readonly import_good: (a: number, b: number) => [number, number, number];
|
|
164
|
+
readonly resolve_team_stats: (a: any, b: number) => [number, number, number];
|
|
165
|
+
readonly weapons_by_type: (a: number, b: number) => [number, number, number];
|
|
166
|
+
readonly init: () => void;
|
|
167
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
168
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
169
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
170
|
+
readonly __externref_table_alloc: () => number;
|
|
171
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
172
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
173
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
174
|
+
readonly __wbindgen_start: () => void;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
181
|
+
* a precompiled `WebAssembly.Module`.
|
|
182
|
+
*
|
|
183
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
184
|
+
*
|
|
185
|
+
* @returns {InitOutput}
|
|
186
|
+
*/
|
|
187
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
191
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
192
|
+
*
|
|
193
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
194
|
+
*
|
|
195
|
+
* @returns {Promise<InitOutput>}
|
|
196
|
+
*/
|
|
197
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,789 @@
|
|
|
1
|
+
/* @ts-self-types="./genshin_calc_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Calculates final stats for a character build with conditional buff activations.
|
|
5
|
+
*
|
|
6
|
+
* Unlike `build_stats_from_good`, this function resolves weapon and artifact
|
|
7
|
+
* conditional buffs (toggles, stacks) via TeamMemberBuilder.
|
|
8
|
+
*
|
|
9
|
+
* # Arguments
|
|
10
|
+
* * `json` - GOOD format JSON string
|
|
11
|
+
* * `character_id` - Character ID (e.g. "diluc")
|
|
12
|
+
* * `weapon_activations` - JS array of {name, active, stacks?} for weapon buffs
|
|
13
|
+
* * `artifact_activations` - JS array of {name, active, stacks?} for artifact set buffs
|
|
14
|
+
*
|
|
15
|
+
* # Returns
|
|
16
|
+
* Stats as a JS object, or null if character not found.
|
|
17
|
+
* @param {string} json
|
|
18
|
+
* @param {string} character_id
|
|
19
|
+
* @param {any} weapon_activations
|
|
20
|
+
* @param {any} artifact_activations
|
|
21
|
+
* @returns {any}
|
|
22
|
+
*/
|
|
23
|
+
export function build_stats(json, character_id, weapon_activations, artifact_activations) {
|
|
24
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
25
|
+
const len0 = WASM_VECTOR_LEN;
|
|
26
|
+
const ptr1 = passStringToWasm0(character_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
27
|
+
const len1 = WASM_VECTOR_LEN;
|
|
28
|
+
const ret = wasm.build_stats(ptr0, len0, ptr1, len1, weapon_activations, artifact_activations);
|
|
29
|
+
if (ret[2]) {
|
|
30
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
31
|
+
}
|
|
32
|
+
return takeFromExternrefTable0(ret[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Calculates final stats for a character from a GOOD JSON export.
|
|
37
|
+
*
|
|
38
|
+
* # Arguments
|
|
39
|
+
* * `json` - GOOD format JSON string (same as `import_good`)
|
|
40
|
+
* * `character_id` - Character ID to find (e.g. "hu_tao")
|
|
41
|
+
*
|
|
42
|
+
* # Returns
|
|
43
|
+
* Stats with per-element DMG bonuses in separate fields.
|
|
44
|
+
* Returns null if the character is not found in the GOOD data.
|
|
45
|
+
* @param {string} json
|
|
46
|
+
* @param {string} character_id
|
|
47
|
+
* @returns {any}
|
|
48
|
+
*/
|
|
49
|
+
export function build_stats_from_good(json, character_id) {
|
|
50
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ptr1 = passStringToWasm0(character_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
53
|
+
const len1 = WASM_VECTOR_LEN;
|
|
54
|
+
const ret = wasm.build_stats_from_good(ptr0, len0, ptr1, len1);
|
|
55
|
+
if (ret[2]) {
|
|
56
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
57
|
+
}
|
|
58
|
+
return takeFromExternrefTable0(ret[0]);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Calculates standard damage (ATK/HP/DEF scaling with crit, defense, resistance).
|
|
63
|
+
*
|
|
64
|
+
* # Arguments
|
|
65
|
+
* * `input` - DamageInput as a JS object (PascalCase enum variants, e.g. element: "Pyro")
|
|
66
|
+
* * `enemy` - Enemy as a JS object
|
|
67
|
+
*
|
|
68
|
+
* # Returns
|
|
69
|
+
* DamageResult as a JS object with non_crit, crit, average, reaction fields.
|
|
70
|
+
*
|
|
71
|
+
* # Errors
|
|
72
|
+
* Throws JsError on invalid input or calculation error.
|
|
73
|
+
* @param {any} input
|
|
74
|
+
* @param {any} enemy
|
|
75
|
+
* @returns {any}
|
|
76
|
+
*/
|
|
77
|
+
export function calculate_damage(input, enemy) {
|
|
78
|
+
const ret = wasm.calculate_damage(input, enemy);
|
|
79
|
+
if (ret[2]) {
|
|
80
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
81
|
+
}
|
|
82
|
+
return takeFromExternrefTable0(ret[0]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Calculates lunar reaction damage (Nod-Krai exclusive crittable reactions).
|
|
87
|
+
*
|
|
88
|
+
* # Arguments
|
|
89
|
+
* * `input` - LunarInput as a JS object
|
|
90
|
+
* * `enemy` - Enemy as a JS object
|
|
91
|
+
*
|
|
92
|
+
* # Returns
|
|
93
|
+
* LunarResult as a JS object with non_crit, crit, average, damage_element fields.
|
|
94
|
+
* @param {any} input
|
|
95
|
+
* @param {any} enemy
|
|
96
|
+
* @returns {any}
|
|
97
|
+
*/
|
|
98
|
+
export function calculate_lunar(input, enemy) {
|
|
99
|
+
const ret = wasm.calculate_lunar(input, enemy);
|
|
100
|
+
if (ret[2]) {
|
|
101
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
102
|
+
}
|
|
103
|
+
return takeFromExternrefTable0(ret[0]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Calculates transformative reaction damage (overloaded, superconduct, swirl, etc.).
|
|
108
|
+
*
|
|
109
|
+
* # Arguments
|
|
110
|
+
* * `input` - TransformativeInput as a JS object
|
|
111
|
+
* * `enemy` - Enemy as a JS object
|
|
112
|
+
*
|
|
113
|
+
* # Returns
|
|
114
|
+
* TransformativeResult as a JS object with damage and damage_element fields.
|
|
115
|
+
* @param {any} input
|
|
116
|
+
* @param {any} enemy
|
|
117
|
+
* @returns {any}
|
|
118
|
+
*/
|
|
119
|
+
export function calculate_transformative(input, enemy) {
|
|
120
|
+
const ret = wasm.calculate_transformative(input, enemy);
|
|
121
|
+
if (ret[2]) {
|
|
122
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
123
|
+
}
|
|
124
|
+
return takeFromExternrefTable0(ret[0]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Returns all characters with the given element.
|
|
129
|
+
* Element is a lowercase string: "pyro", "hydro", "electro", "cryo", "anemo", "geo", "dendro".
|
|
130
|
+
* @param {string} element
|
|
131
|
+
* @returns {any}
|
|
132
|
+
*/
|
|
133
|
+
export function characters_by_element(element) {
|
|
134
|
+
const ptr0 = passStringToWasm0(element, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
135
|
+
const len0 = WASM_VECTOR_LEN;
|
|
136
|
+
const ret = wasm.characters_by_element(ptr0, len0);
|
|
137
|
+
if (ret[2]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
139
|
+
}
|
|
140
|
+
return takeFromExternrefTable0(ret[0]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Finds an artifact set by ID (lowercase, e.g. "crimson_witch").
|
|
145
|
+
* Returns the artifact set data as a JS object, or null if not found.
|
|
146
|
+
* @param {string} id
|
|
147
|
+
* @returns {any}
|
|
148
|
+
*/
|
|
149
|
+
export function find_artifact_set(id) {
|
|
150
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
151
|
+
const len0 = WASM_VECTOR_LEN;
|
|
152
|
+
const ret = wasm.find_artifact_set(ptr0, len0);
|
|
153
|
+
if (ret[2]) {
|
|
154
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
155
|
+
}
|
|
156
|
+
return takeFromExternrefTable0(ret[0]);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Finds a character by ID (lowercase, e.g. "diluc", "hu_tao").
|
|
161
|
+
* Returns the character data as a JS object, or null if not found.
|
|
162
|
+
* @param {string} id
|
|
163
|
+
* @returns {any}
|
|
164
|
+
*/
|
|
165
|
+
export function find_character(id) {
|
|
166
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
167
|
+
const len0 = WASM_VECTOR_LEN;
|
|
168
|
+
const ret = wasm.find_character(ptr0, len0);
|
|
169
|
+
if (ret[2]) {
|
|
170
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
171
|
+
}
|
|
172
|
+
return takeFromExternrefTable0(ret[0]);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Finds an enemy by ID (lowercase, e.g. "hilichurl").
|
|
177
|
+
* Returns the enemy data as a JS object, or null if not found.
|
|
178
|
+
* @param {string} id
|
|
179
|
+
* @returns {any}
|
|
180
|
+
*/
|
|
181
|
+
export function find_enemy(id) {
|
|
182
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
183
|
+
const len0 = WASM_VECTOR_LEN;
|
|
184
|
+
const ret = wasm.find_enemy(ptr0, len0);
|
|
185
|
+
if (ret[2]) {
|
|
186
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
187
|
+
}
|
|
188
|
+
return takeFromExternrefTable0(ret[0]);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Finds a weapon by ID (lowercase, e.g. "wolfs_gravestone").
|
|
193
|
+
* Returns the weapon data as a JS object, or null if not found.
|
|
194
|
+
* @param {string} id
|
|
195
|
+
* @returns {any}
|
|
196
|
+
*/
|
|
197
|
+
export function find_weapon(id) {
|
|
198
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
199
|
+
const len0 = WASM_VECTOR_LEN;
|
|
200
|
+
const ret = wasm.find_weapon(ptr0, len0);
|
|
201
|
+
if (ret[2]) {
|
|
202
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
203
|
+
}
|
|
204
|
+
return takeFromExternrefTable0(ret[0]);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Returns the current game data version.
|
|
209
|
+
* @returns {string}
|
|
210
|
+
*/
|
|
211
|
+
export function game_version() {
|
|
212
|
+
let deferred1_0;
|
|
213
|
+
let deferred1_1;
|
|
214
|
+
try {
|
|
215
|
+
const ret = wasm.game_version();
|
|
216
|
+
deferred1_0 = ret[0];
|
|
217
|
+
deferred1_1 = ret[1];
|
|
218
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
219
|
+
} finally {
|
|
220
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Imports a GOOD (Genshin Open Object Description) JSON string and returns parsed character builds.
|
|
226
|
+
*
|
|
227
|
+
* # Arguments
|
|
228
|
+
* * `json` - GOOD format JSON string (e.g. exported from Genshin Optimizer, Scanner tools)
|
|
229
|
+
*
|
|
230
|
+
* # Returns
|
|
231
|
+
* GoodImport object with source, version, builds array, and warnings.
|
|
232
|
+
*
|
|
233
|
+
* # Errors
|
|
234
|
+
* Throws JsError on invalid JSON or unsupported GOOD format.
|
|
235
|
+
* @param {string} json
|
|
236
|
+
* @returns {any}
|
|
237
|
+
*/
|
|
238
|
+
export function import_good(json) {
|
|
239
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
240
|
+
const len0 = WASM_VECTOR_LEN;
|
|
241
|
+
const ret = wasm.import_good(ptr0, len0);
|
|
242
|
+
if (ret[2]) {
|
|
243
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
244
|
+
}
|
|
245
|
+
return takeFromExternrefTable0(ret[0]);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Initialize panic hook for better error messages in browser console.
|
|
250
|
+
*/
|
|
251
|
+
export function init() {
|
|
252
|
+
wasm.init();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Resolves team buffs and returns final stats for the target member.
|
|
257
|
+
*
|
|
258
|
+
* # Arguments
|
|
259
|
+
* * `members` - Array of TeamMember objects
|
|
260
|
+
* * `target_index` - Index of the DPS/target member (0-based)
|
|
261
|
+
*
|
|
262
|
+
* # Returns
|
|
263
|
+
* Stats as a JS object with hp, atk, def, elemental_mastery, crit_rate,
|
|
264
|
+
* crit_dmg, energy_recharge, dmg_bonus, pyro_dmg_bonus, hydro_dmg_bonus,
|
|
265
|
+
* electro_dmg_bonus, cryo_dmg_bonus, dendro_dmg_bonus, anemo_dmg_bonus,
|
|
266
|
+
* geo_dmg_bonus, physical_dmg_bonus.
|
|
267
|
+
* @param {any} members
|
|
268
|
+
* @param {number} target_index
|
|
269
|
+
* @returns {any}
|
|
270
|
+
*/
|
|
271
|
+
export function resolve_team_stats(members, target_index) {
|
|
272
|
+
const ret = wasm.resolve_team_stats(members, target_index);
|
|
273
|
+
if (ret[2]) {
|
|
274
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
275
|
+
}
|
|
276
|
+
return takeFromExternrefTable0(ret[0]);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Returns all weapons of the given type.
|
|
281
|
+
* Weapon type is a lowercase string: "sword", "claymore", "polearm", "bow", "catalyst".
|
|
282
|
+
* @param {string} weapon_type
|
|
283
|
+
* @returns {any}
|
|
284
|
+
*/
|
|
285
|
+
export function weapons_by_type(weapon_type) {
|
|
286
|
+
const ptr0 = passStringToWasm0(weapon_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
287
|
+
const len0 = WASM_VECTOR_LEN;
|
|
288
|
+
const ret = wasm.weapons_by_type(ptr0, len0);
|
|
289
|
+
if (ret[2]) {
|
|
290
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
291
|
+
}
|
|
292
|
+
return takeFromExternrefTable0(ret[0]);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function __wbg_get_imports() {
|
|
296
|
+
const import0 = {
|
|
297
|
+
__proto__: null,
|
|
298
|
+
__wbg_Error_55538483de6e3abe: function(arg0, arg1) {
|
|
299
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
300
|
+
return ret;
|
|
301
|
+
},
|
|
302
|
+
__wbg_Number_f257194b7002d6f9: function(arg0) {
|
|
303
|
+
const ret = Number(arg0);
|
|
304
|
+
return ret;
|
|
305
|
+
},
|
|
306
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
307
|
+
const ret = String(arg1);
|
|
308
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
309
|
+
const len1 = WASM_VECTOR_LEN;
|
|
310
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
311
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
312
|
+
},
|
|
313
|
+
__wbg___wbindgen_boolean_get_fe2a24fdfdb4064f: function(arg0) {
|
|
314
|
+
const v = arg0;
|
|
315
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
316
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
317
|
+
},
|
|
318
|
+
__wbg___wbindgen_debug_string_d89627202d0155b7: function(arg0, arg1) {
|
|
319
|
+
const ret = debugString(arg1);
|
|
320
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
321
|
+
const len1 = WASM_VECTOR_LEN;
|
|
322
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
323
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
324
|
+
},
|
|
325
|
+
__wbg___wbindgen_in_fe3eb6a509f75744: function(arg0, arg1) {
|
|
326
|
+
const ret = arg0 in arg1;
|
|
327
|
+
return ret;
|
|
328
|
+
},
|
|
329
|
+
__wbg___wbindgen_is_function_2a95406423ea8626: function(arg0) {
|
|
330
|
+
const ret = typeof(arg0) === 'function';
|
|
331
|
+
return ret;
|
|
332
|
+
},
|
|
333
|
+
__wbg___wbindgen_is_object_59a002e76b059312: function(arg0) {
|
|
334
|
+
const val = arg0;
|
|
335
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
336
|
+
return ret;
|
|
337
|
+
},
|
|
338
|
+
__wbg___wbindgen_is_string_624d5244bb2bc87c: function(arg0) {
|
|
339
|
+
const ret = typeof(arg0) === 'string';
|
|
340
|
+
return ret;
|
|
341
|
+
},
|
|
342
|
+
__wbg___wbindgen_is_undefined_87a3a837f331fef5: function(arg0) {
|
|
343
|
+
const ret = arg0 === undefined;
|
|
344
|
+
return ret;
|
|
345
|
+
},
|
|
346
|
+
__wbg___wbindgen_jsval_loose_eq_cf851f110c48f9ba: function(arg0, arg1) {
|
|
347
|
+
const ret = arg0 == arg1;
|
|
348
|
+
return ret;
|
|
349
|
+
},
|
|
350
|
+
__wbg___wbindgen_number_get_769f3676dc20c1d7: function(arg0, arg1) {
|
|
351
|
+
const obj = arg1;
|
|
352
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
353
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
354
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
355
|
+
},
|
|
356
|
+
__wbg___wbindgen_string_get_f1161390414f9b59: function(arg0, arg1) {
|
|
357
|
+
const obj = arg1;
|
|
358
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
359
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
360
|
+
var len1 = WASM_VECTOR_LEN;
|
|
361
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
362
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
363
|
+
},
|
|
364
|
+
__wbg___wbindgen_throw_5549492daedad139: function(arg0, arg1) {
|
|
365
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
366
|
+
},
|
|
367
|
+
__wbg_call_6ae20895a60069a2: function() { return handleError(function (arg0, arg1) {
|
|
368
|
+
const ret = arg0.call(arg1);
|
|
369
|
+
return ret;
|
|
370
|
+
}, arguments); },
|
|
371
|
+
__wbg_done_19f92cb1f8738aba: function(arg0) {
|
|
372
|
+
const ret = arg0.done;
|
|
373
|
+
return ret;
|
|
374
|
+
},
|
|
375
|
+
__wbg_entries_28ed7cb892e12eff: function(arg0) {
|
|
376
|
+
const ret = Object.entries(arg0);
|
|
377
|
+
return ret;
|
|
378
|
+
},
|
|
379
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
380
|
+
let deferred0_0;
|
|
381
|
+
let deferred0_1;
|
|
382
|
+
try {
|
|
383
|
+
deferred0_0 = arg0;
|
|
384
|
+
deferred0_1 = arg1;
|
|
385
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
386
|
+
} finally {
|
|
387
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
__wbg_get_94f5fc088edd3138: function(arg0, arg1) {
|
|
391
|
+
const ret = arg0[arg1 >>> 0];
|
|
392
|
+
return ret;
|
|
393
|
+
},
|
|
394
|
+
__wbg_get_a50328e7325d7f9b: function() { return handleError(function (arg0, arg1) {
|
|
395
|
+
const ret = Reflect.get(arg0, arg1);
|
|
396
|
+
return ret;
|
|
397
|
+
}, arguments); },
|
|
398
|
+
__wbg_get_unchecked_7c6bbabf5b0b1fbf: function(arg0, arg1) {
|
|
399
|
+
const ret = arg0[arg1 >>> 0];
|
|
400
|
+
return ret;
|
|
401
|
+
},
|
|
402
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
403
|
+
const ret = arg0[arg1];
|
|
404
|
+
return ret;
|
|
405
|
+
},
|
|
406
|
+
__wbg_instanceof_ArrayBuffer_8d855993947fc3a2: function(arg0) {
|
|
407
|
+
let result;
|
|
408
|
+
try {
|
|
409
|
+
result = arg0 instanceof ArrayBuffer;
|
|
410
|
+
} catch (_) {
|
|
411
|
+
result = false;
|
|
412
|
+
}
|
|
413
|
+
const ret = result;
|
|
414
|
+
return ret;
|
|
415
|
+
},
|
|
416
|
+
__wbg_instanceof_Uint8Array_ce24d58a5f4bdcc3: function(arg0) {
|
|
417
|
+
let result;
|
|
418
|
+
try {
|
|
419
|
+
result = arg0 instanceof Uint8Array;
|
|
420
|
+
} catch (_) {
|
|
421
|
+
result = false;
|
|
422
|
+
}
|
|
423
|
+
const ret = result;
|
|
424
|
+
return ret;
|
|
425
|
+
},
|
|
426
|
+
__wbg_isArray_867202cf8f195ed8: function(arg0) {
|
|
427
|
+
const ret = Array.isArray(arg0);
|
|
428
|
+
return ret;
|
|
429
|
+
},
|
|
430
|
+
__wbg_isSafeInteger_1dfae065cbfe1915: function(arg0) {
|
|
431
|
+
const ret = Number.isSafeInteger(arg0);
|
|
432
|
+
return ret;
|
|
433
|
+
},
|
|
434
|
+
__wbg_iterator_54661826e186eb6a: function() {
|
|
435
|
+
const ret = Symbol.iterator;
|
|
436
|
+
return ret;
|
|
437
|
+
},
|
|
438
|
+
__wbg_length_e6e1633fbea6cfa9: function(arg0) {
|
|
439
|
+
const ret = arg0.length;
|
|
440
|
+
return ret;
|
|
441
|
+
},
|
|
442
|
+
__wbg_length_fae3e439140f48a4: function(arg0) {
|
|
443
|
+
const ret = arg0.length;
|
|
444
|
+
return ret;
|
|
445
|
+
},
|
|
446
|
+
__wbg_new_1d96678aaacca32e: function(arg0) {
|
|
447
|
+
const ret = new Uint8Array(arg0);
|
|
448
|
+
return ret;
|
|
449
|
+
},
|
|
450
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
451
|
+
const ret = new Error();
|
|
452
|
+
return ret;
|
|
453
|
+
},
|
|
454
|
+
__wbg_new_4370be21fa2b2f80: function() {
|
|
455
|
+
const ret = new Array();
|
|
456
|
+
return ret;
|
|
457
|
+
},
|
|
458
|
+
__wbg_new_48e1d86cfd30c8e7: function() {
|
|
459
|
+
const ret = new Object();
|
|
460
|
+
return ret;
|
|
461
|
+
},
|
|
462
|
+
__wbg_next_55d835fe0ab5b3e7: function(arg0) {
|
|
463
|
+
const ret = arg0.next;
|
|
464
|
+
return ret;
|
|
465
|
+
},
|
|
466
|
+
__wbg_next_e34cfb9df1518d7c: function() { return handleError(function (arg0) {
|
|
467
|
+
const ret = arg0.next();
|
|
468
|
+
return ret;
|
|
469
|
+
}, arguments); },
|
|
470
|
+
__wbg_prototypesetcall_3875d54d12ef2eec: function(arg0, arg1, arg2) {
|
|
471
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
472
|
+
},
|
|
473
|
+
__wbg_set_4702dfa37c77f492: function(arg0, arg1, arg2) {
|
|
474
|
+
arg0[arg1 >>> 0] = arg2;
|
|
475
|
+
},
|
|
476
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
477
|
+
arg0[arg1] = arg2;
|
|
478
|
+
},
|
|
479
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
480
|
+
const ret = arg1.stack;
|
|
481
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
482
|
+
const len1 = WASM_VECTOR_LEN;
|
|
483
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
484
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
485
|
+
},
|
|
486
|
+
__wbg_value_d5b248ce8419bd1b: function(arg0) {
|
|
487
|
+
const ret = arg0.value;
|
|
488
|
+
return ret;
|
|
489
|
+
},
|
|
490
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
491
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
492
|
+
const ret = arg0;
|
|
493
|
+
return ret;
|
|
494
|
+
},
|
|
495
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
496
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
497
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
498
|
+
return ret;
|
|
499
|
+
},
|
|
500
|
+
__wbindgen_init_externref_table: function() {
|
|
501
|
+
const table = wasm.__wbindgen_externrefs;
|
|
502
|
+
const offset = table.grow(4);
|
|
503
|
+
table.set(0, undefined);
|
|
504
|
+
table.set(offset + 0, undefined);
|
|
505
|
+
table.set(offset + 1, null);
|
|
506
|
+
table.set(offset + 2, true);
|
|
507
|
+
table.set(offset + 3, false);
|
|
508
|
+
},
|
|
509
|
+
};
|
|
510
|
+
return {
|
|
511
|
+
__proto__: null,
|
|
512
|
+
"./genshin_calc_wasm_bg.js": import0,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function addToExternrefTable0(obj) {
|
|
517
|
+
const idx = wasm.__externref_table_alloc();
|
|
518
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
519
|
+
return idx;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
function debugString(val) {
|
|
523
|
+
// primitive types
|
|
524
|
+
const type = typeof val;
|
|
525
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
526
|
+
return `${val}`;
|
|
527
|
+
}
|
|
528
|
+
if (type == 'string') {
|
|
529
|
+
return `"${val}"`;
|
|
530
|
+
}
|
|
531
|
+
if (type == 'symbol') {
|
|
532
|
+
const description = val.description;
|
|
533
|
+
if (description == null) {
|
|
534
|
+
return 'Symbol';
|
|
535
|
+
} else {
|
|
536
|
+
return `Symbol(${description})`;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (type == 'function') {
|
|
540
|
+
const name = val.name;
|
|
541
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
542
|
+
return `Function(${name})`;
|
|
543
|
+
} else {
|
|
544
|
+
return 'Function';
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// objects
|
|
548
|
+
if (Array.isArray(val)) {
|
|
549
|
+
const length = val.length;
|
|
550
|
+
let debug = '[';
|
|
551
|
+
if (length > 0) {
|
|
552
|
+
debug += debugString(val[0]);
|
|
553
|
+
}
|
|
554
|
+
for(let i = 1; i < length; i++) {
|
|
555
|
+
debug += ', ' + debugString(val[i]);
|
|
556
|
+
}
|
|
557
|
+
debug += ']';
|
|
558
|
+
return debug;
|
|
559
|
+
}
|
|
560
|
+
// Test for built-in
|
|
561
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
562
|
+
let className;
|
|
563
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
564
|
+
className = builtInMatches[1];
|
|
565
|
+
} else {
|
|
566
|
+
// Failed to match the standard '[object ClassName]'
|
|
567
|
+
return toString.call(val);
|
|
568
|
+
}
|
|
569
|
+
if (className == 'Object') {
|
|
570
|
+
// we're a user defined class or Object
|
|
571
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
572
|
+
// easier than looping through ownProperties of `val`.
|
|
573
|
+
try {
|
|
574
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
575
|
+
} catch (_) {
|
|
576
|
+
return 'Object';
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
// errors
|
|
580
|
+
if (val instanceof Error) {
|
|
581
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
582
|
+
}
|
|
583
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
584
|
+
return className;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
588
|
+
ptr = ptr >>> 0;
|
|
589
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
let cachedDataViewMemory0 = null;
|
|
593
|
+
function getDataViewMemory0() {
|
|
594
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
595
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
596
|
+
}
|
|
597
|
+
return cachedDataViewMemory0;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function getStringFromWasm0(ptr, len) {
|
|
601
|
+
ptr = ptr >>> 0;
|
|
602
|
+
return decodeText(ptr, len);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
let cachedUint8ArrayMemory0 = null;
|
|
606
|
+
function getUint8ArrayMemory0() {
|
|
607
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
608
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
609
|
+
}
|
|
610
|
+
return cachedUint8ArrayMemory0;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function handleError(f, args) {
|
|
614
|
+
try {
|
|
615
|
+
return f.apply(this, args);
|
|
616
|
+
} catch (e) {
|
|
617
|
+
const idx = addToExternrefTable0(e);
|
|
618
|
+
wasm.__wbindgen_exn_store(idx);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function isLikeNone(x) {
|
|
623
|
+
return x === undefined || x === null;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
627
|
+
if (realloc === undefined) {
|
|
628
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
629
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
630
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
631
|
+
WASM_VECTOR_LEN = buf.length;
|
|
632
|
+
return ptr;
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
let len = arg.length;
|
|
636
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
637
|
+
|
|
638
|
+
const mem = getUint8ArrayMemory0();
|
|
639
|
+
|
|
640
|
+
let offset = 0;
|
|
641
|
+
|
|
642
|
+
for (; offset < len; offset++) {
|
|
643
|
+
const code = arg.charCodeAt(offset);
|
|
644
|
+
if (code > 0x7F) break;
|
|
645
|
+
mem[ptr + offset] = code;
|
|
646
|
+
}
|
|
647
|
+
if (offset !== len) {
|
|
648
|
+
if (offset !== 0) {
|
|
649
|
+
arg = arg.slice(offset);
|
|
650
|
+
}
|
|
651
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
652
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
653
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
654
|
+
|
|
655
|
+
offset += ret.written;
|
|
656
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
WASM_VECTOR_LEN = offset;
|
|
660
|
+
return ptr;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
function takeFromExternrefTable0(idx) {
|
|
664
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
665
|
+
wasm.__externref_table_dealloc(idx);
|
|
666
|
+
return value;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
670
|
+
cachedTextDecoder.decode();
|
|
671
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
672
|
+
let numBytesDecoded = 0;
|
|
673
|
+
function decodeText(ptr, len) {
|
|
674
|
+
numBytesDecoded += len;
|
|
675
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
676
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
677
|
+
cachedTextDecoder.decode();
|
|
678
|
+
numBytesDecoded = len;
|
|
679
|
+
}
|
|
680
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const cachedTextEncoder = new TextEncoder();
|
|
684
|
+
|
|
685
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
686
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
687
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
688
|
+
view.set(buf);
|
|
689
|
+
return {
|
|
690
|
+
read: arg.length,
|
|
691
|
+
written: buf.length
|
|
692
|
+
};
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
let WASM_VECTOR_LEN = 0;
|
|
697
|
+
|
|
698
|
+
let wasmModule, wasm;
|
|
699
|
+
function __wbg_finalize_init(instance, module) {
|
|
700
|
+
wasm = instance.exports;
|
|
701
|
+
wasmModule = module;
|
|
702
|
+
cachedDataViewMemory0 = null;
|
|
703
|
+
cachedUint8ArrayMemory0 = null;
|
|
704
|
+
wasm.__wbindgen_start();
|
|
705
|
+
return wasm;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
async function __wbg_load(module, imports) {
|
|
709
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
710
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
711
|
+
try {
|
|
712
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
713
|
+
} catch (e) {
|
|
714
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
715
|
+
|
|
716
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
717
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
718
|
+
|
|
719
|
+
} else { throw e; }
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
const bytes = await module.arrayBuffer();
|
|
724
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
725
|
+
} else {
|
|
726
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
727
|
+
|
|
728
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
729
|
+
return { instance, module };
|
|
730
|
+
} else {
|
|
731
|
+
return instance;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function expectedResponseType(type) {
|
|
736
|
+
switch (type) {
|
|
737
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
738
|
+
}
|
|
739
|
+
return false;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
function initSync(module) {
|
|
744
|
+
if (wasm !== undefined) return wasm;
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
if (module !== undefined) {
|
|
748
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
749
|
+
({module} = module)
|
|
750
|
+
} else {
|
|
751
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const imports = __wbg_get_imports();
|
|
756
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
757
|
+
module = new WebAssembly.Module(module);
|
|
758
|
+
}
|
|
759
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
760
|
+
return __wbg_finalize_init(instance, module);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
async function __wbg_init(module_or_path) {
|
|
764
|
+
if (wasm !== undefined) return wasm;
|
|
765
|
+
|
|
766
|
+
|
|
767
|
+
if (module_or_path !== undefined) {
|
|
768
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
769
|
+
({module_or_path} = module_or_path)
|
|
770
|
+
} else {
|
|
771
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
if (module_or_path === undefined) {
|
|
776
|
+
module_or_path = new URL('genshin_calc_wasm_bg.wasm', import.meta.url);
|
|
777
|
+
}
|
|
778
|
+
const imports = __wbg_get_imports();
|
|
779
|
+
|
|
780
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
781
|
+
module_or_path = fetch(module_or_path);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
785
|
+
|
|
786
|
+
return __wbg_finalize_init(instance, module);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kotenbu135/genshin-calc-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"kotenbu135"
|
|
6
|
+
],
|
|
7
|
+
"description": "WASM bindings for genshin-calc damage calculator",
|
|
8
|
+
"version": "0.2.4",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/kotenbu135/genshin-calc"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"genshin_calc_wasm_bg.wasm",
|
|
16
|
+
"genshin_calc_wasm.js",
|
|
17
|
+
"genshin_calc_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "genshin_calc_wasm.js",
|
|
20
|
+
"types": "genshin_calc_wasm.d.ts",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"./snippets/*"
|
|
23
|
+
]
|
|
24
|
+
}
|