simplex-chat 0.2.1 → 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.
- package/README.md +108 -21
- package/binding.gyp +50 -0
- package/cpp/simplex.cc +426 -0
- package/cpp/simplex.h +46 -0
- package/dist/api.d.ts +423 -0
- package/dist/api.js +857 -0
- package/dist/api.js.map +1 -0
- package/dist/bot.d.ts +29 -0
- package/dist/bot.js +189 -0
- package/dist/bot.js.map +1 -0
- package/dist/core.d.ts +128 -0
- package/dist/core.js +121 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/simplex.d.ts +10 -0
- package/dist/simplex.js +1 -0
- package/dist/util.d.ts +15 -0
- package/dist/util.js +91 -0
- package/dist/util.js.map +1 -0
- package/docs/Namespace.api.md +33 -0
- package/docs/Namespace.bot.md +23 -0
- package/docs/Namespace.core.md +48 -0
- package/docs/Namespace.util.md +25 -0
- package/docs/README.md +12 -0
- package/docs/api.Class.ChatApi.md +1752 -0
- package/docs/api.Class.ChatCommandError.md +205 -0
- package/docs/api.Enumeration.ConnReqType.md +27 -0
- package/docs/api.Interface.BotAddressSettings.md +60 -0
- package/docs/api.TypeAlias.DbConfig.md +64 -0
- package/docs/api.TypeAlias.EventSubscriberFunc.md +27 -0
- package/docs/api.TypeAlias.EventSubscribers.md +11 -0
- package/docs/api.Variable.defaultBotAddressSettings.md +11 -0
- package/docs/bot.Function.run.md +21 -0
- package/docs/bot.Interface.BotConfig.md +75 -0
- package/docs/bot.Interface.BotOptions.md +81 -0
- package/docs/bot.TypeAlias.BotDbOpts.md +17 -0
- package/docs/core.Class.ChatAPIError.md +205 -0
- package/docs/core.Class.ChatInitError.md +205 -0
- package/docs/core.DBMigrationError.Interface.ErrorMigration.md +41 -0
- package/docs/core.DBMigrationError.Interface.ErrorNotADatabase.md +33 -0
- package/docs/core.DBMigrationError.Interface.ErrorSQL.md +41 -0
- package/docs/core.DBMigrationError.Interface.InvalidConfirmation.md +25 -0
- package/docs/core.DBMigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Enumeration.MigrationConfirmation.md +43 -0
- package/docs/core.Function.chatCloseStore.md +23 -0
- package/docs/core.Function.chatDecryptFile.md +31 -0
- package/docs/core.Function.chatEncryptFile.md +31 -0
- package/docs/core.Function.chatMigrateInit.md +31 -0
- package/docs/core.Function.chatReadFile.md +27 -0
- package/docs/core.Function.chatRecvMsgWait.md +27 -0
- package/docs/core.Function.chatSendCmd.md +27 -0
- package/docs/core.Function.chatWriteFile.md +31 -0
- package/docs/core.Interface.APIResult.md +31 -0
- package/docs/core.Interface.CryptoArgs.md +27 -0
- package/docs/core.Interface.UpMigration.md +25 -0
- package/docs/core.MTRError.Interface.MTREDifferent.md +33 -0
- package/docs/core.MTRError.Interface.MTRENoDown.md +33 -0
- package/docs/core.MTRError.TypeAlias.Tag.md +11 -0
- package/docs/core.MigrationError.Interface.MEDowngrade.md +33 -0
- package/docs/core.MigrationError.Interface.MEUpgrade.md +33 -0
- package/docs/core.MigrationError.Interface.MigrationError.md +33 -0
- package/docs/core.MigrationError.TypeAlias.Tag.md +11 -0
- package/docs/core.Namespace.DBMigrationError.md +18 -0
- package/docs/core.Namespace.MTRError.md +16 -0
- package/docs/core.Namespace.MigrationError.md +17 -0
- package/docs/core.TypeAlias.DBMigrationError.md +11 -0
- package/docs/core.TypeAlias.MTRError.md +11 -0
- package/docs/core.TypeAlias.MigrationError.md +11 -0
- package/docs/util.Function.botAddressSettings.md +21 -0
- package/docs/util.Function.chatInfoName.md +21 -0
- package/docs/util.Function.chatInfoRef.md +21 -0
- package/docs/util.Function.ciBotCommand.md +21 -0
- package/docs/util.Function.ciContentText.md +21 -0
- package/docs/util.Function.contactAddressStr.md +21 -0
- package/docs/util.Function.fromLocalProfile.md +21 -0
- package/docs/util.Function.reactionText.md +21 -0
- package/docs/util.Function.senderName.md +25 -0
- package/docs/util.Interface.BotCommand.md +25 -0
- package/examples/squaring-bot-pg.js +21 -0
- package/examples/squaring-bot-readme.js +17 -0
- package/examples/squaring-bot.ts +42 -0
- package/package.json +34 -37
- package/src/api.ts +939 -0
- package/src/bot.ts +214 -0
- package/src/core.ts +210 -0
- package/src/download-libs.js +239 -0
- package/src/index.ts +22 -0
- package/src/simplex.d.ts +10 -0
- package/src/simplex.js +1 -0
- package/src/util.ts +92 -0
- package/tsconfig.json +23 -0
- package/dist/client.d.ts +0 -76
- package/dist/client.js +0 -329
- package/dist/client.js.map +0 -1
- package/dist/command.d.ts +0 -412
- package/dist/command.js +0 -186
- package/dist/command.js.map +0 -1
- package/dist/index-web.d.ts +0 -1
- package/dist/index-web.js +0 -6
- package/dist/index-web.js.map +0 -1
- package/dist/index.bundle.js +0 -11
- package/dist/queue.d.ts +0 -24
- package/dist/queue.js +0 -77
- package/dist/queue.js.map +0 -1
- package/dist/response.d.ts +0 -755
- package/dist/response.js +0 -21
- package/dist/response.js.map +0 -1
- package/dist/test.html +0 -7
- package/dist/transport.d.ts +0 -51
- package/dist/transport.js +0 -131
- package/dist/transport.js.map +0 -1
- package/dist/websocket.d.ts +0 -8
- package/dist/websocket.js +0 -4
- 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;IAEvC,MAAM;QACJ,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;QACjB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAiB,EAAE,CAAA;IACrE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,OAAO,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;YAClD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;SACnD;QACD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;IACnB,CAAC;CACF;AAID,MAAM,WAAW,GAAG,MAAM,EAAE,CAAA;AAI5B,MAAa,YAAa,SAAQ,KAAK;CAAG;AAA1C,oCAA0C;AAE1C,MAAa,OAAO;IAOlB,YAAqB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QANnB,UAAK,GAAmB,EAAE,CAAA;QAGnC,cAAS,GAAG,KAAK,CAAA;QACjB,cAAS,GAAG,KAAK,CAAA;QAGvB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAA;QACrB,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,C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