@webpieces/http-client-browser 0.4.1008 → 0.4.1010
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 +94 -8
- package/package.json +3 -3
- package/src/ClientHttpBrowserFactory.d.ts +4 -3
- package/src/ClientHttpBrowserFactory.js +27 -6
- package/src/ClientHttpBrowserFactory.js.map +1 -1
- package/src/ReactNativeRuntimeDetector.d.ts +5 -2
- package/src/ReactNativeRuntimeDetector.js +27 -2
- package/src/ReactNativeRuntimeDetector.js.map +1 -1
- package/src/index.d.ts +2 -2
- package/src/index.js +4 -2
- package/src/index.js.map +1 -1
package/README.md
CHANGED
|
@@ -120,14 +120,15 @@ deadline and the backoff never extends one.
|
|
|
120
120
|
The factory checks for the React Native **JavaScript runtime**, via `navigator.product === 'ReactNative'`
|
|
121
121
|
(set by React Native's `Libraries/Core/setUpNavigator.js`; verified on 0.83.10). In that runtime,
|
|
122
122
|
`new ClientHttpBrowserFactory(store)` — and passing `HttpClientRuntime.platformDefaults()` — throws
|
|
123
|
-
`ReactNativeRuntimeConfigError` at construction, naming the missing `fetch` / `deadlines` and linking
|
|
124
|
-
|
|
123
|
+
`ReactNativeRuntimeConfigError` at construction, naming the missing `fetch` / `deadlines` and linking to
|
|
124
|
+
[#1463](https://github.com/deanhiller/webpieces-ts/issues/1463). Nothing is sent first. `HttpClientRuntime.reactNative(...)` itself refuses a missing collaborator
|
|
125
125
|
(for plain-JavaScript callers the types cannot stop).
|
|
126
126
|
|
|
127
|
-
- **
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
- **Standalone browsers are unaffected**, including Chrome/Safari on phones. A generic
|
|
128
|
+
`window.ReactNativeWebView.postMessage` (or `globalThis.ReactNativeWebView.postMessage`) is a
|
|
129
|
+
WebView hint, not proof of Expo or native capabilities. Its presence now **refuses browser defaults**
|
|
130
|
+
until the shell is explicitly configured as described below. No user-agent sniffing or mandatory
|
|
131
|
+
`react-native`/Expo import.
|
|
131
132
|
- **Node, SSR, workers and tests** (no `navigator`, or no `product`) keep the platform defaults and never
|
|
132
133
|
throw on a missing global.
|
|
133
134
|
- **Detection limits.** A runtime that hides or rewrites `navigator.product` is not detected — declare it
|
|
@@ -143,8 +144,93 @@ here. Nothing is sent first. `HttpClientRuntime.reactNative(...)` itself refuses
|
|
|
143
144
|
Before #1445, a React Native app that built `new ClientHttpBrowserFactory(store)` silently got the default
|
|
144
145
|
`fetch` and JS timers — and stalled while locked. It now **fails at startup** with
|
|
145
146
|
`ReactNativeRuntimeConfigError`. Fix every React Native factory (auth, heartbeat, log shipping, …) by
|
|
146
|
-
passing one shared `HttpClientRuntime.reactNative(fetch, deadlines)` as the third argument.
|
|
147
|
-
WebView code needs no change. A custom `CallStrategy` that waited with `setTimeout` should wait on its
|
|
147
|
+
passing one shared `HttpClientRuntime.reactNative(fetch, deadlines)` as the third argument. Standalone browser code needs no change. Embedded WebView code must also migrate as described below. A custom `CallStrategy` that waited with `setTimeout` should wait on its
|
|
148
148
|
new third argument, `deadlines` (see [client timeouts](../../../docs/client-timeouts.md)). Direct
|
|
149
149
|
`fetch` calls outside the typed client (e.g. media byte-range downloads) are not covered — wire the
|
|
150
150
|
same native transport into them yourself.
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
## Websites inside Expo / React Native WebViews (#1463)
|
|
154
|
+
|
|
155
|
+
The website is a **different JavaScript runtime** from RN. Importing `expo/fetch` in the website
|
|
156
|
+
selects its web fallback; it does not reach native HTTP. `http-client-browser` and
|
|
157
|
+
`http-client-core` therefore depend on neither Expo nor React Native. Both an Expo adapter and a
|
|
158
|
+
future replacement adapter can implement the existing shared `HttpFetch` + `DeadlineScheduler` API.
|
|
159
|
+
There is no process-global registration, fetch patch, or magic truthy `EXPO_CLIENT` flag.
|
|
160
|
+
|
|
161
|
+
Complete shell bootstrap **before constructing the factory**. The shell must explicitly acknowledge
|
|
162
|
+
its host kind, protocol version, current document/session identity and all three native capabilities.
|
|
163
|
+
After receiving that acknowledgement over the application's existing trusted bootstrap channel:
|
|
164
|
+
|
|
165
|
+
```ts
|
|
166
|
+
import {
|
|
167
|
+
ClientHttpBrowserFactory, HttpClientRuntime, MobileWebViewHost,
|
|
168
|
+
} from '@webpieces/http-client-browser';
|
|
169
|
+
|
|
170
|
+
// Values below come from the shell's completed bootstrap negotiation, not guessed page globals.
|
|
171
|
+
// Forward these same identities to the app's adapter so the native side checks each request/reply.
|
|
172
|
+
const host = new MobileWebViewHost(
|
|
173
|
+
'expo-webview', // or 'react-native-webview' for a different native shell
|
|
174
|
+
1,
|
|
175
|
+
bootstrap.documentId,
|
|
176
|
+
bootstrap.sessionId,
|
|
177
|
+
bootstrap.nativeHttp, // must be true
|
|
178
|
+
bootstrap.nativeDeadlines, // must be true
|
|
179
|
+
bootstrap.nativeCancellation, // must be true
|
|
180
|
+
);
|
|
181
|
+
const runtime = HttpClientRuntime.mobileWebView(shellFetch, shellDeadlines, host);
|
|
182
|
+
const factory = new ClientHttpBrowserFactory(store, lifecycleListener, runtime);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`host` may also be the deserialized JSON acknowledgement: no class prototype or `instanceof` is
|
|
186
|
+
required. `mobileWebView` validates it immediately and snapshots/freezes the identity. A missing
|
|
187
|
+
transport/scheduler, false/missing capability, unknown host/version or empty identity throws
|
|
188
|
+
`MobileWebViewRuntimeConfigError`, with the missing fields, the remedy and the issue link. It is a
|
|
189
|
+
configuration error for bootstrap to handle, not a remote HTTP 500 or an application server-bug modal.
|
|
190
|
+
It also works without a WebView marker, for shells that deliberately hide that marker.
|
|
191
|
+
|
|
192
|
+
A marker-present **undeclared/older shell is refused at factory construction**. Passing platform
|
|
193
|
+
defaults, or an RN runtime without a WebView acknowledgement, does not bypass it. Upgrade the shell
|
|
194
|
+
and bootstrap the page before building clients; do not catch the error and rebuild with browser
|
|
195
|
+
fetch. A marker installed between factory and client construction is checked again at client binding.
|
|
196
|
+
A shell hiding every marker must supply the explicit runtime: ordinary browser APIs cannot discover
|
|
197
|
+
an otherwise invisible embedding. A marker is configuration only, never an authorization boundary.
|
|
198
|
+
|
|
199
|
+
### Adapter obligations and delivery boundary
|
|
200
|
+
|
|
201
|
+
This package supplies **the portable injection contract and construction checks**, not an Expo
|
|
202
|
+
module, a universal native URL proxy, or a consumer-specific IPC bridge. The application supplies
|
|
203
|
+
`shellFetch` and `shellDeadlines`. A declaration cannot prove their implementation is native or that
|
|
204
|
+
its live bridge remains available. The adapter must:
|
|
205
|
+
|
|
206
|
+
- Route through native HTTP and a native end-to-end deadline covering IPC handoff, network and body
|
|
207
|
+
completion. Native timeout/cancellation must close the request and release bounded pending work
|
|
208
|
+
even while page JS is asleep. `now()` must advance during sleep; a late result is rejected on resume.
|
|
209
|
+
A WebView `setTimeout`, including one hidden behind a scheduler, does not satisfy the contract.
|
|
210
|
+
- Enforce approved service routes/origins and redirect destinations **natively**, with bounded request,
|
|
211
|
+
response and concurrent-call limits. Do not grant page-provided URLs, headers or tokens unrestricted
|
|
212
|
+
authority. The native side owns credentials; define which untrusted context headers the page may
|
|
213
|
+
forward. Native bearer authentication does not inherit the page's cookies/CORS rules.
|
|
214
|
+
- Bind every pending request/reply to native account, document and session epochs. On navigation,
|
|
215
|
+
logout, account change or bridge loss, cancel/reject pending work, ignore stale replies and negotiate
|
|
216
|
+
a fresh runtime before new clients. The frozen host is an acknowledgement, not a live session monitor.
|
|
217
|
+
- Preserve HTTP status, headers and body when reconstructing `Response`. Keep transport failures
|
|
218
|
+
separate from HTTP responses: native connection rejection must become the fetch-compatible network
|
|
219
|
+
rejection, deadline/cancel must retain their semantics, and unexpected implementation errors must
|
|
220
|
+
remain errors. Generic IPC RPC error translation attributes a peer's local connection failure to
|
|
221
|
+
the peer (`ApiDependencyError`); wrapping native fetch in such an RPC without a transport-specific
|
|
222
|
+
outcome codec loses `ApiConnectionError`. Verify the adapter through real JSON serialization.
|
|
223
|
+
- Explicitly reject unsupported bodies/responses. `HttpFetchInit` sends an optional serialized string
|
|
224
|
+
body and abort signal; buffered JSON RPC is the initial proven use case. A `Response` facade does
|
|
225
|
+
not imply support for streaming, binary or media. Those need their own bounded adapter design;
|
|
226
|
+
do not base64-buffer whole downloads through IPC or silently fall back to page fetch. Adapters
|
|
227
|
+
must test response-body failures as well as headers. No default retries are introduced here;
|
|
228
|
+
native queues must not amplify the configured typed client's retries.
|
|
229
|
+
|
|
230
|
+
The reproduction and its limitations live in [#1463](https://github.com/deanhiller/webpieces-ts/issues/1463):
|
|
231
|
+
a physical Pixel's page HTTP stalled during screen lock while native HTTP and audio continued;
|
|
232
|
+
delegating through RN's Expo fetch/native deadlines avoided the stall in the comparison. It tested
|
|
233
|
+
transport and deadlines together, not each independently. These portable tests verify construction,
|
|
234
|
+
injected transport and deadlines with page timers frozen; they are not a physical Android/iOS
|
|
235
|
+
background-execution certification. The consumer must verify its actual bridge, native resource
|
|
236
|
+
cleanup, credential/session enforcement and locked-device behavior on each supported platform.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-client-browser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1010",
|
|
4
4
|
"description": "Browser HTTP client for webpieces: DI-free (React or Angular), app-managed context store, no AsyncLocalStorage",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@webpieces/core-util": "0.4.
|
|
26
|
-
"@webpieces/http-client-core": "0.4.
|
|
25
|
+
"@webpieces/core-util": "0.4.1010",
|
|
26
|
+
"@webpieces/http-client-core": "0.4.1010"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -31,8 +31,8 @@ import { RequestLifecycleListener } from './RequestLifecycleListener';
|
|
|
31
31
|
* endpoint throws in `createRpcClient`, not on the first call.
|
|
32
32
|
*
|
|
33
33
|
* **Runtime (#1445).** The optional third argument is this factory's {@link HttpClientRuntime}: the
|
|
34
|
-
* fetch every client it builds sends through and the clock their deadlines use. Omitted, a
|
|
35
|
-
*
|
|
34
|
+
* fetch every client it builds sends through and the clock their deadlines use. Omitted, a
|
|
35
|
+
* standalone browser gets the platform fetch and JS timers. In the React Native JS
|
|
36
36
|
* runtime (detected by `navigator.product === 'ReactNative'`) omitting it — or passing
|
|
37
37
|
* `HttpClientRuntime.platformDefaults()` — THROWS {@link ReactNativeRuntimeConfigError} here, before
|
|
38
38
|
* any request, because React Native's default fetch and JS timers can stop while a phone is locked:
|
|
@@ -53,7 +53,8 @@ export declare class ClientHttpBrowserFactory {
|
|
|
53
53
|
constructor(store: MutableContextStore, lifecycleListener?: RequestLifecycleListener | undefined, runtime?: HttpClientRuntime);
|
|
54
54
|
/**
|
|
55
55
|
* The supplied runtime, else the platform defaults — unless this is the React Native JS runtime,
|
|
56
|
-
* where only an explicit {@link HttpClientRuntime.reactNative} is accepted.
|
|
56
|
+
* where only an explicit {@link HttpClientRuntime.reactNative} is accepted. An embedded RN
|
|
57
|
+
* WebView separately requires {@link HttpClientRuntime.mobileWebView} and shell capabilities.
|
|
57
58
|
*/
|
|
58
59
|
private static selectRuntime;
|
|
59
60
|
/**
|
|
@@ -37,8 +37,8 @@ const ReactNativeRuntimeDetector_1 = require("./ReactNativeRuntimeDetector");
|
|
|
37
37
|
* endpoint throws in `createRpcClient`, not on the first call.
|
|
38
38
|
*
|
|
39
39
|
* **Runtime (#1445).** The optional third argument is this factory's {@link HttpClientRuntime}: the
|
|
40
|
-
* fetch every client it builds sends through and the clock their deadlines use. Omitted, a
|
|
41
|
-
*
|
|
40
|
+
* fetch every client it builds sends through and the clock their deadlines use. Omitted, a
|
|
41
|
+
* standalone browser gets the platform fetch and JS timers. In the React Native JS
|
|
42
42
|
* runtime (detected by `navigator.product === 'ReactNative'`) omitting it — or passing
|
|
43
43
|
* `HttpClientRuntime.platformDefaults()` — THROWS {@link ReactNativeRuntimeConfigError} here, before
|
|
44
44
|
* any request, because React Native's default fetch and JS timers can stop while a phone is locked:
|
|
@@ -63,15 +63,34 @@ let ClientHttpBrowserFactory = ClientHttpBrowserFactory_1 = class ClientHttpBrow
|
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* The supplied runtime, else the platform defaults — unless this is the React Native JS runtime,
|
|
66
|
-
* where only an explicit {@link HttpClientRuntime.reactNative} is accepted.
|
|
66
|
+
* where only an explicit {@link HttpClientRuntime.reactNative} is accepted. An embedded RN
|
|
67
|
+
* WebView separately requires {@link HttpClientRuntime.mobileWebView} and shell capabilities.
|
|
67
68
|
*/
|
|
68
69
|
// webpieces-disable no-function-outside-class -- pure construction-time selection
|
|
69
70
|
static selectRuntime(runtime, detector) {
|
|
70
|
-
|
|
71
|
-
if (selected.kind !== http_client_core_1.HttpRuntimeKind.REACT_NATIVE && detector.isReactNative()) {
|
|
71
|
+
if (runtime?.kind !== http_client_core_1.HttpRuntimeKind.REACT_NATIVE && detector.isReactNative()) {
|
|
72
72
|
throw new http_client_core_1.ReactNativeRuntimeConfigError(['fetch', 'deadlines'], 'new ClientHttpBrowserFactory(...)');
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
if (runtime?.kind !== http_client_core_1.HttpRuntimeKind.MOBILE_WEBVIEW && detector.isWebView()) {
|
|
75
|
+
throw new http_client_core_1.MobileWebViewRuntimeConfigError([
|
|
76
|
+
'declared shell host',
|
|
77
|
+
'nativeHttp',
|
|
78
|
+
'nativeDeadlines',
|
|
79
|
+
'nativeCancellation',
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
// Revalidate at the library boundary too: untyped callers can assemble a runtime object
|
|
83
|
+
// without ever calling its named constructor. A kind/marker alone is not a capability.
|
|
84
|
+
if (runtime?.kind === http_client_core_1.HttpRuntimeKind.MOBILE_WEBVIEW) {
|
|
85
|
+
if (!runtime.host) {
|
|
86
|
+
throw new http_client_core_1.MobileWebViewRuntimeConfigError(['shell host capabilities']);
|
|
87
|
+
}
|
|
88
|
+
return http_client_core_1.HttpClientRuntime.mobileWebView(runtime.fetch, runtime.deadlines, runtime.host);
|
|
89
|
+
}
|
|
90
|
+
if (runtime?.kind === http_client_core_1.HttpRuntimeKind.REACT_NATIVE) {
|
|
91
|
+
return http_client_core_1.HttpClientRuntime.reactNative(runtime.fetch, runtime.deadlines);
|
|
92
|
+
}
|
|
93
|
+
return runtime ?? http_client_core_1.HttpClientRuntime.platformDefaults();
|
|
75
94
|
}
|
|
76
95
|
/**
|
|
77
96
|
* Create a type-safe HTTP client for one API contract.
|
|
@@ -80,6 +99,8 @@ let ClientHttpBrowserFactory = ClientHttpBrowserFactory_1 = class ClientHttpBrow
|
|
|
80
99
|
* @param config - This client's state (its baseUrl)
|
|
81
100
|
*/
|
|
82
101
|
createRpcClient(apiPrototype, config) {
|
|
102
|
+
// Also catch a shell marker installed after the factory, before binding a client.
|
|
103
|
+
ClientHttpBrowserFactory_1.selectRuntime(this.runtime, new ReactNativeRuntimeDetector_1.ReactNativeRuntimeDetector());
|
|
83
104
|
(0, core_util_1.assertNotInternalApi)(apiPrototype, 'ClientHttpBrowserFactory');
|
|
84
105
|
const proxyClient = new BrowserProxyClient_1.BrowserProxyClient(this.contextMgr, this.runtime, this.lifecycleListener);
|
|
85
106
|
proxyClient.init(apiPrototype, config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientHttpBrowserFactory.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ClientHttpBrowserFactory.ts"],"names":[],"mappings":";;;;;AAAA,oDAAwF;AACxF,
|
|
1
|
+
{"version":3,"file":"ClientHttpBrowserFactory.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ClientHttpBrowserFactory.ts"],"names":[],"mappings":";;;;;AAAA,oDAAwF;AACxF,kEAOqC;AACrC,6DAA0D;AAE1D,+DAA4D;AAE5D,6EAA0E;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEI,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IAMZ;IALJ,UAAU,CAAa;IACvB,OAAO,CAAoB;IAE5C,YACI,KAA0B,EACT,iBAA4C,EAC7D,OAA2B;QADV,sBAAiB,GAAjB,iBAAiB,CAA2B;QAG7D,IAAI,CAAC,UAAU,GAAG,IAAI,sBAAU,CAAC,KAAK,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,0BAAwB,CAAC,aAAa,CACjD,OAAO,EACP,IAAI,uDAA0B,EAAE,CACnC,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,kFAAkF;IAC1E,MAAM,CAAC,aAAa,CACxB,OAAsC,EACtC,QAAoC;QAEpC,IAAI,OAAO,EAAE,IAAI,KAAK,kCAAe,CAAC,YAAY,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;YAC7E,MAAM,IAAI,gDAA6B,CACnC,CAAC,OAAO,EAAE,WAAW,CAAC,EACtB,mCAAmC,CACtC,CAAC;QACN,CAAC;QACD,IAAI,OAAO,EAAE,IAAI,KAAK,kCAAe,CAAC,cAAc,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC;YAC3E,MAAM,IAAI,kDAA+B,CAAC;gBACtC,qBAAqB;gBACrB,YAAY;gBACZ,iBAAiB;gBACjB,oBAAoB;aACvB,CAAC,CAAC;QACP,CAAC;QACD,wFAAwF;QACxF,uFAAuF;QACvF,IAAI,OAAO,EAAE,IAAI,KAAK,kCAAe,CAAC,cAAc,EAAE,CAAC;YACnD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;gBAChB,MAAM,IAAI,kDAA+B,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC3E,CAAC;YACD,OAAO,oCAAiB,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3F,CAAC;QACD,IAAI,OAAO,EAAE,IAAI,KAAK,kCAAe,CAAC,YAAY,EAAE,CAAC;YACjD,OAAO,oCAAiB,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,OAAO,IAAI,oCAAiB,CAAC,gBAAgB,EAAE,CAAC;IAC3D,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAmB,YAA6B,EAAE,MAAoB;QACjF,kFAAkF;QAClF,0BAAwB,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,uDAA0B,EAAE,CAAC,CAAC;QACvF,IAAA,gCAAoB,EAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,IAAI,uCAAkB,CACtC,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,iBAAiB,CACzB,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACvC,OAAO,IAAA,mCAAgB,EAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IACvD,CAAC;CACJ,CAAA;AAxEY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,0BAAc,GAAE;6CAMF,yCAAmB,UAEhB,oCAAiB;GAPtB,wBAAwB,CAwEpC","sourcesContent":["import { assertNotInternalApi, ContextMgr, DocumentDesign } from '@webpieces/core-util';\nimport {\n ApiPrototype,\n buildClientProxy,\n HttpClientRuntime,\n HttpRuntimeKind,\n ReactNativeRuntimeConfigError,\n MobileWebViewRuntimeConfigError,\n} from '@webpieces/http-client-core';\nimport { BrowserProxyClient } from './BrowserProxyClient';\nimport { ClientConfig } from './ClientConfig';\nimport { MutableContextStore } from './MutableContextStore';\nimport { RequestLifecycleListener } from './RequestLifecycleListener';\nimport { ReactNativeRuntimeDetector } from './ReactNativeRuntimeDetector';\n\n/**\n * ClientHttpBrowserFactory - builds type-safe HTTP clients for a BROWSER from API prototypes\n * carrying @ApiPath/@Endpoint decorators.\n *\n * Deliberately a plain class with NO decorators and NO inversify: this package may be bundled by\n * React just as easily as by Angular, and neither should be forced to adopt a Node DI container.\n * The app provides it through whatever DI it already has — Angular's `useFactory`, a React context,\n * or a module-level `const`.\n *\n * The factory holds the ONE collaborator every browser client shares (the app's\n * {@link MutableContextStore}); each {@link ClientConfig} holds only that one client's base URL.\n *\n * ```typescript\n * // once, at startup (after HeaderRegistry.configure(...)):\n * const store = new MutableContextStore();\n * const factory = new ClientHttpBrowserFactory(store);\n *\n * const saveApi = factory.createRpcClient(SaveApi, new ClientConfig('server', ClientRole.END_USER_CLIENT));\n * const response = await saveApi.save({ query: 'test' }); // type-safe\n *\n * // later, when the user logs in / picks a tenant — every subsequent call carries them:\n * store.set(AppHeaders.AUTHORIZATION, token); // an app-defined key, if it wants auto-attach\n * store.set(CompanyHeaders.TENANT_ID, tenantId);\n * ```\n *\n * A browser cannot hold service credentials, so a contract with an oidcSameProject() / oidcSvcs(...) or sharedSecret(...)\n * endpoint throws in `createRpcClient`, not on the first call.\n *\n * **Runtime (#1445).** The optional third argument is this factory's {@link HttpClientRuntime}: the\n * fetch every client it builds sends through and the clock their deadlines use. Omitted, a\n * standalone browser gets the platform fetch and JS timers. In the React Native JS\n * runtime (detected by `navigator.product === 'ReactNative'`) omitting it — or passing\n * `HttpClientRuntime.platformDefaults()` — THROWS {@link ReactNativeRuntimeConfigError} here, before\n * any request, because React Native's default fetch and JS timers can stop while a phone is locked:\n *\n * ```typescript\n * import { fetch as expoFetch } from 'expo/fetch';\n * const factory = new ClientHttpBrowserFactory(\n * store,\n * listener,\n * HttpClientRuntime.reactNative(expoFetch, nativeDeadlineScheduler),\n * );\n * ```\n */\n@DocumentDesign()\nexport class ClientHttpBrowserFactory {\n private readonly contextMgr: ContextMgr;\n private readonly runtime: HttpClientRuntime;\n\n constructor(\n store: MutableContextStore,\n private readonly lifecycleListener?: RequestLifecycleListener,\n runtime?: HttpClientRuntime,\n ) {\n this.contextMgr = new ContextMgr(store);\n this.runtime = ClientHttpBrowserFactory.selectRuntime(\n runtime,\n new ReactNativeRuntimeDetector(),\n );\n }\n\n /**\n * The supplied runtime, else the platform defaults — unless this is the React Native JS runtime,\n * where only an explicit {@link HttpClientRuntime.reactNative} is accepted. An embedded RN\n * WebView separately requires {@link HttpClientRuntime.mobileWebView} and shell capabilities.\n */\n // webpieces-disable no-function-outside-class -- pure construction-time selection\n private static selectRuntime(\n runtime: HttpClientRuntime | undefined,\n detector: ReactNativeRuntimeDetector,\n ): HttpClientRuntime {\n if (runtime?.kind !== HttpRuntimeKind.REACT_NATIVE && detector.isReactNative()) {\n throw new ReactNativeRuntimeConfigError(\n ['fetch', 'deadlines'],\n 'new ClientHttpBrowserFactory(...)',\n );\n }\n if (runtime?.kind !== HttpRuntimeKind.MOBILE_WEBVIEW && detector.isWebView()) {\n throw new MobileWebViewRuntimeConfigError([\n 'declared shell host',\n 'nativeHttp',\n 'nativeDeadlines',\n 'nativeCancellation',\n ]);\n }\n // Revalidate at the library boundary too: untyped callers can assemble a runtime object\n // without ever calling its named constructor. A kind/marker alone is not a capability.\n if (runtime?.kind === HttpRuntimeKind.MOBILE_WEBVIEW) {\n if (!runtime.host) {\n throw new MobileWebViewRuntimeConfigError(['shell host capabilities']);\n }\n return HttpClientRuntime.mobileWebView(runtime.fetch, runtime.deadlines, runtime.host);\n }\n if (runtime?.kind === HttpRuntimeKind.REACT_NATIVE) {\n return HttpClientRuntime.reactNative(runtime.fetch, runtime.deadlines);\n }\n return runtime ?? HttpClientRuntime.platformDefaults();\n }\n\n /**\n * Create a type-safe HTTP client for one API contract.\n *\n * @param apiPrototype - The API prototype class with @ApiPath/@Endpoint decorators\n * @param config - This client's state (its baseUrl)\n */\n createRpcClient<T extends object>(apiPrototype: ApiPrototype<T>, config: ClientConfig): T {\n // Also catch a shell marker installed after the factory, before binding a client.\n ClientHttpBrowserFactory.selectRuntime(this.runtime, new ReactNativeRuntimeDetector());\n assertNotInternalApi(apiPrototype, 'ClientHttpBrowserFactory');\n const proxyClient = new BrowserProxyClient(\n this.contextMgr,\n this.runtime,\n this.lifecycleListener,\n );\n proxyClient.init(apiPrototype, config);\n return buildClientProxy(apiPrototype, proxyClient);\n }\n}\n"]}
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* `Libraries/Core/setUpNavigator.js` (verified on 0.83.10). Deliberately NOT used:
|
|
6
6
|
* - `window` / `document` presence — React Native defines window-like globals, and a WebView page's
|
|
7
7
|
* JavaScript has a real `window`; neither tells the two apart.
|
|
8
|
-
* - `window.ReactNativeWebView` — present in a WebView PAGE, which runs on the browser engine's fetch
|
|
9
|
-
* and timers and must keep the browser defaults.
|
|
10
8
|
* - the user agent, or importing `react-native` — this package must stay importable without it.
|
|
11
9
|
*
|
|
10
|
+
* `isWebView()` separately recognizes the generic RN WebView hint. It triggers fail-closed
|
|
11
|
+
* configuration, never claims Expo or native capabilities. Shells without that hint must explicitly
|
|
12
|
+
* supply HttpClientRuntime.mobileWebView(...) before constructing factories.
|
|
13
|
+
*
|
|
12
14
|
* Reads are guarded so Node, SSR, workers and tests (no `navigator`, or one without `product`) are
|
|
13
15
|
* simply "not React Native". A runtime that hides this marker is covered by declaring it explicitly
|
|
14
16
|
* with `HttpClientRuntime.reactNative(...)`.
|
|
@@ -16,4 +18,5 @@
|
|
|
16
18
|
export declare class ReactNativeRuntimeDetector {
|
|
17
19
|
static readonly REACT_NATIVE_PRODUCT = "ReactNative";
|
|
18
20
|
isReactNative(): boolean;
|
|
21
|
+
isWebView(): boolean;
|
|
19
22
|
}
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReactNativeRuntimeDetector = void 0;
|
|
4
|
+
/** Only the fields used for environment hints; no DOM or RN dependency. */
|
|
5
|
+
class NavigatorProduct {
|
|
6
|
+
product;
|
|
7
|
+
}
|
|
8
|
+
class WebViewBridge {
|
|
9
|
+
postMessage;
|
|
10
|
+
}
|
|
11
|
+
class WebViewWindow {
|
|
12
|
+
ReactNativeWebView;
|
|
13
|
+
}
|
|
14
|
+
/** These globals may be absent in Node, SSR and workers. */
|
|
15
|
+
class GlobalWithNavigator {
|
|
16
|
+
navigator;
|
|
17
|
+
ReactNativeWebView;
|
|
18
|
+
window;
|
|
19
|
+
}
|
|
4
20
|
/**
|
|
5
21
|
* Recognizes the React Native JAVASCRIPT runtime (#1445) — not "a page embedded in a WebView".
|
|
6
22
|
*
|
|
@@ -8,10 +24,12 @@ exports.ReactNativeRuntimeDetector = void 0;
|
|
|
8
24
|
* `Libraries/Core/setUpNavigator.js` (verified on 0.83.10). Deliberately NOT used:
|
|
9
25
|
* - `window` / `document` presence — React Native defines window-like globals, and a WebView page's
|
|
10
26
|
* JavaScript has a real `window`; neither tells the two apart.
|
|
11
|
-
* - `window.ReactNativeWebView` — present in a WebView PAGE, which runs on the browser engine's fetch
|
|
12
|
-
* and timers and must keep the browser defaults.
|
|
13
27
|
* - the user agent, or importing `react-native` — this package must stay importable without it.
|
|
14
28
|
*
|
|
29
|
+
* `isWebView()` separately recognizes the generic RN WebView hint. It triggers fail-closed
|
|
30
|
+
* configuration, never claims Expo or native capabilities. Shells without that hint must explicitly
|
|
31
|
+
* supply HttpClientRuntime.mobileWebView(...) before constructing factories.
|
|
32
|
+
*
|
|
15
33
|
* Reads are guarded so Node, SSR, workers and tests (no `navigator`, or one without `product`) are
|
|
16
34
|
* simply "not React Native". A runtime that hides this marker is covered by declaring it explicitly
|
|
17
35
|
* with `HttpClientRuntime.reactNative(...)`.
|
|
@@ -26,6 +44,13 @@ class ReactNativeRuntimeDetector {
|
|
|
26
44
|
return false;
|
|
27
45
|
return navigator.product === ReactNativeRuntimeDetector.REACT_NATIVE_PRODUCT;
|
|
28
46
|
}
|
|
47
|
+
isWebView() {
|
|
48
|
+
if (typeof globalThis === 'undefined')
|
|
49
|
+
return false;
|
|
50
|
+
const globals = globalThis;
|
|
51
|
+
return (typeof globals.ReactNativeWebView?.postMessage === 'function' ||
|
|
52
|
+
typeof globals.window?.ReactNativeWebView?.postMessage === 'function');
|
|
53
|
+
}
|
|
29
54
|
}
|
|
30
55
|
exports.ReactNativeRuntimeDetector = ReactNativeRuntimeDetector;
|
|
31
56
|
//# sourceMappingURL=ReactNativeRuntimeDetector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeRuntimeDetector.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ReactNativeRuntimeDetector.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ReactNativeRuntimeDetector.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/ReactNativeRuntimeDetector.ts"],"names":[],"mappings":";;;AAAA,2EAA2E;AAC3E,MAAM,gBAAgB;IACT,OAAO,CAAU;CAC7B;AAED,MAAM,aAAa;IACN,WAAW,CAA6B;CACpD;AAED,MAAM,aAAa;IACN,kBAAkB,CAAwB;CACtD;AAED,4DAA4D;AAC5D,MAAM,mBAAmB;IACZ,SAAS,CAA2B;IACpC,kBAAkB,CAAwB;IAC1C,MAAM,CAAwB;CAC1C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,0BAA0B;IACnC,MAAM,CAAU,oBAAoB,GAAG,aAAa,CAAC;IAErD,aAAa;QACT,IAAI,OAAO,UAAU,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QACpD,MAAM,SAAS,GAAI,UAAkC,CAAC,SAAS,CAAC;QAChE,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACtE,OAAO,SAAS,CAAC,OAAO,KAAK,0BAA0B,CAAC,oBAAoB,CAAC;IACjF,CAAC;IAED,SAAS;QACL,IAAI,OAAO,UAAU,KAAK,WAAW;YAAE,OAAO,KAAK,CAAC;QACpD,MAAM,OAAO,GAAG,UAAiC,CAAC;QAClD,OAAO,CACH,OAAO,OAAO,CAAC,kBAAkB,EAAE,WAAW,KAAK,UAAU;YAC7D,OAAO,OAAO,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,KAAK,UAAU,CACxE,CAAC;IACN,CAAC;;AAjBL,gEAkBC","sourcesContent":["/** Only the fields used for environment hints; no DOM or RN dependency. */\nclass NavigatorProduct {\n readonly product?: string;\n}\n\nclass WebViewBridge {\n readonly postMessage?: (message: string) => void;\n}\n\nclass WebViewWindow {\n readonly ReactNativeWebView?: WebViewBridge | null;\n}\n\n/** These globals may be absent in Node, SSR and workers. */\nclass GlobalWithNavigator {\n readonly navigator?: NavigatorProduct | null;\n readonly ReactNativeWebView?: WebViewBridge | null;\n readonly window?: WebViewWindow | null;\n}\n\n/**\n * Recognizes the React Native JAVASCRIPT runtime (#1445) — not \"a page embedded in a WebView\".\n *\n * The signal is `navigator.product === 'ReactNative'`, which React Native sets in\n * `Libraries/Core/setUpNavigator.js` (verified on 0.83.10). Deliberately NOT used:\n * - `window` / `document` presence — React Native defines window-like globals, and a WebView page's\n * JavaScript has a real `window`; neither tells the two apart.\n * - the user agent, or importing `react-native` — this package must stay importable without it.\n *\n * `isWebView()` separately recognizes the generic RN WebView hint. It triggers fail-closed\n * configuration, never claims Expo or native capabilities. Shells without that hint must explicitly\n * supply HttpClientRuntime.mobileWebView(...) before constructing factories.\n *\n * Reads are guarded so Node, SSR, workers and tests (no `navigator`, or one without `product`) are\n * simply \"not React Native\". A runtime that hides this marker is covered by declaring it explicitly\n * with `HttpClientRuntime.reactNative(...)`.\n */\nexport class ReactNativeRuntimeDetector {\n static readonly REACT_NATIVE_PRODUCT = 'ReactNative';\n\n isReactNative(): boolean {\n if (typeof globalThis === 'undefined') return false;\n const navigator = (globalThis as GlobalWithNavigator).navigator;\n if (typeof navigator !== 'object' || navigator === null) return false;\n return navigator.product === ReactNativeRuntimeDetector.REACT_NATIVE_PRODUCT;\n }\n\n isWebView(): boolean {\n if (typeof globalThis === 'undefined') return false;\n const globals = globalThis as GlobalWithNavigator;\n return (\n typeof globals.ReactNativeWebView?.postMessage === 'function' ||\n typeof globals.window?.ReactNativeWebView?.postMessage === 'function'\n );\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export { ServiceWorkerSyntheticResponse, ServiceWorkerSyntheticResponseError, }
|
|
|
32
32
|
export { MutableContextStore } from './MutableContextStore';
|
|
33
33
|
export type { RequestLifecycleListener } from './RequestLifecycleListener';
|
|
34
34
|
export { ProxyClient, ClientErrorTranslator, RequestOutcome } from '@webpieces/http-client-core';
|
|
35
|
-
export { HttpClientRuntime, HttpFetchInit, HttpRuntimeKind, ReactNativeRuntimeConfigError, } from '@webpieces/http-client-core';
|
|
35
|
+
export { HttpClientRuntime, HttpFetchInit, HttpRuntimeKind, ReactNativeRuntimeConfigError, MobileWebViewHost, MobileWebViewRuntimeConfigError, } from '@webpieces/http-client-core';
|
|
36
36
|
export type { HttpFetch } from '@webpieces/http-client-core';
|
|
37
37
|
export { TimerDeadlineScheduler } from '@webpieces/core-util';
|
|
38
38
|
export type { DeadlineScheduler, DeadlineTimer } from '@webpieces/core-util';
|
|
@@ -46,6 +46,6 @@ export type { Wiring, AppWiring, BindModule } from './Wiring';
|
|
|
46
46
|
export { Binder, ClientBindOptions, BrowserWiringProviders } from './Wiring';
|
|
47
47
|
export { ExternalImpl, UseClass, UseExisting } from './ExternalImpl';
|
|
48
48
|
export type { ExternalClassType, ExternalExistingType } from './ExternalImpl';
|
|
49
|
-
export { BrowserValueProvider, BrowserClassProvider, BrowserExistingProvider, BrowserFactoryProvider } from './BrowserProviders';
|
|
49
|
+
export { BrowserValueProvider, BrowserClassProvider, BrowserExistingProvider, BrowserFactoryProvider, } from './BrowserProviders';
|
|
50
50
|
export type { BrowserProvider, BrowserToken, BrowserType } from './BrowserProviders';
|
|
51
51
|
export { WiringPolicy } from '@webpieces/http-client-core';
|
package/src/index.js
CHANGED
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
* The server twin is @webpieces/http-client-node.
|
|
26
26
|
*/
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
29
|
-
exports.WiringPolicy = exports.BrowserFactoryProvider = exports.BrowserExistingProvider = exports.BrowserClassProvider = exports.BrowserValueProvider = exports.UseExisting = exports.UseClass = void 0;
|
|
28
|
+
exports.ClientBindOptions = exports.Binder = exports.Queue = exports.PubSub = exports.Rpc = exports.apiKey = exports.vendorAuth = exports.sharedSecret = exports.oidcSvcs = exports.oidcSameProject = exports.jwt = exports.WpLocalOnly = exports.AuthorizationType = exports.WpAuthorization = exports.WpAuth = exports.WpAuthPublic = exports.QueryParams = exports.QueryString = exports.QueryParam = exports.PathParam = exports.Endpoint = exports.ApiPath = exports.WebpiecesCoreHeaders = exports.templateDeriver = exports.CallModeMarker = exports.CallMode = exports.ClientRole = exports.ClientRegistry = exports.HeaderRegistry = exports.ContextKey = exports.ContextMgr = exports.StreamingCapabilityError = exports.TimerDeadlineScheduler = exports.MobileWebViewRuntimeConfigError = exports.MobileWebViewHost = exports.ReactNativeRuntimeConfigError = exports.HttpRuntimeKind = exports.HttpFetchInit = exports.HttpClientRuntime = exports.RequestOutcome = exports.ClientErrorTranslator = exports.ProxyClient = exports.MutableContextStore = exports.ServiceWorkerSyntheticResponseError = exports.ServiceWorkerSyntheticResponse = exports.ServiceWorkerRouting = exports.ClientConfig = exports.BrowserApiCallContext = exports.BrowserProxyClient = exports.ClientHttpBrowserFactory = void 0;
|
|
29
|
+
exports.WiringPolicy = exports.BrowserFactoryProvider = exports.BrowserExistingProvider = exports.BrowserClassProvider = exports.BrowserValueProvider = exports.UseExisting = exports.UseClass = exports.ExternalImpl = exports.BrowserWiringProviders = void 0;
|
|
30
30
|
var ClientHttpBrowserFactory_1 = require("./ClientHttpBrowserFactory");
|
|
31
31
|
Object.defineProperty(exports, "ClientHttpBrowserFactory", { enumerable: true, get: function () { return ClientHttpBrowserFactory_1.ClientHttpBrowserFactory; } });
|
|
32
32
|
var BrowserProxyClient_1 = require("./BrowserProxyClient");
|
|
@@ -57,6 +57,8 @@ Object.defineProperty(exports, "HttpClientRuntime", { enumerable: true, get: fun
|
|
|
57
57
|
Object.defineProperty(exports, "HttpFetchInit", { enumerable: true, get: function () { return http_client_core_2.HttpFetchInit; } });
|
|
58
58
|
Object.defineProperty(exports, "HttpRuntimeKind", { enumerable: true, get: function () { return http_client_core_2.HttpRuntimeKind; } });
|
|
59
59
|
Object.defineProperty(exports, "ReactNativeRuntimeConfigError", { enumerable: true, get: function () { return http_client_core_2.ReactNativeRuntimeConfigError; } });
|
|
60
|
+
Object.defineProperty(exports, "MobileWebViewHost", { enumerable: true, get: function () { return http_client_core_2.MobileWebViewHost; } });
|
|
61
|
+
Object.defineProperty(exports, "MobileWebViewRuntimeConfigError", { enumerable: true, get: function () { return http_client_core_2.MobileWebViewRuntimeConfigError; } });
|
|
60
62
|
var core_util_1 = require("@webpieces/core-util");
|
|
61
63
|
Object.defineProperty(exports, "TimerDeadlineScheduler", { enumerable: true, get: function () { return core_util_1.TimerDeadlineScheduler; } });
|
|
62
64
|
var http_client_core_3 = require("@webpieces/http-client-core");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;AAEH,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,4FAA4F;AAC5F,kGAAkG;AAClG,8BAA8B;AAC9B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,kFAAkF;AAClF,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,mFAG0C;AAFtC,gJAAA,8BAA8B,OAAA;AAC9B,qJAAA,mCAAmC,OAAA;AAEvC,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiG;AAAxF,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,kHAAA,cAAc,OAAA;AAC3D,yGAAyG;AACzG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-client-browser/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;AAEH,uEAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA;AAC3B,4FAA4F;AAC5F,kGAAkG;AAClG,8BAA8B;AAC9B,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AACrB,kFAAkF;AAClF,+DAA8D;AAArD,4HAAA,oBAAoB,OAAA;AAC7B,mFAG0C;AAFtC,gJAAA,8BAA8B,OAAA;AAC9B,qJAAA,mCAAmC,OAAA;AAEvC,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAG5B,wEAAwE;AACxE,gEAAiG;AAAxF,+GAAA,WAAW,OAAA;AAAE,yHAAA,qBAAqB,OAAA;AAAE,kHAAA,cAAc,OAAA;AAC3D,yGAAyG;AACzG,gEAOqC;AANjC,qHAAA,iBAAiB,OAAA;AACjB,iHAAA,aAAa,OAAA;AACb,mHAAA,eAAe,OAAA;AACf,iIAAA,6BAA6B,OAAA;AAC7B,qHAAA,iBAAiB,OAAA;AACjB,mIAAA,+BAA+B,OAAA;AAGnC,kDAA8D;AAArD,mHAAA,sBAAsB,OAAA;AAG/B,gEAAuE;AAA9D,4HAAA,wBAAwB,OAAA;AAEjC,iGAAiG;AACjG,mGAAmG;AACnG,kDAAkD;AAAzC,uGAAA,UAAU,OAAA;AAEnB,yFAAyF;AACzF,kDAY8B;AAR1B,uGAAA,UAAU,OAAA;AACV,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,uGAAA,UAAU,OAAA;AACV,qGAAA,QAAQ,OAAA;AACR,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,iHAAA,oBAAoB,OAAA;AAIxB,uEAAuE;AACvE,kDAsB8B;AArB1B,oGAAA,OAAO,OAAA;AACP,qGAAA,QAAQ,OAAA;AACR,sGAAA,SAAS,OAAA;AACT,uGAAA,UAAU,OAAA;AACV,wGAAA,WAAW,OAAA;AACX,wGAAA,WAAW,OAAA;AACX,yGAAA,YAAY,OAAA;AACZ,mGAAA,MAAM,OAAA;AACN,4GAAA,eAAe,OAAA;AACf,8GAAA,iBAAiB,OAAA;AACjB,wGAAA,WAAW,OAAA;AACX,gGAAA,GAAG,OAAA;AACH,4GAAA,eAAe,OAAA;AACf,qGAAA,QAAQ,OAAA;AACR,yGAAA,YAAY,OAAA;AACZ,uGAAA,UAAU,OAAA;AACV,mGAAA,MAAM,OAAA;AACN,gGAAA,GAAG,OAAA;AACH,mGAAA,MAAM,OAAA;AACN,kGAAA,KAAK,OAAA;AAOT,mCAA6E;AAApE,gGAAA,MAAM,OAAA;AAAE,2GAAA,iBAAiB,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAC1D,+CAAqE;AAA5D,4GAAA,YAAY,OAAA;AAAE,wGAAA,QAAQ,OAAA;AAAE,2GAAA,WAAW,OAAA;AAE5C,uDAK4B;AAJxB,wHAAA,oBAAoB,OAAA;AACpB,wHAAA,oBAAoB,OAAA;AACpB,2HAAA,uBAAuB,OAAA;AACvB,0HAAA,sBAAsB,OAAA;AAI1B,gEAA2D;AAAlD,gHAAA,YAAY,OAAA","sourcesContent":["/**\n * @webpieces/http-client-browser\n *\n * The BROWSER HTTP client. Reads an API contract's decorators and generates type-safe HTTP\n * clients from it — the same contract the server implements.\n *\n * DI-free on purpose: this may be bundled by React or Angular, so it ships no inversify and no\n * @webpieces/core-context (which is AsyncLocalStorage-backed and Node-only). Browsers have no\n * ambient request scope, so the app holds a {@link MutableContextStore} and sets context values\n * as they become known; every outbound call then transfers them as headers.\n *\n * Usage:\n * ```typescript\n * import { ClientHttpBrowserFactory, ClientConfig, MutableContextStore } from '@webpieces/http-client-browser';\n *\n * HeaderRegistry.configure(CompanyHeaders.ALL_HEADERS, true);\n * const store = new MutableContextStore();\n * const factory = new ClientHttpBrowserFactory(store);\n *\n * const client = factory.createRpcClient(SaveApi, new ClientConfig('save-svc', ClientRole.END_USER_CLIENT));\n * const response = await client.save({ query: 'test' });\n * ```\n *\n * The server twin is @webpieces/http-client-node.\n */\n\nexport { ClientHttpBrowserFactory } from './ClientHttpBrowserFactory';\nexport { BrowserProxyClient } from './BrowserProxyClient';\n// Browser impl of the ApiCallContext seam, constructed by BrowserProxyClient. Exported so a\n// browser/Angular logger can read the current tag via the STATIC BrowserApiCallContext.snapshot()\n// and fold it into log lines.\nexport { BrowserApiCallContext } from './BrowserApiCallContext';\nexport { ClientConfig } from './ClientConfig';\n// #1293: service-worker routing for every RPC, and ngsw's synthetic-504 fallback.\nexport { ServiceWorkerRouting } from './ServiceWorkerRouting';\nexport {\n ServiceWorkerSyntheticResponse,\n ServiceWorkerSyntheticResponseError,\n} from './ServiceWorkerSyntheticResponse';\nexport { MutableContextStore } from './MutableContextStore';\nexport type { RequestLifecycleListener } from './RequestLifecycleListener';\n\n// The isomorphic engine, re-exported so a browser app needs one import.\nexport { ProxyClient, ClientErrorTranslator, RequestOutcome } from '@webpieces/http-client-core';\n// #1445: the factory's runtime collaborator — injected fetch + deadline clock, required in React Native.\nexport {\n HttpClientRuntime,\n HttpFetchInit,\n HttpRuntimeKind,\n ReactNativeRuntimeConfigError,\n MobileWebViewHost,\n MobileWebViewRuntimeConfigError,\n} from '@webpieces/http-client-core';\nexport type { HttpFetch } from '@webpieces/http-client-core';\nexport { TimerDeadlineScheduler } from '@webpieces/core-util';\nexport type { DeadlineScheduler, DeadlineTimer } from '@webpieces/core-util';\nexport type { ApiPrototype } from '@webpieces/http-client-core';\nexport { StreamingCapabilityError } from '@webpieces/http-client-core';\n\n// ContextMgr is the BROWSER's outbound-header propagation. This is the only package that may use\n// it; the server reads RequestContext directly (RequestContextHeaders in @webpieces/core-context).\nexport { ContextMgr } from '@webpieces/core-util';\n\n// Re-export the context-key contract from core-util for convenience (browser one-import)\nexport {\n ContextReader,\n ContextWriter,\n ContextStore,\n ContextKey,\n HeaderRegistry,\n ClientRegistry,\n ClientRole,\n CallMode,\n CallModeMarker,\n templateDeriver,\n WebpiecesCoreHeaders,\n} from '@webpieces/core-util';\nexport type { ServiceUrlDeriver } from '@webpieces/core-util';\n\n// Re-export API decorators for convenience (same as http-routing does)\nexport {\n ApiPath,\n Endpoint,\n PathParam,\n QueryParam,\n QueryString,\n QueryParams,\n WpAuthPublic,\n WpAuth,\n WpAuthorization,\n AuthorizationType,\n WpLocalOnly,\n jwt,\n oidcSameProject,\n oidcSvcs,\n sharedSecret,\n vendorAuth,\n apiKey,\n Rpc,\n PubSub,\n Queue,\n ValidateImplementation,\n} from '@webpieces/core-util';\n\n// The browser host's wiring: bind modules only (no route channel), the Binder they configure, and\n// the ExternalImpl recipes (UseClass / UseExisting) Binder.bindExternal takes.\nexport type { Wiring, AppWiring, BindModule } from './Wiring';\nexport { Binder, ClientBindOptions, BrowserWiringProviders } from './Wiring';\nexport { ExternalImpl, UseClass, UseExisting } from './ExternalImpl';\nexport type { ExternalClassType, ExternalExistingType } from './ExternalImpl';\nexport {\n BrowserValueProvider,\n BrowserClassProvider,\n BrowserExistingProvider,\n BrowserFactoryProvider,\n} from './BrowserProviders';\nexport type { BrowserProvider, BrowserToken, BrowserType } from './BrowserProviders';\n\nexport { WiringPolicy } from '@webpieces/http-client-core';\n"]}
|