@lvce-editor/extension-management-worker 4.14.0 → 4.15.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.
@@ -1752,6 +1752,30 @@ const getWebExtensions = async assetDir => {
1752
1752
 
1753
1753
  const WorkspaceConfigFolderName = '.lvce';
1754
1754
  const DisabledExtensionsFileName = 'disabled-extensions.json';
1755
+ const UriSchemeRegex = /^[a-zA-Z][a-zA-Z\d+.-]*:/;
1756
+ const WindowsDrivePathRegex = /^[a-zA-Z]:[\\/]/;
1757
+ const WindowsDriveSegmentRegex = /^[a-zA-Z]:$/;
1758
+ const encodePathSegment = (segment, index) => {
1759
+ if (index === 0 && WindowsDriveSegmentRegex.test(segment)) {
1760
+ return segment;
1761
+ }
1762
+ return encodeURIComponent(segment);
1763
+ };
1764
+ const encodeFilePath = path => {
1765
+ return path.split('/').map(encodePathSegment).join('/');
1766
+ };
1767
+ const toWorkspaceUri = workspacePath => {
1768
+ if (WindowsDrivePathRegex.test(workspacePath)) {
1769
+ return `file:///${encodeFilePath(workspacePath.replaceAll('\\', '/'))}`;
1770
+ }
1771
+ if (UriSchemeRegex.test(workspacePath)) {
1772
+ return workspacePath;
1773
+ }
1774
+ if (workspacePath.startsWith('/')) {
1775
+ return `file://${encodeFilePath(workspacePath)}`;
1776
+ }
1777
+ return workspacePath;
1778
+ };
1755
1779
  const joinUri = (base, ...parts) => {
1756
1780
  const normalizedBase = base.endsWith('/') ? base.slice(0, -1) : base;
1757
1781
  return [normalizedBase, ...parts].join('/');
@@ -1760,7 +1784,8 @@ const stringifyJson = data => {
1760
1784
  return JSON.stringify(data, null, 2) + '\n';
1761
1785
  };
1762
1786
  const getWorkspaceUri = async () => {
1763
- return invoke$3('Workspace.getPath');
1787
+ const workspacePath = await invoke$3('Workspace.getPath');
1788
+ return toWorkspaceUri(workspacePath);
1764
1789
  };
1765
1790
  const getWorkspaceConfigDirUri = async () => {
1766
1791
  const workspaceUri = await getWorkspaceUri();
@@ -2447,9 +2472,19 @@ const dispatchViewEvent = async (viewId, uid, event, assetDir, platform) => {
2447
2472
  }
2448
2473
  return rpc.invoke('ExtensionApi.dispatchViewEvent', uid, event);
2449
2474
  };
2475
+ const getViewMenuEntries = async (viewId, uid, menuId, assetDir, platform) => {
2476
+ const instance = get$1(uid);
2477
+ if (!instance || instance.status === 'error') {
2478
+ return [];
2479
+ }
2480
+ return instance.rpc.invoke('ExtensionApi.getViewMenuEntries', uid, menuId);
2481
+ };
2450
2482
  const requestViewRerender = async uid => {
2451
2483
  await invoke$3('Viewlet.executeViewletCommand', uid, 'rerender');
2452
2484
  };
2485
+ const showViewContextMenu = async (uid, viewId, menuId, x, y) => {
2486
+ await invoke$3('ExtensionManagement.showViewContextMenu', uid, viewId, menuId, x, y);
2487
+ };
2453
2488
  const renderViewInstance = async (viewId, uid, assetDir, platform) => {
2454
2489
  const instance = get$1(uid);
2455
2490
  if (!instance || instance.status === 'error') {
@@ -3114,6 +3149,7 @@ const commandMap = {
3114
3149
  'Extensions.getRpcInfo': getRpcInfo,
3115
3150
  'Extensions.getRuntimeStatus': getRuntimeStatus,
3116
3151
  'Extensions.getStatusBarItems': getStatusBarItems,
3152
+ 'Extensions.getViewMenuEntries': getViewMenuEntries,
3117
3153
  'Extensions.getViews': getViews,
3118
3154
  'Extensions.handleMessagePort': handleMessagePort,
3119
3155
  'Extensions.handleViewContextChange': handleViewContextChange,
@@ -3126,6 +3162,7 @@ const commandMap = {
3126
3162
  'Extensions.saveViewInstanceState': saveViewInstanceState,
3127
3163
  'Extensions.sendMessagePortToFileSystemWorker': sendMessagePortToFileSystemWorker,
3128
3164
  'Extensions.setPreference': setPreference,
3165
+ 'Extensions.showViewContextMenu': showViewContextMenu,
3129
3166
  'Extensions.uninstall': uninstallExtension,
3130
3167
  'StatusBar.handleChange': handleChange
3131
3168
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"