@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 CHANGED
@@ -1 +1,7 @@
1
- # extension-search-view
1
+ # Extension Search View
2
+
3
+ Webworker for the extension search view in Lvce Editor.
4
+
5
+ ## Gitpod
6
+
7
+ [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/lvce-editor/extension-search-view)
@@ -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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "",
5
5
  "main": "dist/extensionSearchViewWorkerMain.js",
6
6
  "type": "module",