@visactor/vrender 0.22.0-vstory.12 → 0.22.0-vstory.15

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.
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import '@visactor/vrender-core';
2
- export declare const version = "0.22.0-vstory.12";
2
+ export declare const version = "0.22.0-vstory.15";
3
3
  export * from '@visactor/vrender-core';
4
4
  export * from '@visactor/vrender-kits';
package/cjs/index.js CHANGED
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "__esModule", {
21
21
 
22
22
  const vrender_core_1 = require("@visactor/vrender-core"), vrender_kits_1 = require("@visactor/vrender-kits"), vrender_kits_2 = require("@visactor/vrender-kits");
23
23
 
24
- exports.version = "0.22.0-vstory.12", (0, vrender_core_1.preLoadAllModule)(), (0,
24
+ exports.version = "0.22.0-vstory.15", (0, vrender_core_1.preLoadAllModule)(), (0,
25
25
  vrender_core_1.isBrowserEnv)() ? (0, vrender_kits_1.loadBrowserEnv)(vrender_core_1.container) : (0,
26
26
  vrender_core_1.isNodeEnv)() && (0, vrender_kits_1.loadNodeEnv)(vrender_core_1.container),
27
27
  (0, vrender_kits_2.registerArc)(), (0, vrender_kits_2.registerArc3d)(), (0, vrender_kits_2.registerArea)(),
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAqE;AACrE,yDAmBgC;AAEnB,QAAA,OAAO,GAAG,kBAAkB,CAAC;AAE1C,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AACtB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\n// 导出版本号\nexport const version = \"0.22.0-vstory.12\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kCAAgC;AAChC,yDAWgC;AAChC,yDAAqE;AACrE,yDAmBgC;AAEnB,QAAA,OAAO,GAAG,kBAAkB,CAAC;AAE1C,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAI,IAAA,2BAAY,GAAE,EAAE;IAClB,IAAA,6BAAc,EAAC,wBAAS,CAAC,CAAC;CAC3B;KAAM,IAAI,IAAA,wBAAS,GAAE,EAAE;IACtB,IAAA,0BAAW,EAAC,wBAAS,CAAC,CAAC;CACxB;AACD,IAAA,0BAAW,GAAE,CAAC;AACd,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,4BAAa,GAAE,CAAC;AAChB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,8BAAe,GAAE,CAAC;AAClB,IAAA,gCAAiB,GAAE,CAAC;AACpB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,+BAAgB,GAAE,CAAC;AACnB,IAAA,iCAAkB,GAAE,CAAC;AACrB,IAAA,6BAAc,GAAE,CAAC;AACjB,IAAA,2BAAY,GAAE,CAAC;AACf,IAAA,+BAAgB,GAAE,CAAC;AAEnB,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,4CAA6B,GAAE,CAAC;AAChC,IAAA,0CAA2B,GAAE,CAAC;AAC9B,IAAA,2CAA4B,GAAE,CAAC;AAC/B,IAAA,uCAAwB,GAAE,CAAC;AAC3B,IAAA,kCAAmB,GAAE,CAAC;AACtB,yDAAuC;AACvC,yDAAuC","file":"index.js","sourcesContent":["import '@visactor/vrender-core';\nimport {\n container,\n isBrowserEnv,\n isNodeEnv,\n preLoadAllModule,\n registerFlexLayoutPlugin,\n registerViewTransform3dPlugin,\n registerHtmlAttributePlugin,\n registerReactAttributePlugin,\n registerDirectionalLight,\n registerOrthoCamera\n} from '@visactor/vrender-core';\nimport { loadBrowserEnv, loadNodeEnv } from '@visactor/vrender-kits';\nimport {\n registerArc,\n registerArc3d,\n registerArea,\n registerCircle,\n registerGlyph,\n registerGroup,\n registerImage,\n registerLine,\n registerPath,\n registerPolygon,\n registerPyramid3d,\n registerRect,\n registerRect3d,\n registerRichtext,\n registerShadowRoot,\n registerSymbol,\n registerText,\n registerWrapText\n} from '@visactor/vrender-kits';\n// 导出版本号\nexport const version = \"0.22.0-vstory.15\";\n\npreLoadAllModule();\n\nif (isBrowserEnv()) {\n loadBrowserEnv(container);\n} else if (isNodeEnv()) {\n loadNodeEnv(container);\n}\nregisterArc();\nregisterArc3d();\nregisterArea();\nregisterCircle();\nregisterGlyph();\nregisterGroup();\nregisterImage();\nregisterLine();\nregisterPath();\nregisterPolygon();\nregisterPyramid3d();\nregisterRect();\nregisterRect3d();\nregisterRichtext();\nregisterShadowRoot();\nregisterSymbol();\nregisterText();\nregisterWrapText();\n\nregisterFlexLayoutPlugin();\nregisterViewTransform3dPlugin();\nregisterHtmlAttributePlugin();\nregisterReactAttributePlugin();\nregisterDirectionalLight();\nregisterOrthoCamera();\nexport * from '@visactor/vrender-core';\nexport * from '@visactor/vrender-kits';\n"]}
package/dist/index.es.js CHANGED
@@ -431,12 +431,15 @@ class Container {
431
431
  serviceIdentifier: injectIdentifier,
432
432
  constructorArgsMetadata: constructorArgsMetadata
433
433
  },
434
- request = {
434
+ bindings = (this._bindingDictionary.get(injectIdentifier) || []).filter(b => b.constraint(target));
435
+ if (bindings.length) {
436
+ const request = {
435
437
  injectIdentifier: injectIdentifier,
436
438
  metadata: constructorArgsMetadata,
437
- bindings: this._bindingDictionary.get(injectIdentifier).filter(b => b.constraint(target))
439
+ bindings: bindings
438
440
  };
439
- arr.push(request);
441
+ arr.push(request);
442
+ }
440
443
  }
441
444
  return arr;
442
445
  }
@@ -2491,6 +2494,8 @@ class Color {
2491
2494
  return color.getLuminance2();
2492
2495
  case "lum3":
2493
2496
  return color.getLuminance3();
2497
+ case "wcag":
2498
+ return color.getLuminanceWCAG();
2494
2499
  }
2495
2500
  }
2496
2501
  static parseColorString(value) {
@@ -2592,6 +2597,14 @@ class Color {
2592
2597
  getLuminance3() {
2593
2598
  return (.299 * this.color.r + .587 * this.color.g + .114 * this.color.b) / 255;
2594
2599
  }
2600
+ getLuminanceWCAG() {
2601
+ const RsRGB = this.color.r / 255,
2602
+ GsRGB = this.color.g / 255,
2603
+ BsRGB = this.color.b / 255;
2604
+ let R, G, B;
2605
+ R = RsRGB <= .03928 ? RsRGB / 12.92 : Math.pow((RsRGB + .055) / 1.055, 2.4), G = GsRGB <= .03928 ? GsRGB / 12.92 : Math.pow((GsRGB + .055) / 1.055, 2.4), B = BsRGB <= .03928 ? BsRGB / 12.92 : Math.pow((BsRGB + .055) / 1.055, 2.4);
2606
+ return .2126 * R + .7152 * G + .0722 * B;
2607
+ }
2595
2608
  clone() {
2596
2609
  return new Color(this.color.toString());
2597
2610
  }
@@ -4146,6 +4159,7 @@ const DefaultStyle = Object.assign(Object.assign(Object.assign(Object.assign({
4146
4159
  texturePadding: 2,
4147
4160
  backgroundMode: "no-repeat",
4148
4161
  backgroundFit: !0,
4162
+ backgroundKeepAspectRatio: !1,
4149
4163
  backgroundClip: !0,
4150
4164
  backgroundScale: 1,
4151
4165
  backgroundOffsetX: 0,
@@ -4784,6 +4798,9 @@ let ATextMeasure = class {
4784
4798
  }
4785
4799
  compatibleMetrics(metrics, options) {
4786
4800
  if (null == metrics.actualBoundingBoxAscent || null == metrics.actualBoundingBoxDescent || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent) {
4801
+ metrics = {
4802
+ width: metrics.width
4803
+ };
4787
4804
  const {
4788
4805
  ascent: ascent,
4789
4806
  descent: descent
@@ -4791,6 +4808,13 @@ let ATextMeasure = class {
4791
4808
  metrics.actualBoundingBoxAscent = ascent, metrics.actualBoundingBoxDescent = descent, metrics.fontBoundingBoxAscent = ascent, metrics.fontBoundingBoxDescent = descent;
4792
4809
  }
4793
4810
  if (null == metrics.actualBoundingBoxLeft || null == metrics.actualBoundingBoxRight) {
4811
+ metrics = {
4812
+ width: metrics.width,
4813
+ actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
4814
+ actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
4815
+ fontBoundingBoxAscent: metrics.fontBoundingBoxAscent,
4816
+ fontBoundingBoxDescent: metrics.fontBoundingBoxDescent
4817
+ };
4794
4818
  const {
4795
4819
  left: left,
4796
4820
  right: right
@@ -14307,6 +14331,12 @@ class Wrapper {
14307
14331
  }
14308
14332
  }
14309
14333
 
14334
+ let supportIntl = !1;
14335
+ try {
14336
+ supportIntl = Intl && "function" == typeof Intl.Segmenter;
14337
+ } catch (e) {
14338
+ supportIntl = !1;
14339
+ }
14310
14340
  const RICHTEXT_UPDATE_TAG_KEY = ["width", "height", "ellipsis", "wordBreak", "verticalDirection", "maxHeight", "maxWidth", "textAlign", "textBaseline", "textConfig", "layoutDirection", "fill", "stroke", "fontSize", "fontFamily", "fontStyle", "fontWeight", "lineWidth", "opacity", "fillOpacity", "strokeOpacity", ...GRAPHIC_UPDATE_TAG_KEY];
14311
14341
  class RichText extends Graphic {
14312
14342
  constructor(params) {
@@ -14396,6 +14426,16 @@ class RichText extends Graphic {
14396
14426
  return cache.every(item => item.isComposing || !(item.text && isString$1(item.text) && RichText.splitText(item.text).length > 1));
14397
14427
  }
14398
14428
  static splitText(text) {
14429
+ if (supportIntl) {
14430
+ const segmenter = new Intl.Segmenter(void 0, {
14431
+ granularity: "grapheme"
14432
+ }),
14433
+ segments = [];
14434
+ for (const {
14435
+ segment: segment
14436
+ } of segmenter.segment(text)) segments.push(segment);
14437
+ return segments;
14438
+ }
14399
14439
  return Array.from(text);
14400
14440
  }
14401
14441
  static TransformTextConfig2SingleCharacter(textConfig) {
@@ -14411,14 +14451,14 @@ class RichText extends Graphic {
14411
14451
  }), tc;
14412
14452
  }
14413
14453
  updateAABBBounds(attribute, richtextTheme, aabbBounds) {
14414
- var _a, _b;
14454
+ var _a, _b, _c, _d;
14415
14455
  const {
14416
14456
  width = richtextTheme.width,
14417
14457
  height = richtextTheme.height,
14418
14458
  maxWidth = richtextTheme.maxWidth,
14419
14459
  maxHeight = richtextTheme.maxHeight,
14420
14460
  textAlign = richtextTheme.textAlign,
14421
- textBaseline = richtextTheme.textBaseline,
14461
+ verticalDirection = null !== (_b = null !== (_a = attribute.textBaseline) && void 0 !== _a ? _a : richtextTheme.textBaseline) && void 0 !== _b ? _b : richtextTheme.verticalDirection,
14422
14462
  editOptions: editOptions
14423
14463
  } = attribute;
14424
14464
  if (width > 0 && height > 0) aabbBounds.set(0, 0, width, height);else {
@@ -14431,9 +14471,9 @@ class RichText extends Graphic {
14431
14471
  contentHeight = height || actualHeight || 0;
14432
14472
  contentHeight = "number" == typeof maxHeight && contentHeight > maxHeight ? maxHeight : contentHeight || 0, contentWidth = "number" == typeof maxWidth && contentWidth > maxWidth ? maxWidth : contentWidth || 0, aabbBounds.set(0, 0, contentWidth, contentHeight);
14433
14473
  }
14434
- editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !(null === (_a = attribute.textConfig) || void 0 === _a ? void 0 : _a.length) && (aabbBounds.y2 = aabbBounds.y1 + (null !== (_b = attribute.fontSize) && void 0 !== _b ? _b : 12), aabbBounds.x2 = aabbBounds.x1 + 2);
14474
+ editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !(null === (_c = attribute.textConfig) || void 0 === _c ? void 0 : _c.length) && (aabbBounds.y2 = aabbBounds.y1 + (null !== (_d = attribute.fontSize) && void 0 !== _d ? _d : 12), aabbBounds.x2 = aabbBounds.x1 + 2);
14435
14475
  let deltaY = 0;
14436
- switch (textBaseline) {
14476
+ switch (verticalDirection) {
14437
14477
  case "top":
14438
14478
  deltaY = 0;
14439
14479
  break;
@@ -14454,7 +14494,7 @@ class RichText extends Graphic {
14454
14494
  case "right":
14455
14495
  deltaX = -aabbBounds.width();
14456
14496
  }
14457
- return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), aabbBounds;
14497
+ return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds), application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this), 0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
14458
14498
  }
14459
14499
  needUpdateTags(keys) {
14460
14500
  return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);
@@ -15437,6 +15477,7 @@ class DefaultBaseBackgroundRenderContribution {
15437
15477
  opacity = graphicAttribute.opacity,
15438
15478
  backgroundMode = graphicAttribute.backgroundMode,
15439
15479
  backgroundFit = graphicAttribute.backgroundFit,
15480
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15440
15481
  backgroundScale = graphicAttribute.backgroundScale,
15441
15482
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15442
15483
  backgroundOffsetY = graphicAttribute.backgroundOffsetY,
@@ -15458,6 +15499,7 @@ class DefaultBaseBackgroundRenderContribution {
15458
15499
  context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), context.globalAlpha = backgroundOpacity * opacity, this.doDrawImage(context, res.data, b, {
15459
15500
  backgroundMode: backgroundMode,
15460
15501
  backgroundFit: backgroundFit,
15502
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15461
15503
  backgroundScale: backgroundScale,
15462
15504
  backgroundOffsetX: backgroundOffsetX,
15463
15505
  backgroundOffsetY: backgroundOffsetY
@@ -15468,6 +15510,7 @@ class DefaultBaseBackgroundRenderContribution {
15468
15510
  const {
15469
15511
  backgroundMode: backgroundMode,
15470
15512
  backgroundFit: backgroundFit,
15513
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15471
15514
  backgroundScale = 1,
15472
15515
  backgroundOffsetX = 0,
15473
15516
  backgroundOffsetY = 0
@@ -15477,7 +15520,12 @@ class DefaultBaseBackgroundRenderContribution {
15477
15520
  let w = targetW,
15478
15521
  h = targetH;
15479
15522
  if ("no-repeat" === backgroundMode) {
15480
- if (backgroundFit) context.drawImage(data, b.x1, b.y1, b.width(), b.height());else {
15523
+ if (backgroundFit) {
15524
+ if (backgroundKeepAspectRatio) {
15525
+ const maxScale = Math.max(targetW / data.width, targetH / data.height);
15526
+ context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, data.width * maxScale * backgroundScale, data.height * maxScale * backgroundScale);
15527
+ } else context.drawImage(data, b.x1, b.y1, b.width(), b.height());
15528
+ } else {
15481
15529
  const resW = data.width * backgroundScale,
15482
15530
  resH = data.height * backgroundScale;
15483
15531
  context.drawImage(data, b.x1 + backgroundOffsetX, b.y1 + backgroundOffsetY, resW, resH);
@@ -15783,6 +15831,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
15783
15831
  background: background,
15784
15832
  backgroundMode = graphicAttribute.backgroundMode,
15785
15833
  backgroundFit = graphicAttribute.backgroundFit,
15834
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio,
15786
15835
  backgroundScale = graphicAttribute.backgroundScale,
15787
15836
  backgroundOffsetX = graphicAttribute.backgroundOffsetX,
15788
15837
  backgroundOffsetY = graphicAttribute.backgroundOffsetY
@@ -15795,6 +15844,7 @@ class DefaultGroupBackgroundRenderContribution extends DefaultBaseBackgroundRend
15795
15844
  this.doDrawImage(context, res.data, b, {
15796
15845
  backgroundMode: backgroundMode,
15797
15846
  backgroundFit: backgroundFit,
15847
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio,
15798
15848
  backgroundScale: backgroundScale,
15799
15849
  backgroundOffsetX: backgroundOffsetX,
15800
15850
  backgroundOffsetY: backgroundOffsetY
@@ -17125,7 +17175,8 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
17125
17175
  var _a, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17126
17176
  const {
17127
17177
  backgroundMode = graphicAttribute.backgroundMode,
17128
- backgroundFit = graphicAttribute.backgroundFit
17178
+ backgroundFit = graphicAttribute.backgroundFit,
17179
+ backgroundKeepAspectRatio = graphicAttribute.backgroundKeepAspectRatio
17129
17180
  } = graphic.attribute;
17130
17181
  let matrix,
17131
17182
  {
@@ -17164,7 +17215,8 @@ class DefaultTextBackgroundRenderContribution extends DefaultBaseBackgroundRende
17164
17215
  if ("success" !== res.state || !res.data) return void restore();
17165
17216
  context.highPerformanceSave(), onlyTranslate && context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.setCommonStyle(graphic, graphic.attribute, x, y, graphicAttribute), this.doDrawImage(context, res.data, b, {
17166
17217
  backgroundMode: backgroundMode,
17167
- backgroundFit: backgroundFit
17218
+ backgroundFit: backgroundFit,
17219
+ backgroundKeepAspectRatio: backgroundKeepAspectRatio
17168
17220
  }), context.highPerformanceRestore(), context.setTransformForCurrent();
17169
17221
  } else {
17170
17222
  const {
@@ -18299,7 +18351,7 @@ var __decorate$1l = undefined && undefined.__decorate || function (decorators, t
18299
18351
  };
18300
18352
  let DefaultDrawContribution = class {
18301
18353
  constructor(contributions, drawItemInterceptorContributions) {
18302
- this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, this.init();
18354
+ this.contributions = contributions, this.drawItemInterceptorContributions = drawItemInterceptorContributions, this.currentRenderMap = new Map(), this.defaultRenderMap = new Map(), this.styleRenderMap = new Map(), this.dirtyBounds = new Bounds(), this.backupDirtyBounds = new Bounds(), this.global = application.global, this.layerService = application.layerService, isArray$1(this.contributions) || (this.contributions = [this.contributions]), this.init();
18303
18355
  }
18304
18356
  init() {
18305
18357
  this.contributions.forEach(item => {
@@ -20342,10 +20394,11 @@ class EditModule {
20342
20394
  textAreaDom.setAttribute("style", "width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;"), textAreaDom.addEventListener("input", this.handleInput), textAreaDom.addEventListener("compositionstart", this.handleCompositionStart), textAreaDom.addEventListener("compositionend", this.handleCompositionEnd), textAreaDom.addEventListener("focusin", this.handleFocusIn), textAreaDom.addEventListener("focusout", this.handleFocusOut), application.global.addEventListener("keydown", this.handleKeyDown);
20343
20395
  }
20344
20396
  parseCompositionStr(configIdx) {
20397
+ var _a;
20345
20398
  const {
20346
20399
  textConfig = []
20347
20400
  } = this.currRt.attribute,
20348
- lastConfig = textConfig[configIdx];
20401
+ lastConfig = null !== (_a = textConfig[configIdx]) && void 0 !== _a ? _a : {};
20349
20402
  textConfig.splice(configIdx, 1);
20350
20403
  const text = lastConfig.text,
20351
20404
  textList = text ? Array.from(text.toString()) : [];
@@ -20402,15 +20455,18 @@ class Selection {
20402
20455
  return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
20403
20456
  }
20404
20457
  getFormat(key) {
20405
- return this.getAllFormat(key)[0];
20458
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20459
+ return this.getAllFormat(key, supportOutAttr)[0];
20406
20460
  }
20407
20461
  getAllFormat(key) {
20462
+ let supportOutAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
20463
+ var _a, _b, _c, _d;
20408
20464
  const valSet = new Set(),
20409
20465
  minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx),
20410
20466
  maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
20411
- if (minCursorIdx === maxCursorIdx) return [this._getFormat(key, minCursorIdx)];
20467
+ if (minCursorIdx === maxCursorIdx) return supportOutAttr ? [null !== (_a = this._getFormat(key, minCursorIdx)) && void 0 !== _a ? _a : (null === (_b = this.rt) || void 0 === _b ? void 0 : _b.attribute)[key]] : [this._getFormat(key, minCursorIdx)];
20412
20468
  for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
20413
- const val = this._getFormat(key, i);
20469
+ const val = supportOutAttr ? null !== (_c = this._getFormat(key, i)) && void 0 !== _c ? _c : (null === (_d = this.rt) || void 0 === _d ? void 0 : _d.attribute)[key] : this._getFormat(key, i);
20414
20470
  val && valSet.add(val);
20415
20471
  }
20416
20472
  return Array.from(valSet.values());
@@ -20458,7 +20514,7 @@ class RichTextEditPlugin {
20458
20514
  const config = rt.attribute.textConfig;
20459
20515
  this._formatTextCommand(payload, config, rt);
20460
20516
  }, this.handleKeyDown = e => {
20461
- this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
20517
+ this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelectionKeyHandler(e) || this.directKeyHandler(e));
20462
20518
  }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
20463
20519
  this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(), this.updateCbs.forEach(cb => cb("input", this)));
20464
20520
  }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
@@ -20471,7 +20527,9 @@ class RichTextEditPlugin {
20471
20527
  }, this.handleFocusOut = () => {
20472
20528
  throw new Error("不会走到这里 handleFocusOut");
20473
20529
  }, this.handleMove = e => {
20474
- this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave), this.tryShowSelection(e, !1));
20530
+ this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave, {
20531
+ capture: !0
20532
+ }), this.tryShowSelection(e, !1));
20475
20533
  }, this.handleEnter = e => {
20476
20534
  this.editing = !0, this.pluginService.stage.setCursor("text");
20477
20535
  }, this.handleLeave = e => {
@@ -20510,7 +20568,17 @@ class RichTextEditPlugin {
20510
20568
  idx > -1 && cbs.splice(idx, 1);
20511
20569
  }
20512
20570
  activate(context) {
20513
- this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove), context.stage.on("pointerdown", this.handlePointerDown), context.stage.on("pointerup", this.handlePointerUp), context.stage.on("pointerleave", this.handlePointerUp), context.stage.on("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20571
+ this.pluginService = context, this.editModule = new EditModule(), context.stage.on("pointermove", this.handleMove, {
20572
+ capture: !0
20573
+ }), context.stage.on("pointerdown", this.handlePointerDown, {
20574
+ capture: !0
20575
+ }), context.stage.on("pointerup", this.handlePointerUp, {
20576
+ capture: !0
20577
+ }), context.stage.on("pointerleave", this.handlePointerUp, {
20578
+ capture: !0
20579
+ }), context.stage.on("dblclick", this.handleDBLClick, {
20580
+ capture: !0
20581
+ }), application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
20514
20582
  }
20515
20583
  copyToClipboard(e) {
20516
20584
  if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
@@ -20544,21 +20612,22 @@ class RichTextEditPlugin {
20544
20612
  const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
20545
20613
  this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
20546
20614
  }
20547
- fullSelection(e) {
20548
- if (application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) {
20549
- const currRt = this.currRt;
20550
- if (!currRt) return;
20551
- const cache = currRt.getFrameCache();
20552
- if (!cache) return;
20553
- const {
20554
- lines: lines
20555
- } = cache,
20556
- totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20557
- return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
20558
- }
20559
- return !1;
20615
+ fullSelection() {
20616
+ const currRt = this.currRt;
20617
+ if (!currRt) return;
20618
+ const cache = currRt.getFrameCache();
20619
+ if (!cache) return;
20620
+ const {
20621
+ lines: lines
20622
+ } = cache;
20623
+ if (!lines.length || !lines[0].paragraphs.length) return;
20624
+ const totalCursorCount = lines.reduce((total, line) => total + line.paragraphs.length, 0) - 1;
20625
+ this.selectionRange(-.1, totalCursorCount + .1);
20626
+ }
20627
+ fullSelectionKeyHandler(e) {
20628
+ return !!(application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) && (this.fullSelection(), e.preventDefault(), !0);
20560
20629
  }
20561
- directKey(e) {
20630
+ directKeyHandler(e) {
20562
20631
  if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
20563
20632
  const cache = this.currRt.getFrameCache();
20564
20633
  if (!cache) return !1;
@@ -20611,7 +20680,7 @@ class RichTextEditPlugin {
20611
20680
  }
20612
20681
  const {
20613
20682
  textConfig: textConfig,
20614
- editOptions: editOptions
20683
+ editOptions = {}
20615
20684
  } = this.currRt.attribute;
20616
20685
  if (textConfig && textConfig.length) return;
20617
20686
  if (!editOptions || !editOptions.placeholder) return;
@@ -20628,11 +20697,23 @@ class RichTextEditPlugin {
20628
20697
  placeholderColor && (textConfigItem.fill = placeholderColor), placeholderFontFamily && (textConfigItem.fontFamily = placeholderFontFamily), placeholderFontSize && (textConfigItem.fontSize = placeholderFontSize), this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
20629
20698
  x: 0,
20630
20699
  y: 0,
20700
+ dx: -this.deltaX,
20701
+ dy: -this.deltaY,
20631
20702
  angle: 0,
20632
- _debug_bounds: !1,
20633
20703
  textConfig: [textConfigItem]
20634
20704
  })), shadow.add(this.shadowPlaceHolder);
20635
20705
  }
20706
+ getRichTextAABBBounds(rt) {
20707
+ const {
20708
+ attribute: attribute
20709
+ } = rt;
20710
+ return attribute.textConfig.length ? rt.AABBBounds : getRichTextBounds(Object.assign(Object.assign({}, this.shadowPlaceHolder.attribute), {
20711
+ x: attribute.x,
20712
+ y: attribute.y,
20713
+ textAlign: attribute.textAlign,
20714
+ boundsMode: "accurate"
20715
+ }));
20716
+ }
20636
20717
  tryShowInputBounds() {
20637
20718
  if (!this.currRt || !this.focusing) return;
20638
20719
  const {
@@ -20642,28 +20723,20 @@ class RichTextEditPlugin {
20642
20723
  boundsStrokeWhenInput: boundsStrokeWhenInput
20643
20724
  } = editOptions;
20644
20725
  if (!editOptions || !boundsStrokeWhenInput) return;
20645
- const {
20646
- attribute: attribute
20647
- } = this.currRt,
20648
- b = this.currRt.AABBBounds;
20649
- let h = b.height();
20650
- if (!attribute.textConfig.length && this.editLine) {
20651
- const {
20652
- points: points
20653
- } = this.editLine.attribute;
20654
- h = points[1].y - points[0].y;
20655
- }
20726
+ const b = this.getRichTextAABBBounds(this.currRt),
20727
+ height = b.height(),
20728
+ width = b.width();
20656
20729
  this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
20657
20730
  x: 0,
20658
20731
  y: 0,
20659
- width: b.width(),
20660
- height: h,
20732
+ width: width,
20733
+ height: height,
20661
20734
  fill: !1,
20662
20735
  stroke: boundsStrokeWhenInput,
20663
20736
  lineWidth: 1,
20664
20737
  zIndex: -1
20665
20738
  });
20666
- this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
20739
+ this.getShadow(this.currRt).add(this.shadowBounds), this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot();
20667
20740
  }
20668
20741
  trySyncPlaceholderToTextConfig() {
20669
20742
  if (!this.currRt) return;
@@ -20672,7 +20745,7 @@ class RichTextEditPlugin {
20672
20745
  editOptions: editOptions
20673
20746
  } = this.currRt.attribute;
20674
20747
  if (textConfig && textConfig.length) return;
20675
- if (!editOptions || !editOptions.placeholder) return;
20748
+ if (!(editOptions && editOptions.placeholder && editOptions.syncPlaceholderToTextConfig)) return;
20676
20749
  const {
20677
20750
  placeholder: placeholder
20678
20751
  } = editOptions;
@@ -20683,7 +20756,20 @@ class RichTextEditPlugin {
20683
20756
  });
20684
20757
  }
20685
20758
  deactivate(context) {
20686
- context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown), context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp), context.stage.off("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown);
20759
+ context.stage.off("pointermove", this.handleMove, {
20760
+ capture: !0
20761
+ }), context.stage.off("pointerdown", this.handlePointerDown, {
20762
+ capture: !0
20763
+ }), context.stage.off("pointerup", this.handlePointerUp, {
20764
+ capture: !0
20765
+ }), context.stage.off("pointerleave", this.handlePointerUp, {
20766
+ capture: !0
20767
+ }), context.stage.off("dblclick", this.handleDBLClick, {
20768
+ capture: !0
20769
+ }), application.global.addEventListener("keydown", this.handleKeyDown);
20770
+ }
20771
+ stopPropagation(e) {
20772
+ e.stopPropagation();
20687
20773
  }
20688
20774
  onFocus(e, data) {
20689
20775
  this.updateCbs && this.updateCbs.forEach(cb => cb("beforeOnfocus", this)), this.deFocus(!1), this.focusing = !0;
@@ -20692,54 +20778,66 @@ class RichTextEditPlugin {
20692
20778
  this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
20693
20779
  const shadowRoot = this.getShadow(target),
20694
20780
  cache = target.getFrameCache();
20695
- if (cache) {
20696
- if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20697
- shadowRootIdx: 1,
20698
- pickable: !1,
20699
- x: this.deltaX,
20700
- y: this.deltaY
20701
- }), !this.editLine) {
20702
- const line = createLine({
20703
- x: 0,
20704
- y: 0,
20705
- lineWidth: 1,
20706
- stroke: "black"
20707
- });
20708
- this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20709
- const g = createGroup({
20710
- x: 0,
20711
- y: 0,
20712
- width: 0,
20713
- height: 0
20714
- });
20715
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20716
- }
20717
- if (data = data || this.computedCursorPosByEvent(e, cache)) {
20718
- const {
20719
- x: x,
20720
- y1: y1,
20721
- y2: y2,
20722
- cursorIndex: cursorIndex
20723
- } = data;
20724
- this.startCursorPos = {
20725
- x: x,
20726
- y: (y1 + y2) / 2
20727
- }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20728
- } else {
20729
- const x = 0,
20730
- y1 = 0,
20731
- y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20732
- textConfig: [{
20733
- text: "a"
20734
- }]
20735
- })).height();
20736
- this.startCursorPos = {
20737
- x: x,
20738
- y: (y1 + y2) / 2
20739
- }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20740
- }
20741
- this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20781
+ if (!cache) return;
20782
+ const {
20783
+ editOptions = {}
20784
+ } = this.currRt.attribute;
20785
+ if (editOptions.stopPropagation && target.addEventListener("*", this.stopPropagation), this.offsetShadowRoot(target), !this.editLine) {
20786
+ const line = createLine({
20787
+ x: 0,
20788
+ y: 0,
20789
+ lineWidth: 1,
20790
+ stroke: "black"
20791
+ });
20792
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
20793
+ const g = createGroup({
20794
+ x: 0,
20795
+ y: 0,
20796
+ width: 0,
20797
+ height: 0
20798
+ });
20799
+ this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
20800
+ }
20801
+ if (data = data || this.computedCursorPosByEvent(e, cache)) {
20802
+ const {
20803
+ x: x,
20804
+ y1: y1,
20805
+ y2: y2,
20806
+ cursorIndex: cursorIndex
20807
+ } = data;
20808
+ this.startCursorPos = {
20809
+ x: x,
20810
+ y: (y1 + y2) / 2
20811
+ }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1, y2, target);
20812
+ } else {
20813
+ const x = 0,
20814
+ y1 = 0,
20815
+ y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
20816
+ textConfig: [{
20817
+ text: "a"
20818
+ }]
20819
+ })).height();
20820
+ this.startCursorPos = {
20821
+ x: x,
20822
+ y: (y1 + y2) / 2
20823
+ }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
20742
20824
  }
20825
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
20826
+ }
20827
+ offsetShadowRoot(rt) {
20828
+ if (!(rt = rt || this.currRt)) return;
20829
+ const shadowRoot = this.getShadow(rt);
20830
+ if (!shadowRoot) return;
20831
+ const cache = rt.getFrameCache();
20832
+ cache && (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
20833
+ shadowRootIdx: 1,
20834
+ pickable: !1,
20835
+ x: this.deltaX,
20836
+ y: this.deltaY
20837
+ }), this.shadowPlaceHolder && this.shadowPlaceHolder.setAttributes({
20838
+ dx: -this.deltaX,
20839
+ dy: -this.deltaY
20840
+ }));
20743
20841
  }
20744
20842
  offsetLineBgAndShadowBounds() {
20745
20843
  const rt = this.currRt,
@@ -20768,7 +20866,10 @@ class RichTextEditPlugin {
20768
20866
  }));
20769
20867
  const target = this.currRt;
20770
20868
  if (!target) return;
20771
- trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20869
+ const {
20870
+ editOptions = {}
20871
+ } = target.attribute;
20872
+ editOptions.stopPropagation && target.removeEventListener("*", this.stopPropagation), trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
20772
20873
  const currRt = this.currRt;
20773
20874
  this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine), this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg), this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds), this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder), this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
20774
20875
  const textConfig = currRt.attribute.textConfig;
@@ -20929,7 +21030,7 @@ class RichTextEditPlugin {
20929
21030
  this.pluginService.stage.renderNextFrame();
20930
21031
  }
20931
21032
  computeGlobalDelta(cache) {
20932
- this.deltaX = 0, this.deltaY = 0;
21033
+ this.deltaX = 0, this.deltaY = 0, 0 === cache.lines.length && this.shadowPlaceHolder && (cache = this.shadowPlaceHolder.getFrameCache());
20933
21034
  const height = cache.height,
20934
21035
  actualHeight = cache.actualHeight,
20935
21036
  width = cache.lines.reduce((w, item) => Math.max(w, item.actualWidth), 0);
@@ -20976,7 +21077,7 @@ class RichTextEditPlugin {
20976
21077
  left: left,
20977
21078
  top: top
20978
21079
  } = this.pluginService.stage.window.getBoundingClientRect();
20979
- out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
21080
+ out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.offsetShadowRoot(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
20980
21081
  }
20981
21082
  computedCursorPosByEvent(e, cache) {
20982
21083
  const p1 = this.getEventPosition(e),
@@ -26333,6 +26434,7 @@ class PickerBase {
26333
26434
  contains(graphic, point, params) {
26334
26435
  if (!graphic.AABBBounds.containsPoint(point)) return !1;
26335
26436
  if ("imprecise" === graphic.attribute.pickMode) return !0;
26437
+ if (!this.canvasRenderer) return !0;
26336
26438
  const {
26337
26439
  pickContext: pickContext
26338
26440
  } = null != params ? params : {};
@@ -31135,7 +31237,7 @@ const registerWrapText = _registerWrapText;
31135
31237
 
31136
31238
  const roughModule = _roughModule;
31137
31239
 
31138
- const version = "0.22.0-vstory.12";
31240
+ const version = "0.22.0-vstory.15";
31139
31241
  preLoadAllModule();
31140
31242
  if (isBrowserEnv()) {
31141
31243
  loadBrowserEnv(container);