Skip to content

Commit 7def038

Browse files
committed
feat: create tauri-runtime package
Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
1 parent b9fd797 commit 7def038

File tree

19 files changed

+382
-212
lines changed

19 files changed

+382
-212
lines changed

.github/renovate.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
"matchUpdateTypes": ["major"],
77
"enabled": false
88
},
9+
{
10+
"matchFileNames": [
11+
"packaging/tauri/**",
12+
"packages/tauri-runtime/**"
13+
],
14+
"separateMajorMinor": false,
15+
"groupName": "tauri"
16+
},
917
{
1018
"matchManagers": [
1119
"npm"
@@ -31,13 +39,6 @@
3139
"separateMajorMinor": false,
3240
"groupName": "ci"
3341
},
34-
{
35-
"matchFileNames": [
36-
"packaging/tauri/**"
37-
],
38-
"separateMajorMinor": false,
39-
"groupName": "tauri"
40-
},
4142
{
4243
"matchUpdateTypes": [
4344
"lockFileMaintenance"

frontend/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
<meta name="mobile-web-app-capable" content="yes">
1111
<meta name="apple-mobile-web-app-capable" content="yes">
1212
<title>Jellyfin Vue</title>
13-
<script type="module" src="src/splashscreen.ts" fetchpriority="high"></script>
14-
<script type="module" src="src/main.ts"></script>
1513
</head>
1614
<body class="j-splash">
1715
<img src="./icon.svg" alt="Jellyfin Logo" loading="eager" decoding="sync">

frontend/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"imports": {
99
"#/*": "./src/*"
1010
},
11+
"exports": {
12+
".": "./src/main.ts",
13+
"./vite-config": "./vite.config.ts"
14+
},
1115
"scripts": {
1216
"analyze:bundle": "vite build --mode analyze:bundle",
1317
"analyze:cycles": "vite build --mode analyze:cycles",

frontend/scripts/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { resolve } from 'node:path';
22

3-
export const localeFilesFolder = resolve('locales/**');
3+
export const localeFilesFolder = resolve(import.meta.dirname, '../locales/**');

frontend/vite.config.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join } from 'node:path';
1+
import { resolve } from 'node:path';
22
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
33
import Virtual from '@rollup/plugin-virtual';
44
import VueDevTools from 'vite-plugin-vue-devtools';
@@ -16,24 +16,31 @@ import { defineConfig } from 'vite';
1616
* TODO: Replace with @jellyfin-vue/vite-plugins after https://github.com/vitejs/vite/issues/5370
1717
* is fixed
1818
*/
19-
import { BundleAnalysis, BundleChunking, BundleSizeReport } from '../packages/vite-plugins/src';
19+
import { JBundle, JMonorepo } from '../packages/vite-plugins/src';
2020
import { JellyfinVueUIToolkit } from '../packages/ui-toolkit/src/resolver';
2121
import virtualModules from './scripts/virtual-modules';
2222
import { localeFilesFolder } from './scripts/paths';
2323

2424
export default defineConfig({
2525
appType: 'spa',
2626
base: './',
27-
cacheDir: '../node_modules/.cache/vite',
2827
plugins: [
29-
BundleAnalysis(),
30-
BundleChunking(),
31-
BundleSizeReport(),
28+
...JBundle,
29+
JMonorepo(import.meta.dirname, {
30+
splashscreen: {
31+
'fetch-priority': 'high'
32+
}
33+
}),
3234
Virtual(virtualModules),
3335
VueRouter({
34-
dts: './types/global/routes.d.ts',
36+
dts: resolve(import.meta.dirname, 'types/global/routes.d.ts'),
3537
importMode: 'sync',
36-
routeBlockLang: 'yaml'
38+
routeBlockLang: 'yaml',
39+
routesFolder: [
40+
{
41+
src: resolve(import.meta.dirname, 'src/pages')
42+
}
43+
]
3744
}),
3845
Vue({
3946
template: {
@@ -44,7 +51,8 @@ export default defineConfig({
4451
}),
4552
// This plugin allows to autoimport Vue components
4653
Components({
47-
dts: './types/global/components.d.ts',
54+
dirs: [resolve(import.meta.dirname, 'src/components')],
55+
dts: resolve(import.meta.dirname, 'types/global/components.d.ts'),
4856
/**
4957
* The icons resolver finds icons components from 'unplugin-icons' using this convenction:
5058
* {prefix}-{collection}-{icon} e.g. <i-mdi-thumb-up />
@@ -78,18 +86,15 @@ export default defineConfig({
7886
* See main.ts for an explanation of this target
7987
*/
8088
target: 'esnext',
81-
/**
82-
* Disable chunk size warnings
83-
*/
8489
cssCodeSplit: true,
8590
cssMinify: 'lightningcss',
8691
modulePreload: false,
8792
reportCompressedSize: false,
8893
rollupOptions: {
8994
input: {
90-
splashscreen: join(import.meta.dirname, 'src/splashscreen.ts'),
91-
main: join(import.meta.dirname, 'src/main.ts'),
92-
index: join(import.meta.dirname, 'index.html')
95+
splashscreen: resolve(import.meta.dirname, 'src/splashscreen.ts'),
96+
main: resolve(import.meta.dirname, 'src/main.ts'),
97+
index: resolve(import.meta.dirname, 'index.html')
9398
},
9499
output: {
95100
validate: true

package-lock.json

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/configs/src/lint/rules/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { join, basename } from 'node:path';
1+
import { basename, resolve } from 'node:path';
22
import { spawnSync } from 'node:child_process';
33
import type { Linter } from 'eslint';
44
import { findUpSync } from 'find-up-simple';
@@ -35,7 +35,7 @@ export function getBaseConfig(packageName: string, forceCache = !CI_environment,
3535
const newArgs = process.argv.slice(1);
3636

3737
if (forceCache && !(newArgs.includes('--cache') && newArgs.includes('--cache-location'))) {
38-
const cacheLocation = join(findUpSync('node_modules', { type: 'directory' }) ?? '', '.cache/eslint', packageName.replace('/', '_'));
38+
const cacheLocation = resolve(findUpSync('node_modules', { type: 'directory' }) ?? '', '.cache/eslint', packageName.replace('/', '_'));
3939

4040
newArgs.push('--cache', '--cache-location', cacheLocation);
4141
console.log(`[@jellyfin-vue/configs/lint] (${packageName}) Force enabling caching for this run`);

packages/tauri-runtime/entrypoint.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import './src/main.ts';
2+
/**
3+
* The Tauri-specific code must be loaded before the frontend code to ensure that
4+
* all the polyfills for the runtime have been loaded
5+
* before the frontend code is executed.
6+
*
7+
* THIS IMPORT ALWAYS NEEDS TO BE THE LAST IMPORT IN THIS FILE
8+
*/
9+
import '@jellyfin-vue/frontend';
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Linter } from 'eslint';
2+
import { getBaseConfig, getNodeFiles, getTSVueConfig, tsFiles } from '@jellyfin-vue/configs/lint';
3+
import pkg from './package.json' with { type: 'json' };
4+
5+
export default [
6+
...getBaseConfig(pkg.name),
7+
...getTSVueConfig(false, import.meta.dirname),
8+
...getNodeFiles(tsFiles)
9+
] satisfies Linter.Config[];

packages/tauri-runtime/package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "@jellyfin-vue/tauri-runtime",
3+
"type": "module",
4+
"description": "The frontend including tauri-specific runtime code",
5+
"scripts": {
6+
"analyze:bundle": "vite build --mode analyze:bundle",
7+
"analyze:cycles": "vite build --mode analyze:cycles",
8+
"lint": "eslint . --flag unstable_ts_config",
9+
"lint:fix": "eslint . --fix --flag unstable_ts_config",
10+
"lint:inspect": "eslint-config-inspector",
11+
"build": "vite build",
12+
"check": "npm run lint && npm run check:types",
13+
"check:types": "vue-tsc",
14+
"start": "vite",
15+
"serve": "vite preview",
16+
"prod": "npm run build && npm run serve",
17+
"clean": "git clean -fxd"
18+
},
19+
"devDependencies": {
20+
"@jellyfin-vue/configs": "*",
21+
"vite": "6.0.7"
22+
},
23+
"dependencies": {
24+
"@jellyfin-vue/frontend": "*"
25+
}
26+
}

packages/tauri-runtime/src/main.ts

Whitespace-only changes.

packages/tauri-runtime/tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"extends": "@jellyfin-vue/configs/typescript",
3+
"compilerOptions": {
4+
"baseUrl": "."
5+
},
6+
"exclude": [
7+
"dist",
8+
"node_modules",
9+
"coverage"
10+
],
11+
"include": [
12+
"**/*.ts"
13+
]
14+
}

packages/tauri-runtime/vite.config.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { resolve } from 'node:path';
2+
import { defineConfig, mergeConfig } from 'vite';
3+
// @ts-expect-error - This error will be fixed once the Vite team adds monorepo support for config files
4+
import BaseConfig from '../../frontend/vite.config.ts';
5+
6+
const host = process.env.TAURI_DEV_HOST;
7+
8+
export default defineConfig(
9+
mergeConfig(BaseConfig, {
10+
// prevent vite from obscuring rust errors
11+
clearScreen: false,
12+
build: {
13+
outDir: resolve(import.meta.dirname, 'dist'),
14+
rollupOptions: {
15+
input: {
16+
main: resolve(import.meta.dirname, 'entrypoint.ts')
17+
}
18+
},
19+
// don't minify for debug builds
20+
minify: process.env.TAURI_ENV_DEBUG ? false : 'esbuild',
21+
// produce sourcemaps for debug builds
22+
sourcemap: !!process.env.TAURI_ENV_DEBUG
23+
},
24+
server: {
25+
// Tauri expects a fixed port, fail if that port is not available
26+
strictPort: true,
27+
// if the host Tauri is expecting is set, use it
28+
...(host ? { host } : {})
29+
},
30+
// Env variables starting with the item of `envPrefix` will be exposed in tauri's source code through `import.meta.env`.
31+
envPrefix: ['VITE_', 'TAURI_ENV_*']
32+
})
33+
);

packages/vite-plugins/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"devDependencies": {
1313
"@jellyfin-vue/configs": "*",
14+
"find-up-simple": "1.0.0",
1415
"pretty-bytes": "6.1.1",
1516
"sonda": "0.7.1",
1617
"vite": "6.0.7"

0 commit comments

Comments
 (0)