@lvce-editor/extension-management-worker 4.44.1 → 4.45.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.
@@ -594,7 +594,7 @@ let CommandNotFoundError$1 = class CommandNotFoundError extends Error {
594
594
  }
595
595
  };
596
596
  const commands = Object.create(null);
597
- const register = commandMap => {
597
+ const register$1 = commandMap => {
598
598
  Object.assign(commands, commandMap);
599
599
  };
600
600
  const getCommand = key => {
@@ -1089,7 +1089,7 @@ const create$8 = async ({
1089
1089
  messagePort
1090
1090
  }) => {
1091
1091
  // TODO create a commandMap per rpc instance
1092
- register(commandMap);
1092
+ register$1(commandMap);
1093
1093
  const rawIpc = await IpcParentWithMessagePort$1.create({
1094
1094
  isMessagePortOpen,
1095
1095
  messagePort
@@ -1185,7 +1185,7 @@ const create$5 = async ({
1185
1185
  webSocket
1186
1186
  }) => {
1187
1187
  // TODO create a commandMap per rpc instance
1188
- register(commandMap);
1188
+ register$1(commandMap);
1189
1189
  let rawIpc;
1190
1190
  try {
1191
1191
  rawIpc = await IpcParentWithWebSocket$1.create({
@@ -1260,7 +1260,7 @@ const create$3 = async ({
1260
1260
  messagePort
1261
1261
  }) => {
1262
1262
  // TODO create a commandMap per rpc instance
1263
- register(commandMap);
1263
+ register$1(commandMap);
1264
1264
  const rawIpc = await IpcParentWithMessagePort$1.create({
1265
1265
  isMessagePortOpen,
1266
1266
  messagePort
@@ -1275,7 +1275,7 @@ const create$2 = async ({
1275
1275
  commandMap
1276
1276
  }) => {
1277
1277
  // TODO create a commandMap per rpc instance
1278
- register(commandMap);
1278
+ register$1(commandMap);
1279
1279
  const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1280
1280
  handleIpc(ipc);
1281
1281
  const rpc = createRpc(ipc);
@@ -1696,6 +1696,17 @@ const activateExtension2 = async (extensionId, extension, absolutePath, extensio
1696
1696
 
1697
1697
  const commandMapRef = {};
1698
1698
 
1699
+ const extensionIds = new Set();
1700
+ const register = extensionId => {
1701
+ extensionIds.add(extensionId);
1702
+ };
1703
+ const unregister = extensionId => {
1704
+ extensionIds.delete(extensionId);
1705
+ };
1706
+ const getRegisteredExtensionIds = () => {
1707
+ return [...extensionIds];
1708
+ };
1709
+
1699
1710
  const extensions = Object.create(null);
1700
1711
  const get$4 = extensionId => {
1701
1712
  return extensions[extensionId];
@@ -1819,8 +1830,14 @@ const createExtensionCommandMap = extensionId => {
1819
1830
  'Extensions.getSecret'(key) {
1820
1831
  return getSecret(extensionId, key);
1821
1832
  },
1833
+ 'Extensions.registerFileChangeHandler'() {
1834
+ register(extensionId);
1835
+ },
1822
1836
  'Extensions.storeSecret'(key, value) {
1823
1837
  return storeSecret(extensionId, key, value);
1838
+ },
1839
+ 'Extensions.unregisterFileChangeHandler'() {
1840
+ unregister(extensionId);
1824
1841
  }
1825
1842
  };
1826
1843
  };
@@ -2561,6 +2578,7 @@ const createWebViewWorkerRpc = async (rpcInfo, port) => {
2561
2578
  };
2562
2579
 
2563
2580
  const disposeIsolatedExtensionHostWorker = async (extensionId, invoke$1 = invoke) => {
2581
+ unregister(extensionId);
2564
2582
  const rpc = remove$1(extensionId);
2565
2583
  if (!rpc) {
2566
2584
  return false;
@@ -3899,6 +3917,19 @@ const getViews = async (assetDir, platform) => {
3899
3917
 
3900
3918
  const handleData = () => {};
3901
3919
 
3920
+ const invokeHandler = async (extensionId, changes) => {
3921
+ const rpc = get$3(extensionId);
3922
+ if (!rpc) {
3923
+ unregister(extensionId);
3924
+ return;
3925
+ }
3926
+ await rpc.invoke('ExtensionApi.handleFileChanges', changes);
3927
+ };
3928
+ const handleFileChanges = async (changes = {}) => {
3929
+ const extensionIds = getRegisteredExtensionIds();
3930
+ await Promise.allSettled(extensionIds.map(async extensionId => invokeHandler(extensionId, changes)));
3931
+ };
3932
+
3902
3933
  const handleMessagePort = async (port, rpcId) => {
3903
3934
  await create$8({
3904
3935
  commandMap: commandMapRef,
@@ -4103,6 +4134,7 @@ const commandMap = {
4103
4134
  'Extensions.getViewMenuEntries': getViewMenuEntries,
4104
4135
  'Extensions.getViews': getViews,
4105
4136
  'Extensions.handleData': handleData,
4137
+ 'Extensions.handleFileChanges': handleFileChanges,
4106
4138
  'Extensions.handleMessagePort': handleMessagePort,
4107
4139
  'Extensions.handleUncaughtExtensionError': handleUncaughtExtensionError,
4108
4140
  'Extensions.handleViewContextChange': handleViewContextChange,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-management-worker",
3
- "version": "4.44.1",
3
+ "version": "4.45.0",
4
4
  "description": "Webworker for the Extension Management functionality in Lvce Editor.",
5
5
  "keywords": [
6
6
  "web-worker"