@lvce-editor/extension-management-worker 4.31.4 → 4.31.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3387,26 +3387,59 @@ const getRpcInfo = rpcId => {
|
|
|
3387
3387
|
return info;
|
|
3388
3388
|
};
|
|
3389
3389
|
|
|
3390
|
-
const
|
|
3390
|
+
const isAbsoluteIcon = icon => {
|
|
3391
|
+
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
|
|
3392
|
+
};
|
|
3393
|
+
|
|
3394
|
+
const isRelativeIconPath = icon => {
|
|
3395
|
+
return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
|
|
3396
|
+
};
|
|
3397
|
+
|
|
3398
|
+
const getIcon = (extension, manifestView, assetDir, platform) => {
|
|
3399
|
+
const manifestIcon = manifestView?.icon;
|
|
3400
|
+
if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
|
|
3401
|
+
if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
|
|
3402
|
+
return manifestIcon;
|
|
3403
|
+
}
|
|
3404
|
+
return getAbsolutePath({
|
|
3405
|
+
...extension,
|
|
3406
|
+
browser: manifestIcon
|
|
3407
|
+
}, assetDir, platform);
|
|
3408
|
+
}
|
|
3409
|
+
return '';
|
|
3410
|
+
};
|
|
3411
|
+
|
|
3412
|
+
const getRunningExtensionsFromState = (extensions, runtimeStatuses, assetDir, platform) => {
|
|
3391
3413
|
return extensions.flatMap(extension => {
|
|
3392
3414
|
const runtimeStatus = runtimeStatuses[extension.id];
|
|
3393
3415
|
if (!runtimeStatus || runtimeStatus.status !== Activated) {
|
|
3394
3416
|
return [];
|
|
3395
3417
|
}
|
|
3418
|
+
const manifestIcon = typeof extension.icon === 'string' ? extension.icon.replace(/^\.\//, '') : undefined;
|
|
3419
|
+
const icon = getIcon(extension, {
|
|
3420
|
+
icon: manifestIcon
|
|
3421
|
+
}, assetDir, platform);
|
|
3396
3422
|
return [{
|
|
3397
3423
|
...extension,
|
|
3398
3424
|
activationEvent: runtimeStatus.activationEvent,
|
|
3399
|
-
activationTime: runtimeStatus.activationTime
|
|
3425
|
+
activationTime: runtimeStatus.activationTime,
|
|
3426
|
+
...(icon && {
|
|
3427
|
+
icon
|
|
3428
|
+
})
|
|
3400
3429
|
}];
|
|
3401
3430
|
}).toSorted((a, b) => b.activationTime - a.activationTime);
|
|
3402
3431
|
};
|
|
3403
3432
|
|
|
3404
3433
|
const getRunningExtensions = async (assetDir, platform) => {
|
|
3405
|
-
const
|
|
3434
|
+
const {
|
|
3435
|
+
assetDir: resolvedAssetDir,
|
|
3436
|
+
platform: resolvedPlatform
|
|
3437
|
+
} = await getRuntimeContext(assetDir, platform);
|
|
3438
|
+
const extensions = await getAllExtensions(resolvedAssetDir, resolvedPlatform);
|
|
3406
3439
|
const {
|
|
3407
3440
|
runtimeStatuses
|
|
3408
3441
|
} = get$5();
|
|
3409
|
-
return getRunningExtensionsFromState(extensions, runtimeStatuses);
|
|
3442
|
+
return getRunningExtensionsFromState(extensions, runtimeStatuses, resolvedAssetDir, resolvedPlatform);
|
|
3410
3443
|
};
|
|
3411
3444
|
|
|
3412
3445
|
const emptyStatus = {
|
|
@@ -3444,28 +3477,6 @@ const getCss = (extension, manifestView, assetDir, platform) => {
|
|
|
3444
3477
|
}, assetDir, platform);
|
|
3445
3478
|
};
|
|
3446
3479
|
|
|
3447
|
-
const isAbsoluteIcon = icon => {
|
|
3448
|
-
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
|
|
3449
|
-
};
|
|
3450
|
-
|
|
3451
|
-
const isRelativeIconPath = icon => {
|
|
3452
|
-
return icon.startsWith('./') || icon.startsWith('../') || icon.includes('/') || /\.(?:bmp|gif|ico|jpe?g|png|svg|webp)$/i.test(icon);
|
|
3453
|
-
};
|
|
3454
|
-
|
|
3455
|
-
const getIcon = (extension, manifestView, assetDir, platform) => {
|
|
3456
|
-
const manifestIcon = manifestView?.icon;
|
|
3457
|
-
if (typeof manifestIcon === 'string' && manifestIcon.length > 0) {
|
|
3458
|
-
if (isAbsoluteIcon(manifestIcon) || !isRelativeIconPath(manifestIcon)) {
|
|
3459
|
-
return manifestIcon;
|
|
3460
|
-
}
|
|
3461
|
-
return getAbsolutePath({
|
|
3462
|
-
...extension,
|
|
3463
|
-
browser: manifestIcon
|
|
3464
|
-
}, assetDir, platform);
|
|
3465
|
-
}
|
|
3466
|
-
return '';
|
|
3467
|
-
};
|
|
3468
|
-
|
|
3469
3480
|
const getIframe = (extension, manifestView, assetDir, platform) => {
|
|
3470
3481
|
const iframe = manifestView?.iframe;
|
|
3471
3482
|
if (!iframe || typeof iframe.path !== 'string' || iframe.path.length === 0) {
|