@visactor/vrender-core 0.17.0-alpha.1 → 0.17.0-alpha.3

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 (228) hide show
  1. package/cjs/allocator/canvas-allocate.d.ts +2 -0
  2. package/cjs/allocator/canvas-allocate.js +12 -6
  3. package/cjs/allocator/canvas-allocate.js.map +1 -1
  4. package/cjs/common/Reflect-metadata.js +349 -358
  5. package/cjs/common/Reflect-metadata.js.map +1 -1
  6. package/cjs/common/inversify/annotation/inject.d.ts +1 -0
  7. package/cjs/common/inversify/annotation/inject.js +10 -0
  8. package/cjs/common/inversify/annotation/inject.js.map +1 -0
  9. package/cjs/common/inversify/annotation/inject_base.d.ts +14 -0
  10. package/cjs/common/inversify/annotation/inject_base.js +39 -0
  11. package/cjs/common/inversify/annotation/inject_base.js.map +1 -0
  12. package/cjs/common/inversify/annotation/injectable.d.ts +1 -0
  13. package/cjs/common/{inversify-lite/annotation/post_construct.js → inversify/annotation/injectable.js} +15 -5
  14. package/cjs/common/inversify/annotation/injectable.js.map +1 -0
  15. package/cjs/common/inversify/annotation/multi_inject.d.ts +1 -0
  16. package/cjs/common/inversify/annotation/multi_inject.js +10 -0
  17. package/cjs/common/inversify/annotation/multi_inject.js.map +1 -0
  18. package/cjs/common/inversify/annotation/named.d.ts +1 -0
  19. package/cjs/common/inversify/annotation/named.js +14 -0
  20. package/cjs/common/inversify/annotation/named.js.map +1 -0
  21. package/cjs/common/inversify/binding.d.ts +18 -0
  22. package/cjs/common/inversify/binding.js +26 -0
  23. package/cjs/common/inversify/binding.js.map +1 -0
  24. package/cjs/common/inversify/container.d.ts +28 -0
  25. package/cjs/common/inversify/container.js +155 -0
  26. package/cjs/common/inversify/container.js.map +1 -0
  27. package/cjs/common/inversify/cotainer-module.d.ts +6 -0
  28. package/cjs/common/inversify/cotainer-module.js +16 -0
  29. package/cjs/common/inversify/cotainer-module.js.map +1 -0
  30. package/cjs/common/inversify/index.d.ts +7 -0
  31. package/cjs/common/inversify/index.js +75 -0
  32. package/cjs/common/inversify/index.js.map +1 -0
  33. package/cjs/common/inversify/interfaces.d.ts +218 -0
  34. package/cjs/common/inversify/interfaces.js +6 -0
  35. package/cjs/common/inversify/interfaces.js.map +1 -0
  36. package/cjs/common/inversify/literal_types.d.ts +5 -0
  37. package/cjs/common/inversify/literal_types.js +34 -0
  38. package/cjs/common/inversify/literal_types.js.map +1 -0
  39. package/cjs/common/inversify/meta-data.d.ts +6 -0
  40. package/cjs/common/inversify/meta-data.js +19 -0
  41. package/cjs/common/inversify/meta-data.js.map +1 -0
  42. package/cjs/common/inversify/metadata_keys.d.ts +12 -0
  43. package/cjs/common/inversify/metadata_keys.js +15 -0
  44. package/cjs/common/inversify/metadata_keys.js.map +1 -0
  45. package/cjs/common/inversify/metadata_reader.d.ts +6 -0
  46. package/cjs/common/inversify/metadata_reader.js +28 -0
  47. package/cjs/common/inversify/metadata_reader.js.map +1 -0
  48. package/cjs/common/inversify/syntax/binding_in_syntax.d.ts +10 -0
  49. package/cjs/common/inversify/syntax/binding_in_syntax.js +29 -0
  50. package/cjs/common/inversify/syntax/binding_in_syntax.js.map +1 -0
  51. package/cjs/common/inversify/syntax/binding_to_syntax.d.ts +12 -0
  52. package/cjs/common/inversify/syntax/binding_to_syntax.js +40 -0
  53. package/cjs/common/inversify/syntax/binding_to_syntax.js.map +1 -0
  54. package/cjs/common/inversify/syntax/constraint_helpers.d.ts +2 -0
  55. package/cjs/common/inversify/syntax/constraint_helpers.js +18 -0
  56. package/cjs/common/inversify/syntax/constraint_helpers.js.map +1 -0
  57. package/cjs/common/inversify-lite/index.d.ts +1 -8
  58. package/cjs/common/inversify-lite/index.js +1 -64
  59. package/cjs/common/inversify-lite/index.js.map +1 -1
  60. package/cjs/common/utils.d.ts +1 -0
  61. package/cjs/common/utils.js +10 -1
  62. package/cjs/common/utils.js.map +1 -1
  63. package/cjs/core/global.d.ts +2 -0
  64. package/cjs/core/global.js +4 -3
  65. package/cjs/core/global.js.map +1 -1
  66. package/cjs/core/graphic-utils.d.ts +5 -2
  67. package/cjs/core/graphic-utils.js +14 -4
  68. package/cjs/core/graphic-utils.js.map +1 -1
  69. package/cjs/core/stage.d.ts +4 -1
  70. package/cjs/core/stage.js +31 -27
  71. package/cjs/core/stage.js.map +1 -1
  72. package/cjs/core/window.js +2 -2
  73. package/cjs/core/window.js.map +1 -1
  74. package/cjs/event/event-manager.js +3 -2
  75. package/cjs/event/event-manager.js.map +1 -1
  76. package/cjs/graphic/builtin-symbol/index.d.ts +1 -0
  77. package/cjs/graphic/builtin-symbol/index.js +8 -2
  78. package/cjs/graphic/builtin-symbol/index.js.map +1 -1
  79. package/cjs/graphic/config.js +4 -1
  80. package/cjs/graphic/config.js.map +1 -1
  81. package/cjs/graphic/richtext/paragraph.js +12 -11
  82. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  83. package/cjs/graphic/symbol.js +3 -2
  84. package/cjs/graphic/symbol.js.map +1 -1
  85. package/cjs/graphic/text.d.ts +1 -0
  86. package/cjs/graphic/text.js +93 -7
  87. package/cjs/graphic/text.js.map +1 -1
  88. package/cjs/graphic/wrap-text.js +6 -5
  89. package/cjs/graphic/wrap-text.js.map +1 -1
  90. package/cjs/interface/global.d.ts +1 -0
  91. package/cjs/interface/global.js.map +1 -1
  92. package/cjs/interface/graphic/richText.d.ts +1 -1
  93. package/cjs/interface/graphic/richText.js.map +1 -1
  94. package/cjs/interface/graphic/text.d.ts +4 -1
  95. package/cjs/interface/graphic/text.js.map +1 -1
  96. package/cjs/render/contributions/render/area-render.d.ts +1 -0
  97. package/cjs/render/contributions/render/area-render.js +42 -5
  98. package/cjs/render/contributions/render/area-render.js.map +1 -1
  99. package/cjs/render/contributions/render/base-render.js +4 -10
  100. package/cjs/render/contributions/render/base-render.js.map +1 -1
  101. package/cjs/render/contributions/render/draw-contribution.d.ts +2 -0
  102. package/cjs/render/contributions/render/draw-contribution.js +18 -9
  103. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  104. package/cjs/render/contributions/render/line-render.d.ts +1 -0
  105. package/cjs/render/contributions/render/line-render.js +21 -6
  106. package/cjs/render/contributions/render/line-render.js.map +1 -1
  107. package/cjs/render/contributions/render/module.js +7 -7
  108. package/cjs/render/contributions/render/module.js.map +1 -1
  109. package/cjs/render/contributions/render/text-render.js +12 -10
  110. package/cjs/render/contributions/render/text-render.js.map +1 -1
  111. package/dist/index.js +691 -1548
  112. package/dist/index.min.js +1 -1
  113. package/es/allocator/canvas-allocate.d.ts +2 -0
  114. package/es/allocator/canvas-allocate.js +12 -6
  115. package/es/allocator/canvas-allocate.js.map +1 -1
  116. package/es/common/Reflect-metadata.js +349 -358
  117. package/es/common/Reflect-metadata.js.map +1 -1
  118. package/es/common/inversify/annotation/inject.d.ts +1 -0
  119. package/es/common/inversify/annotation/inject.js +6 -0
  120. package/es/common/inversify/annotation/inject.js.map +1 -0
  121. package/es/common/inversify/annotation/inject_base.d.ts +14 -0
  122. package/es/common/inversify/annotation/inject_base.js +29 -0
  123. package/es/common/inversify/annotation/inject_base.js.map +1 -0
  124. package/es/common/inversify/annotation/injectable.d.ts +1 -0
  125. package/es/common/inversify/annotation/injectable.js +10 -0
  126. package/es/common/inversify/annotation/injectable.js.map +1 -0
  127. package/es/common/inversify/annotation/multi_inject.d.ts +1 -0
  128. package/es/common/inversify/annotation/multi_inject.js +6 -0
  129. package/es/common/inversify/annotation/multi_inject.js.map +1 -0
  130. package/es/common/inversify/annotation/named.d.ts +1 -0
  131. package/es/common/inversify/annotation/named.js +10 -0
  132. package/es/common/inversify/annotation/named.js.map +1 -0
  133. package/es/common/inversify/binding.d.ts +18 -0
  134. package/es/common/inversify/binding.js +22 -0
  135. package/es/common/inversify/binding.js.map +1 -0
  136. package/es/common/inversify/container.d.ts +28 -0
  137. package/es/common/inversify/container.js +155 -0
  138. package/es/common/inversify/container.js.map +1 -0
  139. package/es/common/inversify/cotainer-module.d.ts +6 -0
  140. package/es/common/inversify/cotainer-module.js +8 -0
  141. package/es/common/inversify/cotainer-module.js.map +1 -0
  142. package/es/common/inversify/index.d.ts +7 -0
  143. package/es/common/inversify/index.js +14 -0
  144. package/es/common/inversify/index.js.map +1 -0
  145. package/es/common/inversify/interfaces.d.ts +218 -0
  146. package/es/common/inversify/interfaces.js +2 -0
  147. package/es/common/inversify/interfaces.js.map +1 -0
  148. package/es/common/inversify/literal_types.d.ts +5 -0
  149. package/es/common/inversify/literal_types.js +20 -0
  150. package/es/common/inversify/literal_types.js.map +1 -0
  151. package/es/common/inversify/meta-data.d.ts +6 -0
  152. package/es/common/inversify/meta-data.js +11 -0
  153. package/es/common/inversify/meta-data.js.map +1 -0
  154. package/es/common/inversify/metadata_keys.d.ts +12 -0
  155. package/es/common/inversify/metadata_keys.js +28 -0
  156. package/es/common/inversify/metadata_keys.js.map +1 -0
  157. package/es/common/inversify/metadata_reader.d.ts +6 -0
  158. package/es/common/inversify/metadata_reader.js +18 -0
  159. package/es/common/inversify/metadata_reader.js.map +1 -0
  160. package/es/common/inversify/syntax/binding_in_syntax.d.ts +10 -0
  161. package/es/common/inversify/syntax/binding_in_syntax.js +24 -0
  162. package/es/common/inversify/syntax/binding_in_syntax.js.map +1 -0
  163. package/es/common/inversify/syntax/binding_to_syntax.d.ts +12 -0
  164. package/es/common/inversify/syntax/binding_to_syntax.js +36 -0
  165. package/es/common/inversify/syntax/binding_to_syntax.js.map +1 -0
  166. package/es/common/inversify/syntax/constraint_helpers.d.ts +2 -0
  167. package/es/common/inversify/syntax/constraint_helpers.js +16 -0
  168. package/es/common/inversify/syntax/constraint_helpers.js.map +1 -0
  169. package/es/common/inversify-lite/index.d.ts +1 -8
  170. package/es/common/inversify-lite/index.js +1 -15
  171. package/es/common/inversify-lite/index.js.map +1 -1
  172. package/es/common/utils.d.ts +1 -0
  173. package/es/common/utils.js +8 -1
  174. package/es/common/utils.js.map +1 -1
  175. package/es/core/global.d.ts +2 -0
  176. package/es/core/global.js +4 -2
  177. package/es/core/global.js.map +1 -1
  178. package/es/core/graphic-utils.d.ts +5 -2
  179. package/es/core/graphic-utils.js +14 -4
  180. package/es/core/graphic-utils.js.map +1 -1
  181. package/es/core/stage.d.ts +4 -1
  182. package/es/core/stage.js +31 -24
  183. package/es/core/stage.js.map +1 -1
  184. package/es/core/window.js +3 -3
  185. package/es/core/window.js.map +1 -1
  186. package/es/event/event-manager.js +3 -2
  187. package/es/event/event-manager.js.map +1 -1
  188. package/es/graphic/builtin-symbol/index.d.ts +1 -0
  189. package/es/graphic/builtin-symbol/index.js +8 -0
  190. package/es/graphic/builtin-symbol/index.js.map +1 -1
  191. package/es/graphic/config.js +4 -1
  192. package/es/graphic/config.js.map +1 -1
  193. package/es/graphic/richtext/paragraph.js +5 -2
  194. package/es/graphic/richtext/paragraph.js.map +1 -1
  195. package/es/graphic/symbol.js +4 -3
  196. package/es/graphic/symbol.js.map +1 -1
  197. package/es/graphic/text.d.ts +1 -0
  198. package/es/graphic/text.js +90 -9
  199. package/es/graphic/text.js.map +1 -1
  200. package/es/graphic/wrap-text.js +6 -4
  201. package/es/graphic/wrap-text.js.map +1 -1
  202. package/es/interface/global.d.ts +1 -0
  203. package/es/interface/global.js.map +1 -1
  204. package/es/interface/graphic/richText.d.ts +1 -1
  205. package/es/interface/graphic/richText.js.map +1 -1
  206. package/es/interface/graphic/text.d.ts +4 -1
  207. package/es/interface/graphic/text.js.map +1 -1
  208. package/es/render/contributions/render/area-render.d.ts +1 -0
  209. package/es/render/contributions/render/area-render.js +42 -5
  210. package/es/render/contributions/render/area-render.js.map +1 -1
  211. package/es/render/contributions/render/base-render.js +2 -14
  212. package/es/render/contributions/render/base-render.js.map +1 -1
  213. package/es/render/contributions/render/draw-contribution.d.ts +2 -0
  214. package/es/render/contributions/render/draw-contribution.js +18 -9
  215. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  216. package/es/render/contributions/render/line-render.d.ts +1 -0
  217. package/es/render/contributions/render/line-render.js +21 -6
  218. package/es/render/contributions/render/line-render.js.map +1 -1
  219. package/es/render/contributions/render/module.js +21 -17
  220. package/es/render/contributions/render/module.js.map +1 -1
  221. package/es/render/contributions/render/text-render.js +13 -9
  222. package/es/render/contributions/render/text-render.js.map +1 -1
  223. package/package.json +4 -2
  224. package/cjs/common/inversify-lite/annotation/post_construct.d.ts +0 -4
  225. package/cjs/common/inversify-lite/annotation/post_construct.js.map +0 -1
  226. package/es/common/inversify-lite/annotation/post_construct.d.ts +0 -4
  227. package/es/common/inversify-lite/annotation/post_construct.js +0 -10
  228. package/es/common/inversify-lite/annotation/post_construct.js.map +0 -1
package/dist/index.js CHANGED
@@ -4,62 +4,25 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VRenderCore = {}, global.VUtils));
5
5
  })(this, (function (exports, vutils) { 'use strict';
6
6
 
7
- let idCounter = 0;
8
- function id() {
9
- return idCounter++;
7
+ class Generator {
8
+ static GenAutoIncrementId() {
9
+ return Generator.auto_increment_id++;
10
+ }
10
11
  }
12
+ Generator.auto_increment_id = 0;
11
13
 
12
14
  class ContainerModule {
13
15
  constructor(registry) {
14
- this.id = id();
16
+ this.id = Generator.GenAutoIncrementId();
15
17
  this.registry = registry;
16
18
  }
17
19
  }
18
20
 
19
21
  const NAMED_TAG = 'named';
20
- const NAME_TAG = 'name';
21
- const UNMANAGED_TAG = 'unmanaged';
22
- const OPTIONAL_TAG = 'optional';
23
22
  const INJECT_TAG = 'inject';
24
23
  const MULTI_INJECT_TAG = 'multi_inject';
25
24
  const TAGGED = 'inversify:tagged';
26
- const TAGGED_PROP = 'inversify:tagged_props';
27
25
  const PARAM_TYPES = 'inversify:paramtypes';
28
- const DESIGN_PARAM_TYPES = 'design:paramtypes';
29
- const POST_CONSTRUCT = 'post_construct';
30
- const PRE_DESTROY = 'pre_destroy';
31
- function getNonCustomTagKeys() {
32
- return [INJECT_TAG, MULTI_INJECT_TAG, NAME_TAG, UNMANAGED_TAG, NAMED_TAG, OPTIONAL_TAG];
33
- }
34
- const NON_CUSTOM_TAG_KEYS = getNonCustomTagKeys();
35
-
36
- const DUPLICATED_INJECTABLE_DECORATOR = 'Cannot apply @injectable decorator multiple times.';
37
- const DUPLICATED_METADATA = 'Metadata key was used more than once in a parameter:';
38
- const NULL_ARGUMENT = 'NULL argument';
39
- const KEY_NOT_FOUND = 'Key Not Found';
40
- const AMBIGUOUS_MATCH = 'Ambiguous match found for serviceIdentifier:';
41
- const CANNOT_UNBIND = 'Could not unbind serviceIdentifier:';
42
- const NOT_REGISTERED = 'No matching bindings found for serviceIdentifier:';
43
- const MISSING_INJECTABLE_ANNOTATION = 'Missing required @injectable annotation in:';
44
- const MISSING_INJECT_ANNOTATION = 'Missing required @inject or @multiInject annotation in:';
45
- const UNDEFINED_INJECT_ANNOTATION = (name) => `@inject called with undefined this could mean that the class ${name} has ` +
46
- 'a circular dependency problem. You can use a LazyServiceIdentifer to ' +
47
- 'overcome this limitation.';
48
- const INVALID_BINDING_TYPE = 'Invalid binding type:';
49
- const INVALID_FUNCTION_BINDING = 'Value provided to function binding must be a function!';
50
- const INVALID_TO_SELF_VALUE = 'The toSelf function can only be applied when a constructor is ' + 'used as service identifier';
51
- const INVALID_DECORATOR_OPERATION = 'The @inject @multiInject @tagged and @named decorators ' +
52
- 'must be applied to the parameters of a class constructor or a class property.';
53
- const ARGUMENTS_LENGTH_MISMATCH = (...values) => 'The number of constructor arguments in the derived class ' +
54
- `${values[0]} must be >= than the number of constructor arguments of its base class.`;
55
- const CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = 'Invalid Container constructor argument. Container options ' + 'must be an object.';
56
- const CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = 'Invalid Container option. Default scope must ' + 'be a string ("singleton" or "transient").';
57
- const CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = 'Invalid Container option. Auto bind injectable must ' + 'be a boolean';
58
- const CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = 'Invalid Container option. Skip base check must ' + 'be a boolean';
59
- const MULTIPLE_POST_CONSTRUCT_METHODS = 'Cannot apply @postConstruct decorator multiple times in the same class';
60
- const ASYNC_UNBIND_REQUIRED = 'Attempting to unbind dependency with asynchronous destruction (@preDestroy or onDeactivation)';
61
- const PRE_DESTROY_ERROR = (clazz, errorMessage) => `@preDestroy error in class ${clazz}: ${errorMessage}`;
62
- const ON_DEACTIVATION_ERROR = (clazz, errorMessage) => `onDeactivation() error in class ${clazz}: ${errorMessage}`;
63
26
 
64
27
  class Metadata {
65
28
  constructor(key, value) {
@@ -74,34 +37,9 @@
74
37
  }
75
38
  }
76
39
 
77
- function getFirstArrayDuplicate(array) {
78
- const seenValues = new Set();
79
- for (const entry of array) {
80
- if (seenValues.has(entry)) {
81
- return entry;
82
- }
83
- seenValues.add(entry);
84
- }
85
- return undefined;
86
- }
87
-
88
- let Reflect$1;
89
- var Reflect$2 = (function (Reflect) {
40
+ var Reflect$1 = (function (Reflect) {
90
41
  (function (factory) {
91
- const root = typeof global === 'object'
92
- ? global
93
- : typeof self === 'object'
94
- ? self
95
- : typeof this === 'object'
96
- ? this
97
- : Function('return this;')();
98
- let exporter = makeExporter(Reflect);
99
- if (typeof root.Reflect === 'undefined') {
100
- root.Reflect = Reflect;
101
- }
102
- else {
103
- exporter = makeExporter(root.Reflect, exporter);
104
- }
42
+ const exporter = makeExporter(Reflect);
105
43
  factory(exporter);
106
44
  function makeExporter(target, previous) {
107
45
  return function (key, value) {
@@ -162,9 +100,6 @@
162
100
  if (!IsObject(target)) {
163
101
  throw new TypeError();
164
102
  }
165
- if (!IsUndefined(propertyKey)) {
166
- propertyKey = ToPropertyKey(propertyKey);
167
- }
168
103
  return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
169
104
  }
170
105
  exporter('defineMetadata', defineMetadata);
@@ -666,79 +601,33 @@
666
601
  }
667
602
  });
668
603
  return Reflect;
669
- })(Reflect$1 || (Reflect$1 = {}));
604
+ })({});
670
605
 
671
- function targetIsConstructorFunction(target) {
672
- return target.prototype !== undefined;
673
- }
674
- function _throwIfMethodParameter(parameterName) {
675
- if (parameterName !== undefined) {
676
- throw new Error(INVALID_DECORATOR_OPERATION);
677
- }
678
- }
679
- function tagParameter(annotationTarget, parameterName, parameterIndex, metadata) {
680
- _throwIfMethodParameter(parameterName);
681
- _tagParameterOrProperty(TAGGED, annotationTarget, parameterIndex.toString(), metadata);
682
- }
683
- function tagProperty(annotationTarget, propertyName, metadata) {
684
- if (targetIsConstructorFunction(annotationTarget)) {
685
- throw new Error(INVALID_DECORATOR_OPERATION);
686
- }
687
- _tagParameterOrProperty(TAGGED_PROP, annotationTarget.constructor, propertyName, metadata);
688
- }
689
- function _ensureNoMetadataKeyDuplicates(metadata) {
690
- let metadatas = [];
691
- if (Array.isArray(metadata)) {
692
- metadatas = metadata;
693
- const duplicate = getFirstArrayDuplicate(metadatas.map(md => md.key));
694
- if (duplicate !== undefined) {
695
- throw new Error(`${DUPLICATED_METADATA} ${duplicate.toString()}`);
696
- }
697
- }
698
- else {
699
- metadatas = [metadata];
700
- }
701
- return metadatas;
702
- }
703
606
  function _tagParameterOrProperty(metadataKey, annotationTarget, key, metadata) {
704
- const metadatas = _ensureNoMetadataKeyDuplicates(metadata);
607
+ const metadatas = [metadata];
705
608
  let paramsOrPropertiesMetadata = {};
706
- if (Reflect$2.hasOwnMetadata(metadataKey, annotationTarget)) {
707
- paramsOrPropertiesMetadata = Reflect$2.getMetadata(metadataKey, annotationTarget);
609
+ if (Reflect$1.hasOwnMetadata(metadataKey, annotationTarget)) {
610
+ paramsOrPropertiesMetadata = Reflect$1.getMetadata(metadataKey, annotationTarget);
708
611
  }
709
612
  let paramOrPropertyMetadata = paramsOrPropertiesMetadata[key];
710
613
  if (paramOrPropertyMetadata === undefined) {
711
614
  paramOrPropertyMetadata = [];
712
615
  }
713
- else {
714
- for (const m of paramOrPropertyMetadata) {
715
- if (metadatas.some(md => md.key === m.key)) {
716
- throw new Error(`${DUPLICATED_METADATA} ${m.key.toString()}`);
717
- }
718
- }
719
- }
720
616
  paramOrPropertyMetadata.push(...metadatas);
721
617
  paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata;
722
- Reflect$2.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
618
+ Reflect$1.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget);
619
+ }
620
+ function tagParameter(annotationTarget, parameterName, parameterIndex, metadata) {
621
+ _tagParameterOrProperty(TAGGED, annotationTarget, parameterIndex.toString(), metadata);
723
622
  }
724
623
  function createTaggedDecorator(metadata) {
725
624
  return (target, targetKey, indexOrPropertyDescriptor) => {
726
- if (typeof indexOrPropertyDescriptor === 'number') {
727
- tagParameter(target, targetKey, indexOrPropertyDescriptor, metadata);
728
- }
729
- else {
730
- tagProperty(target, targetKey, metadata);
731
- }
625
+ tagParameter(target, targetKey, indexOrPropertyDescriptor, metadata);
732
626
  };
733
627
  }
734
-
735
628
  function injectBase(metadataKey) {
736
629
  return (serviceIdentifier) => {
737
630
  return (target, targetKey, indexOrPropertyDescriptor) => {
738
- if (serviceIdentifier === undefined) {
739
- const className = typeof target === 'function' ? target.name : target.constructor.name;
740
- throw new Error(UNDEFINED_INJECT_ANNOTATION(className));
741
- }
742
631
  return createTaggedDecorator(new Metadata(metadataKey, serviceIdentifier))(target, targetKey, indexOrPropertyDescriptor);
743
632
  };
744
633
  };
@@ -750,11 +639,7 @@
750
639
 
751
640
  function injectable() {
752
641
  return function (target) {
753
- if (Reflect$2.hasOwnMetadata(PARAM_TYPES, target)) {
754
- throw new Error(DUPLICATED_INJECTABLE_DECORATOR);
755
- }
756
- const types = Reflect$2.getMetadata(DESIGN_PARAM_TYPES, target) || [];
757
- Reflect$2.defineMetadata(PARAM_TYPES, types, target);
642
+ Reflect$1.defineMetadata(PARAM_TYPES, null, target);
758
643
  return target;
759
644
  };
760
645
  }
@@ -763,65 +648,7 @@
763
648
  return createTaggedDecorator(new Metadata(NAMED_TAG, name));
764
649
  }
765
650
 
766
- function _typeof(o) {
767
- "@babel/helpers - typeof";
768
-
769
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
770
- return typeof o;
771
- } : function (o) {
772
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
773
- }, _typeof(o);
774
- }
775
-
776
- function __decorate(decorators, target, key, desc) {
777
- var c = arguments.length,
778
- r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
779
- d;
780
- if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
781
- return c > 3 && r && Object.defineProperty(target, key, r), r;
782
- }
783
- function __param(paramIndex, decorator) {
784
- return function (target, key) {
785
- decorator(target, key, paramIndex);
786
- };
787
- }
788
- function __metadata(metadataKey, metadataValue) {
789
- if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
790
- }
791
- function __awaiter(thisArg, _arguments, P, generator) {
792
- function adopt(value) {
793
- return value instanceof P ? value : new P(function (resolve) {
794
- resolve(value);
795
- });
796
- }
797
- return new (P || (P = Promise))(function (resolve, reject) {
798
- function fulfilled(value) {
799
- try {
800
- step(generator.next(value));
801
- } catch (e) {
802
- reject(e);
803
- }
804
- }
805
- function rejected(value) {
806
- try {
807
- step(generator["throw"](value));
808
- } catch (e) {
809
- reject(e);
810
- }
811
- }
812
- function step(result) {
813
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
814
- }
815
- step((generator = generator.apply(thisArg, _arguments || [])).next());
816
- });
817
- }
818
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
819
- var e = new Error(message);
820
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
821
- };
822
-
823
651
  const BindingScopeEnum = {
824
- Request: 'Request',
825
652
  Singleton: 'Singleton',
826
653
  Transient: 'Transient'
827
654
  };
@@ -835,15 +662,10 @@
835
662
  Invalid: 'Invalid',
836
663
  Provider: 'Provider'
837
664
  };
838
- const TargetTypeEnum = {
839
- ClassProperty: 'ClassProperty',
840
- ConstructorArgument: 'ConstructorArgument',
841
- Variable: 'Variable'
842
- };
843
665
 
844
666
  class Binding {
845
667
  constructor(serviceIdentifier, scope) {
846
- this.id = id();
668
+ this.id = Generator.GenAutoIncrementId();
847
669
  this.activated = false;
848
670
  this.serviceIdentifier = serviceIdentifier;
849
671
  this.scope = scope;
@@ -853,8 +675,6 @@
853
675
  this.cache = null;
854
676
  this.factory = null;
855
677
  this.provider = null;
856
- this.onActivation = null;
857
- this.onDeactivation = null;
858
678
  this.dynamicValue = null;
859
679
  }
860
680
  clone() {
@@ -864,11 +684,8 @@
864
684
  clone.dynamicValue = this.dynamicValue;
865
685
  clone.scope = this.scope;
866
686
  clone.type = this.type;
867
- clone.factory = this.factory;
868
687
  clone.provider = this.provider;
869
688
  clone.constraint = this.constraint;
870
- clone.onActivation = this.onActivation;
871
- clone.onDeactivation = this.onDeactivation;
872
689
  clone.cache = this.cache;
873
690
  return clone;
874
691
  }
@@ -876,791 +693,54 @@
876
693
 
877
694
  class MetadataReader {
878
695
  getConstructorMetadata(constructorFunc) {
879
- const compilerGeneratedMetadata = Reflect$2.getMetadata(PARAM_TYPES, constructorFunc);
880
- const userGeneratedMetadata = Reflect$2.getMetadata(TAGGED, constructorFunc);
696
+ const compilerGeneratedMetadata = Reflect$1.getMetadata(PARAM_TYPES, constructorFunc);
697
+ const userGeneratedMetadata = Reflect$1.getMetadata(TAGGED, constructorFunc);
881
698
  return {
882
699
  compilerGeneratedMetadata,
883
700
  userGeneratedMetadata: userGeneratedMetadata || {}
884
701
  };
885
702
  }
886
703
  getPropertiesMetadata(constructorFunc) {
887
- const userGeneratedMetadata = Reflect$2.getMetadata(TAGGED_PROP, constructorFunc) || [];
888
- return userGeneratedMetadata;
889
- }
890
- }
891
-
892
- const BindingCount = {
893
- MultipleBindingsAvailable: 2,
894
- NoBindingsAvailable: 0,
895
- OnlyOneBindingAvailable: 1
896
- };
897
-
898
- function getServiceIdentifierAsString(serviceIdentifier) {
899
- if (typeof serviceIdentifier === 'function') {
900
- const _serviceIdentifier = serviceIdentifier;
901
- return _serviceIdentifier.name;
902
- }
903
- else if (typeof serviceIdentifier === 'symbol') {
904
- return serviceIdentifier.toString();
905
- }
906
- const _serviceIdentifier = serviceIdentifier;
907
- return _serviceIdentifier;
908
- }
909
- function listRegisteredBindingsForServiceIdentifier(container, serviceIdentifier, getBindings) {
910
- let registeredBindingsList = '';
911
- const registeredBindings = getBindings(container, serviceIdentifier);
912
- if (registeredBindings.length !== 0) {
913
- registeredBindingsList = '\nRegistered bindings:';
914
- registeredBindings.forEach((binding) => {
915
- let name = 'Object';
916
- if (binding.implementationType !== null) {
917
- name = getFunctionName(binding.implementationType);
918
- }
919
- registeredBindingsList = `${registeredBindingsList}\n ${name}`;
920
- if (binding.constraint.metaData) {
921
- registeredBindingsList = `${registeredBindingsList} - ${binding.constraint.metaData}`;
922
- }
923
- });
924
- }
925
- return registeredBindingsList;
926
- }
927
- function listMetadataForTarget(serviceIdentifierString, target) {
928
- if (target.isTagged() || target.isNamed()) {
929
- let m = '';
930
- const namedTag = target.getNamedTag();
931
- const otherTags = target.getCustomTags();
932
- if (namedTag !== null) {
933
- m += namedTag.toString() + '\n';
934
- }
935
- if (otherTags !== null) {
936
- otherTags.forEach(tag => {
937
- m += tag.toString() + '\n';
938
- });
939
- }
940
- return ` ${serviceIdentifierString}\n ${serviceIdentifierString} - ${m}`;
941
- }
942
- return ` ${serviceIdentifierString}`;
943
- }
944
- function getFunctionName(func) {
945
- if (func.name) {
946
- return func.name;
947
- }
948
- const name = func.toString();
949
- const match = name.match(/^function\s*([^\s(]+)/);
950
- return match ? match[1] : `Anonymous function: ${name}`;
951
- }
952
- function getSymbolDescription(symbol) {
953
- return symbol.toString().slice(7, -1);
954
- }
955
-
956
- class Context {
957
- constructor(container) {
958
- this.id = id();
959
- this.container = container;
960
- }
961
- addPlan(plan) {
962
- this.plan = plan;
963
- }
964
- setCurrentRequest(currentRequest) {
965
- this.currentRequest = currentRequest;
966
- }
967
- }
968
-
969
- class Plan {
970
- constructor(parentContext, rootRequest) {
971
- this.parentContext = parentContext;
972
- this.rootRequest = rootRequest;
973
- }
974
- }
975
-
976
- class LazyServiceIdentifer {
977
- constructor(cb) {
978
- this._cb = cb;
979
- }
980
- unwrap() {
981
- return this._cb();
982
- }
983
- }
984
-
985
- class QueryableString {
986
- constructor(str) {
987
- this.str = str;
988
- }
989
- contains(searchString) {
990
- return this.str.indexOf(searchString) !== -1;
991
- }
992
- equals(compareString) {
993
- return this.str === compareString;
994
- }
995
- value() {
996
- return this.str;
704
+ throw new Error('暂未实现');
997
705
  }
998
706
  }
999
707
 
1000
- class Target {
1001
- constructor(type, identifier, serviceIdentifier, namedOrTagged) {
1002
- this.id = id();
1003
- this.type = type;
1004
- this.serviceIdentifier = serviceIdentifier;
1005
- const queryableName = typeof identifier === 'symbol' ? getSymbolDescription(identifier) : identifier;
1006
- this.name = new QueryableString(queryableName || '');
1007
- this.identifier = identifier;
1008
- this.metadata = [];
1009
- let metadataItem = null;
1010
- if (typeof namedOrTagged === 'string') {
1011
- metadataItem = new Metadata(NAMED_TAG, namedOrTagged);
1012
- }
1013
- else if (namedOrTagged instanceof Metadata) {
1014
- metadataItem = namedOrTagged;
1015
- }
1016
- if (metadataItem !== null) {
1017
- this.metadata.push(metadataItem);
708
+ const taggedConstraint = (key) => (value) => {
709
+ const constraint = (request) => {
710
+ if (request == null || request.constructorArgsMetadata == null) {
711
+ return false;
1018
712
  }
1019
- }
1020
- hasTag(key) {
1021
- for (const m of this.metadata) {
1022
- if (m.key === key) {
713
+ const constructorArgsMetadata = request.constructorArgsMetadata;
714
+ for (let i = 0; i < constructorArgsMetadata.length; i++) {
715
+ if (constructorArgsMetadata[i].key === key && constructorArgsMetadata[i].value === value) {
1023
716
  return true;
1024
717
  }
1025
718
  }
1026
719
  return false;
1027
- }
1028
- isArray() {
1029
- return this.hasTag(MULTI_INJECT_TAG);
1030
- }
1031
- matchesArray(name) {
1032
- return this.matchesTag(MULTI_INJECT_TAG)(name);
1033
- }
1034
- isNamed() {
1035
- return this.hasTag(NAMED_TAG);
1036
- }
1037
- isTagged() {
1038
- return this.metadata.some(metadata => NON_CUSTOM_TAG_KEYS.every(key => metadata.key !== key));
1039
- }
1040
- isOptional() {
1041
- return this.matchesTag(OPTIONAL_TAG)(true);
1042
- }
1043
- getNamedTag() {
1044
- if (this.isNamed()) {
1045
- return this.metadata.filter(m => m.key === NAMED_TAG)[0];
1046
- }
1047
- return null;
1048
- }
1049
- getCustomTags() {
1050
- if (this.isTagged()) {
1051
- return this.metadata.filter(metadata => NON_CUSTOM_TAG_KEYS.every(key => metadata.key !== key));
1052
- }
1053
- return null;
1054
- }
1055
- matchesNamedTag(name) {
1056
- return this.matchesTag(NAMED_TAG)(name);
1057
- }
1058
- matchesTag(key) {
1059
- return (value) => {
1060
- for (const m of this.metadata) {
1061
- if (m.key === key && m.value === value) {
1062
- return true;
1063
- }
1064
- }
1065
- return false;
1066
- };
1067
- }
1068
- }
1069
-
1070
- function getDependencies(metadataReader, func) {
1071
- const constructorName = getFunctionName(func);
1072
- return getTargets(metadataReader, constructorName, func, false);
1073
- }
1074
- function getTargets(metadataReader, constructorName, func, isBaseClass) {
1075
- const metadata = metadataReader.getConstructorMetadata(func);
1076
- const serviceIdentifiers = metadata.compilerGeneratedMetadata;
1077
- if (serviceIdentifiers === undefined) {
1078
- const msg = `${MISSING_INJECTABLE_ANNOTATION} ${constructorName}.`;
1079
- throw new Error(msg);
1080
- }
1081
- const constructorArgsMetadata = metadata.userGeneratedMetadata;
1082
- const keys = Object.keys(constructorArgsMetadata);
1083
- const hasUserDeclaredUnknownInjections = func.length === 0 && keys.length > 0;
1084
- const hasOptionalParameters = keys.length > func.length;
1085
- const iterations = hasUserDeclaredUnknownInjections || hasOptionalParameters ? keys.length : func.length;
1086
- const constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations);
1087
- const propertyTargets = getClassPropsAsTargets(metadataReader, func, constructorName);
1088
- const targets = [...constructorTargets, ...propertyTargets];
1089
- return targets;
1090
- }
1091
- function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) {
1092
- const targetMetadata = constructorArgsMetadata[index.toString()] || [];
1093
- const metadata = formatTargetMetadata(targetMetadata);
1094
- const isManaged = metadata.unmanaged !== true;
1095
- let serviceIdentifier = serviceIdentifiers[index];
1096
- const injectIdentifier = metadata.inject || metadata.multiInject;
1097
- serviceIdentifier = (injectIdentifier ? injectIdentifier : serviceIdentifier);
1098
- if (serviceIdentifier instanceof LazyServiceIdentifer) {
1099
- serviceIdentifier = serviceIdentifier.unwrap();
1100
- }
1101
- if (isManaged) {
1102
- const isObject = serviceIdentifier === Object;
1103
- const isFunction = serviceIdentifier === Function;
1104
- const isUndefined = serviceIdentifier === undefined;
1105
- const isUnknownType = isObject || isFunction || isUndefined;
1106
- if (!isBaseClass && isUnknownType) {
1107
- const msg = `${MISSING_INJECT_ANNOTATION} argument ${index} in class ${constructorName}.`;
1108
- throw new Error(msg);
1109
- }
1110
- const target = new Target(TargetTypeEnum.ConstructorArgument, metadata.targetName, serviceIdentifier);
1111
- target.metadata = targetMetadata;
1112
- return target;
1113
- }
1114
- return null;
1115
- }
1116
- function getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations) {
1117
- const targets = [];
1118
- for (let i = 0; i < iterations; i++) {
1119
- const index = i;
1120
- const target = getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata);
1121
- if (target !== null) {
1122
- targets.push(target);
1123
- }
1124
- }
1125
- return targets;
1126
- }
1127
- function _getServiceIdentifierForProperty(inject, multiInject, propertyName, className) {
1128
- const serviceIdentifier = inject || multiInject;
1129
- if (serviceIdentifier === undefined) {
1130
- const msg = `${MISSING_INJECTABLE_ANNOTATION} for property ${String(propertyName)} in class ${className}.`;
1131
- throw new Error(msg);
1132
- }
1133
- return serviceIdentifier;
1134
- }
1135
- function getClassPropsAsTargets(metadataReader, constructorFunc, constructorName) {
1136
- const classPropsMetadata = metadataReader.getPropertiesMetadata(constructorFunc);
1137
- let targets = [];
1138
- const symbolKeys = Object.getOwnPropertySymbols(classPropsMetadata);
1139
- const stringKeys = Object.keys(classPropsMetadata);
1140
- const keys = stringKeys.concat(symbolKeys);
1141
- for (const key of keys) {
1142
- const targetMetadata = classPropsMetadata[key];
1143
- const metadata = formatTargetMetadata(targetMetadata);
1144
- const identifier = metadata.targetName || key;
1145
- const serviceIdentifier = _getServiceIdentifierForProperty(metadata.inject, metadata.multiInject, key, constructorName);
1146
- const target = new Target(TargetTypeEnum.ClassProperty, identifier, serviceIdentifier);
1147
- target.metadata = targetMetadata;
1148
- targets.push(target);
1149
- }
1150
- const baseConstructor = Object.getPrototypeOf(constructorFunc.prototype).constructor;
1151
- if (baseConstructor !== Object) {
1152
- const baseTargets = getClassPropsAsTargets(metadataReader, baseConstructor, constructorName);
1153
- targets = [...targets, ...baseTargets];
1154
- }
1155
- return targets;
1156
- }
1157
- function getBaseClassDependencyCount(metadataReader, func) {
1158
- const baseConstructor = Object.getPrototypeOf(func.prototype).constructor;
1159
- if (baseConstructor !== Object) {
1160
- const baseConstructorName = getFunctionName(baseConstructor);
1161
- const targets = getTargets(metadataReader, baseConstructorName, baseConstructor, true);
1162
- const metadata = targets.map(t => t.metadata.filter(m => m.key === UNMANAGED_TAG));
1163
- const unmanagedCount = [].concat.apply([], metadata).length;
1164
- const dependencyCount = targets.length - unmanagedCount;
1165
- if (dependencyCount > 0) {
1166
- return dependencyCount;
1167
- }
1168
- return getBaseClassDependencyCount(metadataReader, baseConstructor);
1169
- }
1170
- return 0;
1171
- }
1172
- function formatTargetMetadata(targetMetadata) {
1173
- const targetMetadataMap = {};
1174
- targetMetadata.forEach((m) => {
1175
- targetMetadataMap[m.key.toString()] = m.value;
1176
- });
1177
- return {
1178
- inject: targetMetadataMap[INJECT_TAG],
1179
- multiInject: targetMetadataMap[MULTI_INJECT_TAG],
1180
- targetName: targetMetadataMap[NAME_TAG],
1181
- unmanaged: targetMetadataMap[UNMANAGED_TAG]
1182
720
  };
1183
- }
1184
-
1185
- class Request {
1186
- constructor(serviceIdentifier, parentContext, parentRequest, bindings, target) {
1187
- this.id = id();
1188
- this.serviceIdentifier = serviceIdentifier;
1189
- this.parentContext = parentContext;
1190
- this.parentRequest = parentRequest;
1191
- this.target = target;
1192
- this.childRequests = [];
1193
- this.bindings = Array.isArray(bindings) ? bindings : [bindings];
1194
- this.requestScope = parentRequest === null ? new Map() : null;
1195
- }
1196
- addChildRequest(serviceIdentifier, bindings, target) {
1197
- const child = new Request(serviceIdentifier, this.parentContext, this, bindings, target);
1198
- this.childRequests.push(child);
1199
- return child;
1200
- }
1201
- }
1202
-
1203
- function getBindingDictionary(cntnr) {
1204
- return cntnr
1205
- ._bindingDictionary;
1206
- }
1207
- function _createTarget(isMultiInject, targetType, serviceIdentifier, name, key, value) {
1208
- const metadataKey = isMultiInject ? MULTI_INJECT_TAG : INJECT_TAG;
1209
- const injectMetadata = new Metadata(metadataKey, serviceIdentifier);
1210
- const target = new Target(targetType, name, serviceIdentifier, injectMetadata);
1211
- if (key !== undefined) {
1212
- const tagMetadata = new Metadata(key, value);
1213
- target.metadata.push(tagMetadata);
1214
- }
1215
- return target;
1216
- }
1217
- function _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target) {
1218
- let bindings = getBindings(context.container, target.serviceIdentifier);
1219
- let activeBindings = [];
1220
- if (bindings.length === BindingCount.NoBindingsAvailable &&
1221
- context.container.options.autoBindInjectable &&
1222
- typeof target.serviceIdentifier === 'function' &&
1223
- metadataReader.getConstructorMetadata(target.serviceIdentifier).compilerGeneratedMetadata) {
1224
- context.container.bind(target.serviceIdentifier).toSelf();
1225
- bindings = getBindings(context.container, target.serviceIdentifier);
1226
- }
1227
- if (!avoidConstraints) {
1228
- activeBindings = bindings.filter(binding => {
1229
- const request = new Request(binding.serviceIdentifier, context, parentRequest, binding, target);
1230
- return binding.constraint(request);
1231
- });
1232
- }
1233
- else {
1234
- activeBindings = bindings;
1235
- }
1236
- _validateActiveBindingCount(target.serviceIdentifier, activeBindings, target, context.container);
1237
- return activeBindings;
1238
- }
1239
- function _validateActiveBindingCount(serviceIdentifier, bindings, target, container) {
1240
- switch (bindings.length) {
1241
- case BindingCount.NoBindingsAvailable:
1242
- if (target.isOptional()) {
1243
- return bindings;
1244
- }
1245
- const serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
1246
- let msg = NOT_REGISTERED;
1247
- msg += listMetadataForTarget(serviceIdentifierString, target);
1248
- msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
1249
- throw new Error(msg);
1250
- case BindingCount.OnlyOneBindingAvailable:
1251
- return bindings;
1252
- case BindingCount.MultipleBindingsAvailable:
1253
- default:
1254
- if (!target.isArray()) {
1255
- const serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
1256
- let msg = `${AMBIGUOUS_MATCH} ${serviceIdentifierString}`;
1257
- msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
1258
- throw new Error(msg);
1259
- }
1260
- else {
1261
- return bindings;
1262
- }
1263
- }
1264
- }
1265
- function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, parentRequest, target) {
1266
- let activeBindings;
1267
- let childRequest;
1268
- if (parentRequest === null) {
1269
- activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, null, target);
1270
- childRequest = new Request(serviceIdentifier, context, null, activeBindings, target);
1271
- const thePlan = new Plan(context, childRequest);
1272
- context.addPlan(thePlan);
1273
- }
1274
- else {
1275
- activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target);
1276
- childRequest = parentRequest.addChildRequest(target.serviceIdentifier, activeBindings, target);
1277
- }
1278
- activeBindings.forEach(binding => {
1279
- let subChildRequest = null;
1280
- if (target.isArray()) {
1281
- subChildRequest = childRequest.addChildRequest(binding.serviceIdentifier, binding, target);
1282
- }
1283
- else {
1284
- if (binding.cache) {
1285
- return;
1286
- }
1287
- subChildRequest = childRequest;
1288
- }
1289
- if (binding.type === BindingTypeEnum.Instance && binding.implementationType !== null) {
1290
- const dependencies = getDependencies(metadataReader, binding.implementationType);
1291
- if (!context.container.options.skipBaseClassChecks) {
1292
- const baseClassDependencyCount = getBaseClassDependencyCount(metadataReader, binding.implementationType);
1293
- if (dependencies.length < baseClassDependencyCount) {
1294
- const error = ARGUMENTS_LENGTH_MISMATCH(getFunctionName(binding.implementationType));
1295
- throw new Error(error);
1296
- }
1297
- }
1298
- dependencies.forEach((dependency) => {
1299
- _createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency);
1300
- });
1301
- }
1302
- });
1303
- }
1304
- function getBindings(container, serviceIdentifier) {
1305
- let bindings = [];
1306
- const bindingDictionary = getBindingDictionary(container);
1307
- if (bindingDictionary.hasKey(serviceIdentifier)) {
1308
- bindings = bindingDictionary.get(serviceIdentifier);
1309
- }
1310
- else if (container.parent !== null) {
1311
- bindings = getBindings(container.parent, serviceIdentifier);
1312
- }
1313
- return bindings;
1314
- }
1315
- function plan(metadataReader, container, isMultiInject, targetType, serviceIdentifier, key, value, avoidConstraints = false) {
1316
- const context = new Context(container);
1317
- const target = _createTarget(isMultiInject, targetType, serviceIdentifier, '', key, value);
1318
- _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, null, target);
1319
- return context;
1320
- }
1321
- function createMockRequest(container, serviceIdentifier, key, value) {
1322
- const target = new Target(TargetTypeEnum.Variable, '', serviceIdentifier, new Metadata(key, value));
1323
- const context = new Context(container);
1324
- const request = new Request(serviceIdentifier, context, null, [], target);
1325
- return request;
1326
- }
1327
-
1328
- function isPromise(object) {
1329
- const isObjectOrFunction = (typeof object === 'object' && object !== null) || typeof object === 'function';
1330
- return isObjectOrFunction && typeof object.then === 'function';
1331
- }
1332
- function isPromiseOrContainsPromise(object) {
1333
- if (isPromise(object)) {
1334
- return true;
1335
- }
1336
- return Array.isArray(object) && object.some(isPromise);
1337
- }
1338
-
1339
- const tryGetFromScope = (requestScope, binding) => {
1340
- if (binding.scope === BindingScopeEnum.Singleton && binding.activated) {
1341
- return binding.cache;
1342
- }
1343
- if (binding.scope === BindingScopeEnum.Request && requestScope.has(binding.id)) {
1344
- return requestScope.get(binding.id);
1345
- }
1346
- return null;
1347
- };
1348
- const saveToScope = (requestScope, binding, result) => {
1349
- if (binding.scope === BindingScopeEnum.Singleton) {
1350
- _saveToSingletonScope(binding, result);
1351
- }
1352
- if (binding.scope === BindingScopeEnum.Request) {
1353
- _saveToRequestScope(requestScope, binding, result);
1354
- }
1355
- };
1356
- const _saveToRequestScope = (requestScope, binding, result) => {
1357
- if (!requestScope.has(binding.id)) {
1358
- requestScope.set(binding.id, result);
1359
- }
1360
- };
1361
- const _saveToSingletonScope = (binding, result) => {
1362
- binding.cache = result;
1363
- binding.activated = true;
1364
- if (isPromise(result)) {
1365
- void _saveAsyncResultToSingletonScope(binding, result);
1366
- }
1367
- };
1368
- const _saveAsyncResultToSingletonScope = (binding, asyncResult) => __awaiter(void 0, void 0, void 0, function* () {
1369
- try {
1370
- const result = yield asyncResult;
1371
- binding.cache = result;
1372
- }
1373
- catch (ex) {
1374
- binding.cache = null;
1375
- binding.activated = false;
1376
- throw ex;
1377
- }
1378
- });
1379
-
1380
- var FactoryType;
1381
- (function (FactoryType) {
1382
- FactoryType["DynamicValue"] = "toDynamicValue";
1383
- FactoryType["Factory"] = "toFactory";
1384
- FactoryType["Provider"] = "toProvider";
1385
- })(FactoryType || (FactoryType = {}));
1386
-
1387
- const ensureFullyBound = (binding) => {
1388
- let boundValue = null;
1389
- switch (binding.type) {
1390
- case BindingTypeEnum.ConstantValue:
1391
- case BindingTypeEnum.Function:
1392
- boundValue = binding.cache;
1393
- break;
1394
- case BindingTypeEnum.Constructor:
1395
- case BindingTypeEnum.Instance:
1396
- boundValue = binding.implementationType;
1397
- break;
1398
- case BindingTypeEnum.DynamicValue:
1399
- boundValue = binding.dynamicValue;
1400
- break;
1401
- case BindingTypeEnum.Provider:
1402
- boundValue = binding.provider;
1403
- break;
1404
- case BindingTypeEnum.Factory:
1405
- boundValue = binding.factory;
1406
- break;
1407
- }
1408
- if (boundValue === null) {
1409
- const serviceIdentifierAsString = getServiceIdentifierAsString(binding.serviceIdentifier);
1410
- throw new Error(`${INVALID_BINDING_TYPE} ${serviceIdentifierAsString}`);
1411
- }
1412
- };
1413
- const getFactoryDetails = (binding) => {
1414
- switch (binding.type) {
1415
- case BindingTypeEnum.Factory:
1416
- return { factory: binding.factory, factoryType: FactoryType.Factory };
1417
- case BindingTypeEnum.Provider:
1418
- return { factory: binding.provider, factoryType: FactoryType.Provider };
1419
- case BindingTypeEnum.DynamicValue:
1420
- return { factory: binding.dynamicValue, factoryType: FactoryType.DynamicValue };
1421
- default:
1422
- throw new Error(`Unexpected factory type ${binding.type}`);
1423
- }
1424
- };
1425
-
1426
- const tryAndThrowErrorIfStackOverflow = (fn, errorCallback) => {
1427
- return fn();
1428
- };
1429
-
1430
- function _resolveRequests(childRequests, resolveRequest) {
1431
- return childRequests.reduce((resolvedRequests, childRequest) => {
1432
- const injection = resolveRequest(childRequest);
1433
- const targetType = childRequest.target.type;
1434
- if (targetType === TargetTypeEnum.ConstructorArgument) {
1435
- resolvedRequests.constructorInjections.push(injection);
1436
- }
1437
- else {
1438
- resolvedRequests.propertyRequests.push(childRequest);
1439
- resolvedRequests.propertyInjections.push(injection);
1440
- }
1441
- if (!resolvedRequests.isAsync) {
1442
- resolvedRequests.isAsync = isPromiseOrContainsPromise(injection);
1443
- }
1444
- return resolvedRequests;
1445
- }, { constructorInjections: [], propertyInjections: [], propertyRequests: [], isAsync: false });
1446
- }
1447
- function _createInstance(constr, childRequests, resolveRequest) {
1448
- let result;
1449
- if (childRequests.length > 0) {
1450
- const resolved = _resolveRequests(childRequests, resolveRequest);
1451
- const createInstanceWithInjectionsArg = Object.assign(Object.assign({}, resolved), { constr });
1452
- if (resolved.isAsync) {
1453
- result = createInstanceWithInjectionsAsync(createInstanceWithInjectionsArg);
1454
- }
1455
- else {
1456
- result = createInstanceWithInjections(createInstanceWithInjectionsArg);
1457
- }
1458
- }
1459
- else {
1460
- result = new constr();
1461
- }
1462
- return result;
1463
- }
1464
- function createInstanceWithInjections(args) {
1465
- const instance = new args.constr(...args.constructorInjections);
1466
- args.propertyRequests.forEach((r, index) => {
1467
- const property = r.target.identifier;
1468
- const injection = args.propertyInjections[index];
1469
- instance[property] = injection;
1470
- });
1471
- return instance;
1472
- }
1473
- function createInstanceWithInjectionsAsync(args) {
1474
- return __awaiter(this, void 0, void 0, function* () {
1475
- const constructorInjections = yield possiblyWaitInjections(args.constructorInjections);
1476
- const propertyInjections = yield possiblyWaitInjections(args.propertyInjections);
1477
- return createInstanceWithInjections(Object.assign(Object.assign({}, args), { constructorInjections, propertyInjections }));
1478
- });
1479
- }
1480
- function possiblyWaitInjections(possiblePromiseinjections) {
1481
- return __awaiter(this, void 0, void 0, function* () {
1482
- const injections = [];
1483
- for (const injection of possiblePromiseinjections) {
1484
- if (Array.isArray(injection)) {
1485
- injections.push(Promise.all(injection));
1486
- }
1487
- else {
1488
- injections.push(injection);
1489
- }
1490
- }
1491
- return Promise.all(injections);
1492
- });
1493
- }
1494
- function _getInstanceAfterPostConstruct(constr, result) {
1495
- const postConstructResult = _postConstruct(constr, result);
1496
- if (isPromise(postConstructResult)) {
1497
- return postConstructResult.then(() => result);
1498
- }
1499
- return result;
1500
- }
1501
- function _postConstruct(constr, instance) {
1502
- var _a, _b;
1503
- if (Reflect$2.hasMetadata(POST_CONSTRUCT, constr)) {
1504
- const data = Reflect$2.getMetadata(POST_CONSTRUCT, constr);
1505
- return (_b = (_a = instance)[data.value]) === null || _b === void 0 ? void 0 : _b.call(_a);
1506
- }
1507
- }
1508
- function _validateInstanceResolution(binding, constr) {
1509
- if (binding.scope !== BindingScopeEnum.Singleton) {
1510
- _throwIfHandlingDeactivation(binding, constr);
1511
- }
1512
- }
1513
- function _throwIfHandlingDeactivation(binding, constr) {
1514
- const scopeErrorMessage = `Class cannot be instantiated in ${binding.scope === BindingScopeEnum.Request ? 'request' : 'transient'} scope.`;
1515
- if (typeof binding.onDeactivation === 'function') {
1516
- throw new Error(ON_DEACTIVATION_ERROR(constr.name, scopeErrorMessage));
1517
- }
1518
- if (Reflect$2.hasMetadata(PRE_DESTROY, constr)) {
1519
- throw new Error(PRE_DESTROY_ERROR(constr.name, scopeErrorMessage));
1520
- }
1521
- }
1522
- function resolveInstance(binding, constr, childRequests, resolveRequest) {
1523
- _validateInstanceResolution(binding, constr);
1524
- const result = _createInstance(constr, childRequests, resolveRequest);
1525
- if (isPromise(result)) {
1526
- return result.then(resolvedResult => _getInstanceAfterPostConstruct(constr, resolvedResult));
1527
- }
1528
- return _getInstanceAfterPostConstruct(constr, result);
1529
- }
1530
-
1531
- const _resolveRequest = (requestScope) => (request) => {
1532
- request.parentContext.setCurrentRequest(request);
1533
- const bindings = request.bindings;
1534
- const childRequests = request.childRequests;
1535
- const targetIsAnArray = request.target && request.target.isArray();
1536
- const targetParentIsNotAnArray = !request.parentRequest ||
1537
- !request.parentRequest.target ||
1538
- !request.target ||
1539
- !request.parentRequest.target.matchesArray(request.target.serviceIdentifier);
1540
- if (targetIsAnArray && targetParentIsNotAnArray) {
1541
- return childRequests.map((childRequest) => {
1542
- const _f = _resolveRequest(requestScope);
1543
- return _f(childRequest);
1544
- });
1545
- }
1546
- if (request.target.isOptional() && bindings.length === 0) {
1547
- return undefined;
1548
- }
1549
- const binding = bindings[0];
1550
- return _resolveBinding(requestScope, request, binding);
1551
- };
1552
- const _resolveFactoryFromBinding = (binding, context) => {
1553
- const factoryDetails = getFactoryDetails(binding);
1554
- return tryAndThrowErrorIfStackOverflow(() => factoryDetails.factory.bind(binding)(context));
1555
- };
1556
- const _getResolvedFromBinding = (requestScope, request, binding) => {
1557
- let result;
1558
- const childRequests = request.childRequests;
1559
- ensureFullyBound(binding);
1560
- switch (binding.type) {
1561
- case BindingTypeEnum.ConstantValue:
1562
- case BindingTypeEnum.Function:
1563
- result = binding.cache;
1564
- break;
1565
- case BindingTypeEnum.Constructor:
1566
- result = binding.implementationType;
1567
- break;
1568
- case BindingTypeEnum.Instance:
1569
- result = resolveInstance(binding, binding.implementationType, childRequests, _resolveRequest(requestScope));
1570
- break;
1571
- default:
1572
- result = _resolveFactoryFromBinding(binding, request.parentContext);
1573
- }
1574
- return result;
1575
- };
1576
- const _resolveInScope = (requestScope, binding, resolveFromBinding) => {
1577
- let result = tryGetFromScope(requestScope, binding);
1578
- if (result !== null) {
1579
- return result;
1580
- }
1581
- result = resolveFromBinding();
1582
- saveToScope(requestScope, binding, result);
1583
- return result;
1584
- };
1585
- const _resolveBinding = (requestScope, request, binding) => {
1586
- return _resolveInScope(requestScope, binding, () => {
1587
- const result = _getResolvedFromBinding(requestScope, request, binding);
1588
- return result;
1589
- });
1590
- };
1591
- function resolve(context) {
1592
- const _f = _resolveRequest(context.plan.rootRequest.requestScope);
1593
- return _f(context.plan.rootRequest);
1594
- }
1595
-
1596
- class BindingOnSyntax {
1597
- constructor(binding) {
1598
- this._binding = binding;
1599
- }
1600
- }
1601
-
1602
- const taggedConstraint = (key) => (value) => {
1603
- const constraint = (request) => request !== null && request.target !== null && request.target.matchesTag(key)(value);
1604
721
  constraint.metaData = new Metadata(key, value);
1605
722
  return constraint;
1606
723
  };
1607
724
  const namedConstraint = taggedConstraint(NAMED_TAG);
1608
725
 
1609
- class BindingWhenSyntax {
1610
- constructor(binding) {
1611
- this._binding = binding;
1612
- }
1613
- whenTargetNamed(name) {
1614
- this._binding.constraint = namedConstraint(name);
1615
- return new BindingOnSyntax(this._binding);
1616
- }
1617
- }
1618
-
1619
- class BindingWhenOnSyntax {
1620
- constructor(binding) {
1621
- this._binding = binding;
1622
- this._bindingWhenSyntax = new BindingWhenSyntax(this._binding);
1623
- }
1624
- whenTargetNamed(name) {
1625
- return this._bindingWhenSyntax.whenTargetNamed(name);
1626
- }
1627
- }
1628
-
1629
726
  class BindingInSyntax {
1630
727
  constructor(binding) {
1631
728
  this._binding = binding;
1632
729
  }
1633
730
  inRequestScope() {
1634
- this._binding.scope = BindingScopeEnum.Request;
1635
- return new BindingWhenOnSyntax(this._binding);
731
+ throw new Error('暂未实现');
1636
732
  }
1637
733
  inSingletonScope() {
1638
734
  this._binding.scope = BindingScopeEnum.Singleton;
1639
- return new BindingWhenOnSyntax(this._binding);
735
+ return this;
1640
736
  }
1641
737
  inTransientScope() {
1642
738
  this._binding.scope = BindingScopeEnum.Transient;
1643
- return new BindingWhenOnSyntax(this._binding);
1644
- }
1645
- }
1646
-
1647
- class BindingInWhenOnSyntax {
1648
- constructor(binding) {
1649
- this._binding = binding;
1650
- this._bindingWhenSyntax = new BindingWhenSyntax(this._binding);
1651
- this._bindingInSyntax = new BindingInSyntax(binding);
1652
- }
1653
- inRequestScope() {
1654
- return this._bindingInSyntax.inRequestScope();
1655
- }
1656
- inSingletonScope() {
1657
- return this._bindingInSyntax.inSingletonScope();
1658
- }
1659
- inTransientScope() {
1660
- return this._bindingInSyntax.inTransientScope();
739
+ return this;
1661
740
  }
1662
741
  whenTargetNamed(name) {
1663
- return this._bindingWhenSyntax.whenTargetNamed(name);
742
+ this._binding.constraint = namedConstraint(name);
743
+ return this;
1664
744
  }
1665
745
  }
1666
746
 
@@ -1671,374 +751,84 @@
1671
751
  to(constructor) {
1672
752
  this._binding.type = BindingTypeEnum.Instance;
1673
753
  this._binding.implementationType = constructor;
1674
- return new BindingInWhenOnSyntax(this._binding);
754
+ return new BindingInSyntax(this._binding);
1675
755
  }
1676
756
  toSelf() {
1677
- if (typeof this._binding.serviceIdentifier !== 'function') {
1678
- throw new Error(`${INVALID_TO_SELF_VALUE}`);
1679
- }
1680
757
  const self = this._binding.serviceIdentifier;
1681
758
  return this.to(self);
1682
759
  }
1683
- toConstantValue(value) {
1684
- this._binding.type = BindingTypeEnum.ConstantValue;
1685
- this._binding.cache = value;
1686
- this._binding.dynamicValue = null;
1687
- this._binding.implementationType = null;
1688
- this._binding.scope = BindingScopeEnum.Singleton;
1689
- return new BindingWhenOnSyntax(this._binding);
1690
- }
1691
760
  toDynamicValue(func) {
1692
761
  this._binding.type = BindingTypeEnum.DynamicValue;
1693
762
  this._binding.cache = null;
1694
763
  this._binding.dynamicValue = func;
1695
764
  this._binding.implementationType = null;
1696
- return new BindingInWhenOnSyntax(this._binding);
1697
- }
1698
- toConstructor(constructor) {
1699
- this._binding.type = BindingTypeEnum.Constructor;
1700
- this._binding.implementationType = constructor;
1701
- this._binding.scope = BindingScopeEnum.Singleton;
1702
- return new BindingWhenOnSyntax(this._binding);
1703
- }
1704
- toFactory(factory) {
1705
- this._binding.type = BindingTypeEnum.Factory;
1706
- this._binding.factory = factory;
1707
- this._binding.scope = BindingScopeEnum.Singleton;
1708
- return new BindingWhenOnSyntax(this._binding);
1709
- }
1710
- toFunction(func) {
1711
- if (typeof func !== 'function') {
1712
- throw new Error(INVALID_FUNCTION_BINDING);
1713
- }
1714
- const bindingWhenOnSyntax = this.toConstantValue(func);
1715
- this._binding.type = BindingTypeEnum.Function;
1716
- this._binding.scope = BindingScopeEnum.Singleton;
1717
- return bindingWhenOnSyntax;
1718
- }
1719
- toAutoFactory(serviceIdentifier) {
1720
- this._binding.type = BindingTypeEnum.Factory;
1721
- this._binding.factory = context => {
1722
- const autofactory = () => context.container.get(serviceIdentifier);
1723
- return autofactory;
1724
- };
1725
- this._binding.scope = BindingScopeEnum.Singleton;
1726
- return new BindingWhenOnSyntax(this._binding);
1727
- }
1728
- toAutoNamedFactory(serviceIdentifier) {
1729
- this._binding.type = BindingTypeEnum.Factory;
1730
- this._binding.factory = context => {
1731
- return (named) => context.container.getNamed(serviceIdentifier, named);
1732
- };
1733
- return new BindingWhenOnSyntax(this._binding);
1734
- }
1735
- toProvider(provider) {
1736
- this._binding.type = BindingTypeEnum.Provider;
1737
- this._binding.provider = provider;
1738
- this._binding.scope = BindingScopeEnum.Singleton;
1739
- return new BindingWhenOnSyntax(this._binding);
1740
- }
1741
- toService(service) {
1742
- this.toDynamicValue(context => context.container.get(service));
1743
- }
1744
- }
1745
-
1746
- function isClonable(obj) {
1747
- return (typeof obj === 'object' &&
1748
- obj !== null &&
1749
- 'clone' in obj &&
1750
- typeof obj.clone === 'function');
1751
- }
1752
-
1753
- class Lookup {
1754
- constructor() {
1755
- this._map = new Map();
1756
- }
1757
- getMap() {
1758
- return this._map;
1759
- }
1760
- add(serviceIdentifier, value) {
1761
- if (serviceIdentifier === null || serviceIdentifier === undefined) {
1762
- throw new Error(NULL_ARGUMENT);
1763
- }
1764
- if (value === null || value === undefined) {
1765
- throw new Error(NULL_ARGUMENT);
1766
- }
1767
- const entry = this._map.get(serviceIdentifier);
1768
- if (entry !== undefined) {
1769
- entry.push(value);
1770
- }
1771
- else {
1772
- this._map.set(serviceIdentifier, [value]);
1773
- }
1774
- }
1775
- get(serviceIdentifier) {
1776
- if (serviceIdentifier === null || serviceIdentifier === undefined) {
1777
- throw new Error(NULL_ARGUMENT);
1778
- }
1779
- const entry = this._map.get(serviceIdentifier);
1780
- if (entry !== undefined) {
1781
- return entry;
1782
- }
1783
- throw new Error(KEY_NOT_FOUND);
1784
- }
1785
- remove(serviceIdentifier) {
1786
- if (serviceIdentifier === null || serviceIdentifier === undefined) {
1787
- throw new Error(NULL_ARGUMENT);
1788
- }
1789
- if (!this._map.delete(serviceIdentifier)) {
1790
- throw new Error(KEY_NOT_FOUND);
1791
- }
1792
- }
1793
- removeIntersection(lookup) {
1794
- this.traverse((serviceIdentifier, value) => {
1795
- const lookupActivations = lookup.hasKey(serviceIdentifier) ? lookup.get(serviceIdentifier) : undefined;
1796
- if (lookupActivations !== undefined) {
1797
- const filteredValues = value.filter(lookupValue => !lookupActivations.some(moduleActivation => lookupValue === moduleActivation));
1798
- this._setValue(serviceIdentifier, filteredValues);
1799
- }
1800
- });
1801
- }
1802
- removeByCondition(condition) {
1803
- const removals = [];
1804
- this._map.forEach((entries, key) => {
1805
- const updatedEntries = [];
1806
- for (const entry of entries) {
1807
- const remove = condition(entry);
1808
- if (remove) {
1809
- removals.push(entry);
1810
- }
1811
- else {
1812
- updatedEntries.push(entry);
1813
- }
1814
- }
1815
- this._setValue(key, updatedEntries);
1816
- });
1817
- return removals;
1818
- }
1819
- hasKey(serviceIdentifier) {
1820
- if (serviceIdentifier === null || serviceIdentifier === undefined) {
1821
- throw new Error(NULL_ARGUMENT);
1822
- }
1823
- return this._map.has(serviceIdentifier);
1824
- }
1825
- clone() {
1826
- const copy = new Lookup();
1827
- this._map.forEach((value, key) => {
1828
- value.forEach(b => copy.add(key, isClonable(b) ? b.clone() : b));
1829
- });
1830
- return copy;
1831
- }
1832
- traverse(func) {
1833
- this._map.forEach((value, key) => {
1834
- func(key, value);
1835
- });
1836
- }
1837
- _setValue(serviceIdentifier, value) {
1838
- if (value.length > 0) {
1839
- this._map.set(serviceIdentifier, value);
1840
- }
1841
- else {
1842
- this._map.delete(serviceIdentifier);
1843
- }
1844
- }
1845
- }
1846
-
1847
- class Container {
1848
- static merge(container1, container2, ...containers) {
1849
- const container = new Container();
1850
- const targetContainers = [
1851
- container1,
1852
- container2,
1853
- ...containers
1854
- ].map(targetContainer => getBindingDictionary(targetContainer));
1855
- const bindingDictionary = getBindingDictionary(container);
1856
- function copyDictionary(origin, destination) {
1857
- origin.traverse((_key, value) => {
1858
- value.forEach(binding => {
1859
- destination.add(binding.serviceIdentifier, binding.clone());
1860
- });
1861
- });
1862
- }
1863
- targetContainers.forEach(targetBindingDictionary => {
1864
- copyDictionary(targetBindingDictionary, bindingDictionary);
1865
- });
1866
- return container;
1867
- }
1868
- constructor(containerOptions) {
1869
- const options = containerOptions || {};
1870
- if (typeof options !== 'object') {
1871
- throw new Error(`${CONTAINER_OPTIONS_MUST_BE_AN_OBJECT}`);
1872
- }
1873
- if (options.defaultScope === undefined) {
1874
- options.defaultScope = BindingScopeEnum.Transient;
1875
- }
1876
- else if (options.defaultScope !== BindingScopeEnum.Singleton &&
1877
- options.defaultScope !== BindingScopeEnum.Transient &&
1878
- options.defaultScope !== BindingScopeEnum.Request) {
1879
- throw new Error(`${CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE}`);
1880
- }
1881
- if (options.autoBindInjectable === undefined) {
1882
- options.autoBindInjectable = false;
1883
- }
1884
- else if (typeof options.autoBindInjectable !== 'boolean') {
1885
- throw new Error(`${CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE}`);
1886
- }
1887
- if (options.skipBaseClassChecks === undefined) {
1888
- options.skipBaseClassChecks = false;
1889
- }
1890
- else if (typeof options.skipBaseClassChecks !== 'boolean') {
1891
- throw new Error(`${CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK}`);
1892
- }
1893
- this.options = {
1894
- autoBindInjectable: options.autoBindInjectable,
1895
- defaultScope: options.defaultScope,
1896
- skipBaseClassChecks: options.skipBaseClassChecks
1897
- };
1898
- this.id = id();
1899
- this._bindingDictionary = new Lookup();
1900
- this.parent = null;
1901
- this._metadataReader = new MetadataReader();
1902
- }
1903
- load(...modules) {
1904
- const getHelpers = this._getContainerModuleHelpersFactory();
1905
- for (const currentModule of modules) {
1906
- const containerModuleHelpers = getHelpers(currentModule.id);
1907
- currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction);
1908
- }
1909
- }
1910
- unload(...modules) {
1911
- modules.forEach(module => {
1912
- const deactivations = this._removeModuleBindings(module.id);
1913
- this._deactivateSingletons(deactivations);
1914
- });
1915
- }
1916
- bind(serviceIdentifier) {
1917
- const scope = this.options.defaultScope || BindingScopeEnum.Transient;
1918
- const binding = new Binding(serviceIdentifier, scope);
1919
- this._bindingDictionary.add(serviceIdentifier, binding);
1920
- return new BindingToSyntax(binding);
1921
- }
1922
- rebind(serviceIdentifier) {
1923
- this.unbind(serviceIdentifier);
1924
- return this.bind(serviceIdentifier);
1925
- }
1926
- unbind(serviceIdentifier) {
1927
- if (this._bindingDictionary.hasKey(serviceIdentifier)) {
1928
- const bindings = this._bindingDictionary.get(serviceIdentifier);
1929
- this._deactivateSingletons(bindings);
1930
- }
1931
- this._removeServiceFromDictionary(serviceIdentifier);
1932
- }
1933
- unbindAll() {
1934
- this._bindingDictionary.traverse((_key, value) => {
1935
- this._deactivateSingletons(value);
1936
- });
1937
- this._bindingDictionary = new Lookup();
1938
- }
1939
- isBound(serviceIdentifier) {
1940
- let bound = this._bindingDictionary.hasKey(serviceIdentifier);
1941
- if (!bound && this.parent) {
1942
- bound = this.parent.isBound(serviceIdentifier);
1943
- }
1944
- return bound;
765
+ return new BindingInSyntax(this._binding);
1945
766
  }
1946
- isCurrentBound(serviceIdentifier) {
1947
- return this._bindingDictionary.hasKey(serviceIdentifier);
767
+ toConstantValue(value) {
768
+ this._binding.type = BindingTypeEnum.ConstantValue;
769
+ this._binding.cache = value;
770
+ this._binding.dynamicValue = null;
771
+ this._binding.implementationType = null;
772
+ this._binding.scope = BindingScopeEnum.Singleton;
773
+ return new BindingInSyntax(this._binding);
774
+ }
775
+ toFactory(factory) {
776
+ this._binding.type = BindingTypeEnum.Factory;
777
+ this._binding.factory = factory;
778
+ this._binding.scope = BindingScopeEnum.Singleton;
779
+ return new BindingInSyntax(this._binding);
1948
780
  }
1949
- isBoundNamed(serviceIdentifier, named) {
1950
- return this.isBoundTagged(serviceIdentifier, NAMED_TAG, named);
781
+ toService(service) {
782
+ this.toDynamicValue(context => context.container.get(service));
1951
783
  }
1952
- isBoundTagged(serviceIdentifier, key, value) {
1953
- let bound = false;
1954
- if (this._bindingDictionary.hasKey(serviceIdentifier)) {
1955
- const bindings = this._bindingDictionary.get(serviceIdentifier);
1956
- const request = createMockRequest(this, serviceIdentifier, key, value);
1957
- bound = bindings.some(b => b.constraint(request));
1958
- }
1959
- if (!bound && this.parent) {
1960
- bound = this.parent.isBoundTagged(serviceIdentifier, key, value);
1961
- }
1962
- return bound;
784
+ }
785
+
786
+ class Container {
787
+ constructor(containerOptions) {
788
+ const options = containerOptions || {};
789
+ options.defaultScope = options.defaultScope || BindingScopeEnum.Transient;
790
+ this.options = options;
791
+ this.id = Generator.GenAutoIncrementId();
792
+ this._bindingDictionary = new Map();
793
+ this._metadataReader = new MetadataReader();
1963
794
  }
1964
- applyCustomMetadataReader(metadataReader) {
1965
- this._metadataReader = metadataReader;
795
+ load(module) {
796
+ const getHelpers = this._getContainerModuleHelpersFactory();
797
+ const containerModuleHelpers = getHelpers(module.id);
798
+ module.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction);
1966
799
  }
1967
800
  get(serviceIdentifier) {
1968
801
  const getArgs = this._getNotAllArgs(serviceIdentifier, false);
1969
- const data = this._getButThrowIfAsync(getArgs);
1970
- return data;
802
+ return this._get(getArgs);
1971
803
  }
1972
- getAsync(serviceIdentifier) {
1973
- return __awaiter(this, void 0, void 0, function* () {
1974
- const getArgs = this._getNotAllArgs(serviceIdentifier, false);
1975
- return this._get(getArgs);
1976
- });
804
+ getAll(serviceIdentifier) {
805
+ const getArgs = this._getAllArgs(serviceIdentifier);
806
+ return this._get(getArgs);
1977
807
  }
1978
808
  getTagged(serviceIdentifier, key, value) {
1979
809
  const getArgs = this._getNotAllArgs(serviceIdentifier, false, key, value);
1980
- return this._getButThrowIfAsync(getArgs);
810
+ return this._get(getArgs);
1981
811
  }
1982
812
  getNamed(serviceIdentifier, named) {
1983
813
  return this.getTagged(serviceIdentifier, NAMED_TAG, named);
1984
814
  }
1985
- getAll(serviceIdentifier) {
1986
- const getArgs = this._getAllArgs(serviceIdentifier);
1987
- return this._getButThrowIfAsync(getArgs);
1988
- }
1989
- getAllTagged(serviceIdentifier, key, value) {
1990
- const getArgs = this._getNotAllArgs(serviceIdentifier, true, key, value);
1991
- return this._getButThrowIfAsync(getArgs);
1992
- }
1993
- getAllNamed(serviceIdentifier, named) {
1994
- return this.getAllTagged(serviceIdentifier, NAMED_TAG, named);
1995
- }
1996
- resolve(constructorFunction) {
1997
- const isBound = this.isBound(constructorFunction);
1998
- if (!isBound) {
1999
- this.bind(constructorFunction).toSelf();
2000
- }
2001
- const resolved = this.get(constructorFunction);
2002
- if (!isBound) {
2003
- this.unbind(constructorFunction);
2004
- }
2005
- return resolved;
2006
- }
2007
- _preDestroy(constructor, instance) {
2008
- var _a, _b;
2009
- if (Reflect$2.hasMetadata(PRE_DESTROY, constructor)) {
2010
- const data = Reflect$2.getMetadata(PRE_DESTROY, constructor);
2011
- return (_b = (_a = instance)[data.value]) === null || _b === void 0 ? void 0 : _b.call(_a);
2012
- }
815
+ isBound(serviceIdentifier) {
816
+ return this._bindingDictionary.has(serviceIdentifier);
2013
817
  }
2014
- _removeModuleBindings(moduleId) {
2015
- return this._bindingDictionary.removeByCondition(binding => binding.moduleId === moduleId);
818
+ bind(serviceIdentifier) {
819
+ const scope = this.options.defaultScope;
820
+ const binding = new Binding(serviceIdentifier, scope);
821
+ const list = this._bindingDictionary.get(serviceIdentifier) || [];
822
+ list.push(binding);
823
+ this._bindingDictionary.set(serviceIdentifier, list);
824
+ return new BindingToSyntax(binding);
2016
825
  }
2017
- _deactivate(binding, instance) {
2018
- const constructor = Object.getPrototypeOf(instance).constructor;
2019
- try {
2020
- const propagateDeactivationResult = this._propagateContainerDeactivationThenBindingAndPreDestroy(binding, instance, constructor);
2021
- if (isPromise(propagateDeactivationResult)) {
2022
- return this._handleDeactivationError(propagateDeactivationResult, constructor);
2023
- }
2024
- }
2025
- catch (ex) {
2026
- if (ex instanceof Error) {
2027
- throw new Error(ON_DEACTIVATION_ERROR(constructor.name, ex.message));
2028
- }
2029
- }
826
+ unbind(serviceIdentifier) {
827
+ this._bindingDictionary.delete(serviceIdentifier);
2030
828
  }
2031
- _handleDeactivationError(asyncResult, constructor) {
2032
- return __awaiter(this, void 0, void 0, function* () {
2033
- try {
2034
- yield asyncResult;
2035
- }
2036
- catch (ex) {
2037
- if (ex instanceof Error) {
2038
- throw new Error(ON_DEACTIVATION_ERROR(constructor.name, ex.message));
2039
- }
2040
- }
2041
- });
829
+ rebind(serviceIdentifier) {
830
+ this.unbind(serviceIdentifier);
831
+ return this.bind(serviceIdentifier);
2042
832
  }
2043
833
  _getContainerModuleHelpersFactory() {
2044
834
  const setModuleId = (bindingToSyntax, moduleId) => {
@@ -2071,103 +861,169 @@
2071
861
  unbindAsyncFunction: getUnbindAsyncFunction()
2072
862
  });
2073
863
  }
2074
- _get(getArgs) {
2075
- const planAndResolveArgs = Object.assign(Object.assign({}, getArgs), { contextInterceptor: context => context, targetType: TargetTypeEnum.Variable });
2076
- return this._planAndResolve()(planAndResolveArgs);
2077
- }
2078
- _getButThrowIfAsync(getArgs) {
2079
- const result = this._get(getArgs);
2080
- return result;
2081
- }
2082
- _getAllArgs(serviceIdentifier) {
2083
- const getAllArgs = {
2084
- avoidConstraints: true,
2085
- isMultiInject: true,
2086
- serviceIdentifier
2087
- };
2088
- return getAllArgs;
2089
- }
2090
864
  _getNotAllArgs(serviceIdentifier, isMultiInject, key, value) {
2091
- const getNotAllArgs = {
865
+ return {
2092
866
  avoidConstraints: false,
2093
867
  isMultiInject,
2094
868
  serviceIdentifier,
2095
869
  key,
2096
870
  value
2097
871
  };
2098
- return getNotAllArgs;
2099
872
  }
2100
- _planAndResolve() {
2101
- return (args) => {
2102
- let context = plan(this._metadataReader, this, args.isMultiInject, args.targetType, args.serviceIdentifier, args.key, args.value, args.avoidConstraints);
2103
- context = args.contextInterceptor(context);
2104
- const result = resolve(context);
2105
- return result;
873
+ _getAllArgs(serviceIdentifier) {
874
+ return {
875
+ avoidConstraints: true,
876
+ isMultiInject: true,
877
+ serviceIdentifier
2106
878
  };
2107
879
  }
2108
- _deactivateIfSingleton(binding) {
2109
- if (!binding.activated) {
2110
- return;
2111
- }
2112
- if (isPromise(binding.cache)) {
2113
- return binding.cache.then(resolved => this._deactivate(binding, resolved));
2114
- }
2115
- return this._deactivate(binding, binding.cache);
880
+ _get(getArgs) {
881
+ const result = [];
882
+ const bindings = this._bindingDictionary.get(getArgs.serviceIdentifier);
883
+ bindings.forEach(binding => {
884
+ result.push(this._resolveFromBinding(binding));
885
+ });
886
+ return !getArgs.isMultiInject && result.length === 1 ? result[0] : result;
2116
887
  }
2117
- _deactivateSingletons(bindings) {
2118
- for (const binding of bindings) {
2119
- const result = this._deactivateIfSingleton(binding);
2120
- if (isPromise(result)) {
2121
- throw new Error(ASYNC_UNBIND_REQUIRED);
2122
- }
888
+ _getChildRequest(binding) {
889
+ const constr = binding.implementationType;
890
+ const { userGeneratedMetadata } = this._metadataReader.getConstructorMetadata(constr);
891
+ const keys = Object.keys(userGeneratedMetadata);
892
+ const arr = [];
893
+ for (let i = 0; i < keys.length; i++) {
894
+ const constructorArgsMetadata = userGeneratedMetadata[i];
895
+ const targetMetadataMap = {};
896
+ constructorArgsMetadata.forEach(md => {
897
+ targetMetadataMap[md.key] = md.value;
898
+ });
899
+ const metadata = {
900
+ inject: targetMetadataMap[INJECT_TAG],
901
+ multiInject: targetMetadataMap[MULTI_INJECT_TAG]
902
+ };
903
+ const injectIdentifier = metadata.inject || metadata.multiInject;
904
+ const target = {
905
+ serviceIdentifier: injectIdentifier,
906
+ constructorArgsMetadata
907
+ };
908
+ const bindings = this._bindingDictionary.get(injectIdentifier).filter(b => {
909
+ return b.constraint(target);
910
+ });
911
+ const request = {
912
+ injectIdentifier,
913
+ metadata: constructorArgsMetadata,
914
+ bindings
915
+ };
916
+ arr.push(request);
2123
917
  }
918
+ return arr;
2124
919
  }
2125
- _propagateContainerDeactivationThenBindingAndPreDestroy(binding, instance, constructor) {
2126
- if (this.parent) {
2127
- return this._deactivate.bind(this.parent)(binding, instance);
2128
- }
2129
- return this._bindingDeactivationAndPreDestroy(binding, instance, constructor);
920
+ _resolveFromBinding(binding) {
921
+ const result = this._getResolvedFromBinding(binding);
922
+ this._saveToScope(binding, result);
923
+ return result;
2130
924
  }
2131
- _removeServiceFromDictionary(serviceIdentifier) {
2132
- try {
2133
- this._bindingDictionary.remove(serviceIdentifier);
925
+ _getResolvedFromBinding(binding) {
926
+ let result;
927
+ switch (binding.type) {
928
+ case BindingTypeEnum.ConstantValue:
929
+ case BindingTypeEnum.Function:
930
+ result = binding.cache;
931
+ break;
932
+ case BindingTypeEnum.Instance:
933
+ result = this._resolveInstance(binding, binding.implementationType);
934
+ break;
935
+ default:
936
+ result = binding.dynamicValue({ container: this });
2134
937
  }
2135
- catch (e) {
2136
- throw new Error(`${CANNOT_UNBIND} ${getServiceIdentifierAsString(serviceIdentifier)}`);
938
+ return result;
939
+ }
940
+ _resolveInstance(binding, constr) {
941
+ if (binding.activated) {
942
+ return binding.cache;
2137
943
  }
944
+ const childRequests = this._getChildRequest(binding);
945
+ return this._createInstance(constr, childRequests);
2138
946
  }
2139
- _bindingDeactivationAndPreDestroy(binding, instance, constructor) {
2140
- if (typeof binding.onDeactivation === 'function') {
2141
- const result = binding.onDeactivation(instance);
2142
- if (isPromise(result)) {
2143
- return result.then(() => this._preDestroy(constructor, instance));
2144
- }
947
+ _createInstance(constr, childRequests) {
948
+ if (childRequests.length) {
949
+ const resolved = this._resolveRequests(childRequests);
950
+ const obj = new constr(...resolved);
951
+ return obj;
2145
952
  }
2146
- return this._preDestroy(constructor, instance);
953
+ const obj = new constr();
954
+ return obj;
2147
955
  }
2148
- _bindingDeactivationAndPreDestroyAsync(binding, instance, constructor) {
2149
- return __awaiter(this, void 0, void 0, function* () {
2150
- if (typeof binding.onDeactivation === 'function') {
2151
- yield binding.onDeactivation(instance);
2152
- }
2153
- yield this._preDestroy(constructor, instance);
956
+ _resolveRequests(childRequests) {
957
+ return childRequests.map(request => {
958
+ return request.bindings.length > 1
959
+ ? request.bindings.map(binding => this._resolveFromBinding(binding))
960
+ : this._resolveFromBinding(request.bindings[0]);
2154
961
  });
2155
962
  }
963
+ _saveToScope(binding, result) {
964
+ if (binding.scope === BindingScopeEnum.Singleton) {
965
+ binding.cache = result;
966
+ binding.activated = true;
967
+ }
968
+ }
2156
969
  }
2157
970
 
2158
- function propertyEventDecorator(eventKey, errorMessage) {
2159
- return () => {
2160
- return (target, propertyKey) => {
2161
- const metadata = new Metadata(eventKey, propertyKey);
2162
- if (Reflect$2.hasOwnMetadata(eventKey, target.constructor)) {
2163
- throw new Error(errorMessage);
2164
- }
2165
- Reflect$2.defineMetadata(eventKey, metadata, target.constructor);
2166
- };
2167
- };
971
+ function _typeof(o) {
972
+ "@babel/helpers - typeof";
973
+
974
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
975
+ return typeof o;
976
+ } : function (o) {
977
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
978
+ }, _typeof(o);
2168
979
  }
2169
980
 
2170
- const postConstruct = propertyEventDecorator(POST_CONSTRUCT, MULTIPLE_POST_CONSTRUCT_METHODS);
981
+ function __decorate(decorators, target, key, desc) {
982
+ var c = arguments.length,
983
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
984
+ d;
985
+ if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
986
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
987
+ }
988
+ function __param(paramIndex, decorator) {
989
+ return function (target, key) {
990
+ decorator(target, key, paramIndex);
991
+ };
992
+ }
993
+ function __metadata(metadataKey, metadataValue) {
994
+ if ((typeof Reflect === "undefined" ? "undefined" : _typeof(Reflect)) === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
995
+ }
996
+ function __awaiter(thisArg, _arguments, P, generator) {
997
+ function adopt(value) {
998
+ return value instanceof P ? value : new P(function (resolve) {
999
+ resolve(value);
1000
+ });
1001
+ }
1002
+ return new (P || (P = Promise))(function (resolve, reject) {
1003
+ function fulfilled(value) {
1004
+ try {
1005
+ step(generator.next(value));
1006
+ } catch (e) {
1007
+ reject(e);
1008
+ }
1009
+ }
1010
+ function rejected(value) {
1011
+ try {
1012
+ step(generator["throw"](value));
1013
+ } catch (e) {
1014
+ reject(e);
1015
+ }
1016
+ }
1017
+ function step(result) {
1018
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
1019
+ }
1020
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1021
+ });
1022
+ }
1023
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1024
+ var e = new Error(message);
1025
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1026
+ };
2171
1027
 
2172
1028
  const ContributionProvider = Symbol('ContributionProvider');
2173
1029
  class ContributionProviderCache {
@@ -2352,11 +1208,13 @@
2352
1208
  }
2353
1209
  constructor(contributions) {
2354
1210
  this.contributions = contributions;
1211
+ this.id = Generator.GenAutoIncrementId();
2355
1212
  this.hooks = {
2356
1213
  onSetEnv: new SyncHook(['lastEnv', 'env', 'global'])
2357
1214
  };
2358
1215
  this.measureTextMethod = 'native';
2359
1216
  this.optimizeVisible = false;
1217
+ this.optmizeSkipCheckBoundariesThreshold = 0;
2360
1218
  }
2361
1219
  bindContribution(params) {
2362
1220
  const promiseArr = [];
@@ -4291,7 +3149,10 @@
4291
3149
  direction: 'horizontal',
4292
3150
  wordBreak: 'break-all',
4293
3151
  ignoreBuf: false,
4294
- verticalMode: 0
3152
+ verticalMode: 0,
3153
+ whiteSpace: 'no-wrap',
3154
+ heightLimit: Infinity,
3155
+ lineClamp: Infinity
4295
3156
  };
4296
3157
  const DefaultStyle = Object.assign(Object.assign(Object.assign({ opacity: 1, background: null, texture: null, textureColor: 'black', textureSize: 10, texturePadding: 2, backgroundMode: 0, blur: 0, cursor: null, html: null }, DefaultFillStyle), DefaultStrokeStyle), DefaultLayout);
4297
3158
  const DefaultConnectAttribute = {
@@ -5422,6 +4283,13 @@
5422
4283
  class DefaultCanvasAllocate {
5423
4284
  constructor() {
5424
4285
  this.pools = [];
4286
+ this.allocatedCanvas = [];
4287
+ }
4288
+ shareCanvas() {
4289
+ if (this.allocatedCanvas.length) {
4290
+ return this.allocatedCanvas[0];
4291
+ }
4292
+ return this.getCommonCanvas();
5425
4293
  }
5426
4294
  getCommonCanvas() {
5427
4295
  if (!this._commonCanvas) {
@@ -5431,7 +4299,9 @@
5431
4299
  }
5432
4300
  allocate(data) {
5433
4301
  if (!this.pools.length) {
5434
- return wrapCanvas(Object.assign({ nativeCanvas: application.global.createCanvas(data) }, data));
4302
+ const c = wrapCanvas(Object.assign({ nativeCanvas: application.global.createCanvas(data) }, data));
4303
+ this.allocatedCanvas.push(c);
4304
+ return c;
5435
4305
  }
5436
4306
  const m = this.pools.pop();
5437
4307
  m.resize(data.width, data.height);
@@ -5445,7 +4315,9 @@
5445
4315
  height: canvas.height / canvas.dpr,
5446
4316
  dpr: canvas.dpr
5447
4317
  };
5448
- return wrapCanvas(Object.assign({ nativeCanvas: application.global.createCanvas(data) }, data));
4318
+ const c = wrapCanvas(Object.assign({ nativeCanvas: application.global.createCanvas(data) }, data));
4319
+ this.allocatedCanvas.push(c);
4320
+ return c;
5449
4321
  }
5450
4322
  const m = this.pools.pop();
5451
4323
  m.width = canvas.width;
@@ -5465,6 +4337,14 @@
5465
4337
  const canvasAllocate = new DefaultCanvasAllocate();
5466
4338
 
5467
4339
  exports.DefaultGraphicUtil = class DefaultGraphicUtil {
4340
+ get canvas() {
4341
+ this.tryInitCanvas();
4342
+ return this._canvas;
4343
+ }
4344
+ get context() {
4345
+ this.tryInitCanvas();
4346
+ return this._context;
4347
+ }
5468
4348
  constructor(contributions) {
5469
4349
  this.contributions = contributions;
5470
4350
  this.configured = false;
@@ -5484,14 +4364,18 @@
5484
4364
  if (this.configured) {
5485
4365
  return;
5486
4366
  }
5487
- const canvas = canvasAllocate.getCommonCanvas();
5488
- this.canvas = canvas;
5489
- this.context = canvas.getContext('2d');
5490
4367
  this.contributions.getContributions().forEach(contribution => {
5491
4368
  contribution.configure(this, env);
5492
4369
  });
5493
4370
  this.configured = true;
5494
4371
  }
4372
+ tryInitCanvas() {
4373
+ if (!this._canvas) {
4374
+ const canvas = canvasAllocate.shareCanvas();
4375
+ this._canvas = canvas;
4376
+ this._context = canvas.getContext('2d');
4377
+ }
4378
+ }
5495
4379
  bindTextMeasure(tm) {
5496
4380
  this._textMeasure = tm;
5497
4381
  }
@@ -5816,13 +4700,6 @@
5816
4700
  return null;
5817
4701
  }
5818
4702
 
5819
- class Generator {
5820
- static GenAutoIncrementId() {
5821
- return Generator.auto_increment_id++;
5822
- }
5823
- }
5824
- Generator.auto_increment_id = 0;
5825
-
5826
4703
  class Node extends vutils.EventEmitter {
5827
4704
  get previousSibling() {
5828
4705
  return this._prev;
@@ -6810,6 +5687,9 @@
6810
5687
  }
6811
5688
  else if (clickEvent.pointerType === 'touch') {
6812
5689
  this.dispatchEvent(clickEvent, 'tap');
5690
+ if (clickHistory.clickCount === 2) {
5691
+ this.dispatchEvent(clickEvent, 'dbltap');
5692
+ }
6813
5693
  }
6814
5694
  this.dispatchEvent(clickEvent, 'pointertap');
6815
5695
  this.freeEvent(clickEvent);
@@ -9022,6 +7902,13 @@
9022
7902
  }
9023
7903
  RafBasedSTO.TimeOut = 1000 / 60;
9024
7904
  const rafBasedSto = new RafBasedSTO();
7905
+ const calculateLineHeight = (lineHeight, fontSize) => {
7906
+ if (vutils.isString(lineHeight) && lineHeight[lineHeight.length - 1] === '%') {
7907
+ const scale = Number.parseFloat(lineHeight.substring(0, lineHeight.length - 1)) / 100;
7908
+ return fontSize * scale;
7909
+ }
7910
+ return lineHeight;
7911
+ };
9025
7912
 
9026
7913
  class IncreaseCount extends ACustomAnimate {
9027
7914
  constructor(from, to, duration, easing, params) {
@@ -13466,6 +12353,7 @@
13466
12353
  };
13467
12354
  this._uid = Generator.GenAutoIncrementId();
13468
12355
  this.global = application.global;
12356
+ this.postInit();
13469
12357
  }
13470
12358
  postInit() {
13471
12359
  this.global.hooks.onSetEnv.tap('window', () => {
@@ -13551,12 +12439,6 @@
13551
12439
  return this._handler.getTopLeft(baseWindow);
13552
12440
  }
13553
12441
  };
13554
- __decorate([
13555
- postConstruct(),
13556
- __metadata("design:type", Function),
13557
- __metadata("design:paramtypes", []),
13558
- __metadata("design:returntype", void 0)
13559
- ], exports.DefaultWindow.prototype, "postInit", null);
13560
12442
  exports.DefaultWindow = __decorate([
13561
12443
  injectable(),
13562
12444
  __metadata("design:paramtypes", [])
@@ -14324,6 +13206,8 @@
14324
13206
  const TEXT_UPDATE_TAG_KEY = [
14325
13207
  'text',
14326
13208
  'maxLineWidth',
13209
+ 'heightLimit',
13210
+ 'lineClamp',
14327
13211
  'fontSize',
14328
13212
  'fontFamily',
14329
13213
  'fontWeight',
@@ -14372,41 +13256,148 @@
14372
13256
  if (!Number.isFinite(maxLineWidth)) {
14373
13257
  return false;
14374
13258
  }
14375
- this.tryUpdateAABBBounds();
14376
- return this.clipedText !== attribute.text.toString();
14377
- }
14378
- get multilineLayout() {
14379
- if (!Array.isArray(this.attribute.text)) {
14380
- return undefined;
13259
+ this.tryUpdateAABBBounds();
13260
+ return this.clipedText !== attribute.text.toString();
13261
+ }
13262
+ get multilineLayout() {
13263
+ if (!Array.isArray(this.attribute.text)) {
13264
+ return undefined;
13265
+ }
13266
+ this.tryUpdateAABBBounds();
13267
+ return this.cache.layoutData;
13268
+ }
13269
+ constructor(params = { text: '', fontSize: 16 }) {
13270
+ super(params);
13271
+ this.type = 'text';
13272
+ this.numberType = TEXT_NUMBER_TYPE;
13273
+ this.cache = {};
13274
+ }
13275
+ isValid() {
13276
+ return super.isValid() && this._isValid();
13277
+ }
13278
+ _isValid() {
13279
+ const { text } = this.attribute;
13280
+ return text != null && text !== '';
13281
+ }
13282
+ doUpdateAABBBounds() {
13283
+ const textTheme = getTheme(this).text;
13284
+ this._AABBBounds.setValue(Infinity, Infinity, -Infinity, -Infinity);
13285
+ const attribute = this.attribute;
13286
+ const bounds = application.graphicService.updateTextAABBBounds(attribute, textTheme, this._AABBBounds, this);
13287
+ const { boundsPadding = textTheme.boundsPadding } = this.attribute;
13288
+ const paddingArray = parsePadding(boundsPadding);
13289
+ if (paddingArray) {
13290
+ bounds.expand(paddingArray);
13291
+ }
13292
+ this.clearUpdateBoundTag();
13293
+ return bounds;
13294
+ }
13295
+ updateWrapAABBBounds(text) {
13296
+ var _a, _b, _c, _d;
13297
+ const textTheme = getTheme(this).text;
13298
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
13299
+ const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
13300
+ const buf = ignoreBuf ? 0 : 2;
13301
+ if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
13302
+ const bbox = this.cache.layoutData.bbox;
13303
+ this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
13304
+ if (stroke) {
13305
+ this._AABBBounds.expand(lineWidth / 2);
13306
+ }
13307
+ return this._AABBBounds;
13308
+ }
13309
+ const textMeasure = application.graphicUtil.textMeasure;
13310
+ const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
13311
+ const lines = vutils.isArray(text) ? text.map(l => l.toString()) : [text.toString()];
13312
+ const linesLayout = [];
13313
+ const bboxWH = [0, 0];
13314
+ let lineCountLimit = Infinity;
13315
+ if (heightLimit > 0) {
13316
+ lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);
13317
+ }
13318
+ if (lineClamp) {
13319
+ lineCountLimit = Math.min(lineCountLimit, lineClamp);
13320
+ }
13321
+ if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {
13322
+ if (maxLineWidth > 0) {
13323
+ for (let i = 0; i < lines.length; i++) {
13324
+ const str = lines[i];
13325
+ let needCut = true;
13326
+ if (i === lineCountLimit - 1) {
13327
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
13328
+ linesLayout.push({
13329
+ str: clip.str,
13330
+ width: clip.width
13331
+ });
13332
+ break;
13333
+ }
13334
+ const clip = layoutObj.textMeasure.clipText(str, layoutObj.textOptions, maxLineWidth, wordBreak === 'break-word');
13335
+ if (str !== '' && clip.str === '') {
13336
+ if (ellipsis) {
13337
+ const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
13338
+ clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
13339
+ clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
13340
+ }
13341
+ else {
13342
+ clip.str = '';
13343
+ clip.width = 0;
13344
+ }
13345
+ needCut = false;
13346
+ }
13347
+ linesLayout.push({
13348
+ str: clip.str,
13349
+ width: clip.width
13350
+ });
13351
+ if (clip.str.length === str.length) ;
13352
+ else if (needCut) {
13353
+ const newStr = str.substring(clip.str.length);
13354
+ lines.splice(i + 1, 0, newStr);
13355
+ }
13356
+ }
13357
+ }
13358
+ let maxWidth = 0;
13359
+ linesLayout.forEach(layout => {
13360
+ maxWidth = Math.max(maxWidth, layout.width);
13361
+ });
13362
+ bboxWH[0] = maxWidth;
13363
+ }
13364
+ else {
13365
+ let lineWidth = 0;
13366
+ let width;
13367
+ let text;
13368
+ for (let i = 0, len = lines.length; i < len; i++) {
13369
+ if (i === lineCountLimit - 1) {
13370
+ const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, false);
13371
+ linesLayout.push({
13372
+ str: clip.str,
13373
+ width: clip.width
13374
+ });
13375
+ lineWidth = Math.max(lineWidth, clip.width);
13376
+ break;
13377
+ }
13378
+ text = lines[i];
13379
+ width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');
13380
+ lineWidth = Math.max(lineWidth, width);
13381
+ linesLayout.push({ str: text, width });
13382
+ }
13383
+ bboxWH[0] = lineWidth;
14381
13384
  }
14382
- this.tryUpdateAABBBounds();
14383
- return this.cache.layoutData;
14384
- }
14385
- constructor(params = { text: '', fontSize: 16 }) {
14386
- super(params);
14387
- this.type = 'text';
14388
- this.numberType = TEXT_NUMBER_TYPE;
14389
- this.cache = {};
14390
- }
14391
- isValid() {
14392
- return super.isValid() && this._isValid();
14393
- }
14394
- _isValid() {
14395
- const { text } = this.attribute;
14396
- return text != null && text !== '';
14397
- }
14398
- doUpdateAABBBounds() {
14399
- const textTheme = getTheme(this).text;
14400
- this._AABBBounds.setValue(Infinity, Infinity, -Infinity, -Infinity);
14401
- const attribute = this.attribute;
14402
- const bounds = application.graphicService.updateTextAABBBounds(attribute, textTheme, this._AABBBounds, this);
14403
- const { boundsPadding = textTheme.boundsPadding } = this.attribute;
14404
- const paddingArray = parsePadding(boundsPadding);
14405
- if (paddingArray) {
14406
- bounds.expand(paddingArray);
13385
+ bboxWH[1] = linesLayout.length * (lineHeight + buf);
13386
+ const bbox = {
13387
+ xOffset: 0,
13388
+ yOffset: 0,
13389
+ width: bboxWH[0],
13390
+ height: bboxWH[1]
13391
+ };
13392
+ layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
13393
+ const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
13394
+ this.cache.layoutData = layoutData;
13395
+ this.clearUpdateShapeTag();
13396
+ this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
13397
+ if (stroke) {
13398
+ this._AABBBounds.expand(lineWidth / 2);
14407
13399
  }
14408
- this.clearUpdateBoundTag();
14409
- return bounds;
13400
+ return this._AABBBounds;
14410
13401
  }
14411
13402
  updateSingallineAABBBounds(text) {
14412
13403
  const textTheme = getTheme(this).text;
@@ -14429,9 +13420,13 @@
14429
13420
  let width;
14430
13421
  let str;
14431
13422
  const attribute = this.attribute;
14432
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, ignoreBuf = textTheme.ignoreBuf } = attribute;
13423
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, ignoreBuf = textTheme.ignoreBuf, whiteSpace = textTheme.whiteSpace } = attribute;
13424
+ if (whiteSpace === 'normal') {
13425
+ return this.updateWrapAABBBounds(text);
13426
+ }
14433
13427
  const buf = ignoreBuf ? 0 : Math.max(2, fontSize * 0.075);
14434
- const { lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf } = attribute;
13428
+ const textFontSize = attribute.fontSize || textTheme.fontSize;
13429
+ const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, textFontSize)) !== null && _a !== void 0 ? _a : textFontSize + buf;
14435
13430
  if (!this.shouldUpdateShape() && this.cache) {
14436
13431
  width = (_b = this.cache.clipedWidth) !== null && _b !== void 0 ? _b : 0;
14437
13432
  const dx = textDrawOffsetX(textAlign, width);
@@ -14489,7 +13484,8 @@
14489
13484
  const attribute = this.attribute;
14490
13485
  const { ignoreBuf = textTheme.ignoreBuf } = attribute;
14491
13486
  const buf = ignoreBuf ? 0 : 2;
14492
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
13487
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontFamily = textTheme.fontFamily, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
13488
+ const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14493
13489
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
14494
13490
  if (!verticalMode) {
14495
13491
  const t = textAlign;
@@ -14546,11 +13542,15 @@
14546
13542
  return this._AABBBounds;
14547
13543
  }
14548
13544
  updateHorizontalMultilineAABBBounds(text) {
14549
- var _a;
13545
+ var _a, _b;
14550
13546
  const textTheme = getTheme(this).text;
14551
13547
  const attribute = this.attribute;
14552
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, lineHeight = attribute.lineHeight || attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak } = attribute;
14553
- if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
13548
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace } = attribute;
13549
+ const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize);
13550
+ if (whiteSpace === 'normal') {
13551
+ return this.updateWrapAABBBounds(text);
13552
+ }
13553
+ if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
14554
13554
  const bbox = this.cache.layoutData.bbox;
14555
13555
  this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14556
13556
  if (stroke) {
@@ -14578,7 +13578,8 @@
14578
13578
  const attribute = this.attribute;
14579
13579
  const { ignoreBuf = textTheme.ignoreBuf } = attribute;
14580
13580
  const buf = ignoreBuf ? 0 : 2;
14581
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineHeight = (_a = attribute.lineHeight) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
13581
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode } = attribute;
13582
+ const lineHeight = (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (attribute.fontSize || textTheme.fontSize) + buf;
14582
13583
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
14583
13584
  if (!verticalMode) {
14584
13585
  const t = textAlign;
@@ -14685,11 +13686,12 @@
14685
13686
  return text != null && text !== '';
14686
13687
  }
14687
13688
  updateMultilineAABBBounds(text) {
14688
- var _a, _b, _c;
13689
+ var _a, _b, _c, _d;
14689
13690
  const textTheme = getTheme(this).text;
14690
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, lineHeight = this.attribute.lineHeight || this.attribute.fontSize || textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
13691
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, lineClamp } = this.attribute;
13692
+ const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
14691
13693
  const buf = ignoreBuf ? 0 : 2;
14692
- if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
13694
+ if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
14693
13695
  const bbox = this.cache.layoutData.bbox;
14694
13696
  this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);
14695
13697
  if (stroke) {
@@ -14726,8 +13728,8 @@
14726
13728
  if (str !== '' && clip.str === '') {
14727
13729
  if (ellipsis) {
14728
13730
  const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, false);
14729
- clip.str = (_b = clipEllipsis.str) !== null && _b !== void 0 ? _b : '';
14730
- clip.width = (_c = clipEllipsis.width) !== null && _c !== void 0 ? _c : 0;
13731
+ clip.str = (_c = clipEllipsis.str) !== null && _c !== void 0 ? _c : '';
13732
+ clip.width = (_d = clipEllipsis.width) !== null && _d !== void 0 ? _d : 0;
14731
13733
  }
14732
13734
  else {
14733
13735
  clip.str = '';
@@ -15569,6 +14571,13 @@
15569
14571
  builtinSymbols.forEach(symbol => {
15570
14572
  builtinSymbolsMap[symbol.type] = symbol;
15571
14573
  });
14574
+ const builtInSymbolStrMap = {
14575
+ arrowLeft: 'M 0.25 -0.5 L -0.25 0 l 0.5 0.5',
14576
+ arrowRight: 'M -0.25 -0.5 l 0.5 0.5 l -0.5 0.5',
14577
+ rect: 'M -0.5,0.25 L 0.5,0.25 L 0.5,-0.25,L -0.5,-0.25 Z',
14578
+ rectRound: 'M 0.3 -0.5 C 0.41 -0.5 0.5 -0.41 0.5 -0.3 C 0.5 -0.3 0.5 0.3 0.5 0.3 C 0.5 0.41 0.41 0.5 0.3 0.5 C 0.3 0.5 -0.3 0.5 -0.3 0.5 C -0.41 0.5 -0.5 0.41 -0.5 0.3 C -0.5 0.3 -0.5 -0.3 -0.5 -0.3 C -0.5 -0.41 -0.41 -0.5 -0.3 -0.5 C -0.3 -0.5 0.3 -0.5 0.3 -0.5 Z',
14579
+ roundLine: 'M 1.2392 -0.258 L -1.3432 -0.258 C -1.4784 -0.258 -1.588 -0.1436 -1.588 -0.002 c 0 0.1416 0.1096 0.256 0.2448 0.256 l 2.5824 0 c 0.1352 0 0.2448 -0.1144 0.2448 -0.256 C 1.484 -0.1436 1.3744 -0.258 1.2392 -0.258 z'
14580
+ };
15572
14581
 
15573
14582
  const _tempBounds$1 = new vutils.AABBBounds();
15574
14583
  const SYMBOL_UPDATE_TAG_KEY = ['symbolType', 'size', ...GRAPHIC_UPDATE_TAG_KEY];
@@ -15594,7 +14603,7 @@
15594
14603
  }
15595
14604
  doUpdateParsedPath() {
15596
14605
  const symbolTheme = getTheme(this).symbol;
15597
- const { symbolType = symbolTheme.symbolType } = this.attribute;
14606
+ let { symbolType = symbolTheme.symbolType } = this.attribute;
15598
14607
  let path = builtinSymbolsMap[symbolType];
15599
14608
  if (path) {
15600
14609
  this._parsedPath = path;
@@ -15605,6 +14614,8 @@
15605
14614
  this._parsedPath = path;
15606
14615
  return path;
15607
14616
  }
14617
+ const _symbolType = builtInSymbolStrMap[symbolType];
14618
+ symbolType = _symbolType || symbolType;
15608
14619
  const valid = isSvg(symbolType);
15609
14620
  if (valid === true) {
15610
14621
  const parser = new XMLParser();
@@ -16354,8 +15365,9 @@
16354
15365
  constructor(text, newLine, character) {
16355
15366
  this.fontSize = character.fontSize || 16;
16356
15367
  this.textBaseline = character.textBaseline || 'alphabetic';
16357
- if (typeof character.lineHeight === 'number') {
16358
- this.lineHeight = character.lineHeight > this.fontSize ? character.lineHeight : this.fontSize;
15368
+ const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);
15369
+ if (typeof lineHeight === 'number') {
15370
+ this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;
16359
15371
  }
16360
15372
  else {
16361
15373
  this.lineHeight = Math.floor(1.2 * this.fontSize);
@@ -19020,7 +18032,7 @@
19020
18032
  return richText.AABBBounds;
19021
18033
  }
19022
18034
 
19023
- exports.BaseRender = class BaseRender {
18035
+ class BaseRender {
19024
18036
  init(contributions) {
19025
18037
  if (contributions) {
19026
18038
  this._renderContribitions = contributions.getContributions();
@@ -19187,10 +18199,7 @@
19187
18199
  context.modelMatrix = lastModelMatrix;
19188
18200
  context.highPerformanceRestore();
19189
18201
  }
19190
- };
19191
- exports.BaseRender = __decorate([
19192
- injectable()
19193
- ], exports.BaseRender);
18202
+ }
19194
18203
 
19195
18204
  function getScaledStroke(context, width, dpr) {
19196
18205
  let strokeWidth = width;
@@ -20074,7 +19083,7 @@
20074
19083
  const defaultSymbolTextureRenderContribution = defaultBaseTextureRenderContribution;
20075
19084
  const defaultSymbolBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
20076
19085
 
20077
- exports.DefaultCanvasArcRender = class DefaultCanvasArcRender extends exports.BaseRender {
19086
+ exports.DefaultCanvasArcRender = class DefaultCanvasArcRender extends BaseRender {
20078
19087
  constructor(arcRenderContribitions) {
20079
19088
  super();
20080
19089
  this.arcRenderContribitions = arcRenderContribitions;
@@ -20296,7 +19305,7 @@
20296
19305
  __metadata("design:paramtypes", [Object])
20297
19306
  ], exports.DefaultCanvasArcRender);
20298
19307
 
20299
- exports.DefaultCanvasCircleRender = class DefaultCanvasCircleRender extends exports.BaseRender {
19308
+ exports.DefaultCanvasCircleRender = class DefaultCanvasCircleRender extends BaseRender {
20300
19309
  constructor(circleRenderContribitions) {
20301
19310
  super();
20302
19311
  this.circleRenderContribitions = circleRenderContribitions;
@@ -20566,7 +19575,7 @@
20566
19575
  }
20567
19576
  }
20568
19577
 
20569
- exports.DefaultCanvasLineRender = class DefaultCanvasLineRender extends exports.BaseRender {
19578
+ exports.DefaultCanvasLineRender = class DefaultCanvasLineRender extends BaseRender {
20570
19579
  constructor() {
20571
19580
  super(...arguments);
20572
19581
  this.numberType = LINE_NUMBER_TYPE;
@@ -20671,19 +19680,55 @@
20671
19680
  }
20672
19681
  return !!ret;
20673
19682
  }
19683
+ drawLinearLineHighPerformance(line, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, lineAttribute, drawContext, params, fillCb, strokeCb) {
19684
+ var _a;
19685
+ context.beginPath();
19686
+ const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
19687
+ const { points } = line.attribute;
19688
+ const startP = points[0];
19689
+ context.moveTo(startP.x, startP.y, z);
19690
+ for (let i = 1; i < points.length; i++) {
19691
+ const p = points[i];
19692
+ context.lineTo(p.x, p.y, z);
19693
+ }
19694
+ context.setShadowBlendStyle && context.setShadowBlendStyle(line, line.attribute, lineAttribute);
19695
+ const { x: originX = 0, x: originY = 0 } = line.attribute;
19696
+ if (fill !== false) {
19697
+ if (fillCb) {
19698
+ fillCb(context, line.attribute, lineAttribute);
19699
+ }
19700
+ else if (fillOpacity) {
19701
+ context.setCommonStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute);
19702
+ context.fill();
19703
+ }
19704
+ }
19705
+ if (stroke !== false) {
19706
+ if (strokeCb) {
19707
+ strokeCb(context, line.attribute, lineAttribute);
19708
+ }
19709
+ else if (strokeOpacity) {
19710
+ context.setStrokeStyle(line, line.attribute, originX - offsetX, originY - offsetY, lineAttribute);
19711
+ context.stroke();
19712
+ }
19713
+ }
19714
+ }
20674
19715
  drawShape(line, context, x, y, drawContext, params, fillCb, strokeCb) {
20675
19716
  const lineAttribute = getTheme(line, params === null || params === void 0 ? void 0 : params.theme).line;
20676
- const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity } = line.attribute;
19717
+ const { fill = lineAttribute.fill, stroke = lineAttribute.stroke, fillOpacity = lineAttribute.fillOpacity, strokeOpacity = lineAttribute.strokeOpacity, segments, points, closePath } = line.attribute;
20677
19718
  const data = this.valid(line, lineAttribute, fillCb, strokeCb);
20678
19719
  if (!data) {
20679
19720
  return;
20680
19721
  }
19722
+ let { curveType = lineAttribute.curveType } = line.attribute;
19723
+ if (closePath && curveType === 'linear') {
19724
+ curveType = 'linearClosed';
19725
+ }
19726
+ const { clipRange = lineAttribute.clipRange, clipRangeByDimension = lineAttribute.clipRangeByDimension } = line.attribute;
19727
+ if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
19728
+ return this.drawLinearLineHighPerformance(line, context, !!fill, !!stroke, fillOpacity, strokeOpacity, x, y, lineAttribute, drawContext, params, fillCb, strokeCb);
19729
+ }
20681
19730
  if (line.shouldUpdateShape()) {
20682
- const { points, segments, closePath } = line.attribute;
20683
- let { curveType = lineAttribute.curveType } = line.attribute;
20684
- if (closePath && curveType === 'linear') {
20685
- curveType = 'linearClosed';
20686
- }
19731
+ const { points, segments } = line.attribute;
20687
19732
  const _points = points;
20688
19733
  if (segments && segments.length) {
20689
19734
  let startPoint;
@@ -20747,7 +19792,6 @@
20747
19792
  }
20748
19793
  line.clearUpdateShapeTag();
20749
19794
  }
20750
- const { clipRange = lineAttribute.clipRange, clipRangeByDimension = lineAttribute.clipRangeByDimension } = line.attribute;
20751
19795
  if (Array.isArray(line.cache)) {
20752
19796
  const segments = line.attribute.segments.filter(item => item.points.length);
20753
19797
  if (segments[0].points.length === 1) {
@@ -21172,7 +20216,7 @@
21172
20216
  return genLinearSegments(points, params);
21173
20217
  }
21174
20218
  }
21175
- exports.DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends exports.BaseRender {
20219
+ exports.DefaultCanvasAreaRender = class DefaultCanvasAreaRender extends BaseRender {
21176
20220
  constructor(areaRenderContribitions) {
21177
20221
  super();
21178
20222
  this.areaRenderContribitions = areaRenderContribitions;
@@ -21180,22 +20224,75 @@
21180
20224
  this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution];
21181
20225
  this.init(areaRenderContribitions);
21182
20226
  }
20227
+ drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
20228
+ var _a, _b, _c, _d, _e;
20229
+ context.beginPath();
20230
+ const z = (_a = this.z) !== null && _a !== void 0 ? _a : 0;
20231
+ const { points } = area.attribute;
20232
+ const startP = points[0];
20233
+ context.moveTo(startP.x, startP.y, z);
20234
+ for (let i = 1; i < points.length; i++) {
20235
+ const p = points[i];
20236
+ context.lineTo(p.x, p.y, z);
20237
+ }
20238
+ for (let i = points.length - 1; i >= 0; i--) {
20239
+ const p = points[i];
20240
+ context.lineTo((_b = p.x1) !== null && _b !== void 0 ? _b : p.x, (_c = p.y1) !== null && _c !== void 0 ? _c : p.y, z);
20241
+ }
20242
+ context.closePath();
20243
+ context.setShadowBlendStyle && context.setShadowBlendStyle(area, area.attribute, areaAttribute);
20244
+ const { x: originX = 0, x: originY = 0 } = area.attribute;
20245
+ if (fill !== false) {
20246
+ if (fillCb) {
20247
+ fillCb(context, area.attribute, areaAttribute);
20248
+ }
20249
+ else if (fillOpacity) {
20250
+ context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute);
20251
+ context.fill();
20252
+ }
20253
+ }
20254
+ if (stroke) {
20255
+ const { stroke = areaAttribute && areaAttribute.stroke } = area.attribute;
20256
+ if (vutils.isArray(stroke) && (stroke[0] || stroke[2]) && stroke[1] === false) {
20257
+ context.beginPath();
20258
+ if (stroke[0]) {
20259
+ context.moveTo(startP.x, startP.y, z);
20260
+ for (let i = 1; i < points.length; i++) {
20261
+ const p = points[i];
20262
+ context.lineTo(p.x, p.y, z);
20263
+ }
20264
+ }
20265
+ else if (stroke[2]) {
20266
+ const endP = points[points.length - 1];
20267
+ context.moveTo(endP.x, endP.y, z);
20268
+ for (let i = points.length - 2; i >= 0; i--) {
20269
+ const p = points[i];
20270
+ context.lineTo((_d = p.x1) !== null && _d !== void 0 ? _d : p.x, (_e = p.y1) !== null && _e !== void 0 ? _e : p.y, z);
20271
+ }
20272
+ }
20273
+ }
20274
+ context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute);
20275
+ context.stroke();
20276
+ }
20277
+ }
21183
20278
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
21184
20279
  var _a, _b, _c, _d, _e, _f;
21185
20280
  const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
21186
- const { fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity } = area.attribute;
20281
+ const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity } = area.attribute;
21187
20282
  const data = this.valid(area, areaAttribute, fillCb, strokeCb);
21188
20283
  if (!data) {
21189
20284
  return;
21190
20285
  }
21191
20286
  const { doFill, doStroke } = data;
21192
- const { clipRange = areaAttribute.clipRange } = area.attribute;
20287
+ const { clipRange = areaAttribute.clipRange, closePath, points, segments } = area.attribute;
20288
+ let { curveType = areaAttribute.curveType } = area.attribute;
20289
+ if (closePath && curveType === 'linear') {
20290
+ curveType = 'linearClosed';
20291
+ }
20292
+ if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
20293
+ return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
20294
+ }
21193
20295
  if (area.shouldUpdateShape()) {
21194
- const { points, segments, closePath } = area.attribute;
21195
- let { curveType = areaAttribute.curveType } = area.attribute;
21196
- if (closePath && curveType === 'linear') {
21197
- curveType = 'linearClosed';
21198
- }
21199
20296
  if (segments && segments.length) {
21200
20297
  let startPoint;
21201
20298
  let lastTopSeg;
@@ -21430,7 +20527,7 @@
21430
20527
  const defaultPathTextureRenderContribution = defaultBaseTextureRenderContribution;
21431
20528
  const defaultPathBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
21432
20529
 
21433
- exports.DefaultCanvasPathRender = class DefaultCanvasPathRender extends exports.BaseRender {
20530
+ exports.DefaultCanvasPathRender = class DefaultCanvasPathRender extends BaseRender {
21434
20531
  constructor(pathRenderContribitions) {
21435
20532
  super();
21436
20533
  this.pathRenderContribitions = pathRenderContribitions;
@@ -21490,7 +20587,7 @@
21490
20587
  __metadata("design:paramtypes", [Object])
21491
20588
  ], exports.DefaultCanvasPathRender);
21492
20589
 
21493
- exports.DefaultCanvasRectRender = class DefaultCanvasRectRender extends exports.BaseRender {
20590
+ exports.DefaultCanvasRectRender = class DefaultCanvasRectRender extends BaseRender {
21494
20591
  constructor(rectRenderContribitions) {
21495
20592
  super();
21496
20593
  this.rectRenderContribitions = rectRenderContribitions;
@@ -21567,7 +20664,7 @@
21567
20664
  __metadata("design:paramtypes", [Object])
21568
20665
  ], exports.DefaultCanvasRectRender);
21569
20666
 
21570
- exports.DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends exports.BaseRender {
20667
+ exports.DefaultCanvasSymbolRender = class DefaultCanvasSymbolRender extends BaseRender {
21571
20668
  constructor(symbolRenderContribitions) {
21572
20669
  super();
21573
20670
  this.symbolRenderContribitions = symbolRenderContribitions;
@@ -21681,7 +20778,7 @@
21681
20778
  __metadata("design:paramtypes", [Object])
21682
20779
  ], exports.DefaultCanvasSymbolRender);
21683
20780
 
21684
- exports.DefaultCanvasTextRender = class DefaultCanvasTextRender extends exports.BaseRender {
20781
+ exports.DefaultCanvasTextRender = class DefaultCanvasTextRender extends BaseRender {
21685
20782
  constructor(textRenderContribitions) {
21686
20783
  super();
21687
20784
  this.textRenderContribitions = textRenderContribitions;
@@ -21691,14 +20788,14 @@
21691
20788
  drawShape(text, context, x, y, drawContext, params, fillCb, strokeCb) {
21692
20789
  var _a, _b, _c;
21693
20790
  const textAttribute = getTheme(text, params === null || params === void 0 ? void 0 : params.theme).text;
21694
- const { text: str, fill = textAttribute.fill, stroke = textAttribute.stroke, fillOpacity = textAttribute.fillOpacity, strokeOpacity = textAttribute.strokeOpacity, opacity = textAttribute.opacity, lineWidth = textAttribute.lineWidth, visible = textAttribute.visible, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, keepDirIn3d = textAttribute.keepDirIn3d, direction = textAttribute.direction, fontSize = textAttribute.fontSize, verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
20791
+ const { text: str, underline = textAttribute.underline, lineThrough = textAttribute.lineThrough, keepDirIn3d = textAttribute.keepDirIn3d, direction = textAttribute.direction, fontSize = textAttribute.fontSize, verticalMode = textAttribute.verticalMode, x: originX = textAttribute.x, y: originY = textAttribute.y } = text.attribute;
21695
20792
  let { textAlign = textAttribute.textAlign, textBaseline = textAttribute.textBaseline } = text.attribute;
21696
20793
  if (!verticalMode && direction === 'vertical') {
21697
20794
  const t = textAlign;
21698
20795
  textAlign = (_a = text.getBaselineMapAlign()[textBaseline]) !== null && _a !== void 0 ? _a : 'left';
21699
20796
  textBaseline = (_b = text.getAlignMapBaseline()[t]) !== null && _b !== void 0 ? _b : 'top';
21700
20797
  }
21701
- const lineHeight = (_c = text.attribute.lineHeight) !== null && _c !== void 0 ? _c : fontSize;
20798
+ const lineHeight = (_c = calculateLineHeight(text.attribute.lineHeight, fontSize)) !== null && _c !== void 0 ? _c : fontSize;
21702
20799
  const data = this.valid(text, textAttribute, fillCb, strokeCb);
21703
20800
  if (!data) {
21704
20801
  return;
@@ -21779,6 +20876,7 @@
21779
20876
  }
21780
20877
  }
21781
20878
  else {
20879
+ text.tryUpdateAABBBounds();
21782
20880
  const cache = text.cache;
21783
20881
  const { verticalList } = cache;
21784
20882
  context.textAlign = 'left';
@@ -21822,7 +20920,6 @@
21822
20920
  }
21823
20921
  }
21824
20922
  else {
21825
- const cache = text.cache;
21826
20923
  if (direction === 'horizontal') {
21827
20924
  context.setTextStyle(text.attribute, textAttribute, z);
21828
20925
  const t = text.clipedText;
@@ -21839,31 +20936,35 @@
21839
20936
  }
21840
20937
  drawText(t, 0, dy, 0);
21841
20938
  }
21842
- else if (cache) {
21843
- context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
21844
- const { verticalList } = cache;
21845
- let offsetY = 0;
21846
- const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
21847
- let offsetX = 0;
21848
- if (textBaseline === 'bottom') {
21849
- offsetX = -lineHeight;
21850
- }
21851
- else if (textBaseline === 'middle') {
21852
- offsetX = -lineHeight / 2;
21853
- }
21854
- if (textAlign === 'center') {
21855
- offsetY -= totalW / 2;
21856
- }
21857
- else if (textAlign === 'right') {
21858
- offsetY -= totalW;
20939
+ else {
20940
+ text.tryUpdateAABBBounds();
20941
+ const cache = text.cache;
20942
+ if (cache) {
20943
+ context.setTextStyleWithoutAlignBaseline(text.attribute, textAttribute, z);
20944
+ const { verticalList } = cache;
20945
+ let offsetY = 0;
20946
+ const totalW = verticalList[0].reduce((a, b) => a + (b.width || 0), 0);
20947
+ let offsetX = 0;
20948
+ if (textBaseline === 'bottom') {
20949
+ offsetX = -lineHeight;
20950
+ }
20951
+ else if (textBaseline === 'middle') {
20952
+ offsetX = -lineHeight / 2;
20953
+ }
20954
+ if (textAlign === 'center') {
20955
+ offsetY -= totalW / 2;
20956
+ }
20957
+ else if (textAlign === 'right') {
20958
+ offsetY -= totalW;
20959
+ }
20960
+ context.textAlign = 'left';
20961
+ context.textBaseline = 'top';
20962
+ verticalList[0].forEach(item => {
20963
+ const { text, width, direction } = item;
20964
+ drawText(text, offsetX, offsetY, direction);
20965
+ offsetY += width;
20966
+ });
21859
20967
  }
21860
- context.textAlign = 'left';
21861
- context.textBaseline = 'top';
21862
- verticalList[0].forEach(item => {
21863
- const { text, width, direction } = item;
21864
- drawText(text, offsetX, offsetY, direction);
21865
- offsetY += width;
21866
- });
21867
20968
  }
21868
20969
  }
21869
20970
  transform3dMatrixToContextMatrix && this.restoreTransformUseContext2d(text, textAttribute, z, context);
@@ -22030,7 +21131,7 @@
22030
21131
  const defaultPolygonTextureRenderContribution = defaultBaseTextureRenderContribution;
22031
21132
  const defaultPolygonBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
22032
21133
 
22033
- exports.DefaultCanvasPolygonRender = class DefaultCanvasPolygonRender extends exports.BaseRender {
21134
+ exports.DefaultCanvasPolygonRender = class DefaultCanvasPolygonRender extends BaseRender {
22034
21135
  constructor(polygonRenderContribitions) {
22035
21136
  super();
22036
21137
  this.polygonRenderContribitions = polygonRenderContribitions;
@@ -22089,7 +21190,7 @@
22089
21190
  ], exports.DefaultCanvasPolygonRender);
22090
21191
 
22091
21192
  const repeatStr = ['', 'repeat-x', 'repeat-y', 'repeat'];
22092
- exports.DefaultCanvasImageRender = class DefaultCanvasImageRender extends exports.BaseRender {
21193
+ exports.DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender {
22093
21194
  constructor(imageRenderContribitions) {
22094
21195
  super();
22095
21196
  this.imageRenderContribitions = imageRenderContribitions;
@@ -23249,6 +22350,7 @@
23249
22350
  this.backupDirtyBounds = new vutils.Bounds();
23250
22351
  this.global = application.global;
23251
22352
  this.layerService = application.layerService;
22353
+ this.init();
23252
22354
  }
23253
22355
  init() {
23254
22356
  this.contributions.forEach(item => {
@@ -23265,7 +22367,17 @@
23265
22367
  .getContributions()
23266
22368
  .sort((a, b) => a.order - b.order);
23267
22369
  }
22370
+ prepareForDraw(renderService, drawContext) {
22371
+ const count = renderService.renderTreeRoots.reduce((a, b) => a + b.count, 0);
22372
+ if (count < this.global.optmizeSkipCheckBoundariesThreshold) {
22373
+ this.useDirtyBounds = false;
22374
+ }
22375
+ else {
22376
+ this.useDirtyBounds = true;
22377
+ }
22378
+ }
23268
22379
  draw(renderService, drawContext) {
22380
+ this.prepareForDraw(renderService, drawContext);
23269
22381
  drawContext.drawContribution = this;
23270
22382
  this.currentRenderMap = this.styleRenderMap.get(drawContext.renderStyle) || this.defaultRenderMap;
23271
22383
  this.currentRenderService = renderService;
@@ -23338,13 +22450,17 @@
23338
22450
  this._increaseRender(group, drawContext);
23339
22451
  return;
23340
22452
  }
23341
- if (!vutils.isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {
22453
+ if (this.useDirtyBounds && !vutils.isRectIntersect(group.AABBBounds, this.dirtyBounds, false)) {
23342
22454
  return;
23343
22455
  }
23344
- const tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);
23345
- const gm = group.transMatrix;
23346
- const nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);
23347
- this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());
22456
+ let nextM;
22457
+ let tempBounds;
22458
+ if (this.useDirtyBounds) {
22459
+ tempBounds = boundsAllocate.allocateByObj(this.dirtyBounds);
22460
+ const gm = group.transMatrix;
22461
+ nextM = matrixAllocate.allocateByObj(parentMatrix).multiply(gm.a, gm.b, gm.c, gm.d, gm.e, gm.f);
22462
+ this.dirtyBounds.copy(this.backupDirtyBounds).transformWithMatrix(nextM.getInverse());
22463
+ }
23348
22464
  this.renderItem(group, drawContext, {
23349
22465
  drawingCb: () => {
23350
22466
  var _a;
@@ -23373,9 +22489,11 @@
23373
22489
  }, false, !!((_a = drawContext.context) === null || _a === void 0 ? void 0 : _a.camera));
23374
22490
  }
23375
22491
  });
23376
- this.dirtyBounds.copy(tempBounds);
23377
- boundsAllocate.free(tempBounds);
23378
- matrixAllocate.free(nextM);
22492
+ if (this.useDirtyBounds) {
22493
+ this.dirtyBounds.copy(tempBounds);
22494
+ boundsAllocate.free(tempBounds);
22495
+ matrixAllocate.free(nextM);
22496
+ }
23379
22497
  }
23380
22498
  _increaseRender(group, drawContext) {
23381
22499
  const { layer, stage } = drawContext;
@@ -23451,7 +22569,7 @@
23451
22569
  this.dirtyBounds.translate(-scrollX, -scrollY);
23452
22570
  }
23453
22571
  }
23454
- if (!(graphic.isContainer || vutils.isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {
22572
+ if (this.useDirtyBounds && !(graphic.isContainer || vutils.isRectIntersect(graphic.AABBBounds, this.dirtyBounds, false))) {
23455
22573
  retrans && this.dirtyBounds.copy(tempBounds);
23456
22574
  return;
23457
22575
  }
@@ -23513,12 +22631,6 @@
23513
22631
  return;
23514
22632
  }
23515
22633
  };
23516
- __decorate([
23517
- postConstruct(),
23518
- __metadata("design:type", Function),
23519
- __metadata("design:paramtypes", []),
23520
- __metadata("design:returntype", void 0)
23521
- ], DefaultDrawContribution.prototype, "init", null);
23522
22634
  DefaultDrawContribution = __decorate([
23523
22635
  injectable(),
23524
22636
  __param(0, multiInject(GraphicRender)),
@@ -24006,7 +23118,7 @@
24006
23118
  __metadata("design:paramtypes", [Array, Object, Object, Object])
24007
23119
  ], DefaultIncrementalDrawContribution);
24008
23120
 
24009
- let DefaultCanvasRect3dRender = class DefaultCanvasRect3dRender extends exports.BaseRender {
23121
+ let DefaultCanvasRect3dRender = class DefaultCanvasRect3dRender extends BaseRender {
24010
23122
  constructor() {
24011
23123
  super(...arguments);
24012
23124
  this.type = 'rect3d';
@@ -24136,7 +23248,7 @@
24136
23248
  injectable()
24137
23249
  ], DefaultCanvasRect3dRender);
24138
23250
 
24139
- let DefaultCanvasRichTextRender = class DefaultCanvasRichTextRender extends exports.BaseRender {
23251
+ let DefaultCanvasRichTextRender = class DefaultCanvasRichTextRender extends BaseRender {
24140
23252
  constructor() {
24141
23253
  super(...arguments);
24142
23254
  this.numberType = RICHTEXT_NUMBER_TYPE;
@@ -24318,7 +23430,7 @@
24318
23430
  context.closePath();
24319
23431
  return collapsedToLine;
24320
23432
  }
24321
- let DefaultCanvasArc3DRender = class DefaultCanvasArc3DRender extends exports.BaseRender {
23433
+ let DefaultCanvasArc3DRender = class DefaultCanvasArc3DRender extends BaseRender {
24322
23434
  constructor() {
24323
23435
  super(...arguments);
24324
23436
  this.numberType = ARC3D_NUMBER_TYPE;
@@ -24428,7 +23540,7 @@
24428
23540
  injectable()
24429
23541
  ], DefaultCanvasArc3DRender);
24430
23542
 
24431
- let DefaultCanvasPyramid3dRender = class DefaultCanvasPyramid3dRender extends exports.BaseRender {
23543
+ let DefaultCanvasPyramid3dRender = class DefaultCanvasPyramid3dRender extends BaseRender {
24432
23544
  constructor() {
24433
23545
  super(...arguments);
24434
23546
  this.type = 'pyramid3d';
@@ -24557,9 +23669,11 @@
24557
23669
  bind(DefaultBaseTextureRenderContribution).toSelf().inSingletonScope();
24558
23670
  bind(DrawContribution).to(DefaultDrawContribution);
24559
23671
  bind(IncrementalDrawContribution).to(DefaultIncrementalDrawContribution);
23672
+ bind(exports.DefaultCanvasCircleRender).toSelf().inSingletonScope();
24560
23673
  bind(CircleRender).to(exports.DefaultCanvasCircleRender).inSingletonScope();
24561
23674
  bind(GraphicRender).toService(CircleRender);
24562
23675
  bindContributionProvider(bind, CircleRenderContribution);
23676
+ bind(exports.DefaultCanvasRectRender).toSelf().inSingletonScope();
24563
23677
  bind(RectRender).to(exports.DefaultCanvasRectRender).inSingletonScope();
24564
23678
  bind(GraphicRender).toService(RectRender);
24565
23679
  bind(Rect3DRender).to(DefaultCanvasRect3dRender).inSingletonScope();
@@ -24568,21 +23682,26 @@
24568
23682
  bind(TextRender).to(exports.DefaultCanvasTextRender).inSingletonScope();
24569
23683
  bind(GraphicRender).toService(TextRender);
24570
23684
  bindContributionProvider(bind, TextRenderContribution);
23685
+ bind(exports.DefaultCanvasPathRender).toSelf().inSingletonScope();
24571
23686
  bind(PathRender).to(exports.DefaultCanvasPathRender).inSingletonScope();
24572
23687
  bind(GraphicRender).toService(PathRender);
24573
23688
  bindContributionProvider(bind, PathRenderContribution);
23689
+ bind(exports.DefaultCanvasSymbolRender).toSelf().inSingletonScope();
24574
23690
  bind(SymbolRender).to(exports.DefaultCanvasSymbolRender).inSingletonScope();
24575
23691
  bind(GraphicRender).toService(SymbolRender);
24576
23692
  bindContributionProvider(bind, SymbolRenderContribution);
23693
+ bind(exports.DefaultCanvasArcRender).toSelf().inSingletonScope();
24577
23694
  bind(ArcRender).to(exports.DefaultCanvasArcRender).inSingletonScope();
24578
23695
  bind(GraphicRender).toService(ArcRender);
24579
23696
  bind(Arc3dRender).to(DefaultCanvasArc3DRender).inSingletonScope();
24580
23697
  bind(GraphicRender).toService(Arc3dRender);
24581
23698
  bindContributionProvider(bind, ArcRenderContribution);
23699
+ bind(exports.DefaultCanvasLineRender).toSelf().inSingletonScope();
24582
23700
  bind(LineRender).to(exports.DefaultCanvasLineRender).inSingletonScope();
24583
23701
  bind(GraphicRender).toService(LineRender);
24584
23702
  bind(DefaultIncrementalCanvasLineRender).toSelf().inSingletonScope();
24585
23703
  bind(DefaultIncrementalCanvasAreaRender).toSelf().inSingletonScope();
23704
+ bind(exports.DefaultCanvasAreaRender).toSelf().inSingletonScope();
24586
23705
  bind(AreaRender).to(exports.DefaultCanvasAreaRender).inSingletonScope();
24587
23706
  bind(GraphicRender).toService(AreaRender);
24588
23707
  bindContributionProvider(bind, AreaRenderContribution);
@@ -25611,6 +24730,16 @@
25611
24730
  }
25612
24731
  }
25613
24732
 
24733
+ function isBrowserEnv() {
24734
+ return new Function('try {return this===window;}catch(e){ return false;}')();
24735
+ }
24736
+ function isNodeEnv() {
24737
+ return new Function('try {return this===global;}catch(e){return false;}')();
24738
+ }
24739
+ function getCurrentEnv() {
24740
+ return isBrowserEnv() ? 'browser' : 'node';
24741
+ }
24742
+
25614
24743
  const DefaultConfig$1 = {
25615
24744
  WIDTH: 500,
25616
24745
  HEIGHT: 500,
@@ -25677,6 +24806,10 @@
25677
24806
  get defaultLayer() {
25678
24807
  return this.at(0);
25679
24808
  }
24809
+ get eventSystem() {
24810
+ this.tryInitEventSystem();
24811
+ return this._eventSystem;
24812
+ }
25680
24813
  constructor(params) {
25681
24814
  var _a;
25682
24815
  super({});
@@ -25696,6 +24829,9 @@
25696
24829
  afterRender: new SyncHook(['stage'])
25697
24830
  };
25698
24831
  this.global = application.global;
24832
+ if (!this.global.env && isBrowserEnv()) {
24833
+ this.global.setEnv('browser');
24834
+ }
25699
24835
  this.window = container.get(VWindow);
25700
24836
  this.renderService = container.get(RenderService);
25701
24837
  this.pluginService = container.get(PluginService);
@@ -25721,13 +24857,35 @@
25721
24857
  this.renderCount = 0;
25722
24858
  this._subView = !(this._viewBox.width() === this.width && this._viewBox.height() === this.height);
25723
24859
  this._background = (_a = params.background) !== null && _a !== void 0 ? _a : DefaultConfig$1.BACKGROUND;
25724
- this.appendChild(this.layerService.createLayer(this, params.canvas && vutils.isString(params.canvas) ? { main: true, canvasId: params.canvas } : { main: true }));
24860
+ this.appendChild(this.layerService.createLayer(this, { main: true }));
25725
24861
  this.nextFrameRenderLayerSet = new Set();
25726
24862
  this.willNextFrameRender = false;
25727
24863
  this.stage = this;
25728
24864
  this.renderStyle = params.renderStyle;
25729
- if (this.global.supportEvent) {
25730
- this.eventSystem = new EventSystem({
24865
+ if (params.autoRender) {
24866
+ this.enableAutoRender();
24867
+ }
24868
+ if (params.disableDirtyBounds === false) {
24869
+ this.enableDirtyBounds();
24870
+ }
24871
+ if (params.enableHtmlAttribute) {
24872
+ this.enableHtmlAttribute(params.enableHtmlAttribute);
24873
+ }
24874
+ params.enableLayout && this.enableLayout();
24875
+ this.hooks.beforeRender.tap('constructor', this.beforeRender);
24876
+ this.hooks.afterRender.tap('constructor', this.afterRender);
24877
+ this._beforeRender = params.beforeRender;
24878
+ this._afterRender = params.afterRender;
24879
+ this.ticker = params.ticker || defaultTicker;
24880
+ this.supportInteractiveLayer = params.interactiveLayer !== false;
24881
+ this.timeline = new DefaultTimeline();
24882
+ this.ticker.addTimeline(this.timeline);
24883
+ this.timeline.pause();
24884
+ this.optmize(params.optimize);
24885
+ }
24886
+ tryInitEventSystem() {
24887
+ if (this.global.supportEvent && !this._eventSystem) {
24888
+ this._eventSystem = new EventSystem({
25731
24889
  targetElement: this.window,
25732
24890
  resolution: this.window.dpr || this.global.devicePixelRatio,
25733
24891
  rootNode: this,
@@ -25749,39 +24907,32 @@
25749
24907
  }
25750
24908
  });
25751
24909
  }
25752
- if (params.autoRender) {
25753
- this.enableAutoRender();
25754
- }
25755
- if (params.disableDirtyBounds === false) {
25756
- this.enableDirtyBounds();
25757
- }
25758
- if (params.enableHtmlAttribute) {
25759
- this.enableHtmlAttribute(params.enableHtmlAttribute);
24910
+ }
24911
+ preventRender(prevent) {
24912
+ if (prevent) {
24913
+ this._skipRender = -Infinity;
25760
24914
  }
25761
- params.enableLayout && this.enableLayout();
25762
- this.hooks.beforeRender.tap('constructor', this.beforeRender);
25763
- this.hooks.afterRender.tap('constructor', this.afterRender);
25764
- this._beforeRender = params.beforeRender;
25765
- this._afterRender = params.afterRender;
25766
- this.ticker = params.ticker || defaultTicker;
25767
- this.supportInteractiveLayer = params.interactiveLayer !== false;
25768
- this.timeline = new DefaultTimeline();
25769
- this.ticker.addTimeline(this.timeline);
25770
- this.timeline.pause();
25771
- this.optmize(params.optimize);
25772
- if (this._background && vutils.isString(this._background)) {
25773
- this.setAttributes({ background: this._background });
24915
+ else {
24916
+ if (this.params && this.params.optimize && this.params.optimize.skipRenderWithOutRange !== false) {
24917
+ this._skipRender = this.window.isVisible() ? 0 : 1;
24918
+ }
24919
+ else {
24920
+ this._skipRender = 0;
24921
+ }
25774
24922
  }
25775
24923
  }
25776
24924
  optmize(params) {
25777
24925
  this.optmizeRender(params === null || params === void 0 ? void 0 : params.skipRenderWithOutRange);
25778
24926
  }
25779
- optmizeRender(skipRenderWithOutRange = true) {
24927
+ optmizeRender(skipRenderWithOutRange = false) {
25780
24928
  if (!skipRenderWithOutRange) {
25781
24929
  return;
25782
24930
  }
25783
- this._skipRender = this.window.isVisible() ? 0 : 1;
24931
+ this._skipRender = this._skipRender < 0 ? this._skipRender : this.window.isVisible() ? 0 : 1;
25784
24932
  this.window.onVisibleChange(visible => {
24933
+ if (this._skipRender < 0) {
24934
+ return;
24935
+ }
25785
24936
  if (visible) {
25786
24937
  if (this.dirtyBounds) {
25787
24938
  this.dirtyBounds.setValue(0, 0, this._viewBox.width(), this._viewBox.height());
@@ -26073,13 +25224,13 @@
26073
25224
  layer.render({
26074
25225
  renderService: this.renderService,
26075
25226
  background: layer === this.defaultLayer ? this.background : undefined,
26076
- updateBounds: !!this.dirtyBounds
25227
+ updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty())
26077
25228
  }, Object.assign({ renderStyle: this.renderStyle }, params));
26078
25229
  });
26079
25230
  if (this.interactiveLayer && !layerList.includes(this.interactiveLayer)) {
26080
25231
  this.interactiveLayer.render({
26081
25232
  renderService: this.renderService,
26082
- updateBounds: !!this.dirtyBounds
25233
+ updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty())
26083
25234
  }, Object.assign({ renderStyle: this.renderStyle }, params));
26084
25235
  }
26085
25236
  }
@@ -26183,7 +25334,7 @@
26183
25334
  }
26184
25335
  renderTo(window, params) {
26185
25336
  this.forEachChildren((layer, i) => {
26186
- layer.drawTo(window, Object.assign(Object.assign({}, params), { renderService: this.renderService, background: layer === this.defaultLayer ? this.background : undefined, clear: i === 0, updateBounds: !!this.dirtyBounds }));
25337
+ layer.drawTo(window, Object.assign(Object.assign({}, params), { renderService: this.renderService, background: layer === this.defaultLayer ? this.background : undefined, clear: i === 0, updateBounds: !!(this.dirtyBounds && !this.dirtyBounds.empty()) }));
26187
25338
  });
26188
25339
  }
26189
25340
  renderToNewWindow(fullImage = true, viewBox) {
@@ -27235,16 +26386,6 @@
27235
26386
  }
27236
26387
  const defaultGraphicMemoryManager = new DefaultGraphicMemoryManager();
27237
26388
 
27238
- function isBrowserEnv() {
27239
- return new Function('try {return this===window;}catch(e){ return false;}')();
27240
- }
27241
- function isNodeEnv() {
27242
- return new Function('try {return this===global;}catch(e){return false;}')();
27243
- }
27244
- function getCurrentEnv() {
27245
- return isBrowserEnv() ? 'browser' : 'node';
27246
- }
27247
-
27248
26389
  exports.ACustomAnimate = ACustomAnimate;
27249
26390
  exports.ARC3D_NUMBER_TYPE = ARC3D_NUMBER_TYPE;
27250
26391
  exports.ARC_NUMBER_TYPE = ARC_NUMBER_TYPE;
@@ -27263,6 +26404,7 @@
27263
26404
  exports.AreaRenderContribution = AreaRenderContribution;
27264
26405
  exports.AttributeAnimate = AttributeAnimate;
27265
26406
  exports.AutoEnablePlugins = AutoEnablePlugins;
26407
+ exports.BaseRender = BaseRender;
27266
26408
  exports.Basis = Basis;
27267
26409
  exports.BeforeRenderConstribution = BeforeRenderConstribution;
27268
26410
  exports.BoundsContext = BoundsContext;
@@ -27471,9 +26613,11 @@
27471
26613
  exports.bindContributionProvider = bindContributionProvider;
27472
26614
  exports.bindContributionProviderNoSingletonScope = bindContributionProviderNoSingletonScope;
27473
26615
  exports.boundStroke = boundStroke;
26616
+ exports.builtInSymbolStrMap = builtInSymbolStrMap;
27474
26617
  exports.builtinSymbols = builtinSymbols;
27475
26618
  exports.builtinSymbolsMap = builtinSymbolsMap;
27476
26619
  exports.calcLineCache = calcLineCache$1;
26620
+ exports.calculateLineHeight = calculateLineHeight;
27477
26621
  exports.canvasAllocate = canvasAllocate;
27478
26622
  exports.centroidOfSubpath = centroidOfSubpath;
27479
26623
  exports.circleBounds = circleBounds;
@@ -27617,7 +26761,6 @@
27617
26761
  exports.pointInterpolationHighPerformance = pointInterpolationHighPerformance;
27618
26762
  exports.pointsEqual = pointsEqual;
27619
26763
  exports.pointsInterpolation = pointsInterpolation;
27620
- exports.postConstruct = postConstruct;
27621
26764
  exports.rafBasedSto = rafBasedSto;
27622
26765
  exports.rectFillVisible = rectFillVisible;
27623
26766
  exports.rectStrokeVisible = rectStrokeVisible;