@uniflowed/web 0.15.0 → 0.17.0
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/package.json +4 -4
- package/vitals.js +26 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniflowed/web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "The primitives a web page is built from, for the Unified Toolchain for Flow.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"!*.test.js"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@uniflowed/core": "0.
|
|
29
|
-
"@uniflowed/hooks": "0.
|
|
30
|
-
"@uniflowed/react": "0.
|
|
28
|
+
"@uniflowed/core": "0.17.0",
|
|
29
|
+
"@uniflowed/hooks": "0.17.0",
|
|
30
|
+
"@uniflowed/react": "0.17.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/vitals.js
CHANGED
|
@@ -136,6 +136,27 @@ export type CollectOptions = {
|
|
|
136
136
|
*/
|
|
137
137
|
export const VITALS_ENDPOINT: string = "/__uf/vitals";
|
|
138
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The routing base `installRouting` publishes, when it is a path.
|
|
141
|
+
*
|
|
142
|
+
* `@uniflowed/web` does not depend on `@uniflowed/router`. The string is the
|
|
143
|
+
* same one `npm/router/internal/base-path.js` writes with `Symbol.for`; the
|
|
144
|
+
* two have to move together, and the symbol is not part of the router's
|
|
145
|
+
* public API. The root is `""`, and anything that is not a path is ignored.
|
|
146
|
+
* ubugeeei-prod/uf#1701
|
|
147
|
+
*/
|
|
148
|
+
function routingBase(): string {
|
|
149
|
+
// Flow rejects `globalThis[symbol]` as a computed property on a namespace.
|
|
150
|
+
const published = (globalThis as $FlowFixMe)[Symbol.for("@uniflowed/router.basePath")];
|
|
151
|
+
return typeof published === "string" && published.startsWith("/") ? published : "";
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The default post, including `app.router.basePath` when one is installed. */
|
|
155
|
+
function defaultVitalsTarget(): string {
|
|
156
|
+
const base = routingBase();
|
|
157
|
+
return base === "" ? VITALS_ENDPOINT : `${base}${VITALS_ENDPOINT}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
139
160
|
/**
|
|
140
161
|
* The published boundaries, in the metric's own units.
|
|
141
162
|
*
|
|
@@ -673,7 +694,6 @@ export function vitalsBeacon(endpoint?: string): VitalsReporter {
|
|
|
673
694
|
return noop;
|
|
674
695
|
}
|
|
675
696
|
|
|
676
|
-
const target = endpoint ?? VITALS_ENDPOINT;
|
|
677
697
|
const pending: Array<Vital> = [];
|
|
678
698
|
let scheduled = false;
|
|
679
699
|
|
|
@@ -682,6 +702,11 @@ export function vitalsBeacon(endpoint?: string): VitalsReporter {
|
|
|
682
702
|
if (pending.length === 0) {
|
|
683
703
|
return;
|
|
684
704
|
}
|
|
705
|
+
// Resolved here, not when the reporter was built. This module evaluates
|
|
706
|
+
// before `installRouting`, and a base installed after that has to be on
|
|
707
|
+
// the post or Vite's base middleware 404s it. An endpoint the project
|
|
708
|
+
// named is used as written.
|
|
709
|
+
const target = endpoint ?? defaultVitalsTarget();
|
|
685
710
|
const body = JSON.stringify({ url: win.location?.href ?? "", vitals: pending });
|
|
686
711
|
pending.length = 0;
|
|
687
712
|
|