Skip to content

Commit 101b369

Browse files
authored
Merge pull request Sofie-Automation#1273 from bbc/upstream/r52-ui-bugs
fix: vite related ui bugs
2 parents e560a4c + 339f8cb commit 101b369

File tree

8 files changed

+55
-5
lines changed

8 files changed

+55
-5
lines changed

meteor/server/api/rest/koa.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare module 'http' {
1818
}
1919

2020
const rootRouter = new KoaRouter()
21+
const boundRouterPaths: string[] = []
2122

2223
Meteor.startup(() => {
2324
const koaApp = new Koa()
@@ -51,7 +52,8 @@ Meteor.startup(() => {
5152

5253
// serve the webui through koa
5354
// This is to avoid meteor injecting anything into the served html
54-
koaApp.use(staticServe(public_dir))
55+
const webuiServer = staticServe(public_dir)
56+
koaApp.use(webuiServer)
5557
logger.debug(`Serving static files from ${public_dir}`)
5658

5759
// Serve the meteor runtime config
@@ -66,9 +68,31 @@ Meteor.startup(() => {
6668
})
6769

6870
koaApp.use(rootRouter.routes()).use(rootRouter.allowedMethods())
71+
72+
koaApp.use(async (ctx, next) => {
73+
if (ctx.method !== 'GET') return next()
74+
75+
// Don't use the fallback for certain paths
76+
if (ctx.path.startsWith('/assets/')) return next()
77+
78+
// Don't use the fallback for anything handled by another router
79+
// This does not feel efficient, but koa doesn't appear to have any shared state between the router handlers
80+
for (const bindPath of boundRouterPaths) {
81+
if (ctx.path.startsWith(bindPath)) return next()
82+
}
83+
84+
// fallback to the root file
85+
ctx.path = '/'
86+
return webuiServer(ctx, next)
87+
})
6988
})
7089

7190
export function bindKoaRouter(koaRouter: KoaRouter, bindPath: string): void {
91+
// Track this path as having a router
92+
let bindPathFull = bindPath
93+
if (!bindPathFull.endsWith('/')) bindPathFull += '/'
94+
boundRouterPaths.push(bindPathFull)
95+
7296
rootRouter.use(bindPath, koaRouter.routes()).use(bindPath, koaRouter.allowedMethods())
7397
}
7498

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
diff --git a/lib/timecode.js b/lib/timecode.js
2+
index ef4028e2ebc3b5480e93d88a38627454553e3502..a521b33cd239c38dfced835410aa57e8be9246ca 100644
3+
--- a/lib/timecode.js
4+
+++ b/lib/timecode.js
5+
@@ -217,3 +217,5 @@ var exports = exports || window;
6+
7+
exports.Timecode = Timecode;
8+
9+
+// Vite needs a more modern export
10+
+module.exports = { Timecode }
11+
\ No newline at end of file

packages/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@
6868
"typescript": "~4.9.5"
6969
},
7070
"name": "packages",
71-
"packageManager": "[email protected]"
71+
"packageManager": "[email protected]",
72+
"resolutions": {
73+
"[email protected]": "patch:timecode@npm%3A0.0.4#./.yarn/patches/timecode-npm-0.0.4-82bde9e6fe.patch"
74+
}
7275
}

packages/webui/.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const tsBase = {
4242
extends: [...tsExtends],
4343
plugins: tsPlugins,
4444
...tsParser,
45-
parserOptions: { project: './packages/webui/tsconfig.eslint.json' },
45+
parserOptions: { project: './tsconfig.eslint.json' },
4646
settings: {
4747
node: {
4848
tryExtensions: ['.js', '.json', '.node', '.ts', '.tsx', '.d.ts'],

packages/webui/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!DOCTYPE html>
12
<head>
23
<title>Sofie</title>
34
<meta charset="utf-8" />

packages/webui/src/client/styles/main.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ input {
3030
@import 'prompter';
3131
@import 'rundownList';
3232
@import 'rundownSystemStatus';
33-
@import 'rundownView';
3433
@import 'settings';
3534
@import 'splitDropdown';
3635
@import 'statusbar';
@@ -104,6 +103,8 @@ input {
104103
@import '../ui/RundownView/MediaStatusPopUp/MediaStatusPopUpSegmentRule.scss';
105104
@import '../ui/SegmentAdlibTesting/SegmentAdlibTesting.scss';
106105

106+
@import 'rundownView';
107+
107108
body {
108109
overscroll-behavior: none;
109110
touch-action: pan-x pan-y;

packages/webui/src/client/ui/SegmentTimeline/TimelineGrid.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ declare class FontFace {
2121
load(): void
2222
}
2323

24-
const LABEL_FONT_URL = 'url("/fonts/roboto-gh-pages/fonts/Light/Roboto-Light.woff")'
24+
const LABEL_FONT_URL = `url("${new URL(
25+
'../../../fonts/roboto-gh-pages/fonts/Light/Roboto-Light.woff2',
26+
import.meta.url
27+
)}")`
2528
const LABEL_COLOR = 'rgb(80,80,80)'
2629
const SHORT_LINE_GRID_COLOR = 'rgb(112,112,112)'
2730
const LONG_LINE_GRID_COLOR = 'rgb(80,80,80)'

packages/yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26028,6 +26028,13 @@ asn1@evs-broadcast/node-asn1:
2602826028
languageName: node
2602926029
linkType: hard
2603026030

26031+
"timecode@patch:timecode@npm%3A0.0.4#./.yarn/patches/timecode-npm-0.0.4-82bde9e6fe.patch::locator=packages%40workspace%3A.":
26032+
version: 0.0.4
26033+
resolution: "timecode@patch:timecode@npm%3A0.0.4#./.yarn/patches/timecode-npm-0.0.4-82bde9e6fe.patch::version=0.0.4&hash=4d4986&locator=packages%40workspace%3A."
26034+
checksum: da05fb8e2f907a5bdb538c00ccaf216447337a568d9efddcb3835c130929fef2aeb864a5eba0381847e9404dbb412012806e0e02fd881562c82ae23c61ef139c
26035+
languageName: node
26036+
linkType: hard
26037+
2603126038
"timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240909-111856-517f0ee37.0":
2603226039
version: 9.2.0-nightly-release52-20240909-111856-517f0ee37.0
2603326040
resolution: "timeline-state-resolver-types@npm:9.2.0-nightly-release52-20240909-111856-517f0ee37.0"

0 commit comments

Comments
 (0)