Skip to content

Commit e2b0638

Browse files
authored
Merge pull request #1342 from mathuo/feat/dockview-modules-package
feat: extract separable feature modules into a dockview-modules package
2 parents 73d0a01 + 78bf993 commit e2b0638

40 files changed

Lines changed: 1083 additions & 537 deletions

MIGRATION-v7.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,18 @@ package.
1414

1515
## React users — action required (breaking)
1616

17-
The React bindings moved from `dockview` to `dockview-react`.
17+
The React bindings moved from `dockview` to `dockview-react`. In v7 the
18+
`dockview` package is the vanilla JavaScript library (a re-export of
19+
`dockview-core`), so it no longer exports the React components.
20+
21+
**Symptoms if you don't migrate** (the React names are simply gone — core names
22+
like `DockviewComponent` still resolve from `dockview`):
23+
24+
- TypeScript: `error TS2305: Module '"dockview"' has no exported member 'DockviewReact'`
25+
- Runtime (JS): React throws *"Element type is invalid … got: undefined"* when
26+
rendering `<DockviewReact />`, because the import resolves to `undefined`.
27+
28+
The fix is to install and import from `dockview-react`:
1829

1930
```diff
2031
- npm install dockview
@@ -61,6 +72,25 @@ grep -rl "from 'dockview'" src | xargs sed -i '' "s/from 'dockview'/from 'dockvi
6172
`dockview-core` continues to be published and will keep working, but new code
6273
should depend on `dockview`.
6374

75+
### `dockview-core` no longer bundles every feature (behaviour change)
76+
77+
In v6, `dockview-core` shipped with all built-in features registered. In v7 a
78+
set of feature modules is no longer part of bare `dockview-core`:
79+
80+
- **tab group chips** (chip rendering + the `onDid*TabGroup` events)
81+
- **context menus** (the built-in tab / chip right-click menus)
82+
- **advanced drag-and-drop** (`onWillDragPanel` / `onWillDragGroup` /
83+
`onWillDrop` hooks, custom drag ghost / drop overlay)
84+
- **keyboard accessibility** (keyboard navigation / docking / live-region
85+
announcements)
86+
87+
These now live in the `dockview` package. **`dockview-core` is an internal
88+
package — use `dockview`** (or a framework package — `dockview-react` / `-vue` /
89+
`-angular`, which all consume `dockview`). Nothing throws if you stay on bare
90+
`dockview-core` — the affected features simply do nothing — so a one-time
91+
`console.warn` is emitted when a component is constructed on bare `dockview-core`
92+
steering you to `dockview`.
93+
6494
## Vue / Angular users
6595

6696
No source changes required — keep installing `dockview-vue` / `dockview-angular`

__generated__/dockview-core-exports.txt

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

nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"cache": true
2020
},
2121
"build:bundle": {
22-
"dependsOn": ["build"],
22+
"dependsOn": ["build", "^build:bundle"],
2323
"inputs": ["production", "^production"],
2424
"outputs": ["{projectRoot}/dist"],
2525
"cache": true

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"packages/*"
1717
],
1818
"scripts": {
19-
"build": "nx run-many -t build --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular",
20-
"build:bundle": "nx run-many -t build:bundle --projects=dockview-core,dockview,dockview-vue,dockview-react,dockview-angular",
19+
"build": "nx run-many -t build --projects=dockview-core,dockview-modules,dockview,dockview-vue,dockview-react,dockview-angular",
20+
"build:bundle": "nx run-many -t build:bundle --projects=dockview-core,dockview-modules,dockview,dockview-vue,dockview-react,dockview-angular",
2121
"clean": "nx run-many -t clean",
2222
"docs": "typedoc && node scripts/docs.mjs",
2323
"lint": "nx run-many -t lint",

packages/dockview-angular/jest.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const config: JestConfigWithTsJest = {
1919
moduleNameMapper: {
2020
'^dockview$': '<rootDir>/packages/dockview/src/index.ts',
2121
'^dockview-core$': '<rootDir>/packages/dockview-core/src/index.ts',
22+
'^dockview-modules$':
23+
'<rootDir>/packages/dockview-modules/src/index.ts',
2224
},
2325
modulePathIgnorePatterns: [
2426
'<rootDir>/packages/dockview-angular/src/__tests__/__mocks__',

packages/dockview-core/src/__tests__/dockview/components/titlebar/voidContainer.spec.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { VoidContainer } from '../../../../dockview/components/titlebar/voidContainer';
22
import { fromPartial } from '@total-typescript/shoehorn';
33
import { DockviewComponent } from '../../../../dockview/dockviewComponent';
4-
import { AdvancedDnDService } from '../../../../dockview/advancedDnDService';
54
import { DockviewGroupPanel } from '../../../../dockview/dockviewGroupPanel';
65
import { DockviewGroupPanelModel } from '../../../../dockview/dockviewGroupPanelModel';
76
import {
@@ -616,10 +615,15 @@ describe('voidContainer', () => {
616615
api: fakeApi as any,
617616
options: { createGroupDragGhostComponent: factory },
618617
doSetGroupActive: jest.fn(),
619-
// The custom-ghost resolution now lives in AdvancedDnDService;
620-
// delegate to the real service so this still exercises it.
621-
buildGroupDragGhost: (g: any) =>
622-
new AdvancedDnDService(accessor).buildGroupDragGhost(g),
618+
// The custom-ghost resolution lives in the AdvancedDnD module
619+
// (covered by its own tests). Here we stub the host's ghost
620+
// builder — exactly what DockviewComponent provides to
621+
// VoidContainer — to verify VoidContainer drives the lifecycle.
622+
buildGroupDragGhost: (g: any) => {
623+
const r = factory(g);
624+
r.init({ group: g, api: fakeApi });
625+
return { element: r.element, dispose: () => r.dispose() };
626+
},
623627
});
624628
const group = fromPartial<DockviewGroupPanel>({
625629
id: 'g1',

0 commit comments

Comments
 (0)