@roj-ai/client 0.1.11 → 0.1.13
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/dist/platform/urls.d.ts
CHANGED
|
@@ -10,14 +10,21 @@ export interface BuildPreviewUrlOptions {
|
|
|
10
10
|
token?: string;
|
|
11
11
|
/** Platform URL for path-based preview (used when subdomains aren't available) */
|
|
12
12
|
platformUrl?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Force path-based URL construction. Required for hosts that don't route
|
|
15
|
+
* wildcard subdomains to the same handler (notably `@roj-ai/standalone-server`,
|
|
16
|
+
* which routes by path only). Has no effect without `platformUrl`.
|
|
17
|
+
*/
|
|
18
|
+
pathBased?: boolean;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
21
|
* Build a dev preview URL for a service running in a roj sandbox.
|
|
16
22
|
*
|
|
17
23
|
* Production: https://dev-{slug}-{code}.{baseDomain}/
|
|
18
|
-
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/
|
|
24
|
+
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/ (when pathBased
|
|
25
|
+
* or running behind a Cloudflare quick tunnel)
|
|
19
26
|
*/
|
|
20
|
-
export declare function buildPreviewUrl({ instanceId, code, baseDomain, token, platformUrl }: BuildPreviewUrlOptions): string;
|
|
27
|
+
export declare function buildPreviewUrl({ instanceId, code, baseDomain, token, platformUrl, pathBased, }: BuildPreviewUrlOptions): string;
|
|
21
28
|
export interface BuildWsUrlOptions {
|
|
22
29
|
platformUrl: string;
|
|
23
30
|
instanceId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/platform/urls.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/platform/urls.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,MAAM,WAAW,sBAAsB;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC/B,UAAU,EACV,IAAI,EACJ,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,GACT,EAAE,sBAAsB,GAAG,MAAM,CAejC;AAED,MAAM,WAAW,iBAAiB;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAMnG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE/E"}
|
package/dist/platform/urls.js
CHANGED
|
@@ -8,11 +8,14 @@ export function instanceIdToHex(instanceId) {
|
|
|
8
8
|
* Build a dev preview URL for a service running in a roj sandbox.
|
|
9
9
|
*
|
|
10
10
|
* Production: https://dev-{slug}-{code}.{baseDomain}/
|
|
11
|
-
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/
|
|
11
|
+
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/ (when pathBased
|
|
12
|
+
* or running behind a Cloudflare quick tunnel)
|
|
12
13
|
*/
|
|
13
|
-
export function buildPreviewUrl({ instanceId, code, baseDomain, token, platformUrl }) {
|
|
14
|
-
//
|
|
15
|
-
|
|
14
|
+
export function buildPreviewUrl({ instanceId, code, baseDomain, token, platformUrl, pathBased, }) {
|
|
15
|
+
// Path-based fallback: explicit opt-in (standalone server) or quick tunnel
|
|
16
|
+
// (already a subdomain — can't nest further).
|
|
17
|
+
const forcePathBased = pathBased || baseDomain.includes('trycloudflare.com');
|
|
18
|
+
if (forcePathBased && platformUrl) {
|
|
16
19
|
const base = `${platformUrl}/api/v1/instances/${instanceId}/preview/${code}`;
|
|
17
20
|
return token ? `${base}/?token=${encodeURIComponent(token)}` : base;
|
|
18
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/platform/urls.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IACjD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AAClD,CAAC;
|
|
1
|
+
{"version":3,"file":"urls.js","sourceRoot":"","sources":["../../src/platform/urls.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAAkB;IACjD,OAAO,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AAClD,CAAC;AAkBD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAC/B,UAAU,EACV,IAAI,EACJ,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,GACe;IACxB,2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,CAAC,QAAQ,EAAE,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,UAAkB;IACtE,OAAO,GAAG,WAAW,qBAAqB,UAAU,EAAE,CAAA;AACvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roj-ai/client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"type-check": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@roj-ai/shared": "^0.1.
|
|
43
|
+
"@roj-ai/shared": "^0.1.13"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "5.9.3"
|
package/src/platform/urls.ts
CHANGED
|
@@ -13,17 +13,33 @@ export interface BuildPreviewUrlOptions {
|
|
|
13
13
|
token?: string
|
|
14
14
|
/** Platform URL for path-based preview (used when subdomains aren't available) */
|
|
15
15
|
platformUrl?: string
|
|
16
|
+
/**
|
|
17
|
+
* Force path-based URL construction. Required for hosts that don't route
|
|
18
|
+
* wildcard subdomains to the same handler (notably `@roj-ai/standalone-server`,
|
|
19
|
+
* which routes by path only). Has no effect without `platformUrl`.
|
|
20
|
+
*/
|
|
21
|
+
pathBased?: boolean
|
|
16
22
|
}
|
|
17
23
|
|
|
18
24
|
/**
|
|
19
25
|
* Build a dev preview URL for a service running in a roj sandbox.
|
|
20
26
|
*
|
|
21
27
|
* Production: https://dev-{slug}-{code}.{baseDomain}/
|
|
22
|
-
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/
|
|
28
|
+
* Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/ (when pathBased
|
|
29
|
+
* or running behind a Cloudflare quick tunnel)
|
|
23
30
|
*/
|
|
24
|
-
export function buildPreviewUrl({
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
export function buildPreviewUrl({
|
|
32
|
+
instanceId,
|
|
33
|
+
code,
|
|
34
|
+
baseDomain,
|
|
35
|
+
token,
|
|
36
|
+
platformUrl,
|
|
37
|
+
pathBased,
|
|
38
|
+
}: BuildPreviewUrlOptions): string {
|
|
39
|
+
// Path-based fallback: explicit opt-in (standalone server) or quick tunnel
|
|
40
|
+
// (already a subdomain — can't nest further).
|
|
41
|
+
const forcePathBased = pathBased || baseDomain.includes('trycloudflare.com')
|
|
42
|
+
if (forcePathBased && platformUrl) {
|
|
27
43
|
const base = `${platformUrl}/api/v1/instances/${instanceId}/preview/${code}`
|
|
28
44
|
return token ? `${base}/?token=${encodeURIComponent(token)}` : base
|
|
29
45
|
}
|