Skip to content

Commit 0540dc9

Browse files
obenjirod3m1d0v
andauthored
fix: fixed critical circular dependencies (#549)
--------- Co-authored-by: d3m1d0v <[email protected]>
1 parent 5277645 commit 0540dc9

File tree

49 files changed

+477
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+477
-241
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,19 @@ jobs:
4141
run: npm run test
4242
- name: ESBuild compatability
4343
run: npm run test:esbuild
44+
45+
check_circular_deps:
46+
name: Check Circular Dependencies
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout
50+
uses: actions/checkout@v3
51+
- name: Setup Node
52+
uses: actions/setup-node@v3
53+
with:
54+
node-version: 18
55+
cache: npm
56+
- name: Install Packages
57+
run: npm ci
58+
- name: Check circular dependencies
59+
run: npm run check-circular-deps

demo/stories/ghost/ghostExtension/toolbar.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {Ghost} from '@gravity-ui/icons';
22

3-
import {ToolbarDataType} from '../../../../src';
4-
import {MToolbarSingleItemData} from '../../../../src/bundle/config/markup';
3+
import {type MToolbarSingleItemData, ToolbarDataType} from '../../../../src';
54

65
import {showGhostPopup} from './commands';
76

package-lock.json

Lines changed: 140 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lint:js": "eslint \"{src,demo}/**/*.{js,jsx,ts,tsx}\"",
2626
"lint:styles": "stylelint \"{src,demo}/**/*.{css,scss}\"",
2727
"lint:prettier": "prettier --check \"{src,demo}/**/*.{js,jsx,ts,tsx,css,scss}\"",
28+
"check-circular-deps": "node scripts/check-circular-deps.js 48",
2829
"test": "jest",
2930
"test:cov": "jest --coverage",
3031
"test:watch": "jest --watchAll",
@@ -235,6 +236,7 @@
235236
"@types/rimraf": "3.0.2",
236237
"@types/sanitize-html": "2.11.0",
237238
"bem-cn-lite": "4.1.0",
239+
"dpdm": "3.14.0",
238240
"esbuild-sass-plugin": "2.15.0",
239241
"eslint": "8.56.0",
240242
"eslint-plugin-lodash": "7.4.0",

scripts/check-circular-deps.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-disable no-console, import/no-extraneous-dependencies, no-undef */
2+
const process = require('process');
3+
4+
const {parseDependencyTree, parseCircular, prettyCircular} = require('dpdm');
5+
6+
const threshold = parseInt(process.argv[2], 10) || 99; // Default to 99 if no argument provided
7+
8+
parseDependencyTree('./src/index.ts', {
9+
/* options, see https://github.com/acrazing/dpdm?tab=readme-ov-file#api-reference */
10+
}).then((tree) => {
11+
const circulars = parseCircular(tree);
12+
if (circulars.length > threshold) {
13+
console.error(prettyCircular(circulars));
14+
console.error(
15+
`Circular dependencies check failed (found: ${circulars.length}, threshold: ${threshold})`,
16+
);
17+
process.exit(1);
18+
}
19+
20+
console.log(
21+
`Circular dependencies check passed (found: ${circulars.length}, threshold: ${threshold})`,
22+
);
23+
process.exit(0);
24+
});

src/bundle/MarkdownEditorView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import {HorizontalDrag} from './HorizontalDrag';
1616
import {MarkupEditorView} from './MarkupEditorView';
1717
import {SplitModeView} from './SplitModeView';
1818
import {WysiwygEditorView} from './WysiwygEditorView';
19-
import {MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData} from './config';
2019
import {useMarkdownEditorContext} from './context';
21-
import {EditorSettings, EditorSettingsProps} from './settings';
20+
import {EditorSettings, type EditorSettingsProps} from './settings';
2221
import {stickyCn} from './sticky';
22+
import type {MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData} from './toolbar/types';
2323
import {getToolbarsConfigs} from './toolbar/utils/toolbarsConfigs';
2424
import type {MarkdownEditorMode} from './types';
2525

src/bundle/MarkupEditorView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react';
22

3-
import {ClassNameProps, cn} from '../classname';
3+
import {type ClassNameProps, cn} from '../classname';
44
import {ReactRendererComponent} from '../extensions';
55
import {logger} from '../logger';
66
import {useRenderTime} from '../react-utils/hooks';
77

88
import type {EditorInt} from './Editor';
99
import {MarkupEditorComponent} from './MarkupEditorComponent';
1010
import {ToolbarView} from './ToolbarView';
11-
import type {MToolbarData, MToolbarItemData} from './config/markup';
1211
import {MarkupToolbarContextProvider} from './toolbar/markup/context';
12+
import type {MToolbarData, MToolbarItemData} from './toolbar/types';
1313
import type {MarkdownEditorSplitMode} from './types';
1414

1515
import './MarkupEditorView.scss';

src/bundle/WysiwygEditorView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import React from 'react';
22

3-
import {ClassNameProps, cn} from '../classname';
3+
import {type ClassNameProps, cn} from '../classname';
44
import {ReactRendererComponent} from '../extensions';
55
import {logger} from '../logger';
66
import {useRenderTime} from '../react-utils/hooks';
77

88
import type {EditorInt} from './Editor';
99
import {ToolbarView} from './ToolbarView';
1010
import {WysiwygEditorComponent} from './WysiwygEditorComponent';
11-
import type {WToolbarData, WToolbarItemData} from './config/wysiwyg';
11+
import type {WToolbarData, WToolbarItemData} from './toolbar/types';
1212

1313
import './WysiwygEditorView.scss';
1414

src/bundle/config/markup.tsx

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,42 +40,43 @@ import {
4040
wrapToYfmCut,
4141
wrapToYfmNote,
4242
} from '../../markup/commands';
43-
import {CodeEditor} from '../../markup/editor';
43+
import type {CodeEditor} from '../../markup/editor';
4444
import {Action as A, formatter as f} from '../../shortcuts';
45-
import {ToolbarData} from '../../toolbar/Toolbar';
46-
import {ToolbarGroupData} from '../../toolbar/ToolbarGroup';
47-
import {ToolbarListButtonData} from '../../toolbar/ToolbarListButton';
48-
import {
49-
ToolbarButtonPopupData,
50-
ToolbarDataType,
51-
ToolbarItemData,
52-
ToolbarListButtonItemData,
53-
ToolbarListItemData,
54-
ToolbarReactComponentData,
55-
ToolbarSingleItemData,
56-
} from '../../toolbar/types';
5745
import {MToolbarColors} from '../toolbar/markup/MToolbarColors';
5846
import {MToolbarFilePopup} from '../toolbar/markup/MToolbarFilePopup';
5947
import {MToolbarImagePopup} from '../toolbar/markup/MToolbarImagePopup';
48+
import type {
49+
MToolbarButtonPopupData,
50+
MToolbarData,
51+
MToolbarGroupData,
52+
MToolbarItemData,
53+
MToolbarListButtonData,
54+
MToolbarListItemData,
55+
MToolbarSingleItemData,
56+
ToolbarListButtonItemData,
57+
} from '../toolbar/types';
58+
import {ToolbarDataType} from '../toolbar/types';
6059
import type {MarkdownEditorPreset} from '../types';
6160

6261
import {ActionName} from './action-names';
6362
import {icons} from './icons';
6463

64+
export type {
65+
MToolbarData,
66+
MToolbarItemData,
67+
MToolbarSingleItemData,
68+
MToolbarGroupData,
69+
MToolbarReactComponentData,
70+
MToolbarListButtonData,
71+
MToolbarListItemData,
72+
MToolbarButtonPopupData,
73+
} from '../toolbar/types';
74+
6575
const noop = () => {};
6676
const inactive = () => false;
6777
const enable = () => true;
6878
const disable = () => false;
6979

70-
export type MToolbarData = ToolbarData<CodeEditor>;
71-
export type MToolbarItemData = ToolbarItemData<CodeEditor>;
72-
export type MToolbarSingleItemData = ToolbarSingleItemData<CodeEditor>;
73-
export type MToolbarGroupData = ToolbarGroupData<CodeEditor>;
74-
export type MToolbarReactComponentData = ToolbarReactComponentData<CodeEditor>;
75-
export type MToolbarListButtonData = ToolbarListButtonData<CodeEditor>;
76-
export type MToolbarListItemData = ToolbarListItemData<CodeEditor>;
77-
export type MToolbarButtonPopupData = ToolbarButtonPopupData<CodeEditor>;
78-
7980
export const mUndoItemData: MToolbarSingleItemData = {
8081
id: ActionName.undo,
8182
type: ToolbarDataType.SingleButton,

0 commit comments

Comments
 (0)