@minip2p/react-native 0.7.3 → 0.7.5
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 +1 -1
- package/android/CMakeLists.txt +1 -0
- package/android/src/main/jniLibs/arm64-v8a/libminip2p_ffi.so +0 -0
- package/android/src/main/jniLibs/x86_64/libminip2p_ffi.so +0 -0
- package/build/Minip2pFfi.xcframework/Info.plist +4 -4
- package/build/Minip2pFfi.xcframework/ios-arm64/libminip2p_ffi.a +2 -2
- package/build/Minip2pFfi.xcframework/ios-arm64-simulator/libminip2p_ffi.a +2 -2
- package/cpp/generated/minip2p_ffi.cpp +45 -3
- package/cpp/generated/minip2p_ffi.hpp +2 -0
- package/cpp/generated/minip2p_ffi_core.cpp +1999 -0
- package/cpp/generated/minip2p_ffi_core.hpp +51 -0
- package/cpp/react-native-minip2p.cpp +2 -0
- package/lib/module/adapter.js +78 -64
- package/lib/module/adapter.js.map +1 -1
- package/lib/module/generated/minip2p_ffi-ffi.js.map +1 -1
- package/lib/module/generated/minip2p_ffi.js +68 -3287
- package/lib/module/generated/minip2p_ffi.js.map +1 -1
- package/lib/module/generated/minip2p_ffi_core-ffi.js +20 -0
- package/lib/module/generated/minip2p_ffi_core-ffi.js.map +1 -0
- package/lib/module/generated/minip2p_ffi_core.js +3441 -0
- package/lib/module/generated/minip2p_ffi_core.js.map +1 -0
- package/lib/module/low-level.js +1 -0
- package/lib/module/low-level.js.map +1 -1
- package/lib/module/native.js +5 -1
- package/lib/module/native.js.map +1 -1
- package/lib/typescript/src/adapter.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi-ffi.d.ts +3 -1
- package/lib/typescript/src/generated/minip2p_ffi-ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi.d.ts +24 -3396
- package/lib/typescript/src/generated/minip2p_ffi.d.ts.map +1 -1
- package/lib/typescript/src/generated/minip2p_ffi_core-ffi.d.ts +67 -0
- package/lib/typescript/src/generated/minip2p_ffi_core-ffi.d.ts.map +1 -0
- package/lib/typescript/src/generated/minip2p_ffi_core.d.ts +3522 -0
- package/lib/typescript/src/generated/minip2p_ffi_core.d.ts.map +1 -0
- package/lib/typescript/src/low-level.d.ts +1 -0
- package/lib/typescript/src/low-level.d.ts.map +1 -1
- package/lib/typescript/src/native.d.ts +3 -0
- package/lib/typescript/src/native.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/adapter.ts +107 -71
- package/src/generated/minip2p_ffi-ffi.ts +3 -1
- package/src/generated/minip2p_ffi.ts +77 -3864
- package/src/generated/minip2p_ffi_core-ffi.ts +97 -0
- package/src/generated/minip2p_ffi_core.ts +4049 -0
- package/src/low-level.ts +1 -0
- package/src/native.tsx +4 -0
- package/lib/module/event-drain.js +0 -71
- package/lib/module/event-drain.js.map +0 -1
- package/lib/typescript/src/event-drain.d.ts +0 -10
- package/lib/typescript/src/event-drain.d.ts.map +0 -1
- package/src/event-drain.ts +0 -80
package/src/low-level.ts
CHANGED
package/src/native.tsx
CHANGED
|
@@ -12,11 +12,13 @@ if (!rustInstalled) {
|
|
|
12
12
|
|
|
13
13
|
// Export the generated bindings to the app.
|
|
14
14
|
export * from './generated/minip2p_ffi';
|
|
15
|
+
export * from './generated/minip2p_ffi_core';
|
|
15
16
|
|
|
16
17
|
// Now import the bindings so we can:
|
|
17
18
|
// - intialize them
|
|
18
19
|
// - export them as namespaced objects as the default export.
|
|
19
20
|
import * as minip2p_ffi from './generated/minip2p_ffi';
|
|
21
|
+
import * as minip2p_ffi_core from './generated/minip2p_ffi_core';
|
|
20
22
|
|
|
21
23
|
// Initialize the generated bindings: mostly checksums, but also callbacks.
|
|
22
24
|
// - the boolean flag ensures this loads exactly once, even if the JS code
|
|
@@ -24,6 +26,7 @@ import * as minip2p_ffi from './generated/minip2p_ffi';
|
|
|
24
26
|
let initialized = false;
|
|
25
27
|
if (!initialized) {
|
|
26
28
|
minip2p_ffi.default.initialize();
|
|
29
|
+
minip2p_ffi_core.default.initialize();
|
|
27
30
|
initialized = true;
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -37,4 +40,5 @@ export async function uniffiInitAsync() {
|
|
|
37
40
|
// Export the crates as individually namespaced objects.
|
|
38
41
|
export default {
|
|
39
42
|
minip2p_ffi,
|
|
43
|
+
minip2p_ffi_core,
|
|
40
44
|
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/* oxlint-disable no-await-in-loop, promise/avoid-new -- Each bounded batch intentionally yields one event-loop turn before the next synchronous native drain. */
|
|
4
|
-
|
|
5
|
-
const DEFAULT_BATCH_LIMIT = 256;
|
|
6
|
-
const scheduleOnNextTurn = task => {
|
|
7
|
-
setTimeout(task, 0);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/** Coalesces native doorbells and drains bounded event batches off the callback stack. */
|
|
11
|
-
export class EventDrain {
|
|
12
|
-
#drain;
|
|
13
|
-
#deliver;
|
|
14
|
-
#limit;
|
|
15
|
-
#schedule;
|
|
16
|
-
#pending = false;
|
|
17
|
-
#running = false;
|
|
18
|
-
#stopped = false;
|
|
19
|
-
constructor(drain, deliver, limit = DEFAULT_BATCH_LIMIT, schedule = scheduleOnNextTurn) {
|
|
20
|
-
this.#drain = drain;
|
|
21
|
-
this.#deliver = deliver;
|
|
22
|
-
this.#limit = limit;
|
|
23
|
-
this.#schedule = schedule;
|
|
24
|
-
}
|
|
25
|
-
ring() {
|
|
26
|
-
if (this.#stopped) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.#pending = true;
|
|
30
|
-
if (!this.#running) {
|
|
31
|
-
this.#running = true;
|
|
32
|
-
this.#schedule(() => {
|
|
33
|
-
void this.#run();
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
stop() {
|
|
38
|
-
this.#stopped = true;
|
|
39
|
-
this.#pending = false;
|
|
40
|
-
}
|
|
41
|
-
async #run() {
|
|
42
|
-
try {
|
|
43
|
-
while (!this.#stopped && this.#pending) {
|
|
44
|
-
this.#pending = false;
|
|
45
|
-
let batch = this.#drain(this.#limit);
|
|
46
|
-
while (!this.#stopped && batch.length > 0) {
|
|
47
|
-
for (const event of batch) {
|
|
48
|
-
try {
|
|
49
|
-
this.#deliver(event);
|
|
50
|
-
} catch {
|
|
51
|
-
// Application callbacks cannot break native event delivery.
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
await new Promise(resolve => {
|
|
55
|
-
this.#schedule(resolve);
|
|
56
|
-
});
|
|
57
|
-
if (this.#stopped) {
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
batch = this.#drain(this.#limit);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
} finally {
|
|
64
|
-
this.#running = false;
|
|
65
|
-
if (this.#pending && !this.#stopped) {
|
|
66
|
-
this.ring();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=event-drain.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DEFAULT_BATCH_LIMIT","scheduleOnNextTurn","task","setTimeout","EventDrain","drain","deliver","limit","schedule","pending","running","stopped","constructor","ring","run","stop","#run","batch","length","event","Promise","resolve"],"sourceRoot":"../../src","sources":["event-drain.ts"],"mappings":";;AAAA;;AAEA,MAAMA,mBAAmB,GAAG,GAAG;AAI/B,MAAMC,kBAA6B,GAAIC,IAAI,IAAK;EAC9CC,UAAU,CAACD,IAAI,EAAE,CAAC,CAAC;AACrB,CAAC;;AAED;AACA,OAAO,MAAME,UAAU,CAAQ;EACpB,CAACC,KAAK;EACN,CAACC,OAAO;EACR,CAACC,KAAK;EACN,CAACC,QAAQ;EAClB,CAACC,OAAO,GAAG,KAAK;EAChB,CAACC,OAAO,GAAG,KAAK;EAChB,CAACC,OAAO,GAAG,KAAK;EAEhBC,WAAWA,CACTP,KAAiC,EACjCC,OAA+B,E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C,IAAI,CAAC,CAACb,QAAQ,CAACa,OAAO,CAAC;UACzB,CAAC,CAAC;UACF,IAAI,IAAI,CAAC,CAACV,OAAO,EAAE;YACjB;UACF;UACAM,KAAK,GAAG,IAAI,CAAC,CAACZ,KAAK,CAAC,IAAI,CAAC,CAACE,KAAK,CAAC;QAClC;MACF;IACF,CAAC,SAAS;MACR,IAAI,CAAC,CAACG,OAAO,GAAG,KAAK;MACrB,IAAI,IAAI,CAAC,CAACD,OAAO,IAAI,CAAC,IAAI,CAAC,CAACE,OAAO,EAAE;QACnC,IAAI,CAACE,IAAI,CAAC,CAAC;MACb;IACF;EACF;AACF","ignoreList":[]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type Scheduler = (task: () => void) => void;
|
|
2
|
-
/** Coalesces native doorbells and drains bounded event batches off the callback stack. */
|
|
3
|
-
export declare class EventDrain<Event> {
|
|
4
|
-
#private;
|
|
5
|
-
constructor(drain: (limit: number) => Event[], deliver: (event: Event) => void, limit?: number, schedule?: Scheduler);
|
|
6
|
-
ring(): void;
|
|
7
|
-
stop(): void;
|
|
8
|
-
}
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=event-drain.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-drain.d.ts","sourceRoot":"","sources":["../../../src/event-drain.ts"],"names":[],"mappings":"AAIA,KAAK,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAM5C,0FAA0F;AAC1F,qBAAa,UAAU,CAAC,KAAK;;IAS3B,YACE,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,EAAE,EACjC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAC/B,KAAK,SAAsB,EAC3B,QAAQ,GAAE,SAA8B,EAMzC;IAED,IAAI,IAAI,IAAI,CAWX;IAED,IAAI,IAAI,IAAI,CAGX;CA+BF"}
|
package/src/event-drain.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/* oxlint-disable no-await-in-loop, promise/avoid-new -- Each bounded batch intentionally yields one event-loop turn before the next synchronous native drain. */
|
|
2
|
-
|
|
3
|
-
const DEFAULT_BATCH_LIMIT = 256;
|
|
4
|
-
|
|
5
|
-
type Scheduler = (task: () => void) => void;
|
|
6
|
-
|
|
7
|
-
const scheduleOnNextTurn: Scheduler = (task) => {
|
|
8
|
-
setTimeout(task, 0);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/** Coalesces native doorbells and drains bounded event batches off the callback stack. */
|
|
12
|
-
export class EventDrain<Event> {
|
|
13
|
-
readonly #drain: (limit: number) => Event[];
|
|
14
|
-
readonly #deliver: (event: Event) => void;
|
|
15
|
-
readonly #limit: number;
|
|
16
|
-
readonly #schedule: Scheduler;
|
|
17
|
-
#pending = false;
|
|
18
|
-
#running = false;
|
|
19
|
-
#stopped = false;
|
|
20
|
-
|
|
21
|
-
constructor(
|
|
22
|
-
drain: (limit: number) => Event[],
|
|
23
|
-
deliver: (event: Event) => void,
|
|
24
|
-
limit = DEFAULT_BATCH_LIMIT,
|
|
25
|
-
schedule: Scheduler = scheduleOnNextTurn
|
|
26
|
-
) {
|
|
27
|
-
this.#drain = drain;
|
|
28
|
-
this.#deliver = deliver;
|
|
29
|
-
this.#limit = limit;
|
|
30
|
-
this.#schedule = schedule;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
ring(): void {
|
|
34
|
-
if (this.#stopped) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
this.#pending = true;
|
|
38
|
-
if (!this.#running) {
|
|
39
|
-
this.#running = true;
|
|
40
|
-
this.#schedule(() => {
|
|
41
|
-
void this.#run();
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
stop(): void {
|
|
47
|
-
this.#stopped = true;
|
|
48
|
-
this.#pending = false;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async #run(): Promise<void> {
|
|
52
|
-
try {
|
|
53
|
-
while (!this.#stopped && this.#pending) {
|
|
54
|
-
this.#pending = false;
|
|
55
|
-
let batch = this.#drain(this.#limit);
|
|
56
|
-
while (!this.#stopped && batch.length > 0) {
|
|
57
|
-
for (const event of batch) {
|
|
58
|
-
try {
|
|
59
|
-
this.#deliver(event);
|
|
60
|
-
} catch {
|
|
61
|
-
// Application callbacks cannot break native event delivery.
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
await new Promise<void>((resolve) => {
|
|
65
|
-
this.#schedule(resolve);
|
|
66
|
-
});
|
|
67
|
-
if (this.#stopped) {
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
batch = this.#drain(this.#limit);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} finally {
|
|
74
|
-
this.#running = false;
|
|
75
|
-
if (this.#pending && !this.#stopped) {
|
|
76
|
-
this.ring();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|