@podium/client
Advanced tools
Comparing version 5.3.0-next.1 to 5.3.0
@@ -1,2 +0,2 @@ | ||
# [5.3.0-next.1](https://github.com/podium-lib/client/compare/v5.2.0...v5.3.0-next.1) (2024-11-13) | ||
# [5.3.0](https://github.com/podium-lib/client/compare/v5.2.7...v5.3.0) (2025-02-07) | ||
@@ -6,4 +6,53 @@ | ||
* track podlet assets ([39022a3](https://github.com/podium-lib/client/commit/39022a3c87184e5f524828591c8185d8a3fc2995)) | ||
* add metric to track register podlets ([673a4e7](https://github.com/podium-lib/client/commit/673a4e7554282570d1a074ae7206873af7183dbe)) | ||
## [5.2.7](https://github.com/podium-lib/client/compare/v5.2.6...v5.2.7) (2025-02-06) | ||
### Bug Fixes | ||
* list exports so types work for imports other than root ([#454](https://github.com/podium-lib/client/issues/454)) ([b186bec](https://github.com/podium-lib/client/commit/b186bece4fd0feb82f4e64c4acf5f27dd6b06659)) | ||
## [5.2.6](https://github.com/podium-lib/client/compare/v5.2.5...v5.2.6) (2025-01-16) | ||
### Bug Fixes | ||
* **deps:** update dependency undici to v6.21.1 ([#453](https://github.com/podium-lib/client/issues/453)) ([2cf54ca](https://github.com/podium-lib/client/commit/2cf54cac312cf6cbb91da0e0f636433f2de7d892)) | ||
## [5.2.5](https://github.com/podium-lib/client/compare/v5.2.4...v5.2.5) (2024-11-27) | ||
### Bug Fixes | ||
* correctly build asset urls from link headers ([#446](https://github.com/podium-lib/client/issues/446)) ([5a30079](https://github.com/podium-lib/client/commit/5a30079fb47ee15a49ae6ff77348c400df3fe99a)) | ||
## [5.2.4](https://github.com/podium-lib/client/compare/v5.2.3...v5.2.4) (2024-11-21) | ||
### Bug Fixes | ||
* reducing logl evel to info on 404 errors ([e6d6d04](https://github.com/podium-lib/client/commit/e6d6d04a4b30729691cafa68521bcfc743c3db64)) | ||
## [5.2.3](https://github.com/podium-lib/client/compare/v5.2.2...v5.2.3) (2024-11-13) | ||
### Bug Fixes | ||
* **deps:** update dependency undici to v6.21.0 ([#445](https://github.com/podium-lib/client/issues/445)) ([6d26507](https://github.com/podium-lib/client/commit/6d26507709beffe5301f89ff7a5d03c358bbb423)) | ||
## [5.2.2](https://github.com/podium-lib/client/compare/v5.2.1...v5.2.2) (2024-11-13) | ||
### Bug Fixes | ||
* **deps:** update dependency @metrics/client to v2.5.4 ([#444](https://github.com/podium-lib/client/issues/444)) ([4f6bc04](https://github.com/podium-lib/client/commit/4f6bc0470a7ad01f32c6ea757cf853f7d2125db5)) | ||
## [5.2.1](https://github.com/podium-lib/client/compare/v5.2.0...v5.2.1) (2024-11-13) | ||
### Bug Fixes | ||
* **deps:** update dependency @podium/utils to v5.4.0 ([#443](https://github.com/podium-lib/client/issues/443)) ([efbe56b](https://github.com/podium-lib/client/commit/efbe56bbed26871566705856adbfa622702bdfa0)) | ||
# [5.2.0](https://github.com/podium-lib/client/compare/v5.1.18...v5.2.0) (2024-11-06) | ||
@@ -10,0 +59,0 @@ |
@@ -71,2 +71,3 @@ import EventEmitter from 'events'; | ||
#metrics; | ||
#counter; | ||
#histogram; | ||
@@ -148,2 +149,12 @@ #options; | ||
this.#counter = this.#metrics.counter({ | ||
name: 'podium_client_registered_podlet_count', | ||
description: 'Number of podlets registered with the client', | ||
labels: { | ||
clientName: this.#options.name, | ||
resourceName: undefined, | ||
resourceUri: undefined, | ||
}, | ||
}); | ||
this.#histogram = this.#metrics.histogram({ | ||
@@ -226,2 +237,9 @@ name: 'podium_client_refresh_manifests', | ||
this.#counter.inc({ | ||
labels: { | ||
resourceName: options.name, | ||
resourceUri: options.uri, | ||
}, | ||
}); | ||
resource.metrics.pipe(this.#metrics); | ||
@@ -228,0 +246,0 @@ |
import { PassThrough } from 'stream'; | ||
import assert from 'assert'; | ||
import { filterAssets } from './utils.js'; | ||
import { toPreloadAssetObjects, filterAssets } from './utils.js'; | ||
@@ -73,3 +73,2 @@ /** | ||
#css; | ||
#assetsReceived = false; | ||
@@ -337,22 +336,2 @@ /** | ||
get assetsReceived() { | ||
return this.#assetsReceived; | ||
} | ||
/** | ||
* Set the assetsReceived flag. | ||
* This is used to signal to the assets object that the client has received assets for a given podlet so it can track | ||
* which podlets have sent their assets. | ||
* @param {boolean} value | ||
*/ | ||
set assetsReceived(value) { | ||
this.#assetsReceived = value; | ||
if (this.#assetsReceived) { | ||
this.#incoming?.assets?.addReceivedAsset(this.#name, { | ||
js: this.js, | ||
css: this.css, | ||
}); | ||
} | ||
} | ||
pushFallback() { | ||
@@ -375,6 +354,19 @@ // @ts-expect-error Internal property | ||
this.#isFallback = true; | ||
// assume the assets from the podlet have failed and fallback assets will be used | ||
this.assetsReceived = true; | ||
// assume the hints from the podlet have failed and fallback assets will be used | ||
this.hintsReceived = true; | ||
} | ||
writeEarlyHints(cb = () => {}) { | ||
if (this.#incoming.response.writeEarlyHints) { | ||
const preloads = toPreloadAssetObjects([ | ||
...(this.js || []), | ||
...(this.css || []), | ||
]); | ||
const link = preloads.map((preload) => preload.toHeader()); | ||
if (link.length) { | ||
this.#incoming.response.writeEarlyHints({ link }, cb); | ||
} | ||
} | ||
} | ||
get [Symbol.toStringTag]() { | ||
@@ -381,0 +373,0 @@ return 'PodletClientHttpOutgoing'; |
@@ -162,3 +162,6 @@ import { pipeline } from 'stream'; | ||
const parsedAssetObjects = parseLinkHeaders(hdrs.link); | ||
const parsedAssetObjects = parseLinkHeaders( | ||
hdrs.link, | ||
outgoing.manifestUri, | ||
); | ||
@@ -209,3 +212,3 @@ const scriptObjects = parsedAssetObjects.filter( | ||
this.#log.warn( | ||
this.#log.debug( | ||
`remote resource responded with non 200 http status code for content - code: ${statusCode} - resource: ${outgoing.name} - url: ${uri}`, | ||
@@ -272,5 +275,2 @@ ); | ||
// mark assets as received | ||
outgoing.assetsReceived = true; | ||
// @ts-ignore | ||
@@ -277,0 +277,0 @@ pipeline([body, outgoing], (err) => { |
@@ -123,3 +123,6 @@ import abslog from 'abslog'; | ||
const parsedAssetObjects = parseLinkHeaders(resHeaders.link); | ||
const parsedAssetObjects = parseLinkHeaders( | ||
resHeaders.link, | ||
outgoing.manifestUri, | ||
); | ||
@@ -126,0 +129,0 @@ const scriptObjects = parsedAssetObjects.filter( |
@@ -14,2 +14,3 @@ import Metrics from '@metrics/client'; | ||
* @property {import('abslog').AbstractLoggerOptions} [logger] | ||
* @property {boolean} [earlyHints] | ||
*/ | ||
@@ -16,0 +17,0 @@ |
@@ -108,4 +108,2 @@ import Metrics from '@metrics/client'; | ||
); | ||
// set expectation to receive a response from this podlet. | ||
incoming.assets.addExpectedAsset(this.#options.name); | ||
const outgoing = new HttpOutgoing(this.#options, reqOptions, incoming); | ||
@@ -198,4 +196,2 @@ | ||
); | ||
// set expectation to receive a response from this podlet. | ||
incoming.assets.addExpectedAsset(this.#options.name); | ||
const outgoing = new HttpOutgoing(this.#options, reqOptions, incoming); | ||
@@ -202,0 +198,0 @@ this.#state.setInitializingState(); |
@@ -1,2 +0,2 @@ | ||
import { AssetJs, AssetCss } from '@podium/utils'; | ||
import { AssetJs, AssetCss, uriRelativeToAbsolute } from '@podium/utils'; | ||
@@ -78,3 +78,3 @@ /** | ||
// parse link headers in AssetCss and AssetJs objects | ||
export const parseLinkHeaders = (headers) => { | ||
export const parseLinkHeaders = (headers, manifestUri) => { | ||
const links = []; | ||
@@ -86,3 +86,6 @@ | ||
const [href, ...rest] = parts; | ||
const value = href.replace(/<|>|"/g, '').trim(); | ||
const value = uriRelativeToAbsolute( | ||
href.replace(/<|>|"/g, '').trim(), | ||
manifestUri, | ||
); | ||
@@ -89,0 +92,0 @@ const asset = { value }; |
{ | ||
"name": "@podium/client", | ||
"version": "5.3.0-next.1", | ||
"version": "5.3.0", | ||
"type": "module", | ||
@@ -31,2 +31,56 @@ "license": "MIT", | ||
"types": "./types/client.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./types/client.js", | ||
"default": "./lib/client.js" | ||
}, | ||
"./lib/client.js": { | ||
"types": "./types/client.js", | ||
"default": "./lib/client.js" | ||
}, | ||
"./lib/http-outgoing.js": { | ||
"types": "./types/http-outgoing.js", | ||
"default": "./lib/http-outgoing.js" | ||
}, | ||
"./lib/http.js": { | ||
"types": "./types/http.js", | ||
"default": "./lib/http.js" | ||
}, | ||
"./lib/resolver.cache.js": { | ||
"types": "./types/resolver.cache.js", | ||
"default": "./lib/resolver.cache.js" | ||
}, | ||
"./lib/resolver.content.js": { | ||
"types": "./types/resolver.content.js", | ||
"default": "./lib/resolver.content.js" | ||
}, | ||
"./lib/resolver.fallback.js": { | ||
"types": "./types/resolver.fallback.js", | ||
"default": "./lib/resolver.fallback.js" | ||
}, | ||
"./lib/resolver.js": { | ||
"types": "./types/resolver.js", | ||
"default": "./lib/resolver.js" | ||
}, | ||
"./lib/resolver.manifest.js": { | ||
"types": "./types/resolver.manifest.js", | ||
"default": "./lib/resolver.manifest.js" | ||
}, | ||
"./lib/resource.js": { | ||
"types": "./types/resource.js", | ||
"default": "./lib/resource.js" | ||
}, | ||
"./lib/response.js": { | ||
"types": "./types/response.js", | ||
"default": "./lib/response.js" | ||
}, | ||
"./lib/state.js": { | ||
"types": "./types/state.js", | ||
"default": "./lib/state.js" | ||
}, | ||
"./lib/utils.js": { | ||
"types": "./types/utils.js", | ||
"default": "./lib/utils.js" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -42,3 +96,3 @@ "lint": "eslint .", | ||
"@hapi/boom": "10.0.1", | ||
"@metrics/client": "2.5.3", | ||
"@metrics/client": "2.5.4", | ||
"@podium/schemas": "5.1.0", | ||
@@ -50,6 +104,6 @@ "@podium/utils": "5.4.0", | ||
"ttl-mem-cache": "4.1.0", | ||
"undici": "6.20.1" | ||
"undici": "6.21.1" | ||
}, | ||
"devDependencies": { | ||
"@podium/eslint-config": "1.0.0", | ||
"@podium/eslint-config": "1.0.5", | ||
"@podium/semantic-release-config": "2.0.0", | ||
@@ -66,11 +120,11 @@ "@podium/test-utils": "3.1.0-next.5", | ||
"benchmark": "2.1.4", | ||
"eslint": "9.6.0", | ||
"eslint": "9.17.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-prettier": "5.1.3", | ||
"express": "4.21.1", | ||
"eslint-plugin-prettier": "5.2.1", | ||
"express": "4.21.2", | ||
"get-stream": "9.0.1", | ||
"http-proxy": "1.18.1", | ||
"is-stream": "4.0.1", | ||
"npm-run-all2": "6.2.3", | ||
"prettier": "3.3.2", | ||
"npm-run-all2": "6.2.6", | ||
"prettier": "3.4.2", | ||
"semantic-release": "24.1.2", | ||
@@ -77,0 +131,0 @@ "tap": "18.7.2", |
@@ -5,5 +5,3 @@ # @podium/client v5 | ||
[![Dependencies](https://img.shields.io/david/podium-lib/client.svg)](https://david-dm.org/podium-lib/client) | ||
[![GitHub Actions status](https://github.com/podium-lib/client/workflows/Run%20Lint%20and%20Tests/badge.svg)](https://github.com/podium-lib/client/actions?query=workflow%3A%22Run+Lint+and+Tests%22) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/podium-lib/client/badge.svg?targetFile=package.json)](https://snyk.io/test/github/podium-lib/client?targetFile=package.json) | ||
@@ -156,2 +154,3 @@ This module is intended for internal use in Podium and is not a module an end | ||
- `includeBy` - {Object} - Inverse of `excludeBy`. Setting both at the same time will throw. - Optional. | ||
- `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). | ||
@@ -158,0 +157,0 @@ ##### `excludeBy` and `includeBy` |
@@ -127,11 +127,5 @@ /** | ||
get isFallback(): boolean; | ||
/** | ||
* Set the assetsReceived flag. | ||
* This is used to signal to the assets object that the client has received assets for a given podlet so it can track | ||
* which podlets have sent their assets. | ||
* @param {boolean} value | ||
*/ | ||
set assetsReceived(value: boolean); | ||
get assetsReceived(): boolean; | ||
pushFallback(): void; | ||
hintsReceived: boolean; | ||
writeEarlyHints(cb?: () => void): void; | ||
get [Symbol.toStringTag](): string; | ||
@@ -138,0 +132,0 @@ #private; |
@@ -5,2 +5,3 @@ /** | ||
* @property {import('abslog').AbstractLoggerOptions} [logger] | ||
* @property {boolean} [earlyHints] | ||
*/ | ||
@@ -35,3 +36,4 @@ export default class PodletClientResolver { | ||
logger?: import("abslog").AbstractLoggerOptions; | ||
earlyHints?: boolean; | ||
}; | ||
import Metrics from '@metrics/client'; |
@@ -5,3 +5,3 @@ export function isHeaderDefined(headers: object, header: string): boolean; | ||
export function filterAssets<T extends import("@podium/utils").AssetCss | import("@podium/utils").AssetJs>(scope: "content" | "fallback" | "all", assets: T[]): T[]; | ||
export function parseLinkHeaders(headers: any): any[]; | ||
export function parseLinkHeaders(headers: any, manifestUri: any): any[]; | ||
export function toPreloadAssetObjects(assetObjects: any): any; |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
186423
2633
0
689
+ Added@metrics/client@2.5.4(transitive)
+ Added@types/node@22.13.4(transitive)
+ Added@types/readable-stream@4.0.18(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedundici@6.21.1(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@metrics/client@2.5.3(transitive)
- Removedundici@6.20.1(transitive)
Updated@metrics/client@2.5.4
Updatedundici@6.21.1