@visactor/vrender-kits 1.1.4 → 1.1.6-alpha.0

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 (2) hide show
  1. package/dist/index.es.js +49 -22
  2. package/package.json +4 -4
package/dist/index.es.js CHANGED
@@ -4496,13 +4496,14 @@ function applyFillStyle(ctx, character, b) {
4496
4496
  }) : fillStyle, setTextStyle(ctx, character);
4497
4497
  }
4498
4498
  function applyStrokeStyle(ctx, character) {
4499
+ var _a, _b;
4499
4500
  const strokeStyle = character && character.stroke || defaultFormatting.stroke;
4500
4501
  if (!strokeStyle) return void (ctx.globalAlpha = 0);
4501
4502
  const {
4502
4503
  strokeOpacity = 1,
4503
4504
  opacity = 1
4504
4505
  } = character;
4505
- ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4506
+ ctx.globalAlpha = strokeOpacity * opacity, ctx.lineWidth = character && "number" == typeof character.lineWidth ? character.lineWidth : 1, ctx.setLineDash(null !== (_a = character.lineDash) && void 0 !== _a ? _a : []), ctx.lineDashOffset = null !== (_b = character.lineDashOffset) && void 0 !== _b ? _b : 0, ctx.strokeStyle = strokeStyle, setTextStyle(ctx, character);
4506
4507
  }
4507
4508
  function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
4508
4509
  if (desc.length <= 1) return 0;
@@ -6286,7 +6287,7 @@ class Node extends EventEmitter {
6286
6287
  constructor() {
6287
6288
  super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
6288
6289
  }
6289
- onParentSharedStateTreeChanged(_stage, _layer) {}
6290
+ onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
6290
6291
  forEachChildren(cb, reverse = !1) {
6291
6292
  if (reverse) {
6292
6293
  let child = this._lastChild,
@@ -8634,14 +8635,17 @@ class GraphicImpl extends Node {
8634
8635
  }
8635
8636
  return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
8636
8637
  }
8637
- syncSharedStateScopeBindingFromTree(markDirty = !0) {
8638
+ syncSharedStateScopeBinding(nextScope, markDirty = !0) {
8638
8639
  var _a;
8639
- const nextScope = this.resolveBoundSharedStateScope();
8640
8640
  return this.boundSharedStateScope === nextScope ? (this.syncSharedStateActiveRegistrations(), !1) : (this.boundSharedStateScope = nextScope, this.boundSharedStateRevision = void 0, this.compiledStateDefinitions = void 0, this.compiledStateDefinitionsCacheKey = void 0, this.stateEngine = void 0, this.stateEngineCompiledDefinitions = void 0, this.syncSharedStateActiveRegistrations(), markDirty && (null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) && this.markSharedStateDirty(), !0);
8641
8641
  }
8642
- syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
8642
+ syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
8643
+ const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
8644
+ return this.syncSharedStateScopeBinding(nextScope, markDirty);
8645
+ }
8646
+ syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
8643
8647
  var _a, _b;
8644
- return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty);
8648
+ return !!((null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || this.boundSharedStateScope || (null === (_b = this.registeredActiveScopes) || void 0 === _b ? void 0 : _b.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingFromTree(markDirty, inheritedSharedStateScope);
8645
8649
  }
8646
8650
  syncSharedStateActiveRegistrations() {
8647
8651
  var _a;
@@ -8649,6 +8653,7 @@ class GraphicImpl extends Node {
8649
8653
  if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
8650
8654
  scope.subtreeActiveDescendants.delete(this);
8651
8655
  }), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
8656
+ if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
8652
8657
  const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
8653
8658
  null == previousScopes || previousScopes.forEach(scope => {
8654
8659
  nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
@@ -8656,6 +8661,15 @@ class GraphicImpl extends Node {
8656
8661
  scope.subtreeActiveDescendants.add(this);
8657
8662
  }), this.registeredActiveScopes = nextScopes;
8658
8663
  }
8664
+ isSharedStateScopeChainRegistered(previousScopes) {
8665
+ let scope = this.boundSharedStateScope,
8666
+ scopeCount = 0;
8667
+ for (; scope;) {
8668
+ if (!previousScopes.has(scope)) return !1;
8669
+ scopeCount += 1, scope = scope.parentScope;
8670
+ }
8671
+ return scopeCount === previousScopes.size;
8672
+ }
8659
8673
  clearSharedStateActiveRegistrations() {
8660
8674
  const previousScopes = this.registeredActiveScopes;
8661
8675
  previousScopes && (previousScopes.forEach(scope => {
@@ -8665,8 +8679,8 @@ class GraphicImpl extends Node {
8665
8679
  markSharedStateDirty() {
8666
8680
  this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
8667
8681
  }
8668
- onParentSharedStateTreeChanged(stage, layer) {
8669
- this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
8682
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
8683
+ this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
8670
8684
  }
8671
8685
  refreshSharedStateBeforeRender() {
8672
8686
  var _a;
@@ -9317,6 +9331,10 @@ class GraphicImpl extends Node {
9317
9331
  var _a;
9318
9332
  return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
9319
9333
  }
9334
+ setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
9335
+ var _a;
9336
+ this.states = definitions, this.localStateDefinitionsSource !== definitions && (this.localStateDefinitionsSource = definitions, this.localStateDefinitionsVersion = (null !== (_a = this.localStateDefinitionsVersion) && void 0 !== _a ? _a : 0) + 1), this.compiledStateDefinitions = compiledDefinitions, this.compiledStateDefinitionsCacheKey = `local:${this.localStateDefinitionsVersion}`;
9337
+ }
9320
9338
  getStateResolveBaseAttrs() {
9321
9339
  var _a;
9322
9340
  return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
@@ -9664,12 +9682,12 @@ class GraphicImpl extends Node {
9664
9682
  this._globalTransMatrix.translate(scrollX, scrollY);
9665
9683
  }
9666
9684
  }
9667
- setStage(stage, layer) {
9685
+ setStage(stage, layer, inheritedSharedStateScope) {
9668
9686
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
9669
9687
  const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
9670
9688
  previousStage = this.stage;
9671
9689
  if (this.stage !== stage || this.layer !== layer) {
9672
- if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
9690
+ if (this.stage = stage, this.layer = layer, ((null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.setStageToShadowRoot(stage, layer), this.mayHaveTrackedAnimates() && this.hasAnyTrackedAnimate()) {
9673
9691
  const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
9674
9692
  nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
9675
9693
  detachedStageAnimates = [];
@@ -9686,7 +9704,7 @@ class GraphicImpl extends Node {
9686
9704
  }
9687
9705
  return this._onSetStage && this._onSetStage(this, stage, layer), void (null === (_h = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _h || _h.call(graphicService, this, stage));
9688
9706
  }
9689
- ((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0);
9707
+ ((null === (_j = this.currentStates) || void 0 === _j ? void 0 : _j.length) || this.boundSharedStateScope || (null === (_k = this.registeredActiveScopes) || void 0 === _k ? void 0 : _k.size) || this.sharedStateDirty) && this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope);
9690
9708
  }
9691
9709
  detachStageForRelease() {
9692
9710
  var _a, _b, _c;
@@ -10108,13 +10126,13 @@ class Group extends Graphic {
10108
10126
  child.setStage(null, null);
10109
10127
  }), this.addUpdateBoundTag();
10110
10128
  }
10111
- setStage(stage, layer) {
10129
+ setStage(stage, layer, inheritedSharedStateScope) {
10112
10130
  var _a, _b, _c, _d, _e, _f;
10113
10131
  const graphicService = null !== (_c = null !== (_a = null == stage ? void 0 : stage.graphicService) && void 0 !== _a ? _a : null === (_b = this.stage) || void 0 === _b ? void 0 : _b.graphicService) && void 0 !== _c ? _c : application.graphicService,
10114
10132
  needsSharedStateTreeSync = this.hasSharedStateDefinitions() || this.sharedStateScope || (null === (_d = this.currentStates) || void 0 === _d ? void 0 : _d.length) || this.boundSharedStateScope || (null === (_e = this.registeredActiveScopes) || void 0 === _e ? void 0 : _e.size) || this.sharedStateDirty;
10115
- if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_f = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _f || _f.call(graphicService, this, stage), void this.notifyChildrenSharedStateTreeChanged();
10133
+ if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope)), this.setStageToShadowRoot(stage, layer), this._onSetStage && this._onSetStage(this, stage, layer), null === (_f = null == graphicService ? void 0 : graphicService.onSetStage) || void 0 === _f || _f.call(graphicService, this, stage), void this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
10116
10134
  const layerChanged = this.layer !== layer;
10117
- layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
10135
+ layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
10118
10136
  }
10119
10137
  addUpdatePositionTag() {
10120
10138
  super.addUpdatePositionTag(), this.forEachChildren(g => {
@@ -10173,17 +10191,26 @@ class Group extends Graphic {
10173
10191
  hasSharedStateDefinitions() {
10174
10192
  return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
10175
10193
  }
10176
- notifyChildrenSharedStateTreeChanged() {
10194
+ resolveChildSharedStateScope(inheritedSharedStateScope) {
10195
+ var _a;
10196
+ return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
10197
+ }
10198
+ notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
10199
+ const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
10177
10200
  this.forEachChildren(item => {
10178
- this.syncChildSharedStateTreeBinding(item);
10201
+ this.setStageToChild(item, childSharedStateScope);
10179
10202
  });
10180
10203
  }
10181
- syncChildSharedStateTreeBinding(child) {
10182
- child.onParentSharedStateTreeChanged(this.stage, this.layer);
10204
+ setStageToChild(child, inheritedSharedStateScope) {
10205
+ const graphic = child;
10206
+ "function" != typeof graphic.setStage || child.onParentSharedStateTreeChanged !== Graphic.prototype.onParentSharedStateTreeChanged && child.onParentSharedStateTreeChanged !== Group.prototype.onParentSharedStateTreeChanged || graphic.stage === this.stage && graphic.layer === this.layer ? child.onParentSharedStateTreeChanged(this.stage, this.layer, inheritedSharedStateScope) : graphic.setStage(this.stage, this.layer, inheritedSharedStateScope);
10207
+ }
10208
+ syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
10209
+ void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
10183
10210
  }
10184
- onParentSharedStateTreeChanged(stage, layer) {
10211
+ onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
10185
10212
  var _a;
10186
- this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)), this.notifyChildrenSharedStateTreeChanged()) : this.setStage(stage, layer);
10213
+ this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length), inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : this.setStage(stage, layer, inheritedSharedStateScope);
10187
10214
  }
10188
10215
  }
10189
10216
  Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
@@ -13557,8 +13584,8 @@ class RichText extends Graphic {
13557
13584
  clone() {
13558
13585
  return new RichText(Object.assign({}, this.attribute));
13559
13586
  }
13560
- setStage(stage, layer) {
13561
- super.setStage(stage, layer);
13587
+ setStage(stage, layer, inheritedSharedStateScope) {
13588
+ super.setStage(stage, layer, inheritedSharedStateScope);
13562
13589
  this.getFrameCache().icons.forEach(icon => {
13563
13590
  icon.setStage(stage, layer);
13564
13591
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-kits",
3
- "version": "1.1.4",
3
+ "version": "1.1.6-alpha.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index-node.js",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@visactor/vutils": "~1.0.12",
47
- "@visactor/vrender-core": "1.1.4",
47
+ "@visactor/vrender-core": "1.1.6-alpha.0",
48
48
  "@resvg/resvg-js": "2.4.1",
49
49
  "roughjs": "4.6.6",
50
50
  "gifuct-js": "2.1.2",
@@ -69,9 +69,9 @@
69
69
  "vite": "3.2.6",
70
70
  "typescript": "4.9.5",
71
71
  "cross-env": "^7.0.3",
72
- "@internal/ts-config": "0.0.1",
72
+ "@internal/bundler": "0.0.1",
73
73
  "@internal/eslint-config": "0.0.1",
74
- "@internal/bundler": "0.0.1"
74
+ "@internal/ts-config": "0.0.1"
75
75
  },
76
76
  "keywords": [
77
77
  "VisActor",