don't require binaries to be present for super basic plugins
This commit is contained in:
@@ -92,10 +92,6 @@ export async function ensurePluginExtracted(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasNative = nativeBinaries.size > 0;
|
|
||||||
if (!hasNative) {
|
|
||||||
throw new Error(`Invalid plugin bundle: ${safeId} (no native binaries found)`);
|
|
||||||
}
|
|
||||||
if (!htmlEntry || !cssEntry || !jsEntry) {
|
if (!htmlEntry || !cssEntry || !jsEntry) {
|
||||||
throw new Error(`Invalid plugin bundle: ${safeId} (missing .html, .css, or .js)`);
|
throw new Error(`Invalid plugin bundle: ${safeId} (missing .html, .css, or .js)`);
|
||||||
}
|
}
|
||||||
@@ -183,7 +179,7 @@ export async function loadPluginBundle(
|
|||||||
ensureExtracted: (pluginId: string) => Promise<void>,
|
ensureExtracted: (pluginId: string) => Promise<void>,
|
||||||
clientOS?: string,
|
clientOS?: string,
|
||||||
clientArch?: string,
|
clientArch?: string,
|
||||||
): Promise<{ manifest: PluginManifest; binary: Uint8Array }> {
|
): Promise<{ manifest: PluginManifest; binary: Uint8Array | null }> {
|
||||||
await ensureExtracted(pluginId);
|
await ensureExtracted(pluginId);
|
||||||
const dir = path.join(pluginRoot, pluginId);
|
const dir = path.join(pluginRoot, pluginId);
|
||||||
const manifestPath = path.join(dir, "manifest.json");
|
const manifestPath = path.join(dir, "manifest.json");
|
||||||
@@ -192,6 +188,11 @@ export async function loadPluginBundle(
|
|||||||
manifest.id = manifest.id || pluginId;
|
manifest.id = manifest.id || pluginId;
|
||||||
manifest.name = manifest.name || pluginId;
|
manifest.name = manifest.name || pluginId;
|
||||||
|
|
||||||
|
const hasBinaries = manifest.binaries && Object.keys(manifest.binaries).length > 0;
|
||||||
|
if (!hasBinaries) {
|
||||||
|
return { manifest, binary: null };
|
||||||
|
}
|
||||||
|
|
||||||
let binaryPath: string | null = null;
|
let binaryPath: string | null = null;
|
||||||
|
|
||||||
if (manifest.binaries && clientOS && clientArch) {
|
if (manifest.binaries && clientOS && clientArch) {
|
||||||
@@ -224,8 +225,9 @@ export async function loadPluginBundle(
|
|||||||
|
|
||||||
export function sendPluginBundle(
|
export function sendPluginBundle(
|
||||||
target: ClientInfo,
|
target: ClientInfo,
|
||||||
bundle: { manifest: PluginManifest; binary: Uint8Array },
|
bundle: { manifest: PluginManifest; binary: Uint8Array | null },
|
||||||
): void {
|
): void {
|
||||||
|
if (!bundle.binary) return;
|
||||||
const chunkSize = 16 * 1024;
|
const chunkSize = 16 * 1024;
|
||||||
const data = bundle.binary;
|
const data = bundle.binary;
|
||||||
const totalChunks = Math.ceil(data.length / chunkSize);
|
const totalChunks = Math.ceil(data.length / chunkSize);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type PluginManifest = {
|
|||||||
|
|
||||||
type PluginBundle = {
|
type PluginBundle = {
|
||||||
manifest: PluginManifest;
|
manifest: PluginManifest;
|
||||||
binary: Uint8Array;
|
binary: Uint8Array | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
type PluginState = {
|
type PluginState = {
|
||||||
|
|||||||
Reference in New Issue
Block a user