fix(plugins): use asset-specific size errors (#7210)

* fix(plugins): use asset-specific size errors #7202

* plugins: inline asset-specific size errors

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>

---------

Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
This commit is contained in:
Asish Kumar 2026-04-16 21:32:39 +05:30 committed by GitHub
parent fd2490009c
commit fec7b25f23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View file

@ -1003,7 +1003,6 @@ export class PluginService implements OnDestroy {
throw new Error(
this._translateService.instant(T.PLUGINS.MANIFEST_TOO_LARGE, {
maxSize: (MAX_PLUGIN_MANIFEST_SIZE / 1024).toFixed(1),
fileSize: (manifestBytes.length / 1024).toFixed(1),
}),
);
}
@ -1032,7 +1031,6 @@ export class PluginService implements OnDestroy {
throw new Error(
this._translateService.instant(T.PLUGINS.CODE_TOO_LARGE, {
maxSize: (MAX_PLUGIN_CODE_SIZE / 1024 / 1024).toFixed(1),
fileSize: (pluginCodeBytes.length / 1024 / 1024).toFixed(1),
}),
);
}
@ -1043,12 +1041,11 @@ export class PluginService implements OnDestroy {
let indexHtml: string | null = null;
if (manifest.iFrame && extractedFiles['index.html']) {
const indexHtmlBytes = extractedFiles['index.html'];
// Validate index.html size (same as manifest for now)
// Reuse the manifest size limit for index.html.
if (indexHtmlBytes.length > MAX_PLUGIN_MANIFEST_SIZE) {
throw new Error(
this._translateService.instant(T.PLUGINS.MANIFEST_TOO_LARGE, {
this._translateService.instant(T.PLUGINS.INDEX_HTML_TOO_LARGE, {
maxSize: (MAX_PLUGIN_MANIFEST_SIZE / 1024).toFixed(1),
fileSize: (indexHtmlBytes.length / 1024).toFixed(1),
}),
);
}
@ -1059,12 +1056,11 @@ export class PluginService implements OnDestroy {
let iconContent: string | null = null;
if (manifest.icon && extractedFiles[manifest.icon]) {
const iconBytes = extractedFiles[manifest.icon];
// Validate icon size (same as manifest for now)
// Reuse the manifest size limit for the SVG icon.
if (iconBytes.length > MAX_PLUGIN_MANIFEST_SIZE) {
throw new Error(
this._translateService.instant(T.PLUGINS.MANIFEST_TOO_LARGE, {
this._translateService.instant(T.PLUGINS.ICON_TOO_LARGE, {
maxSize: (MAX_PLUGIN_MANIFEST_SIZE / 1024).toFixed(1),
fileSize: (iconBytes.length / 1024).toFixed(1),
}),
);
}

View file

@ -2609,7 +2609,9 @@ const T = {
GRANT_PERMISSION: 'PLUGINS.GRANT_PERMISSION',
HOOKS: 'PLUGINS.HOOKS',
ID: 'PLUGINS.ID',
ICON_TOO_LARGE: 'PLUGINS.ICON_TOO_LARGE',
INDEX_HTML_NOT_LOADED: 'PLUGINS.INDEX_HTML_NOT_LOADED',
INDEX_HTML_TOO_LARGE: 'PLUGINS.INDEX_HTML_TOO_LARGE',
INSTALL_PLUGIN: 'PLUGINS.INSTALL_PLUGIN',
INSTALL_WARNING: 'PLUGINS.INSTALL_WARNING',
INSTALLING: 'PLUGINS.INSTALLING',

View file

@ -2556,7 +2556,9 @@
"GRANT_PERMISSION": "Grant Permission",
"HOOKS": "Hooks",
"ID": "ID:",
"ICON_TOO_LARGE": "Plugin icon is too large (max {{maxSize}}KB)",
"INDEX_HTML_NOT_LOADED": "Plugin index.html not loaded",
"INDEX_HTML_TOO_LARGE": "Plugin index.html is too large (max {{maxSize}}KB)",
"INSTALL_PLUGIN": "Install Plugin",
"INSTALL_WARNING": "Before installing a plugin, ensure you trust its source and understand the permissions it requests.",
"INSTALLING": "Installing...",