@eclipse-glsp/layout-elk 0.9.0-next.397cddd.4

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 (38) hide show
  1. package/LICENSE +642 -0
  2. package/README.md +9 -0
  3. package/lib/basic-type-mapper.d.ts +26 -0
  4. package/lib/basic-type-mapper.d.ts.map +1 -0
  5. package/lib/basic-type-mapper.js +97 -0
  6. package/lib/basic-type-mapper.js.map +1 -0
  7. package/lib/di.config.d.ts +53 -0
  8. package/lib/di.config.d.ts.map +1 -0
  9. package/lib/di.config.js +90 -0
  10. package/lib/di.config.js.map +1 -0
  11. package/lib/di.config.spec.d.ts +2 -0
  12. package/lib/di.config.spec.d.ts.map +1 -0
  13. package/lib/di.config.spec.js +100 -0
  14. package/lib/di.config.spec.js.map +1 -0
  15. package/lib/glsp-element-filter.d.ts +17 -0
  16. package/lib/glsp-element-filter.d.ts.map +1 -0
  17. package/lib/glsp-element-filter.js +53 -0
  18. package/lib/glsp-element-filter.js.map +1 -0
  19. package/lib/glsp-elk-layout-engine.d.ts +39 -0
  20. package/lib/glsp-elk-layout-engine.d.ts.map +1 -0
  21. package/lib/glsp-elk-layout-engine.js +80 -0
  22. package/lib/glsp-elk-layout-engine.js.map +1 -0
  23. package/lib/glsp-layout-configurator.d.ts +43 -0
  24. package/lib/glsp-layout-configurator.d.ts.map +1 -0
  25. package/lib/glsp-layout-configurator.js +57 -0
  26. package/lib/glsp-layout-configurator.js.map +1 -0
  27. package/lib/index.d.ts +23 -0
  28. package/lib/index.d.ts.map +1 -0
  29. package/lib/index.js +36 -0
  30. package/lib/index.js.map +1 -0
  31. package/package.json +61 -0
  32. package/src/basic-type-mapper.ts +73 -0
  33. package/src/di.config.spec.ts +92 -0
  34. package/src/di.config.ts +117 -0
  35. package/src/glsp-element-filter.ts +38 -0
  36. package/src/glsp-elk-layout-engine.ts +57 -0
  37. package/src/glsp-layout-configurator.ts +59 -0
  38. package/src/index.ts +22 -0
@@ -0,0 +1,26 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 STMicroelectronics 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 { DiagramConfiguration, GModelElementConstructor } from '@eclipse-glsp/server-node';
17
+ import { SModelElement } from 'sprotty-protocol';
18
+ export declare type BasicGModelType = 'graph' | 'node' | 'edge' | 'label' | 'port' | 'unknown';
19
+ export declare class BasicTypeMapper {
20
+ protected diagramConfiguration: DiagramConfiguration;
21
+ protected basicTypeMap: Map<string, BasicGModelType>;
22
+ protected postConstruct(): void;
23
+ protected toBasicType(constructor: GModelElementConstructor): BasicGModelType;
24
+ getBasicType(input: SModelElement | string): BasicGModelType;
25
+ }
26
+ //# sourceMappingURL=basic-type-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-type-mapper.d.ts","sourceRoot":"","sources":["../src/basic-type-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,oBAAoB,EAAyB,wBAAwB,EAAgB,MAAM,2BAA2B,CAAC;AAEhI,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,oBAAY,eAAe,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvF,qBAMa,eAAe;IAExB,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAErD,SAAS,CAAC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAGrD,SAAS,CAAC,aAAa,IAAI,IAAI;IAU/B,SAAS,CAAC,WAAW,CAAC,WAAW,EAAE,wBAAwB,GAAG,eAAe;IAgB7E,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,eAAe;CAY/D"}
@@ -0,0 +1,97 @@
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.BasicTypeMapper = void 0;
13
+ /********************************************************************************
14
+ * Copyright (c) 2022 STMicroelectronics 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 server_node_1 = require("@eclipse-glsp/server-node");
29
+ const inversify_1 = require("inversify");
30
+ let BasicTypeMapper =
31
+ /**
32
+ * The `BasicTypeMapper` provides the means to derive the basic type from a given graph model element.
33
+ * The basic type information is used by the `ElkLayoutEngine` to transform graphic model elements into their corresponding ELK object
34
+ * representation.
35
+ */
36
+ class BasicTypeMapper {
37
+ postConstruct() {
38
+ this.basicTypeMap = new Map();
39
+ this.diagramConfiguration.typeMapping.forEach((constructor, type) => {
40
+ const basicType = this.toBasicType(constructor);
41
+ if (basicType) {
42
+ this.basicTypeMap.set(type, basicType);
43
+ }
44
+ });
45
+ }
46
+ toBasicType(constructor) {
47
+ const element = new constructor();
48
+ if (element instanceof server_node_1.GNode) {
49
+ return 'node';
50
+ }
51
+ else if (element instanceof server_node_1.GEdge) {
52
+ return 'edge';
53
+ }
54
+ else if (element instanceof server_node_1.GGraph) {
55
+ return 'graph';
56
+ }
57
+ else if (element instanceof server_node_1.GLabel) {
58
+ return 'label';
59
+ }
60
+ else if (element instanceof server_node_1.GPort) {
61
+ return 'port';
62
+ }
63
+ return 'unknown';
64
+ }
65
+ getBasicType(input) {
66
+ const type = typeof input === 'string' ? input : input.type;
67
+ const basicType = this.basicTypeMap.get(type);
68
+ if (basicType) {
69
+ return basicType;
70
+ }
71
+ const subtypeSeparator = type.lastIndexOf(':');
72
+ if (subtypeSeparator > 0) {
73
+ return this.getBasicType(type.substring(0, subtypeSeparator));
74
+ }
75
+ return 'unknown';
76
+ }
77
+ };
78
+ __decorate([
79
+ inversify_1.inject(server_node_1.DiagramConfiguration),
80
+ __metadata("design:type", Object)
81
+ ], BasicTypeMapper.prototype, "diagramConfiguration", void 0);
82
+ __decorate([
83
+ inversify_1.postConstruct(),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", []),
86
+ __metadata("design:returntype", void 0)
87
+ ], BasicTypeMapper.prototype, "postConstruct", null);
88
+ BasicTypeMapper = __decorate([
89
+ inversify_1.injectable()
90
+ /**
91
+ * The `BasicTypeMapper` provides the means to derive the basic type from a given graph model element.
92
+ * The basic type information is used by the `ElkLayoutEngine` to transform graphic model elements into their corresponding ELK object
93
+ * representation.
94
+ */
95
+ ], BasicTypeMapper);
96
+ exports.BasicTypeMapper = BasicTypeMapper;
97
+ //# sourceMappingURL=basic-type-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basic-type-mapper.js","sourceRoot":"","sources":["../src/basic-type-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,2DAAgI;AAChI,yCAA8D;AAW9D,IAAa,eAAe;AAL5B;;;;GAIG;AACH,MAAa,eAAe;IAOd,aAAa;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE;YAChE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;YAChD,IAAI,SAAS,EAAE;gBACX,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;aAC1C;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAES,WAAW,CAAC,WAAqC;QACvD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,OAAO,YAAY,mBAAK,EAAE;YAC1B,OAAO,MAAM,CAAC;SACjB;aAAM,IAAI,OAAO,YAAY,mBAAK,EAAE;YACjC,OAAO,MAAM,CAAC;SACjB;aAAM,IAAI,OAAO,YAAY,oBAAM,EAAE;YAClC,OAAO,OAAO,CAAC;SAClB;aAAM,IAAI,OAAO,YAAY,oBAAM,EAAE;YAClC,OAAO,OAAO,CAAC;SAClB;aAAM,IAAI,OAAO,YAAY,mBAAK,EAAE;YACjC,OAAO,MAAM,CAAC;SACjB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,YAAY,CAAC,KAA6B;QACtC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,gBAAgB,GAAG,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC;SACjE;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;CACJ,CAAA;AA3CG;IADC,kBAAM,CAAC,kCAAoB,CAAC;;6DACwB;AAKrD;IADC,yBAAa,EAAE;;;;oDASf;AAfQ,eAAe;IAN3B,sBAAU,EAAE;IACb;;;;OAIG;GACU,eAAe,CA6C3B;AA7CY,0CAAe"}
@@ -0,0 +1,53 @@
1
+ import { LayoutOptions } from 'elkjs/lib/elk.bundled';
2
+ import { ContainerModule } from 'inversify';
3
+ import { GlspElementFilter } from './glsp-element-filter';
4
+ import { GlspLayoutConfigurator } from './glsp-layout-configurator';
5
+ declare type Constructor<T> = new (...args: any[]) => T;
6
+ /**
7
+ * Configuration options for the {@link configureELKLayoutModule} function.
8
+ */
9
+ export interface ElkModuleOptions {
10
+ /**
11
+ * The set of elk algorithms that is used by the {@link GlspElkLayoutEngine}.
12
+ */
13
+ algorithms: string[];
14
+ /**
15
+ * Additional default layout options. This options are passed to the underlying {@link ElkFactory}.
16
+ * In addition, they are used to configure the {@link FallbackGlspLayoutConfigurator}.
17
+ */
18
+ defaultLayoutOptions?: LayoutOptions;
19
+ /**
20
+ * The custom {@link GlspLayoutConfigurator} class that should be bound. If this option is not set
21
+ * the {@link FallbackGlspLayoutConfigurator} is bound instead.
22
+ */
23
+ layoutConfigurator?: Constructor<GlspLayoutConfigurator>;
24
+ /**
25
+ * The custom {@link GlspElementFilter} class that should be bound. If this option is not set, the default implementation
26
+ * is bound.
27
+ */
28
+ elementFilter?: Constructor<GlspElementFilter>;
29
+ }
30
+ /**
31
+ * Utility method to create a DI module that provides all necessary bindings to use the {@link GlspElkLayoutEngine} in a node GLSP server
32
+ * implementation. A set of configuration options is provided to enable easy customization. In most cases at least
33
+ * the custom {@link layoutConfigurator} binding should be provided (in addition to the required `algorithms' property) via these options.
34
+ *
35
+ * The constructed module is not intended for standalone use cases and only works in combination with a GLSPDiagramModule.
36
+ *
37
+ * * The following bindings are provided:
38
+ * - {@link BasicTypeMapper}
39
+ * - {@link BaseElkLayoutEngine}
40
+ * - {@link ElkLayoutEngine}
41
+ * - {@link GlspElementFilter}
42
+ * - {@link IElementFilter}
43
+ * - {@link GlspLayoutConfigurator}
44
+ * - {@link ILayoutConfigurator}
45
+ * - {@link LayoutEngine}
46
+ * - {@link ElkFactory}
47
+ *
48
+ * @param options The configuration options
49
+ * @returns A DI module that can be loaded as additional module when configuring a diagram module for a GLSP server.
50
+ */
51
+ export declare function configureELKLayoutModule(options: ElkModuleOptions): ContainerModule;
52
+ export {};
53
+ //# sourceMappingURL=di.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"di.config.d.ts","sourceRoot":"","sources":["../src/di.config.ts"],"names":[],"mappings":"AAgBA,OAAuB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAI5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAkC,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpG,aAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,aAAa,CAAC;IACrC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,sBAAsB,CAAC,CAAC;IACzD;;;OAGG;IACH,aAAa,CAAC,EAAE,WAAW,CAAC,iBAAiB,CAAC,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CA2CnF"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureELKLayoutModule = void 0;
4
+ /********************************************************************************
5
+ * Copyright (c) 2022 STMicroelectronics and others.
6
+ *
7
+ * This program and the accompanying materials are made available under the
8
+ * terms of the Eclipse Public License v. 2.0 which is available at
9
+ * http://www.eclipse.org/legal/epl-2.0.
10
+ *
11
+ * This Source Code may also be made available under the following Secondary
12
+ * Licenses when the conditions for such availability set forth in the Eclipse
13
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
14
+ * with the GNU Classpath Exception which is available at
15
+ * https://www.gnu.org/software/classpath/license.html.
16
+ *
17
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
18
+ ********************************************************************************/
19
+ const server_node_1 = require("@eclipse-glsp/server-node/");
20
+ const elk_bundled_1 = require("elkjs/lib/elk.bundled");
21
+ const inversify_1 = require("inversify");
22
+ const sprotty_elk_1 = require("sprotty-elk");
23
+ const _1 = require(".");
24
+ const basic_type_mapper_1 = require("./basic-type-mapper");
25
+ const glsp_element_filter_1 = require("./glsp-element-filter");
26
+ const glsp_elk_layout_engine_1 = require("./glsp-elk-layout-engine");
27
+ const glsp_layout_configurator_1 = require("./glsp-layout-configurator");
28
+ /**
29
+ * Utility method to create a DI module that provides all necessary bindings to use the {@link GlspElkLayoutEngine} in a node GLSP server
30
+ * implementation. A set of configuration options is provided to enable easy customization. In most cases at least
31
+ * the custom {@link layoutConfigurator} binding should be provided (in addition to the required `algorithms' property) via these options.
32
+ *
33
+ * The constructed module is not intended for standalone use cases and only works in combination with a GLSPDiagramModule.
34
+ *
35
+ * * The following bindings are provided:
36
+ * - {@link BasicTypeMapper}
37
+ * - {@link BaseElkLayoutEngine}
38
+ * - {@link ElkLayoutEngine}
39
+ * - {@link GlspElementFilter}
40
+ * - {@link IElementFilter}
41
+ * - {@link GlspLayoutConfigurator}
42
+ * - {@link ILayoutConfigurator}
43
+ * - {@link LayoutEngine}
44
+ * - {@link ElkFactory}
45
+ *
46
+ * @param options The configuration options
47
+ * @returns A DI module that can be loaded as additional module when configuring a diagram module for a GLSP server.
48
+ */
49
+ function configureELKLayoutModule(options) {
50
+ return new inversify_1.ContainerModule(bind => {
51
+ bind(basic_type_mapper_1.BasicTypeMapper).toSelf().inSingletonScope();
52
+ bind(glsp_elk_layout_engine_1.BaseElkLayoutEngine)
53
+ .toDynamicValue(context => {
54
+ const elkFactory = context.container.get(sprotty_elk_1.ElkFactory);
55
+ const elementFilter = context.container.get(sprotty_elk_1.IElementFilter);
56
+ const layoutConfigurator = context.container.get(sprotty_elk_1.ILayoutConfigurator);
57
+ const typeMapper = context.container.get(basic_type_mapper_1.BasicTypeMapper);
58
+ return new glsp_elk_layout_engine_1.BaseElkLayoutEngine(elkFactory, elementFilter, layoutConfigurator, typeMapper);
59
+ })
60
+ .inSingletonScope();
61
+ bind(sprotty_elk_1.ElkLayoutEngine).to(glsp_elk_layout_engine_1.BaseElkLayoutEngine);
62
+ if (options.elementFilter) {
63
+ bind(glsp_element_filter_1.GlspElementFilter).to(options.elementFilter).inSingletonScope();
64
+ }
65
+ else {
66
+ bind(glsp_element_filter_1.GlspElementFilter).toSelf().inSingletonScope();
67
+ }
68
+ bind(sprotty_elk_1.IElementFilter).toService(glsp_element_filter_1.GlspElementFilter);
69
+ if (options.layoutConfigurator) {
70
+ bind(glsp_layout_configurator_1.GlspLayoutConfigurator).to(options.layoutConfigurator);
71
+ }
72
+ else {
73
+ bind(glsp_layout_configurator_1.GlspLayoutConfigurator)
74
+ .toDynamicValue(context => {
75
+ const typeMapper = context.container.get(basic_type_mapper_1.BasicTypeMapper);
76
+ return new glsp_layout_configurator_1.FallbackGlspLayoutConfigurator(typeMapper, options.algorithms, options.defaultLayoutOptions);
77
+ })
78
+ .inSingletonScope();
79
+ }
80
+ bind(sprotty_elk_1.ILayoutConfigurator).toService(glsp_layout_configurator_1.GlspLayoutConfigurator);
81
+ bind(server_node_1.LayoutEngine).to(_1.GlspElkLayoutEngine).inSingletonScope();
82
+ const elkFactory = () => new elk_bundled_1.default({
83
+ algorithms: options.algorithms,
84
+ defaultLayoutOptions: options.defaultLayoutOptions
85
+ });
86
+ bind(sprotty_elk_1.ElkFactory).toConstantValue(elkFactory);
87
+ });
88
+ }
89
+ exports.configureELKLayoutModule = configureELKLayoutModule;
90
+ //# sourceMappingURL=di.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"di.config.js","sourceRoot":"","sources":["../src/di.config.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,4DAA0D;AAC1D,uDAAsE;AACtE,yCAA4C;AAC5C,6CAA+F;AAC/F,wBAAwC;AACxC,2DAAsD;AACtD,+DAA0D;AAC1D,qEAA+D;AAC/D,yEAAoG;AA6BpG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,SAAgB,wBAAwB,CAAC,OAAyB;IAC9D,OAAO,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;QAC9B,IAAI,CAAC,mCAAe,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;QAClD,IAAI,CAAC,4CAAmB,CAAC;aACpB,cAAc,CAAC,OAAO,CAAC,EAAE;YACtB,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAa,wBAAU,CAAC,CAAC;YACjE,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAiB,4BAAc,CAAC,CAAC;YAC5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BAAmB,CAAC,CAAC,gBAAgB,EAAE,CAAC;QAE9D,MAAM,UAAU,GAAe,GAAG,EAAE,CAChC,IAAI,qBAAc,CAAC;YACf,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;SACrD,CAAC,CAAC;QAEP,IAAI,CAAC,wBAAU,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACP,CAAC;AA3CD,4DA2CC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=di.config.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"di.config.spec.d.ts","sourceRoot":"","sources":["../src/di.config.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,100 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ /********************************************************************************
10
+ * Copyright (c) 2022 STMicroelectronics and others.
11
+ *
12
+ * This program and the accompanying materials are made available under the
13
+ * terms of the Eclipse Public License v. 2.0 which is available at
14
+ * http://www.eclipse.org/legal/epl-2.0.
15
+ *
16
+ * This Source Code may also be made available under the following Secondary
17
+ * Licenses when the conditions for such availability set forth in the Eclipse
18
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
19
+ * with the GNU Classpath Exception which is available at
20
+ * https://www.gnu.org/software/classpath/license.html.
21
+ *
22
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
23
+ ********************************************************************************/
24
+ const server_node_1 = require("@eclipse-glsp/server-node");
25
+ const mock_util_1 = require("@eclipse-glsp/server-node/lib/test/mock-util");
26
+ const chai_1 = require("chai");
27
+ const inversify_1 = require("inversify");
28
+ const sinon = require("sinon");
29
+ const sprotty_elk_1 = require("sprotty-elk");
30
+ const sprotty_protocol_1 = require("sprotty-protocol");
31
+ const _1 = require(".");
32
+ const di_config_1 = require("./di.config");
33
+ const glsp_element_filter_1 = require("./glsp-element-filter");
34
+ const glsp_layout_configurator_1 = require("./glsp-layout-configurator");
35
+ let CustomLayoutConfigurator = class CustomLayoutConfigurator extends _1.GlspLayoutConfigurator {
36
+ };
37
+ CustomLayoutConfigurator = __decorate([
38
+ inversify_1.injectable()
39
+ ], CustomLayoutConfigurator);
40
+ let CustomElementFilter = class CustomElementFilter extends glsp_element_filter_1.GlspElementFilter {
41
+ };
42
+ CustomElementFilter = __decorate([
43
+ inversify_1.injectable()
44
+ ], CustomElementFilter);
45
+ describe('test configureELKLayoutModule', () => {
46
+ const sandbox = sinon.createSandbox();
47
+ const mockDiagramConfiguration = new mock_util_1.StubDiagramConfiguration();
48
+ const typeMappings = new Map();
49
+ typeMappings.set('graph', server_node_1.GGraph);
50
+ sandbox.stub(mockDiagramConfiguration, 'typeMapping').value(typeMappings);
51
+ const modelState = new server_node_1.DefaultModelState();
52
+ const baseModule = new inversify_1.ContainerModule(bind => {
53
+ bind(server_node_1.DiagramConfiguration).toConstantValue(mockDiagramConfiguration);
54
+ bind(server_node_1.ModelState).toConstantValue(modelState);
55
+ });
56
+ it('configure with minimal options', () => {
57
+ const algorithm = 'layered';
58
+ const elkModule = di_config_1.configureELKLayoutModule({ algorithms: [algorithm] });
59
+ const container = new inversify_1.Container();
60
+ container.load(baseModule, elkModule);
61
+ const filter = container.get(sprotty_elk_1.IElementFilter);
62
+ chai_1.expect(filter).to.be.instanceOf(glsp_element_filter_1.GlspElementFilter);
63
+ const configurator = container.get(sprotty_elk_1.ILayoutConfigurator);
64
+ chai_1.expect(configurator).to.be.instanceOf(glsp_layout_configurator_1.FallbackGlspLayoutConfigurator);
65
+ const graphOptions = configurator.apply(new server_node_1.GGraph(), new sprotty_protocol_1.SModelIndex());
66
+ chai_1.expect(graphOptions).not.to.be.undefined;
67
+ chai_1.expect(graphOptions['elk.algorithm']).to.equal(algorithm);
68
+ });
69
+ it('configure with additional default layout options', () => {
70
+ const algorithm = 'layered';
71
+ const defaultLayoutOptions = {
72
+ 'elk.direction': 'LEFT',
73
+ 'elk.edgeRouting': 'POLYLINE'
74
+ };
75
+ const elkModule = di_config_1.configureELKLayoutModule({ algorithms: [algorithm], defaultLayoutOptions });
76
+ const container = new inversify_1.Container();
77
+ container.load(baseModule, elkModule);
78
+ const configurator = container.get(sprotty_elk_1.ILayoutConfigurator);
79
+ const graphOptions = configurator.apply(new server_node_1.GGraph(), new sprotty_protocol_1.SModelIndex());
80
+ chai_1.expect(graphOptions).not.to.be.undefined;
81
+ chai_1.expect(graphOptions).to.include(defaultLayoutOptions);
82
+ });
83
+ it('configure with custom layout configurator', () => {
84
+ const algorithm = 'layered';
85
+ const elkModule = di_config_1.configureELKLayoutModule({ algorithms: [algorithm], layoutConfigurator: CustomLayoutConfigurator });
86
+ const container = new inversify_1.Container();
87
+ container.load(baseModule, elkModule);
88
+ const configurator = container.get(sprotty_elk_1.ILayoutConfigurator);
89
+ chai_1.expect(configurator).to.be.instanceOf(CustomLayoutConfigurator);
90
+ });
91
+ it('configure with custom element filter', () => {
92
+ const algorithm = 'layered';
93
+ const elkModule = di_config_1.configureELKLayoutModule({ algorithms: [algorithm], elementFilter: CustomElementFilter });
94
+ const container = new inversify_1.Container();
95
+ container.load(baseModule, elkModule);
96
+ const filter = container.get(sprotty_elk_1.IElementFilter);
97
+ chai_1.expect(filter).to.be.instanceOf(CustomElementFilter);
98
+ });
99
+ });
100
+ //# sourceMappingURL=di.config.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AC,CAAC;QAC7D,aAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { DefaultElementFilter } from 'sprotty-elk';
2
+ import { SModelElement } from 'sprotty-protocol';
3
+ import { BasicTypeMapper } from './basic-type-mapper';
4
+ /**
5
+ * The default `IElementFilter` used to determine which model elements should be included in the automatic layout.
6
+ * Without further configuration this filter includes all basic model elements (nodes,edges,labels,ports) that are
7
+ * part of the graphical model. For each a custom filter behavior is in place. Edges that have no source or target are filtered out.
8
+ * In addition, edges that are connected to a filtered element are filtered out as well.
9
+ * The filter behavior for each of the basic types can be customized by overriding the corresponding `filter` method.
10
+ * (e.g. {@link GlspElementFilter.filterNode})
11
+ *
12
+ */
13
+ export declare class GlspElementFilter extends DefaultElementFilter {
14
+ protected typeMapper: BasicTypeMapper;
15
+ protected getBasicType(smodel: SModelElement): string;
16
+ }
17
+ //# sourceMappingURL=glsp-element-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-element-filter.d.ts","sourceRoot":"","sources":["../src/glsp-element-filter.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;;;GAQG;AACH,qBACa,iBAAkB,SAAQ,oBAAoB;IAEvD,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC;IAEtC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;CAGxD"}
@@ -0,0 +1,53 @@
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.GlspElementFilter = void 0;
13
+ /********************************************************************************
14
+ * Copyright (c) 2022 STMicroelectronics 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 inversify_1 = require("inversify");
29
+ const sprotty_elk_1 = require("sprotty-elk");
30
+ const basic_type_mapper_1 = require("./basic-type-mapper");
31
+ /**
32
+ * The default `IElementFilter` used to determine which model elements should be included in the automatic layout.
33
+ * Without further configuration this filter includes all basic model elements (nodes,edges,labels,ports) that are
34
+ * part of the graphical model. For each a custom filter behavior is in place. Edges that have no source or target are filtered out.
35
+ * In addition, edges that are connected to a filtered element are filtered out as well.
36
+ * The filter behavior for each of the basic types can be customized by overriding the corresponding `filter` method.
37
+ * (e.g. {@link GlspElementFilter.filterNode})
38
+ *
39
+ */
40
+ let GlspElementFilter = class GlspElementFilter extends sprotty_elk_1.DefaultElementFilter {
41
+ getBasicType(smodel) {
42
+ return this.typeMapper.getBasicType(smodel);
43
+ }
44
+ };
45
+ __decorate([
46
+ inversify_1.inject(basic_type_mapper_1.BasicTypeMapper),
47
+ __metadata("design:type", basic_type_mapper_1.BasicTypeMapper)
48
+ ], GlspElementFilter.prototype, "typeMapper", void 0);
49
+ GlspElementFilter = __decorate([
50
+ inversify_1.injectable()
51
+ ], GlspElementFilter);
52
+ exports.GlspElementFilter = GlspElementFilter;
53
+ //# sourceMappingURL=glsp-element-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-element-filter.js","sourceRoot":"","sources":["../src/glsp-element-filter.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,yCAA+C;AAC/C,6CAAmD;AAEnD,2DAAsD;AAEtD;;;;;;;;GAQG;AAEH,IAAa,iBAAiB,GAA9B,MAAa,iBAAkB,SAAQ,kCAAoB;IAI7C,YAAY,CAAC,MAAqB;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACJ,CAAA;AALG;IADC,kBAAM,CAAC,mCAAe,CAAC;8BACF,mCAAe;qDAAC;AAF7B,iBAAiB;IAD7B,sBAAU,EAAE;GACA,iBAAiB,CAO7B;AAPY,8CAAiB"}
@@ -0,0 +1,39 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 STMicroelectronics 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 { LayoutEngine, ModelState } from '@eclipse-glsp/server-node';
17
+ import { ElkFactory, ElkLayoutEngine, IElementFilter, ILayoutConfigurator } from 'sprotty-elk/lib/inversify';
18
+ import { SModelElement } from 'sprotty-protocol/lib/model';
19
+ import { BasicTypeMapper } from './basic-type-mapper';
20
+ /**
21
+ * Layout engine that delegates to ELK by transforming the graphical model into an ELK graph.
22
+ */
23
+ export declare class BaseElkLayoutEngine extends ElkLayoutEngine {
24
+ protected readonly filter: IElementFilter;
25
+ protected readonly configurator: ILayoutConfigurator;
26
+ protected typeMapper: BasicTypeMapper;
27
+ constructor(elkFactory: ElkFactory, filter: IElementFilter, configurator: ILayoutConfigurator, typeMapper: BasicTypeMapper);
28
+ protected getBasicType(smodel: SModelElement): string;
29
+ }
30
+ /**
31
+ * A implement of GLSP's {@link LayoutEngine} interface that retrieves the graphical model from the {@link ModelState}
32
+ * and delegates the to an underlying {@link BaseElkLayoutEngine} instance for computing the layout.
33
+ */
34
+ export declare class GlspElkLayoutEngine implements LayoutEngine {
35
+ protected modelState: ModelState;
36
+ protected elkLayoutEngine: BaseElkLayoutEngine;
37
+ layout(): Promise<void>;
38
+ }
39
+ //# sourceMappingURL=glsp-elk-layout-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-elk-layout-engine.d.ts","sourceRoot":"","sources":["../src/glsp-elk-layout-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;GAEG;AACH,qBACa,mBAAoB,SAAQ,eAAe;IAGxB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc;IACpC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,mBAAmB;IACxD,SAAS,CAAC,UAAU,EAAE,eAAe;gBAH1C,UAAU,EAAE,UAAU,EACC,MAAM,EAAE,cAAc,EACjB,YAAY,EAAE,mBAAmB,EAC9C,UAAU,EAAE,eAAe;IAKlE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;CAGxD;AAED;;;GAGG;AACH,qBACa,mBAAoB,YAAW,YAAY;IAEpD,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAGjC,SAAS,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAEzC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
@@ -0,0 +1,80 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.GlspElkLayoutEngine = exports.BaseElkLayoutEngine = void 0;
16
+ /********************************************************************************
17
+ * Copyright (c) 2022 STMicroelectronics and others.
18
+ *
19
+ * This program and the accompanying materials are made available under the
20
+ * terms of the Eclipse Public License v. 2.0 which is available at
21
+ * http://www.eclipse.org/legal/epl-2.0.
22
+ *
23
+ * This Source Code may also be made available under the following Secondary
24
+ * Licenses when the conditions for such availability set forth in the Eclipse
25
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
26
+ * with the GNU Classpath Exception which is available at
27
+ * https://www.gnu.org/software/classpath/license.html.
28
+ *
29
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
30
+ ********************************************************************************/
31
+ const server_node_1 = require("@eclipse-glsp/server-node");
32
+ const inversify_1 = require("inversify");
33
+ const inversify_2 = require("sprotty-elk/lib/inversify");
34
+ const basic_type_mapper_1 = require("./basic-type-mapper");
35
+ /**
36
+ * Layout engine that delegates to ELK by transforming the graphical model into an ELK graph.
37
+ */
38
+ let BaseElkLayoutEngine = class BaseElkLayoutEngine extends inversify_2.ElkLayoutEngine {
39
+ constructor(elkFactory, filter, configurator, typeMapper) {
40
+ super(elkFactory, filter, configurator);
41
+ this.filter = filter;
42
+ this.configurator = configurator;
43
+ this.typeMapper = typeMapper;
44
+ }
45
+ getBasicType(smodel) {
46
+ return this.typeMapper.getBasicType(smodel);
47
+ }
48
+ };
49
+ BaseElkLayoutEngine = __decorate([
50
+ inversify_1.injectable(),
51
+ __param(0, inversify_1.inject(inversify_2.ElkFactory)),
52
+ __param(1, inversify_1.inject(inversify_2.IElementFilter)),
53
+ __param(2, inversify_1.inject(inversify_2.ILayoutConfigurator)),
54
+ __param(3, inversify_1.inject(basic_type_mapper_1.BasicTypeMapper)),
55
+ __metadata("design:paramtypes", [Function, Object, Object, basic_type_mapper_1.BasicTypeMapper])
56
+ ], BaseElkLayoutEngine);
57
+ exports.BaseElkLayoutEngine = BaseElkLayoutEngine;
58
+ /**
59
+ * A implement of GLSP's {@link LayoutEngine} interface that retrieves the graphical model from the {@link ModelState}
60
+ * and delegates the to an underlying {@link BaseElkLayoutEngine} instance for computing the layout.
61
+ */
62
+ let GlspElkLayoutEngine = class GlspElkLayoutEngine {
63
+ async layout() {
64
+ const graph = this.modelState.root;
65
+ await this.elkLayoutEngine.layout(graph);
66
+ }
67
+ };
68
+ __decorate([
69
+ inversify_1.inject(server_node_1.ModelState),
70
+ __metadata("design:type", Object)
71
+ ], GlspElkLayoutEngine.prototype, "modelState", void 0);
72
+ __decorate([
73
+ inversify_1.inject(BaseElkLayoutEngine),
74
+ __metadata("design:type", BaseElkLayoutEngine)
75
+ ], GlspElkLayoutEngine.prototype, "elkLayoutEngine", void 0);
76
+ GlspElkLayoutEngine = __decorate([
77
+ inversify_1.injectable()
78
+ ], GlspElkLayoutEngine);
79
+ exports.GlspElkLayoutEngine = GlspElkLayoutEngine;
80
+ //# sourceMappingURL=glsp-elk-layout-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-elk-layout-engine.js","sourceRoot":"","sources":["../src/glsp-elk-layout-engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,2DAAqE;AACrE,yCAA+C;AAC/C,yDAA6G;AAE7G,2DAAsD;AAEtD;;GAEG;AAEH,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,2BAAe;IACpD,YACwB,UAAsB,EACC,MAAsB,EACjB,YAAiC,EAC9C,UAA2B;QAE9D,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAJG,WAAM,GAAN,MAAM,CAAgB;QACjB,iBAAY,GAAZ,YAAY,CAAqB;QAC9C,eAAU,GAAV,UAAU,CAAiB;IAGlE,CAAC;IAES,YAAY,CAAC,MAAqB;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;CACJ,CAAA;AAbY,mBAAmB;IAD/B,sBAAU,EAAE;IAGJ,WAAA,kBAAM,CAAC,sBAAU,CAAC,CAAA;IAClB,WAAA,kBAAM,CAAC,0BAAc,CAAC,CAAA;IACtB,WAAA,kBAAM,CAAC,+BAAmB,CAAC,CAAA;IAC3B,WAAA,k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