@tailor-cms/tce-preview-runtime 0.2.2 → 0.4.0-beta.2

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,11 +1,12 @@
1
1
  {
2
2
  "name": "@tailor-cms/tce-preview-runtime",
3
- "version": "0.2.2",
3
+ "version": "0.4.0-beta.2",
4
4
  "dependencies": {
5
5
  "@mdi/font": "7.2.96",
6
6
  "@vitejs/plugin-vue": "4.3.4",
7
7
  "@vueuse/core": "10.4.1",
8
8
  "ky": "1.0.1",
9
+ "lodash": "^4.17.21",
9
10
  "sass": "1.68.0",
10
11
  "split.js": "1.6.5",
11
12
  "typescript": "5.2.2",
package/src/App.vue CHANGED
@@ -5,9 +5,11 @@ import ky from 'ky';
5
5
  import AppBar from './components/AppBar.vue';
6
6
  import MainLayout from './components/MainLayout.vue';
7
7
 
8
- const SERVER_HOST = `localhost:${import.meta.env.VITE_TCE_SERVER_PORT || 8030}`;
9
- const api = ky.create({ prefixUrl: `http://${SERVER_HOST}` });
10
- const ws = new WebSocket(`ws://${SERVER_HOST}`);
8
+ const appUrl = new URL(window.location.href);
9
+ const apiPrefix = '/tce-server';
10
+ const api = ky.create({ prefixUrl: apiPrefix });
11
+ const wsProtocol = appUrl.protocol === 'http:' ? 'ws:' : 'wss:';
12
+ const ws = new WebSocket(`${wsProtocol}//${appUrl.host}${apiPrefix}`);
11
13
 
12
14
  const element = ref({});
13
15
  onMounted(async () => {
@@ -2,11 +2,11 @@
2
2
  import logoUrl from '../assets/logo.png';
3
3
  import { useGlobalState } from '../state';
4
4
 
5
- const { isDark, showEdit, showDisplay, showBothComponents } = useGlobalState();
5
+ const { showEdit, showDisplay, showBothComponents } = useGlobalState();
6
6
  </script>
7
7
 
8
8
  <template>
9
- <v-app-bar :color="isDark ? 'grey-darken-4' : 'grey-lighten-4'" elevation="1">
9
+ <v-app-bar color="blue-grey-darken-4" elevation="6">
10
10
  <template #prepend>
11
11
  <v-app-bar-nav-icon class="ml-2">
12
12
  <img :src="logoUrl" alt="Tailor logo" width="36" />
@@ -16,7 +16,7 @@ const { isDark, showEdit, showDisplay, showBothComponents } = useGlobalState();
16
16
  Content Element Kit
17
17
  <v-chip
18
18
  class="ml-3 mb-1 text-body-2"
19
- color="teal-accent-4"
19
+ color="#23F48B"
20
20
  density="compact"
21
21
  variant="tonal"
22
22
  >
@@ -24,17 +24,13 @@ const { isDark, showEdit, showDisplay, showBothComponents } = useGlobalState();
24
24
  </v-chip>
25
25
  </v-app-bar-title>
26
26
  <v-spacer />
27
- <v-btn-toggle
28
- :variant="isDark ? 'flat' : 'tonal'"
29
- class="mr-4"
30
- density="compact"
31
- >
27
+ <v-btn-toggle class="mr-4" density="compact">
32
28
  <v-btn @click="showEdit">
33
- <span>Edit</span>
29
+ <span>Authoring</span>
34
30
  <v-icon end>mdi-pencil</v-icon>
35
31
  </v-btn>
36
32
  <v-btn @click="showDisplay">
37
- <span>Display</span>
33
+ <span>End-user</span>
38
34
  <v-icon end>mdi-fullscreen</v-icon>
39
35
  </v-btn>
40
36
  <v-btn @click="showBothComponents">
@@ -3,10 +3,10 @@
3
3
  <div :id="PANELS.EDIT" class="d-flex flex-1-1-50">
4
4
  <iframe
5
5
  :key="`author-${isLoaded ? new Date().getTime() : 0}`"
6
+ :src="VITE_EDIT_RUNTIME_URL"
6
7
  class="flex-1-1-100"
7
8
  frameBorder="0"
8
9
  sandbox="allow-scripts"
9
- src="http://localhost:8010"
10
10
  title="Edit component container"
11
11
  >
12
12
  </iframe>
@@ -14,10 +14,10 @@
14
14
  <div :id="PANELS.DISPLAY" class="d-flex flex-1-1-50">
15
15
  <iframe
16
16
  :key="`display-${isLoaded ? new Date().getTime() : 0}`"
17
+ :src="VITE_DISPLAY_RUNTIME_URL"
17
18
  class="flex-1-1-100"
18
19
  frameBorder="0"
19
20
  sandbox="allow-scripts"
20
- src="http://localhost:8020"
21
21
  title="Display component container"
22
22
  >
23
23
  </iframe>
@@ -31,6 +31,7 @@ import Split from 'split.js';
31
31
 
32
32
  import { PANELS, useGlobalState } from '../state';
33
33
 
34
+ const { VITE_DISPLAY_RUNTIME_URL, VITE_EDIT_RUNTIME_URL } = import.meta.env;
34
35
  const { previewPanelSplit } = useGlobalState();
35
36
 
36
37
  defineProps<{ isLoaded: Boolean }>();
package/vite.config.ts CHANGED
@@ -1,14 +1,36 @@
1
1
  import { defineConfig } from 'vite';
2
+ import pick from 'lodash/pick';
2
3
  import vue from '@vitejs/plugin-vue';
3
4
  import vuetify from 'vite-plugin-vuetify';
4
5
 
6
+ const config = pick(process.env, [
7
+ 'EDIT_RUNTIME_URL',
8
+ 'DISPLAY_RUNTIME_URL',
9
+ 'SERVER_RUNTIME_URL',
10
+ 'PREVIEW_RUNTIME_PORT',
11
+ ]);
12
+
13
+ // Expose to Frontend by prefixing with VITE_
14
+ Object.entries(config).forEach(
15
+ ([k, v]) => (process.env[`VITE_${k}`] = v as string),
16
+ );
17
+
5
18
  // https://vitejs.dev/config/
6
19
  export default defineConfig((): any => {
7
20
  return {
8
21
  root: './src',
9
22
  server: {
10
- host: '0.0.0.0', // Accept connections from any host (Docker)
11
- port: 8080,
23
+ // Accept connections from any host (Docker)
24
+ host: '0.0.0.0',
25
+ port: parseInt(config.PREVIEW_RUNTIME_PORT, 10),
26
+ proxy: {
27
+ '/tce-server': {
28
+ target: config.SERVER_RUNTIME_URL,
29
+ ws: true,
30
+ changeOrigin: true,
31
+ rewrite: (path) => path.replace(/^\/tce-server/, ''),
32
+ },
33
+ },
12
34
  },
13
35
  logLevel: 'warn',
14
36
  optimizeDeps: { entries: ['./src/main.js'] },