@podium/client 5.2.0 → 5.3.0-next.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/CHANGELOG.md +7 -0
- package/README.md +0 -1
- package/lib/http-outgoing.js +24 -16
- package/lib/resolver.content.js +3 -0
- package/lib/resolver.js +0 -1
- package/lib/resource.js +4 -0
- package/package.json +10 -9
- package/types/http-outgoing.d.ts +8 -2
- package/types/resolver.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [5.3.0-next.1](https://github.com/podium-lib/client/compare/v5.2.0...v5.3.0-next.1) (2024-11-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* track podlet assets ([39022a3](https://github.com/podium-lib/client/commit/39022a3c87184e5f524828591c8185d8a3fc2995))
|
|
7
|
+
|
|
1
8
|
# [5.2.0](https://github.com/podium-lib/client/compare/v5.1.18...v5.2.0) (2024-11-06)
|
|
2
9
|
|
|
3
10
|
|
package/README.md
CHANGED
|
@@ -152,7 +152,6 @@ The following values can be provided:
|
|
|
152
152
|
- `throwable` - {Boolean} - Defines whether an error should be thrown if a failure occurs during the process of fetching a podium component. Defaults to `false` - Optional.
|
|
153
153
|
- `excludeBy` - {Object} - Lets you define a set of rules where a `fetch` call will not be resolved if it matches. - Optional.
|
|
154
154
|
- `includeBy` - {Object} - Inverse of `excludeBy`. Setting both at the same time will throw. - Optional.
|
|
155
|
-
- `earlyHints` - {boolean} - Can be used to disable early hints from being sent to the browser for this resource, see [HTTP Status 103 Early Hints](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103).
|
|
156
155
|
|
|
157
156
|
##### `excludeBy` and `includeBy`
|
|
158
157
|
|
package/lib/http-outgoing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PassThrough } from 'stream';
|
|
2
2
|
import assert from 'assert';
|
|
3
|
-
import {
|
|
3
|
+
import { filterAssets } from './utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @typedef {object} PodiumClientHttpOutgoingOptions
|
|
@@ -70,6 +70,7 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
70
70
|
#uri;
|
|
71
71
|
#js;
|
|
72
72
|
#css;
|
|
73
|
+
#assetsReceived = false;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* @constructor
|
|
@@ -332,6 +333,26 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
332
333
|
return this.#isFallback;
|
|
333
334
|
}
|
|
334
335
|
|
|
336
|
+
get assetsReceived() {
|
|
337
|
+
return this.#assetsReceived;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Set the assetsReceived flag.
|
|
342
|
+
* This is used to signal to the assets object that the client has received assets for a given podlet so it can track
|
|
343
|
+
* which podlets have sent their assets.
|
|
344
|
+
* @param {boolean} value
|
|
345
|
+
*/
|
|
346
|
+
set assetsReceived(value) {
|
|
347
|
+
this.#assetsReceived = value;
|
|
348
|
+
if (this.#assetsReceived) {
|
|
349
|
+
this.#incoming?.assets?.addReceivedAsset(this.#name, {
|
|
350
|
+
js: this.js,
|
|
351
|
+
css: this.css,
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
335
356
|
pushFallback() {
|
|
336
357
|
// @ts-expect-error Internal property
|
|
337
358
|
this.push(this.#manifest._fallback);
|
|
@@ -349,21 +370,8 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
349
370
|
: filterAssets('fallback', this.#manifest.css);
|
|
350
371
|
this.push(null);
|
|
351
372
|
this.#isFallback = true;
|
|
352
|
-
// assume the
|
|
353
|
-
this.
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
writeEarlyHints(cb = () => {}) {
|
|
357
|
-
if (this.#incoming.response.writeEarlyHints) {
|
|
358
|
-
const preloads = toPreloadAssetObjects([
|
|
359
|
-
...(this.js || []),
|
|
360
|
-
...(this.css || []),
|
|
361
|
-
]);
|
|
362
|
-
const link = preloads.map((preload) => preload.toHeader());
|
|
363
|
-
if (link.length) {
|
|
364
|
-
this.#incoming.response.writeEarlyHints({ link }, cb);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
373
|
+
// assume the assets from the podlet have failed and fallback assets will be used
|
|
374
|
+
this.assetsReceived = true;
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
get [Symbol.toStringTag]() {
|
package/lib/resolver.content.js
CHANGED
package/lib/resolver.js
CHANGED
|
@@ -11,7 +11,6 @@ import Cache from './resolver.cache.js';
|
|
|
11
11
|
* @typedef {object} PodletClientResolverOptions
|
|
12
12
|
* @property {string} clientName
|
|
13
13
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
14
|
-
* @property {boolean} [earlyHints]
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
16
|
export default class PodletClientResolver {
|
package/lib/resource.js
CHANGED
|
@@ -105,6 +105,8 @@ 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
|
+
// set expectation to receive a response from this podlet.
|
|
109
|
+
incoming.assets.addExpectedAsset(this.#options.name);
|
|
108
110
|
const outgoing = new HttpOutgoing(this.#options, reqOptions, incoming);
|
|
109
111
|
|
|
110
112
|
if (this.#options.excludeBy) {
|
|
@@ -192,6 +194,8 @@ export default class PodiumClientResource {
|
|
|
192
194
|
throw new TypeError(
|
|
193
195
|
'you must pass an instance of "HttpIncoming" as the first argument to the .stream() method',
|
|
194
196
|
);
|
|
197
|
+
// set expectation to receive a response from this podlet.
|
|
198
|
+
incoming.assets.addExpectedAsset(this.#options.name);
|
|
195
199
|
const outgoing = new HttpOutgoing(this.#options, reqOptions, incoming);
|
|
196
200
|
this.#state.setInitializingState();
|
|
197
201
|
this.#resolver.resolve(outgoing);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@podium/client",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0-next.1",
|
|
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.1.0",
|
|
43
|
-
"@podium/utils": "5.
|
|
43
|
+
"@podium/utils": "5.4.0",
|
|
44
44
|
"abslog": "2.4.4",
|
|
45
45
|
"http-cache-semantics": "^4.0.3",
|
|
46
46
|
"lodash.clonedeep": "^4.5.0",
|
|
@@ -48,22 +48,22 @@
|
|
|
48
48
|
"undici": "6.20.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@podium/eslint-config": "1.0.0",
|
|
52
|
+
"@podium/semantic-release-config": "2.0.0",
|
|
51
53
|
"@podium/test-utils": "3.1.0-next.5",
|
|
54
|
+
"@podium/typescript-config": "1.0.0",
|
|
52
55
|
"@semantic-release/changelog": "6.0.3",
|
|
53
56
|
"@semantic-release/git": "10.0.1",
|
|
54
57
|
"@semantic-release/github": "10.0.6",
|
|
55
58
|
"@semantic-release/npm": "12.0.1",
|
|
56
59
|
"@semantic-release/release-notes-generator": "13.0.0",
|
|
57
|
-
"eslint-config-prettier": "9.1.0",
|
|
58
|
-
"eslint-plugin-prettier": "5.1.3",
|
|
59
|
-
"express": "4.21.1",
|
|
60
|
-
"@podium/eslint-config": "1.0.0",
|
|
61
|
-
"@podium/semantic-release-config": "2.0.0",
|
|
62
|
-
"@podium/typescript-config": "1.0.0",
|
|
63
60
|
"@sinonjs/fake-timers": "11.3.1",
|
|
64
61
|
"@types/readable-stream": "4.0.18",
|
|
65
62
|
"benchmark": "2.1.4",
|
|
66
63
|
"eslint": "9.6.0",
|
|
64
|
+
"eslint-config-prettier": "9.1.0",
|
|
65
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
66
|
+
"express": "4.21.1",
|
|
67
67
|
"get-stream": "9.0.1",
|
|
68
68
|
"http-proxy": "1.18.1",
|
|
69
69
|
"is-stream": "4.0.1",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"prettier": "3.3.2",
|
|
72
72
|
"semantic-release": "24.1.2",
|
|
73
73
|
"tap": "18.7.2",
|
|
74
|
-
"typescript": "5.6.3"
|
|
74
|
+
"typescript": "5.6.3",
|
|
75
|
+
"why-is-node-running": "3.2.1"
|
|
75
76
|
}
|
|
76
77
|
}
|
package/types/http-outgoing.d.ts
CHANGED
|
@@ -124,9 +124,15 @@ export default class PodletClientHttpOutgoing extends PassThrough {
|
|
|
124
124
|
* @see https://podium-lib.io/docs/podlet/fallbacks
|
|
125
125
|
*/
|
|
126
126
|
get isFallback(): boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Set the assetsReceived flag.
|
|
129
|
+
* This is used to signal to the assets object that the client has received assets for a given podlet so it can track
|
|
130
|
+
* which podlets have sent their assets.
|
|
131
|
+
* @param {boolean} value
|
|
132
|
+
*/
|
|
133
|
+
set assetsReceived(value: boolean);
|
|
134
|
+
get assetsReceived(): boolean;
|
|
127
135
|
pushFallback(): void;
|
|
128
|
-
hintsReceived: boolean;
|
|
129
|
-
writeEarlyHints(cb?: () => void): void;
|
|
130
136
|
get [Symbol.toStringTag](): string;
|
|
131
137
|
#private;
|
|
132
138
|
}
|
package/types/resolver.d.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* @typedef {object} PodletClientResolverOptions
|
|
3
3
|
* @property {string} clientName
|
|
4
4
|
* @property {import('abslog').AbstractLoggerOptions} [logger]
|
|
5
|
-
* @property {boolean} [earlyHints]
|
|
6
5
|
*/
|
|
7
6
|
export default class PodletClientResolver {
|
|
8
7
|
/**
|
|
@@ -32,6 +31,5 @@ export default class PodletClientResolver {
|
|
|
32
31
|
export type PodletClientResolverOptions = {
|
|
33
32
|
clientName: string;
|
|
34
33
|
logger?: import("abslog").AbstractLoggerOptions;
|
|
35
|
-
earlyHints?: boolean;
|
|
36
34
|
};
|
|
37
35
|
import Metrics from '@metrics/client';
|