@gnolang/gnonative 4.0.0 → 4.1.1
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/Makefile +20 -3
- package/android/libs/gnocore-sources.jar +0 -0
- package/android/libs/gnocore.aar +0 -0
- package/android/src/main/java/land/gno/gnonative/GnonativeModule.kt +0 -13
- package/build/GoBridge.d.ts +0 -1
- package/build/GoBridge.d.ts.map +1 -1
- package/build/GoBridge.js +0 -3
- package/build/GoBridge.js.map +1 -1
- package/build/api/GnoNativeApi.d.ts +6 -6
- package/build/api/GnoNativeApi.d.ts.map +1 -1
- package/build/api/GnoNativeApi.js +50 -61
- package/build/api/GnoNativeApi.js.map +1 -1
- package/build/api/types.d.ts +2 -2
- package/build/api/types.d.ts.map +1 -1
- package/build/api/types.js.map +1 -1
- package/build/api/vendor/gnonativetypes_pb.d.ts +1334 -0
- package/build/api/vendor/gnonativetypes_pb.d.ts.map +1 -0
- package/build/api/vendor/gnonativetypes_pb.js +379 -0
- package/build/api/vendor/gnonativetypes_pb.js.map +1 -0
- package/build/api/vendor/rpc_pb.d.ts +646 -0
- package/build/api/vendor/rpc_pb.d.ts.map +1 -0
- package/build/api/vendor/rpc_pb.js +227 -0
- package/build/api/vendor/rpc_pb.js.map +1 -0
- package/build/grpc/client.d.ts +3 -3
- package/build/grpc/client.d.ts.map +1 -1
- package/build/grpc/client.js +3 -3
- package/build/grpc/client.js.map +1 -1
- package/build/grpc/error.d.ts +1 -1
- package/build/grpc/error.d.ts.map +1 -1
- package/build/grpc/error.js +1 -1
- package/build/grpc/error.js.map +1 -1
- package/build/grpc/transport_native.d.ts.map +1 -1
- package/build/grpc/transport_native.js +20 -25
- package/build/grpc/transport_native.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/ios/Frameworks/GnoCore.xcframework/Info.plist +5 -5
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/A/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/A/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64/GnoCore.framework/Versions/Current/Headers/GnoGnonative.objc.h +0 -7
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/GnoCore +0 -0
- package/ios/Frameworks/GnoCore.xcframework/ios-arm64_x86_64-simulator/GnoCore.framework/Headers/GnoGnonative.objc.h +0 -7
- package/ios/GnonativeModule.swift +0 -12
- package/package.json +4 -6
- package/src/GoBridge.ts +0 -5
- package/src/api/GnoNativeApi.ts +87 -142
- package/src/api/types.ts +10 -3
- package/src/api/vendor/gnonativetypes_pb.ts +1627 -0
- package/src/api/vendor/rpc_pb.ts +697 -0
- package/src/grpc/client.ts +4 -4
- package/src/grpc/error.ts +2 -1
- package/src/grpc/transport_native.ts +35 -36
- package/src/index.ts +2 -2
- package/tsconfig.json +0 -1
package/src/grpc/client.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createPromiseClient, PromiseClient } from '@connectrpc/connect';
|
|
1
|
+
import { createClient as cc, Client } from '@connectrpc/connect';
|
|
3
2
|
|
|
4
3
|
import { createNativeGrpcTransport } from './transport_native';
|
|
4
|
+
import { GnoNativeService } from '../api/vendor/rpc_pb';
|
|
5
5
|
|
|
6
6
|
// Create a GnoNativeService client
|
|
7
|
-
export function createClient(_port: number):
|
|
7
|
+
export function createClient(_port: number): Client<typeof GnoNativeService> {
|
|
8
8
|
const transport = createNativeGrpcTransport({
|
|
9
9
|
baseUrl: '',
|
|
10
10
|
useBinaryFormat: false,
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
return
|
|
13
|
+
return cc(GnoNativeService, transport);
|
|
14
14
|
}
|
package/src/grpc/error.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DescMessage,
|
|
3
|
+
DescMethodUnary,
|
|
4
|
+
DescMethodStreaming,
|
|
5
|
+
MessageShape,
|
|
6
|
+
MessageInitShape,
|
|
7
|
+
} from '@bufbuild/protobuf';
|
|
8
|
+
import { toJsonString } from '@bufbuild/protobuf';
|
|
3
9
|
import type {
|
|
4
10
|
ContextValues,
|
|
5
11
|
StreamResponse,
|
|
@@ -14,7 +20,7 @@ import {
|
|
|
14
20
|
runStreamingCall,
|
|
15
21
|
runUnaryCall,
|
|
16
22
|
} from '@connectrpc/connect/protocol';
|
|
17
|
-
import { requestHeader } from '@connectrpc/connect/protocol-
|
|
23
|
+
import { requestHeader } from '@connectrpc/connect/protocol-connect';
|
|
18
24
|
import { GrpcWebTransportOptions } from '@connectrpc/connect-web';
|
|
19
25
|
import { toByteArray } from 'base64-js';
|
|
20
26
|
import { CodedError } from 'expo-modules-core';
|
|
@@ -24,13 +30,12 @@ import { GoBridge } from '../GoBridge';
|
|
|
24
30
|
export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Transport {
|
|
25
31
|
const useBinaryFormat = options.useBinaryFormat ?? true;
|
|
26
32
|
return {
|
|
27
|
-
async unary<I extends
|
|
28
|
-
|
|
29
|
-
method: MethodInfo<I, O>,
|
|
33
|
+
async unary<I extends DescMessage, O extends DescMessage>(
|
|
34
|
+
method: DescMethodUnary<I, O>,
|
|
30
35
|
signal: AbortSignal | undefined,
|
|
31
36
|
timeoutMs: number | undefined,
|
|
32
37
|
header: HeadersInit | undefined,
|
|
33
|
-
message:
|
|
38
|
+
message: MessageInitShape<I>,
|
|
34
39
|
contextValues?: ContextValues,
|
|
35
40
|
): Promise<UnaryResponse<I, O>> {
|
|
36
41
|
const { parse } = createClientMethodSerializers(
|
|
@@ -45,23 +50,18 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
45
50
|
interceptors: options.interceptors,
|
|
46
51
|
req: {
|
|
47
52
|
stream: false,
|
|
48
|
-
service,
|
|
53
|
+
service: method.parent,
|
|
49
54
|
method,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
mode: 'cors',
|
|
54
|
-
},
|
|
55
|
-
header: new Headers(),
|
|
55
|
+
requestMethod: 'POST',
|
|
56
|
+
url: createMethodUrl(options.baseUrl, method),
|
|
57
|
+
header: requestHeader(method.methodKind, useBinaryFormat, timeoutMs, header, false),
|
|
56
58
|
contextValues: contextValues ?? createContextValues(),
|
|
57
59
|
message,
|
|
58
60
|
},
|
|
59
61
|
next: async (req: UnaryRequest<I, O>): Promise<UnaryResponse<I, O>> => {
|
|
60
62
|
try {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
req.message.toJsonString(),
|
|
64
|
-
);
|
|
63
|
+
const messageJson = toJsonString(req.method.input, req.message);
|
|
64
|
+
const res = await GoBridge.invokeGrpcMethod(req.method.name, messageJson);
|
|
65
65
|
|
|
66
66
|
const header: Headers | undefined = new Headers();
|
|
67
67
|
const trailer: Headers | undefined = new Headers();
|
|
@@ -71,7 +71,7 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
71
71
|
|
|
72
72
|
return {
|
|
73
73
|
stream: false,
|
|
74
|
-
service,
|
|
74
|
+
service: method.parent,
|
|
75
75
|
method,
|
|
76
76
|
header,
|
|
77
77
|
message,
|
|
@@ -85,13 +85,12 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
|
|
88
|
-
async stream<I extends
|
|
89
|
-
|
|
90
|
-
method: MethodInfo<I, O>,
|
|
88
|
+
async stream<I extends DescMessage, O extends DescMessage>(
|
|
89
|
+
method: DescMethodStreaming<I, O>,
|
|
91
90
|
signal: AbortSignal | undefined,
|
|
92
91
|
timeoutMs: number | undefined,
|
|
93
92
|
header: HeadersInit | undefined,
|
|
94
|
-
input: AsyncIterable<
|
|
93
|
+
input: AsyncIterable<MessageInitShape<I>>,
|
|
95
94
|
contextValues?: ContextValues,
|
|
96
95
|
): Promise<StreamResponse<I, O>> {
|
|
97
96
|
const { parse } = createClientMethodSerializers(
|
|
@@ -101,8 +100,11 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
101
100
|
options.binaryOptions,
|
|
102
101
|
);
|
|
103
102
|
|
|
104
|
-
async function createRequestBody(
|
|
105
|
-
|
|
103
|
+
async function createRequestBody(
|
|
104
|
+
schema: DescMessage,
|
|
105
|
+
input: AsyncIterable<MessageShape<I>>,
|
|
106
|
+
): Promise<string> {
|
|
107
|
+
if (method.methodKind !== 'server_streaming') {
|
|
106
108
|
throw 'The fetch API does not support streaming request bodies';
|
|
107
109
|
}
|
|
108
110
|
|
|
@@ -111,7 +113,8 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
111
113
|
throw 'missing request message';
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
const messageJson = toJsonString(schema, r.value);
|
|
117
|
+
return messageJson;
|
|
115
118
|
}
|
|
116
119
|
|
|
117
120
|
return await runStreamingCall<I, O>({
|
|
@@ -120,15 +123,11 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
120
123
|
signal,
|
|
121
124
|
req: {
|
|
122
125
|
stream: true,
|
|
123
|
-
service,
|
|
126
|
+
service: method.parent,
|
|
124
127
|
method,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
credentials: options.credentials ?? 'same-origin',
|
|
129
|
-
mode: 'cors',
|
|
130
|
-
},
|
|
131
|
-
header: requestHeader(useBinaryFormat, timeoutMs, header, false),
|
|
128
|
+
requestMethod: 'POST',
|
|
129
|
+
url: createMethodUrl(options.baseUrl, method),
|
|
130
|
+
header: requestHeader(method.methodKind, useBinaryFormat, timeoutMs, header, false),
|
|
132
131
|
message: input,
|
|
133
132
|
contextValues: contextValues ?? createContextValues(),
|
|
134
133
|
},
|
|
@@ -136,7 +135,7 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
136
135
|
const header: Headers | undefined = new Headers();
|
|
137
136
|
const trailer: Headers | undefined = new Headers();
|
|
138
137
|
|
|
139
|
-
const body = await createRequestBody(req.message);
|
|
138
|
+
const body = await createRequestBody(req.method.input, req.message);
|
|
140
139
|
|
|
141
140
|
let streamId: string;
|
|
142
141
|
try {
|
|
@@ -148,7 +147,7 @@ export function createNativeGrpcTransport(options: GrpcWebTransportOptions): Tra
|
|
|
148
147
|
|
|
149
148
|
const generator = {
|
|
150
149
|
async *[Symbol.asyncIterator]() {
|
|
151
|
-
for (
|
|
150
|
+
for (;;) {
|
|
152
151
|
try {
|
|
153
152
|
const res = await GoBridge.streamClientReceive(streamId);
|
|
154
153
|
const data = toByteArray(res);
|
package/src/index.ts
CHANGED
|
@@ -17,8 +17,8 @@ export function addChangeListener(listener: (event: ChangeEventPayload) => void)
|
|
|
17
17
|
|
|
18
18
|
export { ChangeEventPayload, GnonativeView, GnonativeViewProps };
|
|
19
19
|
export * from './provider/gnonative-provider';
|
|
20
|
-
export * from '
|
|
21
|
-
export * from '
|
|
20
|
+
export * from './api/vendor/gnonativetypes_pb';
|
|
21
|
+
export * from './api/vendor/rpc_pb';
|
|
22
22
|
export { GRPCError } from './grpc/error';
|
|
23
23
|
|
|
24
24
|
export * from './api/GnoNativeApi';
|
package/tsconfig.json
CHANGED