lucid-extension-sdk 1.0.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.
Files changed (60) hide show
  1. package/bin/constants.d.ts +14 -0
  2. package/bin/constants.js +2 -0
  3. package/bin/document/blockclasses/blockproxyregistry.d.ts +5 -0
  4. package/bin/document/blockclasses/blockproxyregistry.js +8 -0
  5. package/bin/document/blockclasses/erdblockproxy.d.ts +15 -0
  6. package/bin/document/blockclasses/erdblockproxy.js +40 -0
  7. package/bin/document/blockdefinition.d.ts +5 -0
  8. package/bin/document/blockdefinition.js +2 -0
  9. package/bin/document/blockproxy.d.ts +7 -0
  10. package/bin/document/blockproxy.js +17 -0
  11. package/bin/document/documentproxy.d.ts +10 -0
  12. package/bin/document/documentproxy.js +20 -0
  13. package/bin/document/elementproxy.d.ts +10 -0
  14. package/bin/document/elementproxy.js +30 -0
  15. package/bin/document/groupproxy.d.ts +9 -0
  16. package/bin/document/groupproxy.js +14 -0
  17. package/bin/document/itemproxy.d.ts +16 -0
  18. package/bin/document/itemproxy.js +54 -0
  19. package/bin/document/linedefinition.d.ts +29 -0
  20. package/bin/document/linedefinition.js +12 -0
  21. package/bin/document/lineproxy.d.ts +10 -0
  22. package/bin/document/lineproxy.js +40 -0
  23. package/bin/document/mapproxy.d.ts +16 -0
  24. package/bin/document/mapproxy.js +35 -0
  25. package/bin/document/pagedefinition.d.ts +3 -0
  26. package/bin/document/pagedefinition.js +2 -0
  27. package/bin/document/pageproxy.d.ts +20 -0
  28. package/bin/document/pageproxy.js +80 -0
  29. package/bin/editorclient.d.ts +21 -0
  30. package/bin/editorclient.js +100 -0
  31. package/bin/index.d.ts +4 -0
  32. package/bin/index.js +9 -0
  33. package/bin/math.d.ts +10 -0
  34. package/bin/math.js +2 -0
  35. package/bin/ui/menu.d.ts +26 -0
  36. package/bin/ui/menu.js +19 -0
  37. package/bin/ui/viewport.d.ts +10 -0
  38. package/bin/ui/viewport.js +22 -0
  39. package/package.json +13 -0
  40. package/src/constants.ts +14 -0
  41. package/src/document/blockclasses/blockproxyregistry.ts +12 -0
  42. package/src/document/blockclasses/erdblockproxy.ts +41 -0
  43. package/src/document/blockdefinition.ts +6 -0
  44. package/src/document/blockproxy.ts +17 -0
  45. package/src/document/documentproxy.ts +28 -0
  46. package/src/document/elementproxy.ts +41 -0
  47. package/src/document/groupproxy.ts +25 -0
  48. package/src/document/itemproxy.ts +58 -0
  49. package/src/document/linedefinition.ts +41 -0
  50. package/src/document/lineproxy.ts +48 -0
  51. package/src/document/mapproxy.ts +43 -0
  52. package/src/document/pagedefinition.ts +3 -0
  53. package/src/document/pageproxy.ts +128 -0
  54. package/src/editorclient.ts +109 -0
  55. package/src/index.ts +4 -0
  56. package/src/interop.d.ts +8 -0
  57. package/src/math.ts +2 -0
  58. package/src/ui/menu.ts +43 -0
  59. package/src/ui/viewport.ts +22 -0
  60. package/tsconfig.json +38 -0
@@ -0,0 +1,14 @@
1
+ export declare const enum OffsetType {
2
+ NW = 0,
3
+ NE = 1,
4
+ SE = 2,
5
+ SW = 3,
6
+ MOVE = 4,
7
+ ROTATE = 5,
8
+ SCALE = 6,
9
+ CUSTOM = 7,
10
+ N = 8,
11
+ E = 9,
12
+ S = 10,
13
+ W = 11
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { BlockProxy } from '../blockproxy';
2
+ export declare type BlockProxyConstructor = typeof BlockProxy & {
3
+ classNameRegex: RegExp;
4
+ };
5
+ export declare function findProxyClass(className: string): BlockProxyConstructor | undefined;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const erdblockproxy_1 = require("./erdblockproxy");
4
+ const allProxyClasses = [erdblockproxy_1.ERDBlockProxy];
5
+ function findProxyClass(className) {
6
+ return allProxyClasses.find((proxy) => proxy.classNameRegex.test(className));
7
+ }
8
+ exports.findProxyClass = findProxyClass;
@@ -0,0 +1,15 @@
1
+ import { BlockProxy } from '../blockproxy';
2
+ export declare class ERDFieldProxy {
3
+ private readonly block;
4
+ private readonly index;
5
+ constructor(block: ERDBlockProxy, index: number);
6
+ getName(): string;
7
+ getType(): string;
8
+ getKey(): string;
9
+ }
10
+ export declare class ERDBlockProxy extends BlockProxy {
11
+ static classNameRegex: RegExp;
12
+ getName(): string;
13
+ getFieldCount(): number;
14
+ getFields(): ERDFieldProxy[];
15
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const blockproxy_1 = require("../blockproxy");
4
+ class ERDFieldProxy {
5
+ constructor(block, index) {
6
+ this.block = block;
7
+ this.index = index;
8
+ }
9
+ getName() {
10
+ return this.block.properties.get('Field' + this.index);
11
+ }
12
+ getType() {
13
+ var _a;
14
+ return (_a = this.block.properties.get('Type' + this.index)) !== null && _a !== void 0 ? _a : '';
15
+ }
16
+ getKey() {
17
+ var _a;
18
+ return (_a = this.block.properties.get('Key' + this.index)) !== null && _a !== void 0 ? _a : '';
19
+ }
20
+ }
21
+ exports.ERDFieldProxy = ERDFieldProxy;
22
+ class ERDBlockProxy extends blockproxy_1.BlockProxy {
23
+ getName() {
24
+ return this.properties.get('Name');
25
+ }
26
+ getFieldCount() {
27
+ return this.properties.get('Fields');
28
+ }
29
+ getFields() {
30
+ const fields = [];
31
+ const fieldCount = this.getFieldCount();
32
+ for (let i = 1; i <= fieldCount; i++) {
33
+ //These are 1-indexed in the property store
34
+ fields.push(new ERDFieldProxy(this, i));
35
+ }
36
+ return fields;
37
+ }
38
+ }
39
+ exports.ERDBlockProxy = ERDBlockProxy;
40
+ ERDBlockProxy.classNameRegex = /^ERDEntityBlock(2|3|4)?$/;
@@ -0,0 +1,5 @@
1
+ import { Box } from '../math';
2
+ export declare type BlockDefinition = {
3
+ className: string;
4
+ boundingBox: Box;
5
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { ItemProxy } from './itemproxy';
2
+ import { LineProxy } from './lineproxy';
3
+ export declare class BlockProxy extends ItemProxy {
4
+ getClassName(): string;
5
+ getRotation(): number;
6
+ getConnectedLines(): LineProxy[];
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const itemproxy_1 = require("./itemproxy");
4
+ const lineproxy_1 = require("./lineproxy");
5
+ class BlockProxy extends itemproxy_1.ItemProxy {
6
+ getClassName() {
7
+ return this.properties.get('ClassName');
8
+ }
9
+ getRotation() {
10
+ return this.properties.get('Rotation');
11
+ }
12
+ getConnectedLines() {
13
+ const ids = this.client.sendCommand('gcl', this.id);
14
+ return ids.map((id) => new lineproxy_1.LineProxy(id, this.client));
15
+ }
16
+ }
17
+ exports.BlockProxy = BlockProxy;
@@ -0,0 +1,10 @@
1
+ import { EditorClient } from '../editorclient';
2
+ import { ElementProxy } from './elementproxy';
3
+ import { MapProxy } from './mapproxy';
4
+ import { PageProxy } from './pageproxy';
5
+ import { PageDefinition } from './pagedefinition';
6
+ export declare class DocumentProxy extends ElementProxy {
7
+ readonly pages: MapProxy<string, PageProxy>;
8
+ constructor(client: EditorClient);
9
+ addPage(def: PageDefinition): PageProxy;
10
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const elementproxy_1 = require("./elementproxy");
4
+ const mapproxy_1 = require("./mapproxy");
5
+ const pageproxy_1 = require("./pageproxy");
6
+ class DocumentProxy extends elementproxy_1.ElementProxy {
7
+ constructor(client) {
8
+ super('', client);
9
+ this.pages = new mapproxy_1.MapProxy(this.client, 'lp', undefined, (pageId) => new pageproxy_1.PageProxy(pageId, this.client));
10
+ }
11
+ addPage(def) {
12
+ const id = this.client.sendCommand('cp', {
13
+ 'Title': def.title,
14
+ });
15
+ const page = new pageproxy_1.PageProxy(id, this.client);
16
+ page.setTitle(def.title);
17
+ return page;
18
+ }
19
+ }
20
+ exports.DocumentProxy = DocumentProxy;
@@ -0,0 +1,10 @@
1
+ import { EditorClient } from '../editorclient';
2
+ import { MapProxy, WriteableMapProxy } from './mapproxy';
3
+ export declare class ElementProxy {
4
+ readonly id: string;
5
+ protected readonly client: EditorClient;
6
+ readonly properties: WriteableMapProxy<string, any>;
7
+ readonly shapeData: MapProxy<string, any>;
8
+ constructor(id: string, client: EditorClient);
9
+ exists(): boolean;
10
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mapproxy_1 = require("./mapproxy");
4
+ class ElementProxy {
5
+ constructor(id, client) {
6
+ this.id = id;
7
+ this.client = client;
8
+ this.properties = new mapproxy_1.WriteableMapProxy(this.client, 'lpr', this.id, (name) => this.client.sendCommand('gp', {
9
+ 'id': this.id,
10
+ 'p': name,
11
+ }), (name, value) => {
12
+ if (name === 'BoundingBox') {
13
+ throw new Error('Do not use properties.set() to move or resize items; use setLocation() or setBoundingBox() or offset()');
14
+ }
15
+ this.client.sendCommand('sp', {
16
+ 'id': this.id,
17
+ 'p': name,
18
+ 'v': value,
19
+ });
20
+ });
21
+ this.shapeData = new mapproxy_1.MapProxy(this.client, 'lsd', this.id, (name) => this.client.sendCommand('gsd', {
22
+ 'id': this.id,
23
+ 'n': name,
24
+ }));
25
+ }
26
+ exists() {
27
+ return this.client.sendCommand('ee', this.id);
28
+ }
29
+ }
30
+ exports.ElementProxy = ElementProxy;
@@ -0,0 +1,9 @@
1
+ import { MapProxy } from './mapproxy';
2
+ import { BlockProxy } from './blockproxy';
3
+ import { LineProxy } from './lineproxy';
4
+ import { ItemProxy } from './itemproxy';
5
+ export declare class GroupProxy extends ItemProxy {
6
+ readonly blocks: MapProxy<string, BlockProxy>;
7
+ readonly lines: MapProxy<string, LineProxy>;
8
+ readonly groups: MapProxy<string, GroupProxy>;
9
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mapproxy_1 = require("./mapproxy");
4
+ const lineproxy_1 = require("./lineproxy");
5
+ const itemproxy_1 = require("./itemproxy");
6
+ class GroupProxy extends itemproxy_1.ItemProxy {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.blocks = new mapproxy_1.MapProxy(this.client, 'lb', this.id, (id) => this.client.getBlockProxy(id));
10
+ this.lines = new mapproxy_1.MapProxy(this.client, 'll', this.id, (id) => new lineproxy_1.LineProxy(id, this.client));
11
+ this.groups = new mapproxy_1.MapProxy(this.client, 'lg', this.id, (id) => new GroupProxy(id, this.client));
12
+ }
13
+ }
14
+ exports.GroupProxy = GroupProxy;
@@ -0,0 +1,16 @@
1
+ import { ElementProxy } from './elementproxy';
2
+ import { MapProxy } from './mapproxy';
3
+ import { OffsetType } from '../constants';
4
+ import { Box, Point } from '../math';
5
+ export declare class ItemProxy extends ElementProxy {
6
+ readonly textAreas: MapProxy<string, string>;
7
+ getBoundingBox(): Box;
8
+ setBoundingBox(bb: Box): void;
9
+ getLocation(): {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ setLocation(location: Point): void;
14
+ offset(type: OffsetType, offset: Point): void;
15
+ delete(): void;
16
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const elementproxy_1 = require("./elementproxy");
4
+ const mapproxy_1 = require("./mapproxy");
5
+ class ItemProxy extends elementproxy_1.ElementProxy {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.textAreas = new mapproxy_1.MapProxy(this.client, 'lta', this.id, (name) => this.client.sendCommand('gp', {
9
+ 'id': this.id,
10
+ 'p': name,
11
+ }));
12
+ }
13
+ getBoundingBox() {
14
+ return this.properties.get('BoundingBox');
15
+ }
16
+ setBoundingBox(bb) {
17
+ const current = this.getBoundingBox();
18
+ if (current.w === bb.w && current.h === bb.h) {
19
+ //Move it into place
20
+ if (current.x !== bb.x || current.y !== bb.y) {
21
+ this.offset(4 /* MOVE */, { x: bb.x - current.x, y: bb.y - current.y });
22
+ }
23
+ }
24
+ else {
25
+ //Stretch it to size
26
+ if (current.x !== bb.x || current.y !== bb.y) {
27
+ this.offset(0 /* NW */, { x: bb.x - current.x, y: bb.y - current.y });
28
+ }
29
+ if (current.x + current.w !== bb.x + bb.w || current.y + current.h !== bb.y + bb.h) {
30
+ this.offset(2 /* SE */, {
31
+ x: bb.x + bb.w - (current.x + current.w),
32
+ y: bb.y + bb.h - (current.y + current.h),
33
+ });
34
+ }
35
+ }
36
+ }
37
+ getLocation() {
38
+ const bb = this.getBoundingBox();
39
+ return { x: bb.x, y: bb.y };
40
+ }
41
+ setLocation(location) {
42
+ const current = this.getBoundingBox();
43
+ if (current.x !== location.x || current.y !== location.y) {
44
+ this.offset(4 /* MOVE */, { x: location.x - current.x, y: location.y - current.y });
45
+ }
46
+ }
47
+ offset(type, offset) {
48
+ this.client.sendCommand('oi', { 'ids': [this.id], 't': type, 'o': offset });
49
+ }
50
+ delete() {
51
+ this.client.sendCommand('di', this.id);
52
+ }
53
+ }
54
+ exports.ItemProxy = ItemProxy;
@@ -0,0 +1,29 @@
1
+ import { BlockProxy } from './blockproxy';
2
+ import { LineProxy } from './lineproxy';
3
+ export interface EndpointStyle {
4
+ style?: string;
5
+ }
6
+ export interface BlockEndpointDefinition extends EndpointStyle {
7
+ connection: BlockProxy;
8
+ linkX: number;
9
+ linkY: number;
10
+ inside?: boolean;
11
+ autoLink?: boolean;
12
+ padding?: number;
13
+ }
14
+ export interface LineEndpointDefinition extends EndpointStyle {
15
+ connection: LineProxy;
16
+ position: number;
17
+ }
18
+ export interface PositionEndpointDefinition extends EndpointStyle {
19
+ connection: void;
20
+ x: number;
21
+ y: number;
22
+ }
23
+ export declare type EndpointDefinition = BlockEndpointDefinition | LineEndpointDefinition | PositionEndpointDefinition;
24
+ export declare function isBlockEndpointDefinition(ep: EndpointDefinition): ep is BlockEndpointDefinition;
25
+ export declare function isLineEndpointDefinition(ep: EndpointDefinition): ep is LineEndpointDefinition;
26
+ export declare type LineDefinition = {
27
+ endpoint1: EndpointDefinition;
28
+ endpoint2: EndpointDefinition;
29
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const blockproxy_1 = require("./blockproxy");
4
+ const lineproxy_1 = require("./lineproxy");
5
+ function isBlockEndpointDefinition(ep) {
6
+ return ep.connection instanceof blockproxy_1.BlockProxy;
7
+ }
8
+ exports.isBlockEndpointDefinition = isBlockEndpointDefinition;
9
+ function isLineEndpointDefinition(ep) {
10
+ return ep.connection instanceof lineproxy_1.LineProxy;
11
+ }
12
+ exports.isLineEndpointDefinition = isLineEndpointDefinition;
@@ -0,0 +1,10 @@
1
+ import { Point } from '../math';
2
+ import { ElementProxy } from './elementproxy';
3
+ import { ItemProxy } from './itemproxy';
4
+ export declare class LineProxy extends ItemProxy {
5
+ private getConnection;
6
+ getUpstreamConnection(): Promise<ElementProxy | undefined>;
7
+ getDownstreamConnection(): Promise<ElementProxy | undefined>;
8
+ getConnectedLines(): LineProxy[];
9
+ getRelativePosition(relative: number): Point;
10
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const itemproxy_1 = require("./itemproxy");
4
+ class LineProxy extends itemproxy_1.ItemProxy {
5
+ async getConnection(ep) {
6
+ let proxy;
7
+ if (ep['Block']) {
8
+ proxy = this.client.getBlockProxy(ep['Block']);
9
+ }
10
+ if (ep['Line']) {
11
+ proxy = new LineProxy(ep['Line'], this.client);
12
+ }
13
+ if (proxy && !proxy.exists()) {
14
+ return undefined;
15
+ }
16
+ return proxy;
17
+ }
18
+ async getUpstreamConnection() {
19
+ const ep = this.properties.get('Endpoint1');
20
+ if (!(typeof ep === 'object')) {
21
+ return undefined;
22
+ }
23
+ return this.getConnection(ep);
24
+ }
25
+ async getDownstreamConnection() {
26
+ const ep = this.properties.get('Endpoint2');
27
+ if (!(typeof ep === 'object')) {
28
+ return undefined;
29
+ }
30
+ return this.getConnection(ep);
31
+ }
32
+ getConnectedLines() {
33
+ const ids = this.client.sendCommand('gcl', this.id);
34
+ return ids.map((id) => new LineProxy(id, this.client));
35
+ }
36
+ getRelativePosition(relative) {
37
+ return this.client.sendCommand('grlp', { 'id': this.id, 'p': relative });
38
+ }
39
+ }
40
+ exports.LineProxy = LineProxy;
@@ -0,0 +1,16 @@
1
+ import { EditorClient } from '../editorclient';
2
+ export declare class MapProxy<KEY, VALUE> {
3
+ protected readonly client: EditorClient;
4
+ private readonly keyCommand;
5
+ private readonly keyParams;
6
+ private readonly getter;
7
+ constructor(client: EditorClient, keyCommand: string, keyParams: any, getter: (key: KEY) => VALUE);
8
+ [Symbol.iterator](): Iterator<[KEY, VALUE]>;
9
+ keys(): KEY[];
10
+ get(key: KEY): VALUE;
11
+ }
12
+ export declare class WriteableMapProxy<KEY, VALUE> extends MapProxy<KEY, VALUE> {
13
+ private readonly setter;
14
+ constructor(client: EditorClient, keyCommand: string, keyParams: any, getter: (key: KEY) => VALUE, setter: (key: KEY, val: VALUE) => void);
15
+ set(key: KEY, value: VALUE): void;
16
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class MapProxy {
4
+ constructor(client, keyCommand, keyParams, getter) {
5
+ this.client = client;
6
+ this.keyCommand = keyCommand;
7
+ this.keyParams = keyParams;
8
+ this.getter = getter;
9
+ }
10
+ *[Symbol.iterator]() {
11
+ for (const key of this.keys()) {
12
+ const value = this.get(key);
13
+ if (value !== undefined) {
14
+ yield [key, value];
15
+ }
16
+ }
17
+ }
18
+ keys() {
19
+ return this.client.sendCommand(this.keyCommand, this.keyParams);
20
+ }
21
+ get(key) {
22
+ return this.getter(key);
23
+ }
24
+ }
25
+ exports.MapProxy = MapProxy;
26
+ class WriteableMapProxy extends MapProxy {
27
+ constructor(client, keyCommand, keyParams, getter, setter) {
28
+ super(client, keyCommand, keyParams, getter);
29
+ this.setter = setter;
30
+ }
31
+ set(key, value) {
32
+ this.setter(key, value);
33
+ }
34
+ }
35
+ exports.WriteableMapProxy = WriteableMapProxy;
@@ -0,0 +1,3 @@
1
+ export declare type PageDefinition = {
2
+ title: string;
3
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ import { ElementProxy } from './elementproxy';
2
+ import { MapProxy } from './mapproxy';
3
+ import { BlockProxy } from './blockproxy';
4
+ import { LineProxy } from './lineproxy';
5
+ import { GroupProxy } from './groupproxy';
6
+ import { BlockDefinition } from './blockdefinition';
7
+ import { LineDefinition } from './linedefinition';
8
+ export declare class PageProxy extends ElementProxy {
9
+ readonly blocks: MapProxy<string, BlockProxy>;
10
+ readonly lines: MapProxy<string, LineProxy>;
11
+ readonly groups: MapProxy<string, GroupProxy>;
12
+ readonly allBlocks: MapProxy<string, BlockProxy>;
13
+ readonly allLines: MapProxy<string, LineProxy>;
14
+ readonly allGroups: MapProxy<string, GroupProxy>;
15
+ addBlock(def: BlockDefinition): BlockProxy;
16
+ addLine(def: LineDefinition): LineProxy;
17
+ setTitle(title: string): void;
18
+ getTitle(): string;
19
+ delete(): void;
20
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const elementproxy_1 = require("./elementproxy");
4
+ const mapproxy_1 = require("./mapproxy");
5
+ const lineproxy_1 = require("./lineproxy");
6
+ const groupproxy_1 = require("./groupproxy");
7
+ const linedefinition_1 = require("./linedefinition");
8
+ class PageProxy extends elementproxy_1.ElementProxy {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.blocks = new mapproxy_1.MapProxy(this.client, 'lb', { id: this.id }, (id) => this.client.getBlockProxy(id));
12
+ this.lines = new mapproxy_1.MapProxy(this.client, 'll', { id: this.id }, (id) => new lineproxy_1.LineProxy(id, this.client));
13
+ this.groups = new mapproxy_1.MapProxy(this.client, 'lg', { id: this.id }, (id) => new groupproxy_1.GroupProxy(id, this.client));
14
+ this.allBlocks = new mapproxy_1.MapProxy(this.client, 'lb', { id: this.id, d: true }, (id) => this.client.getBlockProxy(id));
15
+ this.allLines = new mapproxy_1.MapProxy(this.client, 'll', { id: this.id, d: true }, (id) => new lineproxy_1.LineProxy(id, this.client));
16
+ this.allGroups = new mapproxy_1.MapProxy(this.client, 'lg', { id: this.id, d: true }, (id) => new groupproxy_1.GroupProxy(id, this.client));
17
+ }
18
+ addBlock(def) {
19
+ const properties = {};
20
+ properties['BoundingBox'] = def.boundingBox;
21
+ const id = this.client.sendCommand('cb', {
22
+ 'p': this.id,
23
+ 'c': def.className,
24
+ });
25
+ const block = this.client.getBlockProxy(id);
26
+ for (const key in properties) {
27
+ block.properties.set(key, properties[key]);
28
+ }
29
+ return block;
30
+ }
31
+ addLine(def) {
32
+ const properties = {};
33
+ const setEndpoint = (ep, name) => {
34
+ if (linedefinition_1.isBlockEndpointDefinition(ep)) {
35
+ const bb = ep.connection.getBoundingBox();
36
+ properties[name] = {
37
+ 'Style': ep.style,
38
+ 'x': bb.x + bb.w * ep.linkX,
39
+ 'y': bb.y + bb.h * ep.linkY,
40
+ 'Block': ep.connection.id,
41
+ 'LinkX': ep.linkX,
42
+ 'LinkY': ep.linkY,
43
+ 'Inside': ep.inside,
44
+ 'AutoLink': ep.autoLink,
45
+ 'Padding': ep.padding,
46
+ };
47
+ }
48
+ else if (linedefinition_1.isLineEndpointDefinition(ep)) {
49
+ properties[name] = Object.assign({ 'Style': ep.style, 'Line': ep.connection.id, 'LineP': ep.position }, ep.connection.getRelativePosition(ep.position));
50
+ }
51
+ else {
52
+ properties[name] = {
53
+ 'Style': ep.style,
54
+ 'x': ep.x,
55
+ 'y': ep.y,
56
+ };
57
+ }
58
+ };
59
+ setEndpoint(def.endpoint1, 'Endpoint1');
60
+ setEndpoint(def.endpoint2, 'Endpoint2');
61
+ const id = this.client.sendCommand('cl', {
62
+ 'p': this.id,
63
+ });
64
+ const line = new lineproxy_1.LineProxy(id, this.client);
65
+ for (const key in properties) {
66
+ line.properties.set(key, properties[key]);
67
+ }
68
+ return line;
69
+ }
70
+ setTitle(title) {
71
+ this.properties.set('Title', title);
72
+ }
73
+ getTitle() {
74
+ return this.properties.get('Title');
75
+ }
76
+ delete() {
77
+ this.client.sendCommand('dp', this.id);
78
+ }
79
+ }
80
+ exports.PageProxy = PageProxy;
@@ -0,0 +1,21 @@
1
+ import { BlockProxy } from './document/blockproxy';
2
+ import { ElementProxy } from './document/elementproxy';
3
+ export declare class EditorClient {
4
+ private nextId;
5
+ private readonly oneTimeCallbacks;
6
+ private readonly actions;
7
+ killExtension(): void;
8
+ reloadExtension(): void;
9
+ download(filename: string, data: string, mime: string, base64: boolean): void;
10
+ showModal(title: string, width: number, height: number, content: string): void;
11
+ hideModal(): void;
12
+ registerOneTimeAction(cb: (value: any) => void): number;
13
+ registerAction(name: string, cb: (value: any) => void): void;
14
+ deleteAction(name: string): void;
15
+ actionExists(name: string): boolean;
16
+ sendCommand(name: string, params?: any): any;
17
+ getBlockProxy(id: string): BlockProxy;
18
+ loadBlockClasses(classNames: string[]): Promise<undefined>;
19
+ getElementProxy(id: string): ElementProxy;
20
+ constructor();
21
+ }