@visactor/vrender 0.19.7 → 0.19.8-beta.2

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/dist/index.js CHANGED
@@ -7224,18 +7224,22 @@
7224
7224
  this[type] = line, line.pathProxy = new CustomPath2D(), root.add(line);
7225
7225
  }
7226
7226
  onStartRect() {
7227
- var _a;
7227
+ var _a, _b, _c;
7228
7228
  const root = this.target.attachShadow(),
7229
- height = this.target.AABBBounds.height(),
7229
+ isHorizontal = null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.isHorizontal) || void 0 === _b || _b,
7230
+ sizeAttr = isHorizontal ? "height" : "width",
7231
+ otherSizeAttr = isHorizontal ? "width" : "height",
7232
+ size = this.target.AABBBounds[sizeAttr](),
7233
+ y = isHorizontal ? 0 : this.target.AABBBounds.y1,
7230
7234
  rect = application.graphicService.creator.rect(Object.assign(Object.assign({
7231
- height: height,
7235
+ [sizeAttr]: size,
7232
7236
  fill: "#bcdeff",
7233
7237
  shadowBlur: 30,
7234
7238
  shadowColor: "#bcdeff"
7235
- }, null === (_a = this.params) || void 0 === _a ? void 0 : _a.attribute), {
7239
+ }, null === (_c = this.params) || void 0 === _c ? void 0 : _c.attribute), {
7236
7240
  x: 0,
7237
- y: 0,
7238
- width: 0
7241
+ y: y,
7242
+ [otherSizeAttr]: 0
7239
7243
  }));
7240
7244
  this.rect = rect, root.add(rect);
7241
7245
  }
@@ -7247,25 +7251,47 @@
7247
7251
  return this.rect ? this.onUpdateRect(end, ratio, out) : this.line || this.area ? this.onUpdateLineOrArea(end, ratio, out) : void 0;
7248
7252
  }
7249
7253
  onUpdateRect(end, ratio, out) {
7250
- var _a, _b, _c, _d, _e, _f;
7251
- const parentWidth = null !== (_a = this.target.attribute.width) && void 0 !== _a ? _a : 250,
7252
- streamLength = null !== (_c = null === (_b = this.params) || void 0 === _b ? void 0 : _b.streamLength) && void 0 !== _c ? _c : parentWidth,
7253
- maxLength = null !== (_f = null === (_e = null === (_d = this.params) || void 0 === _d ? void 0 : _d.attribute) || void 0 === _e ? void 0 : _e.width) && void 0 !== _f ? _f : 60,
7254
- startX = -maxLength,
7255
- currentX = startX + (streamLength - startX) * ratio,
7256
- x = Math.max(currentX, 0),
7257
- w = Math.min(Math.min(currentX + maxLength, maxLength), streamLength - currentX),
7258
- width = w + x > parentWidth ? Math.max(parentWidth - x, 0) : w;
7259
- this.rect.setAttributes({
7260
- x: x,
7261
- width: width
7262
- }, !1, {
7263
- type: exports.AttributeUpdateType.ANIMATE_PLAY,
7264
- animationState: {
7265
- ratio: ratio,
7266
- end: end
7267
- }
7268
- });
7254
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
7255
+ const isHorizontal = null === (_b = null === (_a = this.params) || void 0 === _a ? void 0 : _a.isHorizontal) || void 0 === _b || _b,
7256
+ parentAttr = this.target.attribute;
7257
+ if (isHorizontal) {
7258
+ const parentWidth = null !== (_d = null !== (_c = parentAttr.width) && void 0 !== _c ? _c : parentAttr.x1 - parentAttr.x) && void 0 !== _d ? _d : 250,
7259
+ streamLength = null !== (_f = null === (_e = this.params) || void 0 === _e ? void 0 : _e.streamLength) && void 0 !== _f ? _f : parentWidth,
7260
+ maxLength = null !== (_j = null === (_h = null === (_g = this.params) || void 0 === _g ? void 0 : _g.attribute) || void 0 === _h ? void 0 : _h.width) && void 0 !== _j ? _j : 60,
7261
+ startX = -maxLength,
7262
+ currentX = startX + (streamLength - startX) * ratio,
7263
+ x = Math.max(currentX, 0),
7264
+ w = Math.min(Math.min(currentX + maxLength, maxLength), streamLength - currentX),
7265
+ width = w + x > parentWidth ? Math.max(parentWidth - x, 0) : w;
7266
+ this.rect.setAttributes({
7267
+ x: x,
7268
+ width: width
7269
+ }, !1, {
7270
+ type: exports.AttributeUpdateType.ANIMATE_PLAY,
7271
+ animationState: {
7272
+ ratio: ratio,
7273
+ end: end
7274
+ }
7275
+ });
7276
+ } else {
7277
+ const parentHeight = null !== (_l = null !== (_k = parentAttr.height) && void 0 !== _k ? _k : parentAttr.y1 - parentAttr.y) && void 0 !== _l ? _l : 250,
7278
+ streamLength = null !== (_o = null === (_m = this.params) || void 0 === _m ? void 0 : _m.streamLength) && void 0 !== _o ? _o : parentHeight,
7279
+ maxLength = null !== (_r = null === (_q = null === (_p = this.params) || void 0 === _p ? void 0 : _p.attribute) || void 0 === _q ? void 0 : _q.height) && void 0 !== _r ? _r : 60,
7280
+ currentY = parentHeight - (streamLength + maxLength) * ratio;
7281
+ let y = Math.min(currentY, parentHeight);
7282
+ const h = Math.min(parentHeight - currentY, maxLength);
7283
+ let height;
7284
+ y <= 0 ? (height = Math.max(y + h, 0), y = 0) : height = h, this.rect.setAttributes({
7285
+ y: y,
7286
+ height: height
7287
+ }, !1, {
7288
+ type: exports.AttributeUpdateType.ANIMATE_PLAY,
7289
+ animationState: {
7290
+ ratio: ratio,
7291
+ end: end
7292
+ }
7293
+ });
7294
+ }
7269
7295
  }
7270
7296
  onUpdateLineOrArea(end, ratio, out) {
7271
7297
  const target = this.line || this.area;
@@ -12263,7 +12289,6 @@
12263
12289
  var _a;
12264
12290
  if (!states.length) return void this.clearStates(hasAnimation);
12265
12291
  if (!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) !== states.length || states.some((stateName, index) => this.currentStates[index] !== stateName))) return;
12266
- this.stopStateAnimates();
12267
12292
  const stateAttrs = {},
12268
12293
  subAttrs = this.subGraphic.map(() => ({}));
12269
12294
  states.forEach(stateName => {
@@ -12277,9 +12302,9 @@
12277
12302
  }), this.updateNormalAttrs(stateAttrs), this.currentStates = states, this.applyStateAttrs(stateAttrs, states, hasAnimation);
12278
12303
  }
12279
12304
  clearStates(hasAnimation) {
12280
- this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.subGraphic.forEach(graphic => {
12305
+ this.hasState() && this.normalAttrs && (this.subGraphic.forEach(graphic => {
12281
12306
  graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, !0), graphic.normalAttrs = null;
12282
- }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
12307
+ }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0), this.normalAttrs = null, this.currentStates = []);
12283
12308
  }
12284
12309
  clone() {
12285
12310
  const glyph = new Glyph(Object.assign({}, this.attribute));
@@ -13851,7 +13876,7 @@
13851
13876
  onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
13852
13877
  beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
13853
13878
  afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
13854
- }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds(), this._rectBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._symbolBoundsContribitions = [new DefaultSymbolOuterBorderBoundsContribution()], this._imageBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._circleBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._arcBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._pathBoundsContribitions = [new DefaultOuterBorderBoundsContribution()];
13879
+ }, this.tempAABBBounds1 = new AABBBounds(), this.tempAABBBounds2 = new AABBBounds(), this._rectBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._symbolBoundsContribitions = [new DefaultSymbolOuterBorderBoundsContribution()], this._circleBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._arcBoundsContribitions = [new DefaultOuterBorderBoundsContribution()], this._pathBoundsContribitions = [new DefaultOuterBorderBoundsContribution()];
13855
13880
  }
13856
13881
  onAttributeUpdate(graphic) {
13857
13882
  this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
@@ -14252,9 +14277,7 @@
14252
14277
  }
14253
14278
  const tb1 = this.tempAABBBounds1,
14254
14279
  tb2 = this.tempAABBBounds2;
14255
- return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), this._imageBoundsContribitions.length && this._imageBoundsContribitions.forEach(c => {
14256
- c.updateBounds(attribute, imageTheme, tb1, graphic), aabbBounds.union(tb1), tb1.setValue(tb2.x1, tb2.y1, tb2.x2, tb2.y2);
14257
- }), this.transformAABBBounds(attribute, aabbBounds, imageTheme, !1, graphic), aabbBounds;
14280
+ return tb1.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), tb2.setValue(aabbBounds.x1, aabbBounds.y1, aabbBounds.x2, aabbBounds.y2), this.transformAABBBounds(attribute, aabbBounds, imageTheme, !1, graphic), aabbBounds;
14258
14281
  }
14259
14282
  combindShadowAABBBounds(bounds, graphic) {
14260
14283
  if (graphic && graphic.shadowRoot) {
@@ -15185,6 +15208,70 @@
15185
15208
  return path.closePath(), path;
15186
15209
  }
15187
15210
 
15211
+ class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution {
15212
+ constructor() {
15213
+ super(...arguments), this.time = exports.BaseRenderContributionTime.beforeFillStroke;
15214
+ }
15215
+ drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
15216
+ const {
15217
+ background: background,
15218
+ backgroundMode = graphicAttribute.backgroundMode,
15219
+ backgroundFit = graphicAttribute.backgroundFit
15220
+ } = graphic.attribute;
15221
+ if (background) if (graphic.backgroundImg) {
15222
+ const res = graphic.resources.get(background);
15223
+ if ("success" !== res.state || !res.data) return;
15224
+ if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
15225
+ const groupAttribute = getTheme(graphic.parent).group,
15226
+ {
15227
+ scrollX = groupAttribute.scrollX,
15228
+ scrollY = groupAttribute.scrollY
15229
+ } = graphic.parent.attribute;
15230
+ context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
15231
+ }
15232
+ const b = graphic.AABBBounds;
15233
+ this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
15234
+ } else if (isObject$1(background)) {
15235
+ const {
15236
+ stroke: stroke,
15237
+ fill: fill,
15238
+ lineWidth = 1,
15239
+ cornerRadius = 0,
15240
+ expandX = 0,
15241
+ expandY = 0
15242
+ } = background;
15243
+ if (!stroke && !fill) return;
15244
+ context.beginPath();
15245
+ const {
15246
+ x: x,
15247
+ y: y,
15248
+ width: width,
15249
+ height: height
15250
+ } = getActualPosition(graphic);
15251
+ cornerRadius ? createRectPath(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY), context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth, context.strokeStyle = stroke, context.stroke());
15252
+ } else {
15253
+ context.beginPath();
15254
+ const b = graphic.AABBBounds;
15255
+ context.rect(x, y, b.width(), b.height()), context.fillStyle = background, context.globalAlpha = 1, context.fill();
15256
+ }
15257
+ }
15258
+ }
15259
+ function getActualPosition(graphic) {
15260
+ const boundsPadding = parsePadding(graphic.attribute.boundsPadding),
15261
+ bounds = graphic.AABBBounds;
15262
+ let x = bounds.x1,
15263
+ y = bounds.y1,
15264
+ width = bounds.width(),
15265
+ height = bounds.height();
15266
+ return isNumber$1(boundsPadding) ? (x += boundsPadding, y += boundsPadding, width -= 2 * boundsPadding, height -= 2 * boundsPadding) : (x += boundsPadding[3], y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3], height -= boundsPadding[0] + boundsPadding[2]), {
15267
+ x: x,
15268
+ y: y,
15269
+ width: width,
15270
+ height: height
15271
+ };
15272
+ }
15273
+ const defaultImageBackgroundRenderContribution = new DefaultImageBackgroundRenderContribution();
15274
+
15188
15275
  var __decorate$1D = undefined && undefined.__decorate || function (decorators, target, key, desc) {
15189
15276
  var d,
15190
15277
  c = arguments.length,
@@ -15291,79 +15378,6 @@
15291
15378
  const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;
15292
15379
  const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
15293
15380
 
15294
- class DefaultImageBackgroundRenderContribution extends DefaultBaseBackgroundRenderContribution {
15295
- constructor() {
15296
- super(...arguments), this.time = exports.BaseRenderContributionTime.beforeFillStroke;
15297
- }
15298
- drawShape(graphic, context, x, y, doFill, doStroke, fVisible, sVisible, graphicAttribute, drawContext, fillCb, strokeCb) {
15299
- const {
15300
- background: background,
15301
- backgroundMode = graphicAttribute.backgroundMode,
15302
- backgroundFit = graphicAttribute.backgroundFit
15303
- } = graphic.attribute;
15304
- if (background) if (graphic.backgroundImg) {
15305
- const res = graphic.resources.get(background);
15306
- if ("success" !== res.state || !res.data) return;
15307
- if (context.save(), graphic.parent && !graphic.transMatrix.onlyTranslate()) {
15308
- const groupAttribute = getTheme(graphic.parent).group,
15309
- {
15310
- scrollX = groupAttribute.scrollX,
15311
- scrollY = groupAttribute.scrollY
15312
- } = graphic.parent.attribute;
15313
- context.setTransformFromMatrix(graphic.parent.globalTransMatrix, !0), context.translate(scrollX, scrollY);
15314
- }
15315
- const b = graphic.AABBBounds;
15316
- this.doDrawImage(context, res.data, b, backgroundMode, backgroundFit), context.restore(), graphic.transMatrix.onlyTranslate() || context.setTransformForCurrent();
15317
- } else if (isObject$1(background)) {
15318
- const {
15319
- stroke: stroke,
15320
- fill: fill,
15321
- lineWidth = 1,
15322
- cornerRadius = 0,
15323
- expandX = 0,
15324
- expandY = 0
15325
- } = background;
15326
- if (!stroke && !fill) return;
15327
- context.beginPath();
15328
- const {
15329
- x: x,
15330
- y: y,
15331
- width: width,
15332
- height: height
15333
- } = getActualPosition(graphic);
15334
- cornerRadius ? createRectPath(context, x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY, cornerRadius) : context.rect(x - expandX, y - expandY, width + 2 * expandX, height + 2 * expandY), context.globalAlpha = 1, fill && (context.fillStyle = fill, context.fill()), stroke && lineWidth > 0 && (context.lineWidth = lineWidth, context.strokeStyle = stroke, context.stroke());
15335
- } else {
15336
- context.beginPath();
15337
- const b = graphic.AABBBounds;
15338
- context.rect(x, y, b.width(), b.height()), context.fillStyle = background, context.globalAlpha = 1, context.fill();
15339
- }
15340
- }
15341
- }
15342
- function getActualPosition(graphic) {
15343
- const boundsPadding = parsePadding(graphic.attribute.boundsPadding),
15344
- bounds = graphic.AABBBounds;
15345
- let x = bounds.x1,
15346
- y = bounds.y1,
15347
- width = bounds.width(),
15348
- height = bounds.height();
15349
- return isNumber$1(boundsPadding) ? (x += boundsPadding, y += boundsPadding, width -= 2 * boundsPadding, height -= 2 * boundsPadding) : (x += boundsPadding[3], y += boundsPadding[0], width -= boundsPadding[1] + boundsPadding[3], height -= boundsPadding[0] + boundsPadding[2]), {
15350
- x: x,
15351
- y: y,
15352
- width: width,
15353
- height: height
15354
- };
15355
- }
15356
- class DefaultImageRenderContribution extends DefaultRectRenderContribution {
15357
- constructor() {
15358
- super(...arguments), this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
15359
- }
15360
- drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
15361
- return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
15362
- }
15363
- }
15364
- const defaultImageRenderContribution = new DefaultImageRenderContribution();
15365
- const defaultImageBackgroundRenderContribution = new DefaultImageBackgroundRenderContribution();
15366
-
15367
15381
  class DefaultSymbolRenderContribution {
15368
15382
  constructor() {
15369
15383
  this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -16943,17 +16957,15 @@
16943
16957
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
16944
16958
  exports.DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender {
16945
16959
  constructor(imageRenderContribitions) {
16946
- super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
16960
+ super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
16947
16961
  }
16948
- drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
16962
+ drawShape(image, context, x, y, drawContext, params, fillCb) {
16949
16963
  const imageAttribute = getTheme(image).image,
16950
16964
  {
16951
16965
  width = imageAttribute.width,
16952
16966
  height = imageAttribute.height,
16953
16967
  repeatX = imageAttribute.repeatX,
16954
16968
  repeatY = imageAttribute.repeatY,
16955
- x: originX = imageAttribute.x,
16956
- y: originY = imageAttribute.y,
16957
16969
  cornerRadius = imageAttribute.cornerRadius,
16958
16970
  image: url
16959
16971
  } = image.attribute,
@@ -16978,7 +16990,7 @@
16978
16990
  } else context.drawImage(res.data, x, y, width, height);
16979
16991
  needRestore && context.restore();
16980
16992
  }
16981
- doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke())), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
16993
+ this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
16982
16994
  }
16983
16995
  draw(image, renderService, drawContext) {
16984
16996
  const {
@@ -19014,9 +19026,7 @@
19014
19026
  let _isBrowserEnv;
19015
19027
  function initIsBrowserEnv() {
19016
19028
  if (null == _isBrowserEnv) try {
19017
- const canvas = document.createElement("canvas"),
19018
- ctx = canvas.getContext("2d");
19019
- _isBrowserEnv = !!(window && canvas.getBoundingClientRect && requestAnimationFrame && window.devicePixelRatio && ctx && ctx.isPointInPath && ctx.isPointInStroke), _isBrowserEnv && (_isBrowserEnv = !!document.createElement);
19029
+ _isBrowserEnv = globalThis === window, _isBrowserEnv && (_isBrowserEnv = !!document.createElement);
19020
19030
  } catch (err) {
19021
19031
  _isBrowserEnv = !1;
19022
19032
  }
@@ -28560,7 +28570,7 @@
28560
28570
 
28561
28571
  const roughModule = _roughModule;
28562
28572
 
28563
- const version = "0.19.7";
28573
+ const version = "0.19.8-beta.2";
28564
28574
  preLoadAllModule();
28565
28575
  if (isBrowserEnv()) {
28566
28576
  loadBrowserEnv(container);
@@ -28674,7 +28684,6 @@
28674
28684
  exports.DefaultGroupBackgroundRenderContribution = DefaultGroupBackgroundRenderContribution;
28675
28685
  exports.DefaultImageAttribute = DefaultImageAttribute;
28676
28686
  exports.DefaultImageBackgroundRenderContribution = DefaultImageBackgroundRenderContribution;
28677
- exports.DefaultImageRenderContribution = DefaultImageRenderContribution;
28678
28687
  exports.DefaultLayout = DefaultLayout;
28679
28688
  exports.DefaultLineAllocate = DefaultLineAllocate;
28680
28689
  exports.DefaultLineAttribute = DefaultLineAttribute;
@@ -28940,7 +28949,6 @@
28940
28949
  exports.defaultGraphicMemoryManager = defaultGraphicMemoryManager;
28941
28950
  exports.defaultGroupBackgroundRenderContribution = defaultGroupBackgroundRenderContribution;
28942
28951
  exports.defaultImageBackgroundRenderContribution = defaultImageBackgroundRenderContribution;
28943
- exports.defaultImageRenderContribution = defaultImageRenderContribution;
28944
28952
  exports.defaultLineAllocate = defaultLineAllocate;
28945
28953
  exports.defaultPathAllocate = defaultPathAllocate;
28946
28954
  exports.defaultRectAllocate = defaultRectAllocate;