@elench/testkit 0.1.136 → 0.1.137

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.
@@ -16,6 +16,7 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
16
16
  });
17
17
  const baseUrlByService = new Map();
18
18
  const readyUrlByService = new Map();
19
+ const publicBaseUrlByService = new Map();
19
20
  const stateDirByService = new Map();
20
21
 
21
22
  for (const config of runtimeConfigs) {
@@ -49,6 +50,9 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
49
50
  })
50
51
  );
51
52
  }
53
+ for (const [serviceName, baseUrl] of baseUrlByService.entries()) {
54
+ publicBaseUrlByService.set(serviceName, publicUrl(baseUrl, options.publicHost || null));
55
+ }
52
56
 
53
57
  const urlMappings = [];
54
58
  for (const config of runtimeConfigs) {
@@ -68,6 +72,8 @@ export function resolveRuntimeInstanceConfigs(runtimeConfigs, runtimeId, runtime
68
72
  portMap,
69
73
  baseUrlByService,
70
74
  readyUrlByService,
75
+ publicBaseUrlByService,
76
+ options.publicHost || null,
71
77
  stateDirByService,
72
78
  urlMappings
73
79
  )
@@ -114,6 +120,8 @@ export function resolveRuntimeConfig(
114
120
  portMap,
115
121
  baseUrlByService,
116
122
  readyUrlByService,
123
+ publicBaseUrlByService,
124
+ publicHost,
117
125
  stateDirByService,
118
126
  urlMappings
119
127
  ) {
@@ -130,6 +138,8 @@ export function resolveRuntimeConfig(
130
138
  portMap,
131
139
  baseUrlByService,
132
140
  readyUrlByService,
141
+ publicBaseUrlByService,
142
+ publicHost,
133
143
  stateDirByService,
134
144
  urlMappings,
135
145
  leaseId: null,
@@ -362,6 +372,16 @@ export function resolveTemplateString(value, context) {
362
372
  }
363
373
  return readyUrl;
364
374
  }
375
+ case "publicHost":
376
+ return context.publicHost || "127.0.0.1";
377
+ case "publicBaseUrl": {
378
+ const serviceName = arg || context.serviceName;
379
+ const publicBaseUrl = context.publicBaseUrlByService?.get(serviceName) || context.baseUrlByService.get(serviceName);
380
+ if (!publicBaseUrl) {
381
+ throw new Error(`Unknown publicBaseUrl placeholder for service "${serviceName}"`);
382
+ }
383
+ return publicBaseUrl;
384
+ }
365
385
  case "dbUrl":
366
386
  case "dbHost":
367
387
  case "dbPort":
@@ -377,6 +397,19 @@ export function resolveTemplateString(value, context) {
377
397
  });
378
398
  }
379
399
 
400
+ function publicUrl(rawUrl, publicHost) {
401
+ if (!publicHost) return rawUrl;
402
+ try {
403
+ const url = new URL(rawUrl);
404
+ url.hostname = publicHost;
405
+ let next = url.toString();
406
+ if (!rawUrl.endsWith("/") && url.pathname === "/" && next.endsWith("/")) next = next.slice(0, -1);
407
+ return next;
408
+ } catch {
409
+ return rawUrl;
410
+ }
411
+ }
412
+
380
413
  function resolveEnvTemplates(values, templateContext) {
381
414
  return Object.fromEntries(
382
415
  Object.entries(values || {}).map(([key, value]) => [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/next-analysis",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "description": "SWC-backed Next.js source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-bridge",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "description": "Browser bridge helpers for testkit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "typecheck": "tsc -p tsconfig.json --noEmit"
23
23
  },
24
24
  "dependencies": {
25
- "@elench/testkit-protocol": "0.1.136"
25
+ "@elench/testkit-protocol": "0.1.137"
26
26
  },
27
27
  "private": false
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/testkit-protocol",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "description": "Shared browser protocol for testkit bridge and extension consumers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elench/ts-analysis",
3
- "version": "0.1.136",
3
+ "version": "0.1.137",
4
4
  "description": "TypeScript compiler-backed source analysis primitives for Erench tools",
5
5
  "type": "module",
6
6
  "exports": {