simplex-chat 0.3.0 → 6.5.0-beta.10

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 (116) hide show
  1. package/README.md +107 -22
  2. package/binding.gyp +50 -0
  3. package/cpp/simplex.cc +426 -0
  4. package/cpp/simplex.h +46 -0
  5. package/dist/api.d.ts +423 -0
  6. package/dist/api.js +857 -0
  7. package/dist/api.js.map +1 -0
  8. package/dist/bot.d.ts +29 -0
  9. package/dist/bot.js +189 -0
  10. package/dist/bot.js.map +1 -0
  11. package/dist/core.d.ts +128 -0
  12. package/dist/core.js +121 -0
  13. package/dist/core.js.map +1 -0
  14. package/dist/index.d.ts +19 -2
  15. package/dist/index.js +20 -4
  16. package/dist/index.js.map +1 -1
  17. package/dist/simplex.d.ts +10 -0
  18. package/dist/simplex.js +1 -0
  19. package/dist/util.d.ts +15 -0
  20. package/dist/util.js +91 -0
  21. package/dist/util.js.map +1 -0
  22. package/docs/Namespace.api.md +33 -0
  23. package/docs/Namespace.bot.md +23 -0
  24. package/docs/Namespace.core.md +48 -0
  25. package/docs/Namespace.util.md +25 -0
  26. package/docs/README.md +12 -0
  27. package/docs/api.Class.ChatApi.md +1752 -0
  28. package/docs/api.Class.ChatCommandError.md +205 -0
  29. package/docs/api.Enumeration.ConnReqType.md +27 -0
  30. package/docs/api.Interface.BotAddressSettings.md +60 -0
  31. package/docs/api.TypeAlias.DbConfig.md +64 -0
  32. package/docs/api.TypeAlias.EventSubscriberFunc.md +27 -0
  33. package/docs/api.TypeAlias.EventSubscribers.md +11 -0
  34. package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
  35. package/docs/bot.Function.run.md +21 -0
  36. package/docs/bot.Interface.BotConfig.md +75 -0
  37. package/docs/bot.Interface.BotOptions.md +81 -0
  38. package/docs/bot.TypeAlias.BotDbOpts.md +17 -0
  39. package/docs/core.Class.ChatAPIError.md +205 -0
  40. package/docs/core.Class.ChatInitError.md +205 -0
  41. package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
  42. package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
  43. package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
  44. package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
  45. package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
  46. package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
  47. package/docs/core.Function.chatCloseStore.md +23 -0
  48. package/docs/core.Function.chatDecryptFile.md +31 -0
  49. package/docs/core.Function.chatEncryptFile.md +31 -0
  50. package/docs/core.Function.chatMigrateInit.md +31 -0
  51. package/docs/core.Function.chatReadFile.md +27 -0
  52. package/docs/core.Function.chatRecvMsgWait.md +27 -0
  53. package/docs/core.Function.chatSendCmd.md +27 -0
  54. package/docs/core.Function.chatWriteFile.md +31 -0
  55. package/docs/core.Interface.APIResult.md +31 -0
  56. package/docs/core.Interface.CryptoArgs.md +27 -0
  57. package/docs/core.Interface.UpMigration.md +25 -0
  58. package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
  59. package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
  60. package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
  61. package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
  62. package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
  63. package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
  64. package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
  65. package/docs/core.Namespace.DBMigrationError.md +18 -0
  66. package/docs/core.Namespace.MTRError.md +16 -0
  67. package/docs/core.Namespace.MigrationError.md +17 -0
  68. package/docs/core.TypeAlias.DBMigrationError.md +11 -0
  69. package/docs/core.TypeAlias.MTRError.md +11 -0
  70. package/docs/core.TypeAlias.MigrationError.md +11 -0
  71. package/docs/util.Function.botAddressSettings.md +21 -0
  72. package/docs/util.Function.chatInfoName.md +21 -0
  73. package/docs/util.Function.chatInfoRef.md +21 -0
  74. package/docs/util.Function.ciBotCommand.md +21 -0
  75. package/docs/util.Function.ciContentText.md +21 -0
  76. package/docs/util.Function.contactAddressStr.md +21 -0
  77. package/docs/util.Function.fromLocalProfile.md +21 -0
  78. package/docs/util.Function.reactionText.md +21 -0
  79. package/docs/util.Function.senderName.md +25 -0
  80. package/docs/util.Interface.BotCommand.md +25 -0
  81. package/examples/squaring-bot-pg.js +21 -0
  82. package/examples/squaring-bot-readme.js +17 -0
  83. package/examples/squaring-bot.ts +42 -0
  84. package/package.json +36 -48
  85. package/src/api.ts +939 -0
  86. package/src/bot.ts +214 -0
  87. package/src/core.ts +210 -0
  88. package/src/download-libs.js +239 -0
  89. package/src/index.ts +22 -0
  90. package/src/simplex.d.ts +10 -0
  91. package/src/simplex.js +1 -0
  92. package/src/util.ts +92 -0
  93. package/tsconfig.json +23 -0
  94. package/dist/client.d.ts +0 -61
  95. package/dist/client.js +0 -271
  96. package/dist/client.js.map +0 -1
  97. package/dist/command.d.ts +0 -408
  98. package/dist/command.js +0 -184
  99. package/dist/command.js.map +0 -1
  100. package/dist/index-web.d.ts +0 -1
  101. package/dist/index-web.js +0 -6
  102. package/dist/index-web.js.map +0 -1
  103. package/dist/index.bundle.js +0 -11
  104. package/dist/queue.d.ts +0 -24
  105. package/dist/queue.js +0 -77
  106. package/dist/queue.js.map +0 -1
  107. package/dist/response.d.ts +0 -754
  108. package/dist/response.js +0 -21
  109. package/dist/response.js.map +0 -1
  110. package/dist/test.html +0 -7
  111. package/dist/transport.d.ts +0 -54
  112. package/dist/transport.js +0 -131
  113. package/dist/transport.js.map +0 -1
  114. package/dist/websocket.d.ts +0 -8
  115. package/dist/websocket.js +0 -4
  116. package/dist/websocket.js.map +0 -1
package/dist/queue.js DELETED
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ABQueue = exports.ABQueueError = void 0;
4
- class Sem {
5
- constructor(permits) {
6
- this.permits = permits;
7
- this.promises = [];
8
- }
9
- signal() {
10
- this.permits += 1;
11
- if (this.promises.length > 0)
12
- this.promises.pop()();
13
- }
14
- async wait() {
15
- if (this.permits === 0 || this.promises.length > 0) {
16
- await new Promise((r) => this.promises.unshift(r));
17
- }
18
- this.permits -= 1;
19
- }
20
- }
21
- const queueClosed = Symbol();
22
- class ABQueueError extends Error {
23
- }
24
- exports.ABQueueError = ABQueueError;
25
- class ABQueue {
26
- constructor(maxSize) {
27
- this.maxSize = maxSize;
28
- this.queue = [];
29
- this.enqClosed = false;
30
- this.deqClosed = false;
31
- this.enq = new Sem(0);
32
- this.deq = new Sem(maxSize);
33
- }
34
- [Symbol.asyncIterator]() {
35
- return this;
36
- }
37
- enqueue(x) {
38
- return this._enqueue(x);
39
- }
40
- async _enqueue(x) {
41
- if (this.enqClosed)
42
- throw new ABQueueError("enqueue: queue closed");
43
- await this.deq.wait();
44
- this.queue.push(x);
45
- this.enq.signal();
46
- }
47
- async dequeue() {
48
- if (this.deqClosed)
49
- throw new ABQueueError("dequeue: queue closed");
50
- this.deq.signal();
51
- await this.enq.wait();
52
- const x = this.queue.shift();
53
- if (x === queueClosed) {
54
- this.deqClosed = true;
55
- throw new ABQueueError("dequeue: queue closed");
56
- }
57
- return x;
58
- }
59
- async close() {
60
- await this._enqueue(queueClosed);
61
- this.enqClosed = true;
62
- }
63
- async next() {
64
- if (this.deqClosed)
65
- return { done: true };
66
- try {
67
- return { value: await this.dequeue() };
68
- }
69
- catch (e) {
70
- if (e instanceof ABQueueError)
71
- return { done: true };
72
- throw e;
73
- }
74
- }
75
- }
76
- exports.ABQueue = ABQueue;
77
- //# sourceMappingURL=queue.js.map
package/dist/queue.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":";;;AAAA,MAAM,GAAG;IAGP,YAAoB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QAFlB,aAAQ,GAA6B,EAAE,CAAA;IAElB,CAAC;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