@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-cms/tce-preview-runtime",
3
- "version": "0.5.4",
3
+ "version": "0.5.5-beta.3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@lukeed/uuid": "^2.0.1",
package/src/App.vue CHANGED
@@ -9,18 +9,20 @@ interface ContentElement {
9
9
  id: number;
10
10
  uid: string;
11
11
  }
12
-
13
- const appUrl = new URL(window.location.href);
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 = appUrl.protocol === 'http:' ? 'ws:' : 'wss:';
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(`${wsProtocol}//${appUrl.host}${apiPrefix}`);
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 config = pick(process.env, [
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