@visactor/vrender-core 1.0.0-alpha.12 → 1.0.0-alpha.14

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 (36) hide show
  1. package/cjs/common/performance-raf.js +2 -2
  2. package/cjs/common/performance-raf.js.map +1 -1
  3. package/cjs/common/segment/curve/cubic-bezier.d.ts +1 -2
  4. package/cjs/common/segment/curve/cubic-bezier.js +3 -8
  5. package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
  6. package/cjs/common/segment/curve/quadratic-bezier.d.ts +1 -0
  7. package/cjs/common/segment/curve/quadratic-bezier.js +10 -3
  8. package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
  9. package/cjs/graphic/graphic-service/graphic-service.js +2 -3
  10. package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
  11. package/cjs/graphic/graphic.d.ts +1 -0
  12. package/cjs/graphic/graphic.js +9 -8
  13. package/cjs/graphic/graphic.js.map +1 -1
  14. package/cjs/graphic/group.js +8 -15
  15. package/cjs/graphic/group.js.map +1 -1
  16. package/cjs/render/contributions/render/group-render.js +2 -2
  17. package/cjs/render/contributions/render/group-render.js.map +1 -1
  18. package/dist/index.es.js +91 -96
  19. package/es/common/performance-raf.js +2 -2
  20. package/es/common/performance-raf.js.map +1 -1
  21. package/es/common/segment/curve/cubic-bezier.d.ts +1 -2
  22. package/es/common/segment/curve/cubic-bezier.js +1 -8
  23. package/es/common/segment/curve/cubic-bezier.js.map +1 -1
  24. package/es/common/segment/curve/quadratic-bezier.d.ts +1 -0
  25. package/es/common/segment/curve/quadratic-bezier.js +5 -2
  26. package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
  27. package/es/graphic/graphic-service/graphic-service.js +1 -4
  28. package/es/graphic/graphic-service/graphic-service.js.map +1 -1
  29. package/es/graphic/graphic.d.ts +1 -0
  30. package/es/graphic/graphic.js +9 -8
  31. package/es/graphic/graphic.js.map +1 -1
  32. package/es/graphic/group.js +8 -15
  33. package/es/graphic/group.js.map +1 -1
  34. package/es/render/contributions/render/group-render.js +2 -2
  35. package/es/render/contributions/render/group-render.js.map +1 -1
  36. package/package.json +3 -3
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  value: !0
17
17
  }), exports.DefaultCanvasGroupRender = void 0;
18
18
 
19
- const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), graphic_service_1 = require("../../../graphic/graphic-service/graphic-service"), vutils_1 = require("@visactor/vutils"), contribution_provider_1 = require("../../../common/contribution-provider"), rect_1 = require("../../../common/shape/rect"), utils_1 = require("./utils"), constants_1 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), constants_2 = require("../../../graphic/constants"), enums_1 = require("../../../common/enums"), contributions_1 = require("./contributions"), matrix_1 = require("../../../common/matrix"), modules_1 = require("../../../modules");
19
+ const inversify_lite_1 = require("../../../common/inversify-lite"), theme_1 = require("../../../graphic/theme"), graphic_service_1 = require("../../../graphic/graphic-service/graphic-service"), vutils_1 = require("@visactor/vutils"), contribution_provider_1 = require("../../../common/contribution-provider"), rect_1 = require("../../../common/shape/rect"), utils_1 = require("./utils"), constants_1 = require("./contributions/constants"), matrix_allocate_1 = require("../../../allocator/matrix-allocate"), constants_2 = require("../../../graphic/constants"), enums_1 = require("../../../common/enums"), contributions_1 = require("./contributions"), matrix_1 = require("../../../common/matrix"), application_1 = require("../../../application");
20
20
 
21
21
  let DefaultCanvasGroupRender = class {
22
22
  constructor(groupRenderContribitions) {
@@ -70,7 +70,7 @@ let DefaultCanvasGroupRender = class {
70
70
  if (!context) return;
71
71
  const {clip: clip, baseOpacity: baseOpacity = 1, drawMode: drawMode} = group.attribute, lastNativeContext = context.nativeContext, lastNativeCanvas = context.canvas.nativeCanvas;
72
72
  if (drawMode > 0) {
73
- const {x: x, y: y, width: width, height: height} = group.attribute, canvas = context.canvas, newCanvas = modules_1.vglobal.createCanvas({
73
+ const {x: x, y: y, width: width, height: height} = group.attribute, canvas = context.canvas, newCanvas = application_1.application.global.createCanvas({
74
74
  width: canvas.width,
75
75
  height: canvas.height,
76
76
  dpr: 1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAe3E,kDAAkD;AAClD,sFAAkF;AAClF,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAC3E,mDAA0D;AAC1D,8CAA2C;AAGpC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY,EACZ,cAAiD;QAGjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;QAE3D,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,UAAU,CAAC,EAAE;YAC3C,OAAO;SACR;QAED,cAAc,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,KAAK,CAAC;QAExE,MAAM,EACJ,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,KAAK,GAAG,cAAc,CAAC,KAAK,EAC5B,MAAM,GAAG,cAAc,CAAC,MAAM,EAC9B,WAAW,GAAG,cAAc,CAAC,WAAW,EACxC,aAAa,GAAG,cAAc,CAAC,aAAa,EAC5C,YAAY,G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-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IGroupGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { vglobal } from '../../../modules';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n groupAttribute?: Required<IGroupGraphicAttribute>\n ) {\n // 提前判定,否则每次都要获取一堆属性\n const { clip, fill, stroke, background } = group.attribute;\n\n if (!(clip || fill || stroke || background)) {\n return;\n }\n\n groupAttribute = groupAttribute ?? getTheme(group, params?.theme).group;\n\n const {\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n const { clip, baseOpacity = 1, drawMode } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const groupAttribute = getTheme(group, params?.theme).group;\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext, null, null, null);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX, scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.renderInGroup) {\n p = params.renderInGroup(\n params.renderInGroupParams?.skipSort,\n group,\n drawContext,\n params.renderInGroupParams?.nextM\n );\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/render/contributions/render/group-render.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mEAA2E;AAe3E,kDAAkD;AAClD,sFAAkF;AAClF,6CAA2C;AAE3C,iFAA6E;AAC7E,qDAA4D;AAC5D,mCAAiF;AACjF,yDAAoE;AACpE,wEAAkE;AAClE,0DAA+D;AAC/D,iDAAmE;AACnE,mDAA2E;AAC3E,mDAA0D;AAC1D,sDAAmD;AAG5C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAMnC,YAGqB,wBAAyE;QAAzE,6BAAwB,GAAxB,wBAAwB,CAAiD;QAP9F,eAAU,GAAW,6BAAiB,CAAC;IAQpC,CAAC;IAEJ,SAAS,CACP,KAAa,EACb,OAAmB,EACnB,CAAS,EACT,CAAS,EACT,WAAyB,EACzB,MAAiC,EACjC,MAIY,EACZ,QAIY,EACZ,cAAiD;QAGjD,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;QAE3D,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,MAAM,IAAI,UAAU,CAAC,EAAE;YAC3C,OAAO;SACR;QAED,cAAc,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,IAAA,gBAAQ,EAAC,KAAK,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,CAAC,KAAK,CAAC;QAExE,MAAM,EACJ,OAAO,GAAG,cAAc,CAAC,OAAO,EAChC,KAAK,GAAG,cAAc,CAAC,KAAK,EAC5B,M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AAM,EAAC,4CAAoB,CAAC,CAAA;IAC5B,WAAA,IAAA,sBAAK,EAAC,mCAAuB,CAAC,CAAA;;GARtB,wBAAwB,CAiXpC;AAjXY,4DAAwB","file":"group-render.js","sourcesContent":["import { inject, injectable, named } from '../../../common/inversify-lite';\nimport type {\n IGraphicAttribute,\n IContext2d,\n IGroup,\n IMarkAttribute,\n IThemeAttribute,\n IGroupRenderContribution,\n IDrawContext,\n IRenderService,\n IGraphicRender,\n IGraphicRenderDrawParams,\n IContributionProvider,\n IGroupGraphicAttribute\n} from '../../../interface';\nimport { getTheme } from '../../../graphic/theme';\nimport { getModelMatrix } from '../../../graphic/graphic-service/graphic-service';\nimport { isArray } from '@visactor/vutils';\n// eslint-disable-next-line @typescript-eslint/consistent-type-imports\nimport { ContributionProvider } from '../../../common/contribution-provider';\nimport { createRectPath } from '../../../common/shape/rect';\nimport { rectFillVisible, rectStrokeVisible, runFill, runStroke } from './utils';\nimport { GroupRenderContribution } from './contributions/constants';\nimport { mat4Allocate } from '../../../allocator/matrix-allocate';\nimport { GROUP_NUMBER_TYPE } from '../../../graphic/constants';\nimport { BaseRenderContributionTime } from '../../../common/enums';\nimport { defaultGroupBackgroundRenderContribution } from './contributions';\nimport { multiplyMat4Mat4 } from '../../../common/matrix';\nimport { application } from '../../../application';\n\n@injectable()\nexport class DefaultCanvasGroupRender implements IGraphicRender {\n type: 'group';\n numberType: number = GROUP_NUMBER_TYPE;\n\n _groupRenderContribitions: IGroupRenderContribution[];\n\n constructor(\n @inject(ContributionProvider)\n @named(GroupRenderContribution)\n protected readonly groupRenderContribitions: IContributionProvider<IGroupRenderContribution>\n ) {}\n\n drawShape(\n group: IGroup,\n context: IContext2d,\n x: number,\n y: number,\n drawContext: IDrawContext,\n params?: IGraphicRenderDrawParams,\n fillCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n strokeCb?: (\n ctx: IContext2d,\n markAttribute: Partial<IMarkAttribute & IGraphicAttribute>,\n themeAttribute: IThemeAttribute\n ) => boolean,\n groupAttribute?: Required<IGroupGraphicAttribute>\n ) {\n // 提前判定,否则每次都要获取一堆属性\n const { clip, fill, stroke, background } = group.attribute;\n\n if (!(clip || fill || stroke || background)) {\n return;\n }\n\n groupAttribute = groupAttribute ?? getTheme(group, params?.theme).group;\n\n const {\n opacity = groupAttribute.opacity,\n width = groupAttribute.width,\n height = groupAttribute.height,\n fillOpacity = groupAttribute.fillOpacity,\n strokeOpacity = groupAttribute.strokeOpacity,\n cornerRadius = groupAttribute.cornerRadius,\n path = groupAttribute.path,\n lineWidth = groupAttribute.lineWidth,\n visible = groupAttribute.visible,\n fillStrokeOrder = groupAttribute.fillStrokeOrder,\n cornerType = groupAttribute.cornerType,\n x: originX = groupAttribute.x,\n y: originY = groupAttribute.y\n } = group.attribute;\n\n // 不绘制或者透明\n const fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill);\n const sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height);\n const doFill = runFill(fill, background);\n const doStroke = runStroke(stroke, lineWidth);\n\n if (!(group.valid && visible)) {\n return;\n }\n\n if (!clip) {\n if (!(doFill || doStroke)) {\n return;\n }\n\n // 如果存在fillCb和strokeCb,那就不直接跳过\n if (!(fVisible || sVisible || fillCb || strokeCb || background)) {\n return;\n }\n }\n\n if (path && path.length && drawContext.drawContribution) {\n // 禁用fill和stroke\n const disableFill = context.disableFill;\n const disableStroke = context.disableStroke;\n const disableBeginPath = context.disableBeginPath;\n context.disableFill = true;\n context.disableStroke = true;\n context.disableBeginPath = true;\n path.forEach(g => {\n const rc = drawContext.drawContribution.getRenderContribution(g);\n rc.draw(g, drawContext.renderService, drawContext, params);\n });\n context.disableFill = disableFill;\n context.disableStroke = disableStroke;\n context.disableBeginPath = disableBeginPath;\n } else if (cornerRadius === 0 || (isArray(cornerRadius) && (<number[]>cornerRadius).every(num => num === 0))) {\n // 不需要处理圆角\n context.beginPath();\n context.rect(x, y, width, height);\n } else {\n context.beginPath();\n // 测试后,cache对于重绘性能提升不大,但是在首屏有一定性能损耗,因此rect不再使用cache\n createRectPath(context, x, y, width, height, cornerRadius, cornerType !== 'bevel');\n }\n\n if (!this._groupRenderContribitions) {\n this._groupRenderContribitions = this.groupRenderContribitions.getContributions() || [];\n this._groupRenderContribitions.push(defaultGroupBackgroundRenderContribution);\n }\n\n const doFillOrStroke = {\n doFill,\n doStroke\n };\n\n // shadow\n context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.beforeFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb,\n doFillOrStroke\n );\n }\n });\n\n // beforeFillStroke contribition可以操作clip范围\n if (clip) {\n context.clip();\n }\n\n const _runFill = () => {\n if ((doFillOrStroke as any).doFill) {\n if (fillCb) {\n fillCb(context, group.attribute, groupAttribute);\n } else if (fVisible) {\n context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.fill();\n }\n }\n };\n\n const _runStroke = () => {\n if ((doFillOrStroke as any).doStroke) {\n if (strokeCb) {\n strokeCb(context, group.attribute, groupAttribute);\n } else if (sVisible) {\n context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute);\n context.stroke();\n }\n }\n };\n\n if (!fillStrokeOrder) {\n _runFill();\n _runStroke();\n } else {\n _runStroke();\n _runFill();\n }\n\n this._groupRenderContribitions.forEach(c => {\n if (c.time === BaseRenderContributionTime.afterFillStroke) {\n // c.useStyle && context.setCommonStyle(group, group.attribute, x, y, groupAttribute);\n c.drawShape(\n group,\n context,\n x,\n y,\n doFill,\n doStroke,\n fVisible,\n sVisible,\n groupAttribute,\n drawContext,\n fillCb,\n strokeCb\n );\n }\n });\n }\n\n draw(group: IGroup, renderService: IRenderService, drawContext: IDrawContext, params?: IGraphicRenderDrawParams) {\n const { context } = drawContext;\n if (!context) {\n return;\n }\n\n const { clip, baseOpacity = 1, drawMode } = group.attribute;\n const lastNativeContext = context.nativeContext;\n const lastNativeCanvas = context.canvas.nativeCanvas;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 绘制到新的Canvas上,然后再绘制回来\n const canvas = context.canvas;\n const newCanvas = application.global.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });\n const newContext = newCanvas.getContext('2d');\n const transform = context.nativeContext.getTransform();\n // 首先应用transform\n newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n // 然后将背景绘制到新的canvas上,只绘制group的Bounds区域\n // 如果drawMode === 1,则需要背景\n // 如果drawMode === 2,则不需要背景,只需要group即可\n if (drawMode === 1) {\n newContext.save();\n newContext.clearRect(0, 0, canvas.width, canvas.height);\n newContext.beginPath();\n\n newContext.rect(x, y, width, height);\n newContext.clip();\n newContext.drawImage(\n canvas.nativeCanvas,\n 0,\n 0,\n canvas.width,\n canvas.height,\n 0,\n 0,\n canvas.displayWidth,\n canvas.displayHeight\n );\n newContext.restore();\n }\n // 狸猫换太子,把新的context赋值给context\n context.nativeContext = newContext;\n canvas.nativeCanvas = newCanvas;\n }\n if (clip) {\n context.save();\n } else {\n context.highPerformanceSave();\n }\n const baseGlobalAlpha = context.baseGlobalAlpha;\n context.baseGlobalAlpha *= baseOpacity;\n\n // const lastMatrix = context.modelMatrix;\n // if (context.camera) {\n // const m = group.transMatrix;\n // const matrix = createMat4();\n // mat3Tomat4(matrix, m);\n // const lastModelMatrix = context.modelMatrix;\n // if (lastModelMatrix) {\n // if (matrix) {\n // const m = createMat4();\n // context.modelMatrix = multiplyMat4Mat4(m, lastModelMatrix, matrix);\n // }\n // } else {\n // context.modelMatrix = matrix;\n // }\n // } else {\n // // group直接transform\n // context.transformFromMatrix(group.transMatrix, true);\n // }\n const lastModelMatrix = context.modelMatrix;\n const camera = context.camera;\n if (camera) {\n const groupAttribute = getTheme(group, params?.theme).group;\n const nextModelMatrix = mat4Allocate.allocate();\n // 计算模型矩阵\n const modelMatrix = mat4Allocate.allocate();\n getModelMatrix(modelMatrix, group, groupAttribute);\n if (lastModelMatrix) {\n multiplyMat4Mat4(nextModelMatrix, lastModelMatrix, modelMatrix);\n } else {\n multiplyMat4Mat4(nextModelMatrix, nextModelMatrix, modelMatrix);\n }\n context.modelMatrix = nextModelMatrix;\n mat4Allocate.free(modelMatrix);\n context.setTransform(1, 0, 0, 1, 0, 0, true);\n } else {\n // group直接transform\n context.transformFromMatrix(group.transMatrix, true);\n }\n\n context.beginPath();\n // 如果跳过绘制,那就不绘制\n if (params.skipDraw) {\n this.drawShape(\n group,\n context,\n 0,\n 0,\n drawContext,\n params,\n () => false,\n () => false\n );\n } else {\n this.drawShape(group, context, 0, 0, drawContext, null, null, null);\n }\n\n // 绘制子元素的时候要添加scroll\n const { scrollX, scrollY } = group.attribute;\n if (scrollX || scrollY) {\n context.translate(scrollX, scrollY);\n }\n let p: any;\n if (params && params.renderInGroup) {\n p = params.renderInGroup(\n params.renderInGroupParams?.skipSort,\n group,\n drawContext,\n params.renderInGroupParams?.nextM\n );\n }\n\n if (context.modelMatrix !== lastModelMatrix) {\n mat4Allocate.free(context.modelMatrix);\n }\n context.modelMatrix = lastModelMatrix;\n\n context.baseGlobalAlpha = baseGlobalAlpha;\n\n if (drawMode > 0) {\n const { x, y, width, height } = group.attribute;\n // 将原始的context和canvas恢复,另外将newCanvas上的内容绘制到lastCanvas上\n const newContext = context.nativeContext;\n const newCanvas = context.canvas.nativeCanvas;\n lastNativeContext.save();\n lastNativeContext.setTransform(context.dpr, 0, 0, context.dpr, 0, 0, true);\n // 如果drawMode === 1,则需要清一下之前的背景,否则背景就重复绘制了一次\n if (drawMode === 1) {\n newContext.rect(x, y, width, height);\n }\n lastNativeContext.drawImage(\n newCanvas,\n 0,\n 0,\n newCanvas.width,\n newCanvas.height,\n 0,\n 0,\n context.canvas.displayWidth,\n context.canvas.displayHeight\n );\n const transform = newContext.getTransform();\n lastNativeContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);\n context.nativeContext = lastNativeContext;\n context.canvas.nativeCanvas = lastNativeCanvas;\n lastNativeContext.restore();\n }\n\n if (p && p.then) {\n p.then(() => {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n });\n } else {\n if (clip) {\n context.restore();\n } else {\n context.highPerformanceRestore();\n }\n }\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -852,6 +852,10 @@ const EnvContribution = Symbol.for('EnvContribution');
852
852
  const VGlobal = Symbol.for('VGlobal');
853
853
  const DEFAULT_TEXT_FONT_FAMILY = 'PingFang SC,Helvetica Neue,Microsoft Yahei,system-ui,-apple-system,segoe ui,Roboto,Helvetica,Arial,sans-serif,apple color emoji,segoe ui emoji,segoe ui symbol';
854
854
 
855
+ class Application {
856
+ }
857
+ const application = new Application();
858
+
855
859
  class PerformanceRAF {
856
860
  constructor() {
857
861
  this.nextAnimationFrameCbs = [];
@@ -870,7 +874,7 @@ class PerformanceRAF {
870
874
  if (this._rafHandle !== null || this.nextAnimationFrameCbs.length === 0) {
871
875
  return;
872
876
  }
873
- this._rafHandle = vglobal.getRequestAnimationFrame()(this.runAnimationFrame);
877
+ this._rafHandle = application.global.getRequestAnimationFrame()(this.runAnimationFrame);
874
878
  };
875
879
  }
876
880
  addAnimationFrameCb(callback) {
@@ -1788,63 +1792,6 @@ function quadLength(p0, p1, p2, iterationCount) {
1788
1792
  return snapLength([p0.x, p1.x, p2.x], [p0.y, p1.y, p2.y]);
1789
1793
  }
1790
1794
 
1791
- class QuadraticBezierCurve extends Curve {
1792
- constructor(p0, p1, p2) {
1793
- super();
1794
- this.type = CurveTypeEnum.QuadraticBezierCurve;
1795
- this.p0 = p0;
1796
- this.p1 = p1;
1797
- this.p2 = p2;
1798
- }
1799
- _validPoint() {
1800
- return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y);
1801
- }
1802
- getPointAt(t) {
1803
- if (this.defined !== false) {
1804
- return quadPointAt(this.p0, this.p1, this.p2, t);
1805
- }
1806
- throw new Error('defined为false的点不能getPointAt');
1807
- }
1808
- calcLength() {
1809
- if (this._validPoint()) {
1810
- return quadLength(this.p0, this.p1, this.p2);
1811
- }
1812
- return 60;
1813
- }
1814
- calcProjLength(direction) {
1815
- if (direction === Direction.ROW) {
1816
- return abs(this.p0.x - this.p2.x);
1817
- }
1818
- else if (direction === Direction.COLUMN) {
1819
- return abs(this.p0.y - this.p2.y);
1820
- }
1821
- return 0;
1822
- }
1823
- getAngleAt(t) {
1824
- const minT = max(t - 0.01, 0);
1825
- const maxT = min(t + 0.01, 1);
1826
- const minP = this.getPointAt(minT);
1827
- const maxP = this.getPointAt(maxT);
1828
- return atan2(maxP.y - minP.y, maxP.x - minP.x);
1829
- }
1830
- draw(path, x, y, sx, sy, percent) {
1831
- path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y);
1832
- if (percent >= 1) {
1833
- path.quadraticCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y);
1834
- }
1835
- else if (percent > 0) {
1836
- const [curve1] = divideQuad(this, percent);
1837
- path.quadraticCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y);
1838
- }
1839
- }
1840
- getYAt(x) {
1841
- throw new Error('QuadraticBezierCurve暂不支持getYAt');
1842
- }
1843
- includeX(x) {
1844
- throw new Error('QuadraticBezierCurve暂不支持includeX');
1845
- }
1846
- }
1847
-
1848
1795
  function divideCubic(curve, t) {
1849
1796
  const { p0, p1, p2, p3 } = curve;
1850
1797
  const pt = cubicPointAt(p0, p1, p2, p3, t);
@@ -1857,15 +1804,6 @@ function divideCubic(curve, t) {
1857
1804
  const curve2 = new CubicBezierCurve(pt, c23, c3, p3);
1858
1805
  return [curve1, curve2];
1859
1806
  }
1860
- function divideQuad(curve, t) {
1861
- const { p0, p1, p2 } = curve;
1862
- const pt = quadPointAt(p0, p1, p2, t);
1863
- const c1 = PointService.pointAtPP(p0, p1, t);
1864
- const c2 = PointService.pointAtPP(p1, p2, t);
1865
- const curve1 = new QuadraticBezierCurve(p0, c1, pt);
1866
- const curve2 = new QuadraticBezierCurve(pt, c2, p2);
1867
- return [curve1, curve2];
1868
- }
1869
1807
  class CubicBezierCurve extends Curve {
1870
1808
  constructor(p0, p1, p2, p3) {
1871
1809
  super();
@@ -2708,6 +2646,72 @@ class CatmullRomClosed {
2708
2646
  }
2709
2647
  const genCatmullRomClosedSegments = commonGenCatmullRomSegments('catmullRomClosed', CatmullRomClosed);
2710
2648
 
2649
+ function divideQuad(curve, t) {
2650
+ const { p0, p1, p2 } = curve;
2651
+ const pt = quadPointAt(p0, p1, p2, t);
2652
+ const c1 = PointService.pointAtPP(p0, p1, t);
2653
+ const c2 = PointService.pointAtPP(p1, p2, t);
2654
+ const curve1 = new QuadraticBezierCurve(p0, c1, pt);
2655
+ const curve2 = new QuadraticBezierCurve(pt, c2, p2);
2656
+ return [curve1, curve2];
2657
+ }
2658
+ class QuadraticBezierCurve extends Curve {
2659
+ constructor(p0, p1, p2) {
2660
+ super();
2661
+ this.type = CurveTypeEnum.QuadraticBezierCurve;
2662
+ this.p0 = p0;
2663
+ this.p1 = p1;
2664
+ this.p2 = p2;
2665
+ }
2666
+ _validPoint() {
2667
+ return Number.isFinite(this.p0.x + this.p0.y + this.p1.x + this.p1.y + this.p2.x + this.p2.y);
2668
+ }
2669
+ getPointAt(t) {
2670
+ if (this.defined !== false) {
2671
+ return quadPointAt(this.p0, this.p1, this.p2, t);
2672
+ }
2673
+ throw new Error('defined为false的点不能getPointAt');
2674
+ }
2675
+ calcLength() {
2676
+ if (this._validPoint()) {
2677
+ return quadLength(this.p0, this.p1, this.p2);
2678
+ }
2679
+ return 60;
2680
+ }
2681
+ calcProjLength(direction) {
2682
+ if (direction === Direction.ROW) {
2683
+ return abs(this.p0.x - this.p2.x);
2684
+ }
2685
+ else if (direction === Direction.COLUMN) {
2686
+ return abs(this.p0.y - this.p2.y);
2687
+ }
2688
+ return 0;
2689
+ }
2690
+ getAngleAt(t) {
2691
+ const minT = max(t - 0.01, 0);
2692
+ const maxT = min(t + 0.01, 1);
2693
+ const minP = this.getPointAt(minT);
2694
+ const maxP = this.getPointAt(maxT);
2695
+ return atan2(maxP.y - minP.y, maxP.x - minP.x);
2696
+ }
2697
+ draw(path, x, y, sx, sy, percent) {
2698
+ path.moveTo(this.p0.x * sx + x, this.p0.y * sy + y);
2699
+ if (percent >= 1) {
2700
+ path.quadraticCurveTo(this.p1.x * sx + x, this.p1.y * sy + y, this.p2.x * sx + x, this.p2.y * sy + y);
2701
+ }
2702
+ else if (percent > 0) {
2703
+ const [curve1] = divideQuad(this, percent);
2704
+ path.quadraticCurveTo(curve1.p1.x * sx + x, curve1.p1.y * sy + y, curve1.p2.x * sx + x, curve1.p2.y * sy + y);
2705
+ }
2706
+ }
2707
+ getYAt(x) {
2708
+ throw new Error('QuadraticBezierCurve暂不支持getYAt');
2709
+ }
2710
+ includeX(x) {
2711
+ throw new Error('QuadraticBezierCurve暂不支持includeX');
2712
+ }
2713
+ }
2714
+
2711
2715
  class CurveContext {
2712
2716
  constructor(path) {
2713
2717
  this.path = path;
@@ -3451,10 +3455,6 @@ const DefaultRichTextAttribute = Object.assign(Object.assign(Object.assign({}, D
3451
3455
  const DefaultImageAttribute = Object.assign(Object.assign({ repeatX: 'no-repeat', repeatY: 'no-repeat', image: '', width: 0, height: 0, maxWidth: 500, maxHeight: 500 }, DefaultAttribute), { fill: true, cornerRadius: 0, cornerType: 'round' });
3452
3456
  const DefaultRichTextIconAttribute = Object.assign(Object.assign({}, DefaultImageAttribute), { backgroundShowMode: 'never', backgroundWidth: 0, backgroundHeight: 0, textAlign: 'left', textBaseline: 'middle', direction: 'horizontal', margin: 0, id: '', width: 20, height: 20, backgroundFill: 'rgba(101, 117, 168, 0.1)', backgroundFillOpacity: 1, backgroundStroke: false, backgroundStrokeOpacity: 1, backgroundRadius: 4, opacity: 1 });
3453
3457
 
3454
- class Application {
3455
- }
3456
- const application = new Application();
3457
-
3458
3458
  const parse = (function () {
3459
3459
  const tokens = {
3460
3460
  linearGradient: /^(linear\-gradient)/i,
@@ -10919,6 +10919,10 @@ class Graphic extends Node {
10919
10919
  this.setShadowGraphic(params.shadowGraphic);
10920
10920
  }
10921
10921
  }
10922
+ getGraphicService() {
10923
+ var _a, _b;
10924
+ return (_b = (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService) !== null && _b !== void 0 ? _b : application.graphicService;
10925
+ }
10922
10926
  getAttributes() {
10923
10927
  return this.attribute;
10924
10928
  }
@@ -10949,7 +10953,6 @@ class Graphic extends Node {
10949
10953
  this._emitCustomEvent('animate-bind', animate);
10950
10954
  }
10951
10955
  tryUpdateAABBBounds() {
10952
- var _a, _b;
10953
10956
  const full = this.attribute.boundsMode === 'imprecise';
10954
10957
  if (!this.shouldUpdateAABBBounds()) {
10955
10958
  return this._AABBBounds;
@@ -10958,9 +10961,9 @@ class Graphic extends Node {
10958
10961
  this._AABBBounds.clear();
10959
10962
  return this._AABBBounds;
10960
10963
  }
10961
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
10964
+ this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
10962
10965
  const bounds = this.doUpdateAABBBounds(full);
10963
- (_b = this.stage) === null || _b === void 0 ? void 0 : _b.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, true);
10966
+ this.getGraphicService().afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, true);
10964
10967
  if (this.attribute.boundsMode === 'empty') {
10965
10968
  bounds.clear();
10966
10969
  }
@@ -11137,10 +11140,10 @@ class Graphic extends Node {
11137
11140
  shouldUpdateAABBBounds() {
11138
11141
  if (this.shadowRoot) {
11139
11142
  return ((!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) || this.shadowRoot.shouldUpdateAABBBounds()) &&
11140
- application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
11143
+ this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
11141
11144
  }
11142
11145
  return (!!(this._updateTag & UpdateTag.UPDATE_BOUNDS) &&
11143
- application.graphicService.validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
11146
+ this.getGraphicService().validCheck(this.attribute, this.getGraphicTheme(), this._AABBBounds, this));
11144
11147
  }
11145
11148
  shouldSelfChangeUpdateAABBBounds() {
11146
11149
  if (this.shadowRoot) {
@@ -11451,11 +11454,10 @@ class Graphic extends Node {
11451
11454
  return this;
11452
11455
  }
11453
11456
  onAttributeUpdate(context) {
11454
- var _a;
11455
11457
  if (context && context.skipUpdateCallback) {
11456
11458
  return;
11457
11459
  }
11458
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onAttributeUpdate(this);
11460
+ this.getGraphicService().onAttributeUpdate(this);
11459
11461
  this._emitCustomEvent('afterAttributeUpdate', context);
11460
11462
  }
11461
11463
  update(d) {
@@ -11748,7 +11750,6 @@ class Graphic extends Node {
11748
11750
  }
11749
11751
  }
11750
11752
  setStage(stage, layer) {
11751
- var _a;
11752
11753
  if (this.stage !== stage) {
11753
11754
  this.stage = stage;
11754
11755
  this.layer = layer;
@@ -11763,7 +11764,7 @@ class Graphic extends Node {
11763
11764
  });
11764
11765
  }
11765
11766
  this._onSetStage && this._onSetStage(this, stage, layer);
11766
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onSetStage(this, stage);
11767
+ this.getGraphicService().onSetStage(this, stage);
11767
11768
  }
11768
11769
  }
11769
11770
  setStageToShadowRoot(stage, layer) {
@@ -12015,15 +12016,14 @@ class Group extends Graphic {
12015
12016
  return false;
12016
12017
  }
12017
12018
  tryUpdateAABBBounds() {
12018
- var _a, _b;
12019
12019
  if (!this.shouldUpdateAABBBounds()) {
12020
12020
  return this._AABBBounds;
12021
12021
  }
12022
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
12022
+ this.getGraphicService().beforeUpdateAABBBounds(this, this.stage, true, this._AABBBounds);
12023
12023
  const selfChange = this.shouldSelfChangeUpdateAABBBounds();
12024
12024
  const bounds = this.doUpdateAABBBounds();
12025
12025
  this.addUpdateLayoutTag();
12026
- (_b = this.stage) === null || _b === void 0 ? void 0 : _b.graphicService.afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange);
12026
+ this.getGraphicService().afterUpdateAABBBounds(this, this.stage, this._AABBBounds, this, selfChange);
12027
12027
  if (this.attribute.boundsMode === 'empty') {
12028
12028
  bounds.clear();
12029
12029
  }
@@ -12092,21 +12092,19 @@ class Group extends Graphic {
12092
12092
  return this.theme.getTheme(this);
12093
12093
  }
12094
12094
  incrementalAppendChild(node) {
12095
- var _a;
12096
12095
  const data = super.appendChild(node);
12097
12096
  if (this.stage && data) {
12098
12097
  data.stage = this.stage;
12099
12098
  data.layer = this.layer;
12100
12099
  }
12101
12100
  this.addUpdateBoundTag();
12102
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onAddIncremental(node, this, this.stage);
12101
+ this.getGraphicService().onAddIncremental(node, this, this.stage);
12103
12102
  return data;
12104
12103
  }
12105
12104
  incrementalClearChild() {
12106
- var _a;
12107
12105
  super.removeAllChild();
12108
12106
  this.addUpdateBoundTag();
12109
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onClearIncremental(this, this.stage);
12107
+ this.getGraphicService().onClearIncremental(this, this.stage);
12110
12108
  return;
12111
12109
  }
12112
12110
  _updateChildToStage(child) {
@@ -12134,17 +12132,15 @@ class Group extends Graphic {
12134
12132
  return this._updateChildToStage(super.insertInto(newNode, idx));
12135
12133
  }
12136
12134
  removeChild(child) {
12137
- var _a;
12138
12135
  const data = super.removeChild(child);
12139
12136
  child.stage = null;
12140
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onRemove(child);
12137
+ this.getGraphicService().onRemove(child);
12141
12138
  this.addUpdateBoundTag();
12142
12139
  return data;
12143
12140
  }
12144
12141
  removeAllChild(deep = false) {
12145
12142
  this.forEachChildren((child) => {
12146
- var _a;
12147
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onRemove(child);
12143
+ this.getGraphicService().onRemove(child);
12148
12144
  if (deep && child.isContainer) {
12149
12145
  child.removeAllChild(deep);
12150
12146
  }
@@ -12153,13 +12149,12 @@ class Group extends Graphic {
12153
12149
  this.addUpdateBoundTag();
12154
12150
  }
12155
12151
  setStage(stage, layer) {
12156
- var _a;
12157
12152
  if (this.stage !== stage) {
12158
12153
  this.stage = stage;
12159
12154
  this.layer = layer;
12160
12155
  this.setStageToShadowRoot(stage, layer);
12161
12156
  this._onSetStage && this._onSetStage(this, stage, layer);
12162
- (_a = this.stage) === null || _a === void 0 ? void 0 : _a.graphicService.onSetStage(this, stage);
12157
+ this.getGraphicService().onSetStage(this, stage);
12163
12158
  this.forEachChildren(item => {
12164
12159
  item.setStage(stage, this.layer);
12165
12160
  });
@@ -13109,7 +13104,7 @@ let DefaultGraphicService = class DefaultGraphicService {
13109
13104
  if (!(graphic.valid && visible)) {
13110
13105
  if (!aabbBounds.empty()) {
13111
13106
  graphic.parent && aabbBounds.transformWithMatrix(graphic.parent.globalTransMatrix);
13112
- application.graphicService.clearAABBBounds(graphic, graphic.stage, aabbBounds);
13107
+ this.clearAABBBounds(graphic, graphic.stage, aabbBounds);
13113
13108
  aabbBounds.clear();
13114
13109
  }
13115
13110
  return false;
@@ -20277,7 +20272,7 @@ let DefaultCanvasGroupRender = class DefaultCanvasGroupRender {
20277
20272
  if (drawMode > 0) {
20278
20273
  const { x, y, width, height } = group.attribute;
20279
20274
  const canvas = context.canvas;
20280
- const newCanvas = vglobal.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });
20275
+ const newCanvas = application.global.createCanvas({ width: canvas.width, height: canvas.height, dpr: 1 });
20281
20276
  const newContext = newCanvas.getContext('2d');
20282
20277
  const transform = context.nativeContext.getTransform();
20283
20278
  newContext.setTransform(transform.a, transform.b, transform.c, transform.d, transform.e, transform.f);
@@ -27693,4 +27688,4 @@ const registerFlexLayoutPlugin = () => {
27693
27688
  Factory.registerPlugin('FlexLayoutPlugin', FlexLayoutPlugin);
27694
27689
  };
27695
27690
 
27696
- export { ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, Circle, CircleRender, CircleRenderContribution, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CubicBezierCurve, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncrementalDrawContribution, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Mat4Allocate, MatrixAllocate, MeasureModeEnum, MonotoneX, MonotoneY, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PerformanceRAF, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, STAR_NUMBER_TYPE, STATUS$1 as STATUS, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step, StepClosed, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCircle, createColor, createConicalGradient, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, diff, divideCubic, divideQuad, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepClosedSegments, genStepSegments, genStepTypeSegments, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, interpolatePureColorArrayToStr, intersect, isBrowserEnv, isNodeEnv, isSvg, isXML, layerService, lineModule, lookAt, mat3Tomat4, mat4Allocate, matrixAllocate, multiInject, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWrapTextGraphic, renderCommandList, renderService, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformMat4, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
27691
+ export { ARC3D_NUMBER_TYPE, ARC_NUMBER_TYPE, AREA_NUMBER_TYPE, AbstractGraphicRender, AnimateMode, AnimateStatus, AnimateStepType, Application, Arc, Arc3d, Arc3dRender, ArcRender, ArcRenderContribution, Area, AreaRender, AreaRenderContribution, AttributeUpdateType, AutoEnablePlugins, BaseCanvas, BaseEnvContribution, BaseRender, BaseRenderContributionTime, BaseWindowHandlerContribution, Basis, BeforeRenderConstribution, BoundsContext, BoundsPicker, CIRCLE_NUMBER_TYPE, Canvas3DDrawItemInterceptor, Canvas3DPickItemInterceptor, CanvasFactory, CanvasTextLayout, Circle, CircleRender, CircleRenderContribution, ColorInterpolate, ColorStore, ColorType, CommonDrawItemInterceptorContribution, CommonRenderContribution, Container, ContainerModule, Context2dFactory, ContributionProvider, CubicBezierCurve, CurveContext, CurveTypeEnum, CustomEvent, CustomPath2D, CustomSymbolClass, DEFAULT_TEXT_FONT_FAMILY, DebugDrawItemInterceptorContribution, DefaultArcAllocate, DefaultArcAttribute, DefaultArcRenderContribution, DefaultAreaAllocate, DefaultAreaAttribute, DefaultAreaTextureRenderContribution, DefaultAttribute, DefaultBaseBackgroundRenderContribution, DefaultBaseClipRenderAfterContribution, DefaultBaseClipRenderBeforeContribution, DefaultBaseInteractiveRenderContribution, DefaultBaseTextureRenderContribution, DefaultCanvasAllocate, DefaultCanvasArcRender, DefaultCanvasAreaRender, DefaultCanvasCircleRender, DefaultCanvasGroupRender, DefaultCanvasImageRender, DefaultCanvasLineRender, DefaultCanvasPathRender, DefaultCanvasPolygonRender, DefaultCanvasRectRender, DefaultCanvasSymbolRender, DefaultCanvasTextRender, DefaultCircleAllocate, DefaultCircleAttribute, DefaultCircleRenderContribution, DefaultConnectAttribute, DefaultDebugAttribute, DefaultFillStyle, DefaultGlobal, DefaultGlobalPickerService, DefaultGlyphAttribute, DefaultGraphicAllocate, DefaultGraphicMemoryManager, DefaultGraphicService, DefaultGraphicUtil, DefaultGroupAttribute, DefaultGroupBackgroundRenderContribution, DefaultImageAttribute, DefaultImageRenderContribution, DefaultLayerService, DefaultLayout, DefaultLineAllocate, DefaultLineAttribute, DefaultMat4Allocate, DefaultMatrixAllocate, DefaultPathAllocate, DefaultPathAttribute, DefaultPickService, DefaultPickStyle, DefaultPolygonAttribute, DefaultRect3dAttribute, DefaultRectAllocate, DefaultRectAttribute, DefaultRectRenderContribution, DefaultRenderService, DefaultRichTextAttribute, DefaultRichTextIconAttribute, DefaultStarAttribute, DefaultStrokeStyle, DefaultStyle, DefaultSymbolAllocate, DefaultSymbolAttribute, DefaultSymbolClipRangeStrokeRenderContribution, DefaultSymbolRenderContribution, DefaultTextAllocate, DefaultTextAttribute, DefaultTextMeasureContribution, DefaultTextStyle, DefaultTransform, DefaultTransformUtil, DefaultWindow, Direction, DirectionalLight, DrawContribution, DrawItemInterceptor, DynamicLayerHandlerContribution, Edge, EditModule, EmptyContext2d, EnvContribution, EventManager, EventSystem, EventTarget, FORMAT_ALL_TEXT_COMMAND, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, Factory, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FlexLayoutPlugin, GLYPH_NUMBER_TYPE, GRAPHIC_UPDATE_TAG_KEY, GROUP_NUMBER_TYPE, Generator, GlobalPickerService, Glyph, GlyphRender, Graphic, GraphicCreator$1 as GraphicCreator, GraphicPicker, GraphicRender, GraphicService, GraphicUtil, Group, GroupRender, GroupRenderContribution, GroupUpdateAABBBoundsMode, HtmlAttributePlugin, IContainPointMode, IMAGE_NUMBER_TYPE, Image, ImageRender, ImageRenderContribution, IncrementalDrawContribution, InteractiveDrawItemInterceptorContribution, InteractivePickItemInterceptorContribution, InteractiveSubRenderContribution, LINE_NUMBER_TYPE, Layer, LayerService, Line$1 as Line, LineRender, Linear, LinearClosed, Mat4Allocate, MatrixAllocate, MeasureModeEnum, MonotoneX, MonotoneY, NOWORK_ANIMATE_ATTR, Node, OrthoCamera, PATH_NUMBER_TYPE, POLYGON_NUMBER_TYPE, PURE_STYLE_KEY, PYRAMID3D_NUMBER_TYPE, Path, PathRender, PathRenderContribution, PerformanceRAF, PickItemInterceptor, PickServiceInterceptor, PickerService, PluginService, Polygon, PolygonRender, PolygonRenderContribution, Pyramid3d, Pyramid3dRender, RECT3D_NUMBER_TYPE, RECT_NUMBER_TYPE, RICHTEXT_NUMBER_TYPE, RafBasedSTO, ReactAttributePlugin, Rect, Rect3DRender, Rect3d, RectRender, RectRenderContribution, ReflectSegContext, RenderSelector, RenderService, ResourceLoader, RichText, RichTextEditPlugin, RichTextRender, STAR_NUMBER_TYPE, STATUS$1 as STATUS, SVG_ATTRIBUTE_MAP, SVG_ATTRIBUTE_MAP_KEYS, SVG_PARSE_ATTRIBUTE_MAP, SVG_PARSE_ATTRIBUTE_MAP_KEYS, SYMBOL_NUMBER_TYPE, SegContext, ShadowPickServiceInterceptorContribution, ShadowRoot, ShadowRootDrawItemInterceptorContribution, ShadowRootPickItemInterceptorContribution, SplitRectAfterRenderContribution, SplitRectBeforeRenderContribution, Stage, Star, StarRender, StarRenderContribution, StaticLayerHandlerContribution, Step, StepClosed, Symbol$1 as Symbol, SymbolRender, SymbolRenderContribution, TEXT_NUMBER_TYPE, Text, TextDirection, TextMeasureContribution, TextRender, TextRenderContribution, Theme, TransformUtil, UpdateTag, VGlobal, VWindow, ViewTransform3dPlugin, VirtualLayerHandlerContribution, WILDCARD, WindowHandlerContribution, WrapText, XMLParser, _calculateLineHeight, _interpolateColor, addArcToBezierPath, addAttributeToPrototype, alignBezierCurves, alignSubpath, application, applyTransformOnBezierCurves, arc3dModule, arcModule, areaModule, bezier, bezierCurversToPath, binarySplitPolygon, bindContributionProvider, bindContributionProviderNoSingletonScope, boundStroke, builtInSymbolStrMap, builtinSymbols, builtinSymbolsMap, calcLineCache, calculateArcCornerRadius, calculateLineHeight, canvasAllocate, centroidOfSubpath, circleBounds, circleModule, clock, colorEqual, colorStringInterpolationToStr, container, cornerTangents, createArc, createArc3d, createArea, createCircle, createColor, createConicalGradient, createGlyph, createGroup, createImage, createLine, createMat4, createPath, createPolygon, createPyramid3d, createRect, createRect3d, createRectPath, createRichText, createShadowRoot, createStage, createStar, createSymbol, createText, createWrapText, cubicCalc, cubicLength, cubicPointAt, cubicSubdivide, defaultArcAllocate, defaultArcBackgroundRenderContribution, defaultArcRenderContribution, defaultArcTextureRenderContribution, defaultAreaAllocate, defaultBaseBackgroundRenderContribution, defaultBaseClipRenderAfterContribution, defaultBaseClipRenderBeforeContribution, defaultBaseTextureRenderContribution, defaultCircleAllocate, defaultCircleBackgroundRenderContribution, defaultCircleRenderContribution, defaultCircleTextureRenderContribution, defaultGraphicMemoryManager, defaultGroupBackgroundRenderContribution, defaultImageBackgroundRenderContribution, defaultImageRenderContribution, defaultLineAllocate, defaultPathAllocate, defaultRectAllocate, defaultRectBackgroundRenderContribution, defaultRectRenderContribution, defaultRectTextureRenderContribution, defaultStarBackgroundRenderContribution, defaultStarTextureRenderContribution, defaultSymbolAllocate, defaultSymbolBackgroundRenderContribution, defaultSymbolClipRangeStrokeRenderContribution, defaultSymbolRenderContribution, defaultSymbolTextureRenderContribution, defaultTextAllocate, diff, divideCubic, drawArc, drawArcPath$1 as drawArcPath, drawAreaSegments, drawIncrementalAreaSegments, drawIncrementalSegments, drawSegments, enumCommandMap, fillVisible, findBestMorphingRotation, findConfigIndexByCursorIdx, findCursorIdxByConfigIndex, findNextGraphic, flatten_simplify, foreach, foreachAsync, genBasisSegments, genBasisTypeSegments, genLinearClosedSegments, genLinearClosedTypeSegments, genLinearSegments, genLinearTypeSegments, genMonotoneXSegments, genMonotoneXTypeSegments, genMonotoneYSegments, genMonotoneYTypeSegments, genNumberType, genStepClosedSegments, genStepSegments, genStepTypeSegments, getAttributeFromDefaultAttrList, getConicGradientAt, getCurrentEnv, getDefaultCharacterConfig, getExtraModelMatrix, getModelMatrix, getRichTextBounds, getScaledStroke, getTextBounds, getTheme, getThemeFromGroup, globalTheme, glyphModule, graphicCreator, graphicService, graphicUtil, identityMat4, imageModule, incrementalAddTo, inject, injectable, interpolateColor, interpolateGradientConicalColor, interpolateGradientLinearColor, interpolateGradientRadialColor, interpolatePureColorArray, interpolatePureColorArrayToStr, intersect, isBrowserEnv, isNodeEnv, isSvg, isXML, layerService, lineModule, lookAt, mat3Tomat4, mat4Allocate, matrixAllocate, multiInject, multiplyMat4Mat3, multiplyMat4Mat4, named, newThemeObj, ortho, parsePadding, parseStroke, parseSvgPath, pathModule, pathToBezierCurves, point$3 as point, pointEqual, pointInterpolation, pointInterpolationHighPerformance, pointsEqual, pointsInterpolation, polygonModule, preLoadAllModule, pyramid3dModule, quadCalc, quadLength, quadPointAt, rafBasedSto, rect3dModule, rectFillVisible, rectModule, rectStrokeVisible, recursiveCallBinarySplit, registerArc3dGraphic, registerArcGraphic, registerAreaGraphic, registerCircleGraphic, registerDirectionalLight, registerFlexLayoutPlugin, registerGlyphGraphic, registerGroupGraphic, registerHtmlAttributePlugin, registerImageGraphic, registerLineGraphic, registerOrthoCamera, registerPathGraphic, registerPolygonGraphic, registerPyramid3dGraphic, registerReactAttributePlugin, registerRect3dGraphic, registerRectGraphic, registerRichtextGraphic, registerShadowRootGraphic, registerStarGraphic, registerSymbolGraphic, registerTextGraphic, registerViewTransform3dPlugin, registerWrapTextGraphic, renderCommandList, renderService, rewriteProto, richtextModule, rotateX, rotateY, rotateZ, runFill, runStroke, scaleMat4, segments, shouldUseMat4, snapLength, splitArc, splitArea, splitCircle, splitLine, splitPath, splitPolygon, splitRect, splitToGrids, starModule, strCommandMap, strokeVisible, symbolModule, textAttributesToStyle, textDrawOffsetX, textDrawOffsetY, textLayoutOffsetY, textModule, transformMat4, transformUtil, translate, verticalLayout, vglobal, waitForAllSubLayers, wrapCanvas, wrapContext, xul };
@@ -1,4 +1,4 @@
1
- import { vglobal } from "../modules";
1
+ import { application } from "../application";
2
2
 
3
3
  export class PerformanceRAF {
4
4
  constructor() {
@@ -8,7 +8,7 @@ export class PerformanceRAF {
8
8
  this.nextAnimationFrameCbs = [];
9
9
  for (let i = 0; i < cbs.length; i++) cbs[i] && cbs[i](time);
10
10
  }, this.tryRunAnimationFrameNextFrame = () => {
11
- null === this._rafHandle && 0 !== this.nextAnimationFrameCbs.length && (this._rafHandle = vglobal.getRequestAnimationFrame()(this.runAnimationFrame));
11
+ null === this._rafHandle && 0 !== this.nextAnimationFrameCbs.length && (this._rafHandle = application.global.getRequestAnimationFrame()(this.runAnimationFrame));
12
12
  };
13
13
  }
14
14
  addAnimationFrameCb(callback) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/common/performance-raf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAKrC,MAAM,OAAO,cAAc;IAA3B;QACE,0BAAqB,GAA2B,EAAE,CAAC;QAC3C,eAAU,GAAkB,IAAI,CAAC;QAkB/B,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACvC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACnC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;oBACV,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;iBACd;aACF;QACH,CAAC,CAAC;QAEQ,kCAA6B,GAAG,GAAG,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE;gBACvE,OAAO;aACR;YACD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/E,CAAC,CAAC;IACJ,CAAC;IAjCC,mBAAmB,CAAC,QAA8B;QAChD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,sBAAsB,CAAC,KAAa;QAClC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE;YAE3D,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YACzC,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAmBF","file":"performance-raf.js","sourcesContent":["import { vglobal } from '../modules';\n\n/**\n * 性能优化,将requestAnimationFrame的回调函数存储起来,在下一帧执行\n */\nexport class PerformanceRAF {\n nextAnimationFrameCbs: FrameRequestCallback[] = [];\n private _rafHandle: number | null = null;\n\n addAnimationFrameCb(callback: FrameRequestCallback) {\n this.nextAnimationFrameCbs.push(callback);\n // 下一帧执行nextAnimationFrameCbs\n this.tryRunAnimationFrameNextFrame();\n return this.nextAnimationFrameCbs.length - 1;\n }\n\n removeAnimationFrameCb(index: number): boolean {\n if (index >= 0 && index < this.nextAnimationFrameCbs.length) {\n // Set to null instead of empty function to avoid linter error\n this.nextAnimationFrameCbs[index] = null;\n return true;\n }\n return false;\n }\n\n protected runAnimationFrame = (time: number) => {\n this._rafHandle = null;\n const cbs = this.nextAnimationFrameCbs;\n this.nextAnimationFrameCbs = [];\n for (let i = 0; i < cbs.length; i++) {\n if (cbs[i]) {\n cbs[i](time);\n }\n }\n };\n\n protected tryRunAnimationFrameNextFrame = () => {\n if (this._rafHandle !== null || this.nextAnimationFrameCbs.length === 0) {\n return;\n }\n this._rafHandle = vglobal.getRequestAnimationFrame()(this.runAnimationFrame);\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/common/performance-raf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7C,MAAM,OAAO,cAAc;IAA3B;QACE,0BAAqB,GAA2B,EAAE,CAAC;QAC3C,eAAU,GAAkB,IAAI,CAAC;QAkB/B,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAC7C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,MAAM,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACvC,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;YAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACnC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE;oBACV,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;iBACd;aACF;QACH,CAAC,CAAC;QAEQ,kCAA6B,GAAG,GAAG,EAAE;YAC7C,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,qBAAqB,CAAC,MAAM,KAAK,CAAC,EAAE;gBACvE,OAAO;aACR;YACD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC,MAAM,CAAC,wBAAwB,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC1F,CAAC,CAAC;IACJ,CAAC;IAjCC,mBAAmB,CAAC,QAA8B;QAChD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1C,IAAI,CAAC,6BAA6B,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/C,CAAC;IAED,sBAAsB,CAAC,KAAa;QAClC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE;YAE3D,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YACzC,OAAO,IAAI,CAAC;SACb;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAmBF","file":"performance-raf.js","sourcesContent":["import { application } from '../application';\n\n/**\n * 性能优化,将requestAnimationFrame的回调函数存储起来,在下一帧执行\n */\nexport class PerformanceRAF {\n nextAnimationFrameCbs: FrameRequestCallback[] = [];\n private _rafHandle: number | null = null;\n\n addAnimationFrameCb(callback: FrameRequestCallback) {\n this.nextAnimationFrameCbs.push(callback);\n // 下一帧执行nextAnimationFrameCbs\n this.tryRunAnimationFrameNextFrame();\n return this.nextAnimationFrameCbs.length - 1;\n }\n\n removeAnimationFrameCb(index: number): boolean {\n if (index >= 0 && index < this.nextAnimationFrameCbs.length) {\n // Set to null instead of empty function to avoid linter error\n this.nextAnimationFrameCbs[index] = null;\n return true;\n }\n return false;\n }\n\n protected runAnimationFrame = (time: number) => {\n this._rafHandle = null;\n const cbs = this.nextAnimationFrameCbs;\n this.nextAnimationFrameCbs = [];\n for (let i = 0; i < cbs.length; i++) {\n if (cbs[i]) {\n cbs[i](time);\n }\n }\n };\n\n protected tryRunAnimationFrameNextFrame = () => {\n if (this._rafHandle !== null || this.nextAnimationFrameCbs.length === 0) {\n return;\n }\n this._rafHandle = application.global.getRequestAnimationFrame()(this.runAnimationFrame);\n };\n}\n"]}
@@ -1,8 +1,7 @@
1
1
  import type { IPoint, IPointLike } from '@visactor/vutils';
2
- import type { ICubicBezierCurve, IDirection, IPath2D, IQuadraticBezierCurve } from '../../../interface';
2
+ import type { ICubicBezierCurve, IDirection, IPath2D } from '../../../interface';
3
3
  import { Curve } from './base';
4
4
  export declare function divideCubic(curve: ICubicBezierCurve, t: number): ICubicBezierCurve[];
5
- export declare function divideQuad(curve: IQuadraticBezierCurve, t: number): IQuadraticBezierCurve[];
6
5
  export declare class CubicBezierCurve extends Curve implements ICubicBezierCurve {
7
6
  type: number;
8
7
  originP1?: IPointLike;
@@ -4,20 +4,13 @@ import { Curve } from "./base";
4
4
 
5
5
  import { CurveTypeEnum, Direction } from "../../enums";
6
6
 
7
- import { cubicLength, cubicPointAt, quadPointAt } from "../../bezier-utils";
8
-
9
- import { QuadraticBezierCurve } from "./quadratic-bezier";
7
+ import { cubicLength, cubicPointAt } from "../../bezier-utils";
10
8
 
11
9
  export function divideCubic(curve, t) {
12
10
  const {p0: p0, p1: p1, p2: p2, p3: p3} = curve, pt = cubicPointAt(p0, p1, p2, p3, t), c1 = PointService.pointAtPP(p0, p1, t), c2 = PointService.pointAtPP(p1, p2, t), c3 = PointService.pointAtPP(p2, p3, t), c12 = PointService.pointAtPP(c1, c2, t), c23 = PointService.pointAtPP(c2, c3, t);
13
11
  return [ new CubicBezierCurve(p0, c1, c12, pt), new CubicBezierCurve(pt, c23, c3, p3) ];
14
12
  }
15
13
 
16
- export function divideQuad(curve, t) {
17
- const {p0: p0, p1: p1, p2: p2} = curve, pt = quadPointAt(p0, p1, p2, t), c1 = PointService.pointAtPP(p0, p1, t), c2 = PointService.pointAtPP(p1, p2, t);
18
- return [ new QuadraticBezierCurve(p0, c1, pt), new QuadraticBezierCurve(pt, c2, p2) ];
19
- }
20
-
21
14
  export class CubicBezierCurve extends Curve {
22
15
  constructor(p0, p1, p2, p3) {
23
16
  super(), this.type = CurveTypeEnum.CubicBezierCurve, this.p0 = p0, this.p1 = p1,