@solidnative-dev/networking 0.0.0-stage → 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +295 -2
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +390 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +43 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +239 -0
- package/dist/json.js.map +1 -0
- package/dist/react-native-adapter.d.ts +29 -0
- package/dist/react-native-adapter.d.ts.map +1 -0
- package/dist/react-native-adapter.js +271 -0
- package/dist/react-native-adapter.js.map +1 -0
- package/dist/react-native.d.ts +6 -0
- package/dist/react-native.d.ts.map +1 -0
- package/dist/react-native.js +32 -0
- package/dist/react-native.js.map +1 -0
- package/dist/server-events.d.ts +72 -0
- package/dist/server-events.d.ts.map +1 -0
- package/dist/server-events.js +372 -0
- package/dist/server-events.js.map +1 -0
- package/dist/solid-json.d.ts +36 -0
- package/dist/solid-json.d.ts.map +1 -0
- package/dist/solid-json.js +234 -0
- package/dist/solid-json.js.map +1 -0
- package/dist/solid-server-events.d.ts +68 -0
- package/dist/solid-server-events.d.ts.map +1 -0
- package/dist/solid-server-events.js +685 -0
- package/dist/solid-server-events.js.map +1 -0
- package/dist/solid.d.ts +15 -0
- package/dist/solid.d.ts.map +1 -0
- package/dist/solid.js +186 -0
- package/dist/solid.js.map +1 -0
- package/package.json +71 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Solid Native contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,296 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@solidnative-dev/networking`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Bounded incremental HTTP(S) text transport for Solid Native. The React Native
|
|
4
|
+
adapter resolves the pinned 0.87 `Networking` TurboModule directly and listens
|
|
5
|
+
to its native event channel without importing or routing requests through
|
|
6
|
+
`fetch`, `XMLHttpRequest`, either `RCTNetworking` platform wrapper, or the
|
|
7
|
+
generated JavaScript specs.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createReactNativeNetworkService } from "@solidnative-dev/networking/react-native";
|
|
11
|
+
import { createNetworkController } from "@solidnative-dev/networking/solid";
|
|
12
|
+
|
|
13
|
+
const network = createNetworkController(createReactNativeNetworkService());
|
|
14
|
+
const request = network.requestText(
|
|
15
|
+
{
|
|
16
|
+
url: "https://api.example/assistant",
|
|
17
|
+
method: "POST",
|
|
18
|
+
headers: { "Content-Type": "application/json" },
|
|
19
|
+
body: JSON.stringify({ prompt: "Show the account summary" }),
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
onResponse(response) {
|
|
23
|
+
console.log(response.status);
|
|
24
|
+
},
|
|
25
|
+
onChunk(chunk) {
|
|
26
|
+
appendIncrementalPayload(chunk.text);
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const result = await request.result;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For a finite JSON response, the optional document layer owns buffering and
|
|
35
|
+
validation instead of leaving each application to rebuild it:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { requestJSON } from "@solidnative-dev/networking/json";
|
|
39
|
+
|
|
40
|
+
const document = requestJSON(
|
|
41
|
+
network,
|
|
42
|
+
{
|
|
43
|
+
url: "https://api.example/assistant/profile",
|
|
44
|
+
headers: { Accept: "application/json" },
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
onResult(result) {
|
|
48
|
+
setProfile(result.value);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const { response, value } = await document.result;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For screen state, `createJSONResource` removes the imperative request-handle
|
|
57
|
+
bookkeeping while retaining the bounded native transport:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { createJSONResource } from "@solidnative-dev/networking/solid-json";
|
|
61
|
+
import { createSignal } from "solid-js";
|
|
62
|
+
|
|
63
|
+
const [accountId, setAccountId] = createSignal("42");
|
|
64
|
+
const account = createJSONResource(
|
|
65
|
+
network,
|
|
66
|
+
() => ({
|
|
67
|
+
url: `https://api.example/accounts/${accountId()}`,
|
|
68
|
+
headers: { Accept: "application/json" },
|
|
69
|
+
}),
|
|
70
|
+
{
|
|
71
|
+
decode(value) {
|
|
72
|
+
if (
|
|
73
|
+
value === null ||
|
|
74
|
+
typeof value !== "object" ||
|
|
75
|
+
Array.isArray(value) ||
|
|
76
|
+
typeof value.name !== "string"
|
|
77
|
+
) {
|
|
78
|
+
throw new TypeError("Account name is required.");
|
|
79
|
+
}
|
|
80
|
+
return { name: value.name };
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Reactive reads: account(), account.state, account.loading, account.error.
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Changing `accountId()` cancels obsolete native work before starting its
|
|
89
|
+
replacement. The last good value remains readable during refresh and after a
|
|
90
|
+
failure; `account.latest`, `account.response`, and `account.result` expose the
|
|
91
|
+
same state explicitly. `account.refetch()` retries the current request,
|
|
92
|
+
`account.cancel()` restores the last stable state, a `false`/`null`/`undefined`
|
|
93
|
+
source disables loading, and owner disposal cancels the final request. The
|
|
94
|
+
optional decoder must be synchronous so validation and publication remain in
|
|
95
|
+
the exact native completion cause.
|
|
96
|
+
|
|
97
|
+
The JSON layer independently caps native chunk count, document characters,
|
|
98
|
+
nesting depth, and value count, accepts `application/json` and registered
|
|
99
|
+
`application/*+json` forms, and deeply freezes the parsed value without
|
|
100
|
+
interpreting HTTP status. Content-type checks can be disabled only through an
|
|
101
|
+
explicit option. `onResult` must be synchronous and runs inside the Solid
|
|
102
|
+
controller's native completion event, so its reactive writes retain the exact
|
|
103
|
+
completion-to-computation-to-commit relationship. The promise is still
|
|
104
|
+
available for ordinary asynchronous control flow, but a later promise
|
|
105
|
+
continuation is not implicitly treated as native input.
|
|
106
|
+
|
|
107
|
+
For Server-Sent Events, the optional protocol layer preserves those same native
|
|
108
|
+
chunk and completion causes through event parsing:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { requestServerEvents } from "@solidnative-dev/networking/server-events";
|
|
112
|
+
|
|
113
|
+
const stream = requestServerEvents(
|
|
114
|
+
network,
|
|
115
|
+
{
|
|
116
|
+
url: "https://api.example/assistant/events",
|
|
117
|
+
headers: { Accept: "text/event-stream" },
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
onEvent(event) {
|
|
121
|
+
applyServerEvent(event.type, event.data);
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const { eventCount, lastEventId, retryMilliseconds } = await stream.result;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Long-lived screens can project the same connection into reactive state:
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { createServerEventStream } from "@solidnative-dev/networking/solid-server-events";
|
|
133
|
+
|
|
134
|
+
const assistant = createServerEventStream(
|
|
135
|
+
network,
|
|
136
|
+
() => ({
|
|
137
|
+
url: `https://api.example/assistant/${conversationId()}`,
|
|
138
|
+
headers: { Accept: "text/event-stream" },
|
|
139
|
+
}),
|
|
140
|
+
{
|
|
141
|
+
onEvent(event) {
|
|
142
|
+
applyAssistantEvent(event.type, event.data);
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Reactive reads: assistant(), assistant.state, assistant.active,
|
|
148
|
+
// assistant.eventCount, assistant.lastEventId, assistant.error.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Changing the request cancels the obsolete native stream and resets its
|
|
152
|
+
logical-stream state. `assistant.restart()` explicitly repeats the current
|
|
153
|
+
request, `assistant.restart(request)` starts a supplied request,
|
|
154
|
+
`assistant.cancel()` closes it, and owner disposal cancels it. Event publication
|
|
155
|
+
and the optional synchronous `onResponse` and `onEvent` callbacks retain each
|
|
156
|
+
native input's causal relationship to Solid computations and Fabric commits.
|
|
157
|
+
|
|
158
|
+
The decoder accepts arbitrary CR, LF, and CRLF chunk boundaries, comments,
|
|
159
|
+
multiline data, event names, IDs, and bounded retry hints. It independently
|
|
160
|
+
bounds line length, data size, data-line count, and total event count. A stream
|
|
161
|
+
must return HTTP 200 and `text/event-stream` unless the caller explicitly opts
|
|
162
|
+
out of the media-type check. Completion flushes a final event whose data was not
|
|
163
|
+
followed by a blank line, which is useful when a server cleanly closes a finite
|
|
164
|
+
AI response.
|
|
165
|
+
|
|
166
|
+
`requestServerEvents` always makes one connection. `createServerEventStream`
|
|
167
|
+
also makes one connection by default. To resume an interrupted stream, opt into
|
|
168
|
+
a bounded policy:
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
const assistant = createServerEventStream(network, request, {
|
|
172
|
+
onEvent(event) {
|
|
173
|
+
applyAssistantEvent(event.type, event.data);
|
|
174
|
+
},
|
|
175
|
+
reconnect: {
|
|
176
|
+
maxAttempts: 3, // At most three reconnects after the initial connection.
|
|
177
|
+
defaultRetryMilliseconds: 3_000,
|
|
178
|
+
minimumRetryMilliseconds: 250,
|
|
179
|
+
maximumRetryMilliseconds: 30_000,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The default policy retries native transport failures, timeouts, and clean EOF.
|
|
185
|
+
Set `reconnectOnCleanClose: false` for a finite response that should finish at
|
|
186
|
+
EOF. Protocol, validation, and application callback failures are terminal by
|
|
187
|
+
default; `shouldReconnect(error)` can synchronously select other failures,
|
|
188
|
+
but application callback failures are never retried. Reaching the attempt bound
|
|
189
|
+
closes a successful connection or reports its terminal error once through
|
|
190
|
+
`onError`. The attempt count does not reset when a connection succeeds.
|
|
191
|
+
|
|
192
|
+
Server `retry:` hints are clamped to the configured delay range. While waiting,
|
|
193
|
+
`state` is `"waiting"`, `active` remains true, and `pendingRetryMilliseconds`
|
|
194
|
+
exposes the owned delay. Automatic reconnects carry the latest nonempty ID in
|
|
195
|
+
`Last-Event-ID`, replace any case-insensitive original ID header, and retain
|
|
196
|
+
the decoder's ID and retry state, including ID-only blocks. An empty ID removes
|
|
197
|
+
the header. IDs are limited to 16,384 characters; each connection retains the
|
|
198
|
+
configured transport and decoder bounds. The stream retains only the latest
|
|
199
|
+
event, not an accumulated history.
|
|
200
|
+
|
|
201
|
+
`eventCount` counts events across the logical stream; `connectionEventCount`
|
|
202
|
+
and event `sequence` are connection-local. `connectionCount` and `reconnectCount`
|
|
203
|
+
count attempts actually started. `restart()` starts a fresh logical stream from
|
|
204
|
+
the original request and configured initial decoder state, not the last
|
|
205
|
+
automatic resume position. Its promise settles when that logical stream ends
|
|
206
|
+
and returns the final connection's result. Cancellation, source replacement,
|
|
207
|
+
restart, and owner disposal cancel pending timers and native work and reject
|
|
208
|
+
the obsolete series with `NetworkRequestCancelledError`. Late callbacks cannot
|
|
209
|
+
publish into a replacement stream, including when a callback itself cancels or
|
|
210
|
+
restarts it. These framing and retry APIs do not define Solid's server-function
|
|
211
|
+
or server-component wire protocol.
|
|
212
|
+
|
|
213
|
+
The adapter normalizes two incompatible native ABIs. Android requires a
|
|
214
|
+
caller-generated signed 32-bit request identifier, tuple headers, and positional
|
|
215
|
+
arguments. iOS accepts an object request and returns its native identifier via a
|
|
216
|
+
callback, including after the application has already cancelled. React Native's
|
|
217
|
+
iOS request counter starts at zero, so the adapter accepts non-negative safe
|
|
218
|
+
integers rather than imposing Android's positive signed 32-bit range. Invalid
|
|
219
|
+
callback IDs settle as a canonical non-timeout transport failure instead of
|
|
220
|
+
creating a malformed completion. Both platforms use native incremental text
|
|
221
|
+
delivery and native abort rather than buffering the entire response through the
|
|
222
|
+
React Native fetch polyfill. React Native 0.87's
|
|
223
|
+
completion event can omit its timeout element for success and ordinary transport
|
|
224
|
+
failure. The bridgeless iOS event path can expose the false NSNumber slot as
|
|
225
|
+
`null` or `undefined`, while other native paths can surface booleans as `0` or
|
|
226
|
+
`1`. The pinned adapter canonicalizes only those bounded two- or three-element
|
|
227
|
+
representations to `false` or `true`; it reports malformed lengths and value
|
|
228
|
+
kinds without including native error values, and the service contract remains
|
|
229
|
+
strictly boolean.
|
|
230
|
+
|
|
231
|
+
Request URLs, methods, credentials, headers, body size, timeout, per-chunk size,
|
|
232
|
+
aggregate response size, response metadata, byte progress, native errors, and
|
|
233
|
+
event ordering are validated. The service never accumulates response text; the
|
|
234
|
+
application decides what to retain. Immediate cancellation avoids native work,
|
|
235
|
+
active cancellation aborts the platform request, and Solid owner disposal
|
|
236
|
+
cancels every pending request. Response and chunk observers are synchronous by
|
|
237
|
+
design so the native input, reactive write, and resulting commit retain one
|
|
238
|
+
exact causal relationship; start separate owned work explicitly when a chunk
|
|
239
|
+
needs asynchronous processing.
|
|
240
|
+
|
|
241
|
+
The Solid controller gives response metadata, every chunk, completion, and
|
|
242
|
+
failure a separate causal platform event. This is the transport-level path for
|
|
243
|
+
tracing a server or AI stream into the Solid computations, Fabric commits, and
|
|
244
|
+
frames it causes. Causal telemetry records none of the URL, headers, request
|
|
245
|
+
body, response headers, streamed text, or parsed JSON. JSON documents and SSE
|
|
246
|
+
are separate, stable framing layers; server functions and Solid server
|
|
247
|
+
components remain future protocol layers and are deliberately not inferred
|
|
248
|
+
here.
|
|
249
|
+
|
|
250
|
+
React Native's application bootstrap still installs its standard fetch/XHR
|
|
251
|
+
globals before the entrypoint. The Release source policy fingerprints that
|
|
252
|
+
unavoidable, platform-specific `setup-env` baseline while requiring the Solid
|
|
253
|
+
Native transport itself to contain only its direct registry, adapter, service,
|
|
254
|
+
and ownership seam. Removing the broader React Native environment bootstrap is
|
|
255
|
+
a separate backend concern, not something this package disguises.
|
|
256
|
+
|
|
257
|
+
The dedicated Release proofs can be run on attached, securely unlocked physical
|
|
258
|
+
devices with:
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
pnpm --filter @solidnative-dev/native-e2e android:networking:test
|
|
262
|
+
|
|
263
|
+
SOLID_NATIVE_IOS_DESTINATION=<xcode-device-id> \
|
|
264
|
+
SOLID_NATIVE_IOS_TEAM=<development-team-id> \
|
|
265
|
+
pnpm --filter @solidnative-dev/native-e2e ios:networking:test
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
The Android runner serves split SSE and JSON responses from a bounded local
|
|
269
|
+
host server through an explicit `adb reverse`. The proof also requires exactly
|
|
270
|
+
two resumed SSE connections, a server-observed `Last-Event-ID`, the requested
|
|
271
|
+
retry delay, and retained decoder state. It forces a native transport failure, physically taps
|
|
272
|
+
explicit and Solid-owner cancellation paths, and requires response/chunk/
|
|
273
|
+
completion-to-computation-to-Fabric-commit/mount/frame causality without the
|
|
274
|
+
URL, headers, bodies, or streamed values entering telemetry. The runner rejects
|
|
275
|
+
emulators and ambiguous devices, bounds the one transparent OkHttp retry seen
|
|
276
|
+
for the idempotent forced-failure request, waits for JavaScript cancellation and
|
|
277
|
+
surface-teardown acknowledgement, and verifies that the app process, disposable
|
|
278
|
+
packages, and reverse tunnel are gone before success. Cleartext permission is
|
|
279
|
+
limited to this checked-in local proof application; the package does not weaken
|
|
280
|
+
an application's network-security policy.
|
|
281
|
+
|
|
282
|
+
The iOS runner uses the same bounded server and proof definition over a
|
|
283
|
+
run-scoped 144-bit `*.local` launch capability. Its app rejects any non-local or
|
|
284
|
+
malformed origin, keeps arbitrary ATS loads disabled, and declares local-network
|
|
285
|
+
access only in the disposable proof bundle. The generic Release app, XCTest
|
|
286
|
+
bundle, Hermes bytecode, and composed source map compile and pass the same seam
|
|
287
|
+
policy without signing. The signed physical URLSession run remains the iOS
|
|
288
|
+
promotion gate. On 2026-09-25 the Xcode 27 signed Release build, source-map
|
|
289
|
+
checks, and scene-based cold launch passed on iOS 27. A `.local` request timed
|
|
290
|
+
out; a retry using the Mac's explicit Wi-Fi IPv4 address revealed iOS's
|
|
291
|
+
`Local network prohibited` error. The runner now reports that permission
|
|
292
|
+
failure without copying request URLs or native payloads into its summary.
|
|
293
|
+
Physical reconnect qualification remains open on both platforms pending iOS
|
|
294
|
+
Local Network authorization and a connected Android rerun. On a dual-homed Mac,
|
|
295
|
+
`SOLID_NATIVE_IOS_NETWORKING_HOST` can select a canonical private IPv4 address;
|
|
296
|
+
it does not bypass the phone's permission check.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export declare const NETWORK_MAX_URL_LENGTH = 8192;
|
|
2
|
+
export declare const NETWORK_MAX_METHOD_LENGTH = 32;
|
|
3
|
+
export declare const NETWORK_MAX_HEADER_COUNT = 256;
|
|
4
|
+
export declare const NETWORK_MAX_HEADER_NAME_LENGTH = 256;
|
|
5
|
+
export declare const NETWORK_MAX_HEADER_VALUE_LENGTH = 16384;
|
|
6
|
+
export declare const NETWORK_MAX_HEADER_CHARACTERS = 131072;
|
|
7
|
+
export declare const NETWORK_MAX_REQUEST_BODY_CHARACTERS = 1048576;
|
|
8
|
+
export declare const NETWORK_MAX_CHUNK_CHARACTERS = 1048576;
|
|
9
|
+
export declare const NETWORK_DEFAULT_MAX_RESPONSE_CHARACTERS = 8388608;
|
|
10
|
+
export declare const NETWORK_MAX_RESPONSE_CHARACTERS = 67108864;
|
|
11
|
+
export declare const NETWORK_DEFAULT_TIMEOUT_MILLISECONDS = 30000;
|
|
12
|
+
export declare const NETWORK_MAX_TIMEOUT_MILLISECONDS = 300000;
|
|
13
|
+
export declare const NETWORK_MAX_NATIVE_ERROR_LENGTH = 2048;
|
|
14
|
+
export type NetworkPlatform = "android" | "ios";
|
|
15
|
+
export type NetworkCredentials = "include" | "omit";
|
|
16
|
+
export interface NetworkTextRequest {
|
|
17
|
+
readonly url: string;
|
|
18
|
+
readonly method?: string;
|
|
19
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
20
|
+
readonly body?: string;
|
|
21
|
+
readonly credentials?: NetworkCredentials;
|
|
22
|
+
readonly timeoutMilliseconds?: number;
|
|
23
|
+
readonly maxResponseCharacters?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface NormalizedNetworkTextRequest {
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly method: string;
|
|
28
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
29
|
+
readonly body?: string;
|
|
30
|
+
readonly withCredentials: boolean;
|
|
31
|
+
readonly timeoutMilliseconds: number;
|
|
32
|
+
readonly maxResponseCharacters: number;
|
|
33
|
+
}
|
|
34
|
+
export interface NetworkResponse {
|
|
35
|
+
readonly status: number;
|
|
36
|
+
readonly url: string;
|
|
37
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
38
|
+
}
|
|
39
|
+
export interface NetworkTextChunk {
|
|
40
|
+
readonly sequence: number;
|
|
41
|
+
readonly text: string;
|
|
42
|
+
readonly loaded: number;
|
|
43
|
+
readonly total?: number;
|
|
44
|
+
}
|
|
45
|
+
export interface NetworkTextObserver {
|
|
46
|
+
readonly onResponse?: (response: NetworkResponse) => unknown;
|
|
47
|
+
readonly onChunk?: (chunk: NetworkTextChunk) => unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface NetworkTextResult {
|
|
50
|
+
readonly response: NetworkResponse;
|
|
51
|
+
readonly chunkCount: number;
|
|
52
|
+
readonly receivedCharacters: number;
|
|
53
|
+
}
|
|
54
|
+
export interface NetworkTextRequestHandle {
|
|
55
|
+
readonly result: Promise<NetworkTextResult>;
|
|
56
|
+
cancel(): void;
|
|
57
|
+
}
|
|
58
|
+
export type NetworkAdapterEvent = Readonly<{
|
|
59
|
+
kind: "response";
|
|
60
|
+
status: unknown;
|
|
61
|
+
headers: unknown;
|
|
62
|
+
url: unknown;
|
|
63
|
+
}> | Readonly<{
|
|
64
|
+
kind: "chunk";
|
|
65
|
+
text: unknown;
|
|
66
|
+
loaded: unknown;
|
|
67
|
+
total: unknown;
|
|
68
|
+
}> | Readonly<{
|
|
69
|
+
kind: "complete";
|
|
70
|
+
error: unknown;
|
|
71
|
+
timedOut: unknown;
|
|
72
|
+
}>;
|
|
73
|
+
export interface NetworkAdapterRequestHandle {
|
|
74
|
+
cancel(): void;
|
|
75
|
+
}
|
|
76
|
+
export interface NetworkAdapter {
|
|
77
|
+
readonly platform: NetworkPlatform;
|
|
78
|
+
startTextRequest(request: NormalizedNetworkTextRequest, listener: (event: NetworkAdapterEvent) => void): NetworkAdapterRequestHandle;
|
|
79
|
+
}
|
|
80
|
+
export interface NetworkService {
|
|
81
|
+
readonly platform: NetworkPlatform;
|
|
82
|
+
requestText(request: NetworkTextRequest, observer?: NetworkTextObserver): NetworkTextRequestHandle;
|
|
83
|
+
}
|
|
84
|
+
export declare class NetworkRequestCancelledError extends Error {
|
|
85
|
+
constructor();
|
|
86
|
+
}
|
|
87
|
+
export declare class NetworkRequestTimedOutError extends Error {
|
|
88
|
+
constructor();
|
|
89
|
+
}
|
|
90
|
+
export declare class NetworkTransportError extends Error {
|
|
91
|
+
constructor(reason: string);
|
|
92
|
+
}
|
|
93
|
+
/** Validates requests plus every metadata, chunk, and completion settlement. */
|
|
94
|
+
export declare function createNetworkService(adapterValue: NetworkAdapter): NetworkService;
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAC5C,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAClD,eAAO,MAAM,+BAA+B,QAAS,CAAC;AACtD,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,eAAO,MAAM,mCAAmC,UAAY,CAAC;AAC7D,eAAO,MAAM,4BAA4B,UAAY,CAAC;AACtD,eAAO,MAAM,uCAAuC,UAAY,CAAC;AACjE,eAAO,MAAM,+BAA+B,WAAa,CAAC;AAC1D,eAAO,MAAM,oCAAoC,QAAS,CAAC;AAC3D,eAAO,MAAM,gCAAgC,SAAU,CAAC;AACxD,eAAO,MAAM,+BAA+B,OAAQ,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,KAAK,CAAC;AAChD,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAA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