@lvce-editor/editor-worker 19.39.0 → 19.41.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.
@@ -1228,7 +1228,7 @@ const Article = 27;
1228
1228
  const Aside = 28;
1229
1229
  const Footer = 29;
1230
1230
  const Header = 30;
1231
- const Nav = 40;
1231
+ const Nav$1 = 40;
1232
1232
  const Section = 41;
1233
1233
  const Search = 42;
1234
1234
  const Dd = 43;
@@ -1332,7 +1332,7 @@ const VirtualDomElements = {
1332
1332
  Line,
1333
1333
  Main,
1334
1334
  Meta,
1335
- Nav,
1335
+ Nav: Nav$1,
1336
1336
  Ol,
1337
1337
  Option,
1338
1338
  P,
@@ -3567,8 +3567,9 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3567
3567
  const x = dimensions.x ?? state.x;
3568
3568
  const y = dimensions.y ?? state.y;
3569
3569
  const outerWidth = dimensions.width ?? state.outerWidth ?? state.width;
3570
+ const outerHeight = dimensions.height ?? state.outerHeight ?? state.height;
3570
3571
  const width$1 = Math.max(outerWidth - (state.minimapEnabled ? width : 0), 0);
3571
- const height = dimensions.height ?? state.height;
3572
+ const height = Math.max(outerHeight - (state.breadcrumbsEnabled ? 22 : 0), 0);
3572
3573
  const numberOfVisibleLines = Math.floor(height / state.itemHeight);
3573
3574
  if (!('foldingRanges' in state)) {
3574
3575
  const total = state.lines.length;
@@ -3592,6 +3593,9 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3592
3593
  ...('outerWidth' in state && {
3593
3594
  outerWidth
3594
3595
  }),
3596
+ ...('outerHeight' in state && {
3597
+ outerHeight
3598
+ }),
3595
3599
  scrollBarHeight,
3596
3600
  width: width$1,
3597
3601
  x,
@@ -3606,6 +3610,9 @@ const resize = (state, dimensions, columnWidth = state.columnWidth) => {
3606
3610
  ...('outerWidth' in state && {
3607
3611
  outerWidth
3608
3612
  }),
3613
+ ...('outerHeight' in state && {
3614
+ outerHeight
3615
+ }),
3609
3616
  width: width$1,
3610
3617
  x,
3611
3618
  y
@@ -4666,6 +4673,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4666
4673
  const editor = {
4667
4674
  additionalFocus: 0,
4668
4675
  assetDir,
4676
+ breadcrumbsEnabled: false,
4669
4677
  breakPoints: [],
4670
4678
  charWidth: 0,
4671
4679
  columnWidth: 0,
@@ -4681,6 +4689,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4681
4689
  diagnostics: [],
4682
4690
  diagnosticsEnabled: false,
4683
4691
  differences: [],
4692
+ documentSymbols: [],
4684
4693
  embeds: [],
4685
4694
  endOfLineDecorations: [],
4686
4695
  finalDeltaY: 0,
@@ -4725,6 +4734,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4725
4734
  modified: false,
4726
4735
  numberOfLines: 0,
4727
4736
  numberOfVisibleLines: 0,
4737
+ outerHeight: height,
4728
4738
  outerWidth: width,
4729
4739
  platform,
4730
4740
  primarySelectionIndex: 0,
@@ -4755,6 +4765,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4755
4765
  widgetRevision: 0,
4756
4766
  widgets: [],
4757
4767
  width,
4768
+ workspaceUri: '',
4758
4769
  x,
4759
4770
  y
4760
4771
  };
@@ -4762,6 +4773,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4762
4773
  };
4763
4774
 
4764
4775
  const emptyEditor = {
4776
+ breadcrumbsEnabled: false,
4765
4777
  breakPoints: [],
4766
4778
  cursorInfos: [],
4767
4779
  debugEnabled: false,
@@ -4770,6 +4782,7 @@ const emptyEditor = {
4770
4782
  deltaY: 0,
4771
4783
  diagnostics: [],
4772
4784
  differences: [],
4785
+ documentSymbols: [],
4773
4786
  embeds: [],
4774
4787
  endOfLineDecorations: [],
4775
4788
  focused: false,
@@ -4789,6 +4802,7 @@ const emptyEditor = {
4789
4802
  minimapLines: [],
4790
4803
  minimapRevision: 0,
4791
4804
  minLineY: 0,
4805
+ outerHeight: 0,
4792
4806
  outerWidth: 0,
4793
4807
  redoStack: [],
4794
4808
  scrollBarHeight: 0,
@@ -4808,6 +4822,7 @@ const emptyEditor = {
4808
4822
  uri: '',
4809
4823
  visibleLineIndices: [],
4810
4824
  width: 0,
4825
+ workspaceUri: '',
4811
4826
  x: 0,
4812
4827
  y: 0
4813
4828
  };
@@ -5139,7 +5154,7 @@ const isEqual$3 = (oldState, newState) => {
5139
5154
  };
5140
5155
 
5141
5156
  const isEqual$2 = (oldState, newState) => {
5142
- return oldState.breakPoints === newState.breakPoints && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos;
5157
+ return oldState.breadcrumbsEnabled === newState.breadcrumbsEnabled && oldState.breakPoints === newState.breakPoints && oldState.cursorInfos === newState.cursorInfos && oldState.diagnostics === newState.diagnostics && oldState.documentSymbols === newState.documentSymbols && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.highlightedLine === newState.highlightedLine && oldState.lineNumbers === newState.lineNumbers && oldState.loadError === newState.loadError && oldState.textInfos === newState.textInfos && oldState.differences === newState.differences && oldState.initial === newState.initial && oldState.selectionInfos === newState.selectionInfos && oldState.selections === newState.selections && oldState.workspaceUri === newState.workspaceUri;
5143
5158
  };
5144
5159
 
5145
5160
  const isEqual$1 = (oldState, newState) => {
@@ -11951,6 +11966,7 @@ const Div = 4;
11951
11966
  const Input = 6;
11952
11967
  const Span = 8;
11953
11968
  const Text = 12;
11969
+ const Nav = 40;
11954
11970
  const TextArea = 62;
11955
11971
 
11956
11972
  const text = data => {
@@ -13015,6 +13031,21 @@ const handleMessagePort = async (port, rpcId) => {
13015
13031
  }
13016
13032
  };
13017
13033
 
13034
+ const getDocumentSymbols = async editor => {
13035
+ try {
13036
+ const result = await execute({
13037
+ args: [],
13038
+ editor,
13039
+ kind: 'document symbol',
13040
+ method: 'provideDocumentSymbols',
13041
+ noProviderFoundResult: []
13042
+ });
13043
+ return Array.isArray(result) ? result : [];
13044
+ } catch {
13045
+ return [];
13046
+ }
13047
+ };
13048
+
13018
13049
  const kLineHeight = 'editor.lineHeight';
13019
13050
  const kFontSize = 'editor.fontSize';
13020
13051
  const kFontFamily = 'editor.fontFamily';
@@ -13028,6 +13059,7 @@ const kAutoClosingBrackets = 'editor.autoclosingBrackets';
13028
13059
  const kFontWeight = 'editor.fontWeight';
13029
13060
  const kHover = 'editor.hover';
13030
13061
  const kMinimapEnabled = 'editor.minimap.enabled';
13062
+ const kBreadcrumbsEnabled = 'breadcrumbs.enabled';
13031
13063
  const isAutoClosingBracketsEnabled = async () => {
13032
13064
  return Boolean(await get$3(kAutoClosingBrackets));
13033
13065
  };
@@ -13076,10 +13108,14 @@ const getFontWeight = async () => {
13076
13108
  const getMinimapEnabled = async () => {
13077
13109
  return (await get$3(kMinimapEnabled)) ?? false;
13078
13110
  };
13111
+ const getBreadcrumbsEnabled = async () => {
13112
+ return (await get$3(kBreadcrumbsEnabled)) ?? false;
13113
+ };
13079
13114
 
13080
13115
  const getEditorPreferences = async () => {
13081
- const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled()]);
13116
+ const [diagnosticsEnabled$1, fontFamily, fontSize, fontWeight, hoverEnabled, isAutoClosingBracketsEnabled$1, isAutoClosingQuotesEnabled$1, isAutoClosingTagsEnabled$1, isQuickSuggestionsEnabled$1, lineNumbers, rowHeight, tabSize, letterSpacing, completionTriggerCharacters, minimapEnabled, breadcrumbsEnabled] = await Promise.all([diagnosticsEnabled(), getFontFamily(), getFontSize(), getFontWeight(), getHoverEnabled(), isAutoClosingBracketsEnabled(), isAutoClosingQuotesEnabled(), isAutoClosingTagsEnabled(), isQuickSuggestionsEnabled(), getLineNumbers(), getRowHeight(), getTabSize(), getLetterSpacing(), getCompletionTriggerCharacters(), getMinimapEnabled(), getBreadcrumbsEnabled()]);
13082
13117
  return {
13118
+ breadcrumbsEnabled,
13083
13119
  completionTriggerCharacters,
13084
13120
  diagnosticsEnabled: diagnosticsEnabled$1,
13085
13121
  fontFamily,
@@ -13098,9 +13134,17 @@ const getEditorPreferences = async () => {
13098
13134
  };
13099
13135
  };
13100
13136
 
13137
+ const getWorkspaceUri$1 = async () => {
13138
+ try {
13139
+ return await invoke$a('Workspace.getPath');
13140
+ } catch {
13141
+ return '';
13142
+ }
13143
+ };
13101
13144
  const handleSettingsChanged = async state => {
13102
13145
  const editorPreferences = await getEditorPreferences();
13103
13146
  const {
13147
+ breadcrumbsEnabled,
13104
13148
  diagnosticsEnabled,
13105
13149
  fontFamily,
13106
13150
  fontSize,
@@ -13122,7 +13166,19 @@ const handleSettingsChanged = async state => {
13122
13166
  minimapRevision: (state.minimapRevision || 0) + (minimapEnabled ? 1 : 0),
13123
13167
  visualDecorations: diagnosticsEnabled ? state.visualDecorations : []
13124
13168
  };
13125
- return resize(editorWithUpdatedSettings, {}, charWidth);
13169
+ let documentSymbols = state.documentSymbols || [];
13170
+ let workspaceUri = state.workspaceUri || '';
13171
+ if (!breadcrumbsEnabled) {
13172
+ documentSymbols = [];
13173
+ workspaceUri = '';
13174
+ } else if (!state.breadcrumbsEnabled) {
13175
+ [documentSymbols, workspaceUri] = await Promise.all([getDocumentSymbols(editorWithUpdatedSettings), getWorkspaceUri$1()]);
13176
+ }
13177
+ return resize({
13178
+ ...editorWithUpdatedSettings,
13179
+ documentSymbols,
13180
+ workspaceUri
13181
+ }, {}, charWidth);
13126
13182
  };
13127
13183
 
13128
13184
  const applyTabCompletion = (editor, result) => {
@@ -13341,6 +13397,13 @@ const intialize = async (syntaxHighlightingEnabled, syncIncremental) => {
13341
13397
  await initializeSyntaxHighlighting(syntaxHighlightingEnabled, syncIncremental);
13342
13398
  };
13343
13399
 
13400
+ const getWorkspaceUri = async () => {
13401
+ try {
13402
+ return await invoke$a('Workspace.getPath');
13403
+ } catch {
13404
+ return '';
13405
+ }
13406
+ };
13344
13407
  const getTokenizePath = (languages, languageId) => {
13345
13408
  for (const language of languages) {
13346
13409
  if (language?.id === languageId && language.tokenize) {
@@ -13387,6 +13450,7 @@ const loadContent = async (state, savedState) => {
13387
13450
  y
13388
13451
  } = state;
13389
13452
  const {
13453
+ breadcrumbsEnabled,
13390
13454
  completionTriggerCharacters,
13391
13455
  diagnosticsEnabled,
13392
13456
  fontFamily,
@@ -13415,6 +13479,7 @@ const loadContent = async (state, savedState) => {
13415
13479
  set$3(newTokenizerId, tokenizer);
13416
13480
  const newEditor0 = {
13417
13481
  ...state,
13482
+ breadcrumbsEnabled,
13418
13483
  charWidth,
13419
13484
  completionTriggerCharacters,
13420
13485
  diagnosticsEnabled,
@@ -13473,13 +13538,23 @@ const loadContent = async (state, savedState) => {
13473
13538
  ...newEditor3,
13474
13539
  decorations: linkDecorations
13475
13540
  };
13541
+ let documentSymbols = state.documentSymbols || [];
13542
+ let workspaceUri = state.workspaceUri || '';
13543
+ if (breadcrumbsEnabled) {
13544
+ [documentSymbols, workspaceUri] = await Promise.all([getDocumentSymbols(newEditor3WithLinks), getWorkspaceUri()]);
13545
+ }
13546
+ const newEditor3WithBreadcrumbs = {
13547
+ ...newEditor3WithLinks,
13548
+ documentSymbols,
13549
+ workspaceUri
13550
+ };
13476
13551
  const syncIncremental = getEnabled();
13477
13552
  const {
13478
13553
  differences,
13479
13554
  textInfos
13480
- } = await getVisible$1(newEditor3WithLinks, syncIncremental);
13555
+ } = await getVisible$1(newEditor3WithBreadcrumbs, syncIncremental);
13481
13556
  const newEditor4 = {
13482
- ...newEditor3WithLinks,
13557
+ ...newEditor3WithBreadcrumbs,
13483
13558
  differences,
13484
13559
  focus: FocusEditorText$1,
13485
13560
  focused: true,
@@ -13925,6 +14000,92 @@ const Button = 'button';
13925
14000
  const Code = 'code';
13926
14001
  const TextBox = 'textbox';
13927
14002
 
14003
+ const getPathname = uri => {
14004
+ try {
14005
+ return decodeURIComponent(new URL(uri).pathname);
14006
+ } catch {
14007
+ return decodeURIComponent(uri);
14008
+ }
14009
+ };
14010
+ const getFileBreadcrumbs = (uri, workspaceUri) => {
14011
+ const path = getPathname(uri);
14012
+ const workspacePath = workspaceUri ? getPathname(workspaceUri).replace(/\/$/, '') : '';
14013
+ const relativePath = workspacePath && (path === workspacePath || path.startsWith(`${workspacePath}/`)) ? path.slice(workspacePath.length + 1) : path.split('/').at(-1) || path;
14014
+ return relativePath.split('/').filter(Boolean).map(label => ({
14015
+ kind: 'file',
14016
+ label
14017
+ }));
14018
+ };
14019
+ const containsOffset = (symbol, offset) => {
14020
+ return Number.isFinite(symbol.startOffset) && Number.isFinite(symbol.endOffset) && symbol.startOffset <= offset && offset <= symbol.endOffset;
14021
+ };
14022
+ const getSymbolBreadcrumbs = (symbols, offset) => {
14023
+ for (const symbol of symbols) {
14024
+ if (!symbol || typeof symbol.name !== 'string' || !containsOffset(symbol, offset)) {
14025
+ continue;
14026
+ }
14027
+ return [{
14028
+ kind: 'symbol',
14029
+ label: symbol.name,
14030
+ symbolKind: symbol.kind
14031
+ }, ...getSymbolBreadcrumbs(Array.isArray(symbol.children) ? symbol.children : [], offset)];
14032
+ }
14033
+ return [];
14034
+ };
14035
+ const getEditorBreadcrumbs = state => {
14036
+ const {
14037
+ breadcrumbsEnabled,
14038
+ documentSymbols,
14039
+ lines,
14040
+ primarySelectionIndex,
14041
+ selections,
14042
+ uri,
14043
+ workspaceUri
14044
+ } = state;
14045
+ if (!breadcrumbsEnabled) {
14046
+ return [];
14047
+ }
14048
+ const selectionIndex = primarySelectionIndex || 0;
14049
+ const rowIndex = selections[selectionIndex + 2] ?? selections[selectionIndex] ?? 0;
14050
+ const columnIndex = selections[selectionIndex + 3] ?? selections[selectionIndex + 1] ?? 0;
14051
+ const offset = offsetAt({
14052
+ lines
14053
+ }, rowIndex, columnIndex);
14054
+ return [...getFileBreadcrumbs(uri, workspaceUri || ''), ...getSymbolBreadcrumbs(documentSymbols || [], offset)];
14055
+ };
14056
+
14057
+ const separator = {
14058
+ ariaHidden: True,
14059
+ childCount: 0,
14060
+ className: mergeClassNames('EditorBreadcrumbSeparator', 'MaskIcon', 'MaskIconChevronRight'),
14061
+ type: Span
14062
+ };
14063
+ const getEditorBreadcrumbsVirtualDom = state => {
14064
+ const breadcrumbs = getEditorBreadcrumbs(state);
14065
+ const children = [];
14066
+ for (let index = 0; index < breadcrumbs.length; index++) {
14067
+ const breadcrumb = breadcrumbs[index];
14068
+ if (index > 0) {
14069
+ children.push(separator);
14070
+ }
14071
+ children.push({
14072
+ childCount: 1,
14073
+ className: mergeClassNames('EditorBreadcrumb', breadcrumb.kind === 'symbol' ? 'EditorBreadcrumbSymbol' : 'EditorBreadcrumbFile'),
14074
+ 'data-kind': breadcrumb.kind,
14075
+ ...(breadcrumb.symbolKind !== undefined && {
14076
+ 'data-symbolKind': breadcrumb.symbolKind
14077
+ }),
14078
+ type: Span
14079
+ }, text(breadcrumb.label));
14080
+ }
14081
+ return [{
14082
+ ariaLabel: 'Breadcrumbs',
14083
+ childCount: children.length,
14084
+ className: 'EditorBreadcrumbs',
14085
+ type: Nav
14086
+ }, ...children];
14087
+ };
14088
+
13928
14089
  const editorInputNode = {
13929
14090
  childCount: 1,
13930
14091
  className: 'EditorInput',
@@ -14256,25 +14417,32 @@ const getMinimapVirtualDom = (minimapEnabled, minimapLines, minLineY) => {
14256
14417
  }];
14257
14418
  };
14258
14419
  const getEditorVirtualDom = ({
14420
+ breadcrumbsEnabled = false,
14259
14421
  breakPoints = [],
14260
14422
  cursorInfos = [],
14261
14423
  diagnostics = [],
14262
14424
  differences,
14425
+ documentSymbols = [],
14263
14426
  endOfLineDecorations = [],
14264
14427
  gutterInfos = [],
14265
14428
  highlightedLine = -1,
14266
14429
  lightBulbRowIndex = -1,
14267
14430
  lineNumbers = true,
14431
+ lines = [],
14268
14432
  loadError = '',
14269
14433
  maxLineY = 0,
14270
14434
  minimapEnabled = false,
14271
14435
  minimapLines = [],
14272
14436
  minLineY = 0,
14437
+ primarySelectionIndex = 0,
14273
14438
  scrollBarDiagnostics = [],
14274
14439
  selectionInfos = [],
14440
+ selections = new Uint32Array(),
14275
14441
  textInfos,
14276
14442
  uid,
14277
- visibleLineIndices
14443
+ uri = '',
14444
+ visibleLineIndices,
14445
+ workspaceUri = ''
14278
14446
  }) => {
14279
14447
  if (loadError) {
14280
14448
  return [{
@@ -14289,14 +14457,23 @@ const getEditorVirtualDom = ({
14289
14457
  const showGutter = lineNumbers || breakPoints.length > 0 || lightBulbRowIndex >= 0;
14290
14458
  const gutterDom = showGutter ? getEditorGutterVirtualDom(visibleGutterInfos) : [];
14291
14459
  const minimapDom = getMinimapVirtualDom(minimapEnabled, minimapLines, minLineY);
14460
+ const breadcrumbsDom = breadcrumbsEnabled ? getEditorBreadcrumbsVirtualDom({
14461
+ breadcrumbsEnabled,
14462
+ documentSymbols,
14463
+ lines,
14464
+ primarySelectionIndex,
14465
+ selections,
14466
+ uri,
14467
+ workspaceUri
14468
+ }) : [];
14292
14469
  return [{
14293
- childCount: (showGutter ? 2 : 1) + (minimapEnabled ? 1 : 0),
14470
+ childCount: (showGutter ? 2 : 1) + (minimapEnabled ? 1 : 0) + (breadcrumbsEnabled ? 1 : 0),
14294
14471
  className: mergeClassNames('Viewlet', 'Editor'),
14295
14472
  'data-uid': uid,
14296
14473
  onContextMenu: HandleContextMenu,
14297
14474
  role: Code,
14298
14475
  type: Div
14299
- }, ...gutterDom, ...getEditorContentVirtualDom({
14476
+ }, ...breadcrumbsDom, ...gutterDom, ...getEditorContentVirtualDom({
14300
14477
  cursorInfos,
14301
14478
  diagnostics,
14302
14479
  differences,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.39.0",
3
+ "version": "19.41.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"