release: WRNexusJS 0.5.10

This commit is contained in:
2026-07-30 13:36:29 +05:30
parent 8fc6f15402
commit d1b0c55b53
159 changed files with 7509 additions and 604 deletions
+1
View File
@@ -144,6 +144,7 @@ export {
currentAppName,
currentAppOrigin,
workspaceAppOrigins,
workspaceRootDomain,
} from "./workspace.ts";
export {
backoffDelay,
+23
View File
@@ -56,3 +56,26 @@ export function currentAppOrigin(): string | undefined {
export function workspaceAppOrigins(): Readonly<Record<string, string>> {
return Object.freeze({ ...workspaceOrigins() });
}
/** Shared DNS suffix for configured workspace apps (for example `staging.example.com`). */
export function workspaceRootDomain(): string {
const hosts = Object.values(workspaceOrigins()).map((origin) =>
new URL(origin).hostname.toLowerCase(),
);
if (!hosts.length) {
throw new Error("Workspace origins are unavailable.");
}
const labels = hosts.map((host) => host.split(".").reverse());
const common: string[] = [];
for (let index = 0; index < labels[0]!.length; index++) {
const label = labels[0]![index];
if (!labels.every((parts) => parts[index] === label)) break;
common.push(label!);
}
if (!common.length) {
throw new Error(`Workspace apps do not share a root domain: ${hosts.join(", ")}.`);
}
return common.reverse().join(".");
}