@visactor/vrender 0.19.8-beta.3 → 0.19.8

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,22 +7224,18 @@
7224
7224
  this[type] = line, line.pathProxy = new CustomPath2D(), root.add(line);
7225
7225
  }
7226
7226
  onStartRect() {
7227
- var _a, _b, _c;
7227
+ var _a;
7228
7228
  const root = this.target.attachShadow(),
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,
7229
+ height = this.target.AABBBounds.height(),
7234
7230
  rect = application.graphicService.creator.rect(Object.assign(Object.assign({
7235
- [sizeAttr]: size,
7231
+ height: height,
7236
7232
  fill: "#bcdeff",
7237
7233
  shadowBlur: 30,
7238
7234
  shadowColor: "#bcdeff"
7239
- }, null === (_c = this.params) || void 0 === _c ? void 0 : _c.attribute), {
7235
+ }, null === (_a = this.params) || void 0 === _a ? void 0 : _a.attribute), {
7240
7236
  x: 0,
7241
- y: y,
7242
- [otherSizeAttr]: 0
7237
+ y: 0,
7238
+ width: 0
7243
7239
  }));
7244
7240
  this.rect = rect, root.add(rect);
7245
7241
  }
@@ -7251,47 +7247,25 @@
7251
7247
  return this.rect ? this.onUpdateRect(end, ratio, out) : this.line || this.area ? this.onUpdateLineOrArea(end, ratio, out) : void 0;
7252
7248
  }
7253
7249
  onUpdateRect(end, ratio, out) {
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 : Math.abs(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 : Math.abs(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
- }
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
+ });
7295
7269
  }
7296
7270
  onUpdateLineOrArea(end, ratio, out) {
7297
7271
  const target = this.line || this.area;
@@ -12289,6 +12263,7 @@
12289
12263
  var _a;
12290
12264
  if (!states.length) return void this.clearStates(hasAnimation);
12291
12265
  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();
12292
12267
  const stateAttrs = {},
12293
12268
  subAttrs = this.subGraphic.map(() => ({}));
12294
12269
  states.forEach(stateName => {
@@ -12302,9 +12277,9 @@
12302
12277
  }), this.updateNormalAttrs(stateAttrs), this.currentStates = states, this.applyStateAttrs(stateAttrs, states, hasAnimation);
12303
12278
  }
12304
12279
  clearStates(hasAnimation) {
12305
- this.hasState() && this.normalAttrs && (this.subGraphic.forEach(graphic => {
12280
+ this.stopStateAnimates(), this.hasState() && this.normalAttrs ? (this.currentStates = [], this.subGraphic.forEach(graphic => {
12306
12281
  graphic.applyStateAttrs(graphic.normalAttrs, this.currentStates, hasAnimation, !0), graphic.normalAttrs = null;
12307
- }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0), this.normalAttrs = null, this.currentStates = []);
12282
+ }), this.applyStateAttrs(this.normalAttrs, this.currentStates, hasAnimation, !0)) : this.currentStates = [], this.normalAttrs = null;
12308
12283
  }
12309
12284
  clone() {
12310
12285
  const glyph = new Glyph(Object.assign({}, this.attribute));
@@ -13876,7 +13851,7 @@
13876
13851
  onClearIncremental: new SyncHook(["graphic", "group", "stage"]),
13877
13852
  beforeUpdateAABBBounds: new SyncHook(["graphic", "stage", "willUpdate", "aabbBounds"]),
13878
13853
  afterUpdateAABBBounds: new SyncHook(["graphic", "stage", "aabbBounds", "globalAABBBounds", "selfChange"])
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()];
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()];
13880
13855
  }
13881
13856
  onAttributeUpdate(graphic) {
13882
13857
  this.hooks.onAttributeUpdate.taps.length && this.hooks.onAttributeUpdate.call(graphic);
@@ -14277,7 +14252,9 @@
14277
14252
  }
14278
14253
  const tb1 = this.tempAABBBounds1,
14279
14254
  tb2 = this.tempAABBBounds2;
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;
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;
14281
14258
  }
14282
14259
  combindShadowAABBBounds(bounds, graphic) {
14283
14260
  if (graphic && graphic.shadowRoot) {
@@ -15208,70 +15185,6 @@
15208
15185
  return path.closePath(), path;
15209
15186
  }
15210
15187
 
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
-
15275
15188
  var __decorate$1D = undefined && undefined.__decorate || function (decorators, target, key, desc) {
15276
15189
  var d,
15277
15190
  c = arguments.length,
@@ -15378,6 +15291,79 @@
15378
15291
  const defaultRectTextureRenderContribution = defaultBaseTextureRenderContribution;
15379
15292
  const defaultRectBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
15380
15293
 
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
+
15381
15367
  class DefaultSymbolRenderContribution {
15382
15368
  constructor() {
15383
15369
  this.time = exports.BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
@@ -16957,15 +16943,17 @@
16957
16943
  const repeatStr = ["", "repeat-x", "repeat-y", "repeat"];
16958
16944
  exports.DefaultCanvasImageRender = class DefaultCanvasImageRender extends BaseRender {
16959
16945
  constructor(imageRenderContribitions) {
16960
- super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
16946
+ super(), this.imageRenderContribitions = imageRenderContribitions, this.numberType = IMAGE_NUMBER_TYPE, this.builtinContributions = [defaultImageRenderContribution, defaultImageBackgroundRenderContribution], this.init(imageRenderContribitions);
16961
16947
  }
16962
- drawShape(image, context, x, y, drawContext, params, fillCb) {
16948
+ drawShape(image, context, x, y, drawContext, params, fillCb, strokeCb) {
16963
16949
  const imageAttribute = getTheme(image).image,
16964
16950
  {
16965
16951
  width = imageAttribute.width,
16966
16952
  height = imageAttribute.height,
16967
16953
  repeatX = imageAttribute.repeatX,
16968
16954
  repeatY = imageAttribute.repeatY,
16955
+ x: originX = imageAttribute.x,
16956
+ y: originY = imageAttribute.y,
16969
16957
  cornerRadius = imageAttribute.cornerRadius,
16970
16958
  image: url
16971
16959
  } = image.attribute,
@@ -16990,7 +16978,7 @@
16990
16978
  } else context.drawImage(res.data, x, y, width, height);
16991
16979
  needRestore && context.restore();
16992
16980
  }
16993
- this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
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);
16994
16982
  }
16995
16983
  draw(image, renderService, drawContext) {
16996
16984
  const {
@@ -19026,7 +19014,9 @@
19026
19014
  let _isBrowserEnv;
19027
19015
  function initIsBrowserEnv() {
19028
19016
  if (null == _isBrowserEnv) try {
19029
- _isBrowserEnv = globalThis === window, _isBrowserEnv && (_isBrowserEnv = !!document.createElement);
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);
19030
19020
  } catch (err) {
19031
19021
  _isBrowserEnv = !1;
19032
19022
  }
@@ -28570,7 +28560,7 @@
28570
28560
 
28571
28561
  const roughModule = _roughModule;
28572
28562
 
28573
- const version = "0.19.8-beta.3";
28563
+ const version = "0.19.8";
28574
28564
  preLoadAllModule();
28575
28565
  if (isBrowserEnv()) {
28576
28566
  loadBrowserEnv(container);
@@ -28684,6 +28674,7 @@
28684
28674
  exports.DefaultGroupBackgroundRenderContribution = DefaultGroupBackgroundRenderContribution;
28685
28675
  exports.DefaultImageAttribute = DefaultImageAttribute;
28686
28676
  exports.DefaultImageBackgroundRenderContribution = DefaultImageBackgroundRenderContribution;
28677
+ exports.DefaultImageRenderContribution = DefaultImageRenderContribution;
28687
28678
  exports.DefaultLayout = DefaultLayout;
28688
28679
  exports.DefaultLineAllocate = DefaultLineAllocate;
28689
28680
  exports.DefaultLineAttribute = DefaultLineAttribute;
@@ -28949,6 +28940,7 @@
28949
28940
  exports.defaultGraphicMemoryManager = defaultGraphicMemoryManager;
28950
28941
  exports.defaultGroupBackgroundRenderContribution = defaultGroupBackgroundRenderContribution;
28951
28942
  exports.defaultImageBackgroundRenderContribution = defaultImageBackgroundRenderContribution;
28943
+ exports.defaultImageRenderContribution = defaultImageRenderContribution;
28952
28944
  exports.defaultLineAllocate = defaultLineAllocate;
28953
28945
  exports.defaultPathAllocate = defaultPathAllocate;
28954
28946
  exports.defaultRectAllocate = defaultRectAllocate;