Skip to content

Commit 212b78d

Browse files
committed
feat(joint-react): update dependencies, refactor components, and enhance performance
- Updated dependencies in yarn.lock, including Babel and added unplugin. - Refactored GraphProvider and Paper components for improved performance and clarity. - Removed unused files and hooks to streamline the codebase. - Enhanced the Storybook setup with a new script for loading react-scan. - Improved element rendering logic and optimized hooks for better state management. - Added tests for new functionalities and ensured existing tests are up to date.
1 parent 0fe069f commit 212b78d

File tree

81 files changed

+3231
-3361
lines changed

Some content is hidden

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

81 files changed

+3231
-3361
lines changed

packages/joint-react-eslint/eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const config = [
170170
"error",
171171
{
172172
replacements: {
173+
dev: false,
173174
doc: false,
174175
Props: false,
175176
props: false,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
11
<!-- Loads a font from a CDN -->
2+
<!-- react-scan: Load with delay to avoid freezing Storybook -->
3+
<script>
4+
// Load react-scan UI overlay after Storybook initializes
5+
(function () {
6+
if (typeof window === 'undefined') return;
7+
8+
// Wait for DOM and React to be ready
9+
function loadReactScan() {
10+
if (window.__REACT_SCAN_LOADED) return;
11+
12+
const script = document.createElement('script');
13+
script.src = 'https://unpkg.com/react-scan@latest/dist/auto.global.js';
14+
script.async = true;
15+
script.onload = function () {
16+
window.__REACT_SCAN_LOADED = true;
17+
18+
19+
// Wait a bit for react-scan to initialize, then configure it for iframe
20+
setTimeout(function () {
21+
// Access react-scan global API
22+
const reactScan = window.reactScan;
23+
24+
if (reactScan && typeof reactScan === 'function') {
25+
// Configure react-scan to work in iframe (Storybook uses iframes)
26+
try {
27+
reactScan({
28+
enabled: false, // Disabled by default - user can enable via toolbar
29+
allowInIframe: true,
30+
showToolbar: true, // Show toolbar so user can toggle it on/off
31+
});
32+
33+
} catch (error) {
34+
console.error('❌ Error configuring react-scan:', error);
35+
}
36+
} else {
37+
console.warn('⚠️ react-scan function not found');
38+
}
39+
}, 500);
40+
};
41+
script.onerror = function () {
42+
console.error('❌ Failed to load react-scan');
43+
};
44+
document.head.appendChild(script);
45+
}
46+
47+
// Try loading after a delay
48+
if (document.readyState === 'loading') {
49+
document.addEventListener('DOMContentLoaded', function () {
50+
setTimeout(loadReactScan, 3000);
51+
});
52+
} else {
53+
setTimeout(loadReactScan, 3000);
54+
}
55+
})();
56+
</script>
257
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
358
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">

packages/joint-react/.storybook/preview.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import './wdyr';
21
import type { Preview } from '@storybook/react';
32
import { withPerformance } from 'storybook-addon-performance';
43
import { theme } from './theme';

packages/joint-react/.storybook/wdyr.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/joint-react/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@
7373
"@types/react": "19.1.12",
7474
"@types/react-dom": "19.1.9",
7575
"@types/react-test-renderer": "19.1.0",
76+
"@types/scheduler": "^0",
7677
"@types/use-sync-external-store": "1.5.0",
7778
"@vitejs/plugin-react": "^5.0.2",
78-
"@welldone-software/why-did-you-render": "10.0.1",
7979
"canvas": "^3.1.0",
8080
"eslint": "9.33.0",
8181
"glob": "^11.0.1",
@@ -88,6 +88,7 @@
8888
"react-docgen-typescript-plugin": "^1.0.8",
8989
"react-dom": "^19.1.1",
9090
"react-redux": "^9.2.0",
91+
"react-scan": "^0.4.3",
9192
"react-test-renderer": "^19.1.1",
9293
"redux": "^5.0.1",
9394
"storybook": "^8.6.14",
@@ -108,6 +109,7 @@
108109
},
109110
"dependencies": {
110111
"@joint/core": "workspace:*",
112+
"scheduler": "^0.27.0",
111113
"use-sync-external-store": "^1.4.0"
112114
},
113115
"peerDependencies": {

packages/joint-react/src/components/graph/graph-provider.stories.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,7 @@ function Component() {
121121
setIsReady(true);
122122
}, 1000);
123123
}, []);
124-
return (
125-
isReady && (
126-
<Paper interactive={false} className={PAPER_CLASSNAME} renderElement={RenderHTMLElement} />
127-
)
128-
);
124+
return isReady && <Paper className={PAPER_CLASSNAME} renderElement={RenderHTMLElement} />;
129125
}
130126

131127
export const ConditionalRender: Story = {

0 commit comments

Comments
 (0)