@ng-desktop/http 0.3.0 → 0.4.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/README.md +35 -8
- package/fesm2022/http-backend.d.ts +0 -1
- package/fesm2022/http-backend.js +43 -20
- package/fesm2022/http-resource.d.ts +2 -2
- package/fesm2022/http-resource.js +63 -22
- package/fesm2022/index.d.ts +0 -1
- package/fesm2022/index.js +0 -1
- package/package.json +4 -3
- package/fesm2022/http-backend.d.ts.map +0 -1
- package/fesm2022/http-backend.js.map +0 -1
- package/fesm2022/http-resource.d.ts.map +0 -1
- package/fesm2022/http-resource.js.map +0 -1
- package/fesm2022/index.d.ts.map +0 -1
- package/fesm2022/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ng-desktop/http`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OS-native HTTP/2 backend (`NativeHttpBackend`) and reactive `createNativeHttpResource()` implementing `@angular/common/http` (`provideHttpClient`, interceptors, caching, parallel batching, and XSRF configuration) over Rust native transport (`libsoup-3.0` on Linux).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
5
|
+
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
pnpm add @ng-desktop/http
|
|
8
|
+
pnpm add @ng-desktop/http @ng-desktop/platform
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
Peer dependencies: `@angular/core >= 22.0.0`, `@angular/common >= 22.0.0`, `@ng-desktop/platform`.
|
|
12
|
+
|
|
13
|
+
## Quick Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { ApplicationConfig } from '@angular/core';
|
|
17
|
+
import { provideHttpClient, withFetch, withXsrfConfiguration } from '@ng-desktop/http';
|
|
18
|
+
|
|
19
|
+
export const appConfig: ApplicationConfig = {
|
|
20
|
+
providers: [
|
|
21
|
+
provideHttpClient(
|
|
22
|
+
withFetch(),
|
|
23
|
+
withXsrfConfiguration({
|
|
24
|
+
cookieName: 'XSRF-TOKEN',
|
|
25
|
+
headerName: 'X-XSRF-TOKEN',
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Key Exports
|
|
33
|
+
|
|
34
|
+
- `provideHttpClient`, `provideNativeHttpClient`, `NativeHttpBackend`
|
|
35
|
+
- `withFetch`, `withInterceptors`, `withInterceptorsFromDi`, `withHttpCaching`, `withParallelBatching`, `withXsrfConfiguration`, `withNoXsrfProtection`, `withNativeHttpConfig`
|
|
36
|
+
- `createNativeHttpResource`, `NATIVE_HTTP_CONFIG`, `resolveNativeHttpConfig`
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
- [Getting Started with External Angular 22+ & Nx Apps](../../docs/GETTING_STARTED.md)
|
|
41
|
+
- [Architectural Roadmap & OS Maturity Matrix](../../ROADMAP.md)
|
package/fesm2022/http-backend.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpBackend, HttpErrorResponse, HttpFeatureKind, HttpHeaders, HttpResponse, provideHttpClient as angularProvideHttpClient, withFetch, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXhr, withXsrfConfiguration, } from '@angular/common/http';
|
|
2
2
|
import { Injectable, InjectionToken, makeEnvironmentProviders, } from '@angular/core';
|
|
3
|
-
import { ensureNgNativeBridge } from '@ng-desktop/platform';
|
|
3
|
+
import { ensureNgNativeBridge, } from '@ng-desktop/platform';
|
|
4
4
|
import { Observable } from 'rxjs';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export { HttpFeatureKind, withFetch, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNoXsrfProtection, withRequestsMadeViaParent, withXhr, withXsrfConfiguration, };
|
|
@@ -170,21 +170,11 @@ function extractRequestHeaders(req) {
|
|
|
170
170
|
export class NativeHttpBackend {
|
|
171
171
|
handle(req) {
|
|
172
172
|
return new Observable((observer) => {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
: typeof serializedBody === 'string'
|
|
179
|
-
? serializedBody
|
|
180
|
-
: JSON.stringify(serializedBody);
|
|
181
|
-
const callKind = detectNativeCallKind(req);
|
|
182
|
-
const rawRes = bridge.httpRequest(req.method, req.urlWithParams, bodyStr, {
|
|
183
|
-
headers: extractRequestHeaders(req),
|
|
184
|
-
responseType: req.responseType,
|
|
185
|
-
callKind,
|
|
186
|
-
withCredentials: req.withCredentials,
|
|
187
|
-
});
|
|
173
|
+
let cancelled = false;
|
|
174
|
+
const emitResponse = (rawRes) => {
|
|
175
|
+
if (cancelled) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
188
178
|
let parsedBody = rawRes.body;
|
|
189
179
|
if (req.responseType === 'json' && rawRes.body.length > 0) {
|
|
190
180
|
try {
|
|
@@ -220,16 +210,50 @@ export class NativeHttpBackend {
|
|
|
220
210
|
url: req.urlWithParams,
|
|
221
211
|
}));
|
|
222
212
|
}
|
|
213
|
+
};
|
|
214
|
+
try {
|
|
215
|
+
const bridge = ensureNgNativeBridge();
|
|
216
|
+
const serializedBody = req.serializeBody();
|
|
217
|
+
const bodyStr = serializedBody === null || serializedBody === undefined
|
|
218
|
+
? undefined
|
|
219
|
+
: typeof serializedBody === 'string'
|
|
220
|
+
? serializedBody
|
|
221
|
+
: JSON.stringify(serializedBody);
|
|
222
|
+
const callKind = detectNativeCallKind(req);
|
|
223
|
+
const options = {
|
|
224
|
+
headers: extractRequestHeaders(req),
|
|
225
|
+
responseType: req.responseType,
|
|
226
|
+
callKind,
|
|
227
|
+
withCredentials: req.withCredentials,
|
|
228
|
+
};
|
|
229
|
+
const hasHostService = typeof globalThis
|
|
230
|
+
.__NG_NATIVE_HOST_SERVICE__ === 'function';
|
|
231
|
+
if (hasHostService && typeof bridge.httpRequestAsync === 'function') {
|
|
232
|
+
bridge
|
|
233
|
+
.httpRequestAsync(req.method, req.urlWithParams, bodyStr, options)
|
|
234
|
+
.then(emitResponse)
|
|
235
|
+
.catch((err) => {
|
|
236
|
+
if (!cancelled) {
|
|
237
|
+
observer.error(err);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
return () => {
|
|
241
|
+
cancelled = true;
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
const rawRes = bridge.httpRequest(req.method, req.urlWithParams, bodyStr, options);
|
|
245
|
+
emitResponse(rawRes);
|
|
223
246
|
}
|
|
224
247
|
catch (err) {
|
|
225
248
|
observer.error(err);
|
|
226
249
|
}
|
|
250
|
+
return undefined;
|
|
227
251
|
});
|
|
228
252
|
}
|
|
229
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
230
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
253
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeHttpBackend, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
254
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeHttpBackend, providedIn: 'root' });
|
|
231
255
|
}
|
|
232
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
256
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeHttpBackend, decorators: [{
|
|
233
257
|
type: Injectable,
|
|
234
258
|
args: [{ providedIn: 'root' }]
|
|
235
259
|
}] });
|
|
@@ -259,4 +283,3 @@ export function provideHttpClient(...features) {
|
|
|
259
283
|
* Backward-compatible alias for `provideHttpClient(...)`.
|
|
260
284
|
*/
|
|
261
285
|
export const provideNativeHttpClient = provideHttpClient;
|
|
262
|
-
//# sourceMappingURL=http-backend.js.map
|
|
@@ -14,10 +14,10 @@ export interface NativeHttpResourceRef<T> {
|
|
|
14
14
|
readonly isLoading: Signal<boolean>;
|
|
15
15
|
readonly hasValue: Signal<boolean>;
|
|
16
16
|
reload(): boolean;
|
|
17
|
+
reloadAsync(): Promise<boolean>;
|
|
17
18
|
}
|
|
18
19
|
/**
|
|
19
20
|
* Signal-based reactive HTTP resource backed by the OS-native Rust HTTP bridge (`ensureNgNativeBridge()`).
|
|
20
|
-
* Mirrors Angular's `httpResource()` ergonomics (`value`, `status`, `error`, `isLoading`, `hasValue`, `reload`).
|
|
21
|
+
* Mirrors Angular's `httpResource()` ergonomics (`value`, `status`, `error`, `isLoading`, `hasValue`, `reload`, `reloadAsync`).
|
|
21
22
|
*/
|
|
22
23
|
export declare function createNativeHttpResource<T = unknown>(urlOrFn: string | (() => string | undefined), options?: NativeHttpResourceOptions<T>): NativeHttpResourceRef<T>;
|
|
23
|
-
//# sourceMappingURL=http-resource.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { computed, signal } from '@angular/core';
|
|
2
|
-
import { ensureNgNativeBridge } from '@ng-desktop/platform';
|
|
2
|
+
import { ensureNgNativeBridge, } from '@ng-desktop/platform';
|
|
3
3
|
/**
|
|
4
4
|
* Signal-based reactive HTTP resource backed by the OS-native Rust HTTP bridge (`ensureNgNativeBridge()`).
|
|
5
|
-
* Mirrors Angular's `httpResource()` ergonomics (`value`, `status`, `error`, `isLoading`, `hasValue`, `reload`).
|
|
5
|
+
* Mirrors Angular's `httpResource()` ergonomics (`value`, `status`, `error`, `isLoading`, `hasValue`, `reload`, `reloadAsync`).
|
|
6
6
|
*/
|
|
7
7
|
export function createNativeHttpResource(urlOrFn, options) {
|
|
8
8
|
const resolveUrl = () => {
|
|
@@ -22,39 +22,80 @@ export function createNativeHttpResource(urlOrFn, options) {
|
|
|
22
22
|
...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
23
23
|
const hasValue = computed(() => value() !== undefined, /* @ts-ignore */
|
|
24
24
|
...(ngDevMode ? [{ debugName: "hasValue" }] : /* istanbul ignore next */ []));
|
|
25
|
+
let requestSeq = 0;
|
|
26
|
+
const applyResponse = (targetUrl, res) => {
|
|
27
|
+
if (res.status >= 200 && res.status < 300) {
|
|
28
|
+
const responseType = options?.request?.responseType ?? 'json';
|
|
29
|
+
let parsed = res.body;
|
|
30
|
+
if (responseType === 'json' && typeof res.body === 'string' && res.body.length > 0) {
|
|
31
|
+
parsed = JSON.parse(res.body);
|
|
32
|
+
}
|
|
33
|
+
const finalValue = options?.map ? options.map(parsed) : parsed;
|
|
34
|
+
value.set(finalValue);
|
|
35
|
+
status.set('resolved');
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
error.set({
|
|
39
|
+
status: res.status,
|
|
40
|
+
statusText: res.statusText,
|
|
41
|
+
body: res.body,
|
|
42
|
+
url: targetUrl,
|
|
43
|
+
});
|
|
44
|
+
status.set('error');
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
const resetToIdle = () => {
|
|
48
|
+
status.set('idle');
|
|
49
|
+
error.set(undefined);
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
25
52
|
const reload = () => {
|
|
53
|
+
const seq = ++requestSeq;
|
|
26
54
|
const targetUrl = resolveUrl();
|
|
27
55
|
if (!targetUrl) {
|
|
28
|
-
|
|
29
|
-
error.set(undefined);
|
|
30
|
-
return false;
|
|
56
|
+
return resetToIdle();
|
|
31
57
|
}
|
|
32
58
|
status.set('loading');
|
|
33
59
|
error.set(undefined);
|
|
34
60
|
try {
|
|
35
61
|
const bridge = ensureNgNativeBridge();
|
|
36
62
|
const res = bridge.httpRequest('GET', targetUrl, undefined, options?.request);
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
let parsed = res.body;
|
|
40
|
-
if (responseType === 'json' && typeof res.body === 'string' && res.body.length > 0) {
|
|
41
|
-
parsed = JSON.parse(res.body);
|
|
42
|
-
}
|
|
43
|
-
const finalValue = options?.map ? options.map(parsed) : parsed;
|
|
44
|
-
value.set(finalValue);
|
|
45
|
-
status.set('resolved');
|
|
46
|
-
return true;
|
|
63
|
+
if (seq !== requestSeq) {
|
|
64
|
+
return false;
|
|
47
65
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
66
|
+
return applyResponse(targetUrl, res);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
if (seq !== requestSeq) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
error.set(err);
|
|
54
73
|
status.set('error');
|
|
55
74
|
return false;
|
|
56
75
|
}
|
|
76
|
+
};
|
|
77
|
+
const reloadAsync = async () => {
|
|
78
|
+
const seq = ++requestSeq;
|
|
79
|
+
const targetUrl = resolveUrl();
|
|
80
|
+
if (!targetUrl) {
|
|
81
|
+
return resetToIdle();
|
|
82
|
+
}
|
|
83
|
+
status.set('loading');
|
|
84
|
+
error.set(undefined);
|
|
85
|
+
try {
|
|
86
|
+
const bridge = ensureNgNativeBridge();
|
|
87
|
+
const res = typeof bridge.httpRequestAsync === 'function'
|
|
88
|
+
? await bridge.httpRequestAsync('GET', targetUrl, undefined, options?.request)
|
|
89
|
+
: bridge.httpRequest('GET', targetUrl, undefined, options?.request);
|
|
90
|
+
if (seq !== requestSeq) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return applyResponse(targetUrl, res);
|
|
94
|
+
}
|
|
57
95
|
catch (err) {
|
|
96
|
+
if (seq !== requestSeq) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
58
99
|
error.set(err);
|
|
59
100
|
status.set('error');
|
|
60
101
|
return false;
|
|
@@ -69,6 +110,6 @@ export function createNativeHttpResource(urlOrFn, options) {
|
|
|
69
110
|
isLoading,
|
|
70
111
|
hasValue,
|
|
71
112
|
reload,
|
|
113
|
+
reloadAsync,
|
|
72
114
|
};
|
|
73
115
|
}
|
|
74
|
-
//# sourceMappingURL=http-resource.js.map
|
package/fesm2022/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { detectNativeCallKind, HttpFeatureKind, NATIVE_HTTP_CONFIG, NativeHttpBackend, provideHttpClient, provideNativeHttpClient, resolveNativeHttpConfig, withFetch, withHttpCaching, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNativeHttpConfig, withNoXsrfProtection, withParallelBatching, withRequestsMadeViaParent, withXhr, withXsrfConfiguration, } from './http-backend';
|
|
2
2
|
export { createNativeHttpResource, type NativeHttpResourceOptions, type NativeHttpResourceRef, type NativeResourceStatus, } from './http-resource';
|
|
3
|
-
//# sourceMappingURL=index.d.ts.map
|
package/fesm2022/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { detectNativeCallKind, HttpFeatureKind, NATIVE_HTTP_CONFIG, NativeHttpBackend, provideHttpClient, provideNativeHttpClient, resolveNativeHttpConfig, withFetch, withHttpCaching, withInterceptors, withInterceptorsFromDi, withJsonpSupport, withNativeHttpConfig, withNoXsrfProtection, withParallelBatching, withRequestsMadeViaParent, withXhr, withXsrfConfiguration, } from './http-backend.js';
|
|
2
2
|
export { createNativeHttpResource, } from './http-resource.js';
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-desktop/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Native Angular HttpBackend bridging HttpClient, interceptors, and httpResource() to the Rust host",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"fesm2022",
|
|
32
32
|
"README.md",
|
|
33
|
-
"LICENSE"
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"!**/*.map"
|
|
34
35
|
],
|
|
35
36
|
"main": "./fesm2022/index.js",
|
|
36
37
|
"module": "./fesm2022/index.js",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@angular/common": ">=22.0.0",
|
|
49
50
|
"@angular/core": ">=22.0.0",
|
|
50
|
-
"@ng-desktop/platform": ">=0.
|
|
51
|
+
"@ng-desktop/platform": ">=0.4.0",
|
|
51
52
|
"rxjs": ">=7.8.0"
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-backend.d.ts","sourceRoot":"","sources":["../../../../packages/http-native/src/http-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,SAAS,EACT,WAAW,EACX,eAAe,EAEf,WAAW,EAGX,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EAEpB,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwB,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;;AAElC,OAAO,EACL,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,GACtB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,kCAA6D,CAAC;AA0D7F;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,SAAS,WAAW,CAAC,eAAe,CAAC,EAAE,GAChD,gBAAgB,CAqDlB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAChC,WAAW,CAAC,eAAe,CAAC,CAK9B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,OAAO,GAAG,WAAW,CAAC,eAAe,CAAC,CAEnF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,sBAAsB,EAAE,MAAM,GAAG,WAAW,CAAC,eAAe,CAAC,CAEjG;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,kBAAkB,CA4BlF;AAaD;;;;;GAKG;AACH,qBACa,iBAAkB,YAAW,WAAW;IACnD,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;yCADtD,iBAAiB;;CA8D7B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,QAAQ,EAAE,WAAW,CAAC,eAAe,CAAC,EAAE,GAC1C,oBAAoB,CAmBtB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,0BAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-backend.js","sourceRoot":"","sources":["../../../../packages/http-native/src/http-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EAGjB,eAAe,EACf,WAAW,EAEX,YAAY,EACZ,iBAAiB,IAAI,wBAAwB,EAC7C,SAAS,EACT,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,UAAU,EACV,cAAc,EACd,wBAAwB,GAEzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAwC,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;;AAElC,OAAO,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HttpEvent,\n HttpFeature,\n HttpFeatureKind,\n HttpHeaders,\n HttpRequest,\n HttpResponse,\n provideHttpClient as angularProvideHttpClient,\n withFetch,\n withInterceptors,\n withInterceptorsFromDi,\n withJsonpSupport,\n withNoXsrfProtection,\n withRequestsMadeViaParent,\n withXhr,\n withXsrfConfiguration,\n} from '@angular/common/http';\nimport {\n EnvironmentProviders,\n Injectable,\n InjectionToken,\n makeEnvironmentProviders,\n Provider,\n} from '@angular/core';\nimport { ensureNgNativeBridge, NativeHttpCallKind, NativeHttpConfig } from '@ng-desktop/platform';\nimport { Observable } from 'rxjs';\n\nexport {\n HttpFeatureKind,\n withFetch,\n withInterceptors,\n withInterceptorsFromDi,\n withJsonpSupport,\n withNoXsrfProtection,\n withRequestsMadeViaParent,\n withXhr,\n withXsrfConfiguration,\n};\n\n/**\n * Injection token holding the resolved `NativeHttpConfig` translated from `provideHttpClient(...)` features.\n */\nexport const NATIVE_HTTP_CONFIG = new InjectionToken<NativeHttpConfig>('NATIVE_HTTP_CONFIG');\n\nconst NATIVE_CONFIG_OVERRIDE_TOKEN = new InjectionToken<Partial<NativeHttpConfig>>(\n 'NATIVE_HTTP_CONFIG_OVERRIDE',\n);\n\ninterface InternalHttpFeature {\n ɵkind: HttpFeatureKind;\n ɵproviders?: unknown[];\n}\n\ninterface ValueProviderLike {\n provide?: unknown;\n useValue?: unknown;\n}\n\nfunction isNativeConfigProvider(\n item: unknown,\n): item is { provide: unknown; useValue: Partial<NativeHttpConfig> } {\n return (\n typeof item === 'object' &&\n item !== null &&\n (item as ValueProviderLike).provide === NATIVE_CONFIG_OVERRIDE_TOKEN &&\n typeof (item as ValueProviderLike).useValue === 'object' &&\n (item as ValueProviderLike).useValue !== null\n );\n}\n\nfunction applyXsrfProviders(providers: unknown[] | undefined, config: NativeHttpConfig): void {\n if (!providers) {\n return;\n }\n const stringValues: string[] = [];\n for (const item of providers) {\n if (typeof item !== 'object' || item === null) {\n continue;\n }\n const candidate = item as ValueProviderLike;\n if (typeof candidate.useValue !== 'string') {\n continue;\n }\n const desc = String(candidate.provide ?? '');\n if (desc.includes('XSRF_COOKIE_NAME')) {\n config.xsrfCookieName = candidate.useValue;\n } else if (desc.includes('XSRF_HEADER_NAME')) {\n config.xsrfHeaderName = candidate.useValue;\n } else {\n stringValues.push(candidate.useValue);\n }\n }\n if (stringValues.length >= 1 && config.xsrfCookieName === 'XSRF-TOKEN') {\n config.xsrfCookieName = stringValues[0];\n }\n if (stringValues.length >= 2 && config.xsrfHeaderName === 'X-XSRF-TOKEN') {\n config.xsrfHeaderName = stringValues[1];\n }\n}\n\n/**\n * Translates Angular `HttpFeature` configurations (`withFetch`, `withXsrfConfiguration`,\n * `withNoXsrfProtection`, `withInterceptors`, `withJsonpSupport`, and `@ng-desktop/http` features)\n * into a Rust-compatible `NativeHttpConfig`.\n */\nexport function resolveNativeHttpConfig(\n features: readonly HttpFeature<HttpFeatureKind>[],\n): NativeHttpConfig {\n const config: NativeHttpConfig = {\n useFetchTransport: true,\n interceptorsEnabled: true,\n xsrfEnabled: true,\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n xsrfTokenValue: '',\n jsonpEnabled: false,\n requestsViaParent: false,\n maxParallelConnections: 24,\n cacheEnabled: true,\n timeoutMs: 15_000,\n };\n\n for (const feature of features) {\n const internal = feature as unknown as InternalHttpFeature;\n if (internal.ɵproviders) {\n for (const item of internal.ɵproviders) {\n if (isNativeConfigProvider(item)) {\n Object.assign(config, item.useValue);\n }\n }\n }\n\n switch (internal.ɵkind) {\n case HttpFeatureKind.Fetch:\n config.useFetchTransport = true;\n break;\n case HttpFeatureKind.Xhr:\n config.useFetchTransport = false;\n break;\n case HttpFeatureKind.Interceptors:\n case HttpFeatureKind.LegacyInterceptors:\n config.interceptorsEnabled = true;\n break;\n case HttpFeatureKind.NoXsrfProtection:\n config.xsrfEnabled = false;\n break;\n case HttpFeatureKind.CustomXsrfConfiguration:\n config.xsrfEnabled = true;\n applyXsrfProviders(internal.ɵproviders, config);\n break;\n case HttpFeatureKind.JsonpSupport:\n config.jsonpEnabled = true;\n break;\n case HttpFeatureKind.RequestsMadeViaParent:\n config.requestsViaParent = true;\n break;\n }\n }\n\n return config;\n}\n\n/**\n * Configures native engine HTTP options alongside standard Angular `provideHttpClient(...)` features.\n */\nexport function withNativeHttpConfig(\n config: Partial<NativeHttpConfig>,\n): HttpFeature<HttpFeatureKind> {\n return {\n ɵkind: HttpFeatureKind.Interceptors,\n ɵproviders: [{ provide: NATIVE_CONFIG_OVERRIDE_TOKEN, useValue: config } satisfies Provider],\n } as unknown as HttpFeature<HttpFeatureKind>;\n}\n\n/**\n * Enables or disables response caching in the Rust OS-native HTTP engine.\n */\nexport function withHttpCaching(cacheEnabled: boolean): HttpFeature<HttpFeatureKind> {\n return withNativeHttpConfig({ cacheEnabled });\n}\n\n/**\n * Tunes parallel multiplexed HTTP/2 connections for batch and asset transfers in Rust.\n */\nexport function withParallelBatching(maxParallelConnections: number): HttpFeature<HttpFeatureKind> {\n return withNativeHttpConfig({ maxParallelConnections: Math.max(1, maxParallelConnections) });\n}\n\nexport function detectNativeCallKind(req: HttpRequest<unknown>): NativeHttpCallKind {\n const overrideKind = req.headers.get('X-Ng-Native-Call-Kind')?.trim().toLowerCase();\n if (\n overrideKind === 'graphql' ||\n overrideKind === 'asset' ||\n overrideKind === 'batch' ||\n overrideKind === 'text' ||\n overrideKind === 'json'\n ) {\n return overrideKind;\n }\n if (req.responseType === 'arraybuffer' || req.responseType === 'blob') {\n return 'asset';\n }\n if (req.responseType === 'text') {\n return 'text';\n }\n const cleanUrl = req.urlWithParams.split('?')[0].toLowerCase();\n if (req.method.toUpperCase() === 'POST' && cleanUrl.includes('graphql')) {\n return 'graphql';\n }\n if (/\\.(png|jpe?g|webp|svg|ico|bin)$/i.test(cleanUrl)) {\n return 'asset';\n }\n if (/\\.(txt|html|css|xml|csv)$/i.test(cleanUrl)) {\n return 'text';\n }\n return 'json';\n}\n\nfunction extractRequestHeaders(req: HttpRequest<unknown>): Record<string, string> {\n const headers: Record<string, string> = {};\n for (const key of req.headers.keys()) {\n const values = req.headers.getAll(key);\n if (values && values.length > 0) {\n headers[key] = values.join(', ');\n }\n }\n return headers;\n}\n\n/**\n * Custom Angular `HttpBackend` that bypasses browser `XMLHttpRequest` / `fetch`\n * and executes requests through `globalThis.__NG_NATIVE__.httpRequest` in the Rust OS-native HTTP engine\n * (`libsoup-3.0` on Linux, `NSURLSession` on macOS, `WinHTTP` on Windows).\n * Compatible with `HttpClient`, functional `HttpInterceptorFn`, and `httpResource()`.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeHttpBackend implements HttpBackend {\n handle(req: HttpRequest<unknown>): Observable<HttpEvent<unknown>> {\n return new Observable<HttpEvent<unknown>>((observer) => {\n try {\n const bridge = ensureNgNativeBridge();\n const serializedBody = req.serializeBody();\n const bodyStr =\n serializedBody === null || serializedBody === undefined\n ? undefined\n : typeof serializedBody === 'string'\n ? serializedBody\n : JSON.stringify(serializedBody);\n\n const callKind = detectNativeCallKind(req);\n const rawRes = bridge.httpRequest(req.method, req.urlWithParams, bodyStr, {\n headers: extractRequestHeaders(req),\n responseType: req.responseType,\n callKind,\n withCredentials: req.withCredentials,\n });\n\n let parsedBody: unknown = rawRes.body;\n if (req.responseType === 'json' && rawRes.body.length > 0) {\n try {\n parsedBody = JSON.parse(rawRes.body);\n } catch {\n parsedBody = rawRes.body;\n }\n } else if (req.responseType === 'blob' && typeof Blob === 'function') {\n parsedBody = new Blob([rawRes.body]);\n } else if (req.responseType === 'arraybuffer' && typeof TextEncoder === 'function') {\n parsedBody = new TextEncoder().encode(rawRes.body).buffer;\n }\n\n const headers = new HttpHeaders(rawRes.headers ?? {});\n if (rawRes.status >= 200 && rawRes.status < 300) {\n observer.next(\n new HttpResponse({\n body: parsedBody,\n headers,\n status: rawRes.status,\n statusText: rawRes.statusText,\n url: req.urlWithParams,\n }),\n );\n observer.complete();\n } else {\n observer.error(\n new HttpErrorResponse({\n error: parsedBody,\n headers,\n status: rawRes.status,\n statusText: rawRes.statusText,\n url: req.urlWithParams,\n }),\n );\n }\n } catch (err) {\n observer.error(err);\n }\n });\n }\n}\n\n/**\n * Drop-in Angular `provideHttpClient(...)` provider for native desktop apps.\n * Translates Angular features (`withFetch`, `withInterceptors`, `withXsrfConfiguration`,\n * `withNoXsrfProtection`, `withJsonpSupport`, `withRequestsMadeViaParent`, and native transport\n * helpers) into the Rust OS-native HTTP engine and routes `HttpClient` through `NativeHttpBackend`.\n */\nexport function provideHttpClient(\n ...features: HttpFeature<HttpFeatureKind>[]\n): EnvironmentProviders {\n const resolvedConfig = resolveNativeHttpConfig(features);\n const appliedConfig = ensureNgNativeBridge().configureHttp(resolvedConfig);\n\n const sanitizedFeatures = features.filter((feature) => {\n const kind = (feature as unknown as InternalHttpFeature).ɵkind;\n return kind !== HttpFeatureKind.Fetch && kind !== HttpFeatureKind.Xhr;\n });\n\n const providers: (Provider | EnvironmentProviders)[] = [\n angularProvideHttpClient(...sanitizedFeatures),\n { provide: NATIVE_HTTP_CONFIG, useValue: appliedConfig },\n ];\n\n if (!resolvedConfig.requestsViaParent) {\n providers.push({ provide: HttpBackend, useExisting: NativeHttpBackend });\n }\n\n return makeEnvironmentProviders(providers);\n}\n\n/**\n * Backward-compatible alias for `provideHttpClient(...)`.\n */\nexport const provideNativeHttpClient = provideHttpClient;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-resource.d.ts","sourceRoot":"","sources":["../../../../packages/http-native/src/http-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAU,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAwB,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEtF,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;AAE7E,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,O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AAC","sourcesContent":["import { computed, Signal, signal, WritableSignal } from '@angular/core';\nimport { ensureNgNativeBridge, NativeHttpRequestOptions } from '@ng-desktop/platform';\n\nexport type NativeResourceStatus = 'idle' | 'loading' | 'resolved' | 'error';\n\nexport interface NativeHttpResourceOptions<T> {\n request?: NativeHttpRequestOptions;\n defaultValue?: T;\n map?: (raw: unknown) => T;\n}\n\nexport interface NativeHttpResourceRef<T> {\n readonly url: Signal<string | undefined>;\n readonly value: WritableSignal<T | undefined>;\n readonly status: WritableSignal<NativeResourceStatus>;\n readonly error: WritableSignal<unknown>;\n readonly isLoading: Signal<boolean>;\n readonly hasValue: Signal<boolean>;\n reload(): boolean;\n}\n\n/**\n * Signal-based reactive HTTP resource backed by the OS-native Rust HTTP bridge (`ensureNgNativeBridge()`).\n * Mirrors Angular's `httpResource()` ergonomics (`value`, `status`, `error`, `isLoading`, `hasValue`, `reload`).\n */\nexport function createNativeHttpResource<T = unknown>(\n urlOrFn: string | (() => string | undefined),\n options?: NativeHttpResourceOptions<T>,\n): NativeHttpResourceRef<T> {\n const resolveUrl = (): string | undefined => {\n const raw = typeof urlOrFn === 'function' ? urlOrFn() : urlOrFn;\n const clean = raw?.trim();\n return clean && clean.length > 0 ? clean : undefined;\n };\n\n const url = computed(() => resolveUrl());\n const value = signal<T | undefined>(options?.defaultValue);\n const status = signal<NativeResourceStatus>('idle');\n const error = signal<unknown>(undefined);\n const isLoading = computed(() => status() === 'loading');\n const hasValue = computed(() => value() !== undefined);\n\n const reload = (): boolean => {\n const targetUrl = resolveUrl();\n if (!targetUrl) {\n status.set('idle');\n error.set(undefined);\n return false;\n }\n\n status.set('loading');\n error.set(undefined);\n try {\n const bridge = ensureNgNativeBridge();\n const res = bridge.httpRequest('GET', targetUrl, undefined, options?.request);\n if (res.status >= 200 && res.status < 300) {\n const responseType = options?.request?.responseType ?? 'json';\n let parsed: unknown = res.body;\n if (responseType === 'json' && typeof res.body === 'string' && res.body.length > 0) {\n parsed = JSON.parse(res.body);\n }\n const finalValue = options?.map ? options.map(parsed) : (parsed as T);\n value.set(finalValue);\n status.set('resolved');\n return true;\n }\n\n error.set({\n status: res.status,\n statusText: res.statusText,\n body: res.body,\n url: targetUrl,\n });\n status.set('error');\n return false;\n } catch (err) {\n error.set(err);\n status.set('error');\n return false;\n }\n };\n\n reload();\n\n return {\n url,\n value,\n status,\n error,\n isLoading,\n hasValue,\n reload,\n };\n}\n"]}
|
package/fesm2022/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/http-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC"}
|
package/fesm2022/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/http-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,uBAAuB,EACvB,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EACzB,OAAO,EACP,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,wBAAwB,GAIzB,MAAM,iBAAiB,CAAC","sourcesContent":["export {\n detectNativeCallKind,\n HttpFeatureKind,\n NATIVE_HTTP_CONFIG,\n NativeHttpBackend,\n provideHttpClient,\n provideNativeHttpClient,\n resolveNativeHttpConfig,\n withFetch,\n withHttpCaching,\n withInterceptors,\n withInterceptorsFromDi,\n withJsonpSupport,\n withNativeHttpConfig,\n withNoXsrfProtection,\n withParallelBatching,\n withRequestsMadeViaParent,\n withXhr,\n withXsrfConfiguration,\n} from './http-backend';\nexport {\n createNativeHttpResource,\n type NativeHttpResourceOptions,\n type NativeHttpResourceRef,\n type NativeResourceStatus,\n} from './http-resource';\n"]}
|