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.
Files changed (69) hide show
  1. package/README.md +73 -0
  2. package/dist/PKHeX.Core.dll +0 -0
  3. package/dist/PKHeX.deps.json +361 -0
  4. package/dist/PKHeX.dll +0 -0
  5. package/dist/PKHeX.runtimeconfig.json +38 -0
  6. package/dist/System.Collections.Concurrent.dll +0 -0
  7. package/dist/System.Collections.dll +0 -0
  8. package/dist/System.ComponentModel.Annotations.dll +0 -0
  9. package/dist/System.ComponentModel.Primitives.dll +0 -0
  10. package/dist/System.ComponentModel.TypeConverter.dll +0 -0
  11. package/dist/System.Console.dll +0 -0
  12. package/dist/System.Diagnostics.DiagnosticSource.dll +0 -0
  13. package/dist/System.Diagnostics.TraceSource.dll +0 -0
  14. package/dist/System.IO.Compression.ZipFile.dll +0 -0
  15. package/dist/System.IO.Compression.dll +0 -0
  16. package/dist/System.IO.Pipelines.dll +0 -0
  17. package/dist/System.Linq.dll +0 -0
  18. package/dist/System.Memory.dll +0 -0
  19. package/dist/System.Net.Http.dll +0 -0
  20. package/dist/System.Net.Primitives.dll +0 -0
  21. package/dist/System.Numerics.Vectors.dll +0 -0
  22. package/dist/System.ObjectModel.dll +0 -0
  23. package/dist/System.Private.CoreLib.dll +0 -0
  24. package/dist/System.Private.Uri.dll +0 -0
  25. package/dist/System.Runtime.InteropServices.JavaScript.dll +0 -0
  26. package/dist/System.Runtime.InteropServices.dll +0 -0
  27. package/dist/System.Runtime.Numerics.dll +0 -0
  28. package/dist/System.Runtime.dll +0 -0
  29. package/dist/System.Security.Cryptography.dll +0 -0
  30. package/dist/System.Text.Encodings.Web.dll +0 -0
  31. package/dist/System.Text.Json.dll +0 -0
  32. package/dist/System.Text.RegularExpressions.dll +0 -0
  33. package/dist/System.Threading.Tasks.Parallel.dll +0 -0
  34. package/dist/System.Threading.dll +0 -0
  35. package/dist/api-wrapper.d.ts +114 -0
  36. package/dist/api-wrapper.js +154 -0
  37. package/dist/blazor.boot.json +47 -0
  38. package/dist/corebindings.c +315 -0
  39. package/dist/dotnet.d.ts +698 -0
  40. package/dist/dotnet.es6.extpost.js +2 -0
  41. package/dist/dotnet.es6.lib.js +149 -0
  42. package/dist/dotnet.es6.pre.js +3 -0
  43. package/dist/dotnet.globalization.js +1015 -0
  44. package/dist/dotnet.js +4 -0
  45. package/dist/dotnet.js.map +1 -0
  46. package/dist/dotnet.native.js +16 -0
  47. package/dist/dotnet.native.js.symbols +8687 -0
  48. package/dist/dotnet.native.wasm +0 -0
  49. package/dist/dotnet.runtime.js +4 -0
  50. package/dist/dotnet.runtime.js.map +1 -0
  51. package/dist/driver.c +573 -0
  52. package/dist/emcc-default.rsp +0 -0
  53. package/dist/emcc-link.rsp +17 -0
  54. package/dist/gc-common.h +73 -0
  55. package/dist/helpers.d.ts +5 -0
  56. package/dist/helpers.js +15 -0
  57. package/dist/index.d.ts +43 -0
  58. package/dist/index.js +54 -0
  59. package/dist/package.json +44 -0
  60. package/dist/pinvoke.c +62 -0
  61. package/dist/pinvoke.h +50 -0
  62. package/dist/runtime.c +386 -0
  63. package/dist/runtime.h +25 -0
  64. package/dist/segmentation-rules.json +83 -0
  65. package/dist/wasm-config.h +13 -0
  66. package/dist/wasm-props.json +21 -0
  67. package/package.json +58 -0
  68. package/src/helpers.ts +20 -0
  69. package/src/index.d.ts +919 -0
package/dist/driver.c ADDED
@@ -0,0 +1,573 @@
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 <emscripten/stack.h>
5
+ #include <stdio.h>
6
+ #include <stddef.h>
7
+ #include <stdlib.h>
8
+ #include <string.h>
9
+ #include <stdint.h>
10
+ #include <assert.h>
11
+ #include <math.h>
12
+ #include <dlfcn.h>
13
+ #include <sys/stat.h>
14
+
15
+ #include <mono/metadata/appdomain.h>
16
+ #include <mono/metadata/assembly.h>
17
+ #include <mono/metadata/class.h>
18
+ #include <mono/metadata/tokentype.h>
19
+ #include <mono/metadata/threads.h>
20
+ #include <mono/metadata/image.h>
21
+ #include <mono/metadata/loader.h>
22
+ #include <mono/metadata/mono-gc.h>
23
+ #include <mono/metadata/object.h>
24
+ #include <mono/metadata/debug-helpers.h>
25
+ // FIXME: unavailable in emscripten
26
+ // #include <mono/metadata/gc-internals.h>
27
+
28
+ #include <mono/metadata/mono-private-unstable.h>
29
+
30
+ #include <mono/utils/mono-logger.h>
31
+ #include <mono/utils/mono-dl-fallback.h>
32
+ #include <mono/jit/jit.h>
33
+ #include <mono/jit/mono-private-unstable.h>
34
+
35
+ #include "wasm-config.h"
36
+ #include "runtime.h"
37
+
38
+ #include "gc-common.h"
39
+
40
+ void bindings_initialize_internals ();
41
+
42
+ char *monoeg_g_getenv(const char *variable);
43
+ int monoeg_g_setenv(const char *variable, const char *value, int overwrite);
44
+ char *mono_method_get_full_name (MonoMethod *method);
45
+
46
+ #ifndef INVARIANT_TIMEZONE
47
+ extern void mono_register_timezones_bundle (void);
48
+ #endif /* INVARIANT_TIMEZONE */
49
+ extern void mono_wasm_set_entrypoint_breakpoint (const char* assembly_name, int method_token);
50
+
51
+ extern void mono_bundled_resources_add_assembly_resource (const char *id, const char *name, const uint8_t *data, uint32_t size, void (*free_func)(void *, void*), void *free_data);
52
+ extern void mono_bundled_resources_add_assembly_symbol_resource (const char *id, const uint8_t *data, uint32_t size, void (*free_func)(void *, void *), void *free_data);
53
+ extern void mono_bundled_resources_add_satellite_assembly_resource (const char *id, const char *name, const char *culture, const uint8_t *data, uint32_t size, void (*free_func)(void *, void*), void *free_data);
54
+
55
+ int
56
+ mono_string_instance_is_interned (MonoString *str_raw);
57
+
58
+ int mono_regression_test_step (int verbose_level, char *image, char *method_name);
59
+
60
+ #define g_new(type, size) ((type *) malloc (sizeof (type) * (size)))
61
+ #define g_new0(type, size) ((type *) calloc (sizeof (type), (size)))
62
+
63
+ static MonoDomain *root_domain;
64
+
65
+ #define RUNTIMECONFIG_BIN_FILE "runtimeconfig.bin"
66
+
67
+ extern void mono_wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data);
68
+
69
+ static void
70
+ wasm_trace_logger (const char *log_domain, const char *log_level, const char *message, mono_bool fatal, void *user_data)
71
+ {
72
+ mono_wasm_trace_logger(log_domain, log_level, message, fatal, user_data);
73
+ if (fatal)
74
+ exit (1);
75
+ }
76
+
77
+ typedef uint32_t target_mword;
78
+ typedef target_mword SgenDescriptor;
79
+ typedef SgenDescriptor MonoGCDescriptor;
80
+ MONO_API int mono_gc_register_root (char *start, size_t size, MonoGCDescriptor descr, MonoGCRootSource source, void *key, const char *msg);
81
+ void mono_gc_deregister_root (char* addr);
82
+
83
+ EMSCRIPTEN_KEEPALIVE int
84
+ mono_wasm_register_root (char *start, size_t size, const char *name)
85
+ {
86
+ int result;
87
+ MONO_ENTER_GC_UNSAFE;
88
+ result = mono_gc_register_root (start, size, (MonoGCDescriptor)NULL, MONO_ROOT_SOURCE_EXTERNAL, NULL, name ? name : "mono_wasm_register_root");
89
+ MONO_EXIT_GC_UNSAFE;
90
+ return result;
91
+ }
92
+
93
+ EMSCRIPTEN_KEEPALIVE void
94
+ mono_wasm_deregister_root (char *addr)
95
+ {
96
+ MONO_ENTER_GC_UNSAFE;
97
+ mono_gc_deregister_root (addr);
98
+ MONO_EXIT_GC_UNSAFE;
99
+ }
100
+
101
+ static void
102
+ bundled_resources_free_func (void *resource, void *free_data)
103
+ {
104
+ free (free_data);
105
+ }
106
+
107
+ EMSCRIPTEN_KEEPALIVE int
108
+ mono_wasm_add_assembly (const char *name, const unsigned char *data, unsigned int size)
109
+ {
110
+ int len = strlen (name);
111
+ if (!strcasecmp (".pdb", &name [len - 4])) {
112
+ char *new_name = strdup (name);
113
+ //FIXME handle debugging assemblies with .exe extension
114
+ strcpy (&new_name [len - 3], "dll");
115
+ mono_bundled_resources_add_assembly_symbol_resource (new_name, data, size, bundled_resources_free_func, new_name);
116
+ return 1;
117
+ }
118
+ char *assembly_name = strdup (name);
119
+ assert (assembly_name);
120
+ mono_bundled_resources_add_assembly_resource (assembly_name, assembly_name, data, size, bundled_resources_free_func, assembly_name);
121
+ return mono_has_pdb_checksum ((char*)data, size);
122
+ }
123
+
124
+ static void
125
+ bundled_resources_free_slots_func (void *resource, void *free_data)
126
+ {
127
+ if (free_data) {
128
+ void **slots = (void **)free_data;
129
+ for (int i = 0; slots [i]; i++)
130
+ free (slots [i]);
131
+ }
132
+ }
133
+
134
+ EMSCRIPTEN_KEEPALIVE void
135
+ mono_wasm_add_satellite_assembly (const char *name, const char *culture, const unsigned char *data, unsigned int size)
136
+ {
137
+ int id_len = strlen (culture) + 1 + strlen (name); // +1 is for the "/"
138
+ char *id = (char *)malloc (sizeof (char) * (id_len + 1)); // +1 is for the terminating null character
139
+ assert (id);
140
+
141
+ int num_char = snprintf (id, (id_len + 1), "%s/%s", culture, name);
142
+ assert (num_char > 0 && num_char == id_len);
143
+
144
+ char *satellite_assembly_name = strdup (name);
145
+ assert (satellite_assembly_name);
146
+
147
+ char *satellite_assembly_culture = strdup (culture);
148
+ assert (satellite_assembly_culture);
149
+
150
+ void **slots = malloc (sizeof (void *) * 4);
151
+ assert (slots);
152
+ slots [0] = id;
153
+ slots [1] = satellite_assembly_name;
154
+ slots [2] = satellite_assembly_culture;
155
+ slots [3] = NULL;
156
+
157
+ mono_bundled_resources_add_satellite_assembly_resource (id, satellite_assembly_name, satellite_assembly_culture, data, size, bundled_resources_free_slots_func, slots);
158
+ }
159
+
160
+ EMSCRIPTEN_KEEPALIVE void
161
+ mono_wasm_setenv (const char *name, const char *value)
162
+ {
163
+ assert (name);
164
+ assert (value);
165
+ monoeg_g_setenv (strdup (name), strdup (value), 1);
166
+ }
167
+
168
+ EMSCRIPTEN_KEEPALIVE char *
169
+ mono_wasm_getenv (const char *name)
170
+ {
171
+ return monoeg_g_getenv (name); // JS must free
172
+ }
173
+
174
+ void mono_wasm_link_icu_shim (void);
175
+
176
+ void
177
+ cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data)
178
+ {
179
+ free (args);
180
+ free (user_data);
181
+ }
182
+
183
+ EMSCRIPTEN_KEEPALIVE void
184
+ mono_wasm_load_runtime (int debug_level)
185
+ {
186
+ const char *interp_opts = "";
187
+
188
+ #ifndef INVARIANT_GLOBALIZATION
189
+ mono_wasm_link_icu_shim ();
190
+ #endif
191
+
192
+ // When the list of app context properties changes, please update RuntimeConfigReservedProperties for
193
+ // target _WasmGenerateRuntimeConfig in BrowserWasmApp.targets file
194
+ const char *appctx_keys[2];
195
+ appctx_keys [0] = "APP_CONTEXT_BASE_DIRECTORY";
196
+ appctx_keys [1] = "RUNTIME_IDENTIFIER";
197
+
198
+ const char *appctx_values[2];
199
+ appctx_values [0] = "/";
200
+ appctx_values [1] = "browser-wasm";
201
+
202
+ char *file_name = RUNTIMECONFIG_BIN_FILE;
203
+ int str_len = strlen (file_name) + 1; // +1 is for the "/"
204
+ char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character
205
+ int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name);
206
+ struct stat buffer;
207
+
208
+ assert (num_char > 0 && num_char == str_len);
209
+
210
+ if (stat (file_path, &buffer) == 0) {
211
+ MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments));
212
+ arg->kind = 0;
213
+ arg->runtimeconfig.name.path = file_path;
214
+ monovm_runtimeconfig_initialize (arg, cleanup_runtime_config, file_path);
215
+ } else {
216
+ free (file_path);
217
+ }
218
+
219
+ monovm_initialize (2, appctx_keys, appctx_values);
220
+
221
+ #ifndef INVARIANT_TIMEZONE
222
+ mono_register_timezones_bundle ();
223
+ #endif /* INVARIANT_TIMEZONE */
224
+
225
+ root_domain = mono_wasm_load_runtime_common (debug_level, wasm_trace_logger, interp_opts);
226
+
227
+ bindings_initialize_internals();
228
+ }
229
+
230
+ EMSCRIPTEN_KEEPALIVE void
231
+ mono_wasm_invoke_jsexport (MonoMethod *method, void* args)
232
+ {
233
+ PVOLATILE(MonoObject) temp_exc = NULL;
234
+
235
+ void *invoke_args[1] = { args };
236
+
237
+ MONO_ENTER_GC_UNSAFE;
238
+ mono_runtime_invoke (method, NULL, args ? invoke_args : NULL, (MonoObject **)&temp_exc);
239
+
240
+ // this failure is unlikely because it would be runtime error, not application exception.
241
+ // the application exception is passed inside JSMarshalerArguments `args`
242
+ // so, if that happens, we should abort the runtime
243
+ if (temp_exc) {
244
+ PVOLATILE(MonoObject) exc2 = NULL;
245
+ store_volatile((MonoObject**)&temp_exc, (MonoObject*)mono_object_to_string ((MonoObject*)temp_exc, (MonoObject **)&exc2));
246
+ if (exc2) {
247
+ mono_wasm_trace_logger ("jsinterop", "critical", "mono_wasm_invoke_jsexport unexpected double fault", 1, NULL);
248
+ } else {
249
+ mono_wasm_trace_logger ("jsinterop", "critical", mono_string_to_utf8((MonoString*)temp_exc), 1, NULL);
250
+ }
251
+ abort ();
252
+ }
253
+ MONO_EXIT_GC_UNSAFE;
254
+ }
255
+
256
+ #ifndef DISABLE_THREADS
257
+
258
+ extern void mono_threads_wasm_async_run_in_target_thread_vii (void* target_thread, void (*func) (gpointer, gpointer), gpointer user_data1, gpointer user_data2);
259
+ extern void mono_threads_wasm_sync_run_in_target_thread_vii (void* target_thread, void (*func) (gpointer, gpointer), gpointer user_data1, gpointer args);
260
+ extern void mono_print_thread_dump (void *sigctx);
261
+
262
+ EMSCRIPTEN_KEEPALIVE void
263
+ mono_wasm_print_thread_dump (void)
264
+ {
265
+ mono_print_thread_dump (NULL);
266
+ }
267
+
268
+ // this is running on the target thread
269
+ static void
270
+ mono_wasm_invoke_jsexport_async_post_cb (MonoMethod *method, void* args)
271
+ {
272
+ mono_wasm_invoke_jsexport (method, args);
273
+ if (args) {
274
+ MonoBoolean *is_receiver_should_free = (MonoBoolean *)(((char *) args) + 20/*JSMarshalerArgumentOffsets.ReceiverShouldFree*/);
275
+ if(*is_receiver_should_free != 0){
276
+ free (args);
277
+ }
278
+ }
279
+ }
280
+
281
+ // async
282
+ EMSCRIPTEN_KEEPALIVE void
283
+ mono_wasm_invoke_jsexport_async_post (void* target_thread, MonoMethod *method, void* args /*JSMarshalerArguments*/)
284
+ {
285
+ mono_threads_wasm_async_run_in_target_thread_vii(target_thread, (void (*)(gpointer, gpointer))mono_wasm_invoke_jsexport_async_post_cb, method, args);
286
+ }
287
+
288
+
289
+ typedef void (*js_interop_event)(void* args);
290
+ typedef void (*sync_context_pump)(void);
291
+ extern js_interop_event before_sync_js_import;
292
+ extern js_interop_event after_sync_js_import;
293
+ extern sync_context_pump synchronization_context_pump_handler;
294
+
295
+ // this is running on the target thread
296
+ EMSCRIPTEN_KEEPALIVE void
297
+ mono_wasm_invoke_jsexport_sync (MonoMethod *method, void* args)
298
+ {
299
+ before_sync_js_import (args);
300
+ mono_wasm_invoke_jsexport (method, args);
301
+ after_sync_js_import (args);
302
+ }
303
+
304
+ // sync
305
+ EMSCRIPTEN_KEEPALIVE void
306
+ mono_wasm_invoke_jsexport_sync_send (void* target_thread, MonoMethod *method, void* args /*JSMarshalerArguments*/)
307
+ {
308
+ mono_threads_wasm_sync_run_in_target_thread_vii (target_thread, (void (*)(gpointer, gpointer))mono_wasm_invoke_jsexport_sync, method, args);
309
+ }
310
+
311
+ EMSCRIPTEN_KEEPALIVE void mono_wasm_synchronization_context_pump (void)
312
+ {
313
+ synchronization_context_pump_handler ();
314
+ }
315
+
316
+ #endif /* DISABLE_THREADS */
317
+
318
+ EMSCRIPTEN_KEEPALIVE void
319
+ mono_wasm_string_from_utf16_ref (const mono_unichar2 * chars, int length, MonoString **result)
320
+ {
321
+ assert (length >= 0);
322
+
323
+ MONO_ENTER_GC_UNSAFE;
324
+ if (chars) {
325
+ mono_gc_wbarrier_generic_store_atomic(result, (MonoObject *)mono_string_new_utf16 (root_domain, chars, length));
326
+ } else {
327
+ mono_gc_wbarrier_generic_store_atomic(result, NULL);
328
+ }
329
+ MONO_EXIT_GC_UNSAFE;
330
+ }
331
+
332
+ EMSCRIPTEN_KEEPALIVE int
333
+ mono_wasm_exec_regression (int verbose_level, char *image)
334
+ {
335
+ return mono_regression_test_step (verbose_level, image, NULL) ? 0 : 1;
336
+ }
337
+
338
+ EMSCRIPTEN_KEEPALIVE int
339
+ mono_wasm_exit (int exit_code)
340
+ {
341
+ if (exit_code == 0)
342
+ {
343
+ mono_jit_cleanup (root_domain);
344
+ }
345
+ fflush (stdout);
346
+ fflush (stderr);
347
+ emscripten_force_exit (exit_code);
348
+ }
349
+
350
+ EMSCRIPTEN_KEEPALIVE void
351
+ mono_wasm_set_main_args (int argc, char* argv[])
352
+ {
353
+ mono_runtime_set_main_args (argc, argv);
354
+ }
355
+
356
+ EMSCRIPTEN_KEEPALIVE int
357
+ mono_wasm_strdup (const char *s)
358
+ {
359
+ return (int)strdup (s);
360
+ }
361
+
362
+ EMSCRIPTEN_KEEPALIVE void
363
+ mono_wasm_parse_runtime_options (int argc, char* argv[])
364
+ {
365
+ mono_jit_parse_options (argc, argv);
366
+ }
367
+
368
+ EMSCRIPTEN_KEEPALIVE void
369
+ mono_wasm_intern_string_ref (MonoString **string)
370
+ {
371
+ MONO_ENTER_GC_UNSAFE;
372
+ mono_gc_wbarrier_generic_store_atomic(string, (MonoObject *)mono_string_intern (*string));
373
+ MONO_EXIT_GC_UNSAFE;
374
+ }
375
+
376
+ EMSCRIPTEN_KEEPALIVE void
377
+ mono_wasm_string_get_data_ref (
378
+ MonoString **string, mono_unichar2 **outChars, int *outLengthBytes, int *outIsInterned
379
+ ) {
380
+ MONO_ENTER_GC_UNSAFE;
381
+ if (!string || !(*string)) {
382
+ if (outChars)
383
+ *outChars = 0;
384
+ if (outLengthBytes)
385
+ *outLengthBytes = 0;
386
+ if (outIsInterned)
387
+ *outIsInterned = 1;
388
+ } else {
389
+ if (outChars)
390
+ *outChars = mono_string_chars (*string);
391
+ if (outLengthBytes)
392
+ *outLengthBytes = mono_string_length (*string) * 2;
393
+ if (outIsInterned)
394
+ *outIsInterned = mono_string_instance_is_interned (*string);
395
+ }
396
+ MONO_EXIT_GC_UNSAFE;
397
+ }
398
+
399
+ EMSCRIPTEN_KEEPALIVE void
400
+ mono_wasm_write_managed_pointer_unsafe (PPVOLATILE(MonoObject) destination, PVOLATILE(MonoObject) source) {
401
+ store_volatile(destination, source);
402
+ }
403
+
404
+ EMSCRIPTEN_KEEPALIVE void
405
+ mono_wasm_copy_managed_pointer (PPVOLATILE(MonoObject) destination, PPVOLATILE(MonoObject) source) {
406
+ copy_volatile(destination, source);
407
+ }
408
+
409
+ #ifdef ENABLE_AOT_PROFILER
410
+
411
+ void mono_profiler_init_aot (const char *desc);
412
+
413
+ EMSCRIPTEN_KEEPALIVE void
414
+ mono_wasm_profiler_init_aot (const char *desc)
415
+ {
416
+ mono_profiler_init_aot (desc);
417
+ }
418
+
419
+ #endif
420
+
421
+ #ifdef ENABLE_BROWSER_PROFILER
422
+
423
+ void mono_profiler_init_browser (const char *desc);
424
+
425
+ EMSCRIPTEN_KEEPALIVE void
426
+ mono_wasm_profiler_init_browser (const char *desc)
427
+ {
428
+ mono_profiler_init_browser (desc);
429
+ }
430
+
431
+ #endif
432
+
433
+ #ifdef ENABLE_LOG_PROFILER
434
+
435
+ void mono_profiler_init_log (const char *desc);
436
+
437
+ EMSCRIPTEN_KEEPALIVE void
438
+ mono_wasm_profiler_init_log (const char *desc)
439
+ {
440
+ mono_profiler_init_log (desc);
441
+ }
442
+
443
+ #endif
444
+
445
+ EMSCRIPTEN_KEEPALIVE void
446
+ mono_wasm_init_finalizer_thread (void)
447
+ {
448
+ // in the single threaded build, finalizers periodically run on the main thread instead.
449
+ #ifndef DISABLE_THREADS
450
+ mono_gc_init_finalizer_thread ();
451
+ #endif
452
+ }
453
+
454
+ #define I52_ERROR_NONE 0
455
+ #define I52_ERROR_NON_INTEGRAL 1
456
+ #define I52_ERROR_OUT_OF_RANGE 2
457
+
458
+ #define U52_MAX_VALUE ((1ULL << 53) - 1)
459
+ #define I52_MAX_VALUE ((1LL << 53) - 1)
460
+ #define I52_MIN_VALUE -I52_MAX_VALUE
461
+
462
+ EMSCRIPTEN_KEEPALIVE double mono_wasm_i52_to_f64 (int64_t *source, int *error) {
463
+ int64_t value = *source;
464
+
465
+ if ((value < I52_MIN_VALUE) || (value > I52_MAX_VALUE)) {
466
+ *error = I52_ERROR_OUT_OF_RANGE;
467
+ return NAN;
468
+ }
469
+
470
+ *error = I52_ERROR_NONE;
471
+ return (double)value;
472
+ }
473
+
474
+ EMSCRIPTEN_KEEPALIVE double mono_wasm_u52_to_f64 (uint64_t *source, int *error) {
475
+ uint64_t value = *source;
476
+
477
+ if (value > U52_MAX_VALUE) {
478
+ *error = I52_ERROR_OUT_OF_RANGE;
479
+ return NAN;
480
+ }
481
+
482
+ *error = I52_ERROR_NONE;
483
+ return (double)value;
484
+ }
485
+
486
+ EMSCRIPTEN_KEEPALIVE int mono_wasm_f64_to_u52 (uint64_t *destination, double value) {
487
+ if ((value < 0) || (value > U52_MAX_VALUE))
488
+ return I52_ERROR_OUT_OF_RANGE;
489
+ if (floor(value) != value)
490
+ return I52_ERROR_NON_INTEGRAL;
491
+
492
+ *destination = (uint64_t)value;
493
+ return I52_ERROR_NONE;
494
+ }
495
+
496
+ EMSCRIPTEN_KEEPALIVE int mono_wasm_f64_to_i52 (int64_t *destination, double value) {
497
+ if ((value < I52_MIN_VALUE) || (value > I52_MAX_VALUE))
498
+ return I52_ERROR_OUT_OF_RANGE;
499
+ if (floor(value) != value)
500
+ return I52_ERROR_NON_INTEGRAL;
501
+
502
+ *destination = (int64_t)value;
503
+ return I52_ERROR_NONE;
504
+ }
505
+
506
+ // JS is responsible for freeing this
507
+ EMSCRIPTEN_KEEPALIVE const char * mono_wasm_method_get_full_name (MonoMethod *method) {
508
+ const char *res;
509
+ MONO_ENTER_GC_UNSAFE;
510
+ res = mono_method_get_full_name (method);
511
+ MONO_EXIT_GC_UNSAFE;
512
+ return res;
513
+ }
514
+
515
+ EMSCRIPTEN_KEEPALIVE const char * mono_wasm_method_get_name (MonoMethod *method) {
516
+ const char *res;
517
+ MONO_ENTER_GC_UNSAFE;
518
+ res = mono_method_get_name (method);
519
+ MONO_EXIT_GC_UNSAFE;
520
+ return res;
521
+ }
522
+
523
+ EMSCRIPTEN_KEEPALIVE float mono_wasm_get_f32_unaligned (const float *src) {
524
+ return *src;
525
+ }
526
+
527
+ EMSCRIPTEN_KEEPALIVE double mono_wasm_get_f64_unaligned (const double *src) {
528
+ return *src;
529
+ }
530
+
531
+ EMSCRIPTEN_KEEPALIVE int32_t mono_wasm_get_i32_unaligned (const int32_t *src) {
532
+ return *src;
533
+ }
534
+
535
+ EMSCRIPTEN_KEEPALIVE int mono_wasm_is_zero_page_reserved () {
536
+ // If the stack is above the first 512 bytes of memory this indicates that it is safe
537
+ // to optimize out null checks for operations that also do a bounds check, like string
538
+ // and array element loads. (We already know that Emscripten malloc will never allocate
539
+ // data at 0.) This is the default behavior for Emscripten release builds and is
540
+ // controlled by the emscripten GLOBAL_BASE option (default value 1024).
541
+ // clang/llvm may perform this optimization if --low-memory-unused is set.
542
+ // https://github.com/emscripten-core/emscripten/issues/19389
543
+ return (emscripten_stack_get_base() > 512) && (emscripten_stack_get_end() > 512);
544
+ }
545
+
546
+ // this will return bool value if the object is a bool, otherwise it will return -1 or error
547
+ // we use it in Blazor's renderBatch as internal only
548
+ EMSCRIPTEN_KEEPALIVE int
549
+ mono_wasm_read_as_bool_or_null_unsafe (PVOLATILE(MonoObject) obj) {
550
+
551
+ int result = -1;
552
+
553
+ MONO_ENTER_GC_UNSAFE;
554
+
555
+ MonoClass *klass = mono_object_get_class (obj);
556
+ if (!klass) {
557
+ goto end;
558
+ }
559
+
560
+ MonoType *type = mono_class_get_type (klass);
561
+ if (!type) {
562
+ goto end;
563
+ }
564
+
565
+ int mono_type = mono_type_get_type (type);
566
+ if (MONO_TYPE_BOOLEAN == mono_type) {
567
+ result = ((signed char*)mono_object_unbox (obj) == 0 ? 0 : 1);
568
+ }
569
+
570
+ end:
571
+ MONO_EXIT_GC_UNSAFE;
572
+ return result;
573
+ }
File without changes
@@ -0,0 +1,17 @@
1
+ -Wno-unused-command-line-argument
2
+ -s INITIAL_MEMORY=33554432
3
+ -s STACK_SIZE=5MB
4
+ -s ALLOW_MEMORY_GROWTH=1
5
+ -s ALLOW_TABLE_GROWTH=1
6
+ -s NO_EXIT_RUNTIME=0
7
+ -s FORCE_FILESYSTEM=1
8
+ -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE="[]"
9
+ -s EXPORTED_RUNTIME_METHODS="['FS','out','err','ccall','cwrap','setValue','getValue','UTF8ToString','UTF8ArrayToString','lengthBytesUTF8','stringToUTF8Array','FS_createPath','FS_createDataFile','removeRunDependency','addRunDependency','addFunction','safeSetTimeout','runtimeKeepalivePush','runtimeKeepalivePop','maybeExit','abort','wasmExports']"
10
+ -s EXPORTED_FUNCTIONS=_free,_htons,_malloc,_sbrk,_memalign,_memset,_ntohs,stackAlloc,stackRestore,stackSave,_emscripten_force_exit,_fmod,_atan2,_fma,_pow,_fmodf,_atan2f,_fmaf,_powf,_asin,_asinh,_acos,_acosh,_atan,_atanh,_cbrt,_cos,_cosh,_exp,_log,_log2,_log10,_sin,_sinh,_tan,_tanh,_asinf,_asinhf,_acosf,_acoshf,_atanf,_atanhf,_cbrtf,_cosf,_coshf,_expf,_logf,_log2f,_log10f,_sinf,_sinhf,_tanf,_tanhf
11
+ --source-map-base http://example.com
12
+ -s WASM_BIGINT=1
13
+ -s EXPORT_NAME="'createDotnetRuntime'"
14
+ -s MODULARIZE=1
15
+ -s ENVIRONMENT="web,webview,worker,node,shell"
16
+ -Wno-limited-postlink-optimizations
17
+ --profiling-funcs
@@ -0,0 +1,73 @@
1
+ #define PVOLATILE(T) T* volatile
2
+ #define PPVOLATILE(T) T* volatile *
3
+
4
+ #if !defined(TARGET_BROWSER) && !defined(EMSCRIPTEN_KEEPALIVE)
5
+ #define EMSCRIPTEN_KEEPALIVE
6
+ #endif
7
+
8
+ #define gpointer void*
9
+
10
+ MONO_API MONO_RT_EXTERNAL_ONLY gpointer
11
+ mono_threads_enter_gc_unsafe_region (gpointer* stackdata);
12
+
13
+ MONO_API MONO_RT_EXTERNAL_ONLY void
14
+ mono_threads_exit_gc_unsafe_region (gpointer cookie, gpointer* stackdata);
15
+
16
+ MONO_API MONO_RT_EXTERNAL_ONLY void
17
+ mono_threads_assert_gc_unsafe_region (void);
18
+
19
+ MONO_API MONO_RT_EXTERNAL_ONLY gpointer
20
+ mono_threads_enter_gc_safe_region (gpointer *stackdata);
21
+
22
+ MONO_API MONO_RT_EXTERNAL_ONLY void
23
+ mono_threads_exit_gc_safe_region (gpointer cookie, gpointer *stackdata);
24
+
25
+ MONO_API void
26
+ mono_threads_assert_gc_safe_region (void);
27
+
28
+ #ifndef DISABLE_THREADS
29
+ #define MONO_ENTER_GC_UNSAFE \
30
+ do { \
31
+ gpointer __dummy; \
32
+ gpointer __gc_unsafe_cookie = mono_threads_enter_gc_unsafe_region (&__dummy) \
33
+
34
+ #define MONO_EXIT_GC_UNSAFE \
35
+ mono_threads_exit_gc_unsafe_region (__gc_unsafe_cookie, &__dummy); \
36
+ } while (0)
37
+
38
+ #define MONO_ENTER_GC_SAFE \
39
+ do { \
40
+ gpointer __dummy; \
41
+ gpointer __gc_safe_cookie = mono_threads_enter_gc_safe_region (&__dummy) \
42
+
43
+ #define MONO_EXIT_GC_SAFE \
44
+ mono_threads_exit_gc_safe_region (__gc_safe_cookie, &__dummy); \
45
+ } while (0)
46
+
47
+ #else /* DISABLE_THREADS */
48
+
49
+ #define MONO_ENTER_GC_UNSAFE do {
50
+
51
+ #define MONO_EXIT_GC_UNSAFE (void)0; } while (0)
52
+
53
+ #define MONO_ENTER_GC_SAFE do {
54
+
55
+ #define MONO_EXIT_GC_SAFE (void)0; } while (0)
56
+
57
+ #endif /* DISABLE_THREADS */
58
+
59
+ static void
60
+ store_volatile (PPVOLATILE(MonoObject) destination, PVOLATILE(MonoObject) source) {
61
+ mono_gc_wbarrier_generic_store_atomic((void*)destination, (MonoObject*)source);
62
+ }
63
+
64
+ static void
65
+ copy_volatile (PPVOLATILE(MonoObject) destination, PPVOLATILE(MonoObject) source) {
66
+ mono_gc_wbarrier_generic_store_atomic((void*)destination, (MonoObject*)(*source));
67
+ }
68
+
69
+ EMSCRIPTEN_KEEPALIVE int
70
+ mono_wasm_register_root (char *start, size_t size, const char *name);
71
+
72
+ EMSCRIPTEN_KEEPALIVE void
73
+ mono_wasm_deregister_root (char *addr);
@@ -0,0 +1,5 @@
1
+ import type { ErrorResponse, SuccessResponse, ApiResult } from './index';
2
+ export declare function isError(response: any): response is ErrorResponse;
3
+ export declare function isSuccess<T>(response: ApiResult<T>): response is SuccessResponse & T;
4
+ export declare function unwrap<T>(response: ApiResult<T>): SuccessResponse & T;
5
+ export declare function getError(response: any): string | null;
@@ -0,0 +1,15 @@
1
+ export function isError(response) {
2
+ return Boolean(response && typeof response === 'object' && 'error' in response);
3
+ }
4
+ export function isSuccess(response) {
5
+ return response && typeof response === 'object' && 'success' in response && response.success === true;
6
+ }
7
+ export function unwrap(response) {
8
+ if (isError(response)) {
9
+ throw new Error(`PKHeX API Error [${response.code || 'UNKNOWN'}]: ${response.error}`);
10
+ }
11
+ return response;
12
+ }
13
+ export function getError(response) {
14
+ return isError(response) ? response.error : null;
15
+ }