react-cosmos-core 6.2.4-canary.b5c8a03.0 → 6.2.4-canary.cd2cc87.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.
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CosmosMode } from '../server/serverTypes.js';
|
|
2
2
|
import { FixtureId } from '../userModules/fixtureTypes.js';
|
|
3
3
|
export type CosmosRendererUrl = null | string | {
|
|
4
4
|
dev: string;
|
|
5
5
|
export: string;
|
|
6
6
|
};
|
|
7
|
+
export declare function pickRendererUrl(rendererUrl: undefined | CosmosRendererUrl, mode: CosmosMode): null | string;
|
|
7
8
|
export declare function createRendererUrl(rendererUrl: string, fixtureId?: FixtureId, locked?: boolean): string;
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function createWebRendererUrl(rendererUrl: string, fixtureId?: FixtureId, locked?: boolean): string;
|
|
9
10
|
export declare function encodeRendererUrlFixture(fixtureId: FixtureId): string;
|
|
10
11
|
export declare function decodeRendererUrlFixture(fixture: string): FixtureId;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Base64 } from 'js-base64';
|
|
2
2
|
import { buildRendererQueryString } from './rendererQueryString.js';
|
|
3
|
+
export function pickRendererUrl(rendererUrl, mode) {
|
|
4
|
+
return rendererUrl && typeof rendererUrl === 'object'
|
|
5
|
+
? rendererUrl[mode]
|
|
6
|
+
: (rendererUrl ?? null);
|
|
7
|
+
}
|
|
3
8
|
export function createRendererUrl(rendererUrl, fixtureId, locked) {
|
|
4
9
|
if (hasFixtureVar(rendererUrl)) {
|
|
5
10
|
if (!fixtureId)
|
|
@@ -14,10 +19,8 @@ export function createRendererUrl(rendererUrl, fixtureId, locked) {
|
|
|
14
19
|
return baseUrl + buildRendererQueryString({ fixtureId, locked });
|
|
15
20
|
}
|
|
16
21
|
}
|
|
17
|
-
export function
|
|
18
|
-
return rendererUrl
|
|
19
|
-
? rendererUrl[command]
|
|
20
|
-
: (rendererUrl ?? null);
|
|
22
|
+
export function createWebRendererUrl(rendererUrl, fixtureId, locked) {
|
|
23
|
+
return applyWindowHostnameToRendererUrl(createRendererUrl(rendererUrl, fixtureId, locked));
|
|
21
24
|
}
|
|
22
25
|
export function encodeRendererUrlFixture(fixtureId) {
|
|
23
26
|
return Base64.encode(JSON.stringify(fixtureId));
|
|
@@ -40,3 +43,15 @@ function hostOnlyUrl(url) {
|
|
|
40
43
|
return false;
|
|
41
44
|
}
|
|
42
45
|
}
|
|
46
|
+
function applyWindowHostnameToRendererUrl(rendererUrl) {
|
|
47
|
+
try {
|
|
48
|
+
const url = new URL(rendererUrl);
|
|
49
|
+
const windowHostname = window.location.hostname;
|
|
50
|
+
if (url.hostname !== windowHostname && url.hostname === 'localhost')
|
|
51
|
+
url.hostname = windowHostname;
|
|
52
|
+
return url.toString();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return rendererUrl;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type CosmosMode = 'dev' | 'export';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cosmos-core",
|
|
3
|
-
"version": "6.2.4-canary.
|
|
3
|
+
"version": "6.2.4-canary.cd2cc87.0+cd2cc87",
|
|
4
4
|
"description": "React Cosmos Core",
|
|
5
5
|
"repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos-core",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,5 +11,5 @@
|
|
|
11
11
|
"js-base64": "3.7.7",
|
|
12
12
|
"lodash-es": "4.17.21"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "cd2cc87ee7c5272ebbe4ca8eab423fb77eadf2b6"
|
|
15
15
|
}
|