Skip to content

Commit a27d956

Browse files
committed
fix: stabilize BytePack registry singletons
1 parent 6f67ba7 commit a27d956

59 files changed

Lines changed: 294 additions & 68 deletions

Some content is hidden

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

packages/vchart-extension/src/charts/3d/arc-3d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { registerArc3d } from '@visactor/vrender-kits/register/register-arc3d';
22
import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot';
3-
import { createArc3d } from '@visactor/vrender-core';
3+
import { createArc3d } from './graphic-creator';
44
import { registerArcAnimation } from '@visactor/vchart/esm/animation/config';
55
import { Factory } from '@visactor/vchart/esm/core/factory';
66
import { BaseArcMark } from '@visactor/vchart/esm/mark/arc';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { createArc3d, createPyramid3d, createRect3d } from '@visactor/vchart/esm/vrender-bridge';

packages/vchart-extension/src/charts/3d/plugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { registerDirectionalLight, registerOrthoCamera, registerViewTransform3dPlugin } from '@visactor/vrender-core';
1+
import {
2+
registerDirectionalLight,
3+
registerOrthoCamera,
4+
registerViewTransform3dPlugin
5+
} from '@visactor/vrender-core/plugin/3d';
26
import type { VChartRenderActionSource } from '@visactor/vchart/esm/core/interface';
37
import { BasePlugin } from '@visactor/vchart/esm/plugin/base/base-plugin';
48
import type { IChartPlugin, IChartPluginService } from '@visactor/vchart/esm/plugin/chart/interface';

packages/vchart-extension/src/charts/3d/pyramid-3d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createPyramid3d } from '@visactor/vrender-core';
1+
import { createPyramid3d } from './graphic-creator';
22
import { registerPyramid3d } from '@visactor/vrender-kits/register/register-pyramid3d';
33
import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot';
44
import { registerPolygonAnimation } from '@visactor/vchart/esm/animation/config';

packages/vchart-extension/src/charts/3d/rect-3d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createRect3d } from '@visactor/vrender-core';
1+
import { createRect3d } from './graphic-creator';
22
import { registerRect3d } from '@visactor/vrender-kits/register/register-rect3d';
33
import { registerShadowRoot } from '@visactor/vrender-kits/register/register-shadowRoot';
44
import { registerRectAnimation } from '@visactor/vchart/esm/animation/config';

packages/vchart-extension/src/charts/pie-3d/chart.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Factory } from '@visactor/vchart/esm/core/factory';
22
import type { AdaptiveSpec } from '@visactor/vchart/esm/typings/spec/common';
33
import { BasePieChart } from '@visactor/vchart/esm/chart/pie/base/base';
44
import { registerMarkTooltipProcessor } from '@visactor/vchart/esm/component/tooltip/processor/mark-tooltip';
5+
import { registerAnimate } from '@visactor/vchart/esm/plugin/other';
56
import type { IPie3dChartSpec } from './interface';
67
import { ChartType3dEnum, SeriesType3dEnum } from '../3d/enum';
78
import { register3DPlugin } from '../3d/plugin';
@@ -20,6 +21,7 @@ export class Pie3dChart<T extends IPie3dChartSpec = IPie3dChartSpec> extends Bas
2021
}
2122

2223
export const registerPie3dChart = () => {
24+
registerAnimate();
2325
registerMarkTooltipProcessor();
2426
register3DPlugin();
2527
registerLayout3d();

packages/vchart-extension/tsconfig.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
"baseUrl": "./",
66
"rootDir": "./src",
77
"outDir": "./esm",
8-
"composite": true
8+
"composite": true,
9+
"paths": {
10+
"@visactor/vrender-core": ["./node_modules/@visactor/vrender-core/es/index"],
11+
"@visactor/vrender-core/*": ["./node_modules/@visactor/vrender-core/es/*"]
12+
}
913
},
1014
"ts-node": {
1115
"transpileOnly": true,
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import { DomTooltipHandler } from '../../../../src/plugin/components/tooltip-handler/dom-tooltip-handler';
2+
import { TOOLTIP_CONTAINER_EL_CLASS_NAME } from '../../../../src/plugin/components/tooltip-handler/constants';
3+
import { createDiv, removeDom } from '../../../util/dom';
4+
5+
const createTooltipSpec = (spec: any) => ({
6+
className: 'vchart-tooltip',
7+
style: {
8+
shape: {},
9+
keyLabel: {},
10+
valueLabel: {}
11+
},
12+
...spec
13+
});
14+
15+
const createHandler = (spec: any, chartContainer?: HTMLElement) => {
16+
const handler = new DomTooltipHandler() as any;
17+
18+
handler._component = {
19+
getSpec: () => createTooltipSpec(spec)
20+
};
21+
handler._chartOption = {
22+
getTheme: (): undefined => undefined
23+
};
24+
handler._chartContainer = chartContainer;
25+
handler._initStyle();
26+
27+
return handler as DomTooltipHandler;
28+
};
29+
30+
describe('DomTooltipHandler', () => {
31+
let container: HTMLElement;
32+
33+
beforeEach(() => {
34+
container = createDiv();
35+
});
36+
37+
afterEach(() => {
38+
removeDom(container);
39+
});
40+
41+
it('falls back to chart container when tooltip parentElement is not a dom element', () => {
42+
const handler = createHandler(
43+
{
44+
parentElement: {}
45+
},
46+
container
47+
);
48+
49+
expect(() => handler.initRootDom()).not.toThrow();
50+
expect(container.querySelector(`.${TOOLTIP_CONTAINER_EL_CLASS_NAME}`)).toBe(handler.getTooltipContainer());
51+
expect(container.querySelector('.vchart-tooltip')).toBe(handler.getRootDom());
52+
});
53+
54+
it('creates tooltip container under an empty valid parentElement', () => {
55+
const parentElement = createDiv(container);
56+
const handler = createHandler({
57+
parentElement
58+
});
59+
60+
handler.initEl();
61+
62+
expect(parentElement.querySelector(`.${TOOLTIP_CONTAINER_EL_CLASS_NAME}`)).toBe(handler.getTooltipContainer());
63+
});
64+
});

packages/vchart/bundler.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function externalizeFactoryRegistryForEsTotal() {
8282
name: 'externalize-vchart-factory-registry',
8383
resolveId(source, importer) {
8484
if (
85-
source === './factory-registry' &&
85+
(source === './factory-registry' || source === factoryRegistryExternalId) &&
8686
importer &&
8787
path.normalize(importer).endsWith(path.normalize('src/core/factory.ts'))
8888
) {

packages/vchart/src/animation/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { registerAnimate as registerVRenderAnimate, registerCustomAnimate } from '@visactor/vrender-animate';
1+
export { registerVRenderAnimate } from '../vrender-bridge';
2+
export { registerCustomAnimate } from '@visactor/vrender-animate/custom/register';
23
export { registerStateTransition } from './state-transition';
34
export { registerSequentialAnimate } from './sequential-animate';
45
export {

0 commit comments

Comments
 (0)