Update Hilla to 24.6.0

Fix plugin loading due to unavailable status from DB
This commit is contained in:
grimsi
2024-12-18 18:29:03 +01:00
parent 79119fc467
commit 774f904334
7 changed files with 5091 additions and 15314 deletions
+4982 -15166
View File
File diff suppressed because it is too large Load Diff
+59 -59
View File
@@ -7,22 +7,22 @@
"@nextui-org/react": "^2.4.8",
"@phosphor-icons/react": "^2.1.7",
"@polymer/polymer": "3.5.2",
"@vaadin/bundles": "24.5.4",
"@vaadin/bundles": "24.6.0",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/hilla-file-router": "24.5.7",
"@vaadin/hilla-frontend": "24.5.7",
"@vaadin/hilla-lit-form": "24.5.7",
"@vaadin/hilla-react-auth": "24.5.7",
"@vaadin/hilla-react-crud": "24.5.7",
"@vaadin/hilla-react-form": "24.5.7",
"@vaadin/hilla-react-i18n": "24.5.7",
"@vaadin/hilla-react-signals": "24.5.7",
"@vaadin/polymer-legacy-adapter": "24.5.4",
"@vaadin/react-components": "24.5.4",
"@vaadin/hilla-file-router": "24.6.0",
"@vaadin/hilla-frontend": "24.6.0",
"@vaadin/hilla-lit-form": "24.6.0",
"@vaadin/hilla-react-auth": "24.6.0",
"@vaadin/hilla-react-crud": "24.6.0",
"@vaadin/hilla-react-form": "24.6.0",
"@vaadin/hilla-react-i18n": "24.6.0",
"@vaadin/hilla-react-signals": "24.6.0",
"@vaadin/polymer-legacy-adapter": "24.6.0",
"@vaadin/react-components": "24.6.0",
"@vaadin/vaadin-development-mode-detector": "2.0.7",
"@vaadin/vaadin-lumo-styles": "24.5.4",
"@vaadin/vaadin-material-styles": "24.5.4",
"@vaadin/vaadin-themable-mixin": "24.5.4",
"@vaadin/vaadin-lumo-styles": "24.6.0",
"@vaadin/vaadin-material-styles": "24.6.0",
"@vaadin/vaadin-themable-mixin": "24.6.0",
"@vaadin/vaadin-usage-statistics": "2.1.3",
"class-variance-authority": "^0.7.0",
"classnames": "^2.5.1",
@@ -46,25 +46,25 @@
"yup": "^1.4.0"
},
"devDependencies": {
"@babel/preset-react": "7.25.9",
"@babel/preset-react": "7.26.3",
"@lit-labs/react": "^2.1.3",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
"@types/node": "^22.4.0",
"@types/react": "18.3.12",
"@types/react": "18.3.13",
"@types/react-dom": "18.3.1",
"@vaadin/hilla-generator-cli": "24.5.7",
"@vaadin/hilla-generator-core": "24.5.7",
"@vaadin/hilla-generator-plugin-backbone": "24.5.7",
"@vaadin/hilla-generator-plugin-barrel": "24.5.7",
"@vaadin/hilla-generator-plugin-client": "24.5.7",
"@vaadin/hilla-generator-plugin-model": "24.5.7",
"@vaadin/hilla-generator-plugin-push": "24.5.7",
"@vaadin/hilla-generator-plugin-signals": "24.5.7",
"@vaadin/hilla-generator-plugin-subtypes": "24.5.7",
"@vaadin/hilla-generator-utils": "24.5.7",
"@vitejs/plugin-react": "4.3.3",
"@vaadin/hilla-generator-cli": "24.6.0",
"@vaadin/hilla-generator-core": "24.6.0",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0",
"@vaadin/hilla-generator-plugin-client": "24.6.0",
"@vaadin/hilla-generator-plugin-model": "24.6.0",
"@vaadin/hilla-generator-plugin-push": "24.6.0",
"@vaadin/hilla-generator-plugin-signals": "24.6.0",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0",
"@vaadin/hilla-generator-utils": "24.6.0",
"@vitejs/plugin-react": "4.3.4",
"@vitejs/plugin-react-swc": "^3.7.0",
"async": "3.2.6",
"autoprefixer": "^10.4.20",
@@ -76,8 +76,8 @@
"strip-css-comments": "5.0.0",
"tailwindcss": "^3.4.10",
"transform-ast": "2.4.4",
"typescript": "5.6.3",
"vite": "5.4.11",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
@@ -129,22 +129,22 @@
"vaadin": {
"dependencies": {
"@polymer/polymer": "3.5.2",
"@vaadin/bundles": "24.5.4",
"@vaadin/bundles": "24.6.0",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/hilla-file-router": "24.5.7",
"@vaadin/hilla-frontend": "24.5.7",
"@vaadin/hilla-lit-form": "24.5.7",
"@vaadin/hilla-react-auth": "24.5.7",
"@vaadin/hilla-react-crud": "24.5.7",
"@vaadin/hilla-react-form": "24.5.7",
"@vaadin/hilla-react-i18n": "24.5.7",
"@vaadin/hilla-react-signals": "24.5.7",
"@vaadin/polymer-legacy-adapter": "24.5.4",
"@vaadin/react-components": "24.5.4",
"@vaadin/hilla-file-router": "24.6.0",
"@vaadin/hilla-frontend": "24.6.0",
"@vaadin/hilla-lit-form": "24.6.0",
"@vaadin/hilla-react-auth": "24.6.0",
"@vaadin/hilla-react-crud": "24.6.0",
"@vaadin/hilla-react-form": "24.6.0",
"@vaadin/hilla-react-i18n": "24.6.0",
"@vaadin/hilla-react-signals": "24.6.0",
"@vaadin/polymer-legacy-adapter": "24.6.0",
"@vaadin/react-components": "24.6.0",
"@vaadin/vaadin-development-mode-detector": "2.0.7",
"@vaadin/vaadin-lumo-styles": "24.5.4",
"@vaadin/vaadin-material-styles": "24.5.4",
"@vaadin/vaadin-themable-mixin": "24.5.4",
"@vaadin/vaadin-lumo-styles": "24.6.0",
"@vaadin/vaadin-material-styles": "24.6.0",
"@vaadin/vaadin-themable-mixin": "24.6.0",
"@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3",
@@ -154,36 +154,36 @@
"react-router-dom": "6.28.0"
},
"devDependencies": {
"@babel/preset-react": "7.25.9",
"@babel/preset-react": "7.26.3",
"@preact/signals-react-transform": "0.4.0",
"@rollup/plugin-replace": "6.0.1",
"@rollup/pluginutils": "5.1.3",
"@types/react": "18.3.12",
"@types/react": "18.3.13",
"@types/react-dom": "18.3.1",
"@vaadin/hilla-generator-cli": "24.5.7",
"@vaadin/hilla-generator-core": "24.5.7",
"@vaadin/hilla-generator-plugin-backbone": "24.5.7",
"@vaadin/hilla-generator-plugin-barrel": "24.5.7",
"@vaadin/hilla-generator-plugin-client": "24.5.7",
"@vaadin/hilla-generator-plugin-model": "24.5.7",
"@vaadin/hilla-generator-plugin-push": "24.5.7",
"@vaadin/hilla-generator-plugin-signals": "24.5.7",
"@vaadin/hilla-generator-plugin-subtypes": "24.5.7",
"@vaadin/hilla-generator-utils": "24.5.7",
"@vitejs/plugin-react": "4.3.3",
"@vaadin/hilla-generator-cli": "24.6.0",
"@vaadin/hilla-generator-core": "24.6.0",
"@vaadin/hilla-generator-plugin-backbone": "24.6.0",
"@vaadin/hilla-generator-plugin-barrel": "24.6.0",
"@vaadin/hilla-generator-plugin-client": "24.6.0",
"@vaadin/hilla-generator-plugin-model": "24.6.0",
"@vaadin/hilla-generator-plugin-push": "24.6.0",
"@vaadin/hilla-generator-plugin-signals": "24.6.0",
"@vaadin/hilla-generator-plugin-subtypes": "24.6.0",
"@vaadin/hilla-generator-utils": "24.6.0",
"@vitejs/plugin-react": "4.3.4",
"async": "3.2.6",
"glob": "10.4.5",
"rollup-plugin-brotli": "3.1.0",
"rollup-plugin-visualizer": "5.12.0",
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.6.3",
"vite": "5.4.11",
"typescript": "5.7.2",
"vite": "6.0.3",
"vite-plugin-checker": "0.8.0",
"workbox-build": "7.3.0",
"workbox-core": "7.3.0",
"workbox-precaching": "7.3.0"
},
"hash": "4bfcc93f77c9246e23c238a651d9282f58f2f417d16fae4df4b60df598bc7d16"
"hash": "accdc7fd578da56f35cba8d898b3776ad5594f3086365a42cccc9e7a0283251d"
}
}
@@ -1,5 +1,6 @@
package de.grimsi.gameyfin.core
import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonValue
import de.grimsi.gameyfin.users.RoleService.Companion.INTERNAL_ROLE_PREFIX
@@ -15,6 +16,14 @@ enum class Role(val roleName: String, val powerLevel: Int) {
}
companion object {
@JsonCreator
@JvmStatic
fun fromValue(value: String): Role? {
val enumString = value.removePrefix(INTERNAL_ROLE_PREFIX)
return Role.entries.find { it.roleName == enumString }
}
fun safeValueOf(type: String): Role? {
val enumString = type.removePrefix(INTERNAL_ROLE_PREFIX)
return java.lang.Enum.valueOf(Role::class.java, enumString)
@@ -3,69 +3,26 @@ package de.grimsi.gameyfin.core.plugins.management
import de.grimsi.gameyfin.core.plugins.config.PluginConfigRepository
import de.grimsi.gameyfin.pluginapi.core.GameyfinPlugin
import io.github.oshai.kotlinlogging.KotlinLogging
import org.pf4j.AbstractPluginManager
import org.pf4j.CompoundPluginDescriptorFinder
import org.pf4j.CompoundPluginLoader
import org.pf4j.CompoundPluginRepository
import org.pf4j.DefaultExtensionFactory
import org.pf4j.DefaultExtensionFinder
import org.pf4j.DefaultPluginFactory
import org.pf4j.DefaultPluginLoader
import org.pf4j.DefaultPluginRepository
import org.pf4j.DefaultVersionManager
import org.pf4j.DevelopmentPluginRepository
import org.pf4j.ExtensionFactory
import org.pf4j.ExtensionFinder
import org.pf4j.JarPluginLoader
import org.pf4j.JarPluginRepository
import org.pf4j.ManifestPluginDescriptorFinder
import org.pf4j.PluginDescriptorFinder
import org.pf4j.PluginFactory
import org.pf4j.PluginLoader
import org.pf4j.PluginRepository
import org.pf4j.PluginStatusProvider
import org.pf4j.PluginWrapper
import org.pf4j.PropertiesPluginDescriptorFinder
import org.pf4j.VersionManager
import org.pf4j.*
import org.springframework.stereotype.Component
import java.nio.file.Path
import kotlin.io.path.Path
/**
* @see https://stackoverflow.com/questions/73654174/my-application-cant-find-the-extension-with-pf4j
*/
@Component
class GameyfinPluginManager(
private val pluginConfigRepository: PluginConfigRepository,
private val pluginStatusProvider: DatabasePluginStatusProvider
) : AbstractPluginManager() {
val pluginConfigRepository: PluginConfigRepository,
val dbPluginStatusProvider: DatabasePluginStatusProvider
) : DefaultPluginManager(Path(System.getProperty("pf4j.pluginsDir", "plugins"))) {
private val log = KotlinLogging.logger {}
override fun createPluginRepository(): PluginRepository {
return CompoundPluginRepository()
.add(DevelopmentPluginRepository(pluginsRoots), this::isDevelopment)
.add(JarPluginRepository(pluginsRoots), this::isNotDevelopment)
.add(DefaultPluginRepository(pluginsRoots), this::isNotDevelopment)
}
override fun createPluginFactory(): PluginFactory {
return DefaultPluginFactory()
}
override fun createExtensionFactory(): ExtensionFactory {
return DefaultExtensionFactory()
}
override fun createPluginDescriptorFinder(): PluginDescriptorFinder {
return CompoundPluginDescriptorFinder()
.add(PropertiesPluginDescriptorFinder())
.add(ManifestPluginDescriptorFinder())
}
override fun createExtensionFinder(): ExtensionFinder {
val extensionFinder = DefaultExtensionFinder(this)
addPluginStateListener(extensionFinder)
return extensionFinder
// This took me way too long to figure out...
// But I learned a lot about Kotlin and Java interoperability in the process
init {
this.pluginStatusProvider = dbPluginStatusProvider
}
override fun createPluginLoader(): PluginLoader {
@@ -80,12 +37,8 @@ class GameyfinPluginManager(
.add(defaultPluginLoader, this::isNotDevelopment)
}
override fun createVersionManager(): VersionManager? {
return DefaultVersionManager()
}
override fun createPluginStatusProvider(): PluginStatusProvider {
return pluginStatusProvider
return dbPluginStatusProvider
}
override fun loadPluginFromPath(pluginPath: Path?): PluginWrapper? {
@@ -115,6 +68,6 @@ class GameyfinPluginManager(
}
private fun getConfig(pluginId: String): Map<String, String?> {
return pluginConfigRepository.findAllById_PluginId(pluginId).map { it.id.key to it.value }.toMap()
return pluginConfigRepository.findAllById_PluginId(pluginId).associate { it.id.key to it.value }
}
}
@@ -1,26 +1,20 @@
package de.grimsi.gameyfin.core.plugins.management
import de.grimsi.gameyfin.core.plugins.config.PluginConfigRepository
import io.github.oshai.kotlinlogging.KotlinLogging
import org.springframework.context.annotation.Bean
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.annotation.Configuration
import org.springframework.context.event.EventListener
@Configuration
class PluginManagerConfig(
private val pluginConfigRepository: PluginConfigRepository,
private val dbPluginStatusProvider: DatabasePluginStatusProvider
private val pluginManager: GameyfinPluginManager
) {
private val log = KotlinLogging.logger {}
@Bean
fun gameyfinPluginManager(): GameyfinPluginManager {
return GameyfinPluginManager(pluginConfigRepository, dbPluginStatusProvider)
}
/*@EventListener(ApplicationReadyEvent::class)
@EventListener(ApplicationReadyEvent::class)
fun loadPlugins() {
gameyfinPluginManager().loadPlugins()
gameyfinPluginManager().startPlugins()
log.info { "Loaded plugins: ${gameyfinPluginManager().plugins.map { it.pluginId }}" }
}*/
pluginManager.loadPlugins()
pluginManager.startPlugins()
log.info { "Loaded plugins: ${pluginManager.plugins.map { it.pluginId }}" }
}
}
+21 -16
View File
@@ -5,7 +5,7 @@
* This file will be overwritten on every run. Any custom changes should be made to vite.config.ts
*/
import path from 'path';
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'fs';
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, Stats } from 'fs';
import { createHash } from 'crypto';
import * as net from 'net';
@@ -23,7 +23,7 @@ import {
ResolvedConfig,
UserConfigFn
} from 'vite';
import { getManifest } from 'workbox-build';
import { getManifest, type ManifestTransform } from 'workbox-build';
import * as rollup from 'rollup';
import brotli from 'rollup-plugin-brotli';
@@ -90,7 +90,7 @@ console.trace = () => {};
console.debug = () => {};
function injectManifestToSWPlugin(): rollup.Plugin {
const rewriteManifestIndexHtmlUrl = (manifest) => {
const rewriteManifestIndexHtmlUrl: ManifestTransform = (manifest) => {
const indexEntry = manifest.find((entry) => entry.url === 'index.html');
if (indexEntry) {
indexEntry.url = appShellUrl;
@@ -106,7 +106,7 @@ function injectManifestToSWPlugin(): rollup.Plugin {
const { manifestEntries } = await getManifest({
globDirectory: buildOutputFolder,
globPatterns: ['**/*'],
globIgnores: ['**/*.br'],
globIgnores: ['**/*.br', 'pwa-icons/**'],
manifestTransforms: [rewriteManifestIndexHtmlUrl],
maximumFileSizeToCacheInBytes: 100 * 1024 * 1024 // 100mb,
});
@@ -117,11 +117,11 @@ function injectManifestToSWPlugin(): rollup.Plugin {
};
}
function buildSWPlugin(opts): PluginOption {
function buildSWPlugin(opts: { devMode: boolean }): PluginOption {
let config: ResolvedConfig;
const devMode = opts.devMode;
const swObj = {};
const swObj: { code?: string, map?: rollup.SourceMap | null } = {};
async function build(action: 'generate' | 'write', additionalPlugins: rollup.Plugin[] = []) {
const includedPluginNames = [
@@ -298,7 +298,7 @@ function statsExtracterPlugin(): PluginOption {
const frontendFiles: Record<string, string> = {};
const projectFileExtensions = ['.js', '.js.map', '.ts', '.ts.map', '.tsx', '.tsx.map', '.css', '.css.map'];
const projectFileExtensions = ['.js', '.js.map', '.ts', '.ts.map', '.tsx', '.tsx.map', '.css', '.css.map', '.'];
const isThemeComponentsResource = (id: string) =>
id.startsWith(themeOptions.frontendGeneratedFolder.replace(/\\/g, '/'))
@@ -563,7 +563,7 @@ export { ${bindings.map(getExportBinding).join(', ')} };`;
};
}
function themePlugin(opts): PluginOption {
function themePlugin(opts: { devMode: boolean }): PluginOption {
const fullThemeOptions = { ...themeOptions, devMode: opts.devMode };
return {
name: 'vaadin:theme',
@@ -571,7 +571,7 @@ function themePlugin(opts): PluginOption {
processThemeResources(fullThemeOptions, console);
},
configureServer(server) {
function handleThemeFileCreateDelete(themeFile, stats) {
function handleThemeFileCreateDelete(themeFile: string, stats?: Stats) {
if (themeFile.startsWith(themeFolder)) {
const changed = path.relative(themeFolder, themeFile);
console.debug('Theme file ' + (!!stats ? 'created' : 'deleted'), changed);
@@ -632,8 +632,8 @@ function themePlugin(opts): PluginOption {
};
}
function runWatchDog(watchDogPort, watchDogHost) {
const client = net.Socket();
function runWatchDog(watchDogPort: number, watchDogHost: string | undefined) {
const client = new net.Socket();
client.setEncoding('utf8');
client.on('error', function (err) {
console.log('Watchdog connection error. Terminating vite process...', err);
@@ -692,7 +692,7 @@ export const vaadinConfig: UserConfigFn = (env) => {
if (devMode && process.env.watchDogPort) {
// Open a connection with the Java dev-mode handler in order to finish
// vite when it exits or crashes.
runWatchDog(process.env.watchDogPort, process.env.watchDogHost);
runWatchDog(parseInt(process.env.watchDogPort), process.env.watchDogHost);
}
return {
@@ -722,20 +722,19 @@ export const vaadinConfig: UserConfigFn = (env) => {
outDir: buildOutputFolder,
emptyOutDir: devBundle,
assetsDir: 'VAADIN/build',
target: ["esnext", "safari15"],
rollupOptions: {
input: {
indexhtml: projectIndexHtml,
...(hasExportedWebComponents ? { webcomponenthtml: path.resolve(frontendFolder, 'web-component.html') } : {})
},
onwarn: (warning: rollup.RollupWarning, defaultHandler: rollup.WarningHandler) => {
onwarn: (warning: rollup.RollupLog, defaultHandler: rollup.LoggingFunction) => {
const ignoreEvalWarning = [
'generated/jar-resources/FlowClient.js',
'generated/jar-resources/vaadin-spreadsheet/spreadsheet-export.js',
'@vaadin/charts/src/helpers.js'
];
if (warning.code === 'EVAL' && warning.id && !!ignoreEvalWarning.find((id) => warning.id.endsWith(id))) {
if (warning.code === 'EVAL' && warning.id && !!ignoreEvalWarning.find((id) => warning.id?.endsWith(id))) {
return;
}
defaultHandler(warning);
@@ -784,7 +783,13 @@ export const vaadinConfig: UserConfigFn = (env) => {
presets: [['@babel/preset-react', { runtime: 'automatic', development: !productionMode }]],
// React writes the source location for where components are used, this writes for where they are defined
plugins: [
!productionMode && addFunctionComponentSourceLocationBabel()
!productionMode && addFunctionComponentSourceLocationBabel(),
[
'module:@preact/signals-react-transform',
{
mode: 'all' // Needed to include translations which do not use something.value
}
]
].filter(Boolean)
}
}),
+1 -1
View File
@@ -1,7 +1,7 @@
# Plugin versions
kotlinVersion=2.0.21
kspVersion=2.0.21-1.0.28
vaadinVersion=24.5.7
vaadinVersion=24.6.0
springBootVersion=3.4.0
springCloudVersion=2024.0.0
springDependencyManagementVersion=1.1.6