@visactor/vrender-kits 1.1.6-alpha.0 → 1.1.6
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/canvas/contributions/create-canvas-module.js +1 -1
- package/cjs/canvas/contributions/modules.js +1 -1
- package/cjs/env/contributions/canvas-wrap.js +1 -1
- package/cjs/env/contributions/feishu-contribution.js +1 -1
- package/cjs/env/contributions/lynx-contribution.d.ts +5 -1
- package/cjs/env/contributions/lynx-contribution.js +10 -8
- package/cjs/env/contributions/lynx-contribution.js.map +1 -1
- package/dist/index.es.js +386 -152
- package/es/canvas/contributions/create-canvas-module.js +1 -1
- package/es/canvas/contributions/modules.js +1 -1
- package/es/env/contributions/canvas-wrap.js +1 -1
- package/es/env/contributions/feishu-contribution.js +1 -1
- package/es/env/contributions/lynx-contribution.d.ts +5 -1
- package/es/env/contributions/lynx-contribution.js +10 -8
- package/es/env/contributions/lynx-contribution.js.map +1 -1
- package/package.json +4 -4
package/dist/index.es.js
CHANGED
|
@@ -4375,18 +4375,21 @@ class GradientParser {
|
|
|
4375
4375
|
}
|
|
4376
4376
|
}
|
|
4377
4377
|
|
|
4378
|
-
function
|
|
4378
|
+
function getScaledStrokeWithMatrix(matrix, width, dpr) {
|
|
4379
4379
|
let strokeWidth = width;
|
|
4380
4380
|
const {
|
|
4381
4381
|
a: a,
|
|
4382
4382
|
b: b,
|
|
4383
4383
|
c: c,
|
|
4384
4384
|
d: d
|
|
4385
|
-
} =
|
|
4385
|
+
} = matrix,
|
|
4386
4386
|
scaleX = Math.sign(a) * Math.sqrt(a * a + b * b),
|
|
4387
4387
|
scaleY = Math.sign(d) * Math.sqrt(c * c + d * d);
|
|
4388
4388
|
return scaleX + scaleY === 0 ? 0 : (strokeWidth = strokeWidth / Math.abs(scaleX + scaleY) * 2 * dpr, strokeWidth);
|
|
4389
4389
|
}
|
|
4390
|
+
function getScaledStroke(context, width, dpr) {
|
|
4391
|
+
return getScaledStrokeWithMatrix(context.currentMatrix, width, dpr);
|
|
4392
|
+
}
|
|
4390
4393
|
function createColor(context, c, params, offsetX = 0, offsetY = 0) {
|
|
4391
4394
|
var _a, _b, _c, _d;
|
|
4392
4395
|
if (!c || !0 === c) return "black";
|
|
@@ -6287,7 +6290,7 @@ class Node extends EventEmitter {
|
|
|
6287
6290
|
constructor() {
|
|
6288
6291
|
super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
|
|
6289
6292
|
}
|
|
6290
|
-
onParentSharedStateTreeChanged(_stage, _layer
|
|
6293
|
+
onParentSharedStateTreeChanged(_stage, _layer) {}
|
|
6291
6294
|
forEachChildren(cb, reverse = !1) {
|
|
6292
6295
|
if (reverse) {
|
|
6293
6296
|
let child = this._lastChild,
|
|
@@ -8384,7 +8387,7 @@ function normalizeNoAnimateAttrConfig(config) {
|
|
|
8384
8387
|
}
|
|
8385
8388
|
class StateTransitionOrchestrator {
|
|
8386
8389
|
analyzeTransition(targetAttrs, hasAnimation, options = {}) {
|
|
8387
|
-
var _a, _b;
|
|
8390
|
+
var _a, _b, _c, _d;
|
|
8388
8391
|
const plan = {
|
|
8389
8392
|
targetAttrs: Object.assign({}, targetAttrs),
|
|
8390
8393
|
animateAttrs: {},
|
|
@@ -8393,10 +8396,17 @@ class StateTransitionOrchestrator {
|
|
|
8393
8396
|
if (!hasAnimation) return plan;
|
|
8394
8397
|
const noWorkAnimateAttr = Object.assign(Object.assign({}, null !== (_a = options.noWorkAnimateAttr) && void 0 !== _a ? _a : {}), normalizeNoAnimateAttrConfig(null === (_b = options.animateConfig) || void 0 === _b ? void 0 : _b.noAnimateAttrs)),
|
|
8395
8398
|
isClear = !0 === options.isClear,
|
|
8396
|
-
|
|
8399
|
+
getDefaultAttribute = options.getDefaultAttribute,
|
|
8400
|
+
readDefaultAttribute = getDefaultAttribute,
|
|
8401
|
+
readStateTransitionDefaultAttribute = null !== (_c = options.getStateTransitionDefaultAttribute) && void 0 !== _c ? _c : getDefaultAttribute,
|
|
8397
8402
|
shouldSkipDefaultAttribute = options.shouldSkipDefaultAttribute,
|
|
8398
|
-
|
|
8399
|
-
|
|
8403
|
+
stateTransitionTargetAttrs = null !== (_d = options.stateTransitionTargetAttrs) && void 0 !== _d ? _d : targetAttrs,
|
|
8404
|
+
assignTransitionAttr = (key, value, isRemovedStateAttr = !1) => {
|
|
8405
|
+
if (noWorkAnimateAttr[key]) plan.noAnimateAttrs[key] = value;else if (isRemovedStateAttr && void 0 === value) {
|
|
8406
|
+
const defaultValue = null == readStateTransitionDefaultAttribute ? void 0 : readStateTransitionDefaultAttribute(key, stateTransitionTargetAttrs);
|
|
8407
|
+
if (void 0 === defaultValue && (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, stateTransitionTargetAttrs))) return;
|
|
8408
|
+
plan.animateAttrs[key] = defaultValue;
|
|
8409
|
+
} else if (isClear && void 0 === value) {
|
|
8400
8410
|
if (null == shouldSkipDefaultAttribute ? void 0 : shouldSkipDefaultAttribute(key, targetAttrs)) return;
|
|
8401
8411
|
plan.animateAttrs[key] = readDefaultAttribute(key);
|
|
8402
8412
|
} else plan.animateAttrs[key] = value;
|
|
@@ -8408,7 +8418,7 @@ class StateTransitionOrchestrator {
|
|
|
8408
8418
|
const extraAnimateAttrs = options.extraAnimateAttrs;
|
|
8409
8419
|
if (extraAnimateAttrs) for (const key in extraAnimateAttrs) {
|
|
8410
8420
|
const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetAttrs, key);
|
|
8411
|
-
!Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key]);
|
|
8421
|
+
!Object.prototype.hasOwnProperty.call(extraAnimateAttrs, key) || hasTargetAttr && void 0 !== targetAttrs[key] || assignTransitionAttr(key, extraAnimateAttrs[key], !0);
|
|
8412
8422
|
}
|
|
8413
8423
|
return plan;
|
|
8414
8424
|
}
|
|
@@ -8440,9 +8450,11 @@ class StateTransitionOrchestrator {
|
|
|
8440
8450
|
noWorkAnimateAttr: graphic.getNoWorkAnimateAttr(),
|
|
8441
8451
|
isClear: !0,
|
|
8442
8452
|
getDefaultAttribute: graphic.getDefaultAttribute.bind(graphic),
|
|
8453
|
+
getStateTransitionDefaultAttribute: options.getStateTransitionDefaultAttribute,
|
|
8443
8454
|
shouldSkipDefaultAttribute: null !== (_a = options.shouldSkipDefaultAttribute) && void 0 !== _a ? _a : graphic.shouldSkipStateTransitionDefaultAttribute.bind(graphic),
|
|
8444
8455
|
animateConfig: options.animateConfig,
|
|
8445
|
-
extraAnimateAttrs: options.extraAnimateAttrs
|
|
8456
|
+
extraAnimateAttrs: options.extraAnimateAttrs,
|
|
8457
|
+
stateTransitionTargetAttrs: options.stateTransitionTargetAttrs
|
|
8446
8458
|
});
|
|
8447
8459
|
return this.applyTransition(graphic, plan, hasAnimation, options);
|
|
8448
8460
|
}
|
|
@@ -8635,17 +8647,14 @@ class GraphicImpl extends Node {
|
|
|
8635
8647
|
}
|
|
8636
8648
|
return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
|
|
8637
8649
|
}
|
|
8638
|
-
|
|
8650
|
+
syncSharedStateScopeBindingFromTree(markDirty = !0) {
|
|
8639
8651
|
var _a;
|
|
8652
|
+
const nextScope = this.resolveBoundSharedStateScope();
|
|
8640
8653
|
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
8654
|
}
|
|
8642
|
-
|
|
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) {
|
|
8655
|
+
syncSharedStateScopeBindingOnTreeChange(markDirty = !0) {
|
|
8647
8656
|
var _a, _b;
|
|
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
|
|
8657
|
+
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);
|
|
8649
8658
|
}
|
|
8650
8659
|
syncSharedStateActiveRegistrations() {
|
|
8651
8660
|
var _a;
|
|
@@ -8653,7 +8662,6 @@ class GraphicImpl extends Node {
|
|
|
8653
8662
|
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
|
|
8654
8663
|
scope.subtreeActiveDescendants.delete(this);
|
|
8655
8664
|
}), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
|
|
8656
|
-
if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
|
|
8657
8665
|
const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
|
|
8658
8666
|
null == previousScopes || previousScopes.forEach(scope => {
|
|
8659
8667
|
nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
|
|
@@ -8661,15 +8669,6 @@ class GraphicImpl extends Node {
|
|
|
8661
8669
|
scope.subtreeActiveDescendants.add(this);
|
|
8662
8670
|
}), this.registeredActiveScopes = nextScopes;
|
|
8663
8671
|
}
|
|
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
|
-
}
|
|
8673
8672
|
clearSharedStateActiveRegistrations() {
|
|
8674
8673
|
const previousScopes = this.registeredActiveScopes;
|
|
8675
8674
|
previousScopes && (previousScopes.forEach(scope => {
|
|
@@ -8679,8 +8678,8 @@ class GraphicImpl extends Node {
|
|
|
8679
8678
|
markSharedStateDirty() {
|
|
8680
8679
|
this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
|
|
8681
8680
|
}
|
|
8682
|
-
onParentSharedStateTreeChanged(stage, layer
|
|
8683
|
-
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(
|
|
8681
|
+
onParentSharedStateTreeChanged(stage, layer) {
|
|
8682
|
+
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
|
|
8684
8683
|
}
|
|
8685
8684
|
refreshSharedStateBeforeRender() {
|
|
8686
8685
|
var _a;
|
|
@@ -8730,21 +8729,20 @@ class GraphicImpl extends Node {
|
|
|
8730
8729
|
}), snapshot) : snapshot;
|
|
8731
8730
|
}
|
|
8732
8731
|
buildRemovedStateAnimationAttrs(targetStateAttrs, previousResolvedStatePatch) {
|
|
8733
|
-
|
|
8734
|
-
if (!previousResolvedStatePatch) return extraAttrs;
|
|
8732
|
+
if (!previousResolvedStatePatch) return;
|
|
8735
8733
|
const snapshot = this.buildStaticAttributeSnapshot(),
|
|
8736
|
-
|
|
8734
|
+
extraAttrs = {};
|
|
8737
8735
|
return Object.keys(previousResolvedStatePatch).forEach(key => {
|
|
8738
8736
|
const hasTargetAttr = Object.prototype.hasOwnProperty.call(targetStateAttrs, key);
|
|
8739
8737
|
if (hasTargetAttr && void 0 !== targetStateAttrs[key]) return;
|
|
8740
8738
|
const assignFallbackAttr = value => {
|
|
8741
|
-
|
|
8739
|
+
extraAttrs[key] = void 0 === value ? value : cloneAttributeValue(value);
|
|
8742
8740
|
};
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
}
|
|
8741
|
+
hasTargetAttr ? assignFallbackAttr(targetStateAttrs[key]) : Object.prototype.hasOwnProperty.call(snapshot, key) ? assignFallbackAttr(snapshot[key]) : assignFallbackAttr(void 0);
|
|
8742
|
+
}), {
|
|
8743
|
+
extraAttrs: extraAttrs,
|
|
8744
|
+
stateTransitionTargetAttrs: snapshot
|
|
8745
|
+
};
|
|
8748
8746
|
}
|
|
8749
8747
|
syncObjectToSnapshot(target, snapshot, excludedKeys) {
|
|
8750
8748
|
const delta = new Map();
|
|
@@ -9331,10 +9329,6 @@ class GraphicImpl extends Node {
|
|
|
9331
9329
|
var _a;
|
|
9332
9330
|
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
9333
9331
|
}
|
|
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
|
-
}
|
|
9338
9332
|
getStateResolveBaseAttrs() {
|
|
9339
9333
|
var _a;
|
|
9340
9334
|
return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
@@ -9464,29 +9458,37 @@ class GraphicImpl extends Node {
|
|
|
9464
9458
|
resolvedStateAttrs: resolvedStateAttrs
|
|
9465
9459
|
} = this.resolveGraphicStateTransition(states, !0),
|
|
9466
9460
|
patchChanged = !this.sameStatePatches(previousResolvedStatePatch, resolvedStateAttrs);
|
|
9467
|
-
patchChanged
|
|
9461
|
+
if ((!patchChanged || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) && (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), patchChanged)) if (hasAnimation && animateSameStatePatchChange) {
|
|
9462
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
9463
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
9464
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
9465
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
9468
9466
|
type: AttributeUpdateType.STATE
|
|
9469
9467
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
9470
9468
|
type: AttributeUpdateType.STATE
|
|
9471
|
-
}), this.emitStateUpdateEvent()
|
|
9469
|
+
}), this.emitStateUpdateEvent();
|
|
9472
9470
|
}
|
|
9473
9471
|
resolveStateAnimateConfig(animateConfig) {
|
|
9474
9472
|
var _a, _b, _c;
|
|
9475
9473
|
return null !== (_c = null !== (_a = null != animateConfig ? animateConfig : this.stateAnimateConfig) && void 0 !== _a ? _a : null === (_b = this.context) || void 0 === _b ? void 0 : _b.stateAnimateConfig) && void 0 !== _c ? _c : DefaultStateAnimateConfig;
|
|
9476
9474
|
}
|
|
9477
|
-
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs) {
|
|
9475
|
+
applyStateAttrs(attrs, stateNames, hasAnimation, isClear, animateConfig, extraAnimateAttrs, stateTransitionTargetAttrs) {
|
|
9478
9476
|
const resolvedAnimateConfig = hasAnimation ? this.resolveStateAnimateConfig(animateConfig) : void 0,
|
|
9479
9477
|
transitionOptions = resolvedAnimateConfig ? {
|
|
9480
9478
|
animateConfig: resolvedAnimateConfig,
|
|
9481
9479
|
extraAnimateAttrs: extraAnimateAttrs,
|
|
9482
|
-
|
|
9480
|
+
getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
|
|
9481
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
|
|
9482
|
+
stateTransitionTargetAttrs: stateTransitionTargetAttrs
|
|
9483
9483
|
} : void 0;
|
|
9484
9484
|
if (isClear) return void this.getStateTransitionOrchestrator().applyClearTransition(this, attrs, hasAnimation, transitionOptions);
|
|
9485
9485
|
const plan = this.getStateTransitionOrchestrator().analyzeTransition(attrs, hasAnimation, {
|
|
9486
9486
|
noWorkAnimateAttr: this.getNoWorkAnimateAttr(),
|
|
9487
9487
|
animateConfig: resolvedAnimateConfig,
|
|
9488
9488
|
extraAnimateAttrs: extraAnimateAttrs,
|
|
9489
|
-
|
|
9489
|
+
getStateTransitionDefaultAttribute: this.getStateTransitionDefaultAttribute.bind(this),
|
|
9490
|
+
shouldSkipDefaultAttribute: this.shouldSkipStateTransitionDefaultAttribute.bind(this),
|
|
9491
|
+
stateTransitionTargetAttrs: stateTransitionTargetAttrs
|
|
9490
9492
|
});
|
|
9491
9493
|
this.getStateTransitionOrchestrator().applyTransition(this, plan, hasAnimation, transitionOptions);
|
|
9492
9494
|
}
|
|
@@ -9513,11 +9515,15 @@ class GraphicImpl extends Node {
|
|
|
9513
9515
|
transition = this.resolveClearStatesTransition();
|
|
9514
9516
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
|
|
9515
9517
|
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
9516
|
-
transition.changed
|
|
9518
|
+
if (!transition.changed || this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !0)) if (this.currentStates = transition.states, this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, this.clearSharedStateActiveRegistrations(), hasAnimation) {
|
|
9519
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
9520
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
9521
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
9522
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
9517
9523
|
type: AttributeUpdateType.STATE
|
|
9518
9524
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
9519
9525
|
type: AttributeUpdateType.STATE
|
|
9520
|
-
}), this.emitStateUpdateEvent()
|
|
9526
|
+
}), this.emitStateUpdateEvent();
|
|
9521
9527
|
}
|
|
9522
9528
|
removeState(stateName, hasAnimation) {
|
|
9523
9529
|
const transition = this.resolveRemoveStateTransition(stateName);
|
|
@@ -9558,11 +9564,15 @@ class GraphicImpl extends Node {
|
|
|
9558
9564
|
effectiveStates: effectiveStates,
|
|
9559
9565
|
resolvedStateAttrs: resolvedStateAttrs
|
|
9560
9566
|
} = this.resolveGraphicStateTransition(states);
|
|
9561
|
-
|
|
9567
|
+
if ((transition.changed || !this.sameStateNames(previousStates, transition.states)) && this.beforeStateUpdate(resolvedStateAttrs, previousStates, transition.states, hasAnimation, !1)) if (this.currentStates = transition.states, this.effectiveStates = [...effectiveStates], this.resolvedStatePatch = resolvedStateAttrs, this.sharedStateDirty = !1, this.syncSharedStateActiveRegistrations(), hasAnimation) {
|
|
9568
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
9569
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
9570
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
9571
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
9562
9572
|
type: AttributeUpdateType.STATE
|
|
9563
9573
|
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
9564
9574
|
type: AttributeUpdateType.STATE
|
|
9565
|
-
}), this.emitStateUpdateEvent()
|
|
9575
|
+
}), this.emitStateUpdateEvent();
|
|
9566
9576
|
}
|
|
9567
9577
|
invalidateResolver() {
|
|
9568
9578
|
var _a, _b;
|
|
@@ -9682,12 +9692,12 @@ class GraphicImpl extends Node {
|
|
|
9682
9692
|
this._globalTransMatrix.translate(scrollX, scrollY);
|
|
9683
9693
|
}
|
|
9684
9694
|
}
|
|
9685
|
-
setStage(stage, layer
|
|
9695
|
+
setStage(stage, layer) {
|
|
9686
9696
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9687
9697
|
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,
|
|
9688
9698
|
previousStage = this.stage;
|
|
9689
9699
|
if (this.stage !== stage || this.layer !== layer) {
|
|
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
|
|
9700
|
+
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()) {
|
|
9691
9701
|
const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
|
|
9692
9702
|
nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
|
|
9693
9703
|
detachedStageAnimates = [];
|
|
@@ -9704,7 +9714,7 @@ class GraphicImpl extends Node {
|
|
|
9704
9714
|
}
|
|
9705
9715
|
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));
|
|
9706
9716
|
}
|
|
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
|
|
9717
|
+
((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);
|
|
9708
9718
|
}
|
|
9709
9719
|
detachStageForRelease() {
|
|
9710
9720
|
var _a, _b, _c;
|
|
@@ -10126,13 +10136,13 @@ class Group extends Graphic {
|
|
|
10126
10136
|
child.setStage(null, null);
|
|
10127
10137
|
}), this.addUpdateBoundTag();
|
|
10128
10138
|
}
|
|
10129
|
-
setStage(stage, layer
|
|
10139
|
+
setStage(stage, layer) {
|
|
10130
10140
|
var _a, _b, _c, _d, _e, _f;
|
|
10131
10141
|
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,
|
|
10132
10142
|
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;
|
|
10133
|
-
if (this.stage !== stage) return this.stage = stage, this.layer = layer, needsSharedStateTreeSync && (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0
|
|
10143
|
+
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();
|
|
10134
10144
|
const layerChanged = this.layer !== layer;
|
|
10135
|
-
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0
|
|
10145
|
+
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
|
|
10136
10146
|
}
|
|
10137
10147
|
addUpdatePositionTag() {
|
|
10138
10148
|
super.addUpdatePositionTag(), this.forEachChildren(g => {
|
|
@@ -10191,26 +10201,17 @@ class Group extends Graphic {
|
|
|
10191
10201
|
hasSharedStateDefinitions() {
|
|
10192
10202
|
return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
|
|
10193
10203
|
}
|
|
10194
|
-
|
|
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);
|
|
10204
|
+
notifyChildrenSharedStateTreeChanged() {
|
|
10200
10205
|
this.forEachChildren(item => {
|
|
10201
|
-
this.
|
|
10206
|
+
this.syncChildSharedStateTreeBinding(item);
|
|
10202
10207
|
});
|
|
10203
10208
|
}
|
|
10204
|
-
|
|
10205
|
-
|
|
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);
|
|
10209
|
+
syncChildSharedStateTreeBinding(child) {
|
|
10210
|
+
child.onParentSharedStateTreeChanged(this.stage, this.layer);
|
|
10210
10211
|
}
|
|
10211
|
-
onParentSharedStateTreeChanged(stage, layer
|
|
10212
|
+
onParentSharedStateTreeChanged(stage, layer) {
|
|
10212
10213
|
var _a;
|
|
10213
|
-
this.stage === stage && this.layer === layer ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length)
|
|
10214
|
+
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);
|
|
10214
10215
|
}
|
|
10215
10216
|
}
|
|
10216
10217
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
@@ -11700,8 +11701,15 @@ class Text extends Graphic {
|
|
|
11700
11701
|
const b = this.AABBBounds;
|
|
11701
11702
|
return this._OBBBounds.setValue(b.x1, b.y1, b.x2, b.y2), this._OBBBounds;
|
|
11702
11703
|
}
|
|
11703
|
-
this.obbText || (this.obbText = new Text({}))
|
|
11704
|
-
|
|
11704
|
+
this.obbText || (this.obbText = new Text({}));
|
|
11705
|
+
const {
|
|
11706
|
+
dx = 0,
|
|
11707
|
+
dy = 0
|
|
11708
|
+
} = attribute;
|
|
11709
|
+
this.obbText.setAttributes(Object.assign(Object.assign({}, attribute), {
|
|
11710
|
+
angle: 0,
|
|
11711
|
+
dx: 0,
|
|
11712
|
+
dy: 0
|
|
11705
11713
|
}));
|
|
11706
11714
|
const bounds1 = this.obbText.AABBBounds,
|
|
11707
11715
|
{
|
|
@@ -11716,7 +11724,7 @@ class Text extends Graphic {
|
|
|
11716
11724
|
x: x,
|
|
11717
11725
|
y: y
|
|
11718
11726
|
});
|
|
11719
|
-
return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x, center.y - boundsCenter.y), this._OBBBounds.angle = angle, this._OBBBounds;
|
|
11727
|
+
return this._OBBBounds.copy(bounds1), this._OBBBounds.translate(center.x - boundsCenter.x + dx, center.y - boundsCenter.y + dy), this._OBBBounds.angle = angle, this._OBBBounds;
|
|
11720
11728
|
}
|
|
11721
11729
|
updateAABBBounds(attribute, textTheme, aabbBounds) {
|
|
11722
11730
|
const {
|
|
@@ -13584,8 +13592,8 @@ class RichText extends Graphic {
|
|
|
13584
13592
|
clone() {
|
|
13585
13593
|
return new RichText(Object.assign({}, this.attribute));
|
|
13586
13594
|
}
|
|
13587
|
-
setStage(stage, layer
|
|
13588
|
-
super.setStage(stage, layer
|
|
13595
|
+
setStage(stage, layer) {
|
|
13596
|
+
super.setStage(stage, layer);
|
|
13589
13597
|
this.getFrameCache().icons.forEach(icon => {
|
|
13590
13598
|
icon.setStage(stage, layer);
|
|
13591
13599
|
});
|
|
@@ -14138,7 +14146,204 @@ function createArc3d(attributes) {
|
|
|
14138
14146
|
return new Arc3d(attributes);
|
|
14139
14147
|
}
|
|
14140
14148
|
|
|
14141
|
-
|
|
14149
|
+
function drawPolygon(path, points, x, y) {
|
|
14150
|
+
if (points && points.length) {
|
|
14151
|
+
path.moveTo(points[0].x + x, points[0].y + y);
|
|
14152
|
+
for (let i = 1; i < points.length; i++) path.lineTo(points[i].x + x, points[i].y + y);
|
|
14153
|
+
}
|
|
14154
|
+
}
|
|
14155
|
+
function drawRoundedPolygon(path, points, x, y, cornerRadius, closePath = !0) {
|
|
14156
|
+
var _a;
|
|
14157
|
+
const normalized = normalizePolygonPoints(points, cornerRadius, closePath);
|
|
14158
|
+
if (normalized) return void drawRoundedPolygon(path, normalized.points, x, y, normalized.cornerRadius, closePath);
|
|
14159
|
+
if (points.length < 3) return void drawPolygon(path, points, x, y);
|
|
14160
|
+
let startI = 0,
|
|
14161
|
+
endI = points.length - 1;
|
|
14162
|
+
closePath || (startI += 1, endI -= 1, path.moveTo(points[0].x + x, points[0].y + y));
|
|
14163
|
+
for (let i = startI; i <= endI; i++) {
|
|
14164
|
+
const p1 = points[0 === i ? endI : (i - 1) % points.length],
|
|
14165
|
+
angularPoint = points[i % points.length],
|
|
14166
|
+
p2 = points[(i + 1) % points.length],
|
|
14167
|
+
dx1 = angularPoint.x - p1.x,
|
|
14168
|
+
dy1 = angularPoint.y - p1.y,
|
|
14169
|
+
dx2 = angularPoint.x - p2.x,
|
|
14170
|
+
dy2 = angularPoint.y - p2.y,
|
|
14171
|
+
angle = (Math.atan2(dy1, dx1) - Math.atan2(dy2, dx2)) / 2,
|
|
14172
|
+
tan = Math.abs(Math.tan(angle));
|
|
14173
|
+
let radius = Array.isArray(cornerRadius) ? null !== (_a = cornerRadius[i % points.length]) && void 0 !== _a ? _a : 0 : cornerRadius,
|
|
14174
|
+
segment = radius / tan;
|
|
14175
|
+
const length1 = getLength(dx1, dy1),
|
|
14176
|
+
length2 = getLength(dx2, dy2),
|
|
14177
|
+
length = Math.min(length1, length2);
|
|
14178
|
+
segment > length && (segment = length, radius = length * tan);
|
|
14179
|
+
const p1Cross = getProportionPoint(angularPoint, segment, length1, dx1, dy1),
|
|
14180
|
+
p2Cross = getProportionPoint(angularPoint, segment, length2, dx2, dy2),
|
|
14181
|
+
dx = 2 * angularPoint.x - p1Cross.x - p2Cross.x,
|
|
14182
|
+
dy = 2 * angularPoint.y - p1Cross.y - p2Cross.y,
|
|
14183
|
+
L = getLength(dx, dy),
|
|
14184
|
+
circlePoint = getProportionPoint(angularPoint, getLength(segment, radius), L, dx, dy);
|
|
14185
|
+
let startAngle = Math.atan2(p1Cross.y - circlePoint.y, p1Cross.x - circlePoint.x);
|
|
14186
|
+
const endAngle = Math.atan2(p2Cross.y - circlePoint.y, p2Cross.x - circlePoint.x);
|
|
14187
|
+
let sweepAngle = endAngle - startAngle;
|
|
14188
|
+
sweepAngle < 0 && (startAngle = endAngle, sweepAngle = -sweepAngle), sweepAngle > Math.PI && (sweepAngle -= Math.PI), 0 === i ? path.moveTo(p1Cross.x + x, p1Cross.y + y) : path.lineTo(p1Cross.x + x, p1Cross.y + y), sweepAngle && path.arcTo(angularPoint.x + x, angularPoint.y + y, p2Cross.x + x, p2Cross.y + y, radius), path.lineTo(p2Cross.x + x, p2Cross.y + y);
|
|
14189
|
+
}
|
|
14190
|
+
closePath || path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);
|
|
14191
|
+
}
|
|
14192
|
+
function getLength(dx, dy) {
|
|
14193
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
14194
|
+
}
|
|
14195
|
+
function getProportionPoint(point, segment, length, dx, dy) {
|
|
14196
|
+
const factor = segment / length;
|
|
14197
|
+
return {
|
|
14198
|
+
x: point.x - dx * factor,
|
|
14199
|
+
y: point.y - dy * factor
|
|
14200
|
+
};
|
|
14201
|
+
}
|
|
14202
|
+
function normalizePolygonPoints(points, cornerRadius, closePath = !0) {
|
|
14203
|
+
var _a;
|
|
14204
|
+
let hasDuplicate = !1;
|
|
14205
|
+
for (let i = 1; i < points.length; i++) if (isSamePoint(points[i - 1], points[i])) {
|
|
14206
|
+
hasDuplicate = !0;
|
|
14207
|
+
break;
|
|
14208
|
+
}
|
|
14209
|
+
if (!hasDuplicate && closePath && points.length > 1 && isSamePoint(points[0], points[points.length - 1]) && (hasDuplicate = !0), !hasDuplicate) return null;
|
|
14210
|
+
const normalizedPoints = [],
|
|
14211
|
+
normalizedCornerRadius = Array.isArray(cornerRadius) ? [] : null;
|
|
14212
|
+
for (let i = 0; i < points.length; i++) normalizedPoints.length && isSamePoint(normalizedPoints[normalizedPoints.length - 1], points[i]) || (normalizedPoints.push(points[i]), null == normalizedCornerRadius || normalizedCornerRadius.push(null !== (_a = cornerRadius[i]) && void 0 !== _a ? _a : 0));
|
|
14213
|
+
return closePath && normalizedPoints.length > 1 && isSamePoint(normalizedPoints[0], normalizedPoints[normalizedPoints.length - 1]) && (normalizedPoints.pop(), null == normalizedCornerRadius || normalizedCornerRadius.pop()), {
|
|
14214
|
+
points: normalizedPoints,
|
|
14215
|
+
cornerRadius: null != normalizedCornerRadius ? normalizedCornerRadius : cornerRadius
|
|
14216
|
+
};
|
|
14217
|
+
}
|
|
14218
|
+
function isSamePoint(a, b) {
|
|
14219
|
+
return a.x === b.x && a.y === b.y;
|
|
14220
|
+
}
|
|
14221
|
+
function getPolygonWinding(points) {
|
|
14222
|
+
let signedArea = 0;
|
|
14223
|
+
for (let i = 0; i < points.length; i++) {
|
|
14224
|
+
const current = points[i],
|
|
14225
|
+
next = points[(i + 1) % points.length];
|
|
14226
|
+
signedArea += current.x * next.y - next.x * current.y;
|
|
14227
|
+
}
|
|
14228
|
+
return signedArea > 0 ? 1 : -1;
|
|
14229
|
+
}
|
|
14230
|
+
function offsetPolygonPoints(points, distance, closePath = !0) {
|
|
14231
|
+
var _a;
|
|
14232
|
+
const n = null !== (_a = null == points ? void 0 : points.length) && void 0 !== _a ? _a : 0;
|
|
14233
|
+
if (n < 2 || closePath && n < 3 || !distance) return points;
|
|
14234
|
+
const sign = getPolygonWinding(points),
|
|
14235
|
+
edgeCount = closePath ? n : n - 1,
|
|
14236
|
+
lines = [];
|
|
14237
|
+
for (let i = 0; i < edgeCount; i++) {
|
|
14238
|
+
const cur = points[i],
|
|
14239
|
+
next = points[(i + 1) % n],
|
|
14240
|
+
dx = next.x - cur.x,
|
|
14241
|
+
dy = next.y - cur.y,
|
|
14242
|
+
len = Math.sqrt(dx * dx + dy * dy);
|
|
14243
|
+
if (!len) {
|
|
14244
|
+
lines.push(null);
|
|
14245
|
+
continue;
|
|
14246
|
+
}
|
|
14247
|
+
const offsetX = sign * dy * distance / len,
|
|
14248
|
+
offsetY = -sign * dx * distance / len;
|
|
14249
|
+
lines.push({
|
|
14250
|
+
x: cur.x + offsetX,
|
|
14251
|
+
y: cur.y + offsetY,
|
|
14252
|
+
dx: dx,
|
|
14253
|
+
dy: dy,
|
|
14254
|
+
len: len,
|
|
14255
|
+
offsetX: offsetX,
|
|
14256
|
+
offsetY: offsetY
|
|
14257
|
+
});
|
|
14258
|
+
}
|
|
14259
|
+
const prevLines = new Array(n);
|
|
14260
|
+
let prevLine = null;
|
|
14261
|
+
if (closePath) for (let i = edgeCount - 1; i >= 0; i--) if (lines[i]) {
|
|
14262
|
+
prevLine = lines[i];
|
|
14263
|
+
break;
|
|
14264
|
+
}
|
|
14265
|
+
for (let i = 0; i < n; i++) prevLines[i] = prevLine, i < edgeCount && lines[i] && (prevLine = lines[i]);
|
|
14266
|
+
const nextLines = new Array(n);
|
|
14267
|
+
let nextLine = null;
|
|
14268
|
+
if (closePath) for (let count = 0; count < edgeCount; count++) {
|
|
14269
|
+
const line = lines[(n - 1 + count) % edgeCount];
|
|
14270
|
+
if (line) {
|
|
14271
|
+
nextLine = line;
|
|
14272
|
+
break;
|
|
14273
|
+
}
|
|
14274
|
+
}
|
|
14275
|
+
for (let i = n - 1; i >= 0; i--) i < edgeCount && lines[i] && (nextLine = lines[i]), nextLines[i] = nextLine;
|
|
14276
|
+
const offsetPointByLine = (point, line) => ({
|
|
14277
|
+
x: point.x + line.offsetX,
|
|
14278
|
+
y: point.y + line.offsetY
|
|
14279
|
+
}),
|
|
14280
|
+
result = [];
|
|
14281
|
+
for (let i = 0; i < n; i++) {
|
|
14282
|
+
const prev = prevLines[i],
|
|
14283
|
+
cur = nextLines[i],
|
|
14284
|
+
line = prev || cur;
|
|
14285
|
+
if (!line) {
|
|
14286
|
+
result.push(points[i]);
|
|
14287
|
+
continue;
|
|
14288
|
+
}
|
|
14289
|
+
if (!prev || !cur) {
|
|
14290
|
+
result.push(offsetPointByLine(points[i], line));
|
|
14291
|
+
continue;
|
|
14292
|
+
}
|
|
14293
|
+
const denominator = prev.dx * cur.dy - prev.dy * cur.dx;
|
|
14294
|
+
if (Math.abs(denominator) <= 1e-12 * prev.len * cur.len) {
|
|
14295
|
+
result.push(offsetPointByLine(points[i], cur));
|
|
14296
|
+
continue;
|
|
14297
|
+
}
|
|
14298
|
+
const t = ((cur.x - prev.x) * cur.dy - (cur.y - prev.y) * cur.dx) / denominator,
|
|
14299
|
+
point = {
|
|
14300
|
+
x: prev.x + prev.dx * t,
|
|
14301
|
+
y: prev.y + prev.dy * t
|
|
14302
|
+
};
|
|
14303
|
+
result.push(Number.isFinite(point.x) && Number.isFinite(point.y) ? point : offsetPointByLine(points[i], cur));
|
|
14304
|
+
}
|
|
14305
|
+
return result;
|
|
14306
|
+
}
|
|
14307
|
+
|
|
14308
|
+
const getBoundsScaleMatrix = polygon => {
|
|
14309
|
+
var _a;
|
|
14310
|
+
const globalMatrix = polygon.globalTransMatrix,
|
|
14311
|
+
viewBoxMatrix = null === (_a = polygon.stage) || void 0 === _a ? void 0 : _a.window.getViewBoxTransform();
|
|
14312
|
+
return viewBoxMatrix ? {
|
|
14313
|
+
a: viewBoxMatrix.a * globalMatrix.a + viewBoxMatrix.c * globalMatrix.b,
|
|
14314
|
+
b: viewBoxMatrix.b * globalMatrix.a + viewBoxMatrix.d * globalMatrix.b,
|
|
14315
|
+
c: viewBoxMatrix.a * globalMatrix.c + viewBoxMatrix.c * globalMatrix.d,
|
|
14316
|
+
d: viewBoxMatrix.b * globalMatrix.c + viewBoxMatrix.d * globalMatrix.d
|
|
14317
|
+
} : globalMatrix;
|
|
14318
|
+
};
|
|
14319
|
+
const getPolygonBoundsScale = polygon => getScaledStrokeWithMatrix(getBoundsScaleMatrix(polygon), 1, 1);
|
|
14320
|
+
const updateBoundsOfPolygonOuterBorder = (attribute, polygonTheme, aabbBounds, polygon) => {
|
|
14321
|
+
const {
|
|
14322
|
+
outerBorder: outerBorder,
|
|
14323
|
+
points = polygonTheme.points,
|
|
14324
|
+
closePath = polygonTheme.closePath,
|
|
14325
|
+
shadowBlur = polygonTheme.shadowBlur,
|
|
14326
|
+
keepStrokeScale = polygonTheme.keepStrokeScale
|
|
14327
|
+
} = attribute;
|
|
14328
|
+
if (outerBorder && !1 !== outerBorder.visible) {
|
|
14329
|
+
const defaultOuterBorder = polygonTheme.outerBorder,
|
|
14330
|
+
{
|
|
14331
|
+
distance = defaultOuterBorder.distance,
|
|
14332
|
+
lineWidth = defaultOuterBorder.lineWidth,
|
|
14333
|
+
lineJoin = defaultOuterBorder.lineJoin,
|
|
14334
|
+
strokeBoundsBuffer = defaultOuterBorder.strokeBoundsBuffer
|
|
14335
|
+
} = outerBorder,
|
|
14336
|
+
boundsScale = getPolygonBoundsScale(polygon);
|
|
14337
|
+
let scaledDistance = distance;
|
|
14338
|
+
keepStrokeScale || (scaledDistance *= boundsScale), offsetPolygonPoints(points, scaledDistance, closePath).forEach(point => {
|
|
14339
|
+
aabbBounds.add(point.x, point.y);
|
|
14340
|
+
});
|
|
14341
|
+
boundStroke(aabbBounds, (shadowBlur * boundsScale + lineWidth * (keepStrokeScale ? 1 : boundsScale)) / 2, "miter" === lineJoin, strokeBoundsBuffer);
|
|
14342
|
+
}
|
|
14343
|
+
return aabbBounds;
|
|
14344
|
+
};
|
|
14345
|
+
|
|
14346
|
+
const POLYGON_UPDATE_TAG_KEY = ["points", "cornerRadius", "outerBorder", "keepStrokeScale", ...GRAPHIC_UPDATE_TAG_KEY];
|
|
14142
14347
|
class Polygon extends Graphic {
|
|
14143
14348
|
constructor(params) {
|
|
14144
14349
|
super(params), this.type = "polygon", this.numberType = POLYGON_NUMBER_TYPE;
|
|
@@ -14155,6 +14360,16 @@ class Polygon extends Graphic {
|
|
|
14155
14360
|
getGraphicTheme() {
|
|
14156
14361
|
return getTheme(this).polygon;
|
|
14157
14362
|
}
|
|
14363
|
+
tryUpdateAABBBounds() {
|
|
14364
|
+
const {
|
|
14365
|
+
outerBorder: outerBorder
|
|
14366
|
+
} = this.attribute;
|
|
14367
|
+
if (outerBorder && !1 !== outerBorder.visible) {
|
|
14368
|
+
const boundsScale = getPolygonBoundsScale(this);
|
|
14369
|
+
boundsScale !== this._outerBorderBoundsScale && (this._outerBorderBoundsScale = boundsScale, this.addUpdateBoundTag());
|
|
14370
|
+
} else this._outerBorderBoundsScale = void 0;
|
|
14371
|
+
return super.tryUpdateAABBBounds();
|
|
14372
|
+
}
|
|
14158
14373
|
updateAABBBounds(attribute, polygonTheme, aabbBounds) {
|
|
14159
14374
|
this.updatePathProxyAABBBounds(aabbBounds) || this.updatePolygonAABBBoundsImprecise(attribute, polygonTheme, aabbBounds), application.graphicService.updateTempAABBBounds(aabbBounds), this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;
|
|
14160
14375
|
const {
|
|
@@ -14168,7 +14383,7 @@ class Polygon extends Graphic {
|
|
|
14168
14383
|
} = attribute;
|
|
14169
14384
|
return points.forEach(p => {
|
|
14170
14385
|
aabbBounds.add(p.x, p.y);
|
|
14171
|
-
}), aabbBounds;
|
|
14386
|
+
}), updateBoundsOfPolygonOuterBorder(attribute, polygonTheme, aabbBounds, this), aabbBounds;
|
|
14172
14387
|
}
|
|
14173
14388
|
_interpolate(key, ratio, lastStepVal, nextStepVal, nextAttributes) {
|
|
14174
14389
|
"points" === key && (nextAttributes.points = pointsInterpolation(lastStepVal, nextStepVal, ratio));
|
|
@@ -15096,22 +15311,26 @@ class DefaultRectRenderContribution {
|
|
|
15096
15311
|
width: width,
|
|
15097
15312
|
height: height
|
|
15098
15313
|
} = rect.attribute;
|
|
15099
|
-
width = (null != width ? width : x1 -
|
|
15100
|
-
const
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
15109
|
-
|
|
15110
|
-
|
|
15111
|
-
|
|
15112
|
-
|
|
15113
|
-
|
|
15114
|
-
|
|
15314
|
+
width = (null != width ? width : x1 - originX) || 0, height = (null != height ? height : y1 - originY) || 0;
|
|
15315
|
+
const borderX = width < 0 ? x + width : x,
|
|
15316
|
+
borderY = height < 0 ? y + height : y,
|
|
15317
|
+
borderWidth = width < 0 ? -width : width,
|
|
15318
|
+
borderHeight = height < 0 ? -height : height,
|
|
15319
|
+
renderBorder = (borderStyle, key) => {
|
|
15320
|
+
const doStroke = !(!borderStyle || !borderStyle.stroke),
|
|
15321
|
+
sign = "outerBorder" === key ? -1 : 1,
|
|
15322
|
+
{
|
|
15323
|
+
distance = rectAttribute[key].distance
|
|
15324
|
+
} = borderStyle,
|
|
15325
|
+
d = keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr),
|
|
15326
|
+
nextX = borderX + sign * d,
|
|
15327
|
+
nextY = borderY + sign * d,
|
|
15328
|
+
dw = 2 * d;
|
|
15329
|
+
if (0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? (context.beginPath(), context.rect(nextX, nextY, borderWidth - sign * dw, borderHeight - sign * dw)) : (context.beginPath(), createRectPath(context, nextX, nextY, borderWidth - sign * dw, borderHeight - sign * dw, cornerRadius, "bevel" !== cornerType)), context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), strokeCb) strokeCb(context, borderStyle, rectAttribute[key]);else if (doStroke) {
|
|
15330
|
+
const lastOpacity = rectAttribute[key].opacity;
|
|
15331
|
+
rectAttribute[key].opacity = opacity, context.setStrokeStyle(rect, borderStyle, (originX - x) / scaleX, (originY - y) / scaleY, rectAttribute[key]), rectAttribute[key].opacity = lastOpacity, context.stroke();
|
|
15332
|
+
}
|
|
15333
|
+
};
|
|
15115
15334
|
doOuterBorder && renderBorder(outerBorder, "outerBorder"), doInnerBorder && renderBorder(innerBorder, "innerBorder");
|
|
15116
15335
|
}
|
|
15117
15336
|
}
|
|
@@ -17346,64 +17565,69 @@ function bindPathRenderModule({
|
|
|
17346
17565
|
}
|
|
17347
17566
|
const pathModule = bindPathRenderModule;
|
|
17348
17567
|
|
|
17349
|
-
|
|
17350
|
-
|
|
17351
|
-
|
|
17352
|
-
|
|
17568
|
+
const defaultPolygonTextureRenderContribution = defaultBaseTextureRenderContribution;
|
|
17569
|
+
const defaultPolygonBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
|
|
17570
|
+
class DefaultPolygonRenderContribution {
|
|
17571
|
+
constructor() {
|
|
17572
|
+
this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
|
|
17353
17573
|
}
|
|
17354
|
-
|
|
17355
|
-
|
|
17356
|
-
|
|
17357
|
-
|
|
17358
|
-
|
|
17359
|
-
|
|
17360
|
-
|
|
17361
|
-
|
|
17362
|
-
const
|
|
17363
|
-
|
|
17364
|
-
|
|
17365
|
-
|
|
17366
|
-
|
|
17367
|
-
|
|
17368
|
-
|
|
17369
|
-
|
|
17370
|
-
|
|
17371
|
-
|
|
17372
|
-
|
|
17373
|
-
|
|
17374
|
-
|
|
17375
|
-
|
|
17376
|
-
|
|
17377
|
-
|
|
17378
|
-
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17574
|
+
drawShape(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb) {
|
|
17575
|
+
const {
|
|
17576
|
+
outerBorder: outerBorder,
|
|
17577
|
+
innerBorder: innerBorder
|
|
17578
|
+
} = polygon.attribute,
|
|
17579
|
+
doOuterBorder = outerBorder && !1 !== outerBorder.visible,
|
|
17580
|
+
doInnerBorder = innerBorder && !1 !== innerBorder.visible;
|
|
17581
|
+
if (!doOuterBorder && !doInnerBorder) return;
|
|
17582
|
+
const {
|
|
17583
|
+
points = polygonAttribute.points,
|
|
17584
|
+
cornerRadius = polygonAttribute.cornerRadius,
|
|
17585
|
+
opacity = polygonAttribute.opacity,
|
|
17586
|
+
x: originX = polygonAttribute.x,
|
|
17587
|
+
y: originY = polygonAttribute.y,
|
|
17588
|
+
scaleX = polygonAttribute.scaleX,
|
|
17589
|
+
scaleY = polygonAttribute.scaleY,
|
|
17590
|
+
keepStrokeScale = polygonAttribute.keepStrokeScale,
|
|
17591
|
+
closePath = polygonAttribute.closePath
|
|
17592
|
+
} = polygon.attribute,
|
|
17593
|
+
renderBorder = (borderStyle, key) => {
|
|
17594
|
+
var _a, _b;
|
|
17595
|
+
const doBorderStroke = !!borderStyle.stroke,
|
|
17596
|
+
distanceDirection = "outerBorder" === key ? 1 : -1,
|
|
17597
|
+
{
|
|
17598
|
+
distance = polygonAttribute[key].distance
|
|
17599
|
+
} = borderStyle,
|
|
17600
|
+
borderDistance = distanceDirection * (keepStrokeScale ? distance : getScaledStroke(context, distance, context.dpr)),
|
|
17601
|
+
normalized = normalizePolygonPoints(points, cornerRadius, closePath),
|
|
17602
|
+
normalizedPoints = null !== (_a = null == normalized ? void 0 : normalized.points) && void 0 !== _a ? _a : points,
|
|
17603
|
+
normalizedCornerRadius = null !== (_b = null == normalized ? void 0 : normalized.cornerRadius) && void 0 !== _b ? _b : cornerRadius,
|
|
17604
|
+
borderPoints = offsetPolygonPoints(normalizedPoints, borderDistance, closePath),
|
|
17605
|
+
winding = getPolygonWinding(normalizedPoints),
|
|
17606
|
+
borderCornerRadius = normalizedPoints.map((point, i) => {
|
|
17607
|
+
var _a;
|
|
17608
|
+
const radius = isArray(normalizedCornerRadius) ? null !== (_a = normalizedCornerRadius[i]) && void 0 !== _a ? _a : 0 : normalizedCornerRadius || 0;
|
|
17609
|
+
if (!closePath && (0 === i || i === normalizedPoints.length - 1) || normalizedPoints.length < 3) return radius;
|
|
17610
|
+
const prev = normalizedPoints[(i - 1 + normalizedPoints.length) % normalizedPoints.length],
|
|
17611
|
+
next = normalizedPoints[(i + 1) % normalizedPoints.length],
|
|
17612
|
+
cornerDirection = ((point.x - prev.x) * (next.y - point.y) - (point.y - prev.y) * (next.x - point.x)) * winding < 0 ? -1 : 1;
|
|
17613
|
+
return Math.max(0, radius + borderDistance * cornerDirection);
|
|
17614
|
+
}),
|
|
17615
|
+
noCorner = 0 === borderCornerRadius.length || borderCornerRadius.every(r => 0 === r);
|
|
17616
|
+
if (context.beginPath(), noCorner ? drawPolygon(context.camera ? context : context.nativeContext, borderPoints, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, borderPoints, x, y, borderCornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), strokeCb) strokeCb(context, borderStyle, polygonAttribute[key]);else if (doBorderStroke) {
|
|
17617
|
+
const lastOpacity = polygonAttribute[key].opacity,
|
|
17618
|
+
borderStyleWithStrokeScale = borderStyle,
|
|
17619
|
+
lastKeepStrokeScale = borderStyleWithStrokeScale.keepStrokeScale;
|
|
17620
|
+
polygonAttribute[key].opacity = opacity, borderStyleWithStrokeScale.keepStrokeScale = keepStrokeScale, context.setStrokeStyle(polygon, borderStyleWithStrokeScale, (originX - x) / scaleX, (originY - y) / scaleY, polygonAttribute[key]), polygonAttribute[key].opacity = lastOpacity, void 0 === lastKeepStrokeScale ? delete borderStyleWithStrokeScale.keepStrokeScale : borderStyleWithStrokeScale.keepStrokeScale = lastKeepStrokeScale, context.stroke();
|
|
17621
|
+
}
|
|
17622
|
+
};
|
|
17623
|
+
doOuterBorder && renderBorder(outerBorder, "outerBorder"), doInnerBorder && renderBorder(innerBorder, "innerBorder");
|
|
17387
17624
|
}
|
|
17388
|
-
closePath || path.lineTo(points[endI + 1].x + x, points[endI + 1].y + y);
|
|
17389
|
-
}
|
|
17390
|
-
function getLength(dx, dy) {
|
|
17391
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
17392
|
-
}
|
|
17393
|
-
function getProportionPoint(point, segment, length, dx, dy) {
|
|
17394
|
-
const factor = segment / length;
|
|
17395
|
-
return {
|
|
17396
|
-
x: point.x - dx * factor,
|
|
17397
|
-
y: point.y - dy * factor
|
|
17398
|
-
};
|
|
17399
17625
|
}
|
|
17400
|
-
|
|
17401
|
-
const defaultPolygonTextureRenderContribution = defaultBaseTextureRenderContribution;
|
|
17402
|
-
const defaultPolygonBackgroundRenderContribution = defaultBaseBackgroundRenderContribution;
|
|
17626
|
+
const defaultPolygonRenderContribution = new DefaultPolygonRenderContribution();
|
|
17403
17627
|
|
|
17404
17628
|
class DefaultCanvasPolygonRender extends BaseRender {
|
|
17405
17629
|
constructor(graphicRenderContributions) {
|
|
17406
|
-
super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = POLYGON_NUMBER_TYPE, this.builtinContributions = [defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution], this.init(graphicRenderContributions);
|
|
17630
|
+
super(), this.graphicRenderContributions = graphicRenderContributions, this.numberType = POLYGON_NUMBER_TYPE, this.builtinContributions = [defaultPolygonRenderContribution, defaultPolygonBackgroundRenderContribution, defaultPolygonTextureRenderContribution], this.init(graphicRenderContributions);
|
|
17407
17631
|
}
|
|
17408
17632
|
drawShape(polygon, context, x, y, drawContext, params, fillCb, strokeCb) {
|
|
17409
17633
|
const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon,
|
|
@@ -22832,6 +23056,8 @@ function getLynxRuntime(params) {
|
|
|
22832
23056
|
var _a, _b;
|
|
22833
23057
|
return (_b = (_a = params === null || params === void 0 ? void 0 : params.lynx) !== null && _a !== void 0 ? _a : params === null || params === void 0 ? void 0 : params.runtime) !== null && _b !== void 0 ? _b : getGlobalLynxRuntime();
|
|
22834
23058
|
}
|
|
23059
|
+
const requestAnimationFrameBasedSTO = (callback) => rafBasedSto.call(callback);
|
|
23060
|
+
const cancelAnimationFrameBasedSTO = (handle) => rafBasedSto.clear(handle);
|
|
22835
23061
|
function getLynxPixelRatio(params, runtime) {
|
|
22836
23062
|
var _a, _b, _c, _d, _e;
|
|
22837
23063
|
return (_e = (_d = (_a = params === null || params === void 0 ? void 0 : params.pixelRatio) !== null && _a !== void 0 ? _a : (_c = (_b = runtime === null || runtime === void 0 ? void 0 : runtime.getSystemInfoSync) === null || _b === void 0 ? void 0 : _b.call(runtime)) === null || _c === void 0 ? void 0 : _c.pixelRatio) !== null && _d !== void 0 ? _d : getGlobalSystemPixelRatio()) !== null && _e !== void 0 ? _e : 1;
|
|
@@ -22933,6 +23159,8 @@ class LynxEnvContribution extends BaseEnvContribution {
|
|
|
22933
23159
|
this.canvasMap = new Map();
|
|
22934
23160
|
this.freeCanvasList = [];
|
|
22935
23161
|
this.canvasIdx = 0;
|
|
23162
|
+
this.requestAnimationFrame = requestAnimationFrameBasedSTO;
|
|
23163
|
+
this.cancelAnimationFrame = cancelAnimationFrameBasedSTO;
|
|
22936
23164
|
this.supportsTouchEvents = true;
|
|
22937
23165
|
try {
|
|
22938
23166
|
this.supportsPointerEvents = !!globalThis.PointerEvent;
|
|
@@ -22945,10 +23173,20 @@ class LynxEnvContribution extends BaseEnvContribution {
|
|
|
22945
23173
|
this.applyStyles = true;
|
|
22946
23174
|
}
|
|
22947
23175
|
configure(service, params = {}) {
|
|
23176
|
+
var _a, _b;
|
|
22948
23177
|
if (service.env === this.type) {
|
|
22949
23178
|
service.setActiveEnvContribution(this);
|
|
22950
23179
|
this.lynxEnvParams = params;
|
|
22951
23180
|
this.lynxRuntime = getLynxRuntime(params);
|
|
23181
|
+
if (typeof ((_a = this.lynxRuntime) === null || _a === void 0 ? void 0 : _a.requestAnimationFrame) === 'function' &&
|
|
23182
|
+
typeof ((_b = this.lynxRuntime) === null || _b === void 0 ? void 0 : _b.cancelAnimationFrame) === 'function') {
|
|
23183
|
+
this.requestAnimationFrame = this.lynxRuntime.requestAnimationFrame.bind(this.lynxRuntime);
|
|
23184
|
+
this.cancelAnimationFrame = this.lynxRuntime.cancelAnimationFrame.bind(this.lynxRuntime);
|
|
23185
|
+
}
|
|
23186
|
+
else {
|
|
23187
|
+
this.requestAnimationFrame = requestAnimationFrameBasedSTO;
|
|
23188
|
+
this.cancelAnimationFrame = cancelAnimationFrameBasedSTO;
|
|
23189
|
+
}
|
|
22952
23190
|
}
|
|
22953
23191
|
}
|
|
22954
23192
|
getDynamicCanvasCount() {
|
|
@@ -23022,14 +23260,10 @@ class LynxEnvContribution extends BaseEnvContribution {
|
|
|
23022
23260
|
return getLynxPixelRatio(undefined, this.lynxRuntime);
|
|
23023
23261
|
}
|
|
23024
23262
|
getRequestAnimationFrame() {
|
|
23025
|
-
return
|
|
23026
|
-
return rafBasedSto.call(callback);
|
|
23027
|
-
};
|
|
23263
|
+
return this.requestAnimationFrame;
|
|
23028
23264
|
}
|
|
23029
23265
|
getCancelAnimationFrame() {
|
|
23030
|
-
return
|
|
23031
|
-
rafBasedSto.clear(h);
|
|
23032
|
-
};
|
|
23266
|
+
return this.cancelAnimationFrame;
|
|
23033
23267
|
}
|
|
23034
23268
|
mapToCanvasPoint(event) {
|
|
23035
23269
|
var _a;
|