@textadventures/quest-viva-wasmplayer 6.0.0-beta.61 → 6.0.0-rc.2

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 (192) hide show
  1. package/WasmPlayer.runtimeconfig.json +1 -1
  2. package/_framework/Common.wasm +0 -0
  3. package/_framework/Engine.wasm +0 -0
  4. package/_framework/ExtendedNumerics.BigDecimal.wasm +0 -0
  5. package/_framework/Legacy.wasm +0 -0
  6. package/_framework/Microsoft.Extensions.Logging.Abstractions.wasm +0 -0
  7. package/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  8. package/_framework/NCalc.Core.wasm +0 -0
  9. package/_framework/NCalc.Domain.wasm +0 -0
  10. package/_framework/NCalc.Parser.wasm +0 -0
  11. package/_framework/Parlot.wasm +0 -0
  12. package/_framework/PlayerCore.wasm +0 -0
  13. package/_framework/System.Collections.Concurrent.wasm +0 -0
  14. package/_framework/System.Collections.Immutable.wasm +0 -0
  15. package/_framework/System.Collections.NonGeneric.wasm +0 -0
  16. package/_framework/System.Collections.Specialized.wasm +0 -0
  17. package/_framework/System.Collections.wasm +0 -0
  18. package/_framework/System.ComponentModel.Annotations.wasm +0 -0
  19. package/_framework/System.ComponentModel.Primitives.wasm +0 -0
  20. package/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  21. package/_framework/System.ComponentModel.wasm +0 -0
  22. package/_framework/System.IO.Compression.wasm +0 -0
  23. package/_framework/System.IO.Pipelines.wasm +0 -0
  24. package/_framework/System.Linq.Expressions.wasm +0 -0
  25. package/_framework/System.Linq.wasm +0 -0
  26. package/_framework/System.Memory.wasm +0 -0
  27. package/_framework/System.Net.Http.wasm +0 -0
  28. package/_framework/System.Net.Primitives.wasm +0 -0
  29. package/_framework/System.ObjectModel.wasm +0 -0
  30. package/_framework/System.Private.CoreLib.wasm +0 -0
  31. package/_framework/System.Private.Uri.wasm +0 -0
  32. package/_framework/System.Private.Xml.Linq.wasm +0 -0
  33. package/_framework/System.Private.Xml.wasm +0 -0
  34. package/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  35. package/_framework/System.Runtime.Numerics.wasm +0 -0
  36. package/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  37. package/_framework/System.Text.Encodings.Web.wasm +0 -0
  38. package/_framework/System.Text.Json.wasm +0 -0
  39. package/_framework/System.Text.RegularExpressions.wasm +0 -0
  40. package/_framework/System.Xml.Linq.wasm +0 -0
  41. package/_framework/System.wasm +0 -0
  42. package/_framework/WasmPlayer.wasm +0 -0
  43. package/_framework/dotnet.boot.js +83 -802
  44. package/_framework/dotnet.native.js +3 -1166
  45. package/_framework/dotnet.native.wasm +0 -0
  46. package/index.html +15 -15
  47. package/package.json +1 -1
  48. package/wasm-player.js +19 -2
  49. package/_framework/Microsoft.CSharp.wasm +0 -0
  50. package/_framework/Microsoft.Extensions.DependencyInjection.Abstractions.wasm +0 -0
  51. package/_framework/Microsoft.VisualBasic.wasm +0 -0
  52. package/_framework/Microsoft.Win32.Primitives.wasm +0 -0
  53. package/_framework/Microsoft.Win32.Registry.wasm +0 -0
  54. package/_framework/NCalc.Async.wasm +0 -0
  55. package/_framework/System.AppContext.wasm +0 -0
  56. package/_framework/System.Buffers.wasm +0 -0
  57. package/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
  58. package/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
  59. package/_framework/System.Configuration.wasm +0 -0
  60. package/_framework/System.Console.wasm +0 -0
  61. package/_framework/System.Core.wasm +0 -0
  62. package/_framework/System.Data.Common.wasm +0 -0
  63. package/_framework/System.Data.DataSetExtensions.wasm +0 -0
  64. package/_framework/System.Data.wasm +0 -0
  65. package/_framework/System.Diagnostics.Contracts.wasm +0 -0
  66. package/_framework/System.Diagnostics.Debug.wasm +0 -0
  67. package/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
  68. package/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
  69. package/_framework/System.Diagnostics.Process.wasm +0 -0
  70. package/_framework/System.Diagnostics.StackTrace.wasm +0 -0
  71. package/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
  72. package/_framework/System.Diagnostics.Tools.wasm +0 -0
  73. package/_framework/System.Diagnostics.TraceSource.wasm +0 -0
  74. package/_framework/System.Diagnostics.Tracing.wasm +0 -0
  75. package/_framework/System.Drawing.Primitives.wasm +0 -0
  76. package/_framework/System.Drawing.wasm +0 -0
  77. package/_framework/System.Dynamic.Runtime.wasm +0 -0
  78. package/_framework/System.Formats.Asn1.wasm +0 -0
  79. package/_framework/System.Formats.Tar.wasm +0 -0
  80. package/_framework/System.Globalization.Calendars.wasm +0 -0
  81. package/_framework/System.Globalization.Extensions.wasm +0 -0
  82. package/_framework/System.Globalization.wasm +0 -0
  83. package/_framework/System.IO.Compression.Brotli.wasm +0 -0
  84. package/_framework/System.IO.Compression.FileSystem.wasm +0 -0
  85. package/_framework/System.IO.Compression.ZipFile.wasm +0 -0
  86. package/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
  87. package/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
  88. package/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
  89. package/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
  90. package/_framework/System.IO.FileSystem.wasm +0 -0
  91. package/_framework/System.IO.IsolatedStorage.wasm +0 -0
  92. package/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
  93. package/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
  94. package/_framework/System.IO.Pipes.wasm +0 -0
  95. package/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
  96. package/_framework/System.IO.wasm +0 -0
  97. package/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
  98. package/_framework/System.Linq.Parallel.wasm +0 -0
  99. package/_framework/System.Linq.Queryable.wasm +0 -0
  100. package/_framework/System.Net.Http.Json.wasm +0 -0
  101. package/_framework/System.Net.HttpListener.wasm +0 -0
  102. package/_framework/System.Net.Mail.wasm +0 -0
  103. package/_framework/System.Net.NameResolution.wasm +0 -0
  104. package/_framework/System.Net.NetworkInformation.wasm +0 -0
  105. package/_framework/System.Net.Ping.wasm +0 -0
  106. package/_framework/System.Net.Quic.wasm +0 -0
  107. package/_framework/System.Net.Requests.wasm +0 -0
  108. package/_framework/System.Net.Security.wasm +0 -0
  109. package/_framework/System.Net.ServerSentEvents.wasm +0 -0
  110. package/_framework/System.Net.ServicePoint.wasm +0 -0
  111. package/_framework/System.Net.Sockets.wasm +0 -0
  112. package/_framework/System.Net.WebClient.wasm +0 -0
  113. package/_framework/System.Net.WebHeaderCollection.wasm +0 -0
  114. package/_framework/System.Net.WebProxy.wasm +0 -0
  115. package/_framework/System.Net.WebSockets.Client.wasm +0 -0
  116. package/_framework/System.Net.WebSockets.wasm +0 -0
  117. package/_framework/System.Net.wasm +0 -0
  118. package/_framework/System.Numerics.Vectors.wasm +0 -0
  119. package/_framework/System.Numerics.wasm +0 -0
  120. package/_framework/System.Private.DataContractSerialization.wasm +0 -0
  121. package/_framework/System.Reflection.DispatchProxy.wasm +0 -0
  122. package/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
  123. package/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
  124. package/_framework/System.Reflection.Emit.wasm +0 -0
  125. package/_framework/System.Reflection.Extensions.wasm +0 -0
  126. package/_framework/System.Reflection.Metadata.wasm +0 -0
  127. package/_framework/System.Reflection.Primitives.wasm +0 -0
  128. package/_framework/System.Reflection.TypeExtensions.wasm +0 -0
  129. package/_framework/System.Reflection.wasm +0 -0
  130. package/_framework/System.Resources.Reader.wasm +0 -0
  131. package/_framework/System.Resources.ResourceManager.wasm +0 -0
  132. package/_framework/System.Resources.Writer.wasm +0 -0
  133. package/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
  134. package/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
  135. package/_framework/System.Runtime.Extensions.wasm +0 -0
  136. package/_framework/System.Runtime.Handles.wasm +0 -0
  137. package/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
  138. package/_framework/System.Runtime.InteropServices.wasm +0 -0
  139. package/_framework/System.Runtime.Intrinsics.wasm +0 -0
  140. package/_framework/System.Runtime.Loader.wasm +0 -0
  141. package/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
  142. package/_framework/System.Runtime.Serialization.Json.wasm +0 -0
  143. package/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
  144. package/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
  145. package/_framework/System.Runtime.Serialization.wasm +0 -0
  146. package/_framework/System.Runtime.wasm +0 -0
  147. package/_framework/System.Security.AccessControl.wasm +0 -0
  148. package/_framework/System.Security.Claims.wasm +0 -0
  149. package/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
  150. package/_framework/System.Security.Cryptography.Cng.wasm +0 -0
  151. package/_framework/System.Security.Cryptography.Csp.wasm +0 -0
  152. package/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
  153. package/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
  154. package/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
  155. package/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
  156. package/_framework/System.Security.Cryptography.wasm +0 -0
  157. package/_framework/System.Security.Principal.Windows.wasm +0 -0
  158. package/_framework/System.Security.Principal.wasm +0 -0
  159. package/_framework/System.Security.SecureString.wasm +0 -0
  160. package/_framework/System.Security.wasm +0 -0
  161. package/_framework/System.ServiceModel.Web.wasm +0 -0
  162. package/_framework/System.ServiceProcess.wasm +0 -0
  163. package/_framework/System.Text.Encoding.Extensions.wasm +0 -0
  164. package/_framework/System.Text.Encoding.wasm +0 -0
  165. package/_framework/System.Threading.AccessControl.wasm +0 -0
  166. package/_framework/System.Threading.Channels.wasm +0 -0
  167. package/_framework/System.Threading.Overlapped.wasm +0 -0
  168. package/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
  169. package/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
  170. package/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
  171. package/_framework/System.Threading.Tasks.wasm +0 -0
  172. package/_framework/System.Threading.Thread.wasm +0 -0
  173. package/_framework/System.Threading.ThreadPool.wasm +0 -0
  174. package/_framework/System.Threading.Timer.wasm +0 -0
  175. package/_framework/System.Threading.wasm +0 -0
  176. package/_framework/System.Transactions.Local.wasm +0 -0
  177. package/_framework/System.Transactions.wasm +0 -0
  178. package/_framework/System.ValueTuple.wasm +0 -0
  179. package/_framework/System.Web.HttpUtility.wasm +0 -0
  180. package/_framework/System.Web.wasm +0 -0
  181. package/_framework/System.Windows.wasm +0 -0
  182. package/_framework/System.Xml.ReaderWriter.wasm +0 -0
  183. package/_framework/System.Xml.Serialization.wasm +0 -0
  184. package/_framework/System.Xml.XDocument.wasm +0 -0
  185. package/_framework/System.Xml.XPath.XDocument.wasm +0 -0
  186. package/_framework/System.Xml.XPath.wasm +0 -0
  187. package/_framework/System.Xml.XmlDocument.wasm +0 -0
  188. package/_framework/System.Xml.XmlSerializer.wasm +0 -0
  189. package/_framework/System.Xml.wasm +0 -0
  190. package/_framework/WindowsBase.wasm +0 -0
  191. package/_framework/mscorlib.wasm +0 -0
  192. package/_framework/netstandard.wasm +0 -0
@@ -488,7 +488,6 @@ if (!Module['noFSInit'] && !FS.init.initialized)
488
488
  FS.ignorePermissions = false;
489
489
 
490
490
  TTY.init();
491
- SOCKFS.root = FS.mount(SOCKFS, {}, null);
492
491
  callRuntimeCallbacks(__ATINIT__);
493
492
  }
494
493
 
@@ -3447,952 +3446,6 @@ function createWasm() {
3447
3446
  return stream;
3448
3447
  },
3449
3448
  };
3450
- function ___syscall_chdir(path) {
3451
- try {
3452
-
3453
- path = SYSCALLS.getStr(path);
3454
- FS.chdir(path);
3455
- return 0;
3456
- } catch (e) {
3457
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
3458
- return -e.errno;
3459
- }
3460
- }
3461
-
3462
- function ___syscall_chmod(path, mode) {
3463
- try {
3464
-
3465
- path = SYSCALLS.getStr(path);
3466
- FS.chmod(path, mode);
3467
- return 0;
3468
- } catch (e) {
3469
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
3470
- return -e.errno;
3471
- }
3472
- }
3473
-
3474
- var SOCKFS = {
3475
- mount(mount) {
3476
- // If Module['websocket'] has already been defined (e.g. for configuring
3477
- // the subprotocol/url) use that, if not initialise it to a new object.
3478
- Module['websocket'] = (Module['websocket'] &&
3479
- ('object' === typeof Module['websocket'])) ? Module['websocket'] : {};
3480
-
3481
- // Add the Event registration mechanism to the exported websocket configuration
3482
- // object so we can register network callbacks from native JavaScript too.
3483
- // For more documentation see system/include/emscripten/emscripten.h
3484
- Module['websocket']._callbacks = {};
3485
- Module['websocket']['on'] = /** @this{Object} */ function(event, callback) {
3486
- if ('function' === typeof callback) {
3487
- this._callbacks[event] = callback;
3488
- }
3489
- return this;
3490
- };
3491
-
3492
- Module['websocket'].emit = /** @this{Object} */ function(event, param) {
3493
- if ('function' === typeof this._callbacks[event]) {
3494
- this._callbacks[event].call(this, param);
3495
- }
3496
- };
3497
-
3498
- // If debug is enabled register simple default logging callbacks for each Event.
3499
-
3500
- return FS.createNode(null, '/', 16384 | 511 /* 0777 */, 0);
3501
- },
3502
- createSocket(family, type, protocol) {
3503
- type &= ~526336; // Some applications may pass it; it makes no sense for a single process.
3504
- var streaming = type == 1;
3505
- if (streaming && protocol && protocol != 6) {
3506
- throw new FS.ErrnoError(66); // if SOCK_STREAM, must be tcp or 0.
3507
- }
3508
-
3509
- // create our internal socket structure
3510
- var sock = {
3511
- family,
3512
- type,
3513
- protocol,
3514
- server: null,
3515
- error: null, // Used in getsockopt for SOL_SOCKET/SO_ERROR test
3516
- peers: {},
3517
- pending: [],
3518
- recv_queue: [],
3519
- sock_ops: SOCKFS.websocket_sock_ops
3520
- };
3521
-
3522
- // create the filesystem node to store the socket structure
3523
- var name = SOCKFS.nextname();
3524
- var node = FS.createNode(SOCKFS.root, name, 49152, 0);
3525
- node.sock = sock;
3526
-
3527
- // and the wrapping stream that enables library functions such
3528
- // as read and write to indirectly interact with the socket
3529
- var stream = FS.createStream({
3530
- path: name,
3531
- node,
3532
- flags: 2,
3533
- seekable: false,
3534
- stream_ops: SOCKFS.stream_ops
3535
- });
3536
-
3537
- // map the new stream to the socket structure (sockets have a 1:1
3538
- // relationship with a stream)
3539
- sock.stream = stream;
3540
-
3541
- return sock;
3542
- },
3543
- getSocket(fd) {
3544
- var stream = FS.getStream(fd);
3545
- if (!stream || !FS.isSocket(stream.node.mode)) {
3546
- return null;
3547
- }
3548
- return stream.node.sock;
3549
- },
3550
- stream_ops:{
3551
- poll(stream) {
3552
- var sock = stream.node.sock;
3553
- return sock.sock_ops.poll(sock);
3554
- },
3555
- ioctl(stream, request, varargs) {
3556
- var sock = stream.node.sock;
3557
- return sock.sock_ops.ioctl(sock, request, varargs);
3558
- },
3559
- read(stream, buffer, offset, length, position /* ignored */) {
3560
- var sock = stream.node.sock;
3561
- var msg = sock.sock_ops.recvmsg(sock, length);
3562
- if (!msg) {
3563
- // socket is closed
3564
- return 0;
3565
- }
3566
- buffer.set(msg.buffer, offset);
3567
- return msg.buffer.length;
3568
- },
3569
- write(stream, buffer, offset, length, position /* ignored */) {
3570
- var sock = stream.node.sock;
3571
- return sock.sock_ops.sendmsg(sock, buffer, offset, length);
3572
- },
3573
- close(stream) {
3574
- var sock = stream.node.sock;
3575
- sock.sock_ops.close(sock);
3576
- },
3577
- },
3578
- nextname() {
3579
- if (!SOCKFS.nextname.current) {
3580
- SOCKFS.nextname.current = 0;
3581
- }
3582
- return 'socket[' + (SOCKFS.nextname.current++) + ']';
3583
- },
3584
- websocket_sock_ops:{
3585
- createPeer(sock, addr, port) {
3586
- var ws;
3587
-
3588
- if (typeof addr == 'object') {
3589
- ws = addr;
3590
- addr = null;
3591
- port = null;
3592
- }
3593
-
3594
- if (ws) {
3595
- // for sockets that've already connected (e.g. we're the server)
3596
- // we can inspect the _socket property for the address
3597
- if (ws._socket) {
3598
- addr = ws._socket.remoteAddress;
3599
- port = ws._socket.remotePort;
3600
- }
3601
- // if we're just now initializing a connection to the remote,
3602
- // inspect the url property
3603
- else {
3604
- var result = /ws[s]?:\/\/([^:]+):(\d+)/.exec(ws.url);
3605
- if (!result) {
3606
- throw new Error('WebSocket URL must be in the format ws(s)://address:port');
3607
- }
3608
- addr = result[1];
3609
- port = parseInt(result[2], 10);
3610
- }
3611
- } else {
3612
- // create the actual websocket object and connect
3613
- try {
3614
- // runtimeConfig gets set to true if WebSocket runtime configuration is available.
3615
- var runtimeConfig = (Module['websocket'] && ('object' === typeof Module['websocket']));
3616
-
3617
- // The default value is 'ws://' the replace is needed because the compiler replaces '//' comments with '#'
3618
- // comments without checking context, so we'd end up with ws:#, the replace swaps the '#' for '//' again.
3619
- var url = 'ws:#'.replace('#', '//');
3620
-
3621
- if (runtimeConfig) {
3622
- if ('string' === typeof Module['websocket']['url']) {
3623
- url = Module['websocket']['url']; // Fetch runtime WebSocket URL config.
3624
- }
3625
- }
3626
-
3627
- if (url === 'ws://' || url === 'wss://') { // Is the supplied URL config just a prefix, if so complete it.
3628
- var parts = addr.split('/');
3629
- url = url + parts[0] + ":" + port + "/" + parts.slice(1).join('/');
3630
- }
3631
-
3632
- // Make the WebSocket subprotocol (Sec-WebSocket-Protocol) default to binary if no configuration is set.
3633
- var subProtocols = 'binary'; // The default value is 'binary'
3634
-
3635
- if (runtimeConfig) {
3636
- if ('string' === typeof Module['websocket']['subprotocol']) {
3637
- subProtocols = Module['websocket']['subprotocol']; // Fetch runtime WebSocket subprotocol config.
3638
- }
3639
- }
3640
-
3641
- // The default WebSocket options
3642
- var opts = undefined;
3643
-
3644
- if (subProtocols !== 'null') {
3645
- // The regex trims the string (removes spaces at the beginning and end, then splits the string by
3646
- // <any space>,<any space> into an Array. Whitespace removal is important for Websockify and ws.
3647
- subProtocols = subProtocols.replace(/^ +| +$/g,"").split(/ *, */);
3648
-
3649
- opts = subProtocols;
3650
- }
3651
-
3652
- // some webservers (azure) does not support subprotocol header
3653
- if (runtimeConfig && null === Module['websocket']['subprotocol']) {
3654
- subProtocols = 'null';
3655
- opts = undefined;
3656
- }
3657
-
3658
- // If node we use the ws library.
3659
- var WebSocketConstructor;
3660
- if (ENVIRONMENT_IS_NODE) {
3661
- WebSocketConstructor = /** @type{(typeof WebSocket)} */(require('ws'));
3662
- } else
3663
- {
3664
- WebSocketConstructor = WebSocket;
3665
- }
3666
- ws = new WebSocketConstructor(url, opts);
3667
- ws.binaryType = 'arraybuffer';
3668
- } catch (e) {
3669
- throw new FS.ErrnoError(23);
3670
- }
3671
- }
3672
-
3673
- var peer = {
3674
- addr,
3675
- port,
3676
- socket: ws,
3677
- dgram_send_queue: []
3678
- };
3679
-
3680
- SOCKFS.websocket_sock_ops.addPeer(sock, peer);
3681
- SOCKFS.websocket_sock_ops.handlePeerEvents(sock, peer);
3682
-
3683
- // if this is a bound dgram socket, send the port number first to allow
3684
- // us to override the ephemeral port reported to us by remotePort on the
3685
- // remote end.
3686
- if (sock.type === 2 && typeof sock.sport != 'undefined') {
3687
- peer.dgram_send_queue.push(new Uint8Array([
3688
- 255, 255, 255, 255,
3689
- 'p'.charCodeAt(0), 'o'.charCodeAt(0), 'r'.charCodeAt(0), 't'.charCodeAt(0),
3690
- ((sock.sport & 0xff00) >> 8) , (sock.sport & 0xff)
3691
- ]));
3692
- }
3693
-
3694
- return peer;
3695
- },
3696
- getPeer(sock, addr, port) {
3697
- return sock.peers[addr + ':' + port];
3698
- },
3699
- addPeer(sock, peer) {
3700
- sock.peers[peer.addr + ':' + peer.port] = peer;
3701
- },
3702
- removePeer(sock, peer) {
3703
- delete sock.peers[peer.addr + ':' + peer.port];
3704
- },
3705
- handlePeerEvents(sock, peer) {
3706
- var first = true;
3707
-
3708
- var handleOpen = function () {
3709
-
3710
- Module['websocket'].emit('open', sock.stream.fd);
3711
-
3712
- try {
3713
- var queued = peer.dgram_send_queue.shift();
3714
- while (queued) {
3715
- peer.socket.send(queued);
3716
- queued = peer.dgram_send_queue.shift();
3717
- }
3718
- } catch (e) {
3719
- // not much we can do here in the way of proper error handling as we've already
3720
- // lied and said this data was sent. shut it down.
3721
- peer.socket.close();
3722
- }
3723
- };
3724
-
3725
- function handleMessage(data) {
3726
- if (typeof data == 'string') {
3727
- var encoder = new TextEncoder(); // should be utf-8
3728
- data = encoder.encode(data); // make a typed array from the string
3729
- } else {
3730
- assert(data.byteLength !== undefined); // must receive an ArrayBuffer
3731
- if (data.byteLength == 0) {
3732
- // An empty ArrayBuffer will emit a pseudo disconnect event
3733
- // as recv/recvmsg will return zero which indicates that a socket
3734
- // has performed a shutdown although the connection has not been disconnected yet.
3735
- return;
3736
- }
3737
- data = new Uint8Array(data); // make a typed array view on the array buffer
3738
- }
3739
-
3740
- // if this is the port message, override the peer's port with it
3741
- var wasfirst = first;
3742
- first = false;
3743
- if (wasfirst &&
3744
- data.length === 10 &&
3745
- data[0] === 255 && data[1] === 255 && data[2] === 255 && data[3] === 255 &&
3746
- data[4] === 'p'.charCodeAt(0) && data[5] === 'o'.charCodeAt(0) && data[6] === 'r'.charCodeAt(0) && data[7] === 't'.charCodeAt(0)) {
3747
- // update the peer's port and it's key in the peer map
3748
- var newport = ((data[8] << 8) | data[9]);
3749
- SOCKFS.websocket_sock_ops.removePeer(sock, peer);
3750
- peer.port = newport;
3751
- SOCKFS.websocket_sock_ops.addPeer(sock, peer);
3752
- return;
3753
- }
3754
-
3755
- sock.recv_queue.push({ addr: peer.addr, port: peer.port, data: data });
3756
- Module['websocket'].emit('message', sock.stream.fd);
3757
- };
3758
-
3759
- if (ENVIRONMENT_IS_NODE) {
3760
- peer.socket.on('open', handleOpen);
3761
- peer.socket.on('message', function(data, isBinary) {
3762
- if (!isBinary) {
3763
- return;
3764
- }
3765
- handleMessage((new Uint8Array(data)).buffer); // copy from node Buffer -> ArrayBuffer
3766
- });
3767
- peer.socket.on('close', function() {
3768
- Module['websocket'].emit('close', sock.stream.fd);
3769
- });
3770
- peer.socket.on('error', function(error) {
3771
- // Although the ws library may pass errors that may be more descriptive than
3772
- // ECONNREFUSED they are not necessarily the expected error code e.g.
3773
- // ENOTFOUND on getaddrinfo seems to be node.js specific, so using ECONNREFUSED
3774
- // is still probably the most useful thing to do.
3775
- sock.error = 14; // Used in getsockopt for SOL_SOCKET/SO_ERROR test.
3776
- Module['websocket'].emit('error', [sock.stream.fd, sock.error, 'ECONNREFUSED: Connection refused']);
3777
- // don't throw
3778
- });
3779
- } else {
3780
- peer.socket.onopen = handleOpen;
3781
- peer.socket.onclose = function() {
3782
- Module['websocket'].emit('close', sock.stream.fd);
3783
- };
3784
- peer.socket.onmessage = function peer_socket_onmessage(event) {
3785
- handleMessage(event.data);
3786
- };
3787
- peer.socket.onerror = function(error) {
3788
- // The WebSocket spec only allows a 'simple event' to be thrown on error,
3789
- // so we only really know as much as ECONNREFUSED.
3790
- sock.error = 14; // Used in getsockopt for SOL_SOCKET/SO_ERROR test.
3791
- Module['websocket'].emit('error', [sock.stream.fd, sock.error, 'ECONNREFUSED: Connection refused']);
3792
- };
3793
- }
3794
- },
3795
- poll(sock) {
3796
- if (sock.type === 1 && sock.server) {
3797
- // listen sockets should only say they're available for reading
3798
- // if there are pending clients.
3799
- return sock.pending.length ? (64 | 1) : 0;
3800
- }
3801
-
3802
- var mask = 0;
3803
- var dest = sock.type === 1 ? // we only care about the socket state for connection-based sockets
3804
- SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport) :
3805
- null;
3806
-
3807
- if (sock.recv_queue.length ||
3808
- !dest || // connection-less sockets are always ready to read
3809
- (dest && dest.socket.readyState === dest.socket.CLOSING) ||
3810
- (dest && dest.socket.readyState === dest.socket.CLOSED)) { // let recv return 0 once closed
3811
- mask |= (64 | 1);
3812
- }
3813
-
3814
- if (!dest || // connection-less sockets are always ready to write
3815
- (dest && dest.socket.readyState === dest.socket.OPEN)) {
3816
- mask |= 4;
3817
- }
3818
-
3819
- if ((dest && dest.socket.readyState === dest.socket.CLOSING) ||
3820
- (dest && dest.socket.readyState === dest.socket.CLOSED)) {
3821
- mask |= 16;
3822
- }
3823
-
3824
- return mask;
3825
- },
3826
- ioctl(sock, request, arg) {
3827
- switch (request) {
3828
- case 21531:
3829
- var bytes = 0;
3830
- if (sock.recv_queue.length) {
3831
- bytes = sock.recv_queue[0].data.length;
3832
- }
3833
- HEAP32[((arg)>>2)] = bytes;
3834
- return 0;
3835
- default:
3836
- return 28;
3837
- }
3838
- },
3839
- close(sock) {
3840
- // if we've spawned a listen server, close it
3841
- if (sock.server) {
3842
- try {
3843
- sock.server.close();
3844
- } catch (e) {
3845
- }
3846
- sock.server = null;
3847
- }
3848
- // close any peer connections
3849
- var peers = Object.keys(sock.peers);
3850
- for (var i = 0; i < peers.length; i++) {
3851
- var peer = sock.peers[peers[i]];
3852
- try {
3853
- peer.socket.close();
3854
- } catch (e) {
3855
- }
3856
- SOCKFS.websocket_sock_ops.removePeer(sock, peer);
3857
- }
3858
- return 0;
3859
- },
3860
- bind(sock, addr, port) {
3861
- if (typeof sock.saddr != 'undefined' || typeof sock.sport != 'undefined') {
3862
- throw new FS.ErrnoError(28); // already bound
3863
- }
3864
- sock.saddr = addr;
3865
- sock.sport = port;
3866
- // in order to emulate dgram sockets, we need to launch a listen server when
3867
- // binding on a connection-less socket
3868
- // note: this is only required on the server side
3869
- if (sock.type === 2) {
3870
- // close the existing server if it exists
3871
- if (sock.server) {
3872
- sock.server.close();
3873
- sock.server = null;
3874
- }
3875
- // swallow error operation not supported error that occurs when binding in the
3876
- // browser where this isn't supported
3877
- try {
3878
- sock.sock_ops.listen(sock, 0);
3879
- } catch (e) {
3880
- if (!(e.name === 'ErrnoError')) throw e;
3881
- if (e.errno !== 138) throw e;
3882
- }
3883
- }
3884
- },
3885
- connect(sock, addr, port) {
3886
- if (sock.server) {
3887
- throw new FS.ErrnoError(138);
3888
- }
3889
-
3890
- // TODO autobind
3891
- // if (!sock.addr && sock.type == 2) {
3892
- // }
3893
-
3894
- // early out if we're already connected / in the middle of connecting
3895
- if (typeof sock.daddr != 'undefined' && typeof sock.dport != 'undefined') {
3896
- var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
3897
- if (dest) {
3898
- if (dest.socket.readyState === dest.socket.CONNECTING) {
3899
- throw new FS.ErrnoError(7);
3900
- } else {
3901
- throw new FS.ErrnoError(30);
3902
- }
3903
- }
3904
- }
3905
-
3906
- // add the socket to our peer list and set our
3907
- // destination address / port to match
3908
- var peer = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
3909
- sock.daddr = peer.addr;
3910
- sock.dport = peer.port;
3911
-
3912
- // always "fail" in non-blocking mode
3913
- throw new FS.ErrnoError(26);
3914
- },
3915
- listen(sock, backlog) {
3916
- if (!ENVIRONMENT_IS_NODE) {
3917
- throw new FS.ErrnoError(138);
3918
- }
3919
- if (sock.server) {
3920
- throw new FS.ErrnoError(28); // already listening
3921
- }
3922
- var WebSocketServer = require('ws').Server;
3923
- var host = sock.saddr;
3924
- sock.server = new WebSocketServer({
3925
- host,
3926
- port: sock.sport
3927
- // TODO support backlog
3928
- });
3929
- Module['websocket'].emit('listen', sock.stream.fd); // Send Event with listen fd.
3930
-
3931
- sock.server.on('connection', function(ws) {
3932
- if (sock.type === 1) {
3933
- var newsock = SOCKFS.createSocket(sock.family, sock.type, sock.protocol);
3934
-
3935
- // create a peer on the new socket
3936
- var peer = SOCKFS.websocket_sock_ops.createPeer(newsock, ws);
3937
- newsock.daddr = peer.addr;
3938
- newsock.dport = peer.port;
3939
-
3940
- // push to queue for accept to pick up
3941
- sock.pending.push(newsock);
3942
- Module['websocket'].emit('connection', newsock.stream.fd);
3943
- } else {
3944
- // create a peer on the listen socket so calling sendto
3945
- // with the listen socket and an address will resolve
3946
- // to the correct client
3947
- SOCKFS.websocket_sock_ops.createPeer(sock, ws);
3948
- Module['websocket'].emit('connection', sock.stream.fd);
3949
- }
3950
- });
3951
- sock.server.on('close', function() {
3952
- Module['websocket'].emit('close', sock.stream.fd);
3953
- sock.server = null;
3954
- });
3955
- sock.server.on('error', function(error) {
3956
- // Although the ws library may pass errors that may be more descriptive than
3957
- // ECONNREFUSED they are not necessarily the expected error code e.g.
3958
- // ENOTFOUND on getaddrinfo seems to be node.js specific, so using EHOSTUNREACH
3959
- // is still probably the most useful thing to do. This error shouldn't
3960
- // occur in a well written app as errors should get trapped in the compiled
3961
- // app's own getaddrinfo call.
3962
- sock.error = 23; // Used in getsockopt for SOL_SOCKET/SO_ERROR test.
3963
- Module['websocket'].emit('error', [sock.stream.fd, sock.error, 'EHOSTUNREACH: Host is unreachable']);
3964
- // don't throw
3965
- });
3966
- },
3967
- accept(listensock) {
3968
- if (!listensock.server || !listensock.pending.length) {
3969
- throw new FS.ErrnoError(28);
3970
- }
3971
- var newsock = listensock.pending.shift();
3972
- newsock.stream.flags = listensock.stream.flags;
3973
- return newsock;
3974
- },
3975
- getname(sock, peer) {
3976
- var addr, port;
3977
- if (peer) {
3978
- if (sock.daddr === undefined || sock.dport === undefined) {
3979
- throw new FS.ErrnoError(53);
3980
- }
3981
- addr = sock.daddr;
3982
- port = sock.dport;
3983
- } else {
3984
- // TODO saddr and sport will be set for bind()'d UDP sockets, but what
3985
- // should we be returning for TCP sockets that've been connect()'d?
3986
- addr = sock.saddr || 0;
3987
- port = sock.sport || 0;
3988
- }
3989
- return { addr, port };
3990
- },
3991
- sendmsg(sock, buffer, offset, length, addr, port) {
3992
- if (sock.type === 2) {
3993
- // connection-less sockets will honor the message address,
3994
- // and otherwise fall back to the bound destination address
3995
- if (addr === undefined || port === undefined) {
3996
- addr = sock.daddr;
3997
- port = sock.dport;
3998
- }
3999
- // if there was no address to fall back to, error out
4000
- if (addr === undefined || port === undefined) {
4001
- throw new FS.ErrnoError(17);
4002
- }
4003
- } else {
4004
- // connection-based sockets will only use the bound
4005
- addr = sock.daddr;
4006
- port = sock.dport;
4007
- }
4008
-
4009
- // find the peer for the destination address
4010
- var dest = SOCKFS.websocket_sock_ops.getPeer(sock, addr, port);
4011
-
4012
- // early out if not connected with a connection-based socket
4013
- if (sock.type === 1) {
4014
- if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
4015
- throw new FS.ErrnoError(53);
4016
- } else if (dest.socket.readyState === dest.socket.CONNECTING) {
4017
- throw new FS.ErrnoError(6);
4018
- }
4019
- }
4020
-
4021
- // create a copy of the incoming data to send, as the WebSocket API
4022
- // doesn't work entirely with an ArrayBufferView, it'll just send
4023
- // the entire underlying buffer
4024
- if (ArrayBuffer.isView(buffer)) {
4025
- offset += buffer.byteOffset;
4026
- buffer = buffer.buffer;
4027
- }
4028
-
4029
- var data;
4030
- data = buffer.slice(offset, offset + length);
4031
-
4032
- // if we're emulating a connection-less dgram socket and don't have
4033
- // a cached connection, queue the buffer to send upon connect and
4034
- // lie, saying the data was sent now.
4035
- if (sock.type === 2) {
4036
- if (!dest || dest.socket.readyState !== dest.socket.OPEN) {
4037
- // if we're not connected, open a new connection
4038
- if (!dest || dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
4039
- dest = SOCKFS.websocket_sock_ops.createPeer(sock, addr, port);
4040
- }
4041
- dest.dgram_send_queue.push(data);
4042
- return length;
4043
- }
4044
- }
4045
-
4046
- try {
4047
- // send the actual data
4048
- dest.socket.send(data);
4049
- return length;
4050
- } catch (e) {
4051
- throw new FS.ErrnoError(28);
4052
- }
4053
- },
4054
- recvmsg(sock, length) {
4055
- // http://pubs.opengroup.org/onlinepubs/7908799/xns/recvmsg.html
4056
- if (sock.type === 1 && sock.server) {
4057
- // tcp servers should not be recv()'ing on the listen socket
4058
- throw new FS.ErrnoError(53);
4059
- }
4060
-
4061
- var queued = sock.recv_queue.shift();
4062
- if (!queued) {
4063
- if (sock.type === 1) {
4064
- var dest = SOCKFS.websocket_sock_ops.getPeer(sock, sock.daddr, sock.dport);
4065
-
4066
- if (!dest) {
4067
- // if we have a destination address but are not connected, error out
4068
- throw new FS.ErrnoError(53);
4069
- }
4070
- if (dest.socket.readyState === dest.socket.CLOSING || dest.socket.readyState === dest.socket.CLOSED) {
4071
- // return null if the socket has closed
4072
- return null;
4073
- }
4074
- // else, our socket is in a valid state but truly has nothing available
4075
- throw new FS.ErrnoError(6);
4076
- }
4077
- throw new FS.ErrnoError(6);
4078
- }
4079
-
4080
- // queued.data will be an ArrayBuffer if it's unadulterated, but if it's
4081
- // requeued TCP data it'll be an ArrayBufferView
4082
- var queuedLength = queued.data.byteLength || queued.data.length;
4083
- var queuedOffset = queued.data.byteOffset || 0;
4084
- var queuedBuffer = queued.data.buffer || queued.data;
4085
- var bytesRead = Math.min(length, queuedLength);
4086
- var res = {
4087
- buffer: new Uint8Array(queuedBuffer, queuedOffset, bytesRead),
4088
- addr: queued.addr,
4089
- port: queued.port
4090
- };
4091
-
4092
- // push back any unread data for TCP connections
4093
- if (sock.type === 1 && bytesRead < queuedLength) {
4094
- var bytesRemaining = queuedLength - bytesRead;
4095
- queued.data = new Uint8Array(queuedBuffer, queuedOffset + bytesRead, bytesRemaining);
4096
- sock.recv_queue.unshift(queued);
4097
- }
4098
-
4099
- return res;
4100
- },
4101
- },
4102
- };
4103
-
4104
- var getSocketFromFD = (fd) => {
4105
- var socket = SOCKFS.getSocket(fd);
4106
- if (!socket) throw new FS.ErrnoError(8);
4107
- return socket;
4108
- };
4109
-
4110
- var Sockets = {
4111
- BUFFER_SIZE:10240,
4112
- MAX_BUFFER_SIZE:10485760,
4113
- nextFd:1,
4114
- fds:{
4115
- },
4116
- nextport:1,
4117
- maxport:65535,
4118
- peer:null,
4119
- connections:{
4120
- },
4121
- portmap:{
4122
- },
4123
- localAddr:4261412874,
4124
- addrPool:[33554442,50331658,67108874,83886090,100663306,117440522,134217738,150994954,167772170,184549386,201326602,218103818,234881034],
4125
- };
4126
-
4127
- var inetNtop4 = (addr) => {
4128
- return (addr & 0xff) + '.' + ((addr >> 8) & 0xff) + '.' + ((addr >> 16) & 0xff) + '.' + ((addr >> 24) & 0xff)
4129
- };
4130
-
4131
-
4132
- var inetNtop6 = (ints) => {
4133
- // ref: http://www.ietf.org/rfc/rfc2373.txt - section 2.5.4
4134
- // Format for IPv4 compatible and mapped 128-bit IPv6 Addresses
4135
- // 128-bits are split into eight 16-bit words
4136
- // stored in network byte order (big-endian)
4137
- // | 80 bits | 16 | 32 bits |
4138
- // +-----------------------------------------------------------------+
4139
- // | 10 bytes | 2 | 4 bytes |
4140
- // +--------------------------------------+--------------------------+
4141
- // + 5 words | 1 | 2 words |
4142
- // +--------------------------------------+--------------------------+
4143
- // |0000..............................0000|0000| IPv4 ADDRESS | (compatible)
4144
- // +--------------------------------------+----+---------------------+
4145
- // |0000..............................0000|FFFF| IPv4 ADDRESS | (mapped)
4146
- // +--------------------------------------+----+---------------------+
4147
- var str = "";
4148
- var word = 0;
4149
- var longest = 0;
4150
- var lastzero = 0;
4151
- var zstart = 0;
4152
- var len = 0;
4153
- var i = 0;
4154
- var parts = [
4155
- ints[0] & 0xffff,
4156
- (ints[0] >> 16),
4157
- ints[1] & 0xffff,
4158
- (ints[1] >> 16),
4159
- ints[2] & 0xffff,
4160
- (ints[2] >> 16),
4161
- ints[3] & 0xffff,
4162
- (ints[3] >> 16)
4163
- ];
4164
-
4165
- // Handle IPv4-compatible, IPv4-mapped, loopback and any/unspecified addresses
4166
-
4167
- var hasipv4 = true;
4168
- var v4part = "";
4169
- // check if the 10 high-order bytes are all zeros (first 5 words)
4170
- for (i = 0; i < 5; i++) {
4171
- if (parts[i] !== 0) { hasipv4 = false; break; }
4172
- }
4173
-
4174
- if (hasipv4) {
4175
- // low-order 32-bits store an IPv4 address (bytes 13 to 16) (last 2 words)
4176
- v4part = inetNtop4(parts[6] | (parts[7] << 16));
4177
- // IPv4-mapped IPv6 address if 16-bit value (bytes 11 and 12) == 0xFFFF (6th word)
4178
- if (parts[5] === -1) {
4179
- str = "::ffff:";
4180
- str += v4part;
4181
- return str;
4182
- }
4183
- // IPv4-compatible IPv6 address if 16-bit value (bytes 11 and 12) == 0x0000 (6th word)
4184
- if (parts[5] === 0) {
4185
- str = "::";
4186
- //special case IPv6 addresses
4187
- if (v4part === "0.0.0.0") v4part = ""; // any/unspecified address
4188
- if (v4part === "0.0.0.1") v4part = "1";// loopback address
4189
- str += v4part;
4190
- return str;
4191
- }
4192
- }
4193
-
4194
- // Handle all other IPv6 addresses
4195
-
4196
- // first run to find the longest contiguous zero words
4197
- for (word = 0; word < 8; word++) {
4198
- if (parts[word] === 0) {
4199
- if (word - lastzero > 1) {
4200
- len = 0;
4201
- }
4202
- lastzero = word;
4203
- len++;
4204
- }
4205
- if (len > longest) {
4206
- longest = len;
4207
- zstart = word - longest + 1;
4208
- }
4209
- }
4210
-
4211
- for (word = 0; word < 8; word++) {
4212
- if (longest > 1) {
4213
- // compress contiguous zeros - to produce "::"
4214
- if (parts[word] === 0 && word >= zstart && word < (zstart + longest) ) {
4215
- if (word === zstart) {
4216
- str += ":";
4217
- if (zstart === 0) str += ":"; //leading zeros case
4218
- }
4219
- continue;
4220
- }
4221
- }
4222
- // converts 16-bit words from big-endian to little-endian before converting to hex string
4223
- str += Number(_ntohs(parts[word] & 0xffff)).toString(16);
4224
- str += word < 7 ? ":" : "";
4225
- }
4226
- return str;
4227
- };
4228
-
4229
- var readSockaddr = (sa, salen) => {
4230
- // family / port offsets are common to both sockaddr_in and sockaddr_in6
4231
- var family = HEAP16[((sa)>>1)];
4232
- var port = _ntohs(HEAPU16[(((sa)+(2))>>1)]);
4233
- var addr;
4234
-
4235
- switch (family) {
4236
- case 2:
4237
- if (salen !== 16) {
4238
- return { errno: 28 };
4239
- }
4240
- addr = HEAP32[(((sa)+(4))>>2)];
4241
- addr = inetNtop4(addr);
4242
- break;
4243
- case 10:
4244
- if (salen !== 28) {
4245
- return { errno: 28 };
4246
- }
4247
- addr = [
4248
- HEAP32[(((sa)+(8))>>2)],
4249
- HEAP32[(((sa)+(12))>>2)],
4250
- HEAP32[(((sa)+(16))>>2)],
4251
- HEAP32[(((sa)+(20))>>2)]
4252
- ];
4253
- addr = inetNtop6(addr);
4254
- break;
4255
- default:
4256
- return { errno: 5 };
4257
- }
4258
-
4259
- return { family: family, addr: addr, port: port };
4260
- };
4261
-
4262
-
4263
- var inetPton4 = (str) => {
4264
- var b = str.split('.');
4265
- for (var i = 0; i < 4; i++) {
4266
- var tmp = Number(b[i]);
4267
- if (isNaN(tmp)) return null;
4268
- b[i] = tmp;
4269
- }
4270
- return (b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24)) >>> 0;
4271
- };
4272
-
4273
-
4274
- /** @suppress {checkTypes} */
4275
- var jstoi_q = (str) => parseInt(str);
4276
- var inetPton6 = (str) => {
4277
- var words;
4278
- var w, offset, z, i;
4279
- /* http://home.deds.nl/~aeron/regex/ */
4280
- var valid6regx = /^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i
4281
- var parts = [];
4282
- if (!valid6regx.test(str)) {
4283
- return null;
4284
- }
4285
- if (str === "::") {
4286
- return [0, 0, 0, 0, 0, 0, 0, 0];
4287
- }
4288
- // Z placeholder to keep track of zeros when splitting the string on ":"
4289
- if (str.startsWith("::")) {
4290
- str = str.replace("::", "Z:"); // leading zeros case
4291
- } else {
4292
- str = str.replace("::", ":Z:");
4293
- }
4294
-
4295
- if (str.indexOf(".") > 0) {
4296
- // parse IPv4 embedded stress
4297
- str = str.replace(new RegExp('[.]', 'g'), ":");
4298
- words = str.split(":");
4299
- words[words.length-4] = jstoi_q(words[words.length-4]) + jstoi_q(words[words.length-3])*256;
4300
- words[words.length-3] = jstoi_q(words[words.length-2]) + jstoi_q(words[words.length-1])*256;
4301
- words = words.slice(0, words.length-2);
4302
- } else {
4303
- words = str.split(":");
4304
- }
4305
-
4306
- offset = 0; z = 0;
4307
- for (w=0; w < words.length; w++) {
4308
- if (typeof words[w] == 'string') {
4309
- if (words[w] === 'Z') {
4310
- // compressed zeros - write appropriate number of zero words
4311
- for (z = 0; z < (8 - words.length+1); z++) {
4312
- parts[w+z] = 0;
4313
- }
4314
- offset = z-1;
4315
- } else {
4316
- // parse hex to field to 16-bit value and write it in network byte-order
4317
- parts[w+offset] = _htons(parseInt(words[w],16));
4318
- }
4319
- } else {
4320
- // parsed IPv4 words
4321
- parts[w+offset] = words[w];
4322
- }
4323
- }
4324
- return [
4325
- (parts[1] << 16) | parts[0],
4326
- (parts[3] << 16) | parts[2],
4327
- (parts[5] << 16) | parts[4],
4328
- (parts[7] << 16) | parts[6]
4329
- ];
4330
- };
4331
- var DNS = {
4332
- address_map:{
4333
- id:1,
4334
- addrs:{
4335
- },
4336
- names:{
4337
- },
4338
- },
4339
- lookup_name(name) {
4340
- // If the name is already a valid ipv4 / ipv6 address, don't generate a fake one.
4341
- var res = inetPton4(name);
4342
- if (res !== null) {
4343
- return name;
4344
- }
4345
- res = inetPton6(name);
4346
- if (res !== null) {
4347
- return name;
4348
- }
4349
-
4350
- // See if this name is already mapped.
4351
- var addr;
4352
-
4353
- if (DNS.address_map.addrs[name]) {
4354
- addr = DNS.address_map.addrs[name];
4355
- } else {
4356
- var id = DNS.address_map.id++;
4357
- assert(id < 65535, 'exceeded max address mappings of 65535');
4358
-
4359
- addr = '172.29.' + (id & 0xff) + '.' + (id & 0xff00);
4360
-
4361
- DNS.address_map.names[addr] = name;
4362
- DNS.address_map.addrs[name] = addr;
4363
- }
4364
-
4365
- return addr;
4366
- },
4367
- lookup_addr(addr) {
4368
- if (DNS.address_map.names[addr]) {
4369
- return DNS.address_map.names[addr];
4370
- }
4371
-
4372
- return null;
4373
- },
4374
- };
4375
- /** @param {boolean=} allowNull */
4376
- var getSocketAddress = (addrp, addrlen, allowNull) => {
4377
- if (allowNull && addrp === 0) return null;
4378
- var info = readSockaddr(addrp, addrlen);
4379
- if (info.errno) throw new FS.ErrnoError(info.errno);
4380
- info.addr = DNS.lookup_addr(info.addr) || info.addr;
4381
- return info;
4382
- };
4383
- function ___syscall_connect(fd, addr, addrlen, d1, d2, d3) {
4384
- try {
4385
-
4386
- var sock = getSocketFromFD(fd);
4387
- var info = getSocketAddress(addr, addrlen);
4388
- sock.sock_ops.connect(sock, info.addr, info.port);
4389
- return 0;
4390
- } catch (e) {
4391
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4392
- return -e.errno;
4393
- }
4394
- }
4395
-
4396
3449
  function ___syscall_faccessat(dirfd, path, amode, flags) {
4397
3450
  try {
4398
3451
 
@@ -4425,17 +3478,6 @@ function createWasm() {
4425
3478
  return 0; // your advice is important to us (but we can't use it)
4426
3479
  };
4427
3480
 
4428
- function ___syscall_fchmod(fd, mode) {
4429
- try {
4430
-
4431
- FS.fchmod(fd, mode);
4432
- return 0;
4433
- } catch (e) {
4434
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4435
- return -e.errno;
4436
- }
4437
- }
4438
-
4439
3481
  function ___syscall_fcntl64(fd, cmd, varargs) {
4440
3482
  SYSCALLS.varargs = varargs;
4441
3483
  try {
@@ -4722,23 +3764,6 @@ function createWasm() {
4722
3764
  }
4723
3765
  }
4724
3766
 
4725
- function ___syscall_mkdirat(dirfd, path, mode) {
4726
- try {
4727
-
4728
- path = SYSCALLS.getStr(path);
4729
- path = SYSCALLS.calculateAt(dirfd, path);
4730
- // remove a trailing slash, if one - /a/b/ has basename of '', but
4731
- // we want to create b in the context of this function
4732
- path = PATH.normalize(path);
4733
- if (path[path.length-1] === '/') path = path.substr(0, path.length-1);
4734
- FS.mkdir(path, mode, 0);
4735
- return 0;
4736
- } catch (e) {
4737
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4738
- return -e.errno;
4739
- }
4740
- }
4741
-
4742
3767
  function ___syscall_newfstatat(dirfd, path, buf, flags) {
4743
3768
  try {
4744
3769
 
@@ -4791,62 +3816,6 @@ function createWasm() {
4791
3816
  }
4792
3817
  }
4793
3818
 
4794
- function ___syscall_renameat(olddirfd, oldpath, newdirfd, newpath) {
4795
- try {
4796
-
4797
- oldpath = SYSCALLS.getStr(oldpath);
4798
- newpath = SYSCALLS.getStr(newpath);
4799
- oldpath = SYSCALLS.calculateAt(olddirfd, oldpath);
4800
- newpath = SYSCALLS.calculateAt(newdirfd, newpath);
4801
- FS.rename(oldpath, newpath);
4802
- return 0;
4803
- } catch (e) {
4804
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4805
- return -e.errno;
4806
- }
4807
- }
4808
-
4809
- function ___syscall_rmdir(path) {
4810
- try {
4811
-
4812
- path = SYSCALLS.getStr(path);
4813
- FS.rmdir(path);
4814
- return 0;
4815
- } catch (e) {
4816
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4817
- return -e.errno;
4818
- }
4819
- }
4820
-
4821
-
4822
- function ___syscall_sendto(fd, message, length, flags, addr, addr_len) {
4823
- try {
4824
-
4825
- var sock = getSocketFromFD(fd);
4826
- var dest = getSocketAddress(addr, addr_len, true);
4827
- if (!dest) {
4828
- // send, no address provided
4829
- return FS.write(sock.stream, HEAP8, message, length);
4830
- }
4831
- // sendto an address
4832
- return sock.sock_ops.sendmsg(sock, HEAP8, message, length, dest.addr, dest.port);
4833
- } catch (e) {
4834
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4835
- return -e.errno;
4836
- }
4837
- }
4838
-
4839
- function ___syscall_socket(domain, type, protocol) {
4840
- try {
4841
-
4842
- var sock = SOCKFS.createSocket(domain, type, protocol);
4843
- return sock.stream.fd;
4844
- } catch (e) {
4845
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4846
- return -e.errno;
4847
- }
4848
- }
4849
-
4850
3819
  function ___syscall_stat64(path, buf) {
4851
3820
  try {
4852
3821
 
@@ -4858,19 +3827,6 @@ function createWasm() {
4858
3827
  }
4859
3828
  }
4860
3829
 
4861
- function ___syscall_symlink(target, linkpath) {
4862
- try {
4863
-
4864
- target = SYSCALLS.getStr(target);
4865
- linkpath = SYSCALLS.getStr(linkpath);
4866
- FS.symlink(target, linkpath);
4867
- return 0;
4868
- } catch (e) {
4869
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4870
- return -e.errno;
4871
- }
4872
- }
4873
-
4874
3830
  function ___syscall_unlinkat(dirfd, path, flags) {
4875
3831
  try {
4876
3832
 
@@ -4890,56 +3846,9 @@ function createWasm() {
4890
3846
  }
4891
3847
  }
4892
3848
 
4893
- var readI53FromI64 = (ptr) => {
4894
- return HEAPU32[((ptr)>>2)] + HEAP32[(((ptr)+(4))>>2)] * 4294967296;
4895
- };
4896
-
4897
- function ___syscall_utimensat(dirfd, path, times, flags) {
4898
- try {
4899
-
4900
- path = SYSCALLS.getStr(path);
4901
- path = SYSCALLS.calculateAt(dirfd, path, true);
4902
- if (!times) {
4903
- var atime = Date.now();
4904
- var mtime = atime;
4905
- } else {
4906
- var seconds = readI53FromI64(times);
4907
- var nanoseconds = HEAP32[(((times)+(8))>>2)];
4908
- atime = (seconds*1000) + (nanoseconds/(1000*1000));
4909
- times += 16;
4910
- seconds = readI53FromI64(times);
4911
- nanoseconds = HEAP32[(((times)+(8))>>2)];
4912
- mtime = (seconds*1000) + (nanoseconds/(1000*1000));
4913
- }
4914
- FS.utime(path, atime, mtime);
4915
- return 0;
4916
- } catch (e) {
4917
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
4918
- return -e.errno;
4919
- }
4920
- }
4921
-
4922
3849
  var nowIsMonotonic = 1;
4923
3850
  var __emscripten_get_now_is_monotonic = () => nowIsMonotonic;
4924
3851
 
4925
- function __gmtime_js(time, tmPtr) {
4926
- time = bigintToI53Checked(time);
4927
-
4928
-
4929
- var date = new Date(time * 1000);
4930
- HEAP32[((tmPtr)>>2)] = date.getUTCSeconds();
4931
- HEAP32[(((tmPtr)+(4))>>2)] = date.getUTCMinutes();
4932
- HEAP32[(((tmPtr)+(8))>>2)] = date.getUTCHours();
4933
- HEAP32[(((tmPtr)+(12))>>2)] = date.getUTCDate();
4934
- HEAP32[(((tmPtr)+(16))>>2)] = date.getUTCMonth();
4935
- HEAP32[(((tmPtr)+(20))>>2)] = date.getUTCFullYear()-1900;
4936
- HEAP32[(((tmPtr)+(24))>>2)] = date.getUTCDay();
4937
- var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
4938
- var yday = ((date.getTime() - start) / (1000 * 60 * 60 * 24))|0;
4939
- HEAP32[(((tmPtr)+(28))>>2)] = yday;
4940
- ;
4941
- }
4942
-
4943
3852
  var isLeapYear = (year) => year%4 === 0 && (year%100 !== 0 || year%400 === 0);
4944
3853
 
4945
3854
  var MONTH_DAYS_LEAP_CUMULATIVE = [0,31,60,91,121,152,182,213,244,274,305,335];
@@ -5005,23 +3914,6 @@ function createWasm() {
5005
3914
  }
5006
3915
 
5007
3916
 
5008
- function __msync_js(addr, len, prot, flags, fd, offset) {
5009
- offset = bigintToI53Checked(offset);
5010
-
5011
-
5012
- try {
5013
-
5014
- if (isNaN(offset)) return 61;
5015
- SYSCALLS.doMsync(addr, SYSCALLS.getStreamFromFD(fd), len, flags, offset);
5016
- return 0;
5017
- } catch (e) {
5018
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
5019
- return -e.errno;
5020
- }
5021
- ;
5022
- }
5023
-
5024
-
5025
3917
  function __munmap_js(addr, len, prot, flags, fd, offset) {
5026
3918
  offset = bigintToI53Checked(offset);
5027
3919
 
@@ -5288,32 +4180,6 @@ function createWasm() {
5288
4180
  }
5289
4181
  }
5290
4182
 
5291
- function _fd_fdstat_get(fd, pbuf) {
5292
- try {
5293
-
5294
- var rightsBase = 0;
5295
- var rightsInheriting = 0;
5296
- var flags = 0;
5297
- {
5298
- var stream = SYSCALLS.getStreamFromFD(fd);
5299
- // All character devices are terminals (other things a Linux system would
5300
- // assume is a character device, like the mouse, we have special APIs for).
5301
- var type = stream.tty ? 2 :
5302
- FS.isDir(stream.mode) ? 3 :
5303
- FS.isLink(stream.mode) ? 7 :
5304
- 4;
5305
- }
5306
- HEAP8[pbuf] = type;
5307
- HEAP16[(((pbuf)+(2))>>1)] = flags;
5308
- HEAP64[(((pbuf)+(8))>>3)] = BigInt(rightsBase);
5309
- HEAP64[(((pbuf)+(16))>>3)] = BigInt(rightsInheriting);
5310
- return 0;
5311
- } catch (e) {
5312
- if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e;
5313
- return e.errno;
5314
- }
5315
- }
5316
-
5317
4183
  /** @param {number=} offset */
5318
4184
  var doReadv = (stream, iov, iovcnt, offset) => {
5319
4185
  var ret = 0;
@@ -6241,23 +5107,15 @@ function createWasm() {
6241
5107
 
6242
5108
  FS.createPreloadedFile = FS_createPreloadedFile;
6243
5109
  FS.staticInit();Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPath"] = FS.createPath;Module["FS_createDataFile"] = FS.createDataFile;Module["FS_createPreloadedFile"] = FS.createPreloadedFile;Module["FS_unlink"] = FS.unlink;Module["FS_createLazyFile"] = FS.createLazyFile;Module["FS_createDevice"] = FS.createDevice;;
6244
- DOTNET.setup({ wasmEnableSIMD: true,wasmEnableEH: true,enableAotProfiler: false, enableDevToolsProfiler: false, enableLogProfiler: false, enableEventPipe: false, runAOTCompilation: true, wasmEnableThreads: false, gitHash: "95017c711e6afc1085133d440e42b4bd78155701", });;
5110
+ DOTNET.setup({ wasmEnableSIMD: true,wasmEnableEH: true,enableAotProfiler: false, enableDevToolsProfiler: false, enableLogProfiler: false, enableEventPipe: false, runAOTCompilation: false, wasmEnableThreads: false, gitHash: "95017c711e6afc1085133d440e42b4bd78155701", });;
6245
5111
  var wasmImports = {
6246
5112
  /** @export */
6247
5113
  __assert_fail: ___assert_fail,
6248
5114
  /** @export */
6249
- __syscall_chdir: ___syscall_chdir,
6250
- /** @export */
6251
- __syscall_chmod: ___syscall_chmod,
6252
- /** @export */
6253
- __syscall_connect: ___syscall_connect,
6254
- /** @export */
6255
5115
  __syscall_faccessat: ___syscall_faccessat,
6256
5116
  /** @export */
6257
5117
  __syscall_fadvise64: ___syscall_fadvise64,
6258
5118
  /** @export */
6259
- __syscall_fchmod: ___syscall_fchmod,
6260
- /** @export */
6261
5119
  __syscall_fcntl64: ___syscall_fcntl64,
6262
5120
  /** @export */
6263
5121
  __syscall_fstat64: ___syscall_fstat64,
@@ -6274,40 +5132,22 @@ var wasmImports = {
6274
5132
  /** @export */
6275
5133
  __syscall_lstat64: ___syscall_lstat64,
6276
5134
  /** @export */
6277
- __syscall_mkdirat: ___syscall_mkdirat,
6278
- /** @export */
6279
5135
  __syscall_newfstatat: ___syscall_newfstatat,
6280
5136
  /** @export */
6281
5137
  __syscall_openat: ___syscall_openat,
6282
5138
  /** @export */
6283
5139
  __syscall_readlinkat: ___syscall_readlinkat,
6284
5140
  /** @export */
6285
- __syscall_renameat: ___syscall_renameat,
6286
- /** @export */
6287
- __syscall_rmdir: ___syscall_rmdir,
6288
- /** @export */
6289
- __syscall_sendto: ___syscall_sendto,
6290
- /** @export */
6291
- __syscall_socket: ___syscall_socket,
6292
- /** @export */
6293
5141
  __syscall_stat64: ___syscall_stat64,
6294
5142
  /** @export */
6295
- __syscall_symlink: ___syscall_symlink,
6296
- /** @export */
6297
5143
  __syscall_unlinkat: ___syscall_unlinkat,
6298
5144
  /** @export */
6299
- __syscall_utimensat: ___syscall_utimensat,
6300
- /** @export */
6301
5145
  _emscripten_get_now_is_monotonic: __emscripten_get_now_is_monotonic,
6302
5146
  /** @export */
6303
- _gmtime_js: __gmtime_js,
6304
- /** @export */
6305
5147
  _localtime_js: __localtime_js,
6306
5148
  /** @export */
6307
5149
  _mmap_js: __mmap_js,
6308
5150
  /** @export */
6309
- _msync_js: __msync_js,
6310
- /** @export */
6311
5151
  _munmap_js: __munmap_js,
6312
5152
  /** @export */
6313
5153
  _tzset_js: __tzset_js,
@@ -6334,8 +5174,6 @@ var wasmImports = {
6334
5174
  /** @export */
6335
5175
  fd_close: _fd_close,
6336
5176
  /** @export */
6337
- fd_fdstat_get: _fd_fdstat_get,
6338
- /** @export */
6339
5177
  fd_pread: _fd_pread,
6340
5178
  /** @export */
6341
5179
  fd_pwrite: _fd_pwrite,
@@ -6571,11 +5409,10 @@ var _mono_wasm_gc_unlock = Module['_mono_wasm_gc_unlock'] = () => (_mono_wasm_gc
6571
5409
  var _mono_print_method_from_ip = Module['_mono_print_method_from_ip'] = (a0) => (_mono_print_method_from_ip = Module['_mono_print_method_from_ip'] = wasmExports['mono_print_method_from_ip'])(a0);
6572
5410
  var _mono_wasm_execute_timer = Module['_mono_wasm_execute_timer'] = () => (_mono_wasm_execute_timer = Module['_mono_wasm_execute_timer'] = wasmExports['mono_wasm_execute_timer'])();
6573
5411
  var _mono_wasm_load_icu_data = Module['_mono_wasm_load_icu_data'] = (a0) => (_mono_wasm_load_icu_data = Module['_mono_wasm_load_icu_data'] = wasmExports['mono_wasm_load_icu_data'])(a0);
6574
- var _ntohs = Module['_ntohs'] = (a0) => (_ntohs = Module['_ntohs'] = wasmExports['ntohs'])(a0);
6575
- var _htons = Module['_htons'] = (a0) => (_htons = Module['_htons'] = wasmExports['htons'])(a0);
6576
5412
  var ___funcs_on_exit = () => (___funcs_on_exit = wasmExports['__funcs_on_exit'])();
6577
- var _htonl = (a0) => (_htonl = wasmExports['htonl'])(a0);
5413
+ var _htons = Module['_htons'] = (a0) => (_htons = Module['_htons'] = wasmExports['htons'])(a0);
6578
5414
  var _emscripten_builtin_memalign = (a0, a1) => (_emscripten_builtin_memalign = wasmExports['emscripten_builtin_memalign'])(a0, a1);
5415
+ var _ntohs = Module['_ntohs'] = (a0) => (_ntohs = Module['_ntohs'] = wasmExports['ntohs'])(a0);
6579
5416
  var _memalign = Module['_memalign'] = (a0, a1) => (_memalign = Module['_memalign'] = wasmExports['memalign'])(a0, a1);
6580
5417
  var ___trap = () => (___trap = wasmExports['__trap'])();
6581
5418
  var stackSave = Module['stackSave'] = () => (stackSave = Module['stackSave'] = wasmExports['stackSave'])();