@visactor/vrender-core 1.1.3 → 1.1.4-alpha.1

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.
Files changed (146) hide show
  1. package/cjs/allocator/bounds-allocate.js +1 -2
  2. package/cjs/allocator/graphic-allocate.js +2 -1
  3. package/cjs/animate/config.js +1 -1
  4. package/cjs/application-state.d.ts +27 -0
  5. package/cjs/application-state.js +22 -0
  6. package/cjs/application-state.js.map +1 -0
  7. package/cjs/application.d.ts +2 -22
  8. package/cjs/application.js +24 -3
  9. package/cjs/application.js.map +1 -1
  10. package/cjs/common/contribution-provider.d.ts +2 -1
  11. package/cjs/common/contribution-provider.js +20 -2
  12. package/cjs/common/contribution-provider.js.map +1 -1
  13. package/cjs/common/contribution-store-state.d.ts +6 -0
  14. package/cjs/common/contribution-store-state.js +20 -0
  15. package/cjs/common/contribution-store-state.js.map +1 -0
  16. package/cjs/common/custom-path2d.js +1 -2
  17. package/cjs/common/module-guard.js +1 -1
  18. package/cjs/common/morphing-utils.js +1 -1
  19. package/cjs/common/path-svg.js +1 -1
  20. package/cjs/common/performance-raf.js +1 -1
  21. package/cjs/common/polygon.js +2 -2
  22. package/cjs/common/rect-utils.js +1 -1
  23. package/cjs/common/render-area.js +1 -1
  24. package/cjs/common/render-command-list.js +2 -1
  25. package/cjs/common/render-curve.js +1 -1
  26. package/cjs/common/render-utils.js +1 -1
  27. package/cjs/common/seg-context.js +1 -1
  28. package/cjs/common/simplify.js +1 -1
  29. package/cjs/common/sort.js +1 -1
  30. package/cjs/common/split-path.js +1 -1
  31. package/cjs/common/text.js +1 -1
  32. package/cjs/core/camera.js +1 -1
  33. package/cjs/core/constants.js +1 -1
  34. package/cjs/core/core-modules.js +1 -2
  35. package/cjs/core/global.js +1 -1
  36. package/cjs/core/graphic-utils.js +1 -1
  37. package/cjs/core/index.js +1 -1
  38. package/cjs/core/layer-service.js +1 -1
  39. package/cjs/core/layer.js +1 -1
  40. package/cjs/core/light.js +1 -1
  41. package/cjs/core/stage.js +1 -1
  42. package/cjs/core/window.js +1 -1
  43. package/cjs/entries/runtime-installer-state.d.ts +12 -0
  44. package/cjs/entries/runtime-installer-state.js +27 -0
  45. package/cjs/entries/runtime-installer-state.js.map +1 -0
  46. package/cjs/entries/runtime-installer.d.ts +3 -1
  47. package/cjs/entries/runtime-installer.js +23 -13
  48. package/cjs/entries/runtime-installer.js.map +1 -1
  49. package/cjs/factory-state.d.ts +5 -0
  50. package/cjs/factory-state.js +19 -0
  51. package/cjs/factory-state.js.map +1 -0
  52. package/cjs/factory.d.ts +2 -0
  53. package/cjs/factory.js +18 -2
  54. package/cjs/factory.js.map +1 -1
  55. package/cjs/graphic/graphic-creator.d.ts +2 -29
  56. package/cjs/graphic/graphic-creator.js +24 -38
  57. package/cjs/graphic/graphic-creator.js.map +1 -1
  58. package/cjs/graphic/graphic-registry.d.ts +36 -0
  59. package/cjs/graphic/graphic-registry.js +65 -0
  60. package/cjs/graphic/graphic-registry.js.map +1 -0
  61. package/cjs/graphic/graphic.d.ts +8 -1
  62. package/cjs/graphic/graphic.js +22 -7
  63. package/cjs/graphic/graphic.js.map +1 -1
  64. package/cjs/graphic/index.d.ts +2 -0
  65. package/cjs/graphic/index.js +29 -16
  66. package/cjs/graphic/index.js.map +1 -1
  67. package/cjs/legacy/bootstrap-state.d.ts +7 -0
  68. package/cjs/legacy/bootstrap-state.js +24 -0
  69. package/cjs/legacy/bootstrap-state.js.map +1 -0
  70. package/cjs/legacy/bootstrap.d.ts +3 -4
  71. package/cjs/legacy/bootstrap.js +20 -7
  72. package/cjs/legacy/bootstrap.js.map +1 -1
  73. package/dist/index.es.js +126 -25
  74. package/es/allocator/bounds-allocate.js +1 -2
  75. package/es/allocator/graphic-allocate.js +2 -1
  76. package/es/animate/config.js +1 -1
  77. package/es/application-state.d.ts +27 -0
  78. package/es/application-state.js +17 -0
  79. package/es/application-state.js.map +1 -0
  80. package/es/application.d.ts +2 -22
  81. package/es/application.js +2 -3
  82. package/es/application.js.map +1 -1
  83. package/es/common/contribution-provider.d.ts +2 -1
  84. package/es/common/contribution-provider.js +6 -1
  85. package/es/common/contribution-provider.js.map +1 -1
  86. package/es/common/contribution-store-state.d.ts +6 -0
  87. package/es/common/contribution-store-state.js +14 -0
  88. package/es/common/contribution-store-state.js.map +1 -0
  89. package/es/common/custom-path2d.js +1 -2
  90. package/es/common/module-guard.js +1 -1
  91. package/es/common/morphing-utils.js +1 -1
  92. package/es/common/path-svg.js +1 -1
  93. package/es/common/performance-raf.js +1 -1
  94. package/es/common/polygon.js +1 -1
  95. package/es/common/rect-utils.js +1 -1
  96. package/es/common/render-area.js +1 -1
  97. package/es/common/render-command-list.js +2 -1
  98. package/es/common/render-curve.js +1 -1
  99. package/es/common/render-utils.js +1 -1
  100. package/es/common/seg-context.js +1 -1
  101. package/es/common/simplify.js +1 -1
  102. package/es/common/sort.js +1 -1
  103. package/es/common/split-path.js +1 -1
  104. package/es/common/text.js +1 -1
  105. package/es/core/camera.js +1 -1
  106. package/es/core/constants.js +1 -1
  107. package/es/core/core-modules.js +1 -2
  108. package/es/core/global.js +1 -1
  109. package/es/core/graphic-utils.js +1 -1
  110. package/es/core/index.js +1 -1
  111. package/es/core/layer-service.js +1 -1
  112. package/es/core/layer.js +1 -1
  113. package/es/core/light.js +1 -1
  114. package/es/core/stage.js +1 -1
  115. package/es/core/window.js +1 -1
  116. package/es/entries/runtime-installer-state.d.ts +12 -0
  117. package/es/entries/runtime-installer-state.js +20 -0
  118. package/es/entries/runtime-installer-state.js.map +1 -0
  119. package/es/entries/runtime-installer.d.ts +3 -1
  120. package/es/entries/runtime-installer.js +8 -9
  121. package/es/entries/runtime-installer.js.map +1 -1
  122. package/es/factory-state.d.ts +5 -0
  123. package/es/factory-state.js +14 -0
  124. package/es/factory-state.js.map +1 -0
  125. package/es/factory.d.ts +2 -0
  126. package/es/factory.js +5 -1
  127. package/es/factory.js.map +1 -1
  128. package/es/graphic/graphic-creator.d.ts +2 -29
  129. package/es/graphic/graphic-creator.js +1 -41
  130. package/es/graphic/graphic-creator.js.map +1 -1
  131. package/es/graphic/graphic-registry.d.ts +36 -0
  132. package/es/graphic/graphic-registry.js +57 -0
  133. package/es/graphic/graphic-registry.js.map +1 -0
  134. package/es/graphic/graphic.d.ts +8 -1
  135. package/es/graphic/graphic.js +22 -3
  136. package/es/graphic/graphic.js.map +1 -1
  137. package/es/graphic/index.d.ts +2 -0
  138. package/es/graphic/index.js +2 -0
  139. package/es/graphic/index.js.map +1 -1
  140. package/es/legacy/bootstrap-state.d.ts +7 -0
  141. package/es/legacy/bootstrap-state.js +17 -0
  142. package/es/legacy/bootstrap-state.js.map +1 -0
  143. package/es/legacy/bootstrap.d.ts +3 -4
  144. package/es/legacy/bootstrap.js +5 -5
  145. package/es/legacy/bootstrap.js.map +1 -1
  146. package/package.json +11 -3
@@ -1,29 +1,2 @@
1
- import type { IArc, IArcGraphicAttribute, IArea, IAreaGraphicAttribute, ICircle, ICircleGraphicAttribute, IGroup, IGroupGraphicAttribute, IImage, IImageGraphicAttribute, ILine, ILineGraphicAttribute, IPath, IPathGraphicAttribute, IPolygon, IPolygonGraphicAttribute, IRect, IRect3d, IRect3dGraphicAttribute, IRectGraphicAttribute, IRichText, IRichTextGraphicAttribute, IShadowRoot, ISymbol, ISymbolGraphicAttribute, IText, ITextGraphicAttribute, IWrapTextGraphicAttribute } from '../interface';
2
- import type { IGraphic } from '../interface/graphic';
3
- export type IGraphicCreateCallback<TGraphic extends IGraphic = IGraphic, TAttributes = any> = (attributes: TAttributes) => TGraphic;
4
- declare class GraphicCreator {
5
- store: Map<string, IGraphicCreateCallback>;
6
- arc?: (attribute: IArcGraphicAttribute) => IArc;
7
- area?: (attribute: IAreaGraphicAttribute) => IArea;
8
- circle?: (attribute: ICircleGraphicAttribute) => ICircle;
9
- group?: (attribute: IGroupGraphicAttribute) => IGroup;
10
- image?: (attribute: IImageGraphicAttribute) => IImage;
11
- line?: (attribute: ILineGraphicAttribute) => ILine;
12
- path?: (attribute: IPathGraphicAttribute) => IPath;
13
- rect?: (attribute: IRectGraphicAttribute) => IRect;
14
- rect3d?: (attribute: IRect3dGraphicAttribute) => IRect3d;
15
- symbol?: (attribute: ISymbolGraphicAttribute) => ISymbol;
16
- text?: (attribute: ITextGraphicAttribute) => IText;
17
- richtext?: (attribute: IRichTextGraphicAttribute) => IRichText;
18
- polygon?: (attribute: IPolygonGraphicAttribute) => IPolygon;
19
- shadowRoot?: (attribute: IGroupGraphicAttribute) => IShadowRoot;
20
- wrapText?: (attribute: IWrapTextGraphicAttribute) => IText;
21
- constructor();
22
- registerStore(name: string, creator: IGraphicCreateCallback): void;
23
- RegisterGraphicCreator(name: string, creator: IGraphicCreateCallback): void;
24
- CreateGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, attributes: TAttributes): TGraphic | null;
25
- }
26
- export declare const graphicCreator: GraphicCreator;
27
- export declare function registerGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, creator: IGraphicCreateCallback<TGraphic, TAttributes>): void;
28
- export declare function createGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, attributes: TAttributes): TGraphic;
29
- export {};
1
+ export { createGraphic, GRAPHIC_REGISTRY_SYMBOL, graphicCreator, getGraphicRegistryState, registerGraphic } from './graphic-registry';
2
+ export type { IGraphicCreateCallback, IGraphicRegistryState } from './graphic-registry';
@@ -1,42 +1,2 @@
1
- import { GraphicFactory } from "../factory/graphic-factory";
2
-
3
- function createGraphicCtor(creator) {
4
- return class {
5
- constructor(attributes) {
6
- try {
7
- return new creator(attributes);
8
- } catch (error) {
9
- return creator(attributes);
10
- }
11
- }
12
- };
13
- }
14
-
15
- const sharedGraphicFactory = new GraphicFactory;
16
-
17
- class GraphicCreator {
18
- constructor() {
19
- this.store = new Map;
20
- }
21
- registerStore(name, creator) {
22
- this.store.set(name, creator), this[name] = creator;
23
- }
24
- RegisterGraphicCreator(name, creator) {
25
- registerGraphic(name, creator);
26
- }
27
- CreateGraphic(name, attributes) {
28
- return this.store.has(name) ? createGraphic(name, attributes) : null;
29
- }
30
- }
31
-
32
- export const graphicCreator = new GraphicCreator;
33
-
34
- export function registerGraphic(name, creator) {
35
- if (!name) throw new Error("Graphic registration requires a non-empty graphic type");
36
- graphicCreator.registerStore(name, creator), sharedGraphicFactory.register(name, createGraphicCtor(creator));
37
- }
38
-
39
- export function createGraphic(name, attributes) {
40
- return sharedGraphicFactory.create(name, attributes);
41
- }
1
+ export { createGraphic, GRAPHIC_REGISTRY_SYMBOL, graphicCreator, getGraphicRegistryState, registerGraphic } from "./graphic-registry";
42
2
  //# sourceMappingURL=graphic-creator.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/graphic-creator.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAO5D,SAAS,iBAAiB,CACxB,OAAsD;IAEtD,OAAO,MAAM,qBAAqB;QAChC,YAAY,UAAuB;YACjC,IAAI;gBACF,OAAO,IAAK,OAAe,CAAC,UAAU,CAAC,CAAC;aACzC;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;aAC5B;QACH,CAAC;KACK,CAAC;AACX,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAI,cAAc,EAAE,CAAC;AAElD,MAAM,cAAc;IAkBlB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,aAAa,CAAC,IAAY,EAAE,OAA+B;QACzD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,sBAAsB,CAAC,IAAY,EAAE,OAA+B;QAClE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,aAAa,CACX,IAAY,EACZ,UAAuB;QAEvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,aAAa,CAAwB,IAAI,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;AAEnD,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAAsD;IAEtD,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,OAAiC,CAAC,CAAC;IACtE,oBAAoB,CAAC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,UAAuB;IAEvB,OAAO,oBAAoB,CAAC,MAAM,CAAwB,IAAI,EAAE,UAAU,CAAC,CAAC;AAC9E,CAAC","file":"graphic-creator.js","sourcesContent":["import type {\n IArc,\n IArcGraphicAttribute,\n IArea,\n IAreaGraphicAttribute,\n ICircle,\n ICircleGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImage,\n IImageGraphicAttribute,\n ILine,\n ILineGraphicAttribute,\n IPath,\n IPathGraphicAttribute,\n IPolygon,\n IPolygonGraphicAttribute,\n IRect,\n IRect3d,\n IRect3dGraphicAttribute,\n IRectGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n IShadowRoot,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '../interface';\nimport { GraphicFactory } from '../factory/graphic-factory';\nimport type { IGraphic } from '../interface/graphic';\n\nexport type IGraphicCreateCallback<TGraphic extends IGraphic = IGraphic, TAttributes = any> = (\n attributes: TAttributes\n) => TGraphic;\n\nfunction createGraphicCtor<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n creator: IGraphicCreateCallback<TGraphic, TAttributes>\n) {\n return class RegisteredGraphicCtor {\n constructor(attributes: TAttributes) {\n try {\n return new (creator as any)(attributes);\n } catch (error) {\n return creator(attributes);\n }\n }\n } as any;\n}\n\nconst sharedGraphicFactory = new GraphicFactory();\n\nclass GraphicCreator {\n declare store: Map<string, IGraphicCreateCallback>;\n declare arc?: (attribute: IArcGraphicAttribute) => IArc;\n declare area?: (attribute: IAreaGraphicAttribute) => IArea;\n declare circle?: (attribute: ICircleGraphicAttribute) => ICircle;\n declare group?: (attribute: IGroupGraphicAttribute) => IGroup;\n declare image?: (attribute: IImageGraphicAttribute) => IImage;\n declare line?: (attribute: ILineGraphicAttribute) => ILine;\n declare path?: (attribute: IPathGraphicAttribute) => IPath;\n declare rect?: (attribute: IRectGraphicAttribute) => IRect;\n declare rect3d?: (attribute: IRect3dGraphicAttribute) => IRect3d;\n declare symbol?: (attribute: ISymbolGraphicAttribute) => ISymbol;\n declare text?: (attribute: ITextGraphicAttribute) => IText;\n declare richtext?: (attribute: IRichTextGraphicAttribute) => IRichText;\n declare polygon?: (attribute: IPolygonGraphicAttribute) => IPolygon;\n declare shadowRoot?: (attribute: IGroupGraphicAttribute) => IShadowRoot;\n declare wrapText?: (attribute: IWrapTextGraphicAttribute) => IText;\n\n constructor() {\n this.store = new Map();\n }\n\n registerStore(name: string, creator: IGraphicCreateCallback) {\n this.store.set(name, creator);\n (this as any)[name] = creator;\n }\n\n RegisterGraphicCreator(name: string, creator: IGraphicCreateCallback) {\n registerGraphic(name, creator);\n }\n\n CreateGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n attributes: TAttributes\n ): TGraphic | null {\n if (!this.store.has(name)) {\n return null;\n }\n\n return createGraphic<TGraphic, TAttributes>(name, attributes);\n }\n}\n\nexport const graphicCreator = new GraphicCreator();\n\nexport function registerGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n creator: IGraphicCreateCallback<TGraphic, TAttributes>\n) {\n if (!name) {\n throw new Error('Graphic registration requires a non-empty graphic type');\n }\n\n graphicCreator.registerStore(name, creator as IGraphicCreateCallback);\n sharedGraphicFactory.register(name, createGraphicCtor(creator));\n}\n\nexport function createGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n attributes: TAttributes\n): TGraphic {\n return sharedGraphicFactory.create<TGraphic, TAttributes>(name, attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/graphic-creator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,uBAAuB,EACvB,cAAc,EACd,uBAAuB,EACvB,eAAe,EAChB,MAAM,oBAAoB,CAAC","file":"graphic-creator.js","sourcesContent":["export {\n createGraphic,\n GRAPHIC_REGISTRY_SYMBOL,\n graphicCreator,\n getGraphicRegistryState,\n registerGraphic\n} from './graphic-registry';\nexport type { IGraphicCreateCallback, IGraphicRegistryState } from './graphic-registry';\n"]}
@@ -0,0 +1,36 @@
1
+ import { GraphicFactory } from '../factory/graphic-factory';
2
+ import type { IArc, IArcGraphicAttribute, IArea, IAreaGraphicAttribute, ICircle, ICircleGraphicAttribute, IGroup, IGroupGraphicAttribute, IImage, IImageGraphicAttribute, ILine, ILineGraphicAttribute, IPath, IPathGraphicAttribute, IPolygon, IPolygonGraphicAttribute, IRect, IRect3d, IRect3dGraphicAttribute, IRectGraphicAttribute, IRichText, IRichTextGraphicAttribute, IShadowRoot, ISymbol, ISymbolGraphicAttribute, IText, ITextGraphicAttribute, IWrapTextGraphicAttribute } from '../interface';
3
+ import type { IGraphic } from '../interface/graphic';
4
+ export type IGraphicCreateCallback<TGraphic extends IGraphic = IGraphic, TAttributes = any> = (attributes: TAttributes) => TGraphic;
5
+ declare class GraphicCreator {
6
+ store: Map<string, IGraphicCreateCallback>;
7
+ arc?: (attribute: IArcGraphicAttribute) => IArc;
8
+ area?: (attribute: IAreaGraphicAttribute) => IArea;
9
+ circle?: (attribute: ICircleGraphicAttribute) => ICircle;
10
+ group?: (attribute: IGroupGraphicAttribute) => IGroup;
11
+ image?: (attribute: IImageGraphicAttribute) => IImage;
12
+ line?: (attribute: ILineGraphicAttribute) => ILine;
13
+ path?: (attribute: IPathGraphicAttribute) => IPath;
14
+ rect?: (attribute: IRectGraphicAttribute) => IRect;
15
+ rect3d?: (attribute: IRect3dGraphicAttribute) => IRect3d;
16
+ symbol?: (attribute: ISymbolGraphicAttribute) => ISymbol;
17
+ text?: (attribute: ITextGraphicAttribute) => IText;
18
+ richtext?: (attribute: IRichTextGraphicAttribute) => IRichText;
19
+ polygon?: (attribute: IPolygonGraphicAttribute) => IPolygon;
20
+ shadowRoot?: (attribute: IGroupGraphicAttribute) => IShadowRoot;
21
+ wrapText?: (attribute: IWrapTextGraphicAttribute) => IText;
22
+ constructor();
23
+ registerStore(name: string, creator: IGraphicCreateCallback): void;
24
+ RegisterGraphicCreator(name: string, creator: IGraphicCreateCallback): void;
25
+ CreateGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, attributes: TAttributes): TGraphic | null;
26
+ }
27
+ export declare const GRAPHIC_REGISTRY_SYMBOL: unique symbol;
28
+ export interface IGraphicRegistryState {
29
+ graphicCreator: GraphicCreator;
30
+ graphicFactory: GraphicFactory;
31
+ }
32
+ export declare function getGraphicRegistryState(): IGraphicRegistryState;
33
+ export declare const graphicCreator: GraphicCreator;
34
+ export declare function registerGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, creator: IGraphicCreateCallback<TGraphic, TAttributes>): void;
35
+ export declare function createGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(name: string, attributes: TAttributes): TGraphic;
36
+ export {};
@@ -0,0 +1,57 @@
1
+ import { GraphicFactory } from "../factory/graphic-factory";
2
+
3
+ function createGraphicCtor(creator) {
4
+ return class {
5
+ constructor(attributes) {
6
+ try {
7
+ return new creator(attributes);
8
+ } catch (error) {
9
+ return creator(attributes);
10
+ }
11
+ }
12
+ };
13
+ }
14
+
15
+ class GraphicCreator {
16
+ constructor() {
17
+ this.store = new Map;
18
+ }
19
+ registerStore(name, creator) {
20
+ this.store.set(name, creator), this[name] = creator;
21
+ }
22
+ RegisterGraphicCreator(name, creator) {
23
+ registerGraphic(name, creator);
24
+ }
25
+ CreateGraphic(name, attributes) {
26
+ return this.store.has(name) ? createGraphic(name, attributes) : null;
27
+ }
28
+ }
29
+
30
+ export const GRAPHIC_REGISTRY_SYMBOL = Symbol.for("@visactor/vrender-core/graphic-registry");
31
+
32
+ function createGraphicRegistryState() {
33
+ return {
34
+ graphicCreator: new GraphicCreator,
35
+ graphicFactory: new GraphicFactory
36
+ };
37
+ }
38
+
39
+ export function getGraphicRegistryState() {
40
+ const scope = globalThis;
41
+ return scope[GRAPHIC_REGISTRY_SYMBOL] || (scope[GRAPHIC_REGISTRY_SYMBOL] = createGraphicRegistryState()),
42
+ scope[GRAPHIC_REGISTRY_SYMBOL];
43
+ }
44
+
45
+ const sharedGraphicRegistry = getGraphicRegistryState();
46
+
47
+ export const graphicCreator = sharedGraphicRegistry.graphicCreator;
48
+
49
+ export function registerGraphic(name, creator) {
50
+ if (!name) throw new Error("Graphic registration requires a non-empty graphic type");
51
+ graphicCreator.registerStore(name, creator), sharedGraphicRegistry.graphicFactory.register(name, createGraphicCtor(creator));
52
+ }
53
+
54
+ export function createGraphic(name, attributes) {
55
+ return sharedGraphicRegistry.graphicFactory.create(name, attributes);
56
+ }
57
+ //# sourceMappingURL=graphic-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graphic/graphic-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAqC5D,SAAS,iBAAiB,CACxB,OAAsD;IAEtD,OAAO,MAAM,qBAAqB;QAChC,YAAY,UAAuB;YACjC,IAAI;gBACF,OAAO,IAAK,OAAe,CAAC,UAAU,CAAC,CAAC;aACzC;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;aAC5B;QACH,CAAC;KACK,CAAC;AACX,CAAC;AAED,MAAM,cAAc;IAkBlB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED,aAAa,CAAC,IAAY,EAAE,OAA+B;QACzD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC7B,IAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,sBAAsB,CAAC,IAAY,EAAE,OAA+B;QAClE,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,aAAa,CACX,IAAY,EACZ,UAAuB;QAEvB,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QAED,OAAO,aAAa,CAAwB,IAAI,EAAE,UAAU,CAAC,CAAC;IAChE,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;AAO7F,SAAS,0BAA0B;IACjC,OAAO;QACL,cAAc,EAAE,IAAI,cAAc,EAAE;QACpC,cAAc,EAAE,IAAI,cAAc,EAAE;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,KAAK,GAAG,UAAuF,CAAC;IAEtG,IAAI,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE;QACnC,KAAK,CAAC,uBAAuB,CAAC,GAAG,0BAA0B,EAAE,CAAC;KAC/D;IAED,OAAO,KAAK,CAAC,uBAAuB,CAA0B,CAAC;AACjE,CAAC;AAED,MAAM,qBAAqB,GAAG,uBAAuB,EAAE,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG,qBAAqB,CAAC,cAAc,CAAC;AAEnE,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAAsD;IAEtD,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;KAC3E;IAED,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,OAAiC,CAAC,CAAC;IACtE,qBAAqB,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,IAAY,EACZ,UAAuB;IAEvB,OAAO,qBAAqB,CAAC,cAAc,CAAC,MAAM,CAAwB,IAAI,EAAE,UAAU,CAAC,CAAC;AAC9F,CAAC","file":"graphic-registry.js","sourcesContent":["import { GraphicFactory } from '../factory/graphic-factory';\nimport type {\n IArc,\n IArcGraphicAttribute,\n IArea,\n IAreaGraphicAttribute,\n ICircle,\n ICircleGraphicAttribute,\n IGroup,\n IGroupGraphicAttribute,\n IImage,\n IImageGraphicAttribute,\n ILine,\n ILineGraphicAttribute,\n IPath,\n IPathGraphicAttribute,\n IPolygon,\n IPolygonGraphicAttribute,\n IRect,\n IRect3d,\n IRect3dGraphicAttribute,\n IRectGraphicAttribute,\n IRichText,\n IRichTextGraphicAttribute,\n IShadowRoot,\n ISymbol,\n ISymbolGraphicAttribute,\n IText,\n ITextGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '../interface';\nimport type { IGraphic } from '../interface/graphic';\n\nexport type IGraphicCreateCallback<TGraphic extends IGraphic = IGraphic, TAttributes = any> = (\n attributes: TAttributes\n) => TGraphic;\n\nfunction createGraphicCtor<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n creator: IGraphicCreateCallback<TGraphic, TAttributes>\n) {\n return class RegisteredGraphicCtor {\n constructor(attributes: TAttributes) {\n try {\n return new (creator as any)(attributes);\n } catch (error) {\n return creator(attributes);\n }\n }\n } as any;\n}\n\nclass GraphicCreator {\n declare store: Map<string, IGraphicCreateCallback>;\n declare arc?: (attribute: IArcGraphicAttribute) => IArc;\n declare area?: (attribute: IAreaGraphicAttribute) => IArea;\n declare circle?: (attribute: ICircleGraphicAttribute) => ICircle;\n declare group?: (attribute: IGroupGraphicAttribute) => IGroup;\n declare image?: (attribute: IImageGraphicAttribute) => IImage;\n declare line?: (attribute: ILineGraphicAttribute) => ILine;\n declare path?: (attribute: IPathGraphicAttribute) => IPath;\n declare rect?: (attribute: IRectGraphicAttribute) => IRect;\n declare rect3d?: (attribute: IRect3dGraphicAttribute) => IRect3d;\n declare symbol?: (attribute: ISymbolGraphicAttribute) => ISymbol;\n declare text?: (attribute: ITextGraphicAttribute) => IText;\n declare richtext?: (attribute: IRichTextGraphicAttribute) => IRichText;\n declare polygon?: (attribute: IPolygonGraphicAttribute) => IPolygon;\n declare shadowRoot?: (attribute: IGroupGraphicAttribute) => IShadowRoot;\n declare wrapText?: (attribute: IWrapTextGraphicAttribute) => IText;\n\n constructor() {\n this.store = new Map();\n }\n\n registerStore(name: string, creator: IGraphicCreateCallback) {\n this.store.set(name, creator);\n (this as any)[name] = creator;\n }\n\n RegisterGraphicCreator(name: string, creator: IGraphicCreateCallback) {\n registerGraphic(name, creator);\n }\n\n CreateGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n attributes: TAttributes\n ): TGraphic | null {\n if (!this.store.has(name)) {\n return null;\n }\n\n return createGraphic<TGraphic, TAttributes>(name, attributes);\n }\n}\n\nexport const GRAPHIC_REGISTRY_SYMBOL = Symbol.for('@visactor/vrender-core/graphic-registry');\n\nexport interface IGraphicRegistryState {\n graphicCreator: GraphicCreator;\n graphicFactory: GraphicFactory;\n}\n\nfunction createGraphicRegistryState(): IGraphicRegistryState {\n return {\n graphicCreator: new GraphicCreator(),\n graphicFactory: new GraphicFactory()\n };\n}\n\nexport function getGraphicRegistryState(): IGraphicRegistryState {\n const scope = globalThis as typeof globalThis & { [GRAPHIC_REGISTRY_SYMBOL]?: IGraphicRegistryState };\n\n if (!scope[GRAPHIC_REGISTRY_SYMBOL]) {\n scope[GRAPHIC_REGISTRY_SYMBOL] = createGraphicRegistryState();\n }\n\n return scope[GRAPHIC_REGISTRY_SYMBOL] as IGraphicRegistryState;\n}\n\nconst sharedGraphicRegistry = getGraphicRegistryState();\n\nexport const graphicCreator = sharedGraphicRegistry.graphicCreator;\n\nexport function registerGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n creator: IGraphicCreateCallback<TGraphic, TAttributes>\n) {\n if (!name) {\n throw new Error('Graphic registration requires a non-empty graphic type');\n }\n\n graphicCreator.registerStore(name, creator as IGraphicCreateCallback);\n sharedGraphicRegistry.graphicFactory.register(name, createGraphicCtor(creator));\n}\n\nexport function createGraphic<TGraphic extends IGraphic = IGraphic, TAttributes = any>(\n name: string,\n attributes: TAttributes\n): TGraphic {\n return sharedGraphicRegistry.graphicFactory.create<TGraphic, TAttributes>(name, attributes);\n}\n"]}
@@ -57,7 +57,7 @@ export declare const NOWORK_ANIMATE_ATTR: {
57
57
  cursor: number;
58
58
  html: number;
59
59
  };
60
- export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> extends Node implements IGraphic<T>, IAnimateTarget {
60
+ declare abstract class GraphicImpl<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> extends Node implements IGraphic<T>, IAnimateTarget {
61
61
  static mixin(source: Dict<any>): void;
62
62
  _events?: any;
63
63
  context?: Record<string, any>;
@@ -320,4 +320,11 @@ export declare abstract class Graphic<T extends Partial<IGraphicAttribute> = Par
320
320
  abstract clone(): IGraphic<any>;
321
321
  toCustomPath(): ICustomPath2D;
322
322
  }
323
+ export type Graphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> = GraphicImpl<T>;
324
+ export declare const GRAPHIC_CLASS_SYMBOL: unique symbol;
325
+ export interface IGraphicClassState {
326
+ Graphic: typeof GraphicImpl;
327
+ }
328
+ export declare function getGraphicClassState(): IGraphicClassState;
329
+ export declare const Graphic: typeof GraphicImpl;
323
330
  export {};
@@ -116,12 +116,12 @@ export const NOWORK_ANIMATE_ATTR = {
116
116
  html: 1
117
117
  };
118
118
 
119
- export class Graphic extends Node {
119
+ class GraphicImpl extends Node {
120
120
  static mixin(source) {
121
121
  const keys = Object.keys(source);
122
122
  for (let i = 0; i < keys.length; ++i) {
123
123
  const propertyName = keys[i];
124
- Object.defineProperty(Graphic.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
124
+ Object.defineProperty(this.prototype, propertyName, Object.getOwnPropertyDescriptor(source, propertyName));
125
125
  }
126
126
  }
127
127
  get AABBBounds() {
@@ -1353,6 +1353,25 @@ export class Graphic extends Node {
1353
1353
  }
1354
1354
  }
1355
1355
 
1356
+ GraphicImpl.userSymbolMap = {};
1357
+
1358
+ export const GRAPHIC_CLASS_SYMBOL = Symbol.for("@visactor/vrender-core/graphic-class");
1359
+
1360
+ function createGraphicClassState() {
1361
+ return {
1362
+ Graphic: GraphicImpl
1363
+ };
1364
+ }
1365
+
1366
+ export function getGraphicClassState() {
1367
+ var _a;
1368
+ const globalScope = globalThis;
1369
+ return null !== (_a = globalScope[GRAPHIC_CLASS_SYMBOL]) && void 0 !== _a || (globalScope[GRAPHIC_CLASS_SYMBOL] = createGraphicClassState()),
1370
+ globalScope[GRAPHIC_CLASS_SYMBOL];
1371
+ }
1372
+
1373
+ export const Graphic = getGraphicClassState().Graphic;
1374
+
1356
1375
  function backgroundNotImage(image) {
1357
1376
  return "string" == typeof image ? !(image.startsWith("<svg") || isValidUrl(image) || image.includes("/") || isBase64(image)) : !(!image.fill && !image.stroke) || !("string" != typeof image.gradient || !Array.isArray(image.stops));
1358
1377
  }
@@ -1361,5 +1380,5 @@ function isExternalTexture(texture) {
1361
1380
  return !!texture && ("string" == typeof texture ? !builtinTextureTypes.has(texture) && (texture.startsWith("<svg") || isValidUrl(texture) || texture.includes("/") || isBase64(texture)) : isObject(texture));
1362
1381
  }
1363
1382
 
1364
- Graphic.userSymbolMap = {}, Graphic.mixin(EventTarget);
1383
+ Graphic.mixin(EventTarget);
1365
1384
  //# sourceMappingURL=graphic.js.map