@visactor/vgrammar-core 0.13.14 → 0.13.16-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/graph/animation/animator.js +6 -1
- package/cjs/graph/animation/animator.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -1
- package/cjs/index.js.map +1 -1
- package/cjs/view/grammar-record.js +2 -3
- package/cjs/view/grammar-record.js.map +1 -1
- package/es/graph/animation/animator.js +6 -1
- package/es/graph/animation/animator.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interactions/brush-filter.js +2 -1
- package/es/interactions/element-highlight-by-group.js +1 -2
- package/es/interactions/index.js +2 -1
- package/es/interactions/legend-filter.js +1 -1
- package/es/interactions/player-filter.js +1 -1
- package/es/interactions/roll-up.js +1 -1
- package/es/interactions/scrollbar-filter.js +1 -1
- package/es/interactions/slider-filter.js +1 -1
- package/es/interactions/toggle-state-mixin.js +1 -1
- package/es/interactions/tooltip.js +1 -1
- package/es/parse/coordinate.js +1 -1
- package/es/parse/event.js +1 -1
- package/es/parse/mark.js +1 -1
- package/es/parse/option.js +1 -1
- package/es/parse/scale.js +1 -2
- package/es/parse/transform.js +1 -1
- package/es/parse/util.js +1 -1
- package/es/parse/view.js +1 -1
- package/es/view/grammar-record.js +2 -3
- package/es/view/grammar-record.js.map +1 -1
- package/package.json +8 -8
|
@@ -10,7 +10,12 @@ vrender_core_1.Animate.mode |= vrender_core_1.AnimateMode.SET_ATTR_IMMEDIATELY;
|
|
|
10
10
|
|
|
11
11
|
let GlobalAnimatorId = 0;
|
|
12
12
|
|
|
13
|
-
const isCustomAnimateCtor = custom =>
|
|
13
|
+
const isCustomAnimateCtor = custom => {
|
|
14
|
+
var _a;
|
|
15
|
+
if ((0, vutils_1.isNil)(custom) || (0, vutils_1.isNil)(custom.prototype)) return !1;
|
|
16
|
+
const prototype = null !== (_a = custom.prototype) && void 0 !== _a ? _a : {};
|
|
17
|
+
return prototype instanceof vrender_core_1.ACustomAnimate || "onBind" in prototype && "onStart" in prototype && "onEnd" in prototype && "onUpdate" in prototype;
|
|
18
|
+
};
|
|
14
19
|
|
|
15
20
|
class Animator {
|
|
16
21
|
constructor(element, unit, animationOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,yDAA4F;AAa5F,2CAAwH;AAExH,sBAAO,CAAC,IAAI,IAAI,0BAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;IACnG,IAAI,IAAA,cAAK,EAAC,MAAM,CAAC,IAAI,IAAA,cAAK,EAAC,MAAM,CAAC,SAAS,CAAC,EAAE;QAC5C,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CACL,MAAM,CAAC,SAAS,YAAY,6BAAc;QAE1C,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS;YAC3B,SAAS,IAAI,MAAM,CAAC,SAAS;YAC7B,OAAO,IAAI,MAAM,CAAC,SAAS;YAC3B,UAAU,IAAI,MAAM,CAAC,SAAS,CAAC,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAa,QAAQ;IAUnB,YACE,OAAiB,EACjB,IAAoB,EACpB,gBAIC;QAhBH,OAAE,GAAW,gBAAgB,EAAE,CAAC;QAGhC,gBAAW,GAAY,KAAK,CAAC;QAGrB,aAAQ,GAAsB,EAAE,CAAC;QAYvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,QAAQ,CAAC,gBAA0C;QACjD,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,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,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;wBACrF,YAAY,EAAE,YAA6C;wBAC3D,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,UAAU,EAAE,sBAAsB;qBACnC,CAAC,CAAC;iBACJ;qBAAM,IAAI,eAAe,EAAE;oBAC1B,OAAO,IAAK,YAA4C,CACtD,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,EAAE,EACb,QAAQ,EACR,MAAM,CAAC,MAAM,EACb,sBAAsB,CACvB,CAAC;iBACH;qBAAM,IAAI,UAAU,CAAC,EAAE,EAAE;oBACxB,OAAO,IAAI,4BAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;iBACtF;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,cAAc,CAAC,IAAI,CAAC,IAAI,2BAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AArMD,4BAqMC","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n if (isNil(custom) || isNil(custom.prototype)) {\n return false;\n }\n return (\n custom.prototype instanceof ACustomAnimate ||\n // similar to ACustomAnimate, apply for different vrender version\n ('onBind' in custom.prototype &&\n 'onStart' in custom.prototype &&\n 'onEnd' in custom.prototype &&\n 'onUpdate' in custom.prototype)\n );\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined) ?? {};\n\n const customOption = attributes.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":";;;AAAA,6CAAwD;AAGxD,yDAA4F;AAa5F,2CAAwH;AAExH,sBAAO,CAAC,IAAI,IAAI,0BAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;;IACnG,IAAI,IAAA,cAAK,EAAC,MAAM,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MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,cAAc,CAAC,IAAI,CAAC,IAAI,2BAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF;AArMD,4BAqMC","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n if (isNil(custom) || isNil(custom.prototype)) {\n return false;\n }\n const prototype = custom.prototype ?? {};\n return (\n prototype instanceof ACustomAnimate ||\n // similar to ACustomAnimate, apply for different vrender version\n ('onBind' in prototype && 'onStart' in prototype && 'onEnd' in prototype && 'onUpdate' in prototype)\n );\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined) ?? {};\n\n const customOption = attributes.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -18,7 +18,8 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
20
|
}), exports.vglobal = exports.ThemeManager = exports.SIGNAL_VIEW_BOX = exports.SIGNAL_WIDTH = exports.SIGNAL_VIEW_WIDTH = exports.SIGNAL_VIEW_HEIGHT = exports.SIGNAL_PADDING = exports.SIGNAL_HEIGHT = exports.SIGNAL_AUTOFIT = exports.Factory = exports.GrammarBase = exports.invokeFunctionType = exports.parseFunctionType = exports.registerCoordinate = exports.Coordinate = exports.registerScale = exports.Scale = exports.View = exports.version = void 0,
|
|
21
|
-
exports.version = "0.13.
|
|
21
|
+
exports.version = "0.13.16-alpha.0", __exportStar(require("./graph"), exports),
|
|
22
|
+
__exportStar(require("./interactions"), exports);
|
|
22
23
|
|
|
23
24
|
var view_1 = require("./view");
|
|
24
25
|
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,0CAAwB;AAExB,iDAA+B;AAE/B,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AACb,sCAAoD;AAA3C,8FAAA,KAAK,OAAA;AAAE,sGAAA,aAAa,OAAA;AAC7B,gDAAmE;AAA1D,wGAAA,UAAU,OAAA;AAAE,gHAAA,kBAAkB,OAAA;AACvC,qCAAqE;AAA5D,yGAAA,iBAAiB,OAAA;AAAE,0GAAA,kBAAkB,OAAA;AAC9C,oDAAkD;AAAzC,2GAAA,WAAW,OAAA;AACpB,8CAA4B;AAC5B,0CAAwB;AACxB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,8CAQ0B;AAPxB,2GAAA,cAAc,OAAA;AACd,0GAAA,aAAa,OAAA;AACb,2GAAA,cAAc,OAAA;AACd,+GAAA,kBAAkB,OAAA;AAClB,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AACZ,4GAAA,eAAe,OAAA;AAGjB,uDAAqD;AAA5C,6GAAA,YAAY,OAAA;AAErB,0CAAwB;AACxB,8CAA4B;AAC5B,+CAA6B;AAC7B,8DAA4C;AAE5C,uDAAiD;AAAxC,uGAAA,OAAO,OAAA;AAChB,wCAAsB;AACtB,iDAA+B;AAC/B,wDAAsC;AACtC,4DAA0C;AAC1C,uDAAqC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.13.16-alpha.0\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
|
@@ -153,9 +153,8 @@ class RecordedTreeGrammars extends RecordedGrammars {
|
|
|
153
153
|
if (super.unrecord(grammar), "mark" === grammar.grammarType) {
|
|
154
154
|
const mark = grammar, currentNode = this._markNodes.find((node => node.mark === mark));
|
|
155
155
|
this._markNodes.forEach((node => {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
currentNode.parent = null) : mark.markType === enums_1.GrammarMarkType.group && mark.includesChild(targetMark, !1) && (currentNode.children = currentNode.children.filter((n => n !== node)),
|
|
156
|
+
node.mark.markType === enums_1.GrammarMarkType.group && node.children.includes(currentNode) ? (node.children = node.children.filter((n => n !== currentNode)),
|
|
157
|
+
currentNode.parent = null) : mark.markType === enums_1.GrammarMarkType.group && currentNode.children.includes(node) && (currentNode.children = currentNode.children.filter((n => n !== node)),
|
|
159
158
|
node.parent = null);
|
|
160
159
|
})), this._markNodes = this._markNodes.filter((n => n !== currentNode));
|
|
161
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/view/grammar-record.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAcnD,0CAAiD;AAEjD,MAAa,gBAAgB;IAsB3B,YACE,MAAoD,EACpD,qBAAoE;QArB9D,cAAS,GAA8D;YAC7E,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QAEM,gBAAW,GAA4E;YAC7F,MAAM,EAAE,EAAE;YACV,IAAI,EAA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C;AAEM,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,EAAE;AAEzD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B","file":"grammar-record.js","sourcesContent":["import { isNil, isString } from '@visactor/vutils';\nimport type {\n BuiltInGrammarType,\n ICoordinate,\n IData,\n IGrammarBase,\n IMark,\n IScale,\n ISignal,\n IRecordedGrammars,\n IGroupMark,\n IMarkTreeNode,\n IRecordedTreeGrammars\n} from '../types';\nimport { GrammarMarkType } from '../graph/enums';\n\nexport class RecordedGrammars implements IRecordedGrammars {\n private _warning: (key: string, grammar: IGrammarBase) => void;\n private _mapKey: (grammar: IGrammarBase) => string;\n private _grammars: Record<BuiltInGrammarType | 'customized', IGrammarBase[]> = {\n signal: [],\n data: [],\n scale: [],\n coordinate: [],\n mark: [],\n customized: []\n };\n // map key might not be unique\n private _grammarMap: Record<BuiltInGrammarType | 'customized', Record<string, IGrammarBase>> = {\n signal: {},\n data: {},\n scale: {},\n coordinate: {},\n mark: {},\n customized: {}\n };\n private _size: number = 0;\n\n constructor(\n mapKey: string | ((grammar: IGrammarBase) => string),\n warningWhenDuplicated?: (key: string, grammar: IGrammarBase) => void\n ) {\n this._mapKey = isString(mapKey) ? grammar => grammar[mapKey] : mapKey;\n this._warning = warningWhenDuplicated;\n }\n\n record(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType].push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap[grammarType][key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap[grammarType][key] = grammar;\n }\n }\n } else {\n this._grammars.customized.push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap.customized[key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap.customized[key] = grammar;\n }\n }\n }\n this._size += 1;\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType] = this._grammars[grammarType].filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap[grammarType][key] === grammar) {\n delete this._grammarMap[grammarType][key];\n }\n } else {\n this._grammars.customized = this._grammars.customized.filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap.customized[key] === grammar) {\n delete this._grammarMap.customized[key];\n }\n }\n this._size -= 1;\n return this;\n }\n\n size() {\n return this._size;\n }\n\n getSignal<T>(key: string): ISignal<T> | null {\n return (this._grammarMap.signal[key] as ISignal<T>) ?? null;\n }\n getData(key: string): IData | null {\n return (this._grammarMap.data[key] as IData) ?? null;\n }\n getScale(key: string): IScale | null {\n return (this._grammarMap.scale[key] as IScale) ?? null;\n }\n getCoordinate(key: string): ICoordinate | null {\n return (this._grammarMap.coordinate[key] as ICoordinate) ?? null;\n }\n getMark(key: string): IMark | null {\n return (this._grammarMap.mark[key] as IMark) ?? null;\n }\n getCustomized(key: string): IGrammarBase | null {\n return this._grammarMap.customized[key] ?? null;\n }\n getGrammar(key: string): IGrammarBase | null {\n if (this._grammarMap.data[key]) {\n return this._grammarMap.data[key];\n } else if (this._grammarMap.signal[key]) {\n return this._grammarMap.signal[key];\n } else if (this._grammarMap.scale[key]) {\n return this._grammarMap.scale[key];\n } else if (this._grammarMap.coordinate[key]) {\n return this._grammarMap.coordinate[key];\n } else if (this._grammarMap.mark[key]) {\n return this._grammarMap.mark[key];\n } else if (this._grammarMap.customized[key]) {\n return this._grammarMap.customized[key];\n }\n return null;\n }\n\n getAllSignals(): ISignal<any>[] {\n return this._grammars.signal as ISignal<any>[];\n }\n getAllData(): IData[] {\n return this._grammars.data as IData[];\n }\n getAllScales(): IScale[] {\n return this._grammars.scale as IScale[];\n }\n getAllCoordinates(): ICoordinate[] {\n return this._grammars.coordinate as ICoordinate[];\n }\n getAllMarks(): IMark[] {\n return this._grammars.mark as IMark[];\n }\n getAllCustomized(): IGrammarBase[] {\n return this._grammars.customized;\n }\n\n traverse(func: (grammar: IGrammarBase) => boolean | void) {\n Object.values(this._grammars ?? {}).forEach(grammars =>\n (grammars ?? []).forEach(grammar => {\n // stop traversing when func returns true\n if (func.call(null, grammar)) {\n return;\n }\n })\n );\n }\n\n find(func: (grammar: IGrammarBase) => boolean) {\n let targetGrammar: IGrammarBase = null;\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammar = grammar;\n return true;\n }\n return false;\n });\n return targetGrammar;\n }\n\n filter(func: (grammar: IGrammarBase) => boolean) {\n const targetGrammars: IGrammarBase[] = [];\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammars.push(grammar);\n }\n });\n return targetGrammars;\n }\n\n clear() {\n this._size = 0;\n this._grammars = { signal: [], data: [], scale: [], coordinate: [], mark: [], customized: [] };\n this._grammarMap = { signal: {}, data: {}, scale: {}, coordinate: {}, mark: {}, customized: {} };\n }\n\n release() {\n this._size = 0;\n this._grammars = null;\n this._grammarMap = null;\n }\n}\n\nexport class RecordedTreeGrammars extends RecordedGrammars implements IRecordedTreeGrammars {\n private _markNodes: IMarkTreeNode[] = [];\n\n record(grammar: IGrammarBase) {\n super.record(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode: IMarkTreeNode = {\n mark: mark,\n parent: null,\n children: []\n };\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children.push(currentNode);\n currentNode.parent = node;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children.push(node);\n node.parent = currentNode;\n }\n });\n this._markNodes.push(currentNode);\n }\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n super.unrecord(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode = this._markNodes.find(node => node.mark === mark);\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children = node.children.filter(n => n !== currentNode);\n currentNode.parent = null;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children = currentNode.children.filter(n => n !== node);\n node.parent = null;\n }\n });\n this._markNodes = this._markNodes.filter(n => n !== currentNode);\n }\n return this;\n }\n\n getAllMarkNodes() {\n return this._markNodes;\n }\n\n clear() {\n super.clear();\n this._markNodes = [];\n }\n\n release() {\n super.release();\n this._markNodes = null;\n }\n}\n\nexport const releaseUpMarkNode = (node: IMarkTreeNode) => {\n // if (node.mark.get)\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/view/grammar-record.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAcnD,0CAAiD;AAEjD,MAAa,gBAAgB;IAsB3B,YACE,MAAoD,EACpD,qBAAoE;QArB9D,cAAS,GAA8D;YAC7E,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QAEM,gBAAW,GAA4E;YAC7F,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QACM,UAAK,GAAW,CAAC,CAAC;QAMxB,IAAI,CAAC,OAAO,GAAG,IAAA,iBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC;IACxC,CAAC;IAED,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MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;oBAC7D,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC;iBAC3B;qBAAM,IAAI,IAAI,CAAC,QAAQ,KAAK,uBAAe,CAAC,KAAK,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;oBACzF,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;oBACpE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF;AA5DD,oDA4DC;AAEM,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,EAAE;AAEzD,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B","file":"grammar-record.js","sourcesContent":["import { isNil, isString } from '@visactor/vutils';\nimport type {\n BuiltInGrammarType,\n ICoordinate,\n IData,\n IGrammarBase,\n IMark,\n IScale,\n ISignal,\n IRecordedGrammars,\n IGroupMark,\n IMarkTreeNode,\n IRecordedTreeGrammars\n} from '../types';\nimport { GrammarMarkType } from '../graph/enums';\n\nexport class RecordedGrammars implements IRecordedGrammars {\n private _warning: (key: string, grammar: IGrammarBase) => void;\n private _mapKey: (grammar: IGrammarBase) => string;\n private _grammars: Record<BuiltInGrammarType | 'customized', IGrammarBase[]> = {\n signal: [],\n data: [],\n scale: [],\n coordinate: [],\n mark: [],\n customized: []\n };\n // map key might not be unique\n private _grammarMap: Record<BuiltInGrammarType | 'customized', Record<string, IGrammarBase>> = {\n signal: {},\n data: {},\n scale: {},\n coordinate: {},\n mark: {},\n customized: {}\n };\n private _size: number = 0;\n\n constructor(\n mapKey: string | ((grammar: IGrammarBase) => string),\n warningWhenDuplicated?: (key: string, grammar: IGrammarBase) => void\n ) {\n this._mapKey = isString(mapKey) ? grammar => grammar[mapKey] : mapKey;\n this._warning = warningWhenDuplicated;\n }\n\n record(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType].push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap[grammarType][key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap[grammarType][key] = grammar;\n }\n }\n } else {\n this._grammars.customized.push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap.customized[key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap.customized[key] = grammar;\n }\n }\n }\n this._size += 1;\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType] = this._grammars[grammarType].filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap[grammarType][key] === grammar) {\n delete this._grammarMap[grammarType][key];\n }\n } else {\n this._grammars.customized = this._grammars.customized.filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap.customized[key] === grammar) {\n delete this._grammarMap.customized[key];\n }\n }\n this._size -= 1;\n return this;\n }\n\n size() {\n return this._size;\n }\n\n getSignal<T>(key: string): ISignal<T> | null {\n return (this._grammarMap.signal[key] as ISignal<T>) ?? null;\n }\n getData(key: string): IData | null {\n return (this._grammarMap.data[key] as IData) ?? null;\n }\n getScale(key: string): IScale | null {\n return (this._grammarMap.scale[key] as IScale) ?? null;\n }\n getCoordinate(key: string): ICoordinate | null {\n return (this._grammarMap.coordinate[key] as ICoordinate) ?? null;\n }\n getMark(key: string): IMark | null {\n return (this._grammarMap.mark[key] as IMark) ?? null;\n }\n getCustomized(key: string): IGrammarBase | null {\n return this._grammarMap.customized[key] ?? null;\n }\n getGrammar(key: string): IGrammarBase | null {\n if (this._grammarMap.data[key]) {\n return this._grammarMap.data[key];\n } else if (this._grammarMap.signal[key]) {\n return this._grammarMap.signal[key];\n } else if (this._grammarMap.scale[key]) {\n return this._grammarMap.scale[key];\n } else if (this._grammarMap.coordinate[key]) {\n return this._grammarMap.coordinate[key];\n } else if (this._grammarMap.mark[key]) {\n return this._grammarMap.mark[key];\n } else if (this._grammarMap.customized[key]) {\n return this._grammarMap.customized[key];\n }\n return null;\n }\n\n getAllSignals(): ISignal<any>[] {\n return this._grammars.signal as ISignal<any>[];\n }\n getAllData(): IData[] {\n return this._grammars.data as IData[];\n }\n getAllScales(): IScale[] {\n return this._grammars.scale as IScale[];\n }\n getAllCoordinates(): ICoordinate[] {\n return this._grammars.coordinate as ICoordinate[];\n }\n getAllMarks(): IMark[] {\n return this._grammars.mark as IMark[];\n }\n getAllCustomized(): IGrammarBase[] {\n return this._grammars.customized;\n }\n\n traverse(func: (grammar: IGrammarBase) => boolean | void) {\n Object.values(this._grammars ?? {}).forEach(grammars =>\n (grammars ?? []).forEach(grammar => {\n // stop traversing when func returns true\n if (func.call(null, grammar)) {\n return;\n }\n })\n );\n }\n\n find(func: (grammar: IGrammarBase) => boolean) {\n let targetGrammar: IGrammarBase = null;\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammar = grammar;\n return true;\n }\n return false;\n });\n return targetGrammar;\n }\n\n filter(func: (grammar: IGrammarBase) => boolean) {\n const targetGrammars: IGrammarBase[] = [];\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammars.push(grammar);\n }\n });\n return targetGrammars;\n }\n\n clear() {\n this._size = 0;\n this._grammars = { signal: [], data: [], scale: [], coordinate: [], mark: [], customized: [] };\n this._grammarMap = { signal: {}, data: {}, scale: {}, coordinate: {}, mark: {}, customized: {} };\n }\n\n release() {\n this._size = 0;\n this._grammars = null;\n this._grammarMap = null;\n }\n}\n\nexport class RecordedTreeGrammars extends RecordedGrammars implements IRecordedTreeGrammars {\n private _markNodes: IMarkTreeNode[] = [];\n\n record(grammar: IGrammarBase) {\n super.record(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode: IMarkTreeNode = {\n mark: mark,\n parent: null,\n children: []\n };\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children.push(currentNode);\n currentNode.parent = node;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children.push(node);\n node.parent = currentNode;\n }\n });\n this._markNodes.push(currentNode);\n }\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n super.unrecord(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode = this._markNodes.find(node => node.mark === mark);\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && node.children.includes(currentNode)) {\n node.children = node.children.filter(n => n !== currentNode);\n currentNode.parent = null;\n } else if (mark.markType === GrammarMarkType.group && currentNode.children.includes(node)) {\n currentNode.children = currentNode.children.filter(n => n !== node);\n node.parent = null;\n }\n });\n this._markNodes = this._markNodes.filter(n => n !== currentNode);\n }\n return this;\n }\n\n getAllMarkNodes() {\n return this._markNodes;\n }\n\n clear() {\n super.clear();\n this._markNodes = [];\n }\n\n release() {\n super.release();\n this._markNodes = null;\n }\n}\n\nexport const releaseUpMarkNode = (node: IMarkTreeNode) => {\n // if (node.mark.get)\n};\n"]}
|
|
@@ -8,7 +8,12 @@ Animate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;
|
|
|
8
8
|
|
|
9
9
|
let GlobalAnimatorId = 0;
|
|
10
10
|
|
|
11
|
-
const isCustomAnimateCtor = custom =>
|
|
11
|
+
const isCustomAnimateCtor = custom => {
|
|
12
|
+
var _a;
|
|
13
|
+
if (isNil(custom) || isNil(custom.prototype)) return !1;
|
|
14
|
+
const prototype = null !== (_a = custom.prototype) && void 0 !== _a ? _a : {};
|
|
15
|
+
return prototype instanceof ACustomAnimate || "onBind" in prototype && "onStart" in prototype && "onEnd" in prototype && "onUpdate" in prototype;
|
|
16
|
+
};
|
|
12
17
|
|
|
13
18
|
export class Animator {
|
|
14
19
|
constructor(element, unit, animationOptions) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;IACnG,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;QAC5C,OAAO,KAAK,CAAC;KACd;IACD,OAAO,CACL,MAAM,CAAC,SAAS,YAAY,cAAc;QAE1C,CAAC,QAAQ,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AC,CAAC,CAAC;aACxC;iBAAM,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n if (isNil(custom) || isNil(custom.prototype)) {\n return false;\n }\n return (\n custom.prototype instanceof ACustomAnimate ||\n // similar to ACustomAnimate, apply for different vrender version\n ('onBind' in custom.prototype &&\n 'onStart' in custom.prototype &&\n 'onEnd' in custom.prototype &&\n 'onUpdate' in custom.prototype)\n );\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined) ?? {};\n\n const customOption = attributes.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graph/animation/animator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAa5F,OAAO,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAExH,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,oBAAoB,CAAC;AAEjD,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB,MAAM,mBAAmB,GAAG,CAAC,MAAoE,EAAE,EAAE;;IACnG,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;QAC5C,OAAO,KAAK,CAAC;KACd;IACD,MAAM,SAAS,GAAG,MAAA,MAAM,CAAC,SAAS,mCAAI,EAAE,CAAC;IACzC,OAAO,CACL,SAAS,YAAY,cAAc;QAEnC,CAAC,QAAQ,IAAI,SAAS,IAAI,SAAS,IAAI,SAAS,IAAI,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,CAAC,CACrG,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,OAAO,QAAQ;IAUnB,YACE,OAAiB,EACjB,IAAoB,EACpB,gBAIC;QAhBH,OAAE,GAAW,gBAAgB,EAAE,CAAC;QAGhC,gBAAW,GAAY,KAAK,CAAC;QAGrB,aAAQ,GAAsB,EAAE,CAAC;QAYvC,IAAI,CAAC,OAAO,G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,CAAC,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;gBAExF,IAAI,oBAAoB,EAAE;oBACxB,OAAO,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;wBACrF,YAAY,EAAE,YAA6C;wBAC3D,OAAO,EAAE,IAAI,CAAC,OAAO;wBACrB,UAAU,EAAE,sBAAsB;qBACnC,CAAC,CAAC;iBACJ;qBAAM,IAAI,eAAe,EAAE;oBAC1B,OAAO,IAAK,YAA4C,CACtD,UAAU,CAAC,IAAI,EACf,UAAU,CAAC,EAAE,EACb,QAAQ,EACR,MAAM,CAAC,MAAM,EACb,sBAAsB,CACvB,CAAC;iBACH;qBAAM,IAAI,UAAU,CAAC,EAAE,EAAE;oBACxB,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;iBACtF;YACH,CAAC,CAAC;iBACD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAEtC,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC/B,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;aACxC;iBAAM,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,cAAc,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;aACjE;SACF;QAED,IAAI,UAAU,GAAG,CAAC,EAAE;YAClB,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;SACjC;IACH,CAAC;CACF","file":"animator.js","sourcesContent":["import { isNil, isValidNumber } from '@visactor/vutils';\nimport type { IAnimate as IGraphicAnimate } from '@visactor/vrender-core';\n// eslint-disable-next-line no-duplicate-imports\nimport { ACustomAnimate, Animate, AnimateGroup, AnimateMode } from '@visactor/vrender-core';\nimport type {\n IAnimationChannelInterpolator,\n IAnimationCustomConstructor,\n IAnimationTimeline,\n IAnimator,\n IAnimatorOptions,\n IAnimationUnit,\n IAnimationParameters,\n IAnimationTimeSlice,\n IElement,\n IAnimationEffect\n} from '../../types';\nimport { AttributeAnimate, channelAnimationAttributes, CustomInterpolator, typeAnimationAttributes } from './attribute';\n\nAnimate.mode |= AnimateMode.SET_ATTR_IMMEDIATELY;\n\nlet GlobalAnimatorId = 0;\n\nconst isCustomAnimateCtor = (custom?: IAnimationChannelInterpolator | IAnimationCustomConstructor) => {\n if (isNil(custom) || isNil(custom.prototype)) {\n return false;\n }\n const prototype = custom.prototype ?? {};\n return (\n prototype instanceof ACustomAnimate ||\n // similar to ACustomAnimate, apply for different vrender version\n ('onBind' in prototype && 'onStart' in prototype && 'onEnd' in prototype && 'onUpdate' in prototype)\n );\n};\n\nexport class Animator implements IAnimator {\n id: number = GlobalAnimatorId++;\n element: IElement;\n animationOptions: IAnimatorOptions;\n isAnimating: boolean = false;\n\n private unit: IAnimationUnit;\n private runnings: IGraphicAnimate[] = [];\n private callbackFunction: (...args: any[]) => any;\n\n constructor(\n element: IElement,\n unit: IAnimationUnit,\n animationOptions: {\n state: string;\n timeline: IAnimationTimeline;\n id: string;\n }\n ) {\n this.element = element;\n this.animationOptions = animationOptions;\n this.unit = unit;\n }\n\n callback(callbackFunction: (...args: any[]) => void): this {\n this.callbackFunction = callbackFunction;\n return this;\n }\n\n animate(animationParameters: IAnimationParameters, parameters: any): this {\n this.isAnimating = true;\n\n this.animateElement(animationParameters, parameters);\n\n // if no valid running, end animating immediately\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n return this;\n }\n\n stop(stopState: 'start' | 'end' = 'end', invokeCallback: boolean = true): this {\n // FIXME: wait for VRender to fix 'end' parameter\n this.runnings.forEach(running => running.stop(stopState));\n this.animationEnd(invokeCallback);\n return this;\n }\n\n pause(): this {\n this.runnings.forEach(running => running.pause());\n return this;\n }\n\n resume(): this {\n this.runnings.forEach(running => running.resume());\n return this;\n }\n\n startAt(startTime: number): this {\n this.runnings.forEach(running => {\n const initialDelay = this.unit.initialDelay;\n running.startAt(initialDelay + startTime);\n });\n return this;\n }\n\n getTotalAnimationTime() {\n const timeLineDuration = this.unit.initialDelay + this.unit.loopDuration * this.unit.loopCount;\n return this.unit.totalTime ?? timeLineDuration;\n }\n\n getEndAttributes() {\n return this.runnings.reduce((attributes, running) => {\n return Object.assign(attributes, running.getEndProps());\n }, {} as Record<string, any>);\n }\n\n private animationEnd(invokeCallback: boolean = true) {\n this.isAnimating = false;\n this.runnings = null;\n if (invokeCallback) {\n this.callbackFunction?.call(null);\n }\n }\n\n private animateElement(animationParameters: IAnimationParameters, parameters: any) {\n const graphicItem = this.element.getGraphicItem();\n\n if (!graphicItem) {\n return;\n }\n\n const graphicAnimate: IGraphicAnimate = graphicItem.animate();\n this.runnings.push(graphicAnimate);\n // initialDelay is only used at first loop\n graphicAnimate.startAt(this.unit.initialDelay);\n // execute loop animation\n graphicAnimate.wait(this.unit.loopDelay);\n this.unit.timeSlices.forEach(timeSlice => {\n this.animateTimeSlice(graphicAnimate, timeSlice, animationParameters, parameters);\n });\n graphicAnimate.wait(this.unit.loopDelayAfter);\n\n graphicAnimate.loop(this.unit.loopCount - 1);\n\n if (isValidNumber(this.unit.totalTime)) {\n // FIXME: use VRender api instead after VRender refactor is finished\n setTimeout(() => {\n if (graphicAnimate) {\n graphicAnimate.stop('end');\n }\n }, this.unit.totalTime);\n }\n\n graphicAnimate.onEnd(() => {\n this.runnings = this.runnings.filter(running => running !== graphicAnimate);\n if (this.runnings.length === 0) {\n this.animationEnd();\n }\n });\n }\n\n private animateTimeSlice(\n graphicAnimate: IGraphicAnimate,\n timeSlice: IAnimationTimeSlice,\n animationParameters: IAnimationParameters,\n parameters: any\n ) {\n const delay = timeSlice.delay as number;\n const delayAfter = timeSlice.delayAfter as number;\n const duration = timeSlice.duration as number;\n const effects = timeSlice.effects as IAnimationEffect[];\n\n // wait in loop animation before animation starts\n if (delay > 0) {\n graphicAnimate.wait(delay);\n }\n\n if (effects.length < 0) {\n graphicAnimate.wait(duration);\n } else {\n const customAnimates = effects\n .map((effect, index) => {\n const attributes =\n (effect.type\n ? typeAnimationAttributes(this.element, effect, animationParameters, parameters)\n : effect.channel\n ? channelAnimationAttributes(this.element, effect, animationParameters, parameters)\n : undefined) ?? {};\n\n const customOption = attributes.custom || effect?.custom;\n const customParametersOption = attributes?.customParameters || effect?.customParameters;\n\n if (\n attributes.from &&\n Object.keys(attributes.from).length &&\n this.unit &&\n this.animationOptions.timeline.controlOptions.immediatelyApply &&\n this.element.mark.markType !== 'component'\n ) {\n this.element.getGraphicItem().setAttributes(attributes.from);\n }\n\n const isCustomAnimate = isCustomAnimateCtor(customOption);\n const isCustomInterpolator = !isNil(customOption) && !isCustomAnimateCtor(customOption);\n\n if (isCustomInterpolator) {\n return new CustomInterpolator(attributes.from, attributes.to, duration, effect.easing, {\n interpolator: customOption as IAnimationChannelInterpolator,\n element: this.element,\n parameters: customParametersOption\n });\n } else if (isCustomAnimate) {\n return new (customOption as IAnimationCustomConstructor)(\n attributes.from,\n attributes.to,\n duration,\n effect.easing,\n customParametersOption\n );\n } else if (attributes.to) {\n return new AttributeAnimate(attributes.from, attributes.to, duration, effect.easing);\n }\n })\n .filter(animate => !isNil(animate));\n\n if (customAnimates.length === 1) {\n graphicAnimate.play(customAnimates[0]);\n } else if (customAnimates.length > 1) {\n graphicAnimate.play(new AnimateGroup(duration, customAnimates));\n }\n }\n\n if (delayAfter > 0) {\n graphicAnimate.wait(delayAfter);\n }\n }\n}\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,SAAS,CAAC;AAExB,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC","file":"index.js","sourcesContent":["// -- Exports -----\nexport const version = \"0.13.16-alpha.0\";\n\nexport * from './graph';\n\nexport * from './interactions';\n\nexport { View } from './view';\nexport { Scale, registerScale } from './view/scale';\nexport { Coordinate, registerCoordinate } from './view/coordinate';\nexport { parseFunctionType, invokeFunctionType } from './parse/util';\nexport { GrammarBase } from './view/grammar-base';\nexport * from './util/text';\nexport * from './types';\nexport { Factory } from './core/factory';\nexport {\n SIGNAL_AUTOFIT,\n SIGNAL_HEIGHT,\n SIGNAL_PADDING,\n SIGNAL_VIEW_HEIGHT,\n SIGNAL_VIEW_WIDTH,\n SIGNAL_WIDTH,\n SIGNAL_VIEW_BOX\n} from './view/constants';\n\nexport { ThemeManager } from './theme/theme-manager';\n\nexport * from './glyph';\nexport * from './component';\nexport * from './transforms';\nexport * from './graph/animation/animation';\n\nexport { vglobal } from '@visactor/vrender-core';\nexport * from './env';\nexport * from './interactions';\nexport * from './semantic-marks/cell';\nexport * from './semantic-marks/interval';\nexport * from './graph/mark/graphic';\n"]}
|
package/es/interactions/index.js
CHANGED
package/es/parse/coordinate.js
CHANGED
package/es/parse/event.js
CHANGED
package/es/parse/mark.js
CHANGED
|
@@ -16,4 +16,4 @@ export function parseEncodeType(encoder, view) {
|
|
|
16
16
|
return encoder.scale && (dependencies = isGrammar(encoder.scale) ? [ encoder.scale ] : array(view.getScaleById(encoder.scale))),
|
|
17
17
|
dependencies.concat(parseFunctionType(encoder, view));
|
|
18
18
|
}
|
|
19
|
-
//# sourceMappingURL=mark.js.map
|
|
19
|
+
//# sourceMappingURL=mark.js.map
|
package/es/parse/option.js
CHANGED
|
@@ -8,4 +8,4 @@ export const parseOptions = (options, params) => options ? isObject(options) ? O
|
|
|
8
8
|
const option = options[key];
|
|
9
9
|
return res[key] = parseOptionValue(option, params), res;
|
|
10
10
|
}), {}) : options.map((option => parseOptionValue(option, params))) : options;
|
|
11
|
-
//# sourceMappingURL=option.js.map
|
|
11
|
+
//# sourceMappingURL=option.js.map
|
package/es/parse/scale.js
CHANGED
package/es/parse/transform.js
CHANGED
package/es/parse/util.js
CHANGED
|
@@ -62,4 +62,4 @@ export const isGrammar = el => el && !isNil(el.grammarType);
|
|
|
62
62
|
export const parseField = field => isFunction(field) ? field : datum => datum[field];
|
|
63
63
|
|
|
64
64
|
export const parseColor = color => isString(color) && Color.parseColorString(color) ? color : null;
|
|
65
|
-
//# sourceMappingURL=util.js.map
|
|
65
|
+
//# sourceMappingURL=util.js.map
|
package/es/parse/view.js
CHANGED
|
@@ -147,9 +147,8 @@ export class RecordedTreeGrammars extends RecordedGrammars {
|
|
|
147
147
|
if (super.unrecord(grammar), "mark" === grammar.grammarType) {
|
|
148
148
|
const mark = grammar, currentNode = this._markNodes.find((node => node.mark === mark));
|
|
149
149
|
this._markNodes.forEach((node => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
currentNode.parent = null) : mark.markType === GrammarMarkType.group && mark.includesChild(targetMark, !1) && (currentNode.children = currentNode.children.filter((n => n !== node)),
|
|
150
|
+
node.mark.markType === GrammarMarkType.group && node.children.includes(currentNode) ? (node.children = node.children.filter((n => n !== currentNode)),
|
|
151
|
+
currentNode.parent = null) : mark.markType === GrammarMarkType.group && currentNode.children.includes(node) && (currentNode.children = currentNode.children.filter((n => n !== node)),
|
|
153
152
|
node.parent = null);
|
|
154
153
|
})), this._markNodes = this._markNodes.filter((n => n !== currentNode));
|
|
155
154
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/view/grammar-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAcnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,OAAO,gBAAgB;IAsB3B,YACE,MAAoD,EACpD,qBAAoE;QArB9D,cAAS,GAA8D;YAC7E,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QAEM,gBAAW,GAA4E;YAC7F,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EA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ICoordinate,\n IData,\n IGrammarBase,\n IMark,\n IScale,\n ISignal,\n IRecordedGrammars,\n IGroupMark,\n IMarkTreeNode,\n IRecordedTreeGrammars\n} from '../types';\nimport { GrammarMarkType } from '../graph/enums';\n\nexport class RecordedGrammars implements IRecordedGrammars {\n private _warning: (key: string, grammar: IGrammarBase) => void;\n private _mapKey: (grammar: IGrammarBase) => string;\n private _grammars: Record<BuiltInGrammarType | 'customized', IGrammarBase[]> = {\n signal: [],\n data: [],\n scale: [],\n coordinate: [],\n mark: [],\n customized: []\n };\n // map key might not be unique\n private _grammarMap: Record<BuiltInGrammarType | 'customized', Record<string, IGrammarBase>> = {\n signal: {},\n data: {},\n scale: {},\n coordinate: {},\n mark: {},\n customized: {}\n };\n private _size: number = 0;\n\n constructor(\n mapKey: string | ((grammar: IGrammarBase) => string),\n warningWhenDuplicated?: (key: string, grammar: IGrammarBase) => void\n ) {\n this._mapKey = isString(mapKey) ? grammar => grammar[mapKey] : mapKey;\n this._warning = warningWhenDuplicated;\n }\n\n record(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType].push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap[grammarType][key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap[grammarType][key] = grammar;\n }\n }\n } else {\n this._grammars.customized.push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap.customized[key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap.customized[key] = grammar;\n }\n }\n }\n this._size += 1;\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType] = this._grammars[grammarType].filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap[grammarType][key] === grammar) {\n delete this._grammarMap[grammarType][key];\n }\n } else {\n this._grammars.customized = this._grammars.customized.filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap.customized[key] === grammar) {\n delete this._grammarMap.customized[key];\n }\n }\n this._size -= 1;\n return this;\n }\n\n size() {\n return this._size;\n }\n\n getSignal<T>(key: string): ISignal<T> | null {\n return (this._grammarMap.signal[key] as ISignal<T>) ?? null;\n }\n getData(key: string): IData | null {\n return (this._grammarMap.data[key] as IData) ?? null;\n }\n getScale(key: string): IScale | null {\n return (this._grammarMap.scale[key] as IScale) ?? null;\n }\n getCoordinate(key: string): ICoordinate | null {\n return (this._grammarMap.coordinate[key] as ICoordinate) ?? null;\n }\n getMark(key: string): IMark | null {\n return (this._grammarMap.mark[key] as IMark) ?? null;\n }\n getCustomized(key: string): IGrammarBase | null {\n return this._grammarMap.customized[key] ?? null;\n }\n getGrammar(key: string): IGrammarBase | null {\n if (this._grammarMap.data[key]) {\n return this._grammarMap.data[key];\n } else if (this._grammarMap.signal[key]) {\n return this._grammarMap.signal[key];\n } else if (this._grammarMap.scale[key]) {\n return this._grammarMap.scale[key];\n } else if (this._grammarMap.coordinate[key]) {\n return this._grammarMap.coordinate[key];\n } else if (this._grammarMap.mark[key]) {\n return this._grammarMap.mark[key];\n } else if (this._grammarMap.customized[key]) {\n return this._grammarMap.customized[key];\n }\n return null;\n }\n\n getAllSignals(): ISignal<any>[] {\n return this._grammars.signal as ISignal<any>[];\n }\n getAllData(): IData[] {\n return this._grammars.data as IData[];\n }\n getAllScales(): IScale[] {\n return this._grammars.scale as IScale[];\n }\n getAllCoordinates(): ICoordinate[] {\n return this._grammars.coordinate as ICoordinate[];\n }\n getAllMarks(): IMark[] {\n return this._grammars.mark as IMark[];\n }\n getAllCustomized(): IGrammarBase[] {\n return this._grammars.customized;\n }\n\n traverse(func: (grammar: IGrammarBase) => boolean | void) {\n Object.values(this._grammars ?? {}).forEach(grammars =>\n (grammars ?? []).forEach(grammar => {\n // stop traversing when func returns true\n if (func.call(null, grammar)) {\n return;\n }\n })\n );\n }\n\n find(func: (grammar: IGrammarBase) => boolean) {\n let targetGrammar: IGrammarBase = null;\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammar = grammar;\n return true;\n }\n return false;\n });\n return targetGrammar;\n }\n\n filter(func: (grammar: IGrammarBase) => boolean) {\n const targetGrammars: IGrammarBase[] = [];\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammars.push(grammar);\n }\n });\n return targetGrammars;\n }\n\n clear() {\n this._size = 0;\n this._grammars = { signal: [], data: [], scale: [], coordinate: [], mark: [], customized: [] };\n this._grammarMap = { signal: {}, data: {}, scale: {}, coordinate: {}, mark: {}, customized: {} };\n }\n\n release() {\n this._size = 0;\n this._grammars = null;\n this._grammarMap = null;\n }\n}\n\nexport class RecordedTreeGrammars extends RecordedGrammars implements IRecordedTreeGrammars {\n private _markNodes: IMarkTreeNode[] = [];\n\n record(grammar: IGrammarBase) {\n super.record(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode: IMarkTreeNode = {\n mark: mark,\n parent: null,\n children: []\n };\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children.push(currentNode);\n currentNode.parent = node;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children.push(node);\n node.parent = currentNode;\n }\n });\n this._markNodes.push(currentNode);\n }\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n super.unrecord(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode = this._markNodes.find(node => node.mark === mark);\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children = node.children.filter(n => n !== currentNode);\n currentNode.parent = null;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children = currentNode.children.filter(n => n !== node);\n node.parent = null;\n }\n });\n this._markNodes = this._markNodes.filter(n => n !== currentNode);\n }\n return this;\n }\n\n getAllMarkNodes() {\n return this._markNodes;\n }\n\n clear() {\n super.clear();\n this._markNodes = [];\n }\n\n release() {\n super.release();\n this._markNodes = null;\n }\n}\n\nexport const releaseUpMarkNode = (node: IMarkTreeNode) => {\n // if (node.mark.get)\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/view/grammar-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAcnD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,OAAO,gBAAgB;IAsB3B,YACE,MAAoD,EACpD,qBAAoE;QArB9D,cAAS,GAA8D;YAC7E,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QAEM,gBAAW,GAA4E;YAC7F,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,EAAE;YACR,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;YACd,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;SACf,CAAC;QACM,UAAK,GAAW,CAAC,CAAC;QAMxB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACtE,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,OAAqB;;QAC1B,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACxC,MAAM,GAAG,GAAG,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,IAAI,CAAC,QAAQ,KAAK,eAAe,CAAC,KAAK,IAAI,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;oBACzF,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;oBACpE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;iBACpB;YACH,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC;SAClE;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAC;QACd,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAmB,EAAE,EAAE;AAEzD,CAAC,CAAC","file":"grammar-record.js","sourcesContent":["import { isNil, isString } from '@visactor/vutils';\nimport type {\n BuiltInGrammarType,\n ICoordinate,\n IData,\n IGrammarBase,\n IMark,\n IScale,\n ISignal,\n IRecordedGrammars,\n IGroupMark,\n IMarkTreeNode,\n IRecordedTreeGrammars\n} from '../types';\nimport { GrammarMarkType } from '../graph/enums';\n\nexport class RecordedGrammars implements IRecordedGrammars {\n private _warning: (key: string, grammar: IGrammarBase) => void;\n private _mapKey: (grammar: IGrammarBase) => string;\n private _grammars: Record<BuiltInGrammarType | 'customized', IGrammarBase[]> = {\n signal: [],\n data: [],\n scale: [],\n coordinate: [],\n mark: [],\n customized: []\n };\n // map key might not be unique\n private _grammarMap: Record<BuiltInGrammarType | 'customized', Record<string, IGrammarBase>> = {\n signal: {},\n data: {},\n scale: {},\n coordinate: {},\n mark: {},\n customized: {}\n };\n private _size: number = 0;\n\n constructor(\n mapKey: string | ((grammar: IGrammarBase) => string),\n warningWhenDuplicated?: (key: string, grammar: IGrammarBase) => void\n ) {\n this._mapKey = isString(mapKey) ? grammar => grammar[mapKey] : mapKey;\n this._warning = warningWhenDuplicated;\n }\n\n record(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType].push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap[grammarType][key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap[grammarType][key] = grammar;\n }\n }\n } else {\n this._grammars.customized.push(grammar);\n if (!isNil(key)) {\n // ignore grammar if key is duplicated\n if (this._grammarMap.customized[key]) {\n this._warning?.(key, grammar);\n } else {\n this._grammarMap.customized[key] = grammar;\n }\n }\n }\n this._size += 1;\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n const grammarType = grammar.grammarType;\n const key = this._mapKey(grammar);\n if (this._grammarMap[grammarType]) {\n this._grammars[grammarType] = this._grammars[grammarType].filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap[grammarType][key] === grammar) {\n delete this._grammarMap[grammarType][key];\n }\n } else {\n this._grammars.customized = this._grammars.customized.filter(\n (storedGrammar: IGrammarBase) => storedGrammar !== grammar\n );\n if (!isNil(key) && this._grammarMap.customized[key] === grammar) {\n delete this._grammarMap.customized[key];\n }\n }\n this._size -= 1;\n return this;\n }\n\n size() {\n return this._size;\n }\n\n getSignal<T>(key: string): ISignal<T> | null {\n return (this._grammarMap.signal[key] as ISignal<T>) ?? null;\n }\n getData(key: string): IData | null {\n return (this._grammarMap.data[key] as IData) ?? null;\n }\n getScale(key: string): IScale | null {\n return (this._grammarMap.scale[key] as IScale) ?? null;\n }\n getCoordinate(key: string): ICoordinate | null {\n return (this._grammarMap.coordinate[key] as ICoordinate) ?? null;\n }\n getMark(key: string): IMark | null {\n return (this._grammarMap.mark[key] as IMark) ?? null;\n }\n getCustomized(key: string): IGrammarBase | null {\n return this._grammarMap.customized[key] ?? null;\n }\n getGrammar(key: string): IGrammarBase | null {\n if (this._grammarMap.data[key]) {\n return this._grammarMap.data[key];\n } else if (this._grammarMap.signal[key]) {\n return this._grammarMap.signal[key];\n } else if (this._grammarMap.scale[key]) {\n return this._grammarMap.scale[key];\n } else if (this._grammarMap.coordinate[key]) {\n return this._grammarMap.coordinate[key];\n } else if (this._grammarMap.mark[key]) {\n return this._grammarMap.mark[key];\n } else if (this._grammarMap.customized[key]) {\n return this._grammarMap.customized[key];\n }\n return null;\n }\n\n getAllSignals(): ISignal<any>[] {\n return this._grammars.signal as ISignal<any>[];\n }\n getAllData(): IData[] {\n return this._grammars.data as IData[];\n }\n getAllScales(): IScale[] {\n return this._grammars.scale as IScale[];\n }\n getAllCoordinates(): ICoordinate[] {\n return this._grammars.coordinate as ICoordinate[];\n }\n getAllMarks(): IMark[] {\n return this._grammars.mark as IMark[];\n }\n getAllCustomized(): IGrammarBase[] {\n return this._grammars.customized;\n }\n\n traverse(func: (grammar: IGrammarBase) => boolean | void) {\n Object.values(this._grammars ?? {}).forEach(grammars =>\n (grammars ?? []).forEach(grammar => {\n // stop traversing when func returns true\n if (func.call(null, grammar)) {\n return;\n }\n })\n );\n }\n\n find(func: (grammar: IGrammarBase) => boolean) {\n let targetGrammar: IGrammarBase = null;\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammar = grammar;\n return true;\n }\n return false;\n });\n return targetGrammar;\n }\n\n filter(func: (grammar: IGrammarBase) => boolean) {\n const targetGrammars: IGrammarBase[] = [];\n this.traverse(grammar => {\n if (func.call(null, grammar) === true) {\n targetGrammars.push(grammar);\n }\n });\n return targetGrammars;\n }\n\n clear() {\n this._size = 0;\n this._grammars = { signal: [], data: [], scale: [], coordinate: [], mark: [], customized: [] };\n this._grammarMap = { signal: {}, data: {}, scale: {}, coordinate: {}, mark: {}, customized: {} };\n }\n\n release() {\n this._size = 0;\n this._grammars = null;\n this._grammarMap = null;\n }\n}\n\nexport class RecordedTreeGrammars extends RecordedGrammars implements IRecordedTreeGrammars {\n private _markNodes: IMarkTreeNode[] = [];\n\n record(grammar: IGrammarBase) {\n super.record(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode: IMarkTreeNode = {\n mark: mark,\n parent: null,\n children: []\n };\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && (targetMark as IGroupMark).includesChild(mark, false)) {\n node.children.push(currentNode);\n currentNode.parent = node;\n } else if (mark.markType === GrammarMarkType.group && (mark as IGroupMark).includesChild(targetMark, false)) {\n currentNode.children.push(node);\n node.parent = currentNode;\n }\n });\n this._markNodes.push(currentNode);\n }\n return this;\n }\n\n unrecord(grammar: IGrammarBase) {\n super.unrecord(grammar);\n if (grammar.grammarType === 'mark') {\n const mark = grammar as IMark;\n const currentNode = this._markNodes.find(node => node.mark === mark);\n this._markNodes.forEach(node => {\n const targetMark = node.mark;\n if (targetMark.markType === GrammarMarkType.group && node.children.includes(currentNode)) {\n node.children = node.children.filter(n => n !== currentNode);\n currentNode.parent = null;\n } else if (mark.markType === GrammarMarkType.group && currentNode.children.includes(node)) {\n currentNode.children = currentNode.children.filter(n => n !== node);\n node.parent = null;\n }\n });\n this._markNodes = this._markNodes.filter(n => n !== currentNode);\n }\n return this;\n }\n\n getAllMarkNodes() {\n return this._markNodes;\n }\n\n clear() {\n super.clear();\n this._markNodes = [];\n }\n\n release() {\n super.release();\n this._markNodes = null;\n }\n}\n\nexport const releaseUpMarkNode = (node: IMarkTreeNode) => {\n // if (node.mark.get)\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vgrammar-core",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.16-alpha.0",
|
|
4
4
|
"description": "VGrammar is a visual grammar library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"grammar",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@visactor/vutils": "~0.18.10",
|
|
28
28
|
"@visactor/vdataset": "~0.18.10",
|
|
29
|
-
"@visactor/vgrammar-coordinate": "0.13.
|
|
30
|
-
"@visactor/vgrammar-util": "0.13.
|
|
29
|
+
"@visactor/vgrammar-coordinate": "0.13.16-alpha.0",
|
|
30
|
+
"@visactor/vgrammar-util": "0.13.16-alpha.0",
|
|
31
31
|
"@visactor/vscale": "~0.18.10",
|
|
32
|
-
"@visactor/vrender-core": "0.19.
|
|
33
|
-
"@visactor/vrender-kits": "0.19.
|
|
34
|
-
"@visactor/vrender-components": "0.19.
|
|
32
|
+
"@visactor/vrender-core": "0.19.18",
|
|
33
|
+
"@visactor/vrender-kits": "0.19.18",
|
|
34
|
+
"@visactor/vrender-components": "0.19.18"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rushstack/eslint-patch": "~1.1.4",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"typescript": "4.9.5",
|
|
47
47
|
"@internal/bundler": "0.0.1",
|
|
48
48
|
"@internal/eslint-config": "0.0.1",
|
|
49
|
-
"@internal/
|
|
50
|
-
"@internal/
|
|
49
|
+
"@internal/jest-config": "0.0.1",
|
|
50
|
+
"@internal/ts-config": "0.0.1"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public",
|