@lvce-editor/extension-detail-view 4.4.0 → 4.5.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.
@@ -2382,20 +2382,20 @@ const getSettingsVirtualDom = state => {
2382
2382
  return getFeatureSettingsVirtualDom(state.settings);
2383
2383
  };
2384
2384
 
2385
- const HandleClickCategory = 'handleClickCategory';
2386
- const HandleClickDisable = 'handleClickDisable';
2387
- const HandleClickEnable = 'handleClickEnable';
2388
- const HandleClickScrollToTop = 'handleClickScrollToTop';
2389
- const HandleClickSetColorTheme = 'handleClickSetColorTheme';
2390
- const HandleClickSettings = 'handleClickSettings';
2391
- const HandleClickSize = 'handleClickSize';
2392
- const HandleClickUninstall = 'handleClickUninstall';
2393
- const HandleFeaturesClick = 'handleFeaturesClick';
2394
- const HandleIconError = 'handleIconError';
2395
- const HandleImageContextMenu = 'handleImageContextMenu';
2396
- const HandleReadmeContextMenu = 'handleReadmeContextMenu';
2397
- const HandleReadmeScroll = 'handleReadmeScroll';
2398
- const HandleTabsClick = 'handleTabsClick';
2385
+ const HandleClickCategory = 1;
2386
+ const HandleClickDisable = 2;
2387
+ const HandleClickEnable = 3;
2388
+ const HandleClickScrollToTop = 4;
2389
+ const HandleClickSetColorTheme = 5;
2390
+ const HandleClickSettings = 6;
2391
+ const HandleClickSize = 7;
2392
+ const HandleClickUninstall = 8;
2393
+ const HandleFeaturesClick = 9;
2394
+ const HandleIconError = 10;
2395
+ const HandleImageContextMenu = 11;
2396
+ const HandleReadmeContextMenu = 12;
2397
+ const HandleReadmeScroll = 13;
2398
+ const HandleTabsClick = 14;
2399
2399
 
2400
2400
  const ActivationEvents = 'ActivationEvents';
2401
2401
  const Changelog = 'Changelog';
@@ -2484,6 +2484,17 @@ const getThemeMarkdown = (themes, iconThemes, productIconThemes) => {
2484
2484
  return markdown;
2485
2485
  };
2486
2486
 
2487
+ const supportsNormalCacheKey = locationProtocol => {
2488
+ return locationProtocol === 'http:' || locationProtocol === 'https:';
2489
+ };
2490
+ const getMarkdownCacheKey = (hash, locationProtocol) => {
2491
+ if (supportsNormalCacheKey(locationProtocol)) {
2492
+ return `/markdown/${hash}`;
2493
+ }
2494
+ // workaround for electron bug
2495
+ return `https://markdown/${hash}`;
2496
+ };
2497
+
2487
2498
  const hash = async content => {
2488
2499
  const sourceBytes = new TextEncoder().encode(content);
2489
2500
  const digest = await crypto.subtle.digest('SHA-256', sourceBytes);
@@ -2548,9 +2559,9 @@ const set$3 = async (key, value) => {
2548
2559
  }));
2549
2560
  };
2550
2561
 
2551
- const renderMarkdownCached = async (markdown, options = {}) => {
2562
+ const renderMarkdownCached = async (markdown, options) => {
2552
2563
  const markdownHash = await hash(markdown); // TODO hash options also
2553
- const cacheKey = `/markdown/${markdownHash}`;
2564
+ const cacheKey = getMarkdownCacheKey(markdownHash, options.locationProtocol);
2554
2565
  const hasItem = await has(cacheKey);
2555
2566
  if (hasItem) {
2556
2567
  const value = await get$1(cacheKey);
@@ -2561,12 +2572,12 @@ const renderMarkdownCached = async (markdown, options = {}) => {
2561
2572
  return html;
2562
2573
  };
2563
2574
 
2564
- const renderMarkdown = async (markdown, options = {}) => {
2575
+ const renderMarkdown = async (markdown, options) => {
2565
2576
  const html = await renderMarkdownCached(markdown, options);
2566
2577
  return html;
2567
2578
  };
2568
2579
 
2569
- const getThemeDetails = async (extension, baseUrl) => {
2580
+ const getThemeDetails = async (extension, baseUrl, locationProtocol) => {
2570
2581
  const {
2571
2582
  colorThemes,
2572
2583
  iconThemes,
@@ -2574,7 +2585,8 @@ const getThemeDetails = async (extension, baseUrl) => {
2574
2585
  } = extension;
2575
2586
  const markdown = getThemeMarkdown(colorThemes || [], iconThemes || [], productIconThemes || []);
2576
2587
  const rendered = await renderMarkdown(markdown, {
2577
- baseUrl
2588
+ baseUrl,
2589
+ locationProtocol
2578
2590
  });
2579
2591
  const themesMarkdownDom = await getMarkdownVirtualDom(rendered);
2580
2592
  return {
@@ -3000,7 +3012,8 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
3000
3012
  paddingLeft: 0,
3001
3013
  paddingRight: 0,
3002
3014
  showSideBar: true,
3003
- sideBarWidth: 0
3015
+ sideBarWidth: 0,
3016
+ locationProtocol: ''
3004
3017
  };
3005
3018
  set(uid, state, state);
3006
3019
  };
@@ -3237,7 +3250,8 @@ const selectFeature = async (state, name) => {
3237
3250
  const {
3238
3251
  features,
3239
3252
  extension,
3240
- baseUrl
3253
+ baseUrl,
3254
+ locationProtocol
3241
3255
  } = state;
3242
3256
  const newFeatures = features.map(feature => {
3243
3257
  if (feature.id === name) {
@@ -3252,7 +3266,7 @@ const selectFeature = async (state, name) => {
3252
3266
  };
3253
3267
  });
3254
3268
  const fn = getFeatureDetailsHandler(name);
3255
- const partialNewState = await fn(extension, baseUrl);
3269
+ const partialNewState = await fn(extension, baseUrl, locationProtocol);
3256
3270
  return {
3257
3271
  ...state,
3258
3272
  ...partialNewState,
@@ -3413,11 +3427,13 @@ const selectTabChangelog = async state => {
3413
3427
  const {
3414
3428
  extension,
3415
3429
  baseUrl,
3416
- tabs
3430
+ tabs,
3431
+ locationProtocol
3417
3432
  } = state;
3418
3433
  const changelogContent = await loadChangelogContent(extension.path); // TODO use uri
3419
3434
  const changelogMarkdownHtml = await renderMarkdown(changelogContent, {
3420
- baseUrl
3435
+ baseUrl,
3436
+ locationProtocol
3421
3437
  });
3422
3438
  const changelogDom = await getMarkdownVirtualDom(changelogMarkdownHtml);
3423
3439
  const newTabs = tabs.map(tab => {
@@ -3457,12 +3473,14 @@ const selectTabDetails = async state => {
3457
3473
  const {
3458
3474
  baseUrl,
3459
3475
  readmeUrl,
3460
- tabs
3476
+ tabs,
3477
+ locationProtocol
3461
3478
  } = state;
3462
3479
  const readmeContent = await loadReadmeContent(readmeUrl);
3463
3480
  const readmeHtml = await renderMarkdown(readmeContent, {
3464
3481
  baseUrl,
3465
- linksExternal: true
3482
+ linksExternal: true,
3483
+ locationProtocol
3466
3484
  });
3467
3485
  const detailsDom = await getMarkdownVirtualDom(readmeHtml);
3468
3486
  const newTabs = tabs.map(tab => {
@@ -3485,14 +3503,15 @@ const selectTabFeatures = async state => {
3485
3503
  baseUrl,
3486
3504
  selectedFeature,
3487
3505
  features,
3488
- tabs
3506
+ tabs,
3507
+ locationProtocol
3489
3508
  } = state;
3490
3509
  if (features.length === 0) {
3491
3510
  return state;
3492
3511
  }
3493
3512
  const actualSelectedFeature = selectedFeature || Theme;
3494
3513
  const fn = getFeatureDetailsHandler(actualSelectedFeature);
3495
- const partialNewState = await fn(extension, baseUrl);
3514
+ const partialNewState = await fn(extension, baseUrl, locationProtocol);
3496
3515
  const newTabs = tabs.map(tab => {
3497
3516
  return {
3498
3517
  ...tab,
@@ -4111,9 +4130,11 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4111
4130
  const [hasReadme, hasChangelog] = await Promise.all([existsFile(readmeUrl), existsFile(changelogUrl)]);
4112
4131
  const readmeContent = hasReadme ? await loadReadmeContent(readmeUrl) : noReadmeFound();
4113
4132
  const baseUrl = getBaseUrl(extension.path, platform);
4133
+ const locationProtocol = location.protocol;
4114
4134
  const readmeHtml = await renderMarkdown(readmeContent, {
4115
4135
  baseUrl,
4116
- linksExternal: true
4136
+ linksExternal: true,
4137
+ locationProtocol
4117
4138
  });
4118
4139
  const detailsVirtualDom = await getMarkdownVirtualDom(readmeHtml, {
4119
4140
  scrollToTopEnabled: true
@@ -4181,7 +4202,8 @@ const loadContent = async (state, platform, savedState, isTest = false) => {
4181
4202
  sideBarWidth,
4182
4203
  sizeOnDisk: size,
4183
4204
  sizeValue,
4184
- tabs: enabledTabs
4205
+ tabs: enabledTabs,
4206
+ locationProtocol
4185
4207
  };
4186
4208
  };
4187
4209
 
@@ -4731,6 +4753,7 @@ const render2 = (uid, diffResult) => {
4731
4753
  return commands;
4732
4754
  };
4733
4755
 
4756
+ // @ts-nocheck
4734
4757
  const renderEventListeners = () => {
4735
4758
  return [{
4736
4759
  name: HandleClickCategory,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-detail-view",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "Extension Detail View Worker",
5
5
  "repository": {
6
6
  "type": "git",