@lvce-editor/main-area-worker 9.53.1 → 9.54.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.
@@ -1217,7 +1217,8 @@ const create$4 = () => {
1217
1217
  const commandQueues = new Map();
1218
1218
  const generations = Object.create(null);
1219
1219
  const states = Object.create(null);
1220
- const commandMapRef = {};
1220
+ const commandMapRef = Object.create(null);
1221
+ const commandsById = Object.create(null);
1221
1222
  const getGeneration = uid => generations[uid] || 0;
1222
1223
  const isCurrentGeneration = (uid, generation) => {
1223
1224
  return states[uid] !== undefined && getGeneration(uid) === generation;
@@ -1279,6 +1280,18 @@ const create$4 = () => {
1279
1280
  delete states[key];
1280
1281
  }
1281
1282
  },
1283
+ createDirectEventCommandMap(requestRender) {
1284
+ return {
1285
+ async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
1286
+ const fn = commandsById[command];
1287
+ if (!fn) {
1288
+ throw new Error(`Viewlet command not found: ${command}`);
1289
+ }
1290
+ await fn(uid, ...args);
1291
+ await requestRender(uid);
1292
+ }
1293
+ };
1294
+ },
1282
1295
  diff(uid, modules, numbers) {
1283
1296
  const {
1284
1297
  oldState,
@@ -1310,6 +1323,9 @@ const create$4 = () => {
1310
1323
  },
1311
1324
  registerCommands(commandMap) {
1312
1325
  Object.assign(commandMapRef, commandMap);
1326
+ for (const [key, fn] of Object.entries(commandMap)) {
1327
+ commandsById[toCommandId(key)] = fn;
1328
+ }
1313
1329
  },
1314
1330
  set(uid, oldState, newState, scheduledState) {
1315
1331
  const current = states[uid];
@@ -3002,12 +3018,8 @@ const getPathEndIndex = pathName => {
3002
3018
  return Math.min(queryIndex, hashIndex);
3003
3019
  };
3004
3020
  const getPathName = uri => {
3005
- if (uri.startsWith('file://')) {
3006
- try {
3007
- return new URL(uri).pathname;
3008
- } catch {
3009
- return uri;
3010
- }
3021
+ if (uri.startsWith('file://') && URL.canParse(uri)) {
3022
+ return new URL(uri).pathname;
3011
3023
  }
3012
3024
  return uri;
3013
3025
  };
@@ -3029,20 +3041,16 @@ const hasBinaryFileSuffix = uri => {
3029
3041
  return binaryFileSuffixes.some(suffix => cleanPath.endsWith(suffix));
3030
3042
  };
3031
3043
  const getEditorInputFromUri = uri => {
3032
- if (uri.startsWith('diff://?')) {
3033
- try {
3034
- const parsed = new URL(uri);
3035
- const uriLeft = parsed.searchParams.get('left');
3036
- const uriRight = parsed.searchParams.get('right');
3037
- if (uriLeft && uriRight) {
3038
- return {
3039
- type: 'diff-editor',
3040
- uriLeft,
3041
- uriRight
3042
- };
3043
- }
3044
- } catch {
3045
- // Ignore malformed legacy URIs and fall back to a text editor input.
3044
+ if (uri.startsWith('diff://?') && URL.canParse(uri)) {
3045
+ const parsed = new URL(uri);
3046
+ const uriLeft = parsed.searchParams.get('left');
3047
+ const uriRight = parsed.searchParams.get('right');
3048
+ if (uriLeft && uriRight) {
3049
+ return {
3050
+ type: 'diff-editor',
3051
+ uriLeft,
3052
+ uriRight
3053
+ };
3046
3054
  }
3047
3055
  }
3048
3056
  if (uri.startsWith('extension-detail://')) {
@@ -3753,6 +3761,9 @@ const getLabel = uri => {
3753
3761
  if (uri.startsWith('running-extensions://')) {
3754
3762
  return 'Running Extensions';
3755
3763
  }
3764
+ if (uri.startsWith('cookie-import-view://')) {
3765
+ return 'Import Firefox Cookies';
3766
+ }
3756
3767
  if (uri.startsWith(inlineDiffPrefix)) {
3757
3768
  return getInlineDiffLabel(uri);
3758
3769
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.53.1",
3
+ "version": "9.54.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",