pkhex 25.10.26-a
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/README.md +73 -0
- package/dist/PKHeX.Core.dll +0 -0
- package/dist/PKHeX.deps.json +361 -0
- package/dist/PKHeX.dll +0 -0
- package/dist/PKHeX.runtimeconfig.json +38 -0
- package/dist/System.Collections.Concurrent.dll +0 -0
- package/dist/System.Collections.dll +0 -0
- package/dist/System.ComponentModel.Annotations.dll +0 -0
- package/dist/System.ComponentModel.Primitives.dll +0 -0
- package/dist/System.ComponentModel.TypeConverter.dll +0 -0
- package/dist/System.Console.dll +0 -0
- package/dist/System.Diagnostics.DiagnosticSource.dll +0 -0
- package/dist/System.Diagnostics.TraceSource.dll +0 -0
- package/dist/System.IO.Compression.ZipFile.dll +0 -0
- package/dist/System.IO.Compression.dll +0 -0
- package/dist/System.IO.Pipelines.dll +0 -0
- package/dist/System.Linq.dll +0 -0
- package/dist/System.Memory.dll +0 -0
- package/dist/System.Net.Http.dll +0 -0
- package/dist/System.Net.Primitives.dll +0 -0
- package/dist/System.Numerics.Vectors.dll +0 -0
- package/dist/System.ObjectModel.dll +0 -0
- package/dist/System.Private.CoreLib.dll +0 -0
- package/dist/System.Private.Uri.dll +0 -0
- package/dist/System.Runtime.InteropServices.JavaScript.dll +0 -0
- package/dist/System.Runtime.InteropServices.dll +0 -0
- package/dist/System.Runtime.Numerics.dll +0 -0
- package/dist/System.Runtime.dll +0 -0
- package/dist/System.Security.Cryptography.dll +0 -0
- package/dist/System.Text.Encodings.Web.dll +0 -0
- package/dist/System.Text.Json.dll +0 -0
- package/dist/System.Text.RegularExpressions.dll +0 -0
- package/dist/System.Threading.Tasks.Parallel.dll +0 -0
- package/dist/System.Threading.dll +0 -0
- package/dist/api-wrapper.d.ts +114 -0
- package/dist/api-wrapper.js +154 -0
- package/dist/blazor.boot.json +47 -0
- package/dist/corebindings.c +315 -0
- package/dist/dotnet.d.ts +698 -0
- package/dist/dotnet.es6.extpost.js +2 -0
- package/dist/dotnet.es6.lib.js +149 -0
- package/dist/dotnet.es6.pre.js +3 -0
- package/dist/dotnet.globalization.js +1015 -0
- package/dist/dotnet.js +4 -0
- package/dist/dotnet.js.map +1 -0
- package/dist/dotnet.native.js +16 -0
- package/dist/dotnet.native.js.symbols +8687 -0
- package/dist/dotnet.native.wasm +0 -0
- package/dist/dotnet.runtime.js +4 -0
- package/dist/dotnet.runtime.js.map +1 -0
- package/dist/driver.c +573 -0
- package/dist/emcc-default.rsp +0 -0
- package/dist/emcc-link.rsp +17 -0
- package/dist/gc-common.h +73 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.js +15 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +54 -0
- package/dist/package.json +44 -0
- package/dist/pinvoke.c +62 -0
- package/dist/pinvoke.h +50 -0
- package/dist/runtime.c +386 -0
- package/dist/runtime.h +25 -0
- package/dist/segmentation-rules.json +83 -0
- package/dist/wasm-config.h +13 -0
- package/dist/wasm-props.json +21 -0
- package/package.json +58 -0
- package/src/helpers.ts +20 -0
- package/src/index.d.ts +919 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
function parseJson(jsonString) {
|
|
2
|
+
try {
|
|
3
|
+
const parsed = JSON.parse(jsonString);
|
|
4
|
+
return parsed;
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return { error: 'Failed to parse API response', code: 'PARSE_ERROR' };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function createPKHeXApiWrapper(rawApiOrExports) {
|
|
11
|
+
const rawApi = 'LoadSave' in rawApiOrExports
|
|
12
|
+
? rawApiOrExports
|
|
13
|
+
: rawApiOrExports?.PKHeX?.Api?.PKHeXApi;
|
|
14
|
+
if (!rawApi) {
|
|
15
|
+
throw new Error('Invalid API object provided to createPKHeXApiWrapper');
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
getSpeciesName: (speciesId) => parseJson(rawApi.GetSpeciesName(speciesId)),
|
|
19
|
+
getAllSpecies: () => parseJson(rawApi.GetAllSpecies()),
|
|
20
|
+
getMoveName: (moveId) => parseJson(rawApi.GetMoveName(moveId)),
|
|
21
|
+
getAllMoves: () => parseJson(rawApi.GetAllMoves()),
|
|
22
|
+
getAbilityName: (abilityId) => parseJson(rawApi.GetAbilityName(abilityId)),
|
|
23
|
+
getAllAbilities: () => parseJson(rawApi.GetAllAbilities()),
|
|
24
|
+
getItemName: (itemId) => parseJson(rawApi.GetItemName(itemId)),
|
|
25
|
+
getAllItems: () => parseJson(rawApi.GetAllItems()),
|
|
26
|
+
getNatureName: (natureId) => parseJson(rawApi.GetNatureName(natureId)),
|
|
27
|
+
getAllNatures: () => parseJson(rawApi.GetAllNatures()),
|
|
28
|
+
getTypeName: (typeId) => parseJson(rawApi.GetTypeName(typeId)),
|
|
29
|
+
getAllTypes: () => parseJson(rawApi.GetAllTypes()),
|
|
30
|
+
save: {
|
|
31
|
+
load: (base64Data) => parseJson(rawApi.LoadSave(base64Data)),
|
|
32
|
+
getInfo: (handle) => parseJson(rawApi.GetSaveInfo(handle)),
|
|
33
|
+
export: (handle) => parseJson(rawApi.ExportSave(handle)),
|
|
34
|
+
dispose: (handle) => parseJson(rawApi.DisposeSave(handle)),
|
|
35
|
+
pokemon: {
|
|
36
|
+
get: (handle, box, slot) => parseJson(rawApi.GetPokemon(handle, box, slot)),
|
|
37
|
+
getAll: (handle) => parseJson(rawApi.GetAllPokemon(handle)),
|
|
38
|
+
getParty: (handle) => parseJson(rawApi.GetParty(handle)),
|
|
39
|
+
getPartySlot: (handle, slot) => parseJson(rawApi.GetPartySlot(handle, slot)),
|
|
40
|
+
modify: (handle, box, slot, modifications) => parseJson(rawApi.ModifyPokemon(handle, box, slot, JSON.stringify(modifications))),
|
|
41
|
+
set: (handle, box, slot, base64PkmData) => parseJson(rawApi.SetPokemon(handle, box, slot, base64PkmData)),
|
|
42
|
+
delete: (handle, box, slot) => parseJson(rawApi.DeletePokemon(handle, box, slot)),
|
|
43
|
+
move: (handle, fromBox, fromSlot, toBox, toSlot) => parseJson(rawApi.MovePokemon(handle, fromBox, fromSlot, toBox, toSlot)),
|
|
44
|
+
generatePID: (handle, box, slot, nature, shiny) => parseJson(rawApi.GeneratePID(handle, box, slot, nature, shiny)),
|
|
45
|
+
setPID: (handle, box, slot, pid) => parseJson(rawApi.SetPID(handle, box, slot, pid)),
|
|
46
|
+
setShiny: (handle, box, slot, shinyType) => parseJson(rawApi.SetShiny(handle, box, slot, shinyType)),
|
|
47
|
+
getPIDInfo: (handle, box, slot) => parseJson(rawApi.GetPIDInfo(handle, box, slot)),
|
|
48
|
+
checkLegality: (handle, box, slot) => parseJson(rawApi.CheckLegality(handle, box, slot)),
|
|
49
|
+
legalize: (handle, box, slot) => parseJson(rawApi.LegalizePokemon(handle, box, slot)),
|
|
50
|
+
exportShowdown: (handle, box, slot) => parseJson(rawApi.ExportShowdown(handle, box, slot)),
|
|
51
|
+
importShowdown: (handle, box, slot, showdownText) => parseJson(rawApi.ImportShowdown(handle, box, slot, showdownText)),
|
|
52
|
+
getRibbons: (handle, box, slot) => parseJson(rawApi.GetRibbons(handle, box, slot)),
|
|
53
|
+
getRibbonCount: (handle, box, slot) => parseJson(rawApi.GetRibbonCount(handle, box, slot)),
|
|
54
|
+
setRibbon: (handle, box, slot, ribbonName, value) => parseJson(rawApi.SetRibbon(handle, box, slot, ribbonName, value)),
|
|
55
|
+
getContestStats: (handle, box, slot) => parseJson(rawApi.GetContestStats(handle, box, slot)),
|
|
56
|
+
setContestStat: (handle, box, slot, statName, value) => parseJson(rawApi.SetContestStat(handle, box, slot, statName, value)),
|
|
57
|
+
},
|
|
58
|
+
trainer: {
|
|
59
|
+
getInfo: (handle) => parseJson(rawApi.GetTrainerInfo(handle)),
|
|
60
|
+
setInfo: (handle, trainerData) => parseJson(rawApi.SetTrainerInfo(handle, JSON.stringify(trainerData))),
|
|
61
|
+
getCard: (handle) => parseJson(rawApi.GetTrainerCard(handle)),
|
|
62
|
+
getAppearance: (handle) => parseJson(rawApi.GetTrainerAppearance(handle)),
|
|
63
|
+
setAppearance: (handle, appearance) => parseJson(rawApi.SetTrainerAppearance(handle, JSON.stringify(appearance))),
|
|
64
|
+
getRivalName: (handle) => parseJson(rawApi.GetRivalName(handle)),
|
|
65
|
+
setRivalName: (handle, rivalName) => parseJson(rawApi.SetRivalName(handle, rivalName)),
|
|
66
|
+
getBadges: (handle) => parseJson(rawApi.GetBadges(handle)),
|
|
67
|
+
setBadge: (handle, badgeIndex, value) => parseJson(rawApi.SetBadge(handle, badgeIndex, value)),
|
|
68
|
+
},
|
|
69
|
+
boxes: {
|
|
70
|
+
getNames: (handle) => parseJson(rawApi.GetBoxNames(handle)),
|
|
71
|
+
getWallpapers: (handle) => parseJson(rawApi.GetBoxWallpapers(handle)),
|
|
72
|
+
setWallpaper: (handle, box, wallpaperId) => parseJson(rawApi.SetBoxWallpaper(handle, box, wallpaperId)),
|
|
73
|
+
getBattleBox: (handle) => parseJson(rawApi.GetBattleBox(handle)),
|
|
74
|
+
setBattleBoxSlot: (handle, slot, base64PkmData) => parseJson(rawApi.SetBattleBoxSlot(handle, slot, base64PkmData)),
|
|
75
|
+
getDaycare: (handle) => parseJson(rawApi.GetDaycare(handle)),
|
|
76
|
+
},
|
|
77
|
+
items: {
|
|
78
|
+
getPouches: (handle) => parseJson(rawApi.GetPouchItems(handle)),
|
|
79
|
+
add: (handle, itemId, count, pouchIndex) => parseJson(rawApi.AddItemToPouch(handle, itemId, count, pouchIndex)),
|
|
80
|
+
remove: (handle, itemId, count) => parseJson(rawApi.RemoveItemFromPouch(handle, itemId, count)),
|
|
81
|
+
},
|
|
82
|
+
pokedex: {
|
|
83
|
+
get: (handle) => parseJson(rawApi.GetPokedex(handle)),
|
|
84
|
+
setSeen: (handle, species, form) => parseJson(rawApi.SetPokedexSeen(handle, species, form)),
|
|
85
|
+
setCaught: (handle, species, form) => parseJson(rawApi.SetPokedexCaught(handle, species, form)),
|
|
86
|
+
},
|
|
87
|
+
progress: {
|
|
88
|
+
getBattlePoints: (handle) => parseJson(rawApi.GetBattlePoints(handle)),
|
|
89
|
+
setBattlePoints: (handle, battlePoints) => parseJson(rawApi.SetBattlePoints(handle, battlePoints)),
|
|
90
|
+
getCoins: (handle) => parseJson(rawApi.GetCoins(handle)),
|
|
91
|
+
setCoins: (handle, coins) => parseJson(rawApi.SetCoins(handle, coins)),
|
|
92
|
+
getRecords: (handle) => parseJson(rawApi.GetRecords(handle)),
|
|
93
|
+
setRecord: (handle, recordIndex, value) => parseJson(rawApi.SetRecord(handle, recordIndex, value)),
|
|
94
|
+
getEventFlag: (handle, flagIndex) => parseJson(rawApi.GetEventFlag(handle, flagIndex)),
|
|
95
|
+
setEventFlag: (handle, flagIndex, value) => parseJson(rawApi.SetEventFlag(handle, flagIndex, value)),
|
|
96
|
+
getEventConst: (handle, constIndex) => parseJson(rawApi.GetEventConst(handle, constIndex)),
|
|
97
|
+
setEventConst: (handle, constIndex, value) => parseJson(rawApi.SetEventConst(handle, constIndex, value)),
|
|
98
|
+
getBattleFacilityStats: (handle) => parseJson(rawApi.GetBattleFacilityStats(handle)),
|
|
99
|
+
getHallOfFame: (handle) => parseJson(rawApi.GetHallOfFame(handle)),
|
|
100
|
+
setHallOfFameEntry: (handle, index, team) => parseJson(rawApi.SetHallOfFameEntry(handle, index, JSON.stringify(team))),
|
|
101
|
+
},
|
|
102
|
+
time: {
|
|
103
|
+
getSecondsPlayed: (handle) => parseJson(rawApi.GetSecondsPlayed(handle)),
|
|
104
|
+
getSecondsToStart: (handle) => parseJson(rawApi.GetSecondsToStart(handle)),
|
|
105
|
+
getSecondsToFame: (handle) => parseJson(rawApi.GetSecondsToFame(handle)),
|
|
106
|
+
setGameTime: (handle, hours, minutes, seconds) => parseJson(rawApi.SetGameTime(handle, hours, minutes, seconds)),
|
|
107
|
+
setSecondsToStart: (handle, seconds) => parseJson(rawApi.SetSecondsToStart(handle, seconds)),
|
|
108
|
+
setSecondsToFame: (handle, seconds) => parseJson(rawApi.SetSecondsToFame(handle, seconds)),
|
|
109
|
+
},
|
|
110
|
+
mail: {
|
|
111
|
+
getMailbox: (handle) => parseJson(rawApi.GetMailbox(handle)),
|
|
112
|
+
getMessage: (handle, index) => parseJson(rawApi.GetMailMessage(handle, index)),
|
|
113
|
+
setMessage: (handle, index, mail) => parseJson(rawApi.SetMailMessage(handle, index, JSON.stringify(mail))),
|
|
114
|
+
delete: (handle, index) => parseJson(rawApi.DeleteMail(handle, index)),
|
|
115
|
+
},
|
|
116
|
+
mysteryGift: {
|
|
117
|
+
getAll: (handle) => parseJson(rawApi.GetMysteryGifts(handle)),
|
|
118
|
+
getCard: (handle, index) => parseJson(rawApi.GetMysteryGiftCard(handle, index)),
|
|
119
|
+
setCard: (handle, index, card) => parseJson(rawApi.SetMysteryGiftCard(handle, index, JSON.stringify(card))),
|
|
120
|
+
getFlags: (handle) => parseJson(rawApi.GetMysteryGiftFlags(handle)),
|
|
121
|
+
delete: (handle, index) => parseJson(rawApi.DeleteMysteryGift(handle, index)),
|
|
122
|
+
},
|
|
123
|
+
features: {
|
|
124
|
+
getSecretBase: (handle) => parseJson(rawApi.GetSecretBase(handle)),
|
|
125
|
+
getEntralinkData: (handle) => parseJson(rawApi.GetEntralinkData(handle)),
|
|
126
|
+
getPokePelago: (handle) => parseJson(rawApi.GetPokePelago(handle)),
|
|
127
|
+
getFestivalPlaza: (handle) => parseJson(rawApi.GetFestivalPlaza(handle)),
|
|
128
|
+
getPokeJobs: (handle) => parseJson(rawApi.GetPokeJobs(handle)),
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
pkm: {
|
|
132
|
+
getData: (base64PkmData, generation) => parseJson(rawApi.GetPKMData(base64PkmData, generation)),
|
|
133
|
+
modify: (base64PkmData, generation, modifications) => parseJson(rawApi.ModifyPKMData(base64PkmData, generation, JSON.stringify(modifications))),
|
|
134
|
+
checkLegality: (base64PkmData, generation) => parseJson(rawApi.CheckPKMLegality(base64PkmData, generation)),
|
|
135
|
+
legalize: (base64PkmData, generation) => parseJson(rawApi.LegalizePKMData(base64PkmData, generation)),
|
|
136
|
+
exportShowdown: (base64PkmData, generation) => parseJson(rawApi.ExportPKMShowdown(base64PkmData, generation)),
|
|
137
|
+
calculateStats: (base64PkmData, generation) => parseJson(rawApi.CalculatePKMStats(base64PkmData, generation)),
|
|
138
|
+
getRibbons: (base64PkmData, generation) => parseJson(rawApi.GetPKMRibbons(base64PkmData, generation)),
|
|
139
|
+
setRibbon: (base64PkmData, generation, ribbonName, value) => parseJson(rawApi.SetPKMRibbon(base64PkmData, generation, ribbonName, value)),
|
|
140
|
+
setShiny: (base64PkmData, generation, shinyType) => parseJson(rawApi.SetPKMShiny(base64PkmData, generation, shinyType)),
|
|
141
|
+
getPIDInfo: (base64PkmData, generation) => parseJson(rawApi.GetPKMPIDInfo(base64PkmData, generation)),
|
|
142
|
+
setPID: (base64PkmData, generation, pid) => parseJson(rawApi.SetPKMPID(base64PkmData, generation, pid)),
|
|
143
|
+
rerollEncryptionConstant: (base64PkmData, generation) => parseJson(rawApi.RerollPKMEncryptionConstant(base64PkmData, generation)),
|
|
144
|
+
getHiddenPower: (base64PkmData, generation) => parseJson(rawApi.GetPKMHiddenPower(base64PkmData, generation)),
|
|
145
|
+
getCharacteristic: (base64PkmData, generation) => parseJson(rawApi.GetPKMCharacteristic(base64PkmData, generation)),
|
|
146
|
+
convertFormat: (base64PkmData, fromGeneration, toGeneration) => parseJson(rawApi.ConvertPKMFormat(base64PkmData, fromGeneration, toGeneration)),
|
|
147
|
+
},
|
|
148
|
+
gameData: {
|
|
149
|
+
getMetLocations: (generation, gameVersion, eggLocations) => parseJson(rawApi.GetPKMMetLocations(generation, gameVersion, eggLocations)),
|
|
150
|
+
getSpeciesForms: (species, generation) => parseJson(rawApi.GetSpeciesForms(species, generation)),
|
|
151
|
+
getSpeciesEvolutions: (species, generation) => parseJson(rawApi.GetSpeciesEvolutions(species, generation)),
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mainAssemblyName": "PKHeX.dll",
|
|
3
|
+
"resources": {
|
|
4
|
+
"assembly": {
|
|
5
|
+
"PKHeX.Core.dll": "",
|
|
6
|
+
"PKHeX.dll": "",
|
|
7
|
+
"System.Collections.Concurrent.dll": "",
|
|
8
|
+
"System.Collections.dll": "",
|
|
9
|
+
"System.ComponentModel.Annotations.dll": "",
|
|
10
|
+
"System.ComponentModel.Primitives.dll": "",
|
|
11
|
+
"System.ComponentModel.TypeConverter.dll": "",
|
|
12
|
+
"System.Console.dll": "",
|
|
13
|
+
"System.Diagnostics.DiagnosticSource.dll": "",
|
|
14
|
+
"System.Diagnostics.TraceSource.dll": "",
|
|
15
|
+
"System.IO.Compression.ZipFile.dll": "",
|
|
16
|
+
"System.IO.Compression.dll": "",
|
|
17
|
+
"System.IO.Pipelines.dll": "",
|
|
18
|
+
"System.Linq.dll": "",
|
|
19
|
+
"System.Memory.dll": "",
|
|
20
|
+
"System.Net.Http.dll": "",
|
|
21
|
+
"System.Net.Primitives.dll": "",
|
|
22
|
+
"System.Numerics.Vectors.dll": "",
|
|
23
|
+
"System.ObjectModel.dll": "",
|
|
24
|
+
"System.Private.CoreLib.dll": "",
|
|
25
|
+
"System.Private.Uri.dll": "",
|
|
26
|
+
"System.Runtime.InteropServices.JavaScript.dll": "",
|
|
27
|
+
"System.Runtime.InteropServices.dll": "",
|
|
28
|
+
"System.Runtime.Numerics.dll": "",
|
|
29
|
+
"System.Runtime.dll": "",
|
|
30
|
+
"System.Security.Cryptography.dll": "",
|
|
31
|
+
"System.Text.Encodings.Web.dll": "",
|
|
32
|
+
"System.Text.Json.dll": "",
|
|
33
|
+
"System.Text.RegularExpressions.dll": "",
|
|
34
|
+
"System.Threading.Tasks.Parallel.dll": "",
|
|
35
|
+
"System.Threading.dll": ""
|
|
36
|
+
},
|
|
37
|
+
"wasmNative": {
|
|
38
|
+
"dotnet.native.wasm": ""
|
|
39
|
+
},
|
|
40
|
+
"jsModuleNative": {
|
|
41
|
+
"dotnet.native.js": ""
|
|
42
|
+
},
|
|
43
|
+
"jsModuleRuntime": {
|
|
44
|
+
"dotnet.runtime.js": ""
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// Licensed to the .NET Foundation under one or more agreements.
|
|
2
|
+
// The .NET Foundation licenses this file to you under the MIT license.
|
|
3
|
+
#include <emscripten.h>
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include <stdint.h>
|
|
8
|
+
#include <assert.h>
|
|
9
|
+
#include <sys/types.h>
|
|
10
|
+
#include <uchar.h>
|
|
11
|
+
|
|
12
|
+
#include <mono/metadata/appdomain.h>
|
|
13
|
+
#include <mono/metadata/class.h>
|
|
14
|
+
#include <mono/metadata/loader.h>
|
|
15
|
+
#include <mono/metadata/object.h>
|
|
16
|
+
#include <mono/metadata/reflection.h>
|
|
17
|
+
#include <mono/metadata/assembly.h>
|
|
18
|
+
#include <mono/jit/jit.h>
|
|
19
|
+
|
|
20
|
+
#include "wasm-config.h"
|
|
21
|
+
#include "gc-common.h"
|
|
22
|
+
|
|
23
|
+
//JS funcs
|
|
24
|
+
extern void mono_wasm_release_cs_owned_object (int js_handle);
|
|
25
|
+
extern void mono_wasm_resolve_or_reject_promise (void *args);
|
|
26
|
+
extern void mono_wasm_cancel_promise (int task_holder_gc_handle);
|
|
27
|
+
extern void mono_wasm_console_clear ();
|
|
28
|
+
extern void mono_wasm_set_entrypoint_breakpoint (int entry_point_metadata_token);
|
|
29
|
+
extern void mono_wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data);
|
|
30
|
+
extern void mono_wasm_invoke_js_function (int function_js_handle, void *args);
|
|
31
|
+
|
|
32
|
+
extern int mono_runtime_run_module_cctor (MonoImage *image, MonoError *error);
|
|
33
|
+
|
|
34
|
+
typedef void (*background_job_cb)(void);
|
|
35
|
+
|
|
36
|
+
void mono_wasm_bind_assembly_exports (char *assembly_name);
|
|
37
|
+
void mono_wasm_assembly_get_entry_point (char *assembly_name, int auto_insert_breakpoint, MonoMethod **method_out);
|
|
38
|
+
void mono_wasm_get_assembly_export (char *assembly_name, char *namespace, char *classname, char *methodname, int signature_hash, MonoMethod **method_out);
|
|
39
|
+
|
|
40
|
+
#ifndef DISABLE_THREADS
|
|
41
|
+
void mono_wasm_release_cs_owned_object_post (pthread_t target_tid, int js_handle);
|
|
42
|
+
void mono_wasm_resolve_or_reject_promise_post (pthread_t target_tid, void *args);
|
|
43
|
+
void mono_wasm_cancel_promise_post (pthread_t target_tid, int task_holder_gc_handle);
|
|
44
|
+
|
|
45
|
+
extern void mono_wasm_install_js_worker_interop (int context_gc_handle);
|
|
46
|
+
void mono_wasm_install_js_worker_interop_wrapper (int context_gc_handle, void* beforeSyncJSImport, void* afterSyncJSImport, void* pumpHandler);
|
|
47
|
+
extern void mono_wasm_uninstall_js_worker_interop ();
|
|
48
|
+
extern void mono_wasm_invoke_jsimport_MT (void* signature, void* args);
|
|
49
|
+
void mono_wasm_invoke_jsimport_async_post (pthread_t target_tid, void* signature, void* args);
|
|
50
|
+
void mono_wasm_invoke_jsimport_sync_send (pthread_t target_tid, void* signature, void* args);
|
|
51
|
+
void mono_wasm_invoke_js_function_send (pthread_t target_tid, int function_js_handle, void *args);
|
|
52
|
+
extern void mono_threads_wasm_async_run_in_target_thread_vi (pthread_t target_thread, void (*func) (gpointer), gpointer user_data1);
|
|
53
|
+
extern void mono_threads_wasm_async_run_in_target_thread_vii (pthread_t target_thread, void (*func) (gpointer, gpointer), gpointer user_data1, gpointer user_data2);
|
|
54
|
+
extern void mono_threads_wasm_sync_run_in_target_thread_vii (pthread_t target_thread, void (*func) (gpointer, gpointer), gpointer user_data1, gpointer args);
|
|
55
|
+
extern void mono_wasm_warn_about_blocking_wait (void* ptr, int32_t length);
|
|
56
|
+
#else
|
|
57
|
+
extern void* mono_wasm_bind_js_import_ST (void *signature);
|
|
58
|
+
extern void mono_wasm_invoke_jsimport_ST (int function_handle, void *args);
|
|
59
|
+
#endif /* DISABLE_THREADS */
|
|
60
|
+
|
|
61
|
+
// HybridGlobalization
|
|
62
|
+
extern char16_t* mono_wasm_change_case (const uint16_t* culture, int32_t cultureLength, const uint16_t* src, int32_t srcLength, uint16_t* dst, int32_t dstLength, mono_bool bToUpper);
|
|
63
|
+
extern char16_t* mono_wasm_compare_string (const uint16_t* culture, int32_t cultureLength, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options, int *resultPtr);
|
|
64
|
+
extern char16_t* mono_wasm_starts_with (const uint16_t* culture, int32_t cultureLength, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options, mono_bool *resultPtr);
|
|
65
|
+
extern char16_t* mono_wasm_ends_with (const uint16_t* culture, int32_t cultureLength, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options, mono_bool *resultPtr);
|
|
66
|
+
extern char16_t* mono_wasm_index_of (const uint16_t* culture, int32_t cultureLength, const uint16_t* str1, int32_t str1Length, const uint16_t* str2, int32_t str2Length, int32_t options, mono_bool fromBeginning, int *resultPtr);
|
|
67
|
+
extern char16_t* mono_wasm_get_calendar_info (const uint16_t* culture, int32_t cultureLength, int32_t calendarId, const uint16_t* result, int32_t resultMaxLength, int *resultLength);
|
|
68
|
+
extern char16_t* mono_wasm_get_culture_info (const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength);
|
|
69
|
+
extern char16_t* mono_wasm_get_locale_info (const uint16_t* locale, int32_t localeLength, const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength);
|
|
70
|
+
extern char16_t* mono_wasm_get_first_day_of_week (const uint16_t* culture, int32_t cultureLength, int *resultPtr);
|
|
71
|
+
extern char16_t* mono_wasm_get_first_week_of_year (const uint16_t* culture, int32_t cultureLength, int *resultPtr);
|
|
72
|
+
|
|
73
|
+
void bindings_initialize_internals (void)
|
|
74
|
+
{
|
|
75
|
+
#ifndef ENABLE_JS_INTEROP_BY_VALUE
|
|
76
|
+
mono_add_internal_call ("Interop/Runtime::RegisterGCRoot", mono_wasm_register_root);
|
|
77
|
+
mono_add_internal_call ("Interop/Runtime::DeregisterGCRoot", mono_wasm_deregister_root);
|
|
78
|
+
#endif /* ENABLE_JS_INTEROP_BY_VALUE */
|
|
79
|
+
|
|
80
|
+
#ifndef DISABLE_THREADS
|
|
81
|
+
mono_add_internal_call ("Interop/Runtime::ReleaseCSOwnedObjectPost", mono_wasm_release_cs_owned_object_post);
|
|
82
|
+
mono_add_internal_call ("Interop/Runtime::ResolveOrRejectPromisePost", mono_wasm_resolve_or_reject_promise_post);
|
|
83
|
+
mono_add_internal_call ("Interop/Runtime::InstallWebWorkerInterop", mono_wasm_install_js_worker_interop_wrapper);
|
|
84
|
+
mono_add_internal_call ("Interop/Runtime::UninstallWebWorkerInterop", mono_wasm_uninstall_js_worker_interop);
|
|
85
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSImportSync", mono_wasm_invoke_jsimport_MT);
|
|
86
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSImportSyncSend", mono_wasm_invoke_jsimport_sync_send);
|
|
87
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSImportAsyncPost", mono_wasm_invoke_jsimport_async_post);
|
|
88
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSFunctionSend", mono_wasm_invoke_js_function_send);
|
|
89
|
+
mono_add_internal_call ("Interop/Runtime::CancelPromisePost", mono_wasm_cancel_promise_post);
|
|
90
|
+
mono_add_internal_call ("System.Threading.Thread::WarnAboutBlockingWait", mono_wasm_warn_about_blocking_wait);
|
|
91
|
+
#else
|
|
92
|
+
mono_add_internal_call ("Interop/Runtime::BindJSImportST", mono_wasm_bind_js_import_ST);
|
|
93
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSImportST", mono_wasm_invoke_jsimport_ST);
|
|
94
|
+
#endif /* DISABLE_THREADS */
|
|
95
|
+
|
|
96
|
+
mono_add_internal_call ("Interop/Runtime::ReleaseCSOwnedObject", mono_wasm_release_cs_owned_object);
|
|
97
|
+
mono_add_internal_call ("Interop/Runtime::ResolveOrRejectPromise", mono_wasm_resolve_or_reject_promise);
|
|
98
|
+
mono_add_internal_call ("Interop/Runtime::InvokeJSFunction", mono_wasm_invoke_js_function);
|
|
99
|
+
mono_add_internal_call ("Interop/Runtime::CancelPromise", mono_wasm_cancel_promise);
|
|
100
|
+
mono_add_internal_call ("Interop/Runtime::AssemblyGetEntryPoint", mono_wasm_assembly_get_entry_point);
|
|
101
|
+
mono_add_internal_call ("Interop/Runtime::BindAssemblyExports", mono_wasm_bind_assembly_exports);
|
|
102
|
+
mono_add_internal_call ("Interop/Runtime::GetAssemblyExport", mono_wasm_get_assembly_export);
|
|
103
|
+
mono_add_internal_call ("System.ConsolePal::Clear", mono_wasm_console_clear);
|
|
104
|
+
|
|
105
|
+
// HybridGlobalization
|
|
106
|
+
mono_add_internal_call ("Interop/JsGlobalization::ChangeCase", mono_wasm_change_case);
|
|
107
|
+
mono_add_internal_call ("Interop/JsGlobalization::CompareString", mono_wasm_compare_string);
|
|
108
|
+
mono_add_internal_call ("Interop/JsGlobalization::StartsWith", mono_wasm_starts_with);
|
|
109
|
+
mono_add_internal_call ("Interop/JsGlobalization::EndsWith", mono_wasm_ends_with);
|
|
110
|
+
mono_add_internal_call ("Interop/JsGlobalization::IndexOf", mono_wasm_index_of);
|
|
111
|
+
mono_add_internal_call ("Interop/JsGlobalization::GetCalendarInfo", mono_wasm_get_calendar_info);
|
|
112
|
+
mono_add_internal_call ("Interop/JsGlobalization::GetLocaleInfo", mono_wasm_get_locale_info);
|
|
113
|
+
mono_add_internal_call ("Interop/JsGlobalization::GetCultureInfo", mono_wasm_get_culture_info);
|
|
114
|
+
mono_add_internal_call ("Interop/JsGlobalization::GetFirstDayOfWeek", mono_wasm_get_first_day_of_week);
|
|
115
|
+
mono_add_internal_call ("Interop/JsGlobalization::GetFirstWeekOfYear", mono_wasm_get_first_week_of_year);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static MonoAssembly* _mono_wasm_assembly_load (char *assembly_name)
|
|
119
|
+
{
|
|
120
|
+
assert (assembly_name);
|
|
121
|
+
MonoImageOpenStatus status;
|
|
122
|
+
MonoAssemblyName* aname = mono_assembly_name_new (assembly_name);
|
|
123
|
+
assert (aname);
|
|
124
|
+
|
|
125
|
+
MonoAssembly *res = mono_assembly_load (aname, NULL, &status);
|
|
126
|
+
mono_assembly_name_free (aname);
|
|
127
|
+
free (assembly_name);
|
|
128
|
+
|
|
129
|
+
return res;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
void mono_wasm_assembly_get_entry_point (char *assembly_name, int auto_insert_breakpoint, MonoMethod **method_out)
|
|
133
|
+
{
|
|
134
|
+
assert (assembly_name);
|
|
135
|
+
*method_out = NULL;
|
|
136
|
+
MonoAssembly* assembly = _mono_wasm_assembly_load (assembly_name);
|
|
137
|
+
if(!assembly)
|
|
138
|
+
goto end;
|
|
139
|
+
|
|
140
|
+
MonoImage *image;
|
|
141
|
+
MonoMethod *method = NULL;
|
|
142
|
+
|
|
143
|
+
image = mono_assembly_get_image (assembly);
|
|
144
|
+
uint32_t entry = mono_image_get_entry_point (image);
|
|
145
|
+
if (!entry)
|
|
146
|
+
goto end;
|
|
147
|
+
|
|
148
|
+
mono_domain_ensure_entry_assembly (mono_get_root_domain (), assembly);
|
|
149
|
+
method = mono_get_method (image, entry, NULL);
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
* If the entry point looks like a compiler generated wrapper around
|
|
153
|
+
* an async method in the form "<Name>" then try to look up the async methods
|
|
154
|
+
* "<Name>$" and "Name" it could be wrapping. We do this because the generated
|
|
155
|
+
* sync wrapper will call task.GetAwaiter().GetResult() when we actually want
|
|
156
|
+
* to yield to the host runtime.
|
|
157
|
+
*/
|
|
158
|
+
if (mono_method_get_flags (method, NULL) & 0x0800 /* METHOD_ATTRIBUTE_SPECIAL_NAME */) {
|
|
159
|
+
const char *name = mono_method_get_name (method);
|
|
160
|
+
int name_length = strlen (name);
|
|
161
|
+
|
|
162
|
+
if ((*name != '<') || (name [name_length - 1] != '>'))
|
|
163
|
+
goto end;
|
|
164
|
+
|
|
165
|
+
MonoClass *klass = mono_method_get_class (method);
|
|
166
|
+
assert(klass);
|
|
167
|
+
char *async_name = malloc (name_length + 2);
|
|
168
|
+
snprintf (async_name, name_length + 2, "%s$", name);
|
|
169
|
+
|
|
170
|
+
// look for "<Name>$"
|
|
171
|
+
MonoMethodSignature *sig = mono_method_get_signature (method, image, mono_method_get_token (method));
|
|
172
|
+
MonoMethod *async_method = mono_class_get_method_from_name (klass, async_name, mono_signature_get_param_count (sig));
|
|
173
|
+
if (async_method != NULL) {
|
|
174
|
+
free (async_name);
|
|
175
|
+
method = async_method;
|
|
176
|
+
goto end;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// look for "Name" by trimming the first and last character of "<Name>"
|
|
180
|
+
async_name [name_length - 1] = '\0';
|
|
181
|
+
async_method = mono_class_get_method_from_name (klass, async_name + 1, mono_signature_get_param_count (sig));
|
|
182
|
+
|
|
183
|
+
free (async_name);
|
|
184
|
+
if (async_method != NULL)
|
|
185
|
+
method = async_method;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
end:
|
|
189
|
+
if (auto_insert_breakpoint && method)
|
|
190
|
+
{
|
|
191
|
+
mono_wasm_set_entrypoint_breakpoint(mono_method_get_token (method));
|
|
192
|
+
}
|
|
193
|
+
*method_out = method;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
void mono_wasm_bind_assembly_exports (char *assembly_name)
|
|
197
|
+
{
|
|
198
|
+
MonoError error;
|
|
199
|
+
MonoAssembly* assembly;
|
|
200
|
+
MonoImage *image;
|
|
201
|
+
MonoClass *klass;
|
|
202
|
+
MonoMethod *method;
|
|
203
|
+
PVOLATILE(MonoObject) temp_exc = NULL;
|
|
204
|
+
|
|
205
|
+
assert (assembly_name);
|
|
206
|
+
assembly = _mono_wasm_assembly_load (assembly_name);
|
|
207
|
+
assert (assembly);
|
|
208
|
+
image = mono_assembly_get_image (assembly);
|
|
209
|
+
assert (image);
|
|
210
|
+
|
|
211
|
+
klass = mono_class_from_name (image, "System.Runtime.InteropServices.JavaScript", "__GeneratedInitializer");
|
|
212
|
+
if (klass) {
|
|
213
|
+
method = mono_class_get_method_from_name (klass, "__Register_", -1);
|
|
214
|
+
if (method) {
|
|
215
|
+
mono_runtime_invoke (method, NULL, NULL, (MonoObject **)&temp_exc);
|
|
216
|
+
if (temp_exc) {
|
|
217
|
+
PVOLATILE(MonoObject) exc2 = NULL;
|
|
218
|
+
store_volatile((MonoObject**)&temp_exc, (MonoObject*)mono_object_to_string ((MonoObject*)temp_exc, (MonoObject **)&exc2));
|
|
219
|
+
if (exc2) {
|
|
220
|
+
mono_wasm_trace_logger ("jsinterop", "critical", "mono_wasm_bind_assembly_exports unexpected double fault", 1, NULL);
|
|
221
|
+
} else {
|
|
222
|
+
mono_wasm_trace_logger ("jsinterop", "critical", mono_string_to_utf8((MonoString*)temp_exc), 1, NULL);
|
|
223
|
+
}
|
|
224
|
+
abort ();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
else if (!mono_runtime_run_module_cctor(image, &error)) {
|
|
229
|
+
//g_print ("Failed to run module constructor due to %s\n", mono_error_get_message (error));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
void mono_wasm_get_assembly_export (char *assembly_name, char *namespace, char *classname, char *methodname, int signature_hash, MonoMethod **method_out)
|
|
234
|
+
{
|
|
235
|
+
MonoError error;
|
|
236
|
+
MonoAssembly* assembly;
|
|
237
|
+
MonoImage *image;
|
|
238
|
+
MonoClass *klass;
|
|
239
|
+
MonoMethod *method=NULL;
|
|
240
|
+
char real_method_name_buffer[4096];
|
|
241
|
+
*method_out = NULL;
|
|
242
|
+
|
|
243
|
+
assert (assembly_name);
|
|
244
|
+
assembly = _mono_wasm_assembly_load (assembly_name);
|
|
245
|
+
assert (assembly);
|
|
246
|
+
image = mono_assembly_get_image (assembly);
|
|
247
|
+
assert (image);
|
|
248
|
+
|
|
249
|
+
klass = mono_class_from_name (image, namespace, classname);
|
|
250
|
+
assert (klass);
|
|
251
|
+
|
|
252
|
+
snprintf(real_method_name_buffer, 4096, "__Wrapper_%s_%d", methodname, signature_hash);
|
|
253
|
+
|
|
254
|
+
method = mono_class_get_method_from_name (klass, real_method_name_buffer, -1);
|
|
255
|
+
assert (method);
|
|
256
|
+
|
|
257
|
+
*method_out = method;
|
|
258
|
+
// This is freed by _mono_wasm_assembly_load for some reason
|
|
259
|
+
// free (assembly_name);
|
|
260
|
+
free (namespace);
|
|
261
|
+
free (classname);
|
|
262
|
+
free (methodname);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
#ifndef DISABLE_THREADS
|
|
266
|
+
|
|
267
|
+
void* before_sync_js_import;
|
|
268
|
+
void* after_sync_js_import;
|
|
269
|
+
void* synchronization_context_pump_handler;
|
|
270
|
+
|
|
271
|
+
void mono_wasm_install_js_worker_interop_wrapper (int context_gc_handle, void* beforeSyncJSImport, void* afterSyncJSImport, void* pumpHandler)
|
|
272
|
+
{
|
|
273
|
+
before_sync_js_import = beforeSyncJSImport;
|
|
274
|
+
after_sync_js_import = afterSyncJSImport;
|
|
275
|
+
synchronization_context_pump_handler = pumpHandler;
|
|
276
|
+
mono_wasm_install_js_worker_interop (context_gc_handle);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// async
|
|
280
|
+
void mono_wasm_release_cs_owned_object_post (pthread_t target_tid, int js_handle)
|
|
281
|
+
{
|
|
282
|
+
mono_threads_wasm_async_run_in_target_thread_vi (target_tid, (void (*) (gpointer))mono_wasm_release_cs_owned_object, (gpointer)js_handle);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// async
|
|
286
|
+
void mono_wasm_resolve_or_reject_promise_post (pthread_t target_tid, void* args)
|
|
287
|
+
{
|
|
288
|
+
mono_threads_wasm_async_run_in_target_thread_vi (target_tid, (void (*) (gpointer))mono_wasm_resolve_or_reject_promise, (gpointer)args);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// async
|
|
292
|
+
void mono_wasm_cancel_promise_post (pthread_t target_tid, int task_holder_gc_handle)
|
|
293
|
+
{
|
|
294
|
+
mono_threads_wasm_async_run_in_target_thread_vi (target_tid, (void (*) (gpointer))mono_wasm_cancel_promise, (gpointer)task_holder_gc_handle);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// async
|
|
298
|
+
void mono_wasm_invoke_jsimport_async_post (pthread_t target_tid, void* signature, void* args)
|
|
299
|
+
{
|
|
300
|
+
mono_threads_wasm_async_run_in_target_thread_vii (target_tid, (void (*) (gpointer, gpointer))mono_wasm_invoke_jsimport_MT, (gpointer)signature, (gpointer)args);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// sync
|
|
304
|
+
void mono_wasm_invoke_jsimport_sync_send (pthread_t target_tid, void* signature, void* args)
|
|
305
|
+
{
|
|
306
|
+
mono_threads_wasm_sync_run_in_target_thread_vii (target_tid, (void (*) (gpointer, gpointer))mono_wasm_invoke_jsimport_MT, (gpointer)signature, (gpointer)args);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// sync
|
|
310
|
+
void mono_wasm_invoke_js_function_send (pthread_t target_tid, int function_js_handle, void *args)
|
|
311
|
+
{
|
|
312
|
+
mono_threads_wasm_sync_run_in_target_thread_vii (target_tid, (void (*) (gpointer, gpointer))mono_wasm_invoke_js_function, (gpointer)function_js_handle, (gpointer)args);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
#endif /* DISABLE_THREADS */
|