@podium/client 5.2.0-next.3 → 5.2.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/lib/client.js +0 -2
- package/lib/http-outgoing.js +21 -7
- package/lib/resolver.content.js +19 -50
- package/lib/resolver.fallback.js +19 -31
- package/lib/resource.js +3 -10
- package/package.json +5 -5
- package/types/client.d.ts +10 -13
- package/types/http-outgoing.d.ts +8 -7
- package/types/http.d.ts +3 -3
- package/types/resolver.cache.d.ts +3 -3
- package/types/resolver.content.d.ts +3 -5
- package/types/resolver.d.ts +3 -3
- package/types/resolver.fallback.d.ts +3 -3
- package/types/resolver.manifest.d.ts +3 -3
- package/types/resource.d.ts +7 -7
- package/types/response.d.ts +3 -3
- package/types/state.d.ts +0 -1
- package/types/utils.d.ts +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [5.2.0-next.5](https://github.com/podium-lib/client/compare/v5.2.0-next.4...v5.2.0-next.5) (2024-10-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* replace early hints with header link reading ([4429681](https://github.com/podium-lib/client/commit/44296811441a857fabeaebb583c42da28ec47705))
|
|
7
|
+
|
|
8
|
+
# [5.2.0-next.4](https://github.com/podium-lib/client/compare/v5.2.0-next.3...v5.2.0-next.4) (2024-09-24)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update @podium/utils to support hints asset collection ([fe97c44](https://github.com/podium-lib/client/commit/fe97c44bc6d29d1e45d335235cd3b1ef6eeafeaa))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* keep track of which resources have emitted early hints and emit complete event once all resources have emitted ([7cf916a](https://github.com/podium-lib/client/commit/7cf916ab286a3c6cb8fbfdae46634b58f2be256f))
|
|
19
|
+
|
|
1
20
|
# [5.2.0-next.3](https://github.com/podium-lib/client/compare/v5.2.0-next.2...v5.2.0-next.3) (2024-09-20)
|
|
2
21
|
|
|
3
22
|
|
package/lib/client.js
CHANGED
|
@@ -62,7 +62,6 @@ const MAX_AGE = Infinity;
|
|
|
62
62
|
* @property {boolean} [redirectable=false] Set to `true` to allow podlet to respond with a redirect. You need to look for the redirect response from the podlet and return a redirect response to the browser yourself.
|
|
63
63
|
* @property {import('./resource.js').RequestFilterOptions} [excludeBy] Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
64
64
|
* @property {import('./resource.js').RequestFilterOptions} [includeBy] Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
65
|
-
* @property {boolean} [earlyHints=true]
|
|
66
65
|
*/
|
|
67
66
|
|
|
68
67
|
export default class PodiumClient extends EventEmitter {
|
|
@@ -213,7 +212,6 @@ export default class PodiumClient extends EventEmitter {
|
|
|
213
212
|
httpAgent: this.#options.httpAgent,
|
|
214
213
|
includeBy: this.#options.includeBy,
|
|
215
214
|
excludeBy: this.#options.excludeBy,
|
|
216
|
-
earlyHints: true,
|
|
217
215
|
...options,
|
|
218
216
|
};
|
|
219
217
|
|
package/lib/http-outgoing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PassThrough } from 'stream';
|
|
2
2
|
import assert from 'assert';
|
|
3
|
-
import { toPreloadAssetObjects } from './utils.js';
|
|
3
|
+
import { toPreloadAssetObjects, filterAssets } from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {object} PodiumClientHttpOutgoingOptions
|
|
@@ -153,7 +153,9 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
153
153
|
|
|
154
154
|
get js() {
|
|
155
155
|
// return the internal js value or, fallback to the manifest for backwards compatibility
|
|
156
|
-
return this.#js
|
|
156
|
+
return this.#js && this.#js.length
|
|
157
|
+
? this.#js
|
|
158
|
+
: filterAssets('content', this.#manifest.js);
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
set js(value) {
|
|
@@ -162,7 +164,9 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
162
164
|
|
|
163
165
|
get css() {
|
|
164
166
|
// return the internal css value or, fallback to the manifest for backwards compatibility
|
|
165
|
-
return this.#css
|
|
167
|
+
return this.#css && this.#css.length
|
|
168
|
+
? this.#css
|
|
169
|
+
: filterAssets('content', this.#manifest.css);
|
|
166
170
|
}
|
|
167
171
|
|
|
168
172
|
set css(value) {
|
|
@@ -331,12 +335,22 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
331
335
|
pushFallback() {
|
|
332
336
|
// @ts-expect-error Internal property
|
|
333
337
|
this.push(this.#manifest._fallback);
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
+
this.js =
|
|
339
|
+
// @ts-expect-error Internal property
|
|
340
|
+
this.#manifest._js && this.#manifest._js.length
|
|
341
|
+
? // @ts-expect-error Internal property
|
|
342
|
+
filterAssets('fallback', this.#manifest._js)
|
|
343
|
+
: filterAssets('fallback', this.#manifest.js);
|
|
344
|
+
this.css =
|
|
345
|
+
// @ts-expect-error Internal property
|
|
346
|
+
this.#manifest._css && this.#manifest._css.length
|
|
347
|
+
? // @ts-expect-error Internal property
|
|
348
|
+
filterAssets('fallback', this.#manifest._css)
|
|
349
|
+
: filterAssets('fallback', this.#manifest.css);
|
|
338
350
|
this.push(null);
|
|
339
351
|
this.#isFallback = true;
|
|
352
|
+
// assume the hints from the podlet have failed and fallback assets will be used
|
|
353
|
+
this.hintsReceived = true;
|
|
340
354
|
}
|
|
341
355
|
|
|
342
356
|
writeEarlyHints(cb = () => {}) {
|
package/lib/resolver.content.js
CHANGED
|
@@ -27,7 +27,6 @@ const UA_STRING = `${pkg.name} ${pkg.version}`;
|
|
|
27
27
|
* @property {string} clientName
|
|
28
28
|
* @property {import('./http.js').default} [http]
|
|
29
29
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
30
|
-
* @property {boolean} [earlyHints]
|
|
31
30
|
*/
|
|
32
31
|
|
|
33
32
|
export default class PodletClientContentResolver {
|
|
@@ -35,7 +34,6 @@ export default class PodletClientContentResolver {
|
|
|
35
34
|
#metrics;
|
|
36
35
|
#histogram;
|
|
37
36
|
#http;
|
|
38
|
-
#earlyHints;
|
|
39
37
|
|
|
40
38
|
/**
|
|
41
39
|
* @constructor
|
|
@@ -46,8 +44,6 @@ export default class PodletClientContentResolver {
|
|
|
46
44
|
this.#http = options.http || new HTTP();
|
|
47
45
|
const name = options.clientName;
|
|
48
46
|
this.#log = abslog(options.logger);
|
|
49
|
-
this.#earlyHints =
|
|
50
|
-
typeof options.earlyHints === 'boolean' ? options.earlyHints : true;
|
|
51
47
|
this.#metrics = new Metrics();
|
|
52
48
|
this.#histogram = this.#metrics.histogram({
|
|
53
49
|
name: 'podium_client_resolver_content_resolve',
|
|
@@ -96,10 +92,7 @@ export default class PodletClientContentResolver {
|
|
|
96
92
|
outgoing.pushFallback();
|
|
97
93
|
outgoing.emit(
|
|
98
94
|
'beforeStream',
|
|
99
|
-
new Response({
|
|
100
|
-
js: utils.filterAssets('fallback', outgoing.manifest.js),
|
|
101
|
-
css: utils.filterAssets('fallback', outgoing.manifest.css),
|
|
102
|
-
}),
|
|
95
|
+
new Response({ js: outgoing.js, css: outgoing.css }),
|
|
103
96
|
);
|
|
104
97
|
return outgoing;
|
|
105
98
|
}
|
|
@@ -119,10 +112,7 @@ export default class PodletClientContentResolver {
|
|
|
119
112
|
outgoing.pushFallback();
|
|
120
113
|
outgoing.emit(
|
|
121
114
|
'beforeStream',
|
|
122
|
-
new Response({
|
|
123
|
-
js: utils.filterAssets('fallback', outgoing.manifest.js),
|
|
124
|
-
css: utils.filterAssets('fallback', outgoing.manifest.css),
|
|
125
|
-
}),
|
|
115
|
+
new Response({ js: outgoing.js, css: outgoing.css }),
|
|
126
116
|
);
|
|
127
117
|
return outgoing;
|
|
128
118
|
}
|
|
@@ -139,8 +129,6 @@ export default class PodletClientContentResolver {
|
|
|
139
129
|
outgoing.contentUri,
|
|
140
130
|
);
|
|
141
131
|
|
|
142
|
-
let hintsReceived = false;
|
|
143
|
-
|
|
144
132
|
/** @type {import('./http.js').PodiumHttpClientRequestOptions} */
|
|
145
133
|
const reqOptions = {
|
|
146
134
|
rejectUnauthorized: outgoing.rejectUnauthorized,
|
|
@@ -148,26 +136,6 @@ export default class PodletClientContentResolver {
|
|
|
148
136
|
method: 'GET',
|
|
149
137
|
query: outgoing.reqOptions.query,
|
|
150
138
|
headers,
|
|
151
|
-
onInfo: ({ statusCode, headers }) => {
|
|
152
|
-
if (statusCode === 103 && !hintsReceived) {
|
|
153
|
-
const parsedAssetObjects = parseLinkHeaders(headers.link);
|
|
154
|
-
|
|
155
|
-
const scriptObjects = parsedAssetObjects.filter(
|
|
156
|
-
(asset) => asset instanceof AssetJs,
|
|
157
|
-
);
|
|
158
|
-
const styleObjects = parsedAssetObjects.filter(
|
|
159
|
-
(asset) => asset instanceof AssetCss,
|
|
160
|
-
);
|
|
161
|
-
// set the content js asset objects
|
|
162
|
-
outgoing.js = filterAssets('content', scriptObjects);
|
|
163
|
-
// set the content css asset objects
|
|
164
|
-
outgoing.css = filterAssets('content', styleObjects);
|
|
165
|
-
// write the early hints to the browser
|
|
166
|
-
if (this.#earlyHints) outgoing.writeEarlyHints();
|
|
167
|
-
|
|
168
|
-
hintsReceived = true;
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
139
|
};
|
|
172
140
|
|
|
173
141
|
if (outgoing.redirectable) {
|
|
@@ -191,6 +159,19 @@ export default class PodletClientContentResolver {
|
|
|
191
159
|
body,
|
|
192
160
|
} = await this.#http.request(uri, reqOptions);
|
|
193
161
|
|
|
162
|
+
const parsedAssetObjects = parseLinkHeaders(hdrs.link);
|
|
163
|
+
|
|
164
|
+
const scriptObjects = parsedAssetObjects.filter(
|
|
165
|
+
(asset) => asset instanceof AssetJs,
|
|
166
|
+
);
|
|
167
|
+
const styleObjects = parsedAssetObjects.filter(
|
|
168
|
+
(asset) => asset instanceof AssetCss,
|
|
169
|
+
);
|
|
170
|
+
// set the content js asset objects
|
|
171
|
+
outgoing.js = filterAssets('content', scriptObjects);
|
|
172
|
+
// set the content css asset objects
|
|
173
|
+
outgoing.css = filterAssets('content', styleObjects);
|
|
174
|
+
|
|
194
175
|
// Remote responds but with an http error code
|
|
195
176
|
const resError = statusCode >= 400;
|
|
196
177
|
if (resError && outgoing.throwable) {
|
|
@@ -231,16 +212,7 @@ export default class PodletClientContentResolver {
|
|
|
231
212
|
outgoing.pushFallback();
|
|
232
213
|
outgoing.emit(
|
|
233
214
|
'beforeStream',
|
|
234
|
-
new Response({
|
|
235
|
-
js: utils.filterAssets(
|
|
236
|
-
'fallback',
|
|
237
|
-
outgoing.manifest.js,
|
|
238
|
-
),
|
|
239
|
-
css: utils.filterAssets(
|
|
240
|
-
'fallback',
|
|
241
|
-
outgoing.manifest.css,
|
|
242
|
-
),
|
|
243
|
-
}),
|
|
215
|
+
new Response({ js: outgoing.js, css: outgoing.css }),
|
|
244
216
|
);
|
|
245
217
|
|
|
246
218
|
// Body must be consumed; https://github.com/nodejs/undici/issues/583#issuecomment-855384858
|
|
@@ -289,8 +261,8 @@ export default class PodletClientContentResolver {
|
|
|
289
261
|
'beforeStream',
|
|
290
262
|
new Response({
|
|
291
263
|
headers: outgoing.headers,
|
|
292
|
-
js:
|
|
293
|
-
css:
|
|
264
|
+
js: outgoing.js,
|
|
265
|
+
css: outgoing.css,
|
|
294
266
|
redirect: outgoing.redirect,
|
|
295
267
|
}),
|
|
296
268
|
);
|
|
@@ -330,10 +302,7 @@ export default class PodletClientContentResolver {
|
|
|
330
302
|
outgoing.pushFallback();
|
|
331
303
|
outgoing.emit(
|
|
332
304
|
'beforeStream',
|
|
333
|
-
new Response({
|
|
334
|
-
js: utils.filterAssets('fallback', outgoing.js),
|
|
335
|
-
css: utils.filterAssets('fallback', outgoing.css),
|
|
336
|
-
}),
|
|
305
|
+
new Response({ js: outgoing.js, css: outgoing.css }),
|
|
337
306
|
);
|
|
338
307
|
|
|
339
308
|
return outgoing;
|
package/lib/resolver.fallback.js
CHANGED
|
@@ -96,40 +96,12 @@ export default class PodletClientFallbackResolver {
|
|
|
96
96
|
'User-Agent': UA_STRING,
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
let hintsReceived = false;
|
|
100
|
-
|
|
101
99
|
/** @type {import('./http.js').PodiumHttpClientRequestOptions} */
|
|
102
100
|
const reqOptions = {
|
|
103
101
|
rejectUnauthorized: outgoing.rejectUnauthorized,
|
|
104
102
|
timeout: outgoing.timeout,
|
|
105
103
|
method: 'GET',
|
|
106
104
|
headers,
|
|
107
|
-
onInfo({ statusCode, headers }) {
|
|
108
|
-
if (statusCode === 103 && !hintsReceived) {
|
|
109
|
-
const parsedAssetObjects = parseLinkHeaders(headers.link);
|
|
110
|
-
|
|
111
|
-
const scriptObjects = parsedAssetObjects.filter(
|
|
112
|
-
(asset) => asset instanceof AssetJs,
|
|
113
|
-
);
|
|
114
|
-
const styleObjects = parsedAssetObjects.filter(
|
|
115
|
-
(asset) => asset instanceof AssetCss,
|
|
116
|
-
);
|
|
117
|
-
// set the content js asset fallback objects
|
|
118
|
-
// @ts-expect-error internal property
|
|
119
|
-
outgoing.manifest._js = filterAssets(
|
|
120
|
-
'fallback',
|
|
121
|
-
scriptObjects,
|
|
122
|
-
);
|
|
123
|
-
// set the fallback css asset fallback objects
|
|
124
|
-
// @ts-expect-error internal property
|
|
125
|
-
outgoing.manifest._css = filterAssets(
|
|
126
|
-
'fallback',
|
|
127
|
-
styleObjects,
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
hintsReceived = true;
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
105
|
};
|
|
134
106
|
|
|
135
107
|
const timer = this.#histogram.timer({
|
|
@@ -142,10 +114,26 @@ export default class PodletClientFallbackResolver {
|
|
|
142
114
|
this.#log.debug(
|
|
143
115
|
`start reading fallback content from remote resource - resource: ${outgoing.name} - url: ${outgoing.fallbackUri}`,
|
|
144
116
|
);
|
|
145
|
-
const {
|
|
146
|
-
|
|
147
|
-
|
|
117
|
+
const {
|
|
118
|
+
statusCode,
|
|
119
|
+
body,
|
|
120
|
+
headers: resHeaders,
|
|
121
|
+
} = await this.#http.request(outgoing.fallbackUri, reqOptions);
|
|
122
|
+
|
|
123
|
+
const parsedAssetObjects = parseLinkHeaders(resHeaders.link);
|
|
124
|
+
|
|
125
|
+
const scriptObjects = parsedAssetObjects.filter(
|
|
126
|
+
(asset) => asset instanceof AssetJs,
|
|
127
|
+
);
|
|
128
|
+
const styleObjects = parsedAssetObjects.filter(
|
|
129
|
+
(asset) => asset instanceof AssetCss,
|
|
148
130
|
);
|
|
131
|
+
// set the content js asset fallback objects
|
|
132
|
+
// @ts-expect-error internal property
|
|
133
|
+
outgoing.manifest._js = filterAssets('fallback', scriptObjects);
|
|
134
|
+
// set the fallback css asset fallback objects
|
|
135
|
+
// @ts-expect-error internal property
|
|
136
|
+
outgoing.manifest._css = filterAssets('fallback', styleObjects);
|
|
149
137
|
|
|
150
138
|
// Remote responds but with an http error code
|
|
151
139
|
const resError = statusCode !== 200;
|
package/lib/resource.js
CHANGED
|
@@ -159,8 +159,7 @@ export default class PodiumClientResource {
|
|
|
159
159
|
|
|
160
160
|
this.#state.setInitializingState();
|
|
161
161
|
|
|
162
|
-
const { headers, redirect
|
|
163
|
-
await this.#resolver.resolve(outgoing);
|
|
162
|
+
const { headers, redirect } = await this.#resolver.resolve(outgoing);
|
|
164
163
|
|
|
165
164
|
const chunks = [];
|
|
166
165
|
|
|
@@ -175,14 +174,8 @@ export default class PodiumClientResource {
|
|
|
175
174
|
return new Response({
|
|
176
175
|
headers,
|
|
177
176
|
content,
|
|
178
|
-
css:
|
|
179
|
-
|
|
180
|
-
outgoing.css,
|
|
181
|
-
),
|
|
182
|
-
js: utils.filterAssets(
|
|
183
|
-
isFallback ? 'fallback' : 'content',
|
|
184
|
-
outgoing.js,
|
|
185
|
-
),
|
|
177
|
+
css: outgoing.css,
|
|
178
|
+
js: outgoing.js,
|
|
186
179
|
redirect,
|
|
187
180
|
});
|
|
188
181
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podium/client",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@hapi/boom": "10.0.1",
|
|
41
41
|
"@metrics/client": "2.5.3",
|
|
42
42
|
"@podium/schemas": "5.0.6",
|
|
43
|
-
"@podium/utils": "5.
|
|
43
|
+
"@podium/utils": "5.3.1",
|
|
44
44
|
"abslog": "2.4.4",
|
|
45
45
|
"http-cache-semantics": "^4.0.3",
|
|
46
46
|
"lodash.clonedeep": "^4.5.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"undici": "6.19.8"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@podium/test-utils": "3.1.0-next.
|
|
51
|
+
"@podium/test-utils": "3.1.0-next.5",
|
|
52
52
|
"@semantic-release/changelog": "6.0.3",
|
|
53
53
|
"@semantic-release/git": "10.0.1",
|
|
54
54
|
"@semantic-release/github": "10.0.6",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"eslint": "9.6.0",
|
|
61
61
|
"eslint-config-prettier": "9.1.0",
|
|
62
62
|
"eslint-plugin-prettier": "5.1.3",
|
|
63
|
-
"express": "4.
|
|
63
|
+
"express": "4.21.1",
|
|
64
64
|
"get-stream": "9.0.1",
|
|
65
65
|
"globals": "15.8.0",
|
|
66
66
|
"http-proxy": "1.18.1",
|
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"prettier": "3.3.2",
|
|
70
70
|
"semantic-release": "23.1.1",
|
|
71
71
|
"tap": "18.7.2",
|
|
72
|
-
"typescript": "5.
|
|
72
|
+
"typescript": "5.6.3"
|
|
73
73
|
}
|
|
74
74
|
}
|
package/types/client.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
/**
|
|
3
2
|
* @typedef {import('./resource.js').default} PodiumClientResource
|
|
4
3
|
* @typedef {import('./resource.js').PodiumClientResourceOptions} PodiumClientResourceOptions
|
|
@@ -29,7 +28,6 @@
|
|
|
29
28
|
* @property {boolean} [redirectable=false] Set to `true` to allow podlet to respond with a redirect. You need to look for the redirect response from the podlet and return a redirect response to the browser yourself.
|
|
30
29
|
* @property {import('./resource.js').RequestFilterOptions} [excludeBy] Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
31
30
|
* @property {import('./resource.js').RequestFilterOptions} [includeBy] Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
32
|
-
* @property {boolean} [earlyHints=true]
|
|
33
31
|
*/
|
|
34
32
|
export default class PodiumClient extends EventEmitter<[never]> {
|
|
35
33
|
/**
|
|
@@ -63,14 +61,14 @@ export default class PodiumClient extends EventEmitter<[never]> {
|
|
|
63
61
|
refreshManifests(): Promise<void>;
|
|
64
62
|
#private;
|
|
65
63
|
}
|
|
66
|
-
export type PodiumClientResource = import(
|
|
67
|
-
export type PodiumClientResourceOptions = import(
|
|
68
|
-
export type PodiumClientResponse = import(
|
|
69
|
-
export type PodiumRedirect = import(
|
|
70
|
-
export type PodletManifest = import(
|
|
64
|
+
export type PodiumClientResource = import("./resource.js").default;
|
|
65
|
+
export type PodiumClientResourceOptions = import("./resource.js").PodiumClientResourceOptions;
|
|
66
|
+
export type PodiumClientResponse = import("./response.js").default;
|
|
67
|
+
export type PodiumRedirect = import("./http-outgoing.js").PodiumRedirect;
|
|
68
|
+
export type PodletManifest = import("@podium/schemas").PodletManifestSchema;
|
|
71
69
|
export type PodiumClientOptions = {
|
|
72
70
|
name: string;
|
|
73
|
-
logger?: import(
|
|
71
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
74
72
|
retries?: number;
|
|
75
73
|
/**
|
|
76
74
|
* In milliseconds
|
|
@@ -80,8 +78,8 @@ export type PodiumClientOptions = {
|
|
|
80
78
|
rejectUnauthorized?: boolean;
|
|
81
79
|
resolveThreshold?: number;
|
|
82
80
|
resolveMax?: number;
|
|
83
|
-
httpAgent?: import(
|
|
84
|
-
httpsAgent?: import(
|
|
81
|
+
httpAgent?: import("http").Agent;
|
|
82
|
+
httpsAgent?: import("https").Agent;
|
|
85
83
|
};
|
|
86
84
|
export type RegisterOptions = {
|
|
87
85
|
/**
|
|
@@ -111,12 +109,11 @@ export type RegisterOptions = {
|
|
|
111
109
|
/**
|
|
112
110
|
* Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
113
111
|
*/
|
|
114
|
-
excludeBy?: import(
|
|
112
|
+
excludeBy?: import("./resource.js").RequestFilterOptions;
|
|
115
113
|
/**
|
|
116
114
|
* Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
117
115
|
*/
|
|
118
|
-
includeBy?: import(
|
|
119
|
-
earlyHints?: boolean;
|
|
116
|
+
includeBy?: import("./resource.js").RequestFilterOptions;
|
|
120
117
|
};
|
|
121
118
|
import EventEmitter from 'events';
|
|
122
119
|
import Metrics from '@metrics/client';
|
package/types/http-outgoing.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
45
45
|
* @param {PodiumClientResourceOptions} [reqOptions]
|
|
46
46
|
* @param {import('@podium/utils').HttpIncoming} [incoming]
|
|
47
47
|
*/
|
|
48
|
-
constructor(options?: PodiumClientHttpOutgoingOptions, reqOptions?: PodiumClientResourceOptions, incoming?: import(
|
|
48
|
+
constructor(options?: PodiumClientHttpOutgoingOptions, reqOptions?: PodiumClientResourceOptions, incoming?: import("@podium/utils").HttpIncoming);
|
|
49
49
|
set js(value: any);
|
|
50
50
|
get js(): any;
|
|
51
51
|
set css(value: any);
|
|
@@ -53,7 +53,7 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
53
53
|
get rejectUnauthorized(): boolean;
|
|
54
54
|
get reqOptions(): {
|
|
55
55
|
pathname: string;
|
|
56
|
-
headers: import(
|
|
56
|
+
headers: import("http").IncomingHttpHeaders;
|
|
57
57
|
query: object;
|
|
58
58
|
};
|
|
59
59
|
get throwable(): boolean;
|
|
@@ -125,6 +125,7 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
125
125
|
*/
|
|
126
126
|
get isFallback(): boolean;
|
|
127
127
|
pushFallback(): void;
|
|
128
|
+
hintsReceived: boolean;
|
|
128
129
|
writeEarlyHints(cb?: () => void): void;
|
|
129
130
|
get [Symbol.toStringTag](): string;
|
|
130
131
|
#private;
|
|
@@ -144,12 +145,12 @@ export type PodiumClientHttpOutgoingOptions = {
|
|
|
144
145
|
throwable?: boolean;
|
|
145
146
|
redirectable?: boolean;
|
|
146
147
|
rejectUnauthorized?: boolean;
|
|
147
|
-
httpAgent?: import(
|
|
148
|
-
httpsAgent?: import(
|
|
148
|
+
httpAgent?: import("http").Agent;
|
|
149
|
+
httpsAgent?: import("https").Agent;
|
|
149
150
|
};
|
|
150
151
|
export type PodiumClientResourceOptions = {
|
|
151
152
|
pathname?: string;
|
|
152
|
-
headers?: import(
|
|
153
|
+
headers?: import("http").IncomingHttpHeaders;
|
|
153
154
|
query?: object;
|
|
154
155
|
};
|
|
155
156
|
export type PodiumRedirect = {
|
|
@@ -174,8 +175,8 @@ export type PodletManifest = {
|
|
|
174
175
|
version: string;
|
|
175
176
|
content: string;
|
|
176
177
|
fallback: string;
|
|
177
|
-
js: Array<import(
|
|
178
|
-
css: Array<import(
|
|
178
|
+
js: Array<import("@podium/utils").AssetJs>;
|
|
179
|
+
css: Array<import("@podium/utils").AssetCss>;
|
|
179
180
|
proxy: Record<string, string> | Array<PodletProxySchema>;
|
|
180
181
|
team: string;
|
|
181
182
|
};
|
package/types/http.d.ts
CHANGED
|
@@ -17,16 +17,16 @@ export default class HTTP {
|
|
|
17
17
|
* @param {PodiumHttpClientRequestOptions} options
|
|
18
18
|
* @returns {Promise<Pick<import('undici').Dispatcher.ResponseData, 'statusCode' | 'headers' | 'body'>>}
|
|
19
19
|
*/
|
|
20
|
-
request(url: string, options: PodiumHttpClientRequestOptions): Promise<Pick<import(
|
|
20
|
+
request(url: string, options: PodiumHttpClientRequestOptions): Promise<Pick<import("undici").Dispatcher.ResponseData, "statusCode" | "headers" | "body">>;
|
|
21
21
|
}
|
|
22
22
|
export type PodiumHttpClientRequestOptions = {
|
|
23
|
-
method:
|
|
23
|
+
method: "GET" | "HEAD" | "POST" | "PUT" | "DELETE" | "CONNECT" | "OPTIONS" | "TRACE" | "PATCH";
|
|
24
24
|
json?: boolean;
|
|
25
25
|
rejectUnauthorized?: boolean;
|
|
26
26
|
follow?: boolean;
|
|
27
27
|
timeout?: number;
|
|
28
28
|
query?: object;
|
|
29
|
-
headers?: import(
|
|
29
|
+
headers?: import("http").IncomingHttpHeaders;
|
|
30
30
|
onInfo?: (info: {
|
|
31
31
|
statusCode: number;
|
|
32
32
|
headers: Record<string, string | string[]>;
|
|
@@ -15,17 +15,17 @@ export default class PodletClientCacheResolver {
|
|
|
15
15
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
16
16
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
17
17
|
*/
|
|
18
|
-
load(outgoing: import(
|
|
18
|
+
load(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
19
19
|
/**
|
|
20
20
|
* Saves the podlet's manifest to the cache
|
|
21
21
|
*
|
|
22
22
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
23
23
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
24
24
|
*/
|
|
25
|
-
save(outgoing: import(
|
|
25
|
+
save(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
26
26
|
get [Symbol.toStringTag](): string;
|
|
27
27
|
#private;
|
|
28
28
|
}
|
|
29
29
|
export type PodletClientCacheResolverOptions = {
|
|
30
|
-
logger?: import(
|
|
30
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
31
31
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* @property {string} clientName
|
|
4
4
|
* @property {import('./http.js').default} [http]
|
|
5
5
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
6
|
-
* @property {boolean} [earlyHints]
|
|
7
6
|
*/
|
|
8
7
|
export default class PodletClientContentResolver {
|
|
9
8
|
/**
|
|
@@ -18,14 +17,13 @@ export default class PodletClientContentResolver {
|
|
|
18
17
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
19
18
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
20
19
|
*/
|
|
21
|
-
resolve(outgoing: import(
|
|
20
|
+
resolve(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
22
21
|
get [Symbol.toStringTag](): string;
|
|
23
22
|
#private;
|
|
24
23
|
}
|
|
25
24
|
export type PodletClientContentResolverOptions = {
|
|
26
25
|
clientName: string;
|
|
27
|
-
http?: import(
|
|
28
|
-
logger?: import(
|
|
29
|
-
earlyHints?: boolean;
|
|
26
|
+
http?: import("./http.js").default;
|
|
27
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
30
28
|
};
|
|
31
29
|
import Metrics from '@metrics/client';
|
package/types/resolver.d.ts
CHANGED
|
@@ -18,20 +18,20 @@ export default class PodletClientResolver {
|
|
|
18
18
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
19
19
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
20
20
|
*/
|
|
21
|
-
resolve(outgoing: import(
|
|
21
|
+
resolve(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
22
22
|
/**
|
|
23
23
|
* Refresh the podlet's cached manifest and fallback
|
|
24
24
|
*
|
|
25
25
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
26
26
|
* @returns {Promise<boolean>} `true` if successful
|
|
27
27
|
*/
|
|
28
|
-
refresh(outgoing: import(
|
|
28
|
+
refresh(outgoing: import("./http-outgoing.js").default): Promise<boolean>;
|
|
29
29
|
get [Symbol.toStringTag](): string;
|
|
30
30
|
#private;
|
|
31
31
|
}
|
|
32
32
|
export type PodletClientResolverOptions = {
|
|
33
33
|
clientName: string;
|
|
34
|
-
logger?: import(
|
|
34
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
35
35
|
earlyHints?: boolean;
|
|
36
36
|
};
|
|
37
37
|
import Metrics from '@metrics/client';
|
|
@@ -17,13 +17,13 @@ export default class PodletClientFallbackResolver {
|
|
|
17
17
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
18
18
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
19
19
|
*/
|
|
20
|
-
resolve(outgoing: import(
|
|
20
|
+
resolve(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
21
21
|
get [Symbol.toStringTag](): string;
|
|
22
22
|
#private;
|
|
23
23
|
}
|
|
24
24
|
export type PodletClientFallbackResolverOptions = {
|
|
25
25
|
clientName: string;
|
|
26
|
-
http?: import(
|
|
27
|
-
logger?: import(
|
|
26
|
+
http?: import("./http.js").default;
|
|
27
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
28
28
|
};
|
|
29
29
|
import Metrics from '@metrics/client';
|
|
@@ -15,13 +15,13 @@ export default class PodletClientManifestResolver {
|
|
|
15
15
|
* @param {import('./http-outgoing.js').default} outgoing
|
|
16
16
|
* @returns {Promise<import('./http-outgoing.js').default>}
|
|
17
17
|
*/
|
|
18
|
-
resolve(outgoing: import(
|
|
18
|
+
resolve(outgoing: import("./http-outgoing.js").default): Promise<import("./http-outgoing.js").default>;
|
|
19
19
|
get [Symbol.toStringTag](): string;
|
|
20
20
|
#private;
|
|
21
21
|
}
|
|
22
22
|
export type PodletClientManifestResolverOptions = {
|
|
23
23
|
clientName: string;
|
|
24
|
-
logger?: import(
|
|
25
|
-
http?: import(
|
|
24
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
25
|
+
http?: import("./http.js").default;
|
|
26
26
|
};
|
|
27
27
|
import Metrics from '@metrics/client';
|
package/types/resource.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export default class PodiumClientResource {
|
|
|
26
26
|
* @param {import('./state.js').default} state
|
|
27
27
|
* @param {PodiumClientResourceOptions} options
|
|
28
28
|
*/
|
|
29
|
-
constructor(registry: any, state: import(
|
|
29
|
+
constructor(registry: any, state: import("./state.js").default, options?: PodiumClientResourceOptions);
|
|
30
30
|
get metrics(): Metrics;
|
|
31
31
|
get name(): string;
|
|
32
32
|
get uri(): string;
|
|
@@ -45,7 +45,7 @@ export default class PodiumClientResource {
|
|
|
45
45
|
* incoming.podlets = [header]; // Register the podlet's JS and CSS assets with the layout's HTML template
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
|
-
fetch(incoming: import(
|
|
48
|
+
fetch(incoming: import("@podium/utils").HttpIncoming, reqOptions?: import("./http-outgoing.js").PodiumClientResourceOptions): Promise<import("./response.js").default>;
|
|
49
49
|
/**
|
|
50
50
|
* Stream the podlet's content, or fallback if the podlet is unavailable.
|
|
51
51
|
*
|
|
@@ -53,7 +53,7 @@ export default class PodiumClientResource {
|
|
|
53
53
|
* @param {import('./http-outgoing.js').PodiumClientResourceOptions} [reqOptions={}]
|
|
54
54
|
* @returns {import('./http-outgoing.js').default}
|
|
55
55
|
*/
|
|
56
|
-
stream(incoming: import(
|
|
56
|
+
stream(incoming: import("@podium/utils").HttpIncoming, reqOptions?: import("./http-outgoing.js").PodiumClientResourceOptions): import("./http-outgoing.js").default;
|
|
57
57
|
/**
|
|
58
58
|
* Refresh the podlet's manifest and fallback in the cache.
|
|
59
59
|
*
|
|
@@ -61,7 +61,7 @@ export default class PodiumClientResource {
|
|
|
61
61
|
* @param {import('./http-outgoing.js').PodiumClientResourceOptions} [reqOptions={}]
|
|
62
62
|
* @returns {Promise<boolean>} `true` if succesful
|
|
63
63
|
*/
|
|
64
|
-
refresh(incoming?: import(
|
|
64
|
+
refresh(incoming?: import("@podium/utils").HttpIncoming, reqOptions?: import("./http-outgoing.js").PodiumClientResourceOptions): Promise<boolean>;
|
|
65
65
|
[inspect](): {
|
|
66
66
|
metrics: Metrics;
|
|
67
67
|
name: string;
|
|
@@ -77,7 +77,7 @@ export type RequestFilterOptions = {
|
|
|
77
77
|
deviceType?: string[];
|
|
78
78
|
};
|
|
79
79
|
export type PodiumClientResourceOptions = {
|
|
80
|
-
logger?: import(
|
|
80
|
+
logger?: import("abslog").AbstractLoggerOptions;
|
|
81
81
|
clientName: string;
|
|
82
82
|
name: string;
|
|
83
83
|
/**
|
|
@@ -93,8 +93,8 @@ export type PodiumClientResourceOptions = {
|
|
|
93
93
|
throwable?: boolean;
|
|
94
94
|
redirectable?: boolean;
|
|
95
95
|
rejectUnauthorized?: boolean;
|
|
96
|
-
httpAgent?: import(
|
|
97
|
-
httpsAgent?: import(
|
|
96
|
+
httpAgent?: import("http").Agent;
|
|
97
|
+
httpsAgent?: import("https").Agent;
|
|
98
98
|
/**
|
|
99
99
|
* Used by `fetch` to conditionally skip fetching the podlet content based on values on the request.
|
|
100
100
|
*/
|
package/types/response.d.ts
CHANGED
|
@@ -39,9 +39,9 @@ export default class PodiumClientResponse {
|
|
|
39
39
|
export type PodiumClientResponseOptions = {
|
|
40
40
|
content?: string;
|
|
41
41
|
headers?: object;
|
|
42
|
-
js?: Array<import(
|
|
43
|
-
css?: Array<import(
|
|
44
|
-
redirect?: import(
|
|
42
|
+
js?: Array<import("@podium/utils").AssetJs>;
|
|
43
|
+
css?: Array<import("@podium/utils").AssetCss>;
|
|
44
|
+
redirect?: import("./http-outgoing.js").PodiumRedirect | null;
|
|
45
45
|
};
|
|
46
46
|
declare const inspect: unique symbol;
|
|
47
47
|
export {};
|
package/types/state.d.ts
CHANGED
package/types/utils.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export function isHeaderDefined(headers: object, header: string): boolean;
|
|
2
2
|
export function hasManifestChange(item: object): boolean;
|
|
3
3
|
export function validateIncoming(incoming?: object): boolean;
|
|
4
|
-
export function filterAssets<T extends AssetCss | AssetJs>(scope: "content" | "fallback" | "all", assets: T[]): T[];
|
|
4
|
+
export function filterAssets<T extends import("@podium/utils").AssetCss | import("@podium/utils").AssetJs>(scope: "content" | "fallback" | "all", assets: T[]): T[];
|
|
5
5
|
export function parseLinkHeaders(headers: any): any[];
|
|
6
6
|
export function toPreloadAssetObjects(assetObjects: any): any;
|
|
7
|
-
import { AssetCss } from '@podium/utils';
|
|
8
|
-
import { AssetJs } from '@podium/utils';
|