@eclipse-glsp/client 2.3.0-next.391 → 2.3.0-next.392

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 (53) hide show
  1. package/lib/base/default.module.d.ts.map +1 -1
  2. package/lib/base/default.module.js +4 -2
  3. package/lib/base/default.module.js.map +1 -1
  4. package/lib/base/feedback/feedback-action-dispatcher.d.ts +18 -5
  5. package/lib/base/feedback/feedback-action-dispatcher.d.ts.map +1 -1
  6. package/lib/base/feedback/feedback-action-dispatcher.js +113 -10
  7. package/lib/base/feedback/feedback-action-dispatcher.js.map +1 -1
  8. package/lib/base/feedback/feedback-emitter.d.ts +2 -2
  9. package/lib/base/feedback/feedback-emitter.d.ts.map +1 -1
  10. package/lib/base/feedback/feedback-emitter.js +1 -2
  11. package/lib/base/feedback/feedback-emitter.js.map +1 -1
  12. package/lib/features/context-menu/delete-element-context-menu.d.ts +19 -2
  13. package/lib/features/context-menu/delete-element-context-menu.d.ts.map +1 -1
  14. package/lib/features/context-menu/delete-element-context-menu.js +11 -7
  15. package/lib/features/context-menu/delete-element-context-menu.js.map +1 -1
  16. package/lib/features/helper-lines/helper-line-manager.d.ts +78 -2
  17. package/lib/features/helper-lines/helper-line-manager.d.ts.map +1 -1
  18. package/lib/features/helper-lines/helper-line-manager.js +194 -0
  19. package/lib/features/helper-lines/helper-line-manager.js.map +1 -1
  20. package/lib/features/helper-lines/helper-line-module.js +2 -2
  21. package/lib/features/helper-lines/helper-line-module.js.map +1 -1
  22. package/lib/features/navigation/navigation-action-handler.d.ts +5 -1
  23. package/lib/features/navigation/navigation-action-handler.d.ts.map +1 -1
  24. package/lib/features/navigation/navigation-action-handler.js +11 -4
  25. package/lib/features/navigation/navigation-action-handler.js.map +1 -1
  26. package/lib/features/tools/base-tools.d.ts +2 -2
  27. package/lib/features/tools/base-tools.d.ts.map +1 -1
  28. package/lib/features/tools/base-tools.js.map +1 -1
  29. package/lib/index.d.ts +0 -2
  30. package/lib/index.d.ts.map +1 -1
  31. package/lib/index.js +0 -2
  32. package/lib/index.js.map +1 -1
  33. package/package.json +3 -3
  34. package/src/base/default.module.ts +3 -1
  35. package/src/base/feedback/feedback-action-dispatcher.ts +114 -11
  36. package/src/base/feedback/feedback-emitter.ts +2 -2
  37. package/src/features/context-menu/delete-element-context-menu.ts +11 -7
  38. package/src/features/helper-lines/helper-line-manager.ts +234 -2
  39. package/src/features/helper-lines/helper-line-module.ts +1 -1
  40. package/src/features/hints/type-hint-provider.spec.ts +1 -1
  41. package/src/features/navigation/navigation-action-handler.ts +9 -5
  42. package/src/features/tools/base-tools.ts +2 -2
  43. package/src/index.ts +0 -2
  44. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts +0 -36
  45. package/lib/base/feedback/feedback-action-dispatcher-default.d.ts.map +0 -1
  46. package/lib/base/feedback/feedback-action-dispatcher-default.js +0 -133
  47. package/lib/base/feedback/feedback-action-dispatcher-default.js.map +0 -1
  48. package/lib/features/helper-lines/helper-line-manager-default.d.ts +0 -95
  49. package/lib/features/helper-lines/helper-line-manager-default.d.ts.map +0 -1
  50. package/lib/features/helper-lines/helper-line-manager-default.js +0 -197
  51. package/lib/features/helper-lines/helper-line-manager-default.js.map +0 -1
  52. package/src/base/feedback/feedback-action-dispatcher-default.ts +0 -130
  53. package/src/features/helper-lines/helper-line-manager-default.ts +0 -250
@@ -1,133 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.FeedbackActionDispatcher = void 0;
13
- /********************************************************************************
14
- * Copyright (c) 2019-2024 EclipseSource and others.
15
- *
16
- * This program and the accompanying materials are made available under the
17
- * terms of the Eclipse Public License v. 2.0 which is available at
18
- * http://www.eclipse.org/legal/epl-2.0.
19
- *
20
- * This Source Code may also be made available under the following Secondary
21
- * Licenses when the conditions for such availability set forth in the Eclipse
22
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
- * with the GNU Classpath Exception which is available at
24
- * https://www.gnu.org/software/classpath/license.html.
25
- *
26
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
- ********************************************************************************/
28
- const sprotty_1 = require("@eclipse-glsp/sprotty");
29
- const inversify_1 = require("inversify");
30
- const feedback_action_dispatcher_1 = require("./feedback-action-dispatcher");
31
- const feedback_command_1 = require("./feedback-command");
32
- const feedback_emitter_1 = require("./feedback-emitter");
33
- let FeedbackActionDispatcher = class FeedbackActionDispatcher {
34
- constructor() {
35
- this.registeredFeedback = new Map();
36
- this.isDisposed = false;
37
- }
38
- registerFeedback(feedbackEmitter, feedbackActions, cleanupActions) {
39
- if (feedbackEmitter instanceof sprotty_1.GModelElement) {
40
- this.logger.log(this,
41
- // eslint-disable-next-line max-len
42
- 'GModelElements as feedback emitters are discouraged, as they usually change between model updates and are considered unstable.');
43
- }
44
- if (feedbackActions.length > 0) {
45
- this.registeredFeedback.set(feedbackEmitter, feedbackActions);
46
- this.dispatchFeedback(feedbackActions, feedbackEmitter);
47
- }
48
- return sprotty_1.Disposable.create(() => this.deregisterFeedback(feedbackEmitter, cleanupActions));
49
- }
50
- deregisterFeedback(feedbackEmitter, cleanupActions) {
51
- this.registeredFeedback.delete(feedbackEmitter);
52
- const actions = feedback_action_dispatcher_1.MaybeActions.asArray(cleanupActions);
53
- if (actions.length > 0) {
54
- this.dispatchFeedback(actions, feedbackEmitter);
55
- }
56
- }
57
- getRegisteredFeedback() {
58
- const result = [];
59
- this.registeredFeedback.forEach(actions => result.push(...actions));
60
- return result;
61
- }
62
- getRegisteredFeedbackEmitters(action) {
63
- const result = [];
64
- this.registeredFeedback.forEach((actions, emitter) => {
65
- if (actions.includes(action)) {
66
- result.push(emitter);
67
- }
68
- });
69
- return result;
70
- }
71
- getFeedbackCommands() {
72
- return this.getRegisteredFeedback()
73
- .flatMap(action => this.actionToCommands(action))
74
- .sort((left, right) => (0, feedback_command_1.getFeedbackRank)(left) - (0, feedback_command_1.getFeedbackRank)(right));
75
- }
76
- async applyFeedbackCommands(context) {
77
- var _a;
78
- const feedbackCommands = (_a = this.getFeedbackCommands()) !== null && _a !== void 0 ? _a : [];
79
- if ((feedbackCommands === null || feedbackCommands === void 0 ? void 0 : feedbackCommands.length) > 0) {
80
- const results = feedbackCommands.map(command => command.execute(context));
81
- await Promise.all(results);
82
- }
83
- }
84
- actionToCommands(action) {
85
- var _a;
86
- return ((_a = this.actionHandlerRegistry
87
- .get(action.kind)
88
- .filter((0, sprotty_1.toTypeGuard)(sprotty_1.CommandActionHandler))
89
- .map(handler => handler.handle(action))) !== null && _a !== void 0 ? _a : []);
90
- }
91
- createEmitter() {
92
- return new feedback_emitter_1.FeedbackEmitter(this);
93
- }
94
- async dispatchFeedback(actions, feedbackEmitter) {
95
- try {
96
- if (this.isDisposed) {
97
- return;
98
- }
99
- await this.actionDispatcher.dispatchAll(actions);
100
- this.logger.info(this, `Dispatched feedback actions for ${feedbackEmitter}`);
101
- }
102
- catch (reason) {
103
- this.logger.error(this, 'Failed to dispatch feedback actions', reason);
104
- }
105
- }
106
- dispose() {
107
- this.registeredFeedback.clear();
108
- this.isDisposed = true;
109
- }
110
- };
111
- exports.FeedbackActionDispatcher = FeedbackActionDispatcher;
112
- __decorate([
113
- (0, inversify_1.inject)(sprotty_1.TYPES.IActionDispatcher),
114
- __metadata("design:type", Object)
115
- ], FeedbackActionDispatcher.prototype, "actionDispatcher", void 0);
116
- __decorate([
117
- (0, inversify_1.inject)(sprotty_1.TYPES.ILogger),
118
- __metadata("design:type", Object)
119
- ], FeedbackActionDispatcher.prototype, "logger", void 0);
120
- __decorate([
121
- (0, inversify_1.inject)(sprotty_1.ActionHandlerRegistry),
122
- __metadata("design:type", sprotty_1.ActionHandlerRegistry)
123
- ], FeedbackActionDispatcher.prototype, "actionHandlerRegistry", void 0);
124
- __decorate([
125
- (0, inversify_1.preDestroy)(),
126
- __metadata("design:type", Function),
127
- __metadata("design:paramtypes", []),
128
- __metadata("design:returntype", void 0)
129
- ], FeedbackActionDispatcher.prototype, "dispose", null);
130
- exports.FeedbackActionDispatcher = FeedbackActionDispatcher = __decorate([
131
- (0, inversify_1.injectable)()
132
- ], FeedbackActionDispatcher);
133
- //# sourceMappingURL=feedback-action-dispatcher-default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"feedback-action-dispatcher-default.js","sourceRoot":"","sources":["../../../src/base/feedback/feedback-action-dispatcher-default.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAa+B;AAC/B,yCAA2D;AAC3D,6EAAyG;AACzG,yDAAqD;AACrD,yDAAqD;AAG9C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QACO,uBAAkB,GAAoC,IAAI,GAAG,EAAE,CAAC;QAQhE,eAAU,GAAG,KAAK,CAAC;IAqFjC,CAAC;IAnFG,gBAAgB,CAAC,eAAiC,EAAE,eAAyB,EAAE,cAA6B;QACxG,IAAI,eAAe,YAAY,uBAAa,EAAE,CAAC;YAC3C,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,IAAI;YACJ,mCAAmC;YACnC,gIAAgI,CACnI,CAAC;QACN,CAAC;QACD,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,e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MAAM,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,qCAAqC,EAAE,MAAM,CAAC,CAAC;QAC3E,CAAC;IACL,CAAC;IAGD,OAAO;QACH,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IAC3B,CAAC;CACJ,CAAA;AA9FY,4DAAwB;AAGU;IAA1C,IAAA,kBAAM,EAAC,eAAK,CAAC,iBAAiB,CAAC;;kEAA+C;AAE9C;IAAhC,IAAA,kBAAM,EAAC,eAAK,CAAC,OAAO,CAAC;;wDAA2B;AAER;IAAxC,IAAA,kBAAM,EAAC,+BAAqB,CAAC;8BAAkC,+BAAqB;uEAAC;AAmFtF;IADC,IAAA,sBAAU,GAAE;;;;uDAIZ;mCA7FQ,wBAAwB;IADpC,IAAA,sBAAU,GAAE;GACA,wBAAwB,CA8FpC"}
@@ -1,95 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2023-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import { Action, GModelElement, GModelRoot, IActionHandler, MoveAction, Point, SetBoundsAction, Vector } from '@eclipse-glsp/sprotty';
17
- import { IFeedbackActionDispatcher } from '../../base/feedback/feedback-action-dispatcher';
18
- import { FeedbackEmitter } from '../../base/feedback/feedback-emitter';
19
- import { ISelectionListener, SelectionService } from '../../base/selection-service';
20
- import { SetBoundsFeedbackAction } from '../bounds/set-bounds-feedback-command';
21
- import { Grid } from '../grid/grid';
22
- import { MoveFinishedEventAction, MoveInitializedEventAction } from '../tools/change-bounds/change-bounds-tool-feedback';
23
- import { AlignmentElementFilter, DrawHelperLinesFeedbackAction, ViewportLineType } from './helper-line-feedback';
24
- import { IHelperLineManager } from './helper-line-manager';
25
- import { Direction, HelperLine, HelperLineType } from './model';
26
- export interface IHelperLineOptions {
27
- /**
28
- * A list of helper line types that should be rendered when elements are aligned.
29
- * Defaults to all possible alignments.
30
- */
31
- elementLines?: HelperLineType[];
32
- /**
33
- * A list of helper line types that should be rendered when an element is aligned with the viewport.
34
- * Defaults to middle and center alignment.
35
- */
36
- viewportLines?: ViewportLineType[];
37
- /**
38
- * The minimum difference between two coordinates
39
- * Defaults to 1 or zero (perfect match) if the optional grid module is loaded.
40
- */
41
- alignmentEpsilon?: number;
42
- /**
43
- * A filter that is applied to determine on which elements the alignment calculation is performed.
44
- * By default all top-level bounds-aware, non-routable elements that are visible on the canvas are considered.
45
- */
46
- alignmentElementFilter?: AlignmentElementFilter;
47
- /**
48
- * The minimum move delta that is necessary for an element to break through a helper line.
49
- * Defaults to { x: 1, y: 1 } whereas the x represents the horizontal distance and y represents the vertical distance.
50
- * If the optional grid module is loaded, defaults to twice the grid size, i.e., two grid moves to break through a helper line.
51
- */
52
- minimumMoveDelta?: Point;
53
- /**
54
- * Produces debug output.
55
- * Defaults to false.
56
- */
57
- debug?: boolean;
58
- }
59
- export declare const DEFAULT_MOVE_DELTA: {
60
- x: number;
61
- y: number;
62
- };
63
- export declare const DEFAULT_HELPER_LINE_OPTIONS: Required<IHelperLineOptions>;
64
- export declare class HelperLineManager implements IActionHandler, ISelectionListener, IHelperLineManager {
65
- protected feedbackDispatcher: IFeedbackActionDispatcher;
66
- protected selectionService: SelectionService;
67
- protected userOptions?: IHelperLineOptions;
68
- protected grid?: Grid;
69
- protected options: Required<IHelperLineOptions>;
70
- protected feedback: FeedbackEmitter;
71
- protected init(): void;
72
- handle(action: Action): void;
73
- protected handleMoveInitializedAction(_action: MoveInitializedEventAction): void;
74
- protected handleMoveFinishedAction(_action: MoveFinishedEventAction): void;
75
- protected handleMoveAction(action: MoveAction): void;
76
- protected submitHelperLineFeedback(elementIds?: string[]): void;
77
- protected createHelperLineFeedback(elementIds: string[]): DrawHelperLinesFeedbackAction;
78
- protected handleSetBoundsAction(action: SetBoundsAction | SetBoundsFeedbackAction): void;
79
- selectionChanged(root: Readonly<GModelRoot>, selectedElements: string[], deselectedElements?: string[] | undefined): void;
80
- getMinimumMoveDelta(element: GModelElement, isSnap: boolean, direction: Direction): number;
81
- getMinimumMoveVector(element: GModelElement, isSnap: boolean, move: Direction[]): Vector | undefined;
82
- protected getHelperLineState(element: GModelElement): HelperLineState;
83
- }
84
- export interface HelperLineState {
85
- helperLines: HelperLine[];
86
- types: {
87
- left: boolean;
88
- right: boolean;
89
- top: boolean;
90
- bottom: boolean;
91
- center: boolean;
92
- middle: boolean;
93
- };
94
- }
95
- //# sourceMappingURL=helper-line-manager-default.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helper-line-manager-default.d.ts","sourceRoot":"","sources":["../../../src/features/helper-lines/helper-line-manager-default.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EACH,MAAM,EACN,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,EACV,KAAK,EACL,eAAe,EAEf,MAAM,EAET,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gDAAgD,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,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,wBAAwB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAI1E,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAQpD,SAAS,CAAC,wBAAwB,CAAC,UAAU,GAAE,MAAM,EAAkD,GAAG,IAAI;IAK9G,SAAS,CAAC,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,6BAA6B;IAIvF,SAAS,CAAC,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,uBAAuB,GAAG,IAAI;IAIxF,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,IAAI;IAIzH,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM;IAQ1F,oBAAoB,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,MAAM,GAAG,SAAS;IA6BpG,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,eAAe;CAsCxE;AAED,MAAM,WAAW,eAAe;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,KAAK,EAAE;QACH,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,EAAE,OAAO,CAAC;QACb,MAAM,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;KACnB,CAAC;CACL"}
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.HelperLineManager = exports.DEFAULT_HELPER_LINE_OPTIONS = exports.DEFAULT_MOVE_DELTA = void 0;
13
- /********************************************************************************
14
- * Copyright (c) 2023-2024 EclipseSource and others.
15
- *
16
- * This program and the accompanying materials are made available under the
17
- * terms of the Eclipse Public License v. 2.0 which is available at
18
- * http://www.eclipse.org/legal/epl-2.0.
19
- *
20
- * This Source Code may also be made available under the following Secondary
21
- * Licenses when the conditions for such availability set forth in the Eclipse
22
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
- * with the GNU Classpath Exception which is available at
24
- * https://www.gnu.org/software/classpath/license.html.
25
- *
26
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
- ********************************************************************************/
28
- const sprotty_1 = require("@eclipse-glsp/sprotty");
29
- const inversify_1 = require("inversify");
30
- const selection_service_1 = require("../../base/selection-service");
31
- const set_bounds_feedback_command_1 = require("../bounds/set-bounds-feedback-command");
32
- const model_1 = require("../change-bounds/model");
33
- const change_bounds_tool_feedback_1 = require("../tools/change-bounds/change-bounds-tool-feedback");
34
- const helper_line_feedback_1 = require("./helper-line-feedback");
35
- const model_2 = require("./model");
36
- exports.DEFAULT_MOVE_DELTA = { x: 1, y: 1 };
37
- exports.DEFAULT_HELPER_LINE_OPTIONS = {
38
- elementLines: helper_line_feedback_1.DEFAULT_ELEMENT_LINES,
39
- viewportLines: helper_line_feedback_1.DEFAULT_VIEWPORT_LINES,
40
- alignmentEpsilon: helper_line_feedback_1.DEFAULT_EPSILON,
41
- alignmentElementFilter: helper_line_feedback_1.DEFAULT_ALIGNABLE_ELEMENT_FILTER,
42
- minimumMoveDelta: exports.DEFAULT_MOVE_DELTA,
43
- debug: helper_line_feedback_1.DEFAULT_DEBUG
44
- };
45
- let HelperLineManager = class HelperLineManager {
46
- init() {
47
- this.feedback = this.feedbackDispatcher.createEmitter();
48
- const dynamicOptions = {};
49
- if (this.grid) {
50
- dynamicOptions.alignmentEpsilon = 0;
51
- dynamicOptions.minimumMoveDelta = sprotty_1.Point.multiplyScalar(this.grid, 2);
52
- }
53
- this.options = { ...exports.DEFAULT_HELPER_LINE_OPTIONS, ...dynamicOptions, ...this.userOptions };
54
- this.selectionService.addListener(this);
55
- }
56
- handle(action) {
57
- if (change_bounds_tool_feedback_1.MoveInitializedEventAction.is(action)) {
58
- this.handleMoveInitializedAction(action);
59
- }
60
- else if (sprotty_1.MoveAction.is(action)) {
61
- this.handleMoveAction(action);
62
- }
63
- else if (change_bounds_tool_feedback_1.MoveFinishedEventAction.is(action)) {
64
- this.handleMoveFinishedAction(action);
65
- }
66
- else if (sprotty_1.SetBoundsAction.is(action) || set_bounds_feedback_command_1.SetBoundsFeedbackAction.is(action)) {
67
- this.handleSetBoundsAction(action);
68
- }
69
- }
70
- handleMoveInitializedAction(_action) {
71
- this.submitHelperLineFeedback();
72
- }
73
- handleMoveFinishedAction(_action) {
74
- this.feedback.dispose();
75
- }
76
- handleMoveAction(action) {
77
- if (!action.finished) {
78
- this.submitHelperLineFeedback(action.moves.map(move => move.elementId));
79
- }
80
- else {
81
- this.feedback.dispose();
82
- }
83
- }
84
- submitHelperLineFeedback(elementIds = this.selectionService.getSelectedElementIDs()) {
85
- const feedback = this.createHelperLineFeedback(elementIds);
86
- this.feedback.add(feedback, [helper_line_feedback_1.RemoveHelperLinesFeedbackAction.create()]).submit();
87
- }
88
- createHelperLineFeedback(elementIds) {
89
- return helper_line_feedback_1.DrawHelperLinesFeedbackAction.create({ elementIds, ...this.options });
90
- }
91
- handleSetBoundsAction(action) {
92
- this.submitHelperLineFeedback(action.bounds.map(bound => bound.elementId));
93
- }
94
- selectionChanged(root, selectedElements, deselectedElements) {
95
- this.feedback.dispose();
96
- }
97
- getMinimumMoveDelta(element, isSnap, direction) {
98
- if (!isSnap) {
99
- return 0;
100
- }
101
- const minimumMoveDelta = this.options.minimumMoveDelta;
102
- return direction === model_2.Direction.Left || direction === model_2.Direction.Right ? minimumMoveDelta.x : minimumMoveDelta.y;
103
- }
104
- getMinimumMoveVector(element, isSnap, move) {
105
- if (!isSnap) {
106
- return undefined;
107
- }
108
- const state = this.getHelperLineState(element);
109
- if (state.helperLines.length === 0) {
110
- return undefined;
111
- }
112
- const minimum = { ...sprotty_1.Vector.ZERO };
113
- const resize = element instanceof model_1.GResizeHandle
114
- ? model_1.ResizeHandleLocation.direction(element.location)
115
- : [model_2.Direction.Left, model_2.Direction.Right, model_2.Direction.Up, model_2.Direction.Down];
116
- if ((state.types.left || state.types.center) && move.includes(model_2.Direction.Left) && resize.includes(model_2.Direction.Left)) {
117
- minimum.x = this.getMinimumMoveDelta(element, isSnap, model_2.Direction.Left);
118
- }
119
- else if ((state.types.right || state.types.center) && move.includes(model_2.Direction.Right) && resize.includes(model_2.Direction.Right)) {
120
- minimum.x = this.getMinimumMoveDelta(element, isSnap, model_2.Direction.Right);
121
- }
122
- if ((state.types.top || state.types.middle) && move.includes(model_2.Direction.Up) && resize.includes(model_2.Direction.Up)) {
123
- minimum.y = this.getMinimumMoveDelta(element, isSnap, model_2.Direction.Up);
124
- }
125
- else if ((state.types.bottom || state.types.middle) && move.includes(model_2.Direction.Down) && resize.includes(model_2.Direction.Down)) {
126
- minimum.y = this.getMinimumMoveDelta(element, isSnap, model_2.Direction.Down);
127
- }
128
- return sprotty_1.Vector.isZero(minimum) ? undefined : minimum;
129
- }
130
- getHelperLineState(element) {
131
- const helperLines = element.root.children.filter(model_2.isHelperLine) || [];
132
- const types = {
133
- left: false,
134
- right: false,
135
- top: false,
136
- bottom: false,
137
- center: false,
138
- middle: false
139
- };
140
- for (const line of helperLines) {
141
- switch (line.lineType) {
142
- case model_2.HelperLineType.Left:
143
- case model_2.HelperLineType.LeftRight:
144
- types.left = true;
145
- break;
146
- case model_2.HelperLineType.Right:
147
- case model_2.HelperLineType.RightLeft:
148
- types.right = true;
149
- break;
150
- case model_2.HelperLineType.Top:
151
- case model_2.HelperLineType.TopBottom:
152
- types.top = true;
153
- break;
154
- case model_2.HelperLineType.Bottom:
155
- case model_2.HelperLineType.BottomTop:
156
- types.bottom = true;
157
- break;
158
- case model_2.HelperLineType.Center:
159
- types.center = true;
160
- break;
161
- case model_2.HelperLineType.Middle:
162
- types.middle = true;
163
- break;
164
- }
165
- }
166
- return { helperLines, types };
167
- }
168
- };
169
- exports.HelperLineManager = HelperLineManager;
170
- __decorate([
171
- (0, inversify_1.inject)(sprotty_1.TYPES.IFeedbackActionDispatcher),
172
- __metadata("design:type", Object)
173
- ], HelperLineManager.prototype, "feedbackDispatcher", void 0);
174
- __decorate([
175
- (0, inversify_1.inject)(selection_service_1.SelectionService),
176
- __metadata("design:type", selection_service_1.SelectionService)
177
- ], HelperLineManager.prototype, "selectionService", void 0);
178
- __decorate([
179
- (0, inversify_1.optional)(),
180
- (0, inversify_1.inject)(sprotty_1.TYPES.IHelperLineOptions),
181
- __metadata("design:type", Object)
182
- ], HelperLineManager.prototype, "userOptions", void 0);
183
- __decorate([
184
- (0, inversify_1.optional)(),
185
- (0, inversify_1.inject)(sprotty_1.TYPES.Grid),
186
- __metadata("design:type", Object)
187
- ], HelperLineManager.prototype, "grid", void 0);
188
- __decorate([
189
- (0, inversify_1.postConstruct)(),
190
- __metadata("design:type", Function),
191
- __metadata("design:paramtypes", []),
192
- __metadata("design:returntype", void 0)
193
- ], HelperLineManager.prototype, "init", null);
194
- exports.HelperLineManager = HelperLineManager = __decorate([
195
- (0, inversify_1.injectable)()
196
- ], HelperLineManager);
197
- //# sourceMappingURL=helper-line-manager-default.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"helper-line-manager-default.js","sourceRoot":"","sources":["../../../src/features/helper-lines/helper-line-manager-default.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,mDAW+B;AAC/B,yCAAwE;AAGxE,oEAAoF;AACpF,uFAAgF;AAChF,kDAA6E;AAE7E,oGAAyH;AACzH,iEAUgC;AAEhC,mCAA8E;AAqCjE,QAAA,kBAAkB,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEpC,QAAA,2BAA2B,GAAiC;IACrE,YAAY,EAAE,4CAAqB;IACnC,aAAa,EAAE,6CAAsB;IACrC,gBAAgB,EAAE,sCAAe;IACjC,sBAAsB,EAAE,uDAAgC;IACxD,gBAAgB,EAAE,0BAAkB;IACpC,KAAK,EAAE,oCAAa;CACvB,CAAC;AAGK,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAUhB,IAAI;QACV,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,CAAC;QACxD,MAAM,cAAc,GAAuB,EAAE,CAAC;QAC9C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,cAAc,CAAC,gBAAgB,GAAG,CAAC,CAAC;YACpC,cAAc,CAAC,gBAAgB,GAAG,eAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,mCAA2B,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1F,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,MAAc;QACjB,IAAI,wDAA0B,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,2BAA2B,CAA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C,SAAS;oBACzB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;oBACpB,MAAM;gBACV,KAAK,sBAAc,CAAC,MAAM;oBACtB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;oBACpB,MAAM;gBACV,KAAK,sBAAc,CAAC,MAAM;oBACtB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;oBACpB,MAAM;YACd,CAAC;QACL,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC;CACJ,CAAA;AA7IY,8CAAiB;AACyB;IAAlD,IAAA,kBAAM,EAAC,eAAK,CAAC,yBAAyB,CAAC;;6DAAyD;AAC7D;IAAnC,IAAA,kBAAM,EAAC,oCAAgB,CAAC;8BAA6B,oCAAgB;2DAAC;AACf;IAAvD,IAAA,oBAAQ,GAAE;IAAE,IAAA,kBAAM,EAAC,eAAK,CAAC,kBAAkB,CAAC;;sDAA4C;AAC/C;IAAzC,IAAA,oBAAQ,GAAE;IAAE,IAAA,kBAAM,EAAC,eAAK,CAAC,IAAI,CAAC;;+CAAuB;AAM5C;IADT,IAAA,yBAAa,GAAE;;;;6CAUf;4BAnBQ,iBAAiB;IAD7B,IAAA,sBAAU,GAAE;GACA,iBAAiB,CA6I7B"}
@@ -1,130 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (c) 2019-2024 EclipseSource and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import {
17
- Action,
18
- ActionHandlerRegistry,
19
- Command,
20
- CommandActionHandler,
21
- CommandExecutionContext,
22
- Disposable,
23
- GModelElement,
24
- IActionDispatcher,
25
- ICommand,
26
- ILogger,
27
- TYPES,
28
- toTypeGuard
29
- } from '@eclipse-glsp/sprotty';
30
- import { inject, injectable, preDestroy } from 'inversify';
31
- import { IFeedbackActionDispatcher, IFeedbackEmitter, MaybeActions } from './feedback-action-dispatcher';
32
- import { getFeedbackRank } from './feedback-command';
33
- import { FeedbackEmitter } from './feedback-emitter';
34
-
35
- @injectable()
36
- export class FeedbackActionDispatcher implements IFeedbackActionDispatcher, Disposable {
37
- protected registeredFeedback: Map<IFeedbackEmitter, Action[]> = new Map();
38
-
39
- @inject(TYPES.IActionDispatcher) protected actionDispatcher: IActionDispatcher;
40
-
41
- @inject(TYPES.ILogger) protected logger: ILogger;
42
-
43
- @inject(ActionHandlerRegistry) protected actionHandlerRegistry: ActionHandlerRegistry;
44
-
45
- protected isDisposed = false;
46
-
47
- registerFeedback(feedbackEmitter: IFeedbackEmitter, feedbackActions: Action[], cleanupActions?: MaybeActions): Disposable {
48
- if (feedbackEmitter instanceof GModelElement) {
49
- this.logger.log(
50
- this,
51
- // eslint-disable-next-line max-len
52
- 'GModelElements as feedback emitters are discouraged, as they usually change between model updates and are considered unstable.'
53
- );
54
- }
55
- if (feedbackActions.length > 0) {
56
- this.registeredFeedback.set(feedbackEmitter, feedbackActions);
57
- this.dispatchFeedback(feedbackActions, feedbackEmitter);
58
- }
59
- return Disposable.create(() => this.deregisterFeedback(feedbackEmitter, cleanupActions));
60
- }
61
-
62
- deregisterFeedback(feedbackEmitter: IFeedbackEmitter, cleanupActions?: MaybeActions): void {
63
- this.registeredFeedback.delete(feedbackEmitter);
64
- const actions = MaybeActions.asArray(cleanupActions);
65
- if (actions.length > 0) {
66
- this.dispatchFeedback(actions, feedbackEmitter);
67
- }
68
- }
69
-
70
- getRegisteredFeedback(): Action[] {
71
- const result: Action[] = [];
72
- this.registeredFeedback.forEach(actions => result.push(...actions));
73
- return result;
74
- }
75
-
76
- getRegisteredFeedbackEmitters(action: Action): IFeedbackEmitter[] {
77
- const result: IFeedbackEmitter[] = [];
78
- this.registeredFeedback.forEach((actions, emitter) => {
79
- if (actions.includes(action)) {
80
- result.push(emitter);
81
- }
82
- });
83
- return result;
84
- }
85
-
86
- getFeedbackCommands(): Command[] {
87
- return this.getRegisteredFeedback()
88
- .flatMap(action => this.actionToCommands(action))
89
- .sort((left, right) => getFeedbackRank(left) - getFeedbackRank(right));
90
- }
91
-
92
- async applyFeedbackCommands(context: CommandExecutionContext): Promise<void> {
93
- const feedbackCommands = this.getFeedbackCommands() ?? [];
94
- if (feedbackCommands?.length > 0) {
95
- const results = feedbackCommands.map(command => command.execute(context));
96
- await Promise.all(results);
97
- }
98
- }
99
-
100
- protected actionToCommands(action: Action): ICommand[] {
101
- return (
102
- this.actionHandlerRegistry
103
- .get(action.kind)
104
- .filter(toTypeGuard(CommandActionHandler))
105
- .map(handler => handler.handle(action)) ?? []
106
- );
107
- }
108
-
109
- createEmitter(): FeedbackEmitter {
110
- return new FeedbackEmitter(this);
111
- }
112
-
113
- protected async dispatchFeedback(actions: Action[], feedbackEmitter: IFeedbackEmitter): Promise<void> {
114
- try {
115
- if (this.isDisposed) {
116
- return;
117
- }
118
- await this.actionDispatcher.dispatchAll(actions);
119
- this.logger.info(this, `Dispatched feedback actions for ${feedbackEmitter}`);
120
- } catch (reason) {
121
- this.logger.error(this, 'Failed to dispatch feedback actions', reason);
122
- }
123
- }
124
-
125
- @preDestroy()
126
- dispose(): void {
127
- this.registeredFeedback.clear();
128
- this.isDisposed = true;
129
- }
130
- }