@tailor-cms/tce-preview-runtime 0.5.4 → 0.5.5-beta.3
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 +1 -1
- package/src/App.vue +6 -4
- package/vite.config.ts +3 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -9,18 +9,20 @@ interface ContentElement {
|
|
|
9
9
|
id: number;
|
|
10
10
|
uid: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
const
|
|
12
|
+
const { VITE_SERVER_RUNTIME_URL } = import.meta.env;
|
|
13
|
+
const serverRuntimeUrl = new URL(VITE_SERVER_RUNTIME_URL);
|
|
14
14
|
const apiPrefix = '/tce-server';
|
|
15
15
|
const api = ky.create({ prefixUrl: apiPrefix });
|
|
16
|
-
const wsProtocol =
|
|
16
|
+
const wsProtocol = serverRuntimeUrl.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
17
17
|
|
|
18
18
|
const element = ref<ContentElement>();
|
|
19
19
|
const userState = ref({});
|
|
20
20
|
|
|
21
21
|
onMounted(async () => {
|
|
22
22
|
await getElement();
|
|
23
|
-
const ws = new WebSocket(
|
|
23
|
+
const ws = new WebSocket(
|
|
24
|
+
`${wsProtocol}//${serverRuntimeUrl.host}${apiPrefix}`,
|
|
25
|
+
);
|
|
24
26
|
ws.addEventListener('message', (message) => {
|
|
25
27
|
const event = JSON.parse(message.data);
|
|
26
28
|
const elementUid = element.value?.uid;
|
package/vite.config.ts
CHANGED
|
@@ -3,10 +3,12 @@ import pick from 'lodash/pick';
|
|
|
3
3
|
import vue from '@vitejs/plugin-vue';
|
|
4
4
|
import vuetify from 'vite-plugin-vuetify';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const env = process.env;
|
|
7
|
+
const config = pick(env, [
|
|
7
8
|
'EDIT_RUNTIME_URL',
|
|
8
9
|
'DISPLAY_RUNTIME_URL',
|
|
9
10
|
'SERVER_RUNTIME_URL',
|
|
11
|
+
'PREVIEW_RUNTIME_URL',
|
|
10
12
|
'PREVIEW_RUNTIME_PORT',
|
|
11
13
|
]);
|
|
12
14
|
|