@visactor/vrender-kits 1.1.8-alpha.0 → 1.1.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/canvas/contributions/create-canvas-module.js +1 -1
- package/cjs/canvas/contributions/lynx/context.js +12 -8
- package/cjs/canvas/contributions/lynx/context.js.map +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/dist/index.es.js +81 -48
- package/es/canvas/contributions/create-canvas-module.js +1 -1
- package/es/canvas/contributions/lynx/context.js +12 -8
- package/es/canvas/contributions/lynx/context.js.map +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/package.json +3 -3
|
@@ -35,14 +35,18 @@ class LynxContext2d extends browser_1.BrowserContext2d {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
measureText(text, method = application_1.application.global.measureTextMethod) {
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
const dpr = this.dpr || 1;
|
|
39
|
+
this.setTransform(1, 0, 0, 1, 0, 0, !0, dpr);
|
|
40
|
+
const metrics = super.measureText(text, method);
|
|
41
|
+
return 1 === dpr || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent ? metrics : Object.assign(Object.assign({}, metrics), {
|
|
42
|
+
width: metrics.width,
|
|
43
|
+
actualBoundingBoxLeft: metrics.actualBoundingBoxLeft,
|
|
44
|
+
actualBoundingBoxRight: metrics.actualBoundingBoxRight,
|
|
45
|
+
actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
|
|
46
|
+
actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
|
|
47
|
+
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent / dpr,
|
|
48
|
+
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent / dpr
|
|
49
|
+
});
|
|
46
50
|
}
|
|
47
51
|
createPattern(image, repetition) {
|
|
48
52
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/canvas/contributions/lynx/context.ts"],"names":[],"mappings":";;;AACA,oEAAiE;AACjE,yDAAsE;AAEtE,wCAA8C;AAE9C,MAAa,aAAc,SAAQ,0BAAgB;IAOjD,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,IAAI,WAAW,CAAC,EAAU;QACxB,IAAI,CAAC,aAAa,CAAC,WAAW,GAAG,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;QAC3D,IAAI,CAAC,YAAY,GAAG,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC;IAChD,CAAC;IAED,WAAW,CAAC,QAAkB;QAC5B,MAAM,CAAC,GAAG,SAAS,CAAC;QACpB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC;QAEpC,IAAI,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YACpC,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAEtB,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;gBAC1C,OAAO;aACR;YACD,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;SAC5C;IACH,CAAC;IAES,eAAe,CACvB,MAA6B,EAC7B,SAA6B,EAE7B,OAAe,EACf,OAAe,EACf,aAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC;QACpC,IAAI,CAAC,aAAa,EAAE;YAClB,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC;SACvC;QACD,MAAM,EAAE,aAAa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QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAxGH,sCAyGC;AAxGQ,iBAAG,GAAY,MAAM,CAAC","file":"context.js","sourcesContent":["// 参考konva\nimport { application } from '@visactor/vrender-core/application';\nimport { createColor, getScaledStroke } from '@visactor/vrender-core';\nimport type { IContext2d, EnvType, ISetStrokeStyleParams, IStrokeStyleParams } from '@visactor/vrender-core';\nimport { BrowserContext2d } from '../browser';\n\nexport class LynxContext2d extends BrowserContext2d implements IContext2d {\n static env: EnvType = 'lynx';\n\n declare drawPromise?: Promise<any>;\n\n declare _globalAlpha: number;\n\n get globalAlpha(): number {\n return this._globalAlpha;\n }\n set globalAlpha(ga: number) {\n this.nativeContext.globalAlpha = ga * this.baseGlobalAlpha;\n this._globalAlpha = ga * this.baseGlobalAlpha;\n }\n\n setLineDash(segments: number[]) {\n const a = arguments;\n const _context = this.nativeContext;\n\n if (!!this.nativeContext.setLineDash) {\n const lineDash = a[0];\n // lynx环境中lineDash不能为[0, 0]\n if (lineDash[0] === 0 && lineDash[1] === 0) {\n return;\n }\n lineDash && _context.setLineDash(lineDash);\n }\n }\n\n protected _setStrokeStyle(\n params: ISetStrokeStyleParams,\n attribute: IStrokeStyleParams,\n // 用于渐变色\n offsetX: number,\n offsetY: number,\n defaultParams?: IStrokeStyleParams\n ) {\n const _context = this.nativeContext;\n if (!defaultParams) {\n defaultParams = this.strokeAttributes;\n }\n const { strokeOpacity = defaultParams.strokeOpacity, opacity = defaultParams.opacity } = attribute;\n if (strokeOpacity > 1e-12 && opacity > 1e-12) {\n const {\n lineWidth = defaultParams.lineWidth,\n stroke = defaultParams.stroke,\n lineJoin = defaultParams.lineJoin,\n lineDash = defaultParams.lineDash,\n lineCap = defaultParams.lineCap,\n miterLimit = defaultParams.miterLimit,\n keepStrokeScale = defaultParams.keepStrokeScale,\n lineDashOffset = defaultParams.lineDashOffset\n } = attribute;\n _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha;\n _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr);\n _context.strokeStyle = createColor(this, stroke as any, params, offsetX, offsetY);\n _context.lineJoin = lineJoin;\n // lynx环境中lineDash不能为[0, 0]\n if (!(lineDash[0] === 0 && lineDash[1] === 0) && lineDash) {\n _context.setLineDash(lineDash);\n _context.lineDashOffset = lineDashOffset;\n }\n _context.lineCap = lineCap;\n _context.miterLimit = miterLimit;\n }\n }\n\n measureText(\n text: string,\n method: 'native' | 'simple' | 'quick' = application.global.measureTextMethod\n ): { width: number } {\n const dpr = this.dpr || 1;\n this.setTransform(1, 0, 0, 1, 0, 0, true, dpr);\n const metrics = super.measureText(text, method) as TextMetrics;\n if (dpr === 1 || metrics.fontBoundingBoxAscent == null || metrics.fontBoundingBoxDescent == null) {\n return metrics;\n }\n return {\n ...metrics,\n width: metrics.width,\n actualBoundingBoxLeft: metrics.actualBoundingBoxLeft,\n actualBoundingBoxRight: metrics.actualBoundingBoxRight,\n actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,\n actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,\n fontBoundingBoxAscent: metrics.fontBoundingBoxAscent / dpr,\n fontBoundingBoxDescent: metrics.fontBoundingBoxDescent / dpr\n } as any;\n }\n\n createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern {\n return null;\n }\n\n draw() {\n const _context = this.nativeContext as any;\n if (!_context.draw) {\n return;\n }\n this.drawPromise = new Promise(resolve => {\n _context.draw(true, () => {\n this.drawPromise = null;\n resolve(null);\n });\n });\n }\n}\n"]}
|
|
@@ -45,4 +45,4 @@ exports.loadAllCavnvas = loadAllCavnvas, exports.loadBrowserCanvas = loadBrowser
|
|
|
45
45
|
exports.loadFeishuCanvas = loadFeishuCanvas, exports.loadLynxCanvas = loadLynxCanvas,
|
|
46
46
|
exports.loadNodeCanvas = loadNodeCanvas, exports.loadTaroCanvas = loadTaroCanvas,
|
|
47
47
|
exports.loadTTCanvas = loadTTCanvas, exports.loadWxCanvas = loadWxCanvas;
|
|
48
|
-
//# sourceMappingURL=modules.js.map
|
|
48
|
+
//# sourceMappingURL=modules.js.map
|
package/dist/index.es.js
CHANGED
|
@@ -6290,7 +6290,7 @@ class Node extends EventEmitter {
|
|
|
6290
6290
|
constructor() {
|
|
6291
6291
|
super(), this._uid = Generator.GenAutoIncrementId(), this._firstChild = null, this._lastChild = null, this.parent = null, this._count = 1;
|
|
6292
6292
|
}
|
|
6293
|
-
onParentSharedStateTreeChanged(_stage, _layer) {}
|
|
6293
|
+
onParentSharedStateTreeChanged(_stage, _layer, _inheritedSharedStateScope) {}
|
|
6294
6294
|
forEachChildren(cb, reverse = !1) {
|
|
6295
6295
|
if (reverse) {
|
|
6296
6296
|
let child = this._lastChild,
|
|
@@ -8647,14 +8647,17 @@ class GraphicImpl extends Node {
|
|
|
8647
8647
|
}
|
|
8648
8648
|
return null === (_a = this.stage) || void 0 === _a ? void 0 : _a.rootSharedStateScope;
|
|
8649
8649
|
}
|
|
8650
|
-
|
|
8650
|
+
syncSharedStateScopeBinding(nextScope, markDirty = !0) {
|
|
8651
8651
|
var _a;
|
|
8652
|
-
const nextScope = this.resolveBoundSharedStateScope();
|
|
8653
8652
|
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);
|
|
8654
8653
|
}
|
|
8655
|
-
|
|
8654
|
+
syncSharedStateScopeBindingFromTree(markDirty = !0, inheritedSharedStateScope) {
|
|
8655
|
+
const nextScope = void 0 === inheritedSharedStateScope ? this.resolveBoundSharedStateScope() : null != inheritedSharedStateScope ? inheritedSharedStateScope : void 0;
|
|
8656
|
+
return this.syncSharedStateScopeBinding(nextScope, markDirty);
|
|
8657
|
+
}
|
|
8658
|
+
syncSharedStateScopeBindingOnTreeChange(markDirty = !0, inheritedSharedStateScope) {
|
|
8656
8659
|
var _a, _b;
|
|
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);
|
|
8660
|
+
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);
|
|
8658
8661
|
}
|
|
8659
8662
|
syncSharedStateActiveRegistrations() {
|
|
8660
8663
|
var _a;
|
|
@@ -8662,6 +8665,7 @@ class GraphicImpl extends Node {
|
|
|
8662
8665
|
if (!(null === (_a = this.currentStates) || void 0 === _a ? void 0 : _a.length) || !this.boundSharedStateScope) return (null == previousScopes ? void 0 : previousScopes.size) && (previousScopes.forEach(scope => {
|
|
8663
8666
|
scope.subtreeActiveDescendants.delete(this);
|
|
8664
8667
|
}), previousScopes.clear()), void (this.registeredActiveScopes = void 0);
|
|
8668
|
+
if ((null == previousScopes ? void 0 : previousScopes.size) && this.isSharedStateScopeChainRegistered(previousScopes)) return;
|
|
8665
8669
|
const nextScopes = new Set(collectSharedStateScopeChain(this.boundSharedStateScope));
|
|
8666
8670
|
null == previousScopes || previousScopes.forEach(scope => {
|
|
8667
8671
|
nextScopes.has(scope) || scope.subtreeActiveDescendants.delete(this);
|
|
@@ -8669,6 +8673,15 @@ class GraphicImpl extends Node {
|
|
|
8669
8673
|
scope.subtreeActiveDescendants.add(this);
|
|
8670
8674
|
}), this.registeredActiveScopes = nextScopes;
|
|
8671
8675
|
}
|
|
8676
|
+
isSharedStateScopeChainRegistered(previousScopes) {
|
|
8677
|
+
let scope = this.boundSharedStateScope,
|
|
8678
|
+
scopeCount = 0;
|
|
8679
|
+
for (; scope;) {
|
|
8680
|
+
if (!previousScopes.has(scope)) return !1;
|
|
8681
|
+
scopeCount += 1, scope = scope.parentScope;
|
|
8682
|
+
}
|
|
8683
|
+
return scopeCount === previousScopes.size;
|
|
8684
|
+
}
|
|
8672
8685
|
clearSharedStateActiveRegistrations() {
|
|
8673
8686
|
const previousScopes = this.registeredActiveScopes;
|
|
8674
8687
|
previousScopes && (previousScopes.forEach(scope => {
|
|
@@ -8678,8 +8691,8 @@ class GraphicImpl extends Node {
|
|
|
8678
8691
|
markSharedStateDirty() {
|
|
8679
8692
|
this.sharedStateDirty = !0, enqueueGraphicSharedStateRefresh(this.stage, this), scheduleStageSharedStateRefresh(this.stage);
|
|
8680
8693
|
}
|
|
8681
|
-
onParentSharedStateTreeChanged(stage, layer) {
|
|
8682
|
-
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange() : this.setStage(stage, layer);
|
|
8694
|
+
onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
|
|
8695
|
+
this.stage === stage && this.layer === layer ? this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope) : this.setStage(stage, layer, inheritedSharedStateScope);
|
|
8683
8696
|
}
|
|
8684
8697
|
refreshSharedStateBeforeRender() {
|
|
8685
8698
|
var _a;
|
|
@@ -9329,6 +9342,10 @@ class GraphicImpl extends Node {
|
|
|
9329
9342
|
var _a;
|
|
9330
9343
|
return null === (_a = this.states) || void 0 === _a ? void 0 : _a[stateName];
|
|
9331
9344
|
}
|
|
9345
|
+
setStateDefinitionsWithCompiled(definitions, compiledDefinitions) {
|
|
9346
|
+
var _a;
|
|
9347
|
+
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}`;
|
|
9348
|
+
}
|
|
9332
9349
|
getStateResolveBaseAttrs() {
|
|
9333
9350
|
var _a;
|
|
9334
9351
|
return null !== (_a = this.baseAttributes) && void 0 !== _a ? _a : this.attribute;
|
|
@@ -9448,6 +9465,11 @@ class GraphicImpl extends Node {
|
|
|
9448
9465
|
}
|
|
9449
9466
|
return !0;
|
|
9450
9467
|
}
|
|
9468
|
+
hasStatePatch(patch) {
|
|
9469
|
+
if (!patch) return !1;
|
|
9470
|
+
for (const key in patch) if (Object.prototype.hasOwnProperty.call(patch, key)) return !0;
|
|
9471
|
+
return !1;
|
|
9472
|
+
}
|
|
9451
9473
|
commitSameStatePatchRefresh(states, hasAnimation, animateSameStatePatchChange = !1) {
|
|
9452
9474
|
var _a;
|
|
9453
9475
|
const previousStates = null !== (_a = this.currentStates) && void 0 !== _a ? _a : EMPTY_STATE_NAMES,
|
|
@@ -9515,15 +9537,17 @@ class GraphicImpl extends Node {
|
|
|
9515
9537
|
transition = this.resolveClearStatesTransition();
|
|
9516
9538
|
if (!transition.changed && 0 === previousStates.length) return this.currentStates = [], this.effectiveStates = [], this.resolvedStatePatch = void 0, this.sharedStateDirty = !1, void this.clearSharedStateActiveRegistrations();
|
|
9517
9539
|
const resolvedStateAttrs = hasAnimation || this.hasCustomEvent("beforeStateUpdate") ? cloneAttributeValue(null !== (_b = this.baseAttributes) && void 0 !== _b ? _b : {}) : null !== (_c = this.baseAttributes) && void 0 !== _c ? _c : {};
|
|
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(),
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9540
|
+
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(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch)) {
|
|
9541
|
+
if (hasAnimation) {
|
|
9542
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
9543
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
9544
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !0, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
9545
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
9546
|
+
type: AttributeUpdateType.STATE
|
|
9547
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, void 0, {
|
|
9548
|
+
type: AttributeUpdateType.STATE
|
|
9549
|
+
}), this.emitStateUpdateEvent();
|
|
9550
|
+
} else this.emitStateUpdateEvent();
|
|
9527
9551
|
}
|
|
9528
9552
|
removeState(stateName, hasAnimation) {
|
|
9529
9553
|
const transition = this.resolveRemoveStateTransition(stateName);
|
|
@@ -9564,15 +9588,17 @@ class GraphicImpl extends Node {
|
|
|
9564
9588
|
effectiveStates: effectiveStates,
|
|
9565
9589
|
resolvedStateAttrs: resolvedStateAttrs
|
|
9566
9590
|
} = this.resolveGraphicStateTransition(states);
|
|
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(),
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9591
|
+
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(), this.attributeMayContainTransientAttrs || this.hasStatePatch(previousResolvedStatePatch) || this.hasStatePatch(resolvedStateAttrs)) {
|
|
9592
|
+
if (hasAnimation) {
|
|
9593
|
+
this._syncFinalAttributeFromStaticTruth();
|
|
9594
|
+
const removedStateAnimationAttrs = this.buildRemovedStateAnimationAttrs(resolvedStateAttrs, previousResolvedStatePatch);
|
|
9595
|
+
this.applyStateAttrs(resolvedStateAttrs, transition.states, hasAnimation, !1, void 0, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.extraAttrs, null == removedStateAnimationAttrs ? void 0 : removedStateAnimationAttrs.stateTransitionTargetAttrs);
|
|
9596
|
+
} else this.stopStateAnimates(), this.attributeMayContainTransientAttrs ? this._restoreAttributeFromStaticTruth({
|
|
9597
|
+
type: AttributeUpdateType.STATE
|
|
9598
|
+
}) : this.restoreAttributeFromStatePatchDelta(previousResolvedStatePatch, this.resolvedStatePatch, {
|
|
9599
|
+
type: AttributeUpdateType.STATE
|
|
9600
|
+
}), this.emitStateUpdateEvent();
|
|
9601
|
+
} else this.emitStateUpdateEvent();
|
|
9576
9602
|
}
|
|
9577
9603
|
invalidateResolver() {
|
|
9578
9604
|
var _a, _b;
|
|
@@ -9692,12 +9718,12 @@ class GraphicImpl extends Node {
|
|
|
9692
9718
|
this._globalTransMatrix.translate(scrollX, scrollY);
|
|
9693
9719
|
}
|
|
9694
9720
|
}
|
|
9695
|
-
setStage(stage, layer) {
|
|
9721
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
9696
9722
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
9697
9723
|
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,
|
|
9698
9724
|
previousStage = this.stage;
|
|
9699
9725
|
if (this.stage !== stage || this.layer !== layer) {
|
|
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()) {
|
|
9726
|
+
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()) {
|
|
9701
9727
|
const previousTimeline = null === (_f = null == previousStage ? void 0 : previousStage.getTimeline) || void 0 === _f ? void 0 : _f.call(previousStage),
|
|
9702
9728
|
nextTimeline = null === (_g = null == stage ? void 0 : stage.getTimeline) || void 0 === _g ? void 0 : _g.call(stage),
|
|
9703
9729
|
detachedStageAnimates = [];
|
|
@@ -9714,7 +9740,7 @@ class GraphicImpl extends Node {
|
|
|
9714
9740
|
}
|
|
9715
9741
|
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));
|
|
9716
9742
|
}
|
|
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);
|
|
9743
|
+
((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);
|
|
9718
9744
|
}
|
|
9719
9745
|
detachStageForRelease() {
|
|
9720
9746
|
var _a, _b, _c;
|
|
@@ -10136,13 +10162,13 @@ class Group extends Graphic {
|
|
|
10136
10162
|
child.setStage(null, null);
|
|
10137
10163
|
}), this.addUpdateBoundTag();
|
|
10138
10164
|
}
|
|
10139
|
-
setStage(stage, layer) {
|
|
10165
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
10140
10166
|
var _a, _b, _c, _d, _e, _f;
|
|
10141
10167
|
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,
|
|
10142
10168
|
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;
|
|
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();
|
|
10169
|
+
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);
|
|
10144
10170
|
const layerChanged = this.layer !== layer;
|
|
10145
|
-
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0), this.notifyChildrenSharedStateTreeChanged()) : layerChanged && this.notifyChildrenSharedStateTreeChanged();
|
|
10171
|
+
layerChanged && (this.layer = layer), needsSharedStateTreeSync ? (this.ensureSharedStateScopeBound(), this.syncSharedStateScopeBindingOnTreeChange(!0, inheritedSharedStateScope), this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope)) : layerChanged && this.notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope);
|
|
10146
10172
|
}
|
|
10147
10173
|
addUpdatePositionTag() {
|
|
10148
10174
|
super.addUpdatePositionTag(), this.forEachChildren(g => {
|
|
@@ -10201,17 +10227,26 @@ class Group extends Graphic {
|
|
|
10201
10227
|
hasSharedStateDefinitions() {
|
|
10202
10228
|
return !!this._sharedStateDefinitions && Object.keys(this._sharedStateDefinitions).length > 0;
|
|
10203
10229
|
}
|
|
10204
|
-
|
|
10230
|
+
resolveChildSharedStateScope(inheritedSharedStateScope) {
|
|
10231
|
+
var _a;
|
|
10232
|
+
return this.sharedStateScope ? this.sharedStateScope : void 0 !== inheritedSharedStateScope ? inheritedSharedStateScope : null !== (_a = this.resolveBoundSharedStateScope()) && void 0 !== _a ? _a : null;
|
|
10233
|
+
}
|
|
10234
|
+
notifyChildrenSharedStateTreeChanged(inheritedSharedStateScope) {
|
|
10235
|
+
const childSharedStateScope = this.resolveChildSharedStateScope(inheritedSharedStateScope);
|
|
10205
10236
|
this.forEachChildren(item => {
|
|
10206
|
-
this.
|
|
10237
|
+
this.setStageToChild(item, childSharedStateScope);
|
|
10207
10238
|
});
|
|
10208
10239
|
}
|
|
10209
|
-
|
|
10210
|
-
child
|
|
10240
|
+
setStageToChild(child, inheritedSharedStateScope) {
|
|
10241
|
+
const graphic = child;
|
|
10242
|
+
"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);
|
|
10243
|
+
}
|
|
10244
|
+
syncChildSharedStateTreeBinding(child, inheritedSharedStateScope) {
|
|
10245
|
+
void 0 === inheritedSharedStateScope && (inheritedSharedStateScope = this.resolveChildSharedStateScope()), this.setStageToChild(child, inheritedSharedStateScope);
|
|
10211
10246
|
}
|
|
10212
|
-
onParentSharedStateTreeChanged(stage, layer) {
|
|
10247
|
+
onParentSharedStateTreeChanged(stage, layer, inheritedSharedStateScope) {
|
|
10213
10248
|
var _a;
|
|
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);
|
|
10249
|
+
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);
|
|
10215
10250
|
}
|
|
10216
10251
|
}
|
|
10217
10252
|
Group.NOWORK_ANIMATE_ATTR = NOWORK_ANIMATE_ATTR;
|
|
@@ -13592,8 +13627,8 @@ class RichText extends Graphic {
|
|
|
13592
13627
|
clone() {
|
|
13593
13628
|
return new RichText(Object.assign({}, this.attribute));
|
|
13594
13629
|
}
|
|
13595
|
-
setStage(stage, layer) {
|
|
13596
|
-
super.setStage(stage, layer);
|
|
13630
|
+
setStage(stage, layer, inheritedSharedStateScope) {
|
|
13631
|
+
super.setStage(stage, layer, inheritedSharedStateScope);
|
|
13597
13632
|
this.getFrameCache().icons.forEach(icon => {
|
|
13598
13633
|
icon.setStage(stage, layer);
|
|
13599
13634
|
});
|
|
@@ -19556,15 +19591,13 @@ class LynxContext2d extends BrowserContext2d {
|
|
|
19556
19591
|
}
|
|
19557
19592
|
}
|
|
19558
19593
|
measureText(text, method = application.global.measureTextMethod) {
|
|
19559
|
-
this.
|
|
19560
|
-
|
|
19561
|
-
|
|
19562
|
-
|
|
19563
|
-
|
|
19564
|
-
|
|
19565
|
-
|
|
19566
|
-
actualBoundingBoxDescent: undefined
|
|
19567
|
-
};
|
|
19594
|
+
const dpr = this.dpr || 1;
|
|
19595
|
+
this.setTransform(1, 0, 0, 1, 0, 0, true, dpr);
|
|
19596
|
+
const metrics = super.measureText(text, method);
|
|
19597
|
+
if (dpr === 1 || metrics.fontBoundingBoxAscent == null || metrics.fontBoundingBoxDescent == null) {
|
|
19598
|
+
return metrics;
|
|
19599
|
+
}
|
|
19600
|
+
return Object.assign(Object.assign({}, metrics), { width: metrics.width, actualBoundingBoxLeft: metrics.actualBoundingBoxLeft, actualBoundingBoxRight: metrics.actualBoundingBoxRight, actualBoundingBoxAscent: metrics.actualBoundingBoxAscent, actualBoundingBoxDescent: metrics.actualBoundingBoxDescent, fontBoundingBoxAscent: metrics.fontBoundingBoxAscent / dpr, fontBoundingBoxDescent: metrics.fontBoundingBoxDescent / dpr });
|
|
19568
19601
|
}
|
|
19569
19602
|
createPattern(image, repetition) {
|
|
19570
19603
|
return null;
|
|
@@ -8,4 +8,4 @@ export function createModule(CanvasConstructor, ContextConstructor) {
|
|
|
8
8
|
hasContextFactory || bindingContainer.bind(Context2dFactory).toDynamicValue((() => (params, dpr) => new ContextConstructor(params, dpr))).whenTargetNamed(ContextConstructor.env);
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
//# sourceMappingURL=create-canvas-module.js.map
|
|
11
|
+
//# sourceMappingURL=create-canvas-module.js.map
|
|
@@ -32,14 +32,18 @@ export class LynxContext2d extends BrowserContext2d {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
measureText(text, method = application.global.measureTextMethod) {
|
|
35
|
-
this.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const dpr = this.dpr || 1;
|
|
36
|
+
this.setTransform(1, 0, 0, 1, 0, 0, !0, dpr);
|
|
37
|
+
const metrics = super.measureText(text, method);
|
|
38
|
+
return 1 === dpr || null == metrics.fontBoundingBoxAscent || null == metrics.fontBoundingBoxDescent ? metrics : Object.assign(Object.assign({}, metrics), {
|
|
39
|
+
width: metrics.width,
|
|
40
|
+
actualBoundingBoxLeft: metrics.actualBoundingBoxLeft,
|
|
41
|
+
actualBoundingBoxRight: metrics.actualBoundingBoxRight,
|
|
42
|
+
actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
|
|
43
|
+
actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,
|
|
44
|
+
fontBoundingBoxAscent: metrics.fontBoundingBoxAscent / dpr,
|
|
45
|
+
fontBoundingBoxDescent: metrics.fontBoundingBoxDescent / dpr
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
createPattern(image, repetition) {
|
|
45
49
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/canvas/contributions/lynx/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,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AAY,MAAM,CAAC","file":"context.js","sourcesContent":["// 参考konva\nimport { application } from '@visactor/vrender-core/application';\nimport { createColor, getScaledStroke } from '@visactor/vrender-core';\nimport type { IContext2d, EnvType, ISetStrokeStyleParams, IStrokeStyleParams } from '@visactor/vrender-core';\nimport { BrowserContext2d } from '../browser';\n\nexport class LynxContext2d extends BrowserContext2d implements IContext2d {\n static env: EnvType = 'lynx';\n\n declare drawPromise?: Promise<any>;\n\n declare _globalAlpha: number;\n\n get globalAlpha(): number {\n return this._globalAlpha;\n }\n set globalAlpha(ga: number) {\n this.nativeContext.globalAlpha = ga * this.baseGlobalAlpha;\n this._globalAlpha = ga * this.baseGlobalAlpha;\n }\n\n setLineDash(segments: number[]) {\n const a = arguments;\n const _context = this.nativeContext;\n\n if (!!this.nativeContext.setLineDash) {\n const lineDash = a[0];\n // lynx环境中lineDash不能为[0, 0]\n if (lineDash[0] === 0 && lineDash[1] === 0) {\n return;\n }\n lineDash && _context.setLineDash(lineDash);\n }\n }\n\n protected _setStrokeStyle(\n params: ISetStrokeStyleParams,\n attribute: IStrokeStyleParams,\n // 用于渐变色\n offsetX: number,\n offsetY: number,\n defaultParams?: IStrokeStyleParams\n ) {\n const _context = this.nativeContext;\n if (!defaultParams) {\n defaultParams = this.strokeAttributes;\n }\n const { strokeOpacity = defaultParams.strokeOpacity, opacity = defaultParams.opacity } = attribute;\n if (strokeOpacity > 1e-12 && opacity > 1e-12) {\n const {\n lineWidth = defaultParams.lineWidth,\n stroke = defaultParams.stroke,\n lineJoin = defaultParams.lineJoin,\n lineDash = defaultParams.lineDash,\n lineCap = defaultParams.lineCap,\n miterLimit = defaultParams.miterLimit,\n keepStrokeScale = defaultParams.keepStrokeScale,\n lineDashOffset = defaultParams.lineDashOffset\n } = attribute;\n _context.globalAlpha = strokeOpacity * opacity * this.baseGlobalAlpha;\n _context.lineWidth = keepStrokeScale ? lineWidth : getScaledStroke(this, lineWidth, this.dpr);\n _context.strokeStyle = createColor(this, stroke as any, params, offsetX, offsetY);\n _context.lineJoin = lineJoin;\n // lynx环境中lineDash不能为[0, 0]\n if (!(lineDash[0] === 0 && lineDash[1] === 0) && lineDash) {\n _context.setLineDash(lineDash);\n _context.lineDashOffset = lineDashOffset;\n }\n _context.lineCap = lineCap;\n _context.miterLimit = miterLimit;\n }\n }\n\n measureText(\n text: string,\n method: 'native' | 'simple' | 'quick' = application.global.measureTextMethod\n ): { width: number } {\n const dpr = this.dpr || 1;\n this.setTransform(1, 0, 0, 1, 0, 0, true, dpr);\n const metrics = super.measureText(text, method) as TextMetrics;\n if (dpr === 1 || metrics.fontBoundingBoxAscent == null || metrics.fontBoundingBoxDescent == null) {\n return metrics;\n }\n return {\n ...metrics,\n width: metrics.width,\n actualBoundingBoxLeft: metrics.actualBoundingBoxLeft,\n actualBoundingBoxRight: metrics.actualBoundingBoxRight,\n actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,\n actualBoundingBoxDescent: metrics.actualBoundingBoxDescent,\n fontBoundingBoxAscent: metrics.fontBoundingBoxAscent / dpr,\n fontBoundingBoxDescent: metrics.fontBoundingBoxDescent / dpr\n } as any;\n }\n\n createPattern(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, repetition: string): CanvasPattern {\n return null;\n }\n\n draw() {\n const _context = this.nativeContext as any;\n if (!_context.draw) {\n return;\n }\n this.drawPromise = new Promise(resolve => {\n _context.draw(true, () => {\n this.drawPromise = null;\n resolve(null);\n });\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-kits",
|
|
3
|
-
"version": "1.1.8-alpha.
|
|
3
|
+
"version": "1.1.8-alpha.2",
|
|
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.8-alpha.
|
|
47
|
+
"@visactor/vrender-core": "1.1.8-alpha.2",
|
|
48
48
|
"@resvg/resvg-js": "2.4.1",
|
|
49
49
|
"roughjs": "4.6.6",
|
|
50
50
|
"gifuct-js": "2.1.2",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"vite": "3.2.6",
|
|
70
70
|
"typescript": "4.9.5",
|
|
71
71
|
"cross-env": "^7.0.3",
|
|
72
|
-
"@internal/bundler": "0.0.1",
|
|
73
72
|
"@internal/ts-config": "0.0.1",
|
|
73
|
+
"@internal/bundler": "0.0.1",
|
|
74
74
|
"@internal/eslint-config": "0.0.1"
|
|
75
75
|
},
|
|
76
76
|
"keywords": [
|