@lvce-editor/extension-search-view 1.2.0 → 1.3.0
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.
- package/README.md +7 -1
- package/dist/extensionSearchViewWorkerMain.js +41 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,6 +196,46 @@ const parseValue = value => {
|
|
|
196
196
|
|
|
197
197
|
const assetDir = '';
|
|
198
198
|
|
|
199
|
+
const Web = 1;
|
|
200
|
+
const Electron = 2;
|
|
201
|
+
const Remote = 3;
|
|
202
|
+
const Test = 4;
|
|
203
|
+
|
|
204
|
+
// TODO treeshake this function out
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @returns {number}
|
|
208
|
+
*/
|
|
209
|
+
const getPlatform = () => {
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
if (typeof PLATFORM !== 'undefined') {
|
|
212
|
+
// @ts-ignore
|
|
213
|
+
return PLATFORM;
|
|
214
|
+
}
|
|
215
|
+
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'test') {
|
|
216
|
+
return Test;
|
|
217
|
+
}
|
|
218
|
+
// TODO find a better way to pass runtime environment
|
|
219
|
+
if (typeof name !== 'undefined' && name.endsWith('(Electron)')) {
|
|
220
|
+
return Electron;
|
|
221
|
+
}
|
|
222
|
+
if (typeof name !== 'undefined' && name.endsWith('(Web)')) {
|
|
223
|
+
return Web;
|
|
224
|
+
}
|
|
225
|
+
return Remote;
|
|
226
|
+
};
|
|
227
|
+
const platform = getPlatform();
|
|
228
|
+
|
|
229
|
+
const getRemoteUrl = extension => {
|
|
230
|
+
if (platform === Remote || platform === Electron) {
|
|
231
|
+
if (extension.builtin) {
|
|
232
|
+
return `${assetDir}/extensions/${extension.id}/${extension.icon}`;
|
|
233
|
+
}
|
|
234
|
+
return `/remote/${extension.path}/${extension.icon}`; // TODO support windows paths
|
|
235
|
+
}
|
|
236
|
+
return '';
|
|
237
|
+
};
|
|
238
|
+
|
|
199
239
|
const ExtensionDefaultIcon = `${assetDir}/icons/extensionDefaultIcon.png`;
|
|
200
240
|
const ExtensionLanguageBasics = `${assetDir}/icons/language-icon.svg`;
|
|
201
241
|
const ExtensionTheme = `${assetDir}/icons/theme-icon.png`;
|
|
@@ -219,7 +259,7 @@ const getIcon = extension => {
|
|
|
219
259
|
}
|
|
220
260
|
return ExtensionDefaultIcon;
|
|
221
261
|
}
|
|
222
|
-
return
|
|
262
|
+
return getRemoteUrl(extension);
|
|
223
263
|
};
|
|
224
264
|
const RE_PUBLISHER = /^[a-z\d\-]+/;
|
|
225
265
|
|