@podium/client 5.2.0-next.3 → 5.2.0-next.4
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 +12 -0
- package/lib/http-outgoing.js +17 -0
- package/lib/resolver.content.js +2 -4
- package/lib/resource.js +4 -0
- package/package.json +2 -2
- package/types/http-outgoing.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# [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)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update @podium/utils to support hints asset collection ([fe97c44](https://github.com/podium-lib/client/commit/fe97c44bc6d29d1e45d335235cd3b1ef6eeafeaa))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* 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))
|
|
12
|
+
|
|
1
13
|
# [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
14
|
|
|
3
15
|
|
package/lib/http-outgoing.js
CHANGED
|
@@ -70,6 +70,7 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
70
70
|
#uri;
|
|
71
71
|
#js;
|
|
72
72
|
#css;
|
|
73
|
+
#hintsReceived = false;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* @constructor
|
|
@@ -300,6 +301,20 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
300
301
|
this.#redirect = value;
|
|
301
302
|
}
|
|
302
303
|
|
|
304
|
+
get hintsReceived() {
|
|
305
|
+
return this.#hintsReceived;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
set hintsReceived(value) {
|
|
309
|
+
this.#hintsReceived = value;
|
|
310
|
+
if (this.#hintsReceived) {
|
|
311
|
+
this.#incoming?.hints?.addReceivedHint(this.#name, {
|
|
312
|
+
js: this.js,
|
|
313
|
+
css: this.css,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
303
318
|
/**
|
|
304
319
|
* Whether the podlet can signal redirects to the layout.
|
|
305
320
|
*
|
|
@@ -337,6 +352,8 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
337
352
|
this.css = this.#manifest._css;
|
|
338
353
|
this.push(null);
|
|
339
354
|
this.#isFallback = true;
|
|
355
|
+
// assume the hints from the podlet have failed and fallback assets will be used
|
|
356
|
+
this.hintsReceived = true;
|
|
340
357
|
}
|
|
341
358
|
|
|
342
359
|
writeEarlyHints(cb = () => {}) {
|
package/lib/resolver.content.js
CHANGED
|
@@ -139,8 +139,6 @@ export default class PodletClientContentResolver {
|
|
|
139
139
|
outgoing.contentUri,
|
|
140
140
|
);
|
|
141
141
|
|
|
142
|
-
let hintsReceived = false;
|
|
143
|
-
|
|
144
142
|
/** @type {import('./http.js').PodiumHttpClientRequestOptions} */
|
|
145
143
|
const reqOptions = {
|
|
146
144
|
rejectUnauthorized: outgoing.rejectUnauthorized,
|
|
@@ -149,7 +147,7 @@ export default class PodletClientContentResolver {
|
|
|
149
147
|
query: outgoing.reqOptions.query,
|
|
150
148
|
headers,
|
|
151
149
|
onInfo: ({ statusCode, headers }) => {
|
|
152
|
-
if (statusCode === 103 && !hintsReceived) {
|
|
150
|
+
if (statusCode === 103 && !outgoing.hintsReceived) {
|
|
153
151
|
const parsedAssetObjects = parseLinkHeaders(headers.link);
|
|
154
152
|
|
|
155
153
|
const scriptObjects = parsedAssetObjects.filter(
|
|
@@ -165,7 +163,7 @@ export default class PodletClientContentResolver {
|
|
|
165
163
|
// write the early hints to the browser
|
|
166
164
|
if (this.#earlyHints) outgoing.writeEarlyHints();
|
|
167
165
|
|
|
168
|
-
hintsReceived = true;
|
|
166
|
+
outgoing.hintsReceived = true;
|
|
169
167
|
}
|
|
170
168
|
},
|
|
171
169
|
};
|
package/lib/resource.js
CHANGED
|
@@ -105,6 +105,10 @@ export default class PodiumClientResource {
|
|
|
105
105
|
throw new TypeError(
|
|
106
106
|
'you must pass an instance of "HttpIncoming" as the first argument to the .fetch() method',
|
|
107
107
|
);
|
|
108
|
+
// add the name of this resource as expecting a hint to be received
|
|
109
|
+
// we use this to track across resources and emit a hint completion event once
|
|
110
|
+
// all hints from all resources have been received.
|
|
111
|
+
incoming.hints.addExpectedHint(this.#options.name);
|
|
108
112
|
const outgoing = new HttpOutgoing(this.#options, reqOptions, incoming);
|
|
109
113
|
|
|
110
114
|
if (this.#options.excludeBy) {
|
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.4",
|
|
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",
|
package/types/http-outgoing.d.ts
CHANGED
|
@@ -105,6 +105,8 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
105
105
|
* @see https://podium-lib.io/docs/layout/handling_redirects
|
|
106
106
|
*/
|
|
107
107
|
get redirect(): PodiumRedirect;
|
|
108
|
+
set hintsReceived(value: boolean);
|
|
109
|
+
get hintsReceived(): boolean;
|
|
108
110
|
set redirectable(value: boolean);
|
|
109
111
|
/**
|
|
110
112
|
* Whether the podlet can signal redirects to the layout.
|